[nautilus-actions] A modified profile implies a modified action



commit 6592bb3d605c222e684cbbe02039f3794f7c724d
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Feb 16 21:32:50 2011 +0100

    A modified profile implies a modified action

 ChangeLog                           |   11 +++++++++++
 src/core/na-factory-object.c        |   21 ++++++---------------
 src/core/na-icontext-factory.c      |   14 +++++++-------
 src/core/na-object-action-factory.c |    2 +-
 src/core/na-object-action.c         |   19 ++++++++++++++++++-
 src/core/na-object-id-factory.c     |    2 +-
 src/nact/nact-tree-ieditable.c      |    6 ++++--
 7 files changed, 48 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5cd2065..d9f0a37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-02-16 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-factory-object.c (na_factory_object_are_equal):
+	* src/nact/nact-tree-ieditable.c (on_object_modified_status_changed):
+	Improve debug messages.
+
+	* src/core/na-icontext-factory.c:
+	* src/core/na-object-action-factory.c:
+	* src/core/na-object-id-factory.c: Set missing default values.
+
+	* src/core/na-object-action.c (ifactory_object_are_equal):
+	An action is modified as soon as at least one profile is modified.
+
 	* src/core/na-icontext-factory.c: Fix string list regression
 
 	* src/core/na-boxed.c: Fix regression when setting values.
diff --git a/src/core/na-factory-object.c b/src/core/na-factory-object.c
index bae9cfc..3cf027f 100644
--- a/src/core/na-factory-object.c
+++ b/src/core/na-factory-object.c
@@ -325,11 +325,8 @@ na_factory_object_set_defaults( NAIFactoryObject *object )
 static gboolean
 set_defaults_iter( NADataDef *def, NafoDefaultIter *data )
 {
-	NADataBoxed *boxed;
-	gboolean is_null;
+	NADataBoxed *boxed = na_ifactory_object_get_data_boxed( data->object, def->name );
 
-	is_null = TRUE;
-	boxed = na_ifactory_object_get_data_boxed( data->object, def->name );
 	if( !boxed ){
 		boxed = na_data_boxed_new( def );
 		attach_boxed_to_object( data->object, boxed );
@@ -415,8 +412,8 @@ na_factory_object_copy( NAIFactoryObject *target, const NAIFactoryObject *source
 
 /*
  * na_factory_object_are_equal:
- * @a: the first #NAIFactoryObject instance.
- * @b: the second #NAIFactoryObject isntance.
+ * @a: the first (original) #NAIFactoryObject instance.
+ * @b: the second (current) #NAIFactoryObject isntance.
  *
  * Returns: %TRUE if @a is equal to @b, %FALSE else.
  */
@@ -448,7 +445,7 @@ na_factory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *
 
 			} else {
 				are_equal = FALSE;
-				g_debug( "%s: %s not equal as %s not set", thisfn, G_OBJECT_TYPE_NAME( a ), a_def->name );
+				g_debug( "%s: %s not equal as %s has disappeared", thisfn, G_OBJECT_TYPE_NAME( a ), a_def->name );
 			}
 		}
 	}
@@ -460,15 +457,9 @@ na_factory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *
 		if( b_def->comparable ){
 
 			NADataBoxed *a_boxed = na_ifactory_object_get_data_boxed( a, b_def->name );
-			if( a_boxed ){
-				are_equal = na_boxed_are_equal( NA_BOXED( a_boxed ), NA_BOXED( b_boxed ));
-				if( !are_equal ){
-					g_debug( "%s: %s not equal as %s different", thisfn, G_OBJECT_TYPE_NAME( a ), b_def->name );
-				}
-
-			} else {
+			if( !a_boxed ){
 				are_equal = FALSE;
-				g_debug( "%s: %s not equal as %s not set", thisfn, G_OBJECT_TYPE_NAME( a ), b_def->name );
+				g_debug( "%s: %s not equal as %s was not set", thisfn, G_OBJECT_TYPE_NAME( a ), b_def->name );
 			}
 		}
 	}
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index 9f6ae38..d85f342 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -354,7 +354,7 @@ NADataDef data_def_conditions [] = {
 				N_( "Only show in environment" ),
 				N_( "Defaults to all." ),
 				NA_DATA_TYPE_STRING_LIST,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -376,7 +376,7 @@ NADataDef data_def_conditions [] = {
 				N_( "Not show in environment" ),
 				N_( "Defaults to none." ),
 				NA_DATA_TYPE_STRING_LIST,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -402,7 +402,7 @@ NADataDef data_def_conditions [] = {
 					"Parameters may appear in 'TryExec' value, and will be substituted at runtime.\n" \
 					"Defaults to successful." ),
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -428,7 +428,7 @@ NADataDef data_def_conditions [] = {
 					"Parameters may appear in 'ShowIfRegistered' value, and will be substituted at runtime.\n" \
 					"Defaults to successful." ),
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -454,7 +454,7 @@ NADataDef data_def_conditions [] = {
 					"Parameters may appear in 'ShowIfTrue' value, and will be substituted at runtime.\n" \
 					"Defaults to successful." ),
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -480,7 +480,7 @@ NADataDef data_def_conditions [] = {
 					"Parameters may appear in 'ShowIfRunning' value, and will be substituted at runtime.\n" \
 					"Defaults to successful." ),
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
@@ -512,7 +512,7 @@ NADataDef data_def_conditions [] = {
 					"- 'Local': selected items are local.\n" \
 					"Defaults to empty list." ),
 				NA_DATA_TYPE_STRING_LIST,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
diff --git a/src/core/na-object-action-factory.c b/src/core/na-object-action-factory.c
index 6ab95fd..80a3821 100644
--- a/src/core/na-object-action-factory.c
+++ b/src/core/na-object-action-factory.c
@@ -54,7 +54,7 @@ static NADataDef data_def_action [] = {
 				"Version of the format",
 				"The version of the configuration format that will be used to manage backward compatibility.",
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
diff --git a/src/core/na-object-action.c b/src/core/na-object-action.c
index 3a2fac0..2e69849 100644
--- a/src/core/na-object-action.c
+++ b/src/core/na-object-action.c
@@ -335,10 +335,27 @@ ifactory_object_get_groups( const NAIFactoryObject *instance )
 	return( action_data_groups );
 }
 
+/*
+ * @a is the original object
+ * @b is the current one
+ *
+ * Even if they have both the same children list, the current action is
+ * considered modified as soon as one of its profile is itself modified.
+ */
 static gboolean
 ifactory_object_are_equal( const NAIFactoryObject *a, const NAIFactoryObject *b )
 {
-	return( na_object_item_are_equal( NA_OBJECT_ITEM( a ), NA_OBJECT_ITEM( b )));
+	GList *it;
+
+	if( na_object_item_are_equal( NA_OBJECT_ITEM( a ), NA_OBJECT_ITEM( b ))){
+		for( it = na_object_get_items( b ) ; it ; it = it->next ){
+			if( na_object_is_modified( it->data )){
+				return( FALSE );
+			}
+		}
+	}
+
+	return( TRUE );
 }
 
 static gboolean
diff --git a/src/core/na-object-id-factory.c b/src/core/na-object-id-factory.c
index 1cd99ae..64bc4f6 100644
--- a/src/core/na-object-id-factory.c
+++ b/src/core/na-object-id-factory.c
@@ -50,7 +50,7 @@ NADataDef data_def_id [] = {
 				"Historically a UUID used as a GConf directory (thus ASCII, case insensitive), " \
 				"it is also the basename of the .desktop file (thus UTF-8, case sensitive).",
 				NA_DATA_TYPE_STRING,
-				NULL,
+				"",
 				FALSE,
 				TRUE,
 				TRUE,
diff --git a/src/nact/nact-tree-ieditable.c b/src/nact/nact-tree-ieditable.c
index 6354c8e..8a8b684 100644
--- a/src/nact/nact-tree-ieditable.c
+++ b/src/nact/nact-tree-ieditable.c
@@ -312,8 +312,10 @@ on_object_modified_status_changed( NactTreeIEditable *instance, NAObject *object
 	gboolean prev_status, status;
 
 	if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
-		g_debug( "%s: instance=%p, is_modified=%s, window=%p",
-				thisfn, ( void * ) instance, is_modified ? "True":"False", ( void * ) window );
+		g_debug( "%s: instance=%p, object=%p (%s), is_modified=%s, window=%p",
+				thisfn, ( void * ) instance,
+				( void * ) object, G_OBJECT_TYPE_NAME( object ), is_modified ? "True":"False",
+				( void * ) window );
 
 		ied = ( IEditableData * ) g_object_get_data( G_OBJECT( instance ), VIEW_DATA_IEDITABLE );
 		prev_status = get_modification_status( ied );



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