[nautilus-actions] Monitor all runtime preferences with only one callback
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Monitor all runtime preferences with only one callback
- Date: Wed, 19 Jan 2011 21:50:59 +0000 (UTC)
commit f406bf58cd41173faf16ead9f878f0f096671f12
Author: Pierre <pierre vfedora13 virtuals pwi>
Date: Wed Jan 12 11:36:31 2011 +0100
Monitor all runtime preferences with only one callback
ChangeLog | 3 +
src/plugin-menu/nautilus-actions.c | 118 ++++++++++--------------------------
2 files changed, 35 insertions(+), 86 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1122efe..979e5a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,9 @@
* run-autogen.sh: Add sysconfdir argument to autogen.sh
+ * src/plugin-menu/nautilus-actions.c:
+ Monitor all runtime preferences with only one callback.
+
* src/api/na-boxed.h:
* src/core/na-boxed.c (na_boxed_get_pointer): New function.
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 9d6b9e3..70c7d39 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -62,8 +62,6 @@ struct NautilusActionsPrivate {
gboolean dispose_has_run;
NAPivot *pivot;
gulong items_changed_handler;
- gboolean items_add_about_item;
- gboolean items_create_root_menu;
};
static GObjectClass *st_parent_class = NULL;
@@ -105,12 +103,7 @@ static GList *add_about_item( NautilusActions *plugin, GList *nautilu
static void execute_about( NautilusMenuItem *item, NautilusActions *plugin );
static void on_pivot_items_changed_handler( NAPivot *pivot, NautilusActions *plugin );
-static void on_items_add_about_item_changed( gpointer newvalue, NautilusActions *plugin );
-static void on_items_create_root_menu_changed( gpointer newvalue, NautilusActions *plugin );
-static void on_io_provider_read_status_changed( gpointer newvalue, NautilusActions *plugin );
-static void on_io_providers_read_order_changed( gpointer newvalue, NautilusActions *plugin );
-static void on_items_level_zero_order_changed( gpointer newvalue, NautilusActions *plugin );
-
+static void on_runtime_preference_changed( const gchar *group, const gchar *key, gconstpointer newvalue, gboolean mandatory, NautilusActions *plugin );
static void record_change_event( NautilusActions *plugin );
static gboolean on_change_event_timeout( NautilusActions *plugin );
static gulong time_val_diff( const GTimeVal *recent, const GTimeVal *old );
@@ -242,37 +235,37 @@ instance_constructed( GObject *object )
*/
settings = na_pivot_get_settings( self->private->pivot );
- /* record and monitor whether we an 'About Nautilus-Actions' item
+ /* monitor
+ * - the changes of the readability status of the i/o providers
+ * - the changes of the read order of the i/o providers
+ * - the modification of the level-zero order
+ * - whether we create a root menu
+ * - whether we add an 'About Nautilus-Actions' item
+ * - the preferred order mode
*/
- self->private->items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM,
- G_CALLBACK( on_items_add_about_item_changed ), self );
+ NA_SETTINGS_RUNTIME_IO_PROVIDER_READ_STATUS,
+ G_CALLBACK( on_runtime_preference_changed ), self );
- /* record and monitor whether we must create a root menu
- */
- self->private->items_create_root_menu = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU,
- G_CALLBACK( on_items_create_root_menu_changed ), self );
+ NA_SETTINGS_RUNTIME_IO_PROVIDERS_READ_ORDER,
+ G_CALLBACK( on_runtime_preference_changed ), self );
- /* monitor the changes of the readability status of the i/o providers
- */
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_IO_PROVIDER_READ_STATUS,
- G_CALLBACK( on_io_provider_read_status_changed ), self );
+ NA_SETTINGS_RUNTIME_ITEMS_LEVEL_ZERO_ORDER,
+ G_CALLBACK( on_runtime_preference_changed ), self );
- /* monitor the changes of the read order of the i/o providers
- */
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_IO_PROVIDERS_READ_ORDER,
- G_CALLBACK( on_io_providers_read_order_changed ), self );
+ NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU,
+ G_CALLBACK( on_runtime_preference_changed ), self );
- /* monitor the modification of the level-zero order
- */
na_settings_register_key_callback( settings,
- NA_SETTINGS_RUNTIME_ITEMS_LEVEL_ZERO_ORDER,
- G_CALLBACK( on_items_level_zero_order_changed ), self );
+ NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM,
+ G_CALLBACK( on_runtime_preference_changed ), self );
+
+ na_settings_register_key_callback( settings,
+ NA_SETTINGS_RUNTIME_ITEMS_LIST_ORDER_MODE,
+ G_CALLBACK( on_runtime_preference_changed ), self );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
@@ -500,6 +493,9 @@ get_menus_items( NautilusActions *plugin, guint target, GList *selection )
GList *menus_list;
NATokens *tokens;
GList *pivot_tree, *copy_tree;
+ NASettings *settings;
+ gboolean items_add_about_item;
+ gboolean items_create_root_menu;
g_return_val_if_fail( NA_IS_PIVOT( plugin->private->pivot ), NULL );
@@ -514,11 +510,15 @@ get_menus_items( NautilusActions *plugin, guint target, GList *selection )
if( target != ITEM_TARGET_TOOLBAR ){
- if( plugin->private->items_create_root_menu ){
+ settings = na_pivot_get_settings( plugin->private->pivot );
+
+ items_create_root_menu = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
+ if( items_create_root_menu ){
menus_list = create_root_menu( plugin, menus_list );
}
- if( plugin->private->items_add_about_item ){
+ items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
+ if( items_add_about_item ){
menus_list = add_about_item( plugin, menus_list );
}
}
@@ -1044,61 +1044,7 @@ on_pivot_items_changed_handler( NAPivot *pivot, NautilusActions *plugin )
}
static void
-on_items_add_about_item_changed( gpointer newvalue, NautilusActions *plugin )
-{
- gboolean newbool;
-
- g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
-
- if( !plugin->private->dispose_has_run ){
-
- newbool = ( gboolean ) GPOINTER_TO_UINT( newvalue );
- if( newbool != plugin->private->items_add_about_item ){
- plugin->private->items_add_about_item = newbool;
- record_change_event( plugin );
- }
- }
-}
-
-static void
-on_items_create_root_menu_changed( gpointer newvalue, NautilusActions *plugin )
-{
- gboolean newbool;
-
- g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
-
- if( !plugin->private->dispose_has_run ){
-
- newbool = ( gboolean ) GPOINTER_TO_UINT( newvalue );
- if( newbool != plugin->private->items_create_root_menu ){
- plugin->private->items_create_root_menu = newbool;
- record_change_event( plugin );
- }
- }
-}
-
-static void
-on_io_provider_read_status_changed( gpointer newvalue, NautilusActions *plugin )
-{
- g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
-
- if( !plugin->private->dispose_has_run ){
- record_change_event( plugin );
- }
-}
-
-static void
-on_io_providers_read_order_changed( gpointer newvalue, NautilusActions *plugin )
-{
- g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
-
- if( !plugin->private->dispose_has_run ){
- record_change_event( plugin );
- }
-}
-
-static void
-on_items_level_zero_order_changed( gpointer newvalue, NautilusActions *plugin )
+on_runtime_preference_changed( const gchar *group, const gchar *key, gconstpointer newvalue, gboolean mandatory, NautilusActions *plugin )
{
g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]