r23235 - gnucash/trunk/src - Gnc-Prefs: migrate GtkCheckbutton widgets (and associated preferences) - first batch

Geert Janssens gjanssens at code.gnucash.org
Mon Oct 7 10:11:43 EDT 2013


Author: gjanssens
Date: 2013-10-07 10:11:42 -0400 (Mon, 07 Oct 2013)
New Revision: 23235
Trac: http://svn.gnucash.org/trac/changeset/23235

Modified:
   gnucash/trunk/src/app-utils/gnc-prefs-utils.c
   gnucash/trunk/src/gnome-utils/dialog-preferences.c
   gnucash/trunk/src/gnome-utils/dialog-totd.c
   gnucash/trunk/src/gnome-utils/dialog-transfer.c
   gnucash/trunk/src/gnome-utils/dialog-utils.c
   gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
   gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
   gnucash/trunk/src/gnome-utils/window-main-summarybar.c
   gnucash/trunk/src/gnome/assistant-hierarchy.c
   gnucash/trunk/src/gnome/window-reconcile.c
   gnucash/trunk/src/gnome/window-reconcile2.c
   gnucash/trunk/src/register/ledger-core/split-register-model.c
Log:
Gnc-Prefs: migrate GtkCheckbutton widgets (and associated preferences) - first batch

Modified: gnucash/trunk/src/app-utils/gnc-prefs-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-prefs-utils.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/app-utils/gnc-prefs-utils.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -31,6 +31,11 @@
 
 static QofLogModule log_module = G_LOG_DOMAIN;
 
+/* Keys used for core preferences */
+#define GNC_PREF_FILE_COMPRESSION  "file_compression"
+#define GNC_PREF_RETAIN_TYPE       "retain_type"
+#define GNC_PREF_RETAIN_DAYS       "retain_days"
+
 /***************************************************************
  * Initialization                                              *
  ***************************************************************/
@@ -65,9 +70,9 @@
 }
 
 static void
-file_compression_changed_cb(GConfEntry *entry, gpointer user_data)
+file_compression_changed_cb(gpointer gsettings, gchar *key, gpointer user_data)
 {
-    gboolean file_compression = gnc_gconf_get_bool(GCONF_GENERAL, KEY_FILE_COMPRESSION, NULL);
+    gboolean file_compression = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION);
     gnc_prefs_set_file_save_compressed (file_compression);
 }
 
@@ -79,12 +84,13 @@
     /* Add hooks to update core preferences whenever the associated gconf key changes */
     gnc_gconf_general_register_cb(KEY_RETAIN_DAYS, file_retain_changed_cb, NULL);
     gnc_gconf_general_register_cb(KEY_RETAIN_TYPE, file_retain_type_changed_cb, NULL);
-    gnc_gconf_general_register_cb(KEY_FILE_COMPRESSION, file_compression_changed_cb, NULL);
+    gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_FILE_COMPRESSION,
+                              (GCallback) file_compression_changed_cb, NULL);
 
     /* Call the hooks once manually to initialize the core preferences */
     file_retain_changed_cb (NULL, NULL);
     file_retain_type_changed_cb (NULL, NULL);
-    file_compression_changed_cb (NULL, NULL);
+    file_compression_changed_cb (NULL, NULL, NULL);
 
     /* Backwards compatibility code. Pre 2.3.15, 0 retain_days meant
      * "keep forever". From 2.3.15 on this is controlled via a multiple

Modified: gnucash/trunk/src/gnome/assistant-hierarchy.c
===================================================================
--- gnucash/trunk/src/gnome/assistant-hierarchy.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome/assistant-hierarchy.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -41,7 +41,7 @@
 #include "gnc-currency-edit.h"
 #include "gnc-exp-parser.h"
 #include "gnc-general-select.h"
-#include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-hooks.h"
 #include "gnc-component-manager.h"
 #include "gnc-path.h"
@@ -1172,7 +1172,7 @@
 static void
 gnc_ui_hierarchy_assistant_hook (void)
 {
-    if (gnc_gconf_get_bool(GCONF_SECTION, "show_on_new_file", NULL))
+    if (gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_SHOW_ON_NEW_FILE))
     {
         gnc_ui_hierarchy_assistant_with_callback(TRUE, create_account_page);
     }

Modified: gnucash/trunk/src/gnome/window-reconcile.c
===================================================================
--- gnucash/trunk/src/gnome/window-reconcile.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome/window-reconcile.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -1064,7 +1064,7 @@
     gboolean formal;
     gchar *title;
 
-    formal = gnc_gconf_get_bool(GCONF_GENERAL, KEY_ACCOUNTING_LABELS, NULL);
+    formal = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS);
 
     if (formal)
         title = _("Debits");

Modified: gnucash/trunk/src/gnome/window-reconcile2.c
===================================================================
--- gnucash/trunk/src/gnome/window-reconcile2.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome/window-reconcile2.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -1064,7 +1064,7 @@
     gboolean formal;
     gchar *title;
 
-    formal = gnc_gconf_get_bool (GCONF_GENERAL, KEY_ACCOUNTING_LABELS, NULL);
+    formal = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS);
 
     if (formal)
         title = _("Debits");

Modified: gnucash/trunk/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-preferences.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/dialog-preferences.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -1350,8 +1350,37 @@
     gtk_widget_show_all(GTK_WIDGET(fb));
 }
 
+/****************************************************************************/
 
+/** Connect a GtkCheckButton widget to its stored value in the preferences database.
+ *
+ *  @internal
+ *
+ *  @param button A pointer to the check button that should be
+ *  connected.
+ */
+static void
+gnc_prefs_connect_check_button (GtkCheckButton *button)
+{
+    gchar *group, *pref;
+    gboolean active;
 
+    g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
+
+    gnc_prefs_split_widget_name (gtk_buildable_get_name(GTK_BUILDABLE(button)), &group, &pref);
+
+//    active = gnc_prefs_get_bool (group, pref);
+//    DEBUG(" Checkbox %s/%s initially %sactive", group, pref, active ? "" : "in");
+//    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
+
+    gnc_prefs_bind (group, pref, G_OBJECT (button), "active");
+
+    g_free (group);
+    g_free (pref);
+}
+
+
+
 /****************************************************************************/
 
 /********************/
@@ -1503,6 +1532,11 @@
         DEBUG("  %s - entry", name);
         gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
     }
+    else if (GTK_IS_CHECK_BUTTON(widget))
+    {
+        DEBUG("  %s - check button", name);
+        gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget));
+    }
     else
     {
         DEBUG("  %s - unsupported %s", name,

Modified: gnucash/trunk/src/gnome-utils/dialog-totd.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-totd.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/dialog-totd.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -32,13 +32,14 @@
 #include "gnc-component-manager.h"
 #include "gnc-filepath-utils.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-gnome-utils.h"
 #include "gnc-engine.h"
 
 #define GCONF_SECTION   "dialogs/tip_of_the_day"
 #define GNC_PREFS_GROUP      "dialogs.totd"
 #define KEY_CURRENT_TIP "current_tip"
-#define KEY_SHOW_TIPS   "show_at_startup"
+#define GNC_PREF_SHOW_TIPS   "show_at_startup"
 #define DIALOG_TOTD_CM_CLASS "dialog-totd"
 
 #define GNC_RESPONSE_FORWARD 1
@@ -165,7 +166,7 @@
     gboolean active;
 
     active = gtk_toggle_button_get_active(button);
-    gnc_gconf_set_bool(GCONF_SECTION, KEY_SHOW_TIPS, active, NULL);
+    gnc_prefs_set_bool(GNC_PREFS_GROUP, GNC_PREF_SHOW_TIPS, active);
 }
 
 
@@ -313,7 +314,7 @@
 
     totd_dialog = g_new0 (TotdDialog, 1);
 
-    show_tips = gnc_gconf_get_bool(GCONF_SECTION, KEY_SHOW_TIPS, NULL);
+    show_tips = gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_SHOW_TIPS);
     if (startup && !show_tips)
         return;
 

Modified: gnucash/trunk/src/gnome-utils/dialog-transfer.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-transfer.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/dialog-transfer.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -36,7 +36,7 @@
 #include "gnc-engine.h"
 #include "gnc-euro.h"
 #include "gnc-exp-parser.h"
-#include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-gui-query.h"
 #include "gnc-pricedb.h"
 #include "gnc-tree-view-account.h"
@@ -535,8 +535,8 @@
     AccountTreeFilterInfo *info;
     GtkBuilder *builder = g_object_get_data (G_OBJECT (xferData->dialog), "builder");
 
-    use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
-                            KEY_ACCOUNTING_LABELS, NULL);
+    use_accounting_labels = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
+                                               GNC_PREF_ACCOUNTING_LABELS);
 
     /* In "normal" mode (non accounting terms) the account where the
      * money comes from is displayed on the left side and the account
@@ -1766,8 +1766,8 @@
     GtkBuilder *builder;
     gboolean  use_accounting_labels;
 
-    use_accounting_labels = gnc_gconf_get_bool(GCONF_GENERAL,
-                            KEY_ACCOUNTING_LABELS, NULL);
+    use_accounting_labels = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
+                                               GNC_PREF_ACCOUNTING_LABELS);
 
     ENTER(" ");
     builder = gtk_builder_new();

Modified: gnucash/trunk/src/gnome-utils/dialog-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-utils.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/dialog-utils.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -114,7 +114,7 @@
     GdkColormap *cm;
     GtkStyle *style;
 
-    if (!gnc_gconf_get_bool(GCONF_GENERAL, "red_for_negative", NULL))
+    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED))
         return;
 
     cm = gtk_widget_get_colormap(GTK_WIDGET(label));

Modified: gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-gnome-utils.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -32,6 +32,7 @@
 
 #include "gnc-gconf-utils.h"
 #include "gnc-prefs-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-gnome-utils.h"
 //#include "gnc-html.h"
 #include "gnc-engine.h"
@@ -96,9 +97,8 @@
     gboolean num_source_is_split_action;
 
     if (!odb) return;
-    num_source_is_split_action = gnc_gconf_get_bool(GCONF_GENERAL,
-                                                    KEY_NUM_SOURCE,
-                                                    NULL);
+    num_source_is_split_action = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
+                                                    GNC_PREF_NUM_SOURCE);
     if (num_source_is_split_action)
     {
         num_source_option = gnc_option_db_get_option_by_name(odb,

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -64,6 +64,7 @@
 #include "gnc-window.h"
 #include "gnc-prefs.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "option-util.h"
 // +JSLED
 //#include "gnc-html.h"
@@ -96,7 +97,7 @@
 #define KEY_TAB_NEXT_RECENT      "tab_next_recent"
 #define KEY_TAB_POSITION         "tab_position"
 #define KEY_TAB_WIDTH            "tab_width"
-#define KEY_TAB_COLOR            "show_account_color_tabs"
+#define GNC_PREF_TAB_COLOR            "show_account_color_tabs"
 
 #define GNC_MAIN_WINDOW_NAME "GncMainWindow"
 
@@ -1952,18 +1953,17 @@
  *  @param user_data GncMainWindow.
  */
 static void
-gnc_main_window_update_tab_color (GConfEntry *entry, gpointer user_data)
+gnc_main_window_update_tab_color (gpointer gsettings, gchar *key, gpointer user_data)
 {
     GncMainWindowPrivate *priv;
     GncMainWindow        *window;
-    gboolean              new_value;
 
     ENTER(" ");
     g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
     window = user_data;
     priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
-    new_value = gconf_value_get_bool(entry->value);
-    priv->show_color_tabs = new_value;
+    if (g_strcmp0 (GNC_PREF_TAB_COLOR, key) == 0)
+        priv->show_color_tabs = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_COLOR);
     gnc_main_window_foreach_page (gnc_main_window_update_tab_color_one_page, window);
     LEAVE(" ");
 }
@@ -2468,11 +2468,12 @@
         qof_event_register_handler(gnc_main_window_event_handler, window);
 
     /* Get the show_color_tabs value from gconf */
-    priv->show_color_tabs = gnc_gconf_get_bool(GCONF_GENERAL, KEY_TAB_COLOR, NULL);
+    priv->show_color_tabs = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_COLOR);
 
-    gnc_gconf_general_register_cb (KEY_TAB_COLOR,
-                                   gnc_main_window_update_tab_color,
-                                   window);
+    gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
+                           GNC_PREF_TAB_COLOR,
+                           gnc_main_window_update_tab_color,
+                           window);
 
     gnc_main_window_setup_window (window);
     gnc_gobject_tracking_remember(G_OBJECT(window),
@@ -2541,6 +2542,10 @@
                                       GNC_MAIN_WINDOW_NAME);
         gnc_gconf_remove_notification(G_OBJECT(window), GCONF_GENERAL,
                                       GNC_MAIN_WINDOW_NAME);
+        gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                     GNC_PREF_TAB_COLOR,
+                                     gnc_main_window_update_tab_color,
+                                     window);
 
         qof_event_unregister_handler(priv->event_handler_id);
         priv->event_handler_id = 0;

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -34,7 +34,7 @@
 #include "Account.h"
 #include "gnc-accounting-period.h"
 #include "gnc-commodity.h"
-#include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-engine.h"
 #include "gnc-event.h"
 #include "gnc-gobject-utils.h"
@@ -109,23 +109,21 @@
 
 /** Tell the GncTreeModelAccount code to update the color that it will
  *  use for negative numbers.  This function will iterate over all
- *  existing models and update their setting from gconf.
+ *  existing models and update their setting.
  *
  *  @internal
  */
 static void
-gnc_tree_model_account_update_color (GConfEntry *entry, gpointer user_data)
+gnc_tree_model_account_update_color (gpointer gsettings, gchar *key, gpointer user_data)
 {
     GncTreeModelAccountPrivate *priv;
     GncTreeModelAccount *model;
-    GConfValue *value;
     gboolean use_red;
 
     g_return_if_fail(GNC_IS_TREE_MODEL_ACCOUNT(user_data));
     model = user_data;
     priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
-    value = gconf_entry_get_value(entry);
-    use_red = gconf_value_get_bool(value);
+    use_red = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
     priv->negative_color = use_red ? "red" : "black";
 }
 /************************************************************/
@@ -202,16 +200,16 @@
         model->stamp = g_random_int ();
     }
 
-    red = gnc_gconf_get_bool(GCONF_GENERAL, KEY_NEGATIVE_IN_RED, NULL);
+    red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
 
     priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
     priv->book = NULL;
     priv->root = NULL;
     priv->negative_color = red ? "red" : "black";
 
-    gnc_gconf_general_register_cb(KEY_NEGATIVE_IN_RED,
-                                  gnc_tree_model_account_update_color,
-                                  model);
+    gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
+                          gnc_tree_model_account_update_color,
+                          model);
 
     LEAVE(" ");
 }
@@ -230,10 +228,6 @@
     model = GNC_TREE_MODEL_ACCOUNT (object);
     priv = GNC_TREE_MODEL_ACCOUNT_GET_PRIVATE(model);
 
-    gnc_gconf_general_remove_cb(KEY_NEGATIVE_IN_RED,
-                                gnc_tree_model_account_update_color,
-                                model);
-
     priv->book = NULL;
 
     if (G_OBJECT_CLASS (parent_class)->finalize)
@@ -261,7 +255,7 @@
         priv->event_handler_id = 0;
     }
 
-    gnc_gconf_general_remove_cb(KEY_NEGATIVE_IN_RED,
+    gnc_prefs_remove_cb_by_func(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
                                 gnc_tree_model_account_update_color,
                                 model);
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-owner.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -33,6 +33,7 @@
 #include "gncOwner.h"
 #include "gnc-commodity.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-engine.h"
 #include "gnc-event.h"
 #include "gnc-gobject-utils.h"
@@ -108,23 +109,21 @@
 
 /** Tell the GncTreeModelOwner code to update the color that it will
  *  use for negative numbers.  This function will iterate over all
- *  existing models and update their setting from gconf.
+ *  existing models and update their setting.
  *
  *  @internal
  */
 static void
-gnc_tree_model_owner_update_color (GConfEntry *entry, gpointer user_data)
+gnc_tree_model_owner_update_color (gpointer gsettings, gchar *key, gpointer user_data)
 {
     GncTreeModelOwnerPrivate *priv;
     GncTreeModelOwner *model;
-    GConfValue *value;
     gboolean use_red;
 
     g_return_if_fail(GNC_IS_TREE_MODEL_OWNER(user_data));
     model = user_data;
     priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
-    value = gconf_entry_get_value(entry);
-    use_red = gconf_value_get_bool(value);
+    use_red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
     priv->negative_color = use_red ? "red" : "black";
 }
 /************************************************************/
@@ -201,7 +200,7 @@
         model->stamp = g_random_int ();
     }
 
-    red = gnc_gconf_get_bool(GCONF_GENERAL, KEY_NEGATIVE_IN_RED, NULL);
+    red = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
 
     priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
     priv->book       = NULL;
@@ -209,9 +208,9 @@
     priv->owner_type = GNC_OWNER_NONE;
     priv->negative_color = red ? "red" : "black";
 
-    gnc_gconf_general_register_cb(KEY_NEGATIVE_IN_RED,
-                                  gnc_tree_model_owner_update_color,
-                                  model);
+    gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
+                          gnc_tree_model_owner_update_color,
+                          model);
 
     LEAVE(" ");
 }
@@ -230,10 +229,6 @@
     model = GNC_TREE_MODEL_OWNER (object);
     priv = GNC_TREE_MODEL_OWNER_GET_PRIVATE(model);
 
-    gnc_gconf_general_remove_cb(KEY_NEGATIVE_IN_RED,
-                                gnc_tree_model_owner_update_color,
-                                model);
-
     priv->book       = NULL;
     priv->owner_list = NULL;
 
@@ -262,7 +257,7 @@
         priv->event_handler_id = 0;
     }
 
-    gnc_gconf_general_remove_cb(KEY_NEGATIVE_IN_RED,
+    gnc_prefs_remove_cb_by_func(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
                                 gnc_tree_model_owner_update_color,
                                 model);
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -34,6 +34,7 @@
 #include "gnc-component-manager.h"
 #include "gnc-commodity.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-engine.h"
 #include "gnc-event.h"
 #include "gnc-gobject-utils.h"
@@ -366,6 +367,31 @@
 
 
 static void
+gnc_tree_model_split_reg_prefs_changed (gpointer gsettings, gchar *key, gpointer user_data)
+{
+    GncTreeModelSplitReg *model = user_data;
+
+    g_return_if_fail (key);
+
+    if (model == NULL)
+        return;
+
+    if (g_str_has_suffix (key, GNC_PREF_ACCOUNTING_LABELS))
+    {
+        model->use_accounting_labels = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS);
+    }
+    else if (g_str_has_suffix (key, GNC_PREF_ACCOUNT_SEPARATOR))
+    {
+        model->separator_changed = TRUE;
+    }
+    else
+    {
+        g_warning("gnc_tree_model_split_reg_prefs_changed: Unknown gsettings key %s", key);
+    }
+}
+
+
+static void
 gnc_tree_model_split_reg_init (GncTreeModelSplitReg *model)
 {
     GncTreeModelSplitRegPrivate *priv;
@@ -378,9 +404,10 @@
 
     model->priv = g_new0 (GncTreeModelSplitRegPrivate, 1);
 
-    gnc_gconf_general_register_cb (KEY_ACCOUNTING_LABELS,
-                                  gnc_tree_model_split_reg_gconf_changed,
-                                  model);
+    gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
+                           GNC_PREF_ACCOUNTING_LABELS,
+                           gnc_tree_model_split_reg_prefs_changed,
+                           model);
     gnc_gconf_general_register_cb (KEY_ACCOUNT_SEPARATOR,
                                   gnc_tree_model_split_reg_gconf_changed,
                                   model);
@@ -491,7 +518,7 @@
     priv->bsplit_node = g_list_append (priv->bsplit_node, priv->bsplit);
 
     /* Setup some config entries */
-    model->use_accounting_labels = gnc_gconf_get_bool (GCONF_GENERAL, KEY_ACCOUNTING_LABELS, NULL);
+    model->use_accounting_labels = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNTING_LABELS);
     model->use_theme_colors = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "use_theme_colors", NULL);
     model->alt_colors_by_txn = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "alternate_color_by_transaction", NULL);
     model->read_only = FALSE;
@@ -947,9 +974,10 @@
     g_object_unref (priv->action_list);
     g_object_unref (priv->account_list);
 
-    gnc_gconf_general_remove_cb (KEY_ACCOUNTING_LABELS,
-                                gnc_tree_model_split_reg_gconf_changed,
-                                model);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_ACCOUNTING_LABELS,
+                                 gnc_tree_model_split_reg_prefs_changed,
+                                 model);
     gnc_gconf_general_remove_cb (KEY_ACCOUNT_SEPARATOR,
                                 gnc_tree_model_split_reg_gconf_changed,
                                 model);

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -40,7 +40,7 @@
 #include "gnc-engine.h"
 #include "gnc-glib-utils.h"
 #include "gnc-gobject-utils.h"
-#include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-hooks.h"
 #include "gnc-session.h"
 #include "gnc-icons.h"
@@ -48,7 +48,8 @@
 #include "dialog-utils.h"
 #include "window-main-summarybar.h"
 
-#define SAMPLE_ACCOUNT_VALUE "$1,000,000.00"
+#define SAMPLE_ACCOUNT_VALUE   "$1,000,000.00"
+#define GNC_PREF_ACCOUNT_COLOR "show_account_color"
 
 /** Static Globals *******************************************************/
 
@@ -84,7 +85,7 @@
                                 GtkTreeIter       *iter,
                                 gpointer           view);
 
-static void gnc_tree_view_account_color_update (GConfEntry *entry, gpointer user_data);
+static void gnc_tree_view_account_color_update (gpointer gsettings, gchar *key, gpointer user_data);
 
 
 typedef struct GncTreeViewAccountPrivate
@@ -189,9 +190,10 @@
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
 
-    gnc_gconf_general_register_cb("show_account_color",
-                                  gnc_tree_view_account_color_update,
-                                  view);
+    gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL,
+                           GNC_PREF_ACCOUNT_COLOR,
+                           gnc_tree_view_account_color_update,
+                           view);
 
     gnc_init_account_view_info(&priv->avi);
 }
@@ -210,9 +212,10 @@
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(account_view);
 
-    gnc_gconf_general_remove_cb("show_account_color",
-                                gnc_tree_view_account_color_update,
-                                account_view);
+    gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL,
+                                 GNC_PREF_ACCOUNT_COLOR,
+                                 gnc_tree_view_account_color_update,
+                                 account_view);
     if (priv->filter_destroy)
     {
         priv->filter_destroy(priv->filter_data);
@@ -643,17 +646,16 @@
  *  @internal
  */
 static void
-gnc_tree_view_account_color_update (GConfEntry *entry, gpointer user_data)
+gnc_tree_view_account_color_update (gpointer gsettings, gchar *key, gpointer user_data)
 {
     GncTreeViewAccountPrivate *priv;
     GncTreeViewAccount *view;
-    GConfValue *value;
 
     g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(user_data));
     view = user_data;
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
-    value = gconf_entry_get_value(entry);
-    priv->show_account_color = gconf_value_get_bool(value);
+    if (g_strcmp0 (key, GNC_PREF_ACCOUNT_COLOR) == 0)
+        priv->show_account_color = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, key);
 }
 
 /************************************************************/
@@ -684,8 +686,8 @@
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(GNC_TREE_VIEW_ACCOUNT (view));
 
-    /* Get the show_account_color value from gconf */
-    priv->show_account_color = gnc_gconf_get_bool(GCONF_GENERAL, "show_account_color", NULL);
+    /* Get the show_account_color value from gsettings */
+    priv->show_account_color = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_ACCOUNT_COLOR);
 
     /* Create/get a pointer to the existing model for this set of books. */
     model = gnc_tree_model_account_new (root);

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -40,6 +40,7 @@
 #include "gnc-ui.h"
 #include "dialog-utils.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "Transaction.h"
 #include "engine-helpers.h"
 #include "Scrub.h"
@@ -474,7 +475,7 @@
     view->priv->key_length = gnc_gconf_get_float(GCONF_GENERAL_REGISTER, "key_length", NULL);
 
     view->priv->acct_short_names = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "show_leaf_account_names", NULL);
-    view->priv->negative_in_red = gnc_gconf_get_bool (GCONF_GENERAL, KEY_NEGATIVE_IN_RED, NULL);
+    view->priv->negative_in_red = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED);
     view->priv->use_horizontal_lines = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
                                   "draw_horizontal_lines", NULL);
 
@@ -564,14 +565,14 @@
 
     model->use_theme_colors = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
                               "use_theme_colors", NULL);
-    model->use_accounting_labels = gnc_gconf_get_bool (GCONF_GENERAL,
-                               KEY_ACCOUNTING_LABELS, NULL);
+    model->use_accounting_labels = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL,
+                                                       GNC_PREF_ACCOUNTING_LABELS);
 
     model->alt_colors_by_txn = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
                                "alternate_color_by_transaction", NULL);
 
-    view->priv->negative_in_red = gnc_gconf_get_bool (GCONF_GENERAL,
-                               KEY_NEGATIVE_IN_RED, NULL);
+    view->priv->negative_in_red = gnc_prefs_get_bool (GNC_PREFS_GROUP_GENERAL,
+                                                      GNC_PREF_NEGATIVE_IN_RED);
 }
 
 

Modified: gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade	2013-10-07 14:11:42 UTC (rev 23235)
@@ -123,7 +123,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/window/pages/account_tree/summary/grand_total">
+                  <object class="GtkCheckButton" id="pref/window.pages.account_tree.summary/grand_total">
                     <property name="label" translatable="yes">Include _grand total</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -144,7 +144,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/window/pages/account_tree/summary/non_currency">
+                  <object class="GtkCheckButton" id="pref/window.pages.account_tree.summary/non_currency">
                     <property name="label" translatable="yes">Include _non-currency totals</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -486,7 +486,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/use_accounting_labels">
+                  <object class="GtkCheckButton" id="pref/general/use_accounting_labels">
                     <property name="label" translatable="yes">Use _formal accounting labels</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -859,7 +859,7 @@
                   <placeholder/>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/show_account_color">
+                  <object class="GtkCheckButton" id="pref/general/show_account_color">
                     <property name="label" translatable="yes">Show the Account Color as background</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -893,7 +893,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/show_account_color_tabs">
+                  <object class="GtkCheckButton" id="pref/general/show_account_color_tabs">
                     <property name="label" translatable="yes">Show the Account Color on tabs</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1542,7 +1542,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/dialogs/new_hierarchy/show_on_new_file">
+                  <object class="GtkCheckButton" id="pref/dialogs.new_hierarchy/show_on_new_file">
                     <property name="label" translatable="yes">Perform account list _setup on new file</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1563,7 +1563,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/num_source">
+                  <object class="GtkCheckButton" id="pref/general/num_source">
                     <property name="label" translatable="yes">Set book option on new files to use split "action" field for "Num" field on registers/reports</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1584,7 +1584,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/dialogs/tip_of_the_day/show_at_startup">
+                  <object class="GtkCheckButton" id="pref/dialogs.totd/show_at_startup">
                     <property name="label" translatable="yes">Display "_tip of the day" dialog</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1673,7 +1673,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/file_compression">
+                  <object class="GtkCheckButton" id="pref/general/file_compression">
                     <property name="label" translatable="yes">Com_press files</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1764,7 +1764,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/auto_decimal_point">
+                  <object class="GtkCheckButton" id="pref/general/auto_decimal_point">
                     <property name="label" translatable="yes">_Automatic decimal point</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
@@ -1785,7 +1785,7 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkCheckButton" id="gconf/general/negative_in_red">
+                  <object class="GtkCheckButton" id="pref/general/negative_in_red">
                     <property name="label" translatable="yes">Display ne_gative amounts in red</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>

Modified: gnucash/trunk/src/gnome-utils/window-main-summarybar.c
===================================================================
--- gnucash/trunk/src/gnome-utils/window-main-summarybar.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/gnome-utils/window-main-summarybar.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -34,6 +34,7 @@
 #include "gnc-euro.h"
 #include "gnc-event.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-locale-utils.h"
 #include "gnc-ui-util.h"
 #include "window-main-summarybar.h"
@@ -50,9 +51,12 @@
 #define WINDOW_SUMMARYBAR_CM_CLASS "summary-bar"
 
 #define GCONF_SECTION    "window/pages/account_tree/summary"
-#define KEY_GRAND_TOTAL  "grand_total"
 #define KEY_NON_CURRENCY "non_currency"
 
+#define GNC_PREFS_GROUP       "window.pages.account_tree.summary"
+#define GNC_PREF_GRAND_TOTAL  "grand_total"
+#define GNC_PREF_NON_CURRENCY "non_currency"
+
 /**
  * An accumulator for a given currency.
  *
@@ -358,9 +362,9 @@
     }
 
     options.grand_total =
-        gnc_gconf_get_bool(GCONF_SECTION, KEY_GRAND_TOTAL, NULL);
+        gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_GRAND_TOTAL);
     options.non_currency =
-        gnc_gconf_get_bool(GCONF_SECTION, KEY_NON_CURRENCY, NULL);
+        gnc_prefs_get_bool(GNC_PREFS_GROUP, GNC_PREF_NON_CURRENCY);
     options.start_date = gnc_accounting_period_fiscal_start();
     options.end_date = gnc_accounting_period_fiscal_end();
 

Modified: gnucash/trunk/src/register/ledger-core/split-register-model.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-model.c	2013-10-07 14:11:18 UTC (rev 23234)
+++ gnucash/trunk/src/register/ledger-core/split-register-model.c	2013-10-07 14:11:42 UTC (rev 23235)
@@ -29,6 +29,7 @@
 #include "dialog-utils.h"
 #include "gnc-engine.h"
 #include "gnc-gconf-utils.h"
+#include "gnc-prefs.h"
 #include "gnc-ui.h"
 #include "pricecell.h"
 #include "recncell.h"
@@ -2266,25 +2267,22 @@
 
 
 static void
-gnc_split_register_colorize_negative (GConfEntry *entry, gpointer unused)
+gnc_split_register_colorize_negative (gpointer gsettings, gchar *key, gpointer unused)
 {
-    GConfValue *value;
-
-    value = gconf_entry_get_value(entry);
-    use_red_for_negative = gconf_value_get_bool(value);
+    use_red_for_negative = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
+                                              GNC_PREF_NEGATIVE_IN_RED);
 }
 
 
 static gpointer
 gnc_split_register_model_add_hooks (gpointer unused)
 {
-    gnc_gconf_general_register_cb(KEY_NEGATIVE_IN_RED,
-                                  gnc_split_register_colorize_negative,
-                                  NULL);
+    gnc_prefs_register_cb(GNC_PREFS_GROUP_GENERAL, GNC_PREF_NEGATIVE_IN_RED,
+                          gnc_split_register_colorize_negative,
+                          NULL);
     /* Get the initial value */
-    use_red_for_negative = gnc_gconf_get_bool(GCONF_GENERAL,
-                           KEY_NEGATIVE_IN_RED,
-                           NULL);
+    use_red_for_negative = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL,
+                                              GNC_PREF_NEGATIVE_IN_RED);
     return NULL;
 }
 



More information about the gnucash-changes mailing list