[nautilus-actions] Trigger main window and nautilus plugin on runtime preferences changes
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Trigger main window and nautilus plugin on runtime preferences changes
- Date: Fri, 2 Oct 2009 22:41:59 +0000 (UTC)
commit 72cc92ab600b43877ea80df511625333fe1b115c
Author: Pierre Wieser <pwieser trychlos org>
Date: Mon Sep 28 22:07:22 2009 +0200
Trigger main window and nautilus plugin on runtime preferences changes
ChangeLog | 11 ++++++++-
src/common/na-iio-provider.c | 2 +-
src/common/na-ipivot-consumer.c | 10 +++++---
src/common/na-ipivot-consumer.h | 14 +++++-------
src/common/na-iprefs.c | 8 +++---
src/common/na-iprefs.h | 4 +-
src/common/na-pivot.c | 16 ++++++++++---
src/nact/nact-main-window.c | 12 +++++-----
src/nact/nact-preferences-editor.c | 22 +++++++++++++++++-
src/nact/nact-tree-model.c | 2 +-
src/nact/nautilus-actions-config-tool.ui | 2 +-
src/plugin/nautilus-actions.c | 34 ++++++++++++++++++++++++++++++
12 files changed, 103 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 987b4e8..13055ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,9 +19,13 @@
Implement the new actions sorting semantic when loading the tree.
Move the sorting functions to NAPivot class.
+ * src/common/na-ipivot-consumer.c:
+ * src/common/na-ipivot-consumer.h:
+ Add new value to virtual functions arguments lists.
+
* src/common/na-iprefs.c:
* src/common/na-iprefs.h (na_iprefs_is_alphabetical_order):
- Renamed as na_iprefs_get_alphabetical_order().
+ Renamed as na_iprefs_get_order_mode().
Move NAIPrefs data to instance object.
* src/common/na-pivot.c:
@@ -64,6 +68,7 @@
Edit the new UI preferences.
Do not implement BaseIPrefs nor NAIPrefs interfaces.
Implement new order mode semantic.
+ Make sure to show the page zero when opening the editor.
* src/nact/nact-tree-model.c (sort_actions_list):
Implement new order mode semantic.
@@ -76,6 +81,10 @@
Edit the user preferences in a notebook.
Remove "orientation=vertical" vbox properties.
+ * src/plugin/nautilus-actions.c:
+ Trigger items-updated signal to Nautilus on runtime preferences
+ changes.
+
2009-09-27 Pierre Wieser <pwieser trychlos org>
* src/common/na-object-api.h (na_object_set_for_copy): New function.
diff --git a/src/common/na-iio-provider.c b/src/common/na-iio-provider.c
index 1a6685f..061f19b 100644
--- a/src/common/na-iio-provider.c
+++ b/src/common/na-iio-provider.c
@@ -181,7 +181,7 @@ na_iio_provider_get_items_tree( const NAPivot *pivot )
na_object_dump_tree( hierarchy );
g_debug( "%s: end of tree", thisfn );
- order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
+ order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
switch( order_mode ){
case PREFS_ORDER_ALPHA_ASCENDING:
hierarchy = sort_tree( pivot, hierarchy, ( GCompareFunc ) na_pivot_sort_alpha_asc );
diff --git a/src/common/na-ipivot-consumer.c b/src/common/na-ipivot-consumer.c
index 0a8e08f..cacbedf 100644
--- a/src/common/na-ipivot-consumer.c
+++ b/src/common/na-ipivot-consumer.c
@@ -188,11 +188,12 @@ void na_ipivot_consumer_notify_actions_changed( NAIPivotConsumer *instance )
* na_ipivot_consumer_notify_of_display_order_change:
* @instance: the #NAIPivotConsumer instance to be notified of the end
* of the modifications.
+ * @order_mode: new order mode.
*
* Notifies the consumers that the display order has been changed.
*/
void
-na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance )
+na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance, gint order_mode )
{
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
@@ -201,7 +202,7 @@ na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance )
if( is_notify_allowed( instance )){
if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed ){
- NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed( instance, NULL );
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_order_changed( instance, order_mode );
}
}
}
@@ -211,12 +212,13 @@ na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance )
* na_ipivot_consumer_notify_of_display_about_change:
* @instance: the #NAIPivotConsumer instance to be notified of the end
* of the modifications.
+ * @enabled: whether the 'About' item should be enabled.
*
* Notifies the consumers that the setting of the display of an 'About'
* item in the Nautilus context menu has been changed.
*/
void
-na_ipivot_consumer_notify_of_display_about_change( NAIPivotConsumer *instance )
+na_ipivot_consumer_notify_of_display_about_change( NAIPivotConsumer *instance, gboolean enabled )
{
g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
@@ -225,7 +227,7 @@ na_ipivot_consumer_notify_of_display_about_change( NAIPivotConsumer *instance )
if( is_notify_allowed( instance )){
if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed ){
- NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed( instance, NULL );
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_display_about_changed( instance, enabled );
}
}
}
diff --git a/src/common/na-ipivot-consumer.h b/src/common/na-ipivot-consumer.h
index 991271b..20401ae 100644
--- a/src/common/na-ipivot-consumer.h
+++ b/src/common/na-ipivot-consumer.h
@@ -75,25 +75,23 @@ typedef struct {
* on_display_about_changed:
* @instance: the #NAIPivotConsumer instance which implements this
* interface.
- * user_data: user data set when emitting the message. Currently,
- * not used.
+ * @order_mode: the new order mode.
*
* This function is triggered each time the setting of the display
* of an 'About' item in the Nautilus context menu is changed.
*/
- void ( *on_display_about_changed )( NAIPivotConsumer *instance, gpointer user_data );
+ void ( *on_display_about_changed )( NAIPivotConsumer *instance, gint order_mode );
/**
* on_display_order_changed:
* @instance: the #NAIPivotConsumer instance which implements this
* interface.
- * user_data: user data set when emitting the message. Currently,
- * not used.
+ * @enabled: whether the 'About' item should be enabled.
*
* This function is triggered each time the display order preference
* is changed.
*/
- void ( *on_display_order_changed )( NAIPivotConsumer *instance, gpointer user_data );
+ void ( *on_display_order_changed )( NAIPivotConsumer *instance, gboolean enabled );
}
NAIPivotConsumerInterface;
@@ -102,8 +100,8 @@ GType na_ipivot_consumer_get_type( void );
void na_ipivot_consumer_delay_notify( NAIPivotConsumer *instance );
void na_ipivot_consumer_notify_actions_changed( NAIPivotConsumer *instance );
-void na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance );
-void na_ipivot_consumer_notify_of_display_about_change( NAIPivotConsumer *instance );
+void na_ipivot_consumer_notify_of_display_order_change( NAIPivotConsumer *instance, gint order_mode );
+void na_ipivot_consumer_notify_of_display_about_change( NAIPivotConsumer *instance, gboolean enabled );
G_END_DECLS
diff --git a/src/common/na-iprefs.c b/src/common/na-iprefs.c
index 694d4c9..e58cbdc 100644
--- a/src/common/na-iprefs.c
+++ b/src/common/na-iprefs.c
@@ -181,7 +181,7 @@ na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order )
}
/**
- * na_iprefs_get_alphabetical_order:
+ * na_iprefs_get_order_mode:
* @instance: this #NAIPrefs interface instance.
*
* Returns: the order mode currently set.
@@ -193,7 +193,7 @@ na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order )
* those defined in schemas.
*/
gint
-na_iprefs_get_alphabetical_order( NAIPrefs *instance )
+na_iprefs_get_order_mode( NAIPrefs *instance )
{
gint alpha_order = PREFS_ORDER_ALPHA_ASCENDING;
@@ -208,7 +208,7 @@ na_iprefs_get_alphabetical_order( NAIPrefs *instance )
}
/**
- * na_iprefs_set_alphabetical_order:
+ * na_iprefs_set_order_mode:
* @instance: this #NAIPrefs interface instance.
* @mode: the new value to be written.
*
@@ -216,7 +216,7 @@ na_iprefs_get_alphabetical_order( NAIPrefs *instance )
* preference system.
*/
void
-na_iprefs_set_alphabetical_order( NAIPrefs *instance, gint mode )
+na_iprefs_set_order_mode( NAIPrefs *instance, gint mode )
{
g_return_if_fail( NA_IS_IPREFS( instance ));
diff --git a/src/common/na-iprefs.h b/src/common/na-iprefs.h
index a1f28c0..298f9f3 100644
--- a/src/common/na-iprefs.h
+++ b/src/common/na-iprefs.h
@@ -102,8 +102,8 @@ GType na_iprefs_get_type( void );
GSList *na_iprefs_get_level_zero_items( NAIPrefs *instance );
void na_iprefs_set_level_zero_items( NAIPrefs *instance, GSList *order );
-gint na_iprefs_get_alphabetical_order( NAIPrefs *instance );
-void na_iprefs_set_alphabetical_order( NAIPrefs *instance, gint mode );
+gint na_iprefs_get_order_mode( NAIPrefs *instance );
+void na_iprefs_set_order_mode( NAIPrefs *instance, gint mode );
gboolean na_iprefs_should_add_about_item( NAIPrefs *instance );
void na_iprefs_set_add_about_item( NAIPrefs *instance, gboolean enabled );
diff --git a/src/common/na-pivot.c b/src/common/na-pivot.c
index 36fae68..a42878b 100644
--- a/src/common/na-pivot.c
+++ b/src/common/na-pivot.c
@@ -876,6 +876,7 @@ monitor_runtime_preferences( NAPivot *pivot )
static void
on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
{
+ static const gchar *thisfn = "na_pivot_on_preferences_change";
const gchar *key;
gchar *key_entry;
@@ -883,6 +884,7 @@ on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NA
key = gconf_entry_get_key( entry );
key_entry = na_utils_path_extract_last_dir( key );
+ g_debug( "%s: key=%s", thisfn, key_entry );
if( !g_ascii_strcasecmp( key_entry, PREFS_ADD_ABOUT_ITEM )){
display_about_changed( pivot );
@@ -898,16 +900,19 @@ on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NA
static void
display_order_changed( NAPivot *pivot )
{
- static const gchar *thisfn = "na_pivot_on_display_order_change";
+ static const gchar *thisfn = "na_pivot_display_order_changed";
GList *ic;
+ gint order_mode;
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
g_assert( NA_IS_PIVOT( pivot ));
if( !pivot->private->dispose_has_run ){
+ order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
+
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
- na_ipivot_consumer_notify_of_display_order_change( NA_IPIVOT_CONSUMER( ic->data ));
+ na_ipivot_consumer_notify_of_display_order_change( NA_IPIVOT_CONSUMER( ic->data ), order_mode );
}
}
}
@@ -915,16 +920,19 @@ display_order_changed( NAPivot *pivot )
static void
display_about_changed( NAPivot *pivot )
{
- static const gchar *thisfn = "na_pivot_on_display_order_change";
+ static const gchar *thisfn = "na_pivot_display_about_changed";
GList *ic;
+ gboolean enabled;
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
g_assert( NA_IS_PIVOT( pivot ));
if( !pivot->private->dispose_has_run ){
+ enabled = na_iprefs_should_add_about_item( NA_IPREFS( pivot ));
+
for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
- na_ipivot_consumer_notify_of_display_order_change( NA_IPIVOT_CONSUMER( ic->data ));
+ na_ipivot_consumer_notify_of_display_about_change( NA_IPIVOT_CONSUMER( ic->data ), enabled );
}
}
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index a40e86a..89e8d6c 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -148,8 +148,8 @@ static void on_tab_updatable_item_updated( NactMainWindow *window, gpointer
static gboolean confirm_for_giveup_from_menu( NactMainWindow *window );
static gboolean confirm_for_giveup_from_pivot( NactMainWindow *window );
static void ipivot_consumer_on_actions_changed( NAIPivotConsumer *instance, gpointer user_data );
-static void ipivot_consumer_on_display_about_changed( NAIPivotConsumer *instance, gpointer user_data );
-static void ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gpointer user_data );
+static void ipivot_consumer_on_display_about_changed( NAIPivotConsumer *instance, gboolean enabled );
+static void ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gint order_mode );
static void reload( NactMainWindow *window );
GType
@@ -1152,12 +1152,12 @@ reload( NactMainWindow *window )
* "display 'about' item" preference is modified.
*/
static void
-ipivot_consumer_on_display_about_changed( NAIPivotConsumer *instance, gpointer user_data )
+ipivot_consumer_on_display_about_changed( NAIPivotConsumer *instance, gboolean enabled )
{
static const gchar *thisfn = "nact_main_window_ipivot_consumer_on_display_about_changed";
/*NactMainWindow *self;*/
- g_debug( "%s: instance=%p, user_data=%p", thisfn, ( void * ) instance, ( void * ) user_data );
+ g_debug( "%s: instance=%p, enabled=%s", thisfn, ( void * ) instance, enabled ? "True":"False" );
g_assert( NACT_IS_MAIN_WINDOW( instance ));
/*self = NACT_MAIN_WINDOW( instance );*/
}
@@ -1167,12 +1167,12 @@ ipivot_consumer_on_display_about_changed( NAIPivotConsumer *instance, gpointer u
* "sort in alphabetical order" preference is modified.
*/
static void
-ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gpointer user_data )
+ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gint order_mode )
{
static const gchar *thisfn = "nact_main_window_ipivot_consumer_on_display_order_changed";
/*NactMainWindow *self;*/
- g_debug( "%s: instance=%p, user_data=%p", thisfn, ( void * ) instance, ( void * ) user_data );
+ g_debug( "%s: instance=%p, order_mode=%d", thisfn, ( void * ) instance, order_mode );
g_assert( NACT_IS_MAIN_WINDOW( instance ));
/*self = NACT_MAIN_WINDOW( instance );*/
}
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index f660a56..56394f7 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -67,6 +67,7 @@ static gchar *base_get_iprefs_window_id( BaseWindow *window );
static gchar *base_get_dialog_name( BaseWindow *window );
static void on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data );
static void on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data );
+static void on_base_all_widgets_showed( NactPreferencesEditor *editor, gpointer user_data );
static void on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void on_ok_clicked( GtkButton *button, NactPreferencesEditor *editor );
static void save_preferences( NactPreferencesEditor *editor );
@@ -157,6 +158,12 @@ instance_init( GTypeInstance *instance, gpointer klass )
BASE_WINDOW_SIGNAL_RUNTIME_INIT,
G_CALLBACK( on_base_runtime_init_dialog ));
+ base_window_signal_connect(
+ BASE_WINDOW( instance ),
+ G_OBJECT( instance ),
+ BASE_WINDOW_SIGNAL_ALL_WIDGETS_SHOWED,
+ G_CALLBACK( on_base_all_widgets_showed));
+
self->private->dispose_has_run = FALSE;
}
@@ -275,7 +282,7 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( editor )));
pivot = nact_application_get_pivot( application );
- order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
+ order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
switch( order_mode ){
case PREFS_ORDER_ALPHA_ASCENDING:
button = base_window_get_widget( BASE_WINDOW( editor ), "OrderAlphaAscButton" );
@@ -322,6 +329,17 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
}
static void
+on_base_all_widgets_showed( NactPreferencesEditor *editor, gpointer user_data )
+{
+ static const gchar *thisfn = "nact_preferences_editor_on_all_widgets_showed";
+ GtkNotebook *notebook;
+
+ g_debug( "%s: editor=%p, user_data=%p", thisfn, ( void * ) editor, ( void * ) user_data );
+ notebook = GTK_NOTEBOOK( base_window_get_widget( BASE_WINDOW( editor ), "PreferencesNotebook" ));
+ gtk_notebook_set_current_page( notebook, 0 );
+}
+
+static void
on_cancel_clicked( GtkButton *button, NactPreferencesEditor *editor )
{
GtkWindow *toplevel = base_window_get_toplevel( BASE_WINDOW( editor ));
@@ -365,7 +383,7 @@ save_preferences( NactPreferencesEditor *editor )
}
}
}
- na_iprefs_set_alphabetical_order( NA_IPREFS( pivot ), order_mode );
+ na_iprefs_set_order_mode( NA_IPREFS( pivot ), order_mode );
button = base_window_get_widget( BASE_WINDOW( editor ), "AddAboutButton" );
enabled = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( button ));
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 2a63e99..3393eaa 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -1465,7 +1465,7 @@ sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, BaseWind
application = NACT_APPLICATION( base_window_get_application( window ));
pivot = nact_application_get_pivot( application );
- order_mode = na_iprefs_get_alphabetical_order( NA_IPREFS( pivot ));
+ order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
gtk_tree_model_get( model, a, IACTIONS_LIST_NAOBJECT_COLUMN, &obj_a, -1 );
gtk_tree_model_get( model, b, IACTIONS_LIST_NAOBJECT_COLUMN, &obj_b, -1 );
diff --git a/src/nact/nautilus-actions-config-tool.ui b/src/nact/nautilus-actions-config-tool.ui
index d329576..b4b783c 100644
--- a/src/nact/nautilus-actions-config-tool.ui
+++ b/src/nact/nautilus-actions-config-tool.ui
@@ -1609,7 +1609,7 @@ Be warned: you will not be prompted another time. This mode may be dangerous.</p
<property name="visible">True</property>
<property name="spacing">2</property>
<child>
- <object class="GtkNotebook" id="notebook1">
+ <object class="GtkNotebook" id="PreferencesNotebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
diff --git a/src/plugin/nautilus-actions.c b/src/plugin/nautilus-actions.c
index d6fde41..766798f 100644
--- a/src/plugin/nautilus-actions.c
+++ b/src/plugin/nautilus-actions.c
@@ -77,7 +77,10 @@ static NautilusMenuItem *create_menu_item( NAObjectAction *action, NAObjectProfi
/*static NautilusMenuItem *create_sub_menu( NautilusMenu **menu );*/
static void add_about_item( NautilusMenu *menu );
static void execute_action( NautilusMenuItem *item, NAObjectProfile *profile );
+
static void actions_changed_handler( NAIPivotConsumer *instance, gpointer user_data );
+static void display_about_changed_handler( NAIPivotConsumer *instance, gboolean enabled );
+static void display_order_changed_handler( NAIPivotConsumer *instance, gint order_mode );
GType
nautilus_actions_get_type( void )
@@ -161,6 +164,8 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
iface->on_actions_changed = actions_changed_handler;
+ iface->on_display_about_changed = display_about_changed_handler;
+ iface->on_display_order_changed = display_order_changed_handler;
}
static void
@@ -480,7 +485,36 @@ actions_changed_handler( NAIPivotConsumer *instance, gpointer user_data )
self = NAUTILUS_ACTIONS( instance );
if( !self->private->dispose_has_run ){
+ nautilus_menu_provider_emit_items_updated_signal( NAUTILUS_MENU_PROVIDER( self ));
+ }
+}
+
+static void
+display_about_changed_handler( NAIPivotConsumer *instance, gboolean enabled )
+{
+ static const gchar *thisfn = "nautilus_actions_display_about_changed_handler";
+ NautilusActions *self;
+
+ g_debug( "%s: instance=%p, enabled=%s", thisfn, ( void * ) instance, enabled ? "True":"False" );
+ g_return_if_fail( NAUTILUS_IS_ACTIONS( instance ));
+ self = NAUTILUS_ACTIONS( instance );
+
+ if( !self->private->dispose_has_run ){
+ nautilus_menu_provider_emit_items_updated_signal( NAUTILUS_MENU_PROVIDER( self ));
+ }
+}
+
+static void
+display_order_changed_handler( NAIPivotConsumer *instance, gint order_mode )
+{
+ static const gchar *thisfn = "nautilus_actions_display_order_changed_handler";
+ NautilusActions *self;
+
+ g_debug( "%s: instance=%p, order_mode=%d", thisfn, ( void * ) instance, order_mode );
+ g_return_if_fail( NAUTILUS_IS_ACTIONS( instance ));
+ self = NAUTILUS_ACTIONS( instance );
+ if( !self->private->dispose_has_run ){
nautilus_menu_provider_emit_items_updated_signal( NAUTILUS_MENU_PROVIDER( self ));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]