[nautilus-actions: 5/19] Update the NactPivotNotify structure to handle profile name



commit ac767bb0e57778921c2d09fa2998e06aee090c49
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Jun 8 05:24:03 2009 +0200

    Update the NactPivotNotify structure to handle profile name
---
 ChangeLog               |    7 +++++++
 src/common/nact-gconf.c |   26 ++++++++++++++++++--------
 src/common/nact-pivot.c |    4 +++-
 src/common/nact-pivot.h |    1 +
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 593c435..0471d24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-06-07 Pierre Wieser <pwieser trychlos org>
 
+	* src/common/nact-pivot.c:
+	* src/common/nact-pivot.h:
+	* src/common/nact-gconf.c:
+	Update the NactPivotNotify structure to handle profile name.
+
+2009-06-07 Pierre Wieser <pwieser trychlos org>
+
 	Install the notification system.
 
 	* src/common/nautilus-actions.c:
diff --git a/src/common/nact-gconf.c b/src/common/nact-gconf.c
index 9fb244a..0f9feaf 100644
--- a/src/common/nact-gconf.c
+++ b/src/common/nact-gconf.c
@@ -468,16 +468,12 @@ set_item_properties( NactObject *object, GSList *properties )
 		NactPivotNotify *npn = entry_to_notify( entry );
 		if( npn ){
 
-			gchar **split = g_strsplit( npn->parm, "/", -1 );
-			gchar *parm = g_strdup( split[ g_strv_length( split ) -1 ] );
-			g_strfreev( split );
-
 			switch( npn->type ){
 
 				case NACT_PIVOT_STR:
 				case NACT_PIVOT_BOOL:
 				case NACT_PIVOT_STRLIST:
-					g_object_set( G_OBJECT( object ), parm, npn->data, NULL );
+					g_object_set( G_OBJECT( object ), npn->parm, npn->data, NULL );
 					break;
 
 				default:
@@ -485,13 +481,24 @@ set_item_properties( NactObject *object, GSList *properties )
 					break;
 			}
 			nact_pivot_free_notify( npn );
-			g_free( parm );
 		}
 	}
 }
 
 /*
  * convert a GConfEntry to a structure suitable to notify NactPivot
+ *
+ * when created or modified, the entry can be of the forms :
+ *  key/parm
+ *  key/profile/parm with a not null value
+ * but when removing an entry, it will be of the form :
+ *  key
+ *  key/parm
+ *  key/profile
+ *  key/profile/parm with a null value
+ * I don't know any way to choose between key/parm and key/profile
+ * as the entry no more exists in GConf and thus cannot be tested
+ * -> we will set this as key/parm, letting pivot try to interpret it
  */
 static NactPivotNotify *
 entry_to_notify( const GConfEntry *entry )
@@ -507,11 +514,14 @@ entry_to_notify( const GConfEntry *entry )
 	NactPivotNotify *npn = g_new0( NactPivotNotify, 1 );
 
 	const gchar *subpath = path + strlen( NACT_GCONF_CONFIG_PATH ) + 1;
-	gchar **split = g_strsplit( subpath, "/", 2 );
+	gchar **split = g_strsplit( subpath, "/", -1 );
 	/*g_debug( "%s: [0]=%s, [1]=%s", thisfn, split[0], split[1] );*/
 	npn->uuid = g_strdup( split[0] );
-	if( split[1] ){
+	if( g_strv_length( split ) == 2 ){
 		npn->parm = g_strdup( split[1] );
+	} else if( g_strv_length( split ) == 3 ){
+		npn->profile = g_strdup( split[1] );
+		npn->parm = g_strdup( split[2] );
 	}
 	g_strfreev( split );
 
diff --git a/src/common/nact-pivot.c b/src/common/nact-pivot.c
index d007296..0a6e37a 100644
--- a/src/common/nact-pivot.c
+++ b/src/common/nact-pivot.c
@@ -451,12 +451,14 @@ nact_pivot_free_notify( NactPivotNotify *npn )
 					break;
 
 				default:
-					g_debug( "nact_pivot_free_notify: uuid=%s, parm=%s, type=%d", npn->uuid, npn->parm, npn->type );
+					g_debug( "nact_pivot_free_notify: uuid=%s, profile=%s, parm=%s, type=%d",
+							npn->uuid, npn->profile, npn->parm, npn->type );
 					g_assert_not_reached();
 					break;
 			}
 		}
 		g_free( npn->uuid );
+		g_free( npn->profile );
 		g_free( npn->parm );
 		g_free( npn );
 	}
diff --git a/src/common/nact-pivot.h b/src/common/nact-pivot.h
index 6f8ff91..e67dcad 100644
--- a/src/common/nact-pivot.h
+++ b/src/common/nact-pivot.h
@@ -87,6 +87,7 @@ enum {
 
 typedef struct {
 	gchar   *uuid;
+	gchar   *profile;
 	gchar   *parm;
 	guint    type;
 	gpointer data;



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