[nautilus-actions] NASettings: no more try to summarize notification messages
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] NASettings: no more try to summarize notification messages
- Date: Mon, 31 Jan 2011 21:41:18 +0000 (UTC)
commit a567f3fabb12342fd77e03b9bebffb79dfc8c666
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Jan 28 22:16:48 2011 +0100
NASettings: no more try to summarize notification messages
+ src/plugin-menu/nautilus-actions.c: Updated accordingly
Note: execution still triggers a segfault here.
ChangeLog | 8 ++
src/core/Makefile.am | 15 +++
src/core/na-settings.c | 227 ++++++++++++++++++------------------
src/core/na-settings.h | 53 +++-----
src/plugin-menu/nautilus-actions.c | 32 +++---
5 files changed, 171 insertions(+), 164 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c0247eb..36ca885 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-01-28 Pierre Wieser <pwieser trychlos org>
+ * src/core/Makefile.am: Generate na_cclosure_masharl functions.
+
+ * src/core/na-settings.c:
+ * src/core/na-settings.h: No more try to summarize notifications here.
+
+ * src/plugin-menu/nautilus-actions.c (instance_constructed):
+ Register NASettings callbacks on the runtime keys.
+
* src/nact/nact-main-window.c:
(NAIPivotConsumer->on_display_order_changed):
Moved to on_settings_order_mode_changed() function.
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index ad942be..7aff493 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -82,6 +82,8 @@ libna_core_la_SOURCES = \
na-ipivot-consumer.h \
na-iprefs.c \
na-iprefs.h \
+ na-marshal.c \
+ na-marshal.h \
na-module.c \
na-module.h \
na-object.c \
@@ -124,4 +126,17 @@ pkgdata_DATA = \
EXTRA_DIST = \
$(pkgdata_DATA) \
+ na-marshal \
+ $(NULL)
+
+na-marshal.c: na-marshal.h
+ echo "#include \"na-marshal.h\"" > $@
+ glib-genmarshal --prefix=na_cclosure_marshal --body na-marshal >> $@
+
+na-marshal.h: na-marshal
+ glib-genmarshal --prefix=na_cclosure_marshal --header na-marshal > $@
+
+CLEANFILES = \
+ na-marshal.c \
+ na-marshal.h \
$(NULL)
diff --git a/src/core/na-settings.c b/src/core/na-settings.c
index 1f54f7a..043ae25 100644
--- a/src/core/na-settings.c
+++ b/src/core/na-settings.c
@@ -42,6 +42,7 @@
#include <api/na-timeout.h>
#include "na-settings.h"
+#include "na-marshal.h"
/* private class data
*/
@@ -97,65 +98,64 @@ struct _NASettingsPrivate {
typedef struct {
const gchar *key;
const gchar *group;
- gboolean runtime; /* whether the key participates to the 'runtime-change' signal */
guint type;
const gchar *default_value;
}
KeyDef;
static const KeyDef st_def_keys[] = {
- { NA_IPREFS_ADMIN_PREFERENCES_LOCKED, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_ADMIN_IO_PROVIDERS_LOCKED, GROUP_RUNTIME, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_ASSISTANT_ESC_CONFIRM, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_ASSISTANT_ESC_QUIT, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_COMMAND_CHOOSER_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_COMMAND_CHOOSER_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///bin" },
- { NA_IPREFS_COMMAND_LEGEND_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_WORKING_DIR_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_WORKING_DIR_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///" },
- { NA_IPREFS_SHOW_IF_RUNNING_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_SHOW_IF_RUNNING_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///bin" },
- { NA_IPREFS_TRY_EXEC_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_TRY_EXEC_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///bin" },
- { NA_IPREFS_EXPORT_ASK_USER_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_EXPORT_ASK_USER_LAST_FORMAT, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_EXPORT_FORMAT },
- { NA_IPREFS_EXPORT_ASK_USER_KEEP_LAST_CHOICE, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_EXPORT_ASSISTANT_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_EXPORT_ASSISTANT_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///tmp" },
- { NA_IPREFS_EXPORT_PREFERRED_FORMAT, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_EXPORT_FORMAT },
- { NA_IPREFS_FOLDER_CHOOSER_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_FOLDER_CHOOSER_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///" },
- { NA_IPREFS_IMPORT_ASK_USER_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_IMPORT_MODE },
- { NA_IPREFS_IMPORT_ASSISTANT_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_IMPORT_ASSISTANT_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///tmp" },
- { NA_IPREFS_IMPORT_ASK_USER_KEEP_LAST_CHOICE, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_IMPORT_PREFERRED_MODE, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_IMPORT_MODE },
- { NA_IPREFS_IO_PROVIDERS_WRITE_ORDER, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING_LIST, "" },
- { NA_IPREFS_ICON_CHOOSER_URI, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING, "file:///" },
- { NA_IPREFS_ICON_CHOOSER_PANED, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT, "200" },
- { NA_IPREFS_ICON_CHOOSER_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, GROUP_RUNTIME, TRUE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_ITEMS_CREATE_ROOT_MENU, GROUP_RUNTIME, TRUE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER, GROUP_RUNTIME, TRUE, NA_BOXED_TYPE_STRING_LIST, "" },
- { NA_IPREFS_ITEMS_LIST_ORDER_MODE, GROUP_RUNTIME, TRUE, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_LIST_ORDER_MODE },
- { NA_IPREFS_MAIN_PANED, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT, "200" },
- { NA_IPREFS_MAIN_SAVE_AUTO, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_MAIN_SAVE_PERIOD, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT, "5" },
- { NA_IPREFS_MAIN_TOOLBAR_EDIT_DISPLAY, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_MAIN_TOOLBAR_FILE_DISPLAY, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_MAIN_TOOLBAR_HELP_DISPLAY, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_MAIN_WINDOW_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_PREFERENCES_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_RELABEL_DUPLICATE_ACTION, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_RELABEL_DUPLICATE_MENU, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_RELABEL_DUPLICATE_PROFILE, GROUP_NACT, FALSE, NA_BOXED_TYPE_BOOLEAN, "false" },
- { NA_IPREFS_SCHEME_ADD_SCHEME_WSP, GROUP_NACT, FALSE, NA_BOXED_TYPE_UINT_LIST, "" },
- { NA_IPREFS_SCHEME_DEFAULT_LIST, GROUP_NACT, FALSE, NA_BOXED_TYPE_STRING_LIST, "" },
- { NA_IPREFS_IO_PROVIDER_READABLE, NA_IPREFS_IO_PROVIDER_GROUP, TRUE, NA_BOXED_TYPE_BOOLEAN, "true" },
- { NA_IPREFS_IO_PROVIDER_WRITABLE, NA_IPREFS_IO_PROVIDER_GROUP, FALSE, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_ADMIN_PREFERENCES_LOCKED, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_ADMIN_IO_PROVIDERS_LOCKED, GROUP_RUNTIME, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_ASSISTANT_ESC_CONFIRM, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_ASSISTANT_ESC_QUIT, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_COMMAND_CHOOSER_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_COMMAND_CHOOSER_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///bin" },
+ { NA_IPREFS_COMMAND_LEGEND_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_WORKING_DIR_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_WORKING_DIR_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///" },
+ { NA_IPREFS_SHOW_IF_RUNNING_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_SHOW_IF_RUNNING_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///bin" },
+ { NA_IPREFS_TRY_EXEC_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_TRY_EXEC_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///bin" },
+ { NA_IPREFS_EXPORT_ASK_USER_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_EXPORT_ASK_USER_LAST_FORMAT, GROUP_NACT, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_EXPORT_FORMAT },
+ { NA_IPREFS_EXPORT_ASK_USER_KEEP_LAST_CHOICE, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_EXPORT_ASSISTANT_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_EXPORT_ASSISTANT_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///tmp" },
+ { NA_IPREFS_EXPORT_PREFERRED_FORMAT, GROUP_NACT, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_EXPORT_FORMAT },
+ { NA_IPREFS_FOLDER_CHOOSER_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_FOLDER_CHOOSER_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///" },
+ { NA_IPREFS_IMPORT_ASK_USER_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_IMPORT_ASK_USER_LAST_MODE, GROUP_NACT, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_IMPORT_MODE },
+ { NA_IPREFS_IMPORT_ASSISTANT_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_IMPORT_ASSISTANT_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///tmp" },
+ { NA_IPREFS_IMPORT_ASK_USER_KEEP_LAST_CHOICE, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_IMPORT_PREFERRED_MODE, GROUP_NACT, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_IMPORT_MODE },
+ { NA_IPREFS_IO_PROVIDERS_WRITE_ORDER, GROUP_NACT, NA_BOXED_TYPE_STRING_LIST, "" },
+ { NA_IPREFS_ICON_CHOOSER_URI, GROUP_NACT, NA_BOXED_TYPE_STRING, "file:///" },
+ { NA_IPREFS_ICON_CHOOSER_PANED, GROUP_NACT, NA_BOXED_TYPE_UINT, "200" },
+ { NA_IPREFS_ICON_CHOOSER_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, GROUP_RUNTIME, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_ITEMS_CREATE_ROOT_MENU, GROUP_RUNTIME, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER, GROUP_RUNTIME, NA_BOXED_TYPE_STRING_LIST, "" },
+ { NA_IPREFS_ITEMS_LIST_ORDER_MODE, GROUP_RUNTIME, NA_BOXED_TYPE_STRING, NA_IPREFS_DEFAULT_LIST_ORDER_MODE },
+ { NA_IPREFS_MAIN_PANED, GROUP_NACT, NA_BOXED_TYPE_UINT, "200" },
+ { NA_IPREFS_MAIN_SAVE_AUTO, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_MAIN_SAVE_PERIOD, GROUP_NACT, NA_BOXED_TYPE_UINT, "5" },
+ { NA_IPREFS_MAIN_TOOLBAR_EDIT_DISPLAY, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_MAIN_TOOLBAR_FILE_DISPLAY, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_MAIN_TOOLBAR_HELP_DISPLAY, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_MAIN_WINDOW_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_PREFERENCES_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_RELABEL_DUPLICATE_ACTION, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_RELABEL_DUPLICATE_MENU, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_RELABEL_DUPLICATE_PROFILE, GROUP_NACT, NA_BOXED_TYPE_BOOLEAN, "false" },
+ { NA_IPREFS_SCHEME_ADD_SCHEME_WSP, GROUP_NACT, NA_BOXED_TYPE_UINT_LIST, "" },
+ { NA_IPREFS_SCHEME_DEFAULT_LIST, GROUP_NACT, NA_BOXED_TYPE_STRING_LIST, "" },
+ { NA_IPREFS_IO_PROVIDER_READABLE, NA_IPREFS_IO_PROVIDER_GROUP, NA_BOXED_TYPE_BOOLEAN, "true" },
+ { NA_IPREFS_IO_PROVIDER_WRITABLE, NA_IPREFS_IO_PROVIDER_GROUP, NA_BOXED_TYPE_BOOLEAN, "true" },
{ 0 }
};
@@ -174,8 +174,7 @@ typedef struct {
/* signals
*/
enum {
- RUNTIME_CHANGE,
- UI_CHANGE,
+ KEY_CHANGED,
LAST_SIGNAL
};
@@ -196,6 +195,7 @@ static KeyDef *get_key_def( const gchar *key );
static KeyFile *key_file_new( NASettings *settings, const gchar *dir );
static void on_keyfile_changed( GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, NASettings *settings );
static void on_keyfile_changed_timeout( NASettings *settings );
+static void on_key_changed_final_handler( NASettings *settings, gchar *group, gchar *key, NABoxed *new_value, gboolean mandatory );
static KeyValue *peek_key_value_from_content( GList *content, const gchar *group, const gchar *key );
static KeyValue *read_key_value( NASettings *settings, const gchar *group, const gchar *key, gboolean *found, gboolean *mandatory );
static KeyValue *read_key_value_from_key_file( GKeyFile *key_file, const gchar *group, const gchar *key, const KeyDef *key_def );
@@ -259,44 +259,34 @@ class_init( NASettingsClass *klass )
klass->private = g_new0( NASettingsClassPrivate, 1 );
/*
- * NASettings::settings-runtime-change:
+ * NASettings::settings-key-changed:
*
- * This signal is sent by NASettings at the end of a burst of
- * modifications which may affect the way the file manager displays
- * its context menus.
+ * This signal is sent by NASettings when the value of a key is modified.
*
- * The signal is registered without any default handler.
- */
- st_signals[ RUNTIME_CHANGE ] = g_signal_new(
- SETTINGS_SIGNAL_RUNTIME_CHANGE,
- NA_SETTINGS_TYPE,
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0, /* class offset */
- NULL, /* accumulator */
- NULL, /* accumulator data */
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0 );
-
- /*
- * NASettings::settings-ui-change:
+ * Arguments are the group, the key, the new value as a NABoxed,
+ * and whether it is mandatory.
*
- * This signal is sent by NASettings at the end of a burst of
- * modifications which only affect the behavior of the NACT
- * configuration tool.
+ * Handler is of type:
+ * void ( *handler )( NASettings *settings,
+ * const gchar *group,
+ * const gchar *key,
+ * NABoxed *value,
+ * gboolean mandatory,
+ * gpointer user_data );
*
- * The signal is registered without any default handler.
+ * The default class handler frees these datas.
*/
- st_signals[ UI_CHANGE ] = g_signal_new(
- SETTINGS_SIGNAL_UI_CHANGE,
+ st_signals[ KEY_CHANGED ] = g_signal_new_class_handler(
+ SETTINGS_SIGNAL_KEY_CHANGED,
NA_SETTINGS_TYPE,
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0, /* class offset */
+ G_CALLBACK( on_key_changed_final_handler ),
NULL, /* accumulator */
NULL, /* accumulator data */
- g_cclosure_marshal_VOID__VOID,
+ na_cclosure_marshal_VOID__STRING_STRING_POINTER_BOOLEAN,
G_TYPE_NONE,
- 0 );
+ 4,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN );
}
static void
@@ -1130,10 +1120,9 @@ on_keyfile_changed_timeout( NASettings *settings )
GList *new_content;
GList *modifs;
GList *ic, *im;
- KeyValue *changed;
- Consumer *consumer;
+ const KeyValue *changed;
+ const Consumer *consumer;
gchar *group_prefix, *key;
- gboolean runtime_change, ui_change;
#ifdef NA_MAINTAINER_MODE
gchar *value;
#endif
@@ -1143,52 +1132,49 @@ on_keyfile_changed_timeout( NASettings *settings )
*/
new_content = content_load( settings );
modifs = content_diff( settings->private->content, new_content );
+
#ifdef NA_MAINTAINER_MODE
g_debug( "%s: %d found update(s)", thisfn, g_list_length( modifs ));
for( im = modifs ; im ; im = im->next ){
- changed = ( KeyValue * ) im->data;
+ changed = ( const KeyValue * ) im->data;
value = na_boxed_get_string( changed->boxed );
- g_debug( "%s: key=%s, value=%s", thisfn, changed->def->key, value );
+ g_debug( "%s: group=%s, key=%s, value=%s", thisfn, changed->group, changed->def->key, value );
g_free( value );
}
#endif
- runtime_change = FALSE;
- ui_change = FALSE;
+ /* for each modification found,
+ * - check consumers and triggers callback if apply
+ * - send a notification message
+ */
+ for( im = modifs ; im ; im = im->next ){
+ changed = ( const KeyValue * ) im->data;
- for( ic = settings->private->consumers ; ic ; ic = ic->next ){
- consumer = ( Consumer * ) ic->data;
+ for( ic = settings->private->consumers ; ic ; ic = ic->next ){
+ consumer = ( const Consumer * ) ic->data;
+ group_prefix = NULL;
- group_prefix = NULL;
- if( !strcmp( consumer->monitored_key, NA_IPREFS_IO_PROVIDERS_READ_STATUS )){
- group_prefix = g_strdup_printf( "%s ", NA_IPREFS_IO_PROVIDER_GROUP );
- key = NA_IPREFS_IO_PROVIDER_READABLE;
- } else {
- key = consumer->monitored_key;
- }
+ if( !strcmp( consumer->monitored_key, NA_IPREFS_IO_PROVIDERS_READ_STATUS )){
+ group_prefix = g_strdup_printf( "%s ", NA_IPREFS_IO_PROVIDER_GROUP );
+ key = NA_IPREFS_IO_PROVIDER_READABLE;
+ } else {
+ key = consumer->monitored_key;
+ }
- for( im = modifs ; im ; im = im->next ){
- changed = ( KeyValue * ) im->data;
if(( !group_prefix || g_str_has_prefix( changed->group, group_prefix )) && !strcmp( changed->def->key, key )){
- ( *( NASettingsKeyCallback ) consumer->callback )( changed->group, changed->def->key, na_boxed_get_pointer( changed->boxed ), changed->mandatory, consumer->user_data );
+ ( *( NASettingsKeyCallback ) consumer->callback )
+ ( changed->group, changed->def->key,
+ na_boxed_get_pointer( changed->boxed ), changed->mandatory, consumer->user_data );
}
- if( changed->def->runtime ){
- runtime_change = TRUE;
- } else {
- ui_change = FALSE;
- }
+ g_free( group_prefix );
}
- g_free( group_prefix );
- }
-
- if( runtime_change ){
- g_signal_emit_by_name(( gpointer ) settings, SETTINGS_SIGNAL_RUNTIME_CHANGE );
- }
-
- if( ui_change ){
- g_signal_emit_by_name(( gpointer ) settings, SETTINGS_SIGNAL_UI_CHANGE );
+ g_debug( "%s: sending signal for group=%s, key=%s", thisfn, changed->group, changed->def->key );
+ g_signal_emit_by_name( settings,
+ SETTINGS_SIGNAL_KEY_CHANGED,
+ g_strdup( changed->group ),
+ g_strdup( changed->def->key ), na_boxed_copy( changed->boxed ), changed->mandatory );
}
g_list_foreach( settings->private->content, ( GFunc ) release_key_value, NULL );
@@ -1199,6 +1185,15 @@ on_keyfile_changed_timeout( NASettings *settings )
g_list_free( modifs );
}
+static void
+on_key_changed_final_handler( NASettings *settings, gchar *group, gchar *key, NABoxed *new_value, gboolean mandatory )
+{
+ g_debug( "na_settings_on_key_changed_final_handler: group=%s, key=%s", group, key );
+ g_free( group );
+ g_free( key );
+ na_boxed_free( new_value );
+}
+
static KeyValue *
peek_key_value_from_content( GList *content, const gchar *group, const gchar *key )
{
diff --git a/src/core/na-settings.h b/src/core/na-settings.h
index c825fe8..152e800 100644
--- a/src/core/na-settings.h
+++ b/src/core/na-settings.h
@@ -50,16 +50,10 @@
* has been read from the global configuration or from the
* per-user one.
*
- * NASettings class implements two notification systems:
- *
- * a) a per-key system, which relies on a callback pre-registration;
- * see na_settings_register_key_callback() function;
- * b) a per-usage system, which relies on the usage of the changed
- * key; see signal descriptions.
- *
- * The consumer of change notifications will choose the most accurate
- * system for its needs, e.g. whether it requires to have an exact list
- * of modified keys, or not.
+ * NASettings class monitors the whole configuration.
+ * A client may be informed of a modification of the value of a key either by
+ * pre-registering a callback on this key (see na_settings_register_key_callback()
+ * function), or by connecting to and filtering the notification signal.
*/
#include <glib-object.h>
@@ -93,15 +87,11 @@ typedef struct {
GType na_settings_get_type( void );
-/* these keys should be monitored by the Nautilus menu plugin as they
- * have an impact on the order or the display of items in the file manager
- * context menus
+/* This is a composite key;
+ * by registering a callback on this key, a client may be informed of any
+ * modification regarding the readability status of the i/o providers.
*/
#define NA_IPREFS_IO_PROVIDERS_READ_STATUS "io-providers-read-status-composite-key"
-#define NA_IPREFS_ITEMS_ADD_ABOUT_ITEM "items-add-about-item"
-#define NA_IPREFS_ITEMS_CREATE_ROOT_MENU "items-create-root-menu"
-#define NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER "items-level-zero-order"
-#define NA_IPREFS_ITEMS_LIST_ORDER_MODE "items-list-order-mode"
/* other keys, mainly user preferences
*/
@@ -137,6 +127,10 @@ GType na_settings_get_type( void );
#define NA_IPREFS_ICON_CHOOSER_PANED "item-icon-chooser-paned-width"
#define NA_IPREFS_ICON_CHOOSER_WSP "item-icon-chooser-wsp"
#define NA_IPREFS_IO_PROVIDERS_WRITE_ORDER "io-providers-write-order"
+#define NA_IPREFS_ITEMS_ADD_ABOUT_ITEM "items-add-about-item"
+#define NA_IPREFS_ITEMS_CREATE_ROOT_MENU "items-create-root-menu"
+#define NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER "items-level-zero-order"
+#define NA_IPREFS_ITEMS_LIST_ORDER_MODE "items-list-order-mode"
#define NA_IPREFS_MAIN_PANED "main-paned-width"
#define NA_IPREFS_MAIN_SAVE_AUTO "main-save-auto"
#define NA_IPREFS_MAIN_SAVE_PERIOD "main-save-period"
@@ -160,26 +154,18 @@ GType na_settings_get_type( void );
#define NA_IPREFS_DEFAULT_IMPORT_MODE "NoImport"
#define NA_IPREFS_DEFAULT_LIST_ORDER_MODE "AscendingOrder"
-/* signals
- *
- * NASettings monitors, and so is able to send messages about, two sort
- * of changes:
- * - runtime preferences change, which group all changes which may have
- * an effect on the display in file manager context menus;
- * - user interface preferences change, which have only an effect on the
- * NACT configuration tool
- *
- * These two signals are a summarization of individual changes.
+/* pre-registration of a callback
*/
-#define SETTINGS_SIGNAL_RUNTIME_CHANGE "settings-runtime-change"
-#define SETTINGS_SIGNAL_UI_CHANGE "settings-ui-change"
-
typedef void ( *NASettingsKeyCallback )( const gchar *group, const gchar *key, gconstpointer new_value, gboolean mandatory, void *user_data );
-NASettings *na_settings_new ( void );
-
void na_settings_register_key_callback ( NASettings *settings, const gchar *key, GCallback callback, gpointer user_data );
+/* signal sent when the value of a key changes
+ */
+#define SETTINGS_SIGNAL_KEY_CHANGED "settings-key-changed"
+
+NASettings *na_settings_new ( void );
+
gboolean na_settings_get_boolean ( NASettings *settings, const gchar *key, gboolean *found, gboolean *mandatory );
gboolean na_settings_get_boolean_ex ( NASettings *settings, const gchar *group, const gchar *key, gboolean *found, gboolean *mandatory );
gchar *na_settings_get_string ( NASettings *settings, const gchar *key, gboolean *found, gboolean *mandatory );
@@ -194,7 +180,8 @@ gboolean na_settings_set_string_list ( NASettings *settings, const gc
gboolean na_settings_set_uint ( NASettings *settings, const gchar *key, guint value );
gboolean na_settings_set_uint_list ( NASettings *settings, const gchar *key, const GList *value );
-/* na_iprefs_get_io_providers() */
+/* na_iprefs_get_io_providers()
+ */
GSList *na_settings_get_groups ( NASettings *settings );
G_END_DECLS
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 66afb72..da37329 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -104,7 +104,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_settings_runtime_changed_handler( NASettings *settings, NautilusActions *plugin );
+static void on_settings_key_changed_handler( const gchar *group, const gchar *key, gconstpointer new_value, gboolean mandatory, NautilusActions *plugin );
static void on_change_event_timeout( NautilusActions *plugin );
GType
@@ -228,23 +228,26 @@ instance_constructed( GObject *object )
/* register against NAPivot to be notified of items changes
*/
self->private->items_changed_handler =
- g_signal_connect(
- self->private->pivot,
- PIVOT_SIGNAL_ITEMS_CHANGED,
- G_CALLBACK( on_pivot_items_changed_handler ), self );
+ g_signal_connect( self->private->pivot,
+ PIVOT_SIGNAL_ITEMS_CHANGED, G_CALLBACK( on_pivot_items_changed_handler ), self );
/* register against NASettings to be notified of changes on
* our runtime preferences
+ * because we only monitor here four runtime keys, we prefer the
+ * callback way that the signal one
*/
settings = na_pivot_get_settings( self->private->pivot );
- /* register against NASettings to be notified of runtime preferences changes
- */
- self->private->settings_changed_handler =
- g_signal_connect(
- settings,
- SETTINGS_SIGNAL_RUNTIME_CHANGE,
- G_CALLBACK( on_settings_runtime_changed_handler ), self );
+ na_settings_register_key_callback( settings,
+ NA_IPREFS_IO_PROVIDERS_READ_STATUS, G_CALLBACK( on_settings_key_changed_handler ), self );
+ na_settings_register_key_callback( settings,
+ NA_IPREFS_ITEMS_ADD_ABOUT_ITEM, G_CALLBACK( on_settings_key_changed_handler ), self );
+ na_settings_register_key_callback( settings,
+ NA_IPREFS_ITEMS_CREATE_ROOT_MENU, G_CALLBACK( on_settings_key_changed_handler ), self );
+ na_settings_register_key_callback( settings,
+ NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER, G_CALLBACK( on_settings_key_changed_handler ), self );
+ na_settings_register_key_callback( settings,
+ NA_IPREFS_ITEMS_LIST_ORDER_MODE, G_CALLBACK( on_settings_key_changed_handler ), self );
/* chain up to the parent class */
if( G_OBJECT_CLASS( st_parent_class )->constructed ){
@@ -1023,14 +1026,13 @@ on_pivot_items_changed_handler( NAPivot *pivot, NautilusActions *plugin )
}
}
-/* signal emitted by NASettings at the end of a burst of 'changed' signals
+/* callback triggered by NASettings at the end of a burst of 'changed' signals
* on runtime preferences which may affect the way file manager displays
* its context menus
*/
static void
-on_settings_runtime_changed_handler( NASettings *settings, NautilusActions *plugin )
+on_settings_key_changed_handler( const gchar *group, const gchar *key, gconstpointer new_value, gboolean mandatory, NautilusActions *plugin )
{
- g_return_if_fail( NA_IS_SETTINGS( settings ));
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]