[nautilus-actions] Let the UI immediately reacts when the status of an I/O provider changes
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Let the UI immediately reacts when the status of an I/O provider changes
- Date: Tue, 10 Aug 2010 19:53:52 +0000 (UTC)
commit b35f76b9288333ea1e8e516ea41388232978739f
Author: pierre <pierre vfedora10 virtuals pwi>
Date: Tue Aug 10 16:24:12 2010 +0200
Let the UI immediately reacts when the status of an I/O provider changes
ChangeLog | 13 ++++
TODO | 13 ++--
src/core/na-ipivot-consumer.c | 27 +++++++-
src/core/na-ipivot-consumer.h | 35 ++++++----
src/core/na-pivot.c | 39 +++++++---
src/nact/nact-main-window.c | 161 +++++++++++++++++++----------------------
6 files changed, 167 insertions(+), 121 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5b1d39b..5c79afd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2010-08-09 Pierre Wieser <pwieser trychlos org>
+ Immediately reacts to a status change in I/O providers.
+
+ * src/core/na-ipivot-consumer.c:
+ * src/core/na-ipivot-consumer.h
+ (na_ipivot_consumer_notify_of_io_provider_prefs_changed): New function.
+ (on_io_provider_prefs_changed): New interface API.
+
+ * src/core/na-pivot.c (monitor_runtime_preferences):
+ Add a monitor on io-providers GConf branch.
+
+ * src/nact/nact-main-window.c
+ (ipivot_consumer_on_io_provider_prefs_changed): New function.
+
Controls are not modifiable for a read-only item.
* src/nact/nact-gtk-utils.c:
diff --git a/TODO b/TODO
index a40ac34..537cf63 100644
--- a/TODO
+++ b/TODO
@@ -25,8 +25,6 @@ TODO
after deleting this default value in the UI, we should write basenames=[] in the I/O provider
so that we really have an empty list
-- nact_gtk_utils_set_editable for radio buttons and combobox
-
N-A ENHANCEMENTS
================
- allow users to upload/download actions directly from a web repository
@@ -36,20 +34,19 @@ N-A ENHANCEMENTS
the dialog box does not become taller of wider than the screen when there is a lot of
lines, making it unreadable
-- 2010-07-27: enhancement: while editing a new filter, making it duplicate, try to keep editing
+- 2010-07-27: while editing a new filter, making it duplicate, try to keep editing
instead of terminating the edition and letting the old value
-- 2010-08-09: ui.enhancement na-pivot:st_burst_timeout should be a preference
+- 2010-08-09: na-pivot:st_burst_timeout should be a preference
-- 2010-08-09: ui.enhancement: plugins should be able to provide a preference page
+- 2010-08-09: plugins should be able to provide a preference page
-- ui.enhancement: let the user edit the current default schemes
- when adding from defaults for a #NAIContext
+- let the user edit the current default schemes when adding from defaults for a #NAIContext
- 2010-06-17: ui enhancement
all edition (entry, buttons, etc.) fields should have a small emblem when read-only.
-- enhancement.ui: add a 'why this item is invalid'
+- add a 'why this item is invalid'
- nact-iactions-list.c: display_label
the 'editable' cell property should be set only once, instead of at each redraw
diff --git a/src/core/na-ipivot-consumer.c b/src/core/na-ipivot-consumer.c
index 04c609d..fe93e05 100644
--- a/src/core/na-ipivot-consumer.c
+++ b/src/core/na-ipivot-consumer.c
@@ -272,6 +272,31 @@ na_ipivot_consumer_notify_of_display_order_changed( NAIPivotConsumer *instance,
}
/**
+ * na_ipivot_consumer_notify_of_io_provider_prefs_changed:
+ * @instance: the #NAIPivotConsumer instance to be notified of the modifications.
+ *
+ * Notifies the consumers that an i/o provider preference has been changed.
+ */
+void na_ipivot_consumer_notify_of_io_provider_prefs_changed( NAIPivotConsumer *instance )
+{
+ static const gchar *thisfn = "na_ipivot_consumer_notify_of_io_provider_prefs_changed";
+
+ g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+
+ if( is_notify_allowed( instance )){
+
+ if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_io_provider_prefs_changed ){
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_io_provider_prefs_changed( instance );
+ }
+ }
+ }
+}
+
+/**
* na_ipivot_consumer_notify_of_items_changed:
* @instance: the #NAIPivotConsumer instance to be notified of the end
* of the modifications.
@@ -302,7 +327,7 @@ void na_ipivot_consumer_notify_of_items_changed( NAIPivotConsumer *instance )
* na_ipivot_consumer_notify_of_mandatory_prefs_changed:
* @instance: the #NAIPivotConsumer instance to be notified of the modifications.
*
- * Notifies the consumers that a mandatory 'locked' preference has been changed.
+ * Notifies the consumers that a mandatory preference has been changed.
*/
void na_ipivot_consumer_notify_of_mandatory_prefs_changed( NAIPivotConsumer *instance )
{
diff --git a/src/core/na-ipivot-consumer.h b/src/core/na-ipivot-consumer.h
index be36c58..a1a9bc3 100644
--- a/src/core/na-ipivot-consumer.h
+++ b/src/core/na-ipivot-consumer.h
@@ -69,7 +69,7 @@ typedef struct {
* auto-save preferences have been changed. Parameters are the new
* parameters of the configuration.
*/
- void ( *on_autosave_changed ) ( NAIPivotConsumer *instance, gboolean enabled, guint period );
+ void ( *on_autosave_changed ) ( NAIPivotConsumer *instance, gboolean enabled, guint period );
/**
* on_create_root_menu_changed:
@@ -80,7 +80,7 @@ typedef struct {
* This function is triggered each time the setting of the display
* of an 'About' item in the Nautilus context menu is changed.
*/
- void ( *on_create_root_menu_changed )( NAIPivotConsumer *instance, gboolean enabled );
+ void ( *on_create_root_menu_changed ) ( NAIPivotConsumer *instance, gboolean enabled );
/**
* on_display_about_changed:
@@ -91,7 +91,7 @@ typedef struct {
* 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, gboolean enabled );
+ void ( *on_display_about_changed ) ( NAIPivotConsumer *instance, gboolean enabled );
/**
* on_display_order_changed:
@@ -102,7 +102,15 @@ typedef struct {
* This function is triggered each time the display order preference
* is changed.
*/
- void ( *on_display_order_changed ) ( NAIPivotConsumer *instance, gint order_mode );
+ void ( *on_display_order_changed ) ( NAIPivotConsumer *instance, gint order_mode );
+
+ /**
+ * on_io_provider_prefs_changed:
+ * @instance: the #NAIPivotConsumer instance which implements this interface.
+ *
+ * This function is triggered each time an i/o provider preference is changed.
+ */
+ void ( *on_io_provider_prefs_changed )( NAIPivotConsumer *instance );
/**
* on_items_changed:
@@ -115,15 +123,15 @@ typedef struct {
* a bunch of modifications. At this time, the embedded list of
* #NAAction has been updated to be up to date.
*/
- void ( *on_items_changed ) ( NAIPivotConsumer *instance, gpointer user_data );
+ void ( *on_items_changed ) ( NAIPivotConsumer *instance, gpointer user_data );
/**
* on_mandatory_prefs_changed:
* @instance: the #NAIPivotConsumer instance which implements this interface.
*
- * This function is triggered each time a mandatory 'locked' preference is changed.
+ * This function is triggered each time a mandatory preference is changed.
*/
- void ( *on_mandatory_prefs_changed ) ( NAIPivotConsumer *instance );
+ void ( *on_mandatory_prefs_changed ) ( NAIPivotConsumer *instance );
}
NAIPivotConsumerInterface;
@@ -131,12 +139,13 @@ GType na_ipivot_consumer_get_type( void );
void na_ipivot_consumer_allow_notify( NAIPivotConsumer *instance, gboolean allow, guint delay );
-void na_ipivot_consumer_notify_of_autosave_changed ( NAIPivotConsumer *instance, gboolean enabled, guint period );
-void na_ipivot_consumer_notify_of_create_root_menu_changed( NAIPivotConsumer *instance, gboolean enabled );
-void na_ipivot_consumer_notify_of_display_about_changed ( NAIPivotConsumer *instance, gboolean enabled );
-void na_ipivot_consumer_notify_of_display_order_changed ( NAIPivotConsumer *instance, gint order_mode );
-void na_ipivot_consumer_notify_of_items_changed ( NAIPivotConsumer *instance );
-void na_ipivot_consumer_notify_of_mandatory_prefs_changed ( NAIPivotConsumer *instance );
+void na_ipivot_consumer_notify_of_autosave_changed ( NAIPivotConsumer *instance, gboolean enabled, guint period );
+void na_ipivot_consumer_notify_of_create_root_menu_changed ( NAIPivotConsumer *instance, gboolean enabled );
+void na_ipivot_consumer_notify_of_display_about_changed ( NAIPivotConsumer *instance, gboolean enabled );
+void na_ipivot_consumer_notify_of_display_order_changed ( NAIPivotConsumer *instance, gint order_mode );
+void na_ipivot_consumer_notify_of_io_provider_prefs_changed( NAIPivotConsumer *instance );
+void na_ipivot_consumer_notify_of_items_changed ( NAIPivotConsumer *instance );
+void na_ipivot_consumer_notify_of_mandatory_prefs_changed ( NAIPivotConsumer *instance );
G_END_DECLS
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index 22a3a79..d8b0cb2 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -91,7 +91,7 @@ enum {
static GObjectClass *st_parent_class = NULL;
-static gint st_burst_timeout = 200; /* burst timeout in msec */
+static gint st_burst_timeout = 100; /* burst timeout in msec */
static GType register_type( void );
static void class_init( NAPivotClass *klass );
@@ -115,6 +115,7 @@ static gulong time_val_diff( const GTimeVal *recent, const GTimeVal *old
/* NAGConf runtime preferences management */
static void monitor_runtime_preferences( NAPivot *pivot );
+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 );
@@ -936,30 +937,44 @@ monitor_runtime_preferences( NAPivot *pivot )
pivot ));
g_free( path );
+ path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, "io-providers" );
+ list = g_list_prepend( list,
+ na_gconf_monitor_new(
+ path,
+ ( GConfClientNotifyFunc ) on_io_provider_prefs_changed,
+ pivot ));
+ g_free( path );
+
pivot->private->monitors = list;
}
static void
-on_mandatory_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
+on_io_provider_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
{
- const gchar *key;
- gchar *key_entry;
GList *ic;
g_return_if_fail( NA_IS_PIVOT( pivot ));
if( !pivot->private->dispose_has_run ){
- key = gconf_entry_get_key( entry );
- key_entry = g_path_get_basename( key );
-
- if( !strcmp( key_entry, "locked" )){
- for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
- na_ipivot_consumer_notify_of_mandatory_prefs_changed( NA_IPIVOT_CONSUMER( ic->data ));
- }
+ for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
+ na_ipivot_consumer_notify_of_io_provider_prefs_changed( NA_IPIVOT_CONSUMER( ic->data ));
}
+ }
+}
+
+static void
+on_mandatory_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
+{
+ GList *ic;
- g_free( key_entry );
+ g_return_if_fail( NA_IS_PIVOT( pivot ));
+
+ if( !pivot->private->dispose_has_run ){
+
+ for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
+ na_ipivot_consumer_notify_of_mandatory_prefs_changed( NA_IPIVOT_CONSUMER( ic->data ));
+ }
}
}
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index f114d04..d8e7d8d 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -174,10 +174,10 @@ static void on_main_window_level_zero_order_changed( NactMainWindow *window,
static void on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
static void on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data );
static void raz_main_properties( NactMainWindow *window );
-static void set_current_object_item( NactMainWindow *window, GSList *selected_items );
-static void set_current_profile( NactMainWindow *window, gboolean set_action, GSList *selected_items );
-static gchar *iactions_list_get_treeview_name( NactIActionsList *instance );
+static void setup_current_selection( NactMainWindow *window, NAObjectId *selected_row );
static void setup_dialog_title( NactMainWindow *window );
+static void setup_writability_status( NactMainWindow *window );
+static gchar *iactions_list_get_treeview_name( NactIActionsList *instance );
static void on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display );
@@ -187,7 +187,9 @@ static void install_autosave( NactMainWindow *window );
static void ipivot_consumer_on_autosave_changed( NAIPivotConsumer *instance, gboolean enabled, guint period );
static void ipivot_consumer_on_items_changed( NAIPivotConsumer *instance, gpointer user_data );
static void ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gint order_mode );
+static void ipivot_consumer_on_io_provider_prefs_changed( NAIPivotConsumer *instance );
static void ipivot_consumer_on_mandatory_prefs_changed( NAIPivotConsumer *instance );
+static void update_ui_after_provider_change( NactMainWindow *window );
static void reload( NactMainWindow *window );
static gchar *iabout_get_application_name( NAIAbout *instance );
@@ -612,6 +614,7 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
iface->on_create_root_menu_changed = NULL;
iface->on_display_about_changed = NULL;
iface->on_display_order_changed = ipivot_consumer_on_display_order_changed;
+ iface->on_io_provider_prefs_changed = ipivot_consumer_on_io_provider_prefs_changed;
iface->on_items_changed = ipivot_consumer_on_items_changed;
iface->on_mandatory_prefs_changed = ipivot_consumer_on_mandatory_prefs_changed;
}
@@ -1230,10 +1233,7 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
{
static const gchar *thisfn = "nact_main_window_on_iactions_list_selection_changed";
NactMainWindow *window;
- NAObject *object;
gint count;
- NactApplication *application;
- NAUpdater *updater;
count = g_slist_length( selected_items );
@@ -1250,33 +1250,23 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
if( count == 1 ){
g_return_if_fail( NA_IS_OBJECT_ID( selected_items->data ));
- object = NA_OBJECT( selected_items->data );
-
- if( NA_IS_OBJECT_ITEM( object )){
- window->private->selected_item = NA_OBJECT_ITEM( object );
- set_current_object_item( window, selected_items );
-
- } else {
- g_assert( NA_IS_OBJECT_PROFILE( object ));
- window->private->selected_profile = NA_OBJECT_PROFILE( object );
- set_current_profile( window, TRUE, selected_items );
- }
-
- application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( instance )));
- updater = nact_application_get_updater( application );
- window->private->editable = na_updater_is_item_writable( updater, window->private->selected_item, &window->private->reason );
- nact_main_statusbar_set_locked( window, !window->private->editable, window->private->reason );
-
- } else {
- set_current_object_item( window, selected_items );
+ setup_current_selection( window, NA_OBJECT_ID( selected_items->data ));
+ setup_writability_status( window );
}
setup_dialog_title( window );
-
g_signal_emit_by_name( window, MAIN_WINDOW_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( count ));
}
static void
+on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
+{
+ g_debug( "nact_main_window_on_iactions_list_status_changed" );
+
+ setup_dialog_title( window );
+}
+
+static void
raz_main_properties( NactMainWindow *window )
{
window->private->selected_item = NULL;
@@ -1287,79 +1277,33 @@ raz_main_properties( NactMainWindow *window )
nact_main_statusbar_set_locked( window, FALSE, 0 );
}
-static void
-on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
-{
- g_debug( "nact_main_window_on_iactions_list_status_changed" );
-
- setup_dialog_title( window );
-}
-
/*
- * update the notebook when selection changes in ActionsList
- * if there is only one profile, we also setup the profile
- * count_profiles may be null (invalid action)
+ * enter after raz_properties
+ * only called when only one selected row
*/
static void
-set_current_object_item( NactMainWindow *window, GSList *selected_items )
+setup_current_selection( NactMainWindow *window, NAObjectId *selected_row )
{
- static const gchar *thisfn = "nact_main_window_set_current_object_item";
- gint count_profiles;
+ guint nb_profiles;
GList *profiles;
- /*NAObject *current;*/
- g_debug( "%s: window=%p, current=%p, selected_items=%p",
- thisfn, ( void * ) window, ( void * ) window->private->selected_item, ( void * ) selected_items );
-
- /* set the profile to be displayed, if any
- */
- window->private->selected_profile = NULL;
-
- if( window->private->selected_item ){
+ if( NA_IS_OBJECT_PROFILE( selected_row )){
+ window->private->selected_profile = NA_OBJECT_PROFILE( selected_row );
+ window->private->selected_item = NA_OBJECT_ITEM( na_object_get_parent( selected_row ));
- if( NA_IS_OBJECT_ACTION( window->private->selected_item )){
+ } else {
+ g_return_if_fail( NA_IS_OBJECT_ITEM( selected_row ));
+ window->private->selected_item = NA_OBJECT_ITEM( selected_row );
- count_profiles = na_object_get_items_count( window->private->selected_item );
- /*g_return_if_fail( count_profiles >= 1 );*/
+ if( NA_IS_OBJECT_ACTION( selected_row )){
+ nb_profiles = na_object_get_items_count( selected_row );
- if( count_profiles == 1 ){
- profiles = na_object_get_items( window->private->selected_item );
+ if( nb_profiles == 1 ){
+ profiles = na_object_get_items( selected_row );
window->private->selected_profile = NA_OBJECT_PROFILE( profiles->data );
}
}
}
-
- set_current_profile( window, FALSE, selected_items );
-}
-
-static void
-set_current_profile( NactMainWindow *window, gboolean set_action, GSList *selected_items )
-{
- static const gchar *thisfn = "nact_main_window_set_current_profile";
-
- g_debug( "%s: window=%p, set_action=%s, selected_items=%p",
- thisfn, ( void * ) window, set_action ? "True":"False", ( void * ) selected_items );
-
- if( window->private->selected_profile && set_action ){
-
- NAObjectAction *action = NA_OBJECT_ACTION( na_object_get_parent( window->private->selected_profile ));
- NactApplication *application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
- NAUpdater *updater = nact_application_get_updater( application );
- window->private->selected_item = NA_OBJECT_ITEM( action );
- window->private->editable = na_updater_is_item_writable( updater, window->private->selected_item, &window->private->reason );
- }
-}
-
-static gchar *
-iactions_list_get_treeview_name( NactIActionsList *instance )
-{
- gchar *name = NULL;
-
- g_return_val_if_fail( NACT_IS_MAIN_WINDOW( instance ), NULL );
-
- name = g_strdup( "ActionsList" );
-
- return( name );
}
/*
@@ -1403,6 +1347,32 @@ setup_dialog_title( NactMainWindow *window )
}
static void
+setup_writability_status( NactMainWindow *window )
+{
+ NactApplication *application;
+ NAUpdater *updater;
+
+ g_return_if_fail( NA_IS_OBJECT_ITEM( window->private->selected_item ));
+
+ application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+ updater = nact_application_get_updater( application );
+ window->private->editable = na_updater_is_item_writable( updater, window->private->selected_item, &window->private->reason );
+ nact_main_statusbar_set_locked( window, !window->private->editable, window->private->reason );
+}
+
+static gchar *
+iactions_list_get_treeview_name( NactIActionsList *instance )
+{
+ gchar *name = NULL;
+
+ g_return_val_if_fail( NACT_IS_MAIN_WINDOW( instance ), NULL );
+
+ name = g_strdup( "ActionsList" );
+
+ return( name );
+}
+
+static void
on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display )
{
/*static const gchar *thisfn = "nact_main_window_on_tab_updatable_item_updated";*/
@@ -1569,9 +1539,26 @@ ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gint order
}
static void
+ipivot_consumer_on_io_provider_prefs_changed( NAIPivotConsumer *instance )
+{
+ update_ui_after_provider_change( NACT_MAIN_WINDOW( instance ));
+}
+
+static void
ipivot_consumer_on_mandatory_prefs_changed( NAIPivotConsumer *instance )
{
- nact_sort_buttons_level_zero_writability_change( NACT_MAIN_WINDOW( instance ));
+ update_ui_after_provider_change( NACT_MAIN_WINDOW( instance ));
+}
+
+static void
+update_ui_after_provider_change( NactMainWindow *window )
+{
+ nact_sort_buttons_level_zero_writability_change( window );
+
+ if( window->private->selected_item ){
+ setup_writability_status( window );
+ g_signal_emit_by_name( window, MAIN_WINDOW_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( 1 ));
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]