[nautilus-actions] Fix compilation of menu plugin vs NASettings



commit eca813d8d0b960d0a811ab896bed46c67b3a4faa
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Jan 10 05:32:39 2011 +0100

    Fix compilation of menu plugin vs NASettings

 ChangeLog                          |    9 ++++
 src/core/na-pivot.c                |    5 ++-
 src/core/na-pivot.h                |    2 +-
 src/core/na-settings.c             |   90 +++++++++++++++++++++++++++++++++---
 src/core/na-settings.h             |   12 ++---
 src/plugin-menu/nautilus-actions.c |   39 ++++++++++------
 6 files changed, 127 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e6f2b86..31f1602 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -33,6 +33,15 @@
 
 	* configure.ac: Enable silent rules by default.
 
+2011-01-10 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-pivot.c:
+	* src/core/na-pivot.h (na_pivot_register):
+	* src/core/na-settings.c:
+	* src/core/na-settings.h (na_settings_register):
+	* src/plugin-menu/nautilus-actions.c (instance_constructed):
+	Fix compilation.
+
 2011-01-09 Pierre Wieser <pwieser trychlos org>
 
 	* src/nact/base-application.c (display_dlg): Setup parent window.
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index 9b1851f..fc6c5e3 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -785,9 +785,12 @@ free_consumers( GList *consumers )
  * Since: 3.1.0
  */
 void
-na_pivot_register( NAPivot *pivot, const gchar *key, NASettingsCallback callback, gpointer user_data )
+na_pivot_register( NAPivot *pivot, const gchar *key, GCallback callback, gpointer user_data )
 {
+	g_return_if_fail( NA_IS_PIVOT( pivot ));
 
+	if( !pivot->private->dispose_has_run ){
+	}
 }
 
 /*
diff --git a/src/core/na-pivot.h b/src/core/na-pivot.h
index 8b50d54..ed2e9c4 100644
--- a/src/core/na-pivot.h
+++ b/src/core/na-pivot.h
@@ -151,7 +151,7 @@ gboolean      na_pivot_write_level_zero( const NAPivot *pivot, GList *items, GSL
  */
 void          na_pivot_register_consumer( NAPivot *pivot, const NAIPivotConsumer *consumer );
 NASettings   *na_pivot_get_settings     ( NAPivot *pivot );
-void          na_pivot_register         ( NAPivot *pivot, const gchar *key, NASettingsCallback callback, gpointer user_data );
+void          na_pivot_register         ( NAPivot *pivot, const gchar *key, GCallback callback, gpointer user_data );
 
 /* NAPivot properties and configuration
  */
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index 2dfd818..2657606 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -32,6 +32,8 @@
 #include <config.h>
 #endif
 
+#include <gio/gio.h>
+
 #include <api/na-data-types.h>
 
 #include "na-settings.h"
@@ -74,9 +76,9 @@ static const KeyDef st_def_keys[] = {
 };
 
 typedef struct {
-	gchar             *key;
-	NASettingsCallback callback;
-	gpointer           user_data;
+	gchar    *key;
+	GCallback callback;
+	gpointer  user_data;
 }
 	Consumer;
 
@@ -89,6 +91,7 @@ static void      instance_dispose( GObject *object );
 static void      instance_finalize( GObject *object );
 
 static GKeyFile *initialize_settings( NASettings* settings, const gchar *dir, GFileMonitor **monitor, gulong *handler );
+static void      on_conf_changed( GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, NASettings *settings );
 static void      release_consumer( Consumer *consumer );
 
 GType
@@ -189,7 +192,7 @@ instance_dispose( GObject *object )
 		g_key_file_free( self->private->global_conf );
 		if( self->private->global_monitor ){
 			if( self->private->global_handler ){
-				g_signal_disconnect( self->private->global_monitor, self->private->global_handler );
+				g_signal_handler_disconnect( self->private->global_monitor, self->private->global_handler );
 			}
 			g_file_monitor_cancel( self->private->global_monitor );
 			g_object_unref( self->private->global_monitor );
@@ -198,7 +201,7 @@ instance_dispose( GObject *object )
 		g_key_file_free( self->private->user_conf );
 		if( self->private->user_monitor ){
 			if( self->private->user_handler ){
-				g_signal_disconnect( self->private->user_monitor, self->private->user_handler );
+				g_signal_handler_disconnect( self->private->user_monitor, self->private->user_handler );
 			}
 			g_file_monitor_cancel( self->private->user_monitor );
 			g_object_unref( self->private->user_monitor );
@@ -271,7 +274,7 @@ na_settings_new( void )
  * Since: 3.1.0
  */
 void
-na_settings_register( NASettings *settings, const gchar *key, NASettingsCallback callback, gpointer user_data )
+na_settings_register( NASettings *settings, const gchar *key, GCallback callback, gpointer user_data )
 {
 	g_return_if_fail( NA_IS_SETTINGS( settings ));
 
@@ -288,6 +291,72 @@ na_settings_register( NASettings *settings, const gchar *key, NASettingsCallback
 }
 
 /**
+ * na_settings_register_global:
+ * @settings: this #NASettings instance.
+ * @callback: the function to be called when the value of the key changes.
+ * @user_data: data to be passed to the @callback function.
+ *
+ * Registers a new consumer of the monitoring of the configuration files.
+ *
+ * Since: 3.1.0
+ */
+void
+na_settings_register_global( NASettings *settings, GCallback callback, gpointer user_data )
+{
+	g_return_if_fail( NA_IS_SETTINGS( settings ));
+
+	if( !settings->private->dispose_has_run ){
+
+		Consumer *consumer = g_new0( Consumer, 1 );
+
+		consumer->key = NULL;
+		consumer->callback = callback;
+		consumer->user_data = user_data;
+		settings->private->consumers = g_list_prepend( settings->private->consumers, consumer );
+	}
+
+}
+
+/**
+ * na_settings_get_boolean:
+ * @settings: this #NASettings instance.
+ * @key: the key whose value is to be returned.
+ * @found: if not %NULL, a pointer to a gboolean in which we will store
+ *  whether the searched @key has been found (%TRUE), or if the returned
+ *  value comes from default (%FALSE).
+ * @global: if not %NULL, a pointer to a gboolean in which we will store
+ *  whether the returned value has been readen from global preferences
+ *  (%TRUE), or from the user preferences (%FALSE). Global preferences
+ *  are usually read-only. When the @key has not been found, @global
+ *  is set to %FALSE.
+ *
+ * Returns: the value of the key, of its default value if not found.
+ *
+ * Since: 3.1.0
+ */
+gboolean
+na_settings_get_boolean( NASettings *settings, const gchar *key, gboolean *found, gboolean *global )
+{
+	gboolean value;
+
+	g_return_val_if_fail( NA_IS_SETTINGS( settings ), FALSE );
+
+	value = FALSE;
+	if( found ){
+		*found = FALSE;
+	}
+	if( global ){
+		*global = FALSE;
+	}
+
+	if( !settings->private->dispose_has_run ){
+
+	}
+
+	return( value );
+}
+
+/**
  * na_settings_get_value:
  * @settings: this #NASettings instance.
  * @key: the key whose value is to be returned.
@@ -312,6 +381,12 @@ na_settings_get_value( NASettings *settings, const gchar *key, gboolean *found,
 	g_return_val_if_fail( NA_IS_SETTINGS( settings ), NULL );
 
 	value = NULL;
+	if( found ){
+		*found = FALSE;
+	}
+	if( global ){
+		*global = FALSE;
+	}
 
 	if( !settings->private->dispose_has_run ){
 
@@ -359,7 +434,8 @@ initialize_settings( NASettings* settings, const gchar *dir, GFileMonitor **moni
 	return( key_file );
 }
 
-void on_conf_changed( GFileMonitor *monitor,
+static void
+on_conf_changed( GFileMonitor *monitor,
 		GFile *file, GFile *other_file, GFileMonitorEvent event_type, NASettings *settings )
 {
 	g_return_if_fail( NA_IS_SETTINGS( settings ));
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index 8c6bf63..d0866e8 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -81,18 +81,16 @@ typedef struct {
 
 GType na_settings_get_type( void );
 
-typedef void ( *NASettingsCallback )( const gchar *key, gpointer new_value, gpointer user_data );
-
 #define NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM		"items-add-about-item"
 #define NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU		"items-create-root-menu"
 
-NASettings *na_settings_new      ( void );
-
-void        na_settings_register ( NASettings *settings, const gchar *key, NASettingsCallback callback, gpointer user_data );
+NASettings *na_settings_new            ( void );
 
-#define     na_settings_get_bool ( settings, key ) (( gboolean ) GPOINTER_TO_UINT( na_settings_get_value( settings, key, NULL, NULL )))
+void        na_settings_register       ( NASettings *settings, const gchar *key, GCallback callback, gpointer user_data );
+void        na_settings_register_global( NASettings *settings, GCallback callback, gpointer user_data );
 
-gpointer    na_settings_get_value( NASettings *settings, const gchar *key, gboolean *found, gboolean *global );
+gboolean    na_settings_get_boolean    ( NASettings *settings, const gchar *key, gboolean *found, gboolean *global );
+gpointer    na_settings_get_value      ( NASettings *settings, const gchar *key, gboolean *found, gboolean *global );
 
 G_END_DECLS
 
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index dde30b3..a612911 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -110,9 +110,10 @@ static GList            *create_root_menu( NautilusActions *plugin, GList *nauti
 static GList            *add_about_item( NautilusActions *plugin, GList *nautilus_menu );
 static void              execute_about( NautilusMenuItem *item, NautilusActions *plugin );
 
-static void              on_items_list_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin );
-static void              on_items_add_about_item_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin );
-static void              on_items_create_root_menu_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin );
+static void              on_items_list_changed( 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( NautilusActions *plugin, gboolean global );
 
 GType
 nautilus_actions_get_type( void )
@@ -226,21 +227,24 @@ instance_constructed( GObject *object )
 		 */
 		na_pivot_register( self->private->pivot,
 				NA_PIVOT_RUNTIME_ITEMS_LIST_CHANGED,
-				( NASettingsCallback ) on_items_list_changed, self );
+				( GCallback ) on_items_list_changed, self );
 
 		/* register against NASettings to be notified of changes on
 		 *  our runtime preferences
 		 */
 		settings = na_pivot_get_settings( self->private->pivot );
-		self->private->items_add_about_item = na_settings_get_bool( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM );
+		self->private->items_add_about_item = na_settings_get_boolean( settings, NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM, NULL, NULL );
 		na_settings_register( settings,
 				NA_SETTINGS_RUNTIME_ITEMS_ADD_ABOUT_ITEM,
-				( NASettingsCallback ) on_items_add_about_item_changed, self );
+				( GCallback ) on_items_add_about_item_changed, self );
 
-		self->private->items_create_root_menu = na_settings_get_bool( settings, NA_SETTINGS_RUNTIME_ITEMS_CREATE_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( settings,
 				NA_SETTINGS_RUNTIME_ITEMS_CREATE_ROOT_MENU,
-				( NASettingsCallback ) on_items_create_root_menu_changed, self );
+				( GCallback ) on_items_create_root_menu_changed, self );
+
+		na_settings_register_global( settings,
+				( GCallback ) on_global_settings_changed, self );
 
 		/* chain up to the parent class */
 		if( G_OBJECT_CLASS( st_parent_class )->constructed ){
@@ -990,13 +994,11 @@ execute_about( NautilusMenuItem *item, NautilusActions *plugin )
  * - the 'readable' status of a i/o provider is changed
  * - the level-zero order is modified
  *
- * there is no relevant 'newvalue' here.
- *
  * if pivot is in automatic reload mode, then it already has reloaded
  * the items tree in the new environment
  */
 static void
-on_items_list_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin )
+on_items_list_changed( NautilusActions *plugin )
 {
 	g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
 
@@ -1007,7 +1009,7 @@ on_items_list_changed( const gchar *key, gpointer newvalue, NautilusActions *plu
 }
 
 static void
-on_items_add_about_item_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin )
+on_items_add_about_item_changed( gpointer newvalue, NautilusActions *plugin )
 {
 	gboolean newbool;
 
@@ -1024,7 +1026,7 @@ on_items_add_about_item_changed( const gchar *key, gpointer newvalue, NautilusAc
 }
 
 static void
-on_items_create_root_menu_changed( const gchar *key, gpointer newvalue, NautilusActions *plugin )
+on_items_create_root_menu_changed( gpointer newvalue, NautilusActions *plugin )
 {
 	gboolean newbool;
 
@@ -1033,9 +1035,18 @@ on_items_create_root_menu_changed( const gchar *key, gpointer newvalue, Nautilus
 	if( !plugin->private->dispose_has_run ){
 
 		newbool = ( gboolean ) GPOINTER_TO_UINT( newvalue );
-		if( newbool != plugin->private->plugin->private->items_create_root_menu ){
+		if( newbool != plugin->private->items_create_root_menu ){
 			plugin->private->items_create_root_menu = newbool;
 			nautilus_menu_provider_emit_items_updated_signal( NAUTILUS_MENU_PROVIDER( plugin ));
 		}
 	}
 }
+
+static void
+on_global_settings_changed( NautilusActions *plugin, gboolean global )
+{
+	g_return_if_fail( NAUTILUS_IS_ACTIONS( plugin ));
+
+	if( !plugin->private->dispose_has_run ){
+	}
+}



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