r23248 - gnucash/trunk/src - Gnc-Prefs: migrate gnc-plugin gconf machinery
Geert Janssens
gjanssens at code.gnucash.org
Mon Oct 7 10:17:00 EDT 2013
Author: gjanssens
Date: 2013-10-07 10:16:59 -0400 (Mon, 07 Oct 2013)
New Revision: 23248
Trac: http://svn.gnucash.org/trac/changeset/23248
Modified:
gnucash/trunk/src/gnome-utils/gnc-plugin.c
gnucash/trunk/src/gnome-utils/gnc-plugin.h
gnucash/trunk/src/gnome/gnc-plugin-register.c
gnucash/trunk/src/gnome/gnc-plugin-register2.c
Log:
Gnc-Prefs: migrate gnc-plugin gconf machinery
Instead of storing a gconf callback function that will
eventually by attached to the preference when the
plugin is added to a window, simply do this for each
plugin internally in its own add_to_window override
function.
This had already been done in earlier commits for most
plugins. This commit cleans it up for the remaining
plugins and the base plugin code.
Modified: gnucash/trunk/src/gnome/gnc-plugin-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-register.c 2013-10-07 14:16:36 UTC (rev 23247)
+++ gnucash/trunk/src/gnome/gnc-plugin-register.c 2013-10-07 14:16:59 UTC (rev 23248)
@@ -31,18 +31,21 @@
#include "gnc-component-manager.h"
#include "gnc-plugin-register.h"
#include "gnc-plugin-page-register.h"
+#include "gnc-prefs.h"
static void gnc_plugin_register_class_init (GncPluginRegisterClass *klass);
static void gnc_plugin_register_init (GncPluginRegister *plugin);
static void gnc_plugin_register_finalize (GObject *object);
+static void gnc_plugin_register_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+static void gnc_plugin_register_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+
/* Command callbacks */
static void gnc_plugin_register_cmd_general_ledger (GtkAction *action, GncMainWindowActionData *data);
#define PLUGIN_ACTIONS_NAME "gnc-plugin-register-actions"
#define PLUGIN_UI_FILENAME "gnc-plugin-register-ui.xml"
-#define GCONF_REGISTER_SECTION "general/register"
static GtkActionEntry gnc_plugin_actions [] =
{
@@ -70,23 +73,19 @@
************************************************************/
/** This function is called whenever an entry in the general register
- * section of gconf is changed. It does nothing more than kick off a
+ * preferences group is changed. It does nothing more than kick off a
* gui refresh which should be delivered to any open register page.
- * The register pages will then reread their settings from gconf and
+ * The register pages will then reread their preferences and
* update the screen.
*
- * @client Unused.
+ * @prefs Unused.
*
- * @cnxn_id Unused.
+ * @pref Unused.
*
- * @entry Unused.
- *
* @user_data Unused.
*/
static void
-gnc_plugin_register_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+gnc_plugin_register_pref_changed (gpointer prefs, gchar *pref,
gpointer user_data)
{
ENTER("");
@@ -154,15 +153,17 @@
/* plugin info */
plugin_class->plugin_name = GNC_PLUGIN_REGISTER_NAME;
+ /* function overrides */
+ plugin_class->add_to_window = gnc_plugin_register_add_to_window;
+ plugin_class->remove_from_window =
+ gnc_plugin_register_remove_from_window;
+
/* widget addition/removal */
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
plugin_class->actions = gnc_plugin_actions;
plugin_class->n_actions = gnc_plugin_n_actions;
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
- plugin_class->gconf_section = GCONF_REGISTER_SECTION;
- plugin_class->gconf_notifications = gnc_plugin_register_gconf_changed;
-
g_type_class_add_private(klass, sizeof(GncPluginRegisterPrivate));
}
@@ -180,6 +181,55 @@
}
/************************************************************
+ * Plugin Function Implementation *
+ ************************************************************/
+
+/** Initialize the registeru for a window. This function is
+ * called as part of the initialization of a window, after all the
+ * plugin menu items have been added to the menu structure. Its job
+ * is to correctly initialize the register. It does this by
+ * installing a function that listens for preference changes. Each
+ * time a preference changes, it kicks off a gui refresh.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the register.
+ *
+ * @param window A pointer to the gnc-main-window that is being initialized.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_register_add_to_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+ gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL,
+ gnc_plugin_register_pref_changed, window);
+}
+
+
+/** Finalize the register for this window. This function is
+ * called as part of the destruction of a window.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the register. It stops listening for
+ * changes in the register preferences.
+ *
+ * @param window A pointer the gnc-main-window that is being destroyed.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_register_remove_from_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+ gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL,
+ gnc_plugin_register_pref_changed, window);
+}
+
+
+/************************************************************
* Command Callbacks *
************************************************************/
Modified: gnucash/trunk/src/gnome/gnc-plugin-register2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-register2.c 2013-10-07 14:16:36 UTC (rev 23247)
+++ gnucash/trunk/src/gnome/gnc-plugin-register2.c 2013-10-07 14:16:59 UTC (rev 23248)
@@ -31,11 +31,15 @@
#include "gnc-component-manager.h"
#include "gnc-plugin-register2.h"
#include "gnc-plugin-page-register2.h"
+#include "gnc-prefs.h"
static void gnc_plugin_register2_class_init (GncPluginRegister2Class *klass);
static void gnc_plugin_register2_init (GncPluginRegister2 *plugin);
static void gnc_plugin_register2_finalize (GObject *object);
+static void gnc_plugin_register2_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+static void gnc_plugin_register2_remove_from_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
+
/* Command callbacks */
static void gnc_plugin_register2_cmd_general_ledger (GtkAction *action, GncMainWindowActionData *data);
@@ -69,23 +73,19 @@
************************************************************/
/** This function is called whenever an entry in the general register
- * section of gconf is changed. It does nothing more than kick off a
+ * preferences group is changed. It does nothing more than kick off a
* gui refresh which should be delivered to any open register page.
- * The register pages will then reread their settings from gconf and
+ * The register pages will then reread their preferences and
* update the screen.
*
- * @client Unused.
+ * @prefs Unused.
*
- * @cnxn_id Unused.
+ * @pref Unused.
*
- * @entry Unused.
- *
* @user_data Unused.
*/
static void
-gnc_plugin_register2_gconf_changed (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+gnc_plugin_register2_pref_changed (gpointer prefs, gchar *pref,
gpointer user_data)
{
ENTER("");
@@ -153,13 +153,16 @@
/* plugin info */
plugin_class->plugin_name = GNC_PLUGIN_REGISTER2_NAME;
+ /* function overrides */
+ plugin_class->add_to_window = gnc_plugin_register2_add_to_window;
+ plugin_class->remove_from_window =
+ gnc_plugin_register2_remove_from_window;
+
/* widget addition/removal */
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
plugin_class->actions = gnc_plugin_actions;
plugin_class->n_actions = gnc_plugin_n_actions;
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
- plugin_class->gconf_section = GCONF_REGISTER2_SECTION;
- plugin_class->gconf_notifications = gnc_plugin_register2_gconf_changed;
g_type_class_add_private(klass, sizeof(GncPluginRegister2Private));
}
@@ -184,6 +187,54 @@
}
/************************************************************
+ * Plugin Function Implementation *
+ ************************************************************/
+
+/** Initialize the registeru for a window. This function is
+ * called as part of the initialization of a window, after all the
+ * plugin menu items have been added to the menu structure. Its job
+ * is to correctly initialize the register. It does this by
+ * installing a function that listens for preference changes. Each
+ * time a preference changes, it kicks off a gui refresh.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the register.
+ *
+ * @param window A pointer to the gnc-main-window that is being initialized.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_register2_add_to_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+ gnc_prefs_register_cb (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL,
+ gnc_plugin_register2_pref_changed, window);
+}
+
+
+/** Finalize the register for this window. This function is
+ * called as part of the destruction of a window.
+ *
+ * @param plugin A pointer to the gnc-plugin object responsible for
+ * adding/removing the register. It stops listening for
+ * changes in the register preferences.
+ *
+ * @param window A pointer the gnc-main-window that is being destroyed.
+ *
+ * @param type Unused
+ */
+static void
+gnc_plugin_register2_remove_from_window (GncPlugin *plugin,
+ GncMainWindow *window,
+ GQuark type)
+{
+ gnc_prefs_remove_cb_by_func (GNC_PREFS_GROUP_GENERAL_REGISTER, NULL,
+ gnc_plugin_register2_pref_changed, window);
+}
+
+/************************************************************
* Command Callbacks *
************************************************************/
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin.c 2013-10-07 14:16:36 UTC (rev 23247)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin.c 2013-10-07 14:16:59 UTC (rev 23248)
@@ -40,7 +40,6 @@
#include "gnc-plugin.h"
#include "gnc-engine.h"
#include "gnc-filepath-utils.h"
-#include "gnc-gconf-utils.h"
#include "gnc-gnome-utils.h"
#include "gnc-gobject-utils.h"
@@ -150,9 +149,8 @@
/** Add the specified plugin from the specified window. This function
- * will add the page's user interface from the window, set up gconf
- * notifications if the page uses gconf, and call the plugin to
- * perform any plugin specific actions.
+ * will add the page's user interface from the window and call the
+ * plugin to perform any plugin specific actions.
*
* See gnc-plugin.h for documentation on the function arguments. */
void
@@ -191,16 +189,6 @@
}
/*
- * Setup gconf notifications if requested
- */
- if (class->gconf_section && class->gconf_notifications)
- {
- DEBUG ("Requesting notification for section %s", class->gconf_section);
- gnc_gconf_add_notification(G_OBJECT(window), class->gconf_section,
- class->gconf_notifications, GNC_PLUGIN_NAME);
- }
-
- /*
* Do plugin specific actions.
*/
if (GNC_PLUGIN_GET_CLASS (plugin)->add_to_window)
@@ -214,8 +202,7 @@
/* Remove the specified plugin from the specified window. This
* function will call the plugin to perform any plugin specific
- * actions, remove any gconf notifications that were set up for the
- * page, and remove the page's user interface from the window.
+ * actions and remove the page's user interface from the window.
*
* See gnc-plugin.h for documentation on the function arguments. */
void
@@ -241,16 +228,6 @@
}
/*
- * Remove any gconf notifications
- */
- if (class->gconf_section && class->gconf_notifications)
- {
- DEBUG ("Remove notification for section %s", class->gconf_section);
- gnc_gconf_remove_notification (G_OBJECT(window), class->gconf_section,
- GNC_PLUGIN_NAME);
- }
-
- /*
* Update window to remove UI items
*/
if (class->actions_name)
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin.h 2013-10-07 14:16:36 UTC (rev 23247)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin.h 2013-10-07 14:16:59 UTC (rev 23248)
@@ -81,7 +81,6 @@
#include "gnc-main-window.h"
#include "gnc-plugin-page.h"
-#include <gconf/gconf-client.h>
G_BEGIN_DECLS
@@ -137,28 +136,6 @@
* menu/toolbar action items. */
const gchar *ui_filename;
- /* GConf section */
-
- /** The partial section name that will be used in GConf for
- * any preferences that are automatically stored for this
- * page. This will be converted to a full section name by
- * prefixing the string "/apps/gnucash/" to whatever is
- * here. */
- const gchar* gconf_section;
- /** A callback that will be invoked when any key in the
- * specified GConf section is changed.
- *
- * @param client A pointer to the gconf client instance.
- *
- * @param cnxn_id The id number for this callback function.
- *
- * @param entry A pointer to the changed data.
- *
- * @param user_data A pointer to the GncWindow where the
- * plugin is installed. */
- void (* gconf_notifications)
- (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data);
-
/* Virtual Table */
/** A callback that will be invoked when this plugin is added
@@ -204,9 +181,8 @@
/** Add the specified plugin to the specified window. This function
- * will add the page's user interface from the window, set up gconf
- * notifications if the page uses gconf, and call the plugin to
- * perform any plugin specific actions.
+ * will add the page's user interface from the window and call the
+ * plugin to perform any plugin specific actions.
*
* @param plugin The plugin to be added.
*
@@ -221,8 +197,7 @@
/** Remove the specified plugin from the specified window. This
* function will call the plugin to perform any plugin specific
- * actions, remove any gconf notifications that were set up for the
- * page, and remove the page's user interface from the window.
+ * actions and remove the page's user interface from the window.
*
* @param plugin The plugin to be removed.
*
More information about the gnucash-changes
mailing list