[nautilus-actions] NAPivot only monitors items changes



commit c868aac0c241b903e3b8f0727c3180d6ec5b9a0e
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Jan 10 21:22:12 2011 +0100

    NAPivot only monitors items changes
    
    The menu plugin monitors all runtime preferences which have an effect on the display
    of items in file manager context menus.

 src/core/na-pivot.c                |   89 ++----------------------------------
 src/plugin-menu/nautilus-actions.c |   69 +++++++++++++++++----------
 2 files changed, 48 insertions(+), 110 deletions(-)
---
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index f883444..b5c973e 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -62,6 +62,7 @@ struct _NAPivotPrivate {
 
 	/* list of instances to be notified of configuration updates
 	 * these are called 'consumers' of NAPivot
+	 * to be deprecated
 	 */
 	GList      *consumers;
 
@@ -75,6 +76,9 @@ struct _NAPivotPrivate {
 	 * defaults to FALSE
 	 */
 	gboolean    automatic_reload;
+
+	/* timeout to manage i/o providers 'item-changed' burst
+	 */
 	GTimeVal    last_event;
 	guint       event_source_id;
 
@@ -120,22 +124,6 @@ static void          free_consumers( GList *list );
 static gboolean      on_item_changed_timeout( NAPivot *pivot );
 static gulong        time_val_diff( const GTimeVal *recent, const GTimeVal *old );
 
-#if 0
-/* NAGConf runtime preferences management */
-static void          on_io_provider_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot );
-static void          on_mandatory_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot );
-static void          on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot );
-static void          display_order_changed( NAPivot *pivot );
-static void          create_root_menu_changed( NAPivot *pivot );
-static void          display_about_changed( NAPivot *pivot );
-static void          autosave_changed( NAPivot *pivot );
-#endif
-/* NASettings monitoring */
-static void          monitor_runtime_preferences( NAPivot *pivot );
-static void          on_io_provider_read_status_changed( gpointer newvalue, NAPivot *pivot );
-static void          on_io_providers_read_order_changed( gpointer newvalue, NAPivot *pivot );
-static void          on_items_level_zero_order_changed( gpointer newvalue, NAPivot *pivot );
-
 GType
 na_pivot_get_type( void )
 {
@@ -265,8 +253,7 @@ instance_constructed( GObject *object )
 		g_debug( "%s: object=%p", thisfn, ( void * ) object );
 
 		self->private->modules = na_module_load_modules();
-
-		monitor_runtime_preferences( self );
+		self->private->settings = na_settings_new();
 
 		/* force class initialization and io-factory registration
 		 */
@@ -979,42 +966,6 @@ na_pivot_is_configuration_locked_by_admin( const NAPivot *pivot )
 	return( locked );
 }
 
-static void
-monitor_runtime_preferences( NAPivot *pivot )
-{
-	static const gchar *thisfn = "na_pivot_monitor_runtime_preferences";
-
-	g_return_if_fail( NA_IS_PIVOT( pivot ));
-	g_return_if_fail( !pivot->private->dispose_has_run );
-
-	g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
-
-	/* this is the new behavior (since 3.1.0)
-	 * NASettings take itself care of maintaining the list of registered callbacks
-	 */
-	pivot->private->settings = na_settings_new();
-
-	/* monitor the modifications of the readability status of the i/o providers
-	 * this use a fake key as this actually monitor the 'readable' key of
-	 * all known i/o providers
-	 */
-	na_settings_register_key_callback( pivot->private->settings,
-			NA_SETTINGS_RUNTIME_IO_PROVIDER_READ_STATUS,
-			G_CALLBACK( on_io_provider_read_status_changed ), pivot );
-
-	/* monitor the modification of the read order of the i/o providers
-	 */
-	na_settings_register_key_callback( pivot->private->settings,
-			NA_SETTINGS_RUNTIME_IO_PROVIDERS_READ_ORDER,
-			G_CALLBACK( on_io_providers_read_order_changed ), pivot );
-
-	/* monitor the modification of the level-zero order
-	 */
-	na_settings_register_key_callback( pivot->private->settings,
-			NA_SETTINGS_RUNTIME_ITEMS_LEVEL_ZERO_ORDER,
-			G_CALLBACK( on_items_level_zero_order_changed ), pivot );
-}
-
 #if 0
 static void
 on_io_provider_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
@@ -1163,33 +1114,3 @@ autosave_changed( NAPivot *pivot )
 	}
 }
 #endif
-
-static void
-on_io_provider_read_status_changed( gpointer newvalue, NAPivot *pivot )
-{
-	g_return_if_fail( NA_IS_PIVOT( pivot ));
-
-	if( !pivot->private->dispose_has_run ){
-
-	}
-}
-
-static void
-on_io_providers_read_order_changed( gpointer newvalue, NAPivot *pivot )
-{
-	g_return_if_fail( NA_IS_PIVOT( pivot ));
-
-	if( !pivot->private->dispose_has_run ){
-
-	}
-}
-
-static void
-on_items_level_zero_order_changed( gpointer newvalue, NAPivot *pivot )
-{
-	g_return_if_fail( NA_IS_PIVOT( pivot ));
-
-	if( !pivot->private->dispose_has_run ){
-
-	}
-}
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index b39ac50..a9a72f0 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -114,7 +114,9 @@ static void              execute_about( NautilusMenuItem *item, NautilusActions
 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_global_settings_changed( gboolean global, 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 );
 
 GType
 nautilus_actions_get_type( void )
@@ -232,23 +234,38 @@ instance_constructed( GObject *object )
 		 *  our runtime preferences
 		 */
 		settings = na_pivot_get_settings( self->private->pivot );
+
+		/* record and monitor whether we an 'About Nautilus-Actions' item
+		 */
 		self->private->items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
-		/*self->private->items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, &found, &global );
-		g_debug( "%s: add_about_item=%s, found=%s, global=%s", thisfn,
-				self->private->items_add_about_item ? "True":"False",
-				found ? "True":"False",
-				global ? "True":"False" );*/
 		na_settings_register_key_callback( settings,
 				NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM,
 				G_CALLBACK( on_items_add_about_item_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_register_global_callback( settings,
-				G_CALLBACK( on_global_settings_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 );
+
+		/* 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 );
+
+		/* 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 );
 
 		/* chain up to the parent class */
 		if( G_OBJECT_CLASS( st_parent_class )->constructed ){
@@ -1042,32 +1059,32 @@ on_items_create_root_menu_changed( gpointer newvalue, NautilusActions *plugin )
 	}
 }
 
-/*
- * this is called when one of the configuration files have been changed
- *
- * as NAPivot is also registered for this same event, then it reloads itself
- * and will send a 'on_items_list_changed' event. which itself triggers
- * the nautilus_menu_provider_emit_items_updated_signal() function.
- *
- * so just reload here the preferences we are monitoring
- */
 static void
-on_global_settings_changed( gboolean global, NautilusActions *plugin )
+on_io_provider_read_status_changed( gpointer newvalue, NautilusActions *plugin )
 {
-	NAPivot *pivot;
-	NASettings *settings;
+	g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
+
+	if( !plugin->private->dispose_has_run ){
 
+	}
+}
+
+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 ){
 
-		g_debug( "nautilus_actions_on_global_settings_changed: global=%s, plugin=%p",
-				global ? "True":"False", ( void * ) plugin );
+	}
+}
+
+static void
+on_items_level_zero_order_changed( gpointer newvalue, NautilusActions *plugin )
+{
+	g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
 
-		pivot = plugin->private->pivot;
-		settings = na_pivot_get_settings( pivot );
+	if( !plugin->private->dispose_has_run ){
 
-		plugin->private->items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
-		plugin->private->items_create_root_menu = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU, NULL, NULL );
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]