[nautilus-actions] No more notify the UI when a desktop file is modified



commit 4eca19834a1a5a0dcf7d32c26c50df0ca01cb714
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Jun 18 03:16:59 2010 +0200

    No more notify the UI when a desktop file is modified

 ChangeLog                              |    8 +++
 src/api/na-iio-provider.h              |    4 +-
 src/core/na-iio-provider.c             |    7 +--
 src/core/na-ipivot-consumer.c          |    6 ++-
 src/io-desktop/nadp-desktop-provider.c |   14 ++++-
 src/io-gconf/nagp-gconf-provider.c     |   88 +++----------------------------
 src/io-gconf/nagp-gconf-provider.h     |    3 +-
 7 files changed, 39 insertions(+), 91 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 609a40a..0c3b99b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-06-17 Pierre Wieser <pwieser trychlos org>
 
+	* src/api/na-iio-provider.h:
+	* src/core/na-iio-provider.c (na_iio_provider_item_changed):
+	Remove useless item id parameter.
+
+	* src/core/na-ipivot-consumer.c (is_notify_allowed):
+	Set a higher delay (1s to 2s) before notifying NAPivot
+	because of the delay of file monitoring.
+
 	* src/nact/nact-clipboard.c (export_objects):
 	Remove unused dest_folder parameter.
 
diff --git a/src/api/na-iio-provider.h b/src/api/na-iio-provider.h
index da313ec..e3107ad 100644
--- a/src/api/na-iio-provider.h
+++ b/src/api/na-iio-provider.h
@@ -199,10 +199,10 @@ typedef struct {
 GType na_iio_provider_get_type( void );
 
 /* This function is to be called by the I/O provider when it detects
- * that the specified object has been modified in its underlying storage
+ * that an object has been modified in its underlying storage
  * subsystem. It eventually ends up by sending a messages to the consumers.
  */
-void  na_iio_provider_item_changed ( const NAIIOProvider *instance, const gchar *id );
+void  na_iio_provider_item_changed ( const NAIIOProvider *instance );
 
 #define IIO_PROVIDER_SIGNAL_ITEM_CHANGED	"na-iio-provider-notify-pivot"
 
diff --git a/src/core/na-iio-provider.c b/src/core/na-iio-provider.c
index 63f7771..3567f09 100644
--- a/src/core/na-iio-provider.c
+++ b/src/core/na-iio-provider.c
@@ -177,7 +177,6 @@ do_is_able_to_write( const NAIIOProvider *instance )
 /**
  * na_iio_provider_item_changed:
  * @instance: the calling #NAIIOProvider.
- * @id: the id of the modified #NAObjectItem-derived object.
  *
  * Advertises Nautilus-Actions that this #NAIIOProvider @instance has
  * detected a modification in one of its configurations (menu or action).
@@ -186,11 +185,11 @@ do_is_able_to_write( const NAIIOProvider *instance )
  * derived modified objects, but (if possible) only once for each one.
  */
 void
-na_iio_provider_item_changed( const NAIIOProvider *instance, const gchar *id )
+na_iio_provider_item_changed( const NAIIOProvider *instance )
 {
 	static const gchar *thisfn = "na_iio_provider_item_changed";
 
-	g_debug( "%s: instance=%p, id=%s", thisfn, ( void * ) instance, id );
+	g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
 
-	g_signal_emit_by_name(( gpointer ) instance, IIO_PROVIDER_SIGNAL_ITEM_CHANGED, id );
+	g_signal_emit_by_name(( gpointer ) instance, IIO_PROVIDER_SIGNAL_ITEM_CHANGED, NULL );
 }
diff --git a/src/core/na-ipivot-consumer.c b/src/core/na-ipivot-consumer.c
index 761c889..11cc2b9 100644
--- a/src/core/na-ipivot-consumer.c
+++ b/src/core/na-ipivot-consumer.c
@@ -286,9 +286,10 @@ na_ipivot_consumer_notify_of_display_order_changed( NAIPivotConsumer *instance,
 static gboolean
 is_notify_allowed( const NAIPivotConsumer *instance )
 {
+	static const gchar *thisfn = "na_ipivot_consumer_is_notify_allowed";
 	GTimeVal *last_delay;
 	GTimeVal now;
-	glong ecart;
+	gulong ecart;
 
 	last_delay = ( GTimeVal * ) g_object_get_data( G_OBJECT( instance ), "na-ipivot-consumer-delay-notify" );
 	if( !last_delay ){
@@ -299,5 +300,6 @@ is_notify_allowed( const NAIPivotConsumer *instance )
 	ecart = 1000000 * ( now.tv_sec - last_delay->tv_sec );
 	ecart += now.tv_usec - last_delay->tv_usec;
 
-	return( ecart > 1000000 );
+	g_debug( "%s: ecart=%ld", thisfn, ecart );
+	return( ecart > 2000000 );
 }
diff --git a/src/io-desktop/nadp-desktop-provider.c b/src/io-desktop/nadp-desktop-provider.c
index f5c4665..9593c11 100644
--- a/src/io-desktop/nadp-desktop-provider.c
+++ b/src/io-desktop/nadp-desktop-provider.c
@@ -276,10 +276,16 @@ nadp_desktop_provider_add_monitor( NadpDesktopProvider *provider, const gchar *d
 void
 nadp_desktop_provider_on_monitor_event( NadpDesktopProvider *provider )
 {
+	static const gchar *thisfn = "nadp_desktop_provider_on_monitor_event";
+	GTimeVal now;
+
 	g_return_if_fail( NADP_IS_DESKTOP_PROVIDER( provider ));
 
 	if( !provider->private->dispose_has_run ){
 
+		g_get_current_time( &now );
+		g_debug( "%s: time=%ld.%ld", thisfn, now.tv_sec, now.tv_usec );
+
 		g_get_current_time( &provider->private->last_event );
 
 		if( !provider->private->event_source_id ){
@@ -311,17 +317,21 @@ nadp_desktop_provider_release_monitors( NadpDesktopProvider *provider )
 static gboolean
 on_monitor_timeout( NadpDesktopProvider *provider )
 {
+	static const gchar *thisfn = "nadp_desktop_provider_on_monitor_timeout";
 	GTimeVal now;
 	gulong diff;
 
+	g_debug( "%s", thisfn );
+
 	g_get_current_time( &now );
 	diff = time_val_diff( &now, &provider->private->last_event );
 	if( diff < st_timeout_usec ){
+		g_debug( "%s: unexpired timeout: returning True", thisfn );
 		return( TRUE );
 	}
 
-	na_iio_provider_item_changed( NA_IIO_PROVIDER( provider ), NULL );
-
+	g_debug( "%s: expired timeout: advertising IIOProvider, returning False", thisfn );
+	na_iio_provider_item_changed( NA_IIO_PROVIDER( provider ));
 	provider->private->event_source_id = 0;
 	return( FALSE );
 }
diff --git a/src/io-gconf/nagp-gconf-provider.c b/src/io-gconf/nagp-gconf-provider.c
index 46cd68a..0ff189f 100644
--- a/src/io-gconf/nagp-gconf-provider.c
+++ b/src/io-gconf/nagp-gconf-provider.c
@@ -70,11 +70,8 @@ static guint    ifactory_provider_get_version( const NAIFactoryProvider *provide
 
 static GList   *install_monitors( NagpGConfProvider *provider );
 static void     config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, NagpGConfProvider *provider );
-static void     config_path_changed_reset_timeout( NagpGConfProvider *provider );
-static void     config_path_changed_set_timeout( NagpGConfProvider *provider, const gchar *uuid );
 static gboolean config_path_changed_trigger_interface( NagpGConfProvider *provider );
 static gulong   time_val_diff( const GTimeVal *recent, const GTimeVal *old );
-static gchar   *entry2uuid( GConfEntry *entry );
 
 GType
 nagp_gconf_provider_get_type( void )
@@ -319,67 +316,23 @@ install_monitors( NagpGConfProvider *provider )
 static void
 config_path_changed_cb( GConfClient *client, guint cnxn_id, GConfEntry *entry, NagpGConfProvider *provider )
 {
-	/*static const gchar *thisfn = "nagp_gconf_provider_config_path_changed_cb";*/
-	gchar *uuid;
-
-	/*g_debug( "%s: client=%p, cnxnid=%u, entry=%p, provider=%p",
-			thisfn, ( void * ) client, cnxn_id, ( void * ) entry, ( void * ) provider );*/
-
 	g_return_if_fail( NAGP_IS_GCONF_PROVIDER( provider ));
 	g_return_if_fail( NA_IS_IIO_PROVIDER( provider ));
 
 	if( !provider->private->dispose_has_run ){
 
-		uuid = entry2uuid( entry );
-		/*g_debug( "%s: uuid=%s", thisfn, uuid );*/
-
-		if( provider->private->event_source_id ){
-			if( g_ascii_strcasecmp( uuid, provider->private->last_triggered_id )){
-
-				/* there already has a timeout, but on another object
-				 * so trigger the interface for the previous object
-				 * and set the timeout for the new object
-				 */
-				config_path_changed_trigger_interface( provider );
-				config_path_changed_set_timeout( provider, uuid );
-			}
+		g_get_current_time( &provider->private->last_event );
 
-			/* there already has a timeout for this same object
-			 * do nothing
-			 */
-
-		} else {
-			/* there was not yet any timeout: set it
-			 */
-			config_path_changed_set_timeout( provider, uuid );
+		if( !provider->private->event_source_id ){
+			provider->private->event_source_id =
+				g_timeout_add(
+						st_timeout_msec,
+						( GSourceFunc ) config_path_changed_trigger_interface,
+						provider );
 		}
-
-		g_free( uuid );
 	}
 }
 
-static void
-config_path_changed_reset_timeout( NagpGConfProvider *provider )
-{
-	g_free( provider->private->last_triggered_id );
-	provider->private->last_triggered_id = NULL;
-	/*provider->private->last_event = ( GTimeVal ) 0;*/
-	provider->private->event_source_id = 0;
-}
-
-static void
-config_path_changed_set_timeout( NagpGConfProvider *provider, const gchar *uuid )
-{
-	config_path_changed_reset_timeout( provider );
-	provider->private->last_triggered_id = g_strdup( uuid );
-	g_get_current_time( &provider->private->last_event );
-	provider->private->event_source_id =
-		g_timeout_add(
-				st_timeout_msec,
-				( GSourceFunc ) config_path_changed_trigger_interface,
-				provider );
-}
-
 /*
  * this timer is set when we receive the first event of a serie
  * we continue to loop until last event is at least one half of a
@@ -402,9 +355,9 @@ config_path_changed_trigger_interface( NagpGConfProvider *provider )
 		return( TRUE );
 	}
 
-	na_iio_provider_item_changed( NA_IIO_PROVIDER( provider ), provider->private->last_triggered_id );
+	na_iio_provider_item_changed( NA_IIO_PROVIDER( provider ));
+	provider->private->event_source_id = 0;
 
-	config_path_changed_reset_timeout( provider );
 	return( FALSE );
 }
 
@@ -418,26 +371,3 @@ time_val_diff( const GTimeVal *recent, const GTimeVal *old )
 	microsec += recent->tv_usec  - old->tv_usec;
 	return( microsec );
 }
-
-/*
- * gets the uuid from an entry
- */
-static gchar *
-entry2uuid( GConfEntry *entry )
-{
-	const gchar *path;
-	const gchar *subpath;
-	gchar **split;
-	gchar *uuid;
-
-	g_return_val_if_fail( entry, NULL );
-
-	path = gconf_entry_get_key( entry );
-	subpath = path + strlen( NAGP_CONFIGURATIONS_PATH ) + 1;
-	split = g_strsplit( subpath, "/", -1 );
-	/*g_debug( "%s: [0]=%s, [1]=%s", thisfn, split[0], split[1] );*/
-	uuid = g_strdup( split[0] );
-	g_strfreev( split );
-
-	return( uuid );
-}
diff --git a/src/io-gconf/nagp-gconf-provider.h b/src/io-gconf/nagp-gconf-provider.h
index 018f685..b143f4f 100644
--- a/src/io-gconf/nagp-gconf-provider.h
+++ b/src/io-gconf/nagp-gconf-provider.h
@@ -64,9 +64,8 @@ struct NagpGConfProviderPrivate {
 	gboolean     dispose_has_run;
 	GConfClient *gconf;
 	GList       *monitors;
-	GTimeVal     last_event;
 	guint        event_source_id;
-	gchar       *last_triggered_id;
+	GTimeVal     last_event;
 };
 
 typedef struct {



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