r23237 - gnucash/trunk/src/business/business-gnome - Gnc-Prefs: migrate extra_toolbuttons preference (business option)
Geert Janssens
gjanssens at code.gnucash.org
Mon Oct 7 10:12:13 EDT 2013
Author: gjanssens
Date: 2013-10-07 10:12:13 -0400 (Mon, 07 Oct 2013)
New Revision: 23237
Trac: http://svn.gnucash.org/trac/changeset/23237
Modified:
gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade
Log:
Gnc-Prefs: migrate extra_toolbuttons preference (business option)
Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c 2013-10-07 14:12:01 UTC (rev 23236)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-business.c 2013-10-07 14:12:13 UTC (rev 23237)
@@ -61,10 +61,6 @@
static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass);
static void gnc_plugin_business_init (GncPluginBusiness *plugin);
static void gnc_plugin_business_finalize (GObject *object);
-static void gnc_plugin_business_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data);
static void gnc_plugin_business_add_to_window (GncPlugin *plugin,
GncMainWindow *window,
GQuark type);
@@ -137,6 +133,8 @@
#define PLUGIN_ACTIONS_NAME "gnc-plugin-business-actions"
#define PLUGIN_UI_FILENAME "gnc-plugin-business-ui.xml"
+#define GNC_PREF_EXTRA_TOOLBUTTONS "enable_toolbuttons"
+
/** This variable maintains a pointer to the last window where a
* Business command was executed. It is used to determine where new
* invoices will be placed. This is a HACK done instead of trudging
@@ -399,8 +397,8 @@
plugin_class->n_actions = gnc_plugin_n_actions;
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
- plugin_class->gconf_notifications = gnc_plugin_business_gconf_changed;
- plugin_class->gconf_section = GCONF_SECTION_INVOICE;
+ plugin_class->gconf_notifications = NULL;
+ plugin_class->gconf_section = NULL;
g_type_class_add_private(klass, sizeof(GncPluginBusinessPrivate));
}
@@ -897,7 +895,6 @@
GncPluginPage *page,
gpointer user_data)
{
-// g_message("gnc_plugin_business_main_window_page_changed, page=%p", page);
gnc_plugin_business_update_menus(page);
update_inactive_actions(page);
}
@@ -1025,16 +1022,13 @@
NULL
};
-/* The code below will set the visibility of some extra toolbar
- * buttons based on a gconf key setting. */
-static void set_toolbuttons_visibility(GncMainWindow *mainwindow,
- gboolean visible)
+/* Bind the visibility of the extra toolbar buttons to the
+ * enable_toolbuttons preference. */
+static void bind_toolbuttons_visibility (GncMainWindow *mainwindow)
{
GtkActionGroup *action_group;
const char **iter;
- /*g_warning("about to set button visibility %d", visible);*/
-
g_return_if_fail(mainwindow);
g_return_if_fail(GNC_IS_MAIN_WINDOW(mainwindow));
@@ -1047,40 +1041,10 @@
{
/* Set the action's visibility */
GtkAction *action = gtk_action_group_get_action (action_group, *iter);
- gtk_action_set_visible(action, visible);
+ gnc_prefs_bind (GNC_PREFS_GROUP_INVOICE, GNC_PREF_EXTRA_TOOLBUTTONS, G_OBJECT (action), "visible");
}
}
-static void update_extra_toolbuttons(GncMainWindow *mainwindow)
-{
- gboolean value = gnc_gconf_get_bool(GCONF_SECTION_INVOICE,
- "enable_toolbuttons", NULL);
- set_toolbuttons_visibility(mainwindow, value);
-}
-
-/** This function is called whenever an entry in the business invoice
- * section of gconf is changed. If the modified gconf entry concerns
- * our toolbar buttons, we update their visibility status. */
-static void
-gnc_plugin_business_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- GncMainWindow *mainwindow = GNC_MAIN_WINDOW(user_data);
- const char* full_gconf_path =
- GCONF_PATH "/" GCONF_SECTION_INVOICE "/enable_toolbuttons";
- const char* entry_key = gconf_entry_get_key(entry);
-
- if (!entry_key)
- return;
-
- if (g_strcmp0(entry_key, full_gconf_path) == 0)
- {
- update_extra_toolbuttons(mainwindow);
- }
-}
-
/**
* Called when this plugin is added to a main window. Connect a few callbacks
* here to track page changes.
@@ -1091,8 +1055,7 @@
GncMainWindow *mainwindow,
GQuark type)
{
-// g_message("gnc_plugin_business_add_to_window");
- update_extra_toolbuttons(mainwindow);
+ bind_toolbuttons_visibility (mainwindow);
g_signal_connect(mainwindow, "page_changed",
G_CALLBACK(gnc_plugin_business_main_window_page_changed),
Modified: gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade
===================================================================
--- gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade 2013-10-07 14:12:01 UTC (rev 23236)
+++ gnucash/trunk/src/business/business-gnome/gtkbuilder/business-prefs.glade 2013-10-07 14:12:13 UTC (rev 23237)
@@ -240,7 +240,7 @@
</packing>
</child>
<child>
- <object class="GtkCheckButton" id="gconf/dialogs/business/invoice/enable_toolbuttons">
+ <object class="GtkCheckButton" id="pref/dialogs.business.invoice/enable_toolbuttons">
<property name="label" translatable="yes">Enable extra _buttons</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
More information about the gnucash-changes
mailing list