[nautilus-actions] Move 'read-only' property to NAObjectItem



commit 0876263cfa2eafcf95778b444f1a92780e2ef984
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Nov 25 21:32:31 2009 +0100

    Move 'read-only' property to NAObjectItem
    
    Actions and menus may be 'read-only'.

 ChangeLog                                        |   16 +++++
 TODO                                             |    5 ++
 nautilus-actions/api/na-object-api.h             |    2 +
 nautilus-actions/io-provider-gconf/nagp-read.c   |    2 +-
 nautilus-actions/io-provider-gconf/nagp-write.c  |   29 +++++++--
 nautilus-actions/private/na-object-action-fn.h   |    3 -
 nautilus-actions/private/na-object-action-priv.h |    6 --
 nautilus-actions/private/na-object-action.c      |   62 ------------------
 nautilus-actions/private/na-object-item-fn.h     |    2 +
 nautilus-actions/private/na-object-item-priv.h   |    6 ++
 nautilus-actions/private/na-object-item.c        |   75 ++++++++++++++++++++--
 11 files changed, 125 insertions(+), 83 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 59408bc..0bdba23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2009-11-25 Pierre Wieser <pwieser trychlos org>
 
+	Read-only flag is moved to NAObjectItem: action and menu may be
+	read-only.
+
+	* nautilus-actions/api/na-object-api.h
+	(na_object_is_readonly, na_object_set_readonly): New functions.
+
+	* nautilus-actions/private/na-object-action-fn.h:
+	* nautilus-actions/private/na-object-action-priv.h:
+	* nautilus-actions/private/na-object-action.c:
+	* nautilus-actions/private/na-object-item-fn.h:
+	* nautilus-actions/private/na-object-item-priv.h:
+	* nautilus-actions/private/na-object-item.c:
+	"read-only" property is moved from NAObjectAction to NAObjectItem.
+	(na_object_action_is_readonly): Renamed to na_object_item_is_readonly.
+	(na_object_action_set_readonly): Renamed to na_object_item_set_readonly.
+
 	* nautilus-actions/io-provider-desktop/egg-desktop-file.c:
 	* nautilus-actions/io-provider-desktop/egg-desktop-file.h:
 	New files.
diff --git a/TODO b/TODO
index 707639e..1823d64 100644
--- a/TODO
+++ b/TODO
@@ -90,3 +90,8 @@
 - have a preference to record default schemes
 
 - have a preference to record order of IO Providers
+
+- nact: add provider orig to displayed item properties
+
+- may we have a read-only menu ?
+  this implies dnd of an action inside of the menu would be forbidden
diff --git a/nautilus-actions/api/na-object-api.h b/nautilus-actions/api/na-object-api.h
index 01aa7cc..3dc39c1 100644
--- a/nautilus-actions/api/na-object-api.h
+++ b/nautilus-actions/api/na-object-api.h
@@ -94,6 +94,7 @@ G_BEGIN_DECLS
 #define na_object_get_icon( object )				na_object_item_get_icon( NA_OBJECT_ITEM( object ))
 #define na_object_get_provider( object )			na_object_item_get_provider( NA_OBJECT_ITEM( object ))
 #define na_object_is_enabled( object )				na_object_item_is_enabled( NA_OBJECT_ITEM( object ))
+#define na_object_is_readonly( object )				na_object_item_is_readonly( NA_OBJECT_ITEM( object ))
 #define na_object_get_item( object, id )			na_object_item_get_item( NA_OBJECT_ITEM( object ), id )
 #define na_object_get_items_list( object )			na_object_item_get_items_list( NA_OBJECT_ITEM( object ))
 #define na_object_get_items_count( object )			na_object_item_get_items_count( NA_OBJECT_ITEM( object ))
@@ -102,6 +103,7 @@ G_BEGIN_DECLS
 #define na_object_set_icon( object, icon )			na_object_item_set_icon( NA_OBJECT_ITEM( object ), icon )
 #define na_object_set_provider( object, provider )	na_object_item_set_provider( NA_OBJECT_ITEM( object ), provider )
 #define na_object_set_enabled( object, enabled )	na_object_item_set_enabled( NA_OBJECT_ITEM( object ), enabled )
+#define na_object_set_readonly( object, readonly )	na_object_item_set_readonly( NA_OBJECT_ITEM( object ), readonly )
 #define na_object_set_items_list( object, list )	na_object_item_set_items_list( NA_OBJECT_ITEM( object ), list )
 
 #define na_object_append_item( object, item )		na_object_item_append_item( NA_OBJECT_ITEM( object ), NA_OBJECT( item ))
diff --git a/nautilus-actions/io-provider-gconf/nagp-read.c b/nautilus-actions/io-provider-gconf/nagp-read.c
index e68ffd8..f5776fa 100644
--- a/nautilus-actions/io-provider-gconf/nagp-read.c
+++ b/nautilus-actions/io-provider-gconf/nagp-read.c
@@ -214,7 +214,7 @@ read_item_action( NagpGConfProvider *provider, const gchar *path, NAObjectAction
 	free_subdirs( list_profiles );
 	na_gconf_utils_free_entries( entries );
 
-	na_object_action_set_readonly( action, !nagp_key_is_writable( provider, path ));
+	/*na_object_action_set_readonly( action, !nagp_key_is_writable( provider, path ));*/
 }
 
 /*
diff --git a/nautilus-actions/io-provider-gconf/nagp-write.c b/nautilus-actions/io-provider-gconf/nagp-write.c
index 93ea94a..aa388bc 100644
--- a/nautilus-actions/io-provider-gconf/nagp-write.c
+++ b/nautilus-actions/io-provider-gconf/nagp-write.c
@@ -49,14 +49,17 @@ static gboolean       write_list( NagpGConfProvider *gconf, const gchar *uuid, c
 static void           free_gslist( GSList *list );
 
 /*
- *
+ * always returns TRUE because user _should_ be able to write its own
+ * configurations into ~/.gconf
  */
 gboolean
 nagp_iio_provider_is_willing_to_write( const NAIIOProvider *provider )
 {
+	static const gchar *thisfn = "nagp_iio_provider_is_willing_to_write";
 	NagpGConfProvider *self;
 	gboolean willing_to = FALSE;
 
+	g_debug( "%s: provider=%p", thisfn, ( void * ) provider );
 	g_return_val_if_fail( NAGP_IS_GCONF_PROVIDER( provider ), FALSE );
 	g_return_val_if_fail( NA_IS_IIO_PROVIDER( provider ), FALSE );
 	self = NAGP_GCONF_PROVIDER( provider );
@@ -293,22 +296,36 @@ nagp_iio_provider_delete_item( const NAIIOProvider *provider, const NAObjectItem
  * -> the UI may use the pivot inside of Nautilus extension via a sort
  *    of API, falling back to its own pivot, when the extension is not
  *    present.
+ *
+ * 2009-11-25 - it appears that gconf_client_key_is_writable() returns
+ * - FALSE for an existant dir (provided 'path')
+ * - FALSE for a non-existant entry
+ * - TRUE for an existant entry
  */
 gboolean
 nagp_key_is_writable( NagpGConfProvider *gconf, const gchar *path )
 {
-	/*static const gchar *thisfn = "nagp_gconf_provider_key_is_writable";
+	static const gchar *thisfn = "nagp_gconf_provider_key_is_writable";
 	GError *error = NULL;
+	gboolean is_writable;
+	gchar *key;
 
-	remove_gconf_watched_dir( gconf );
+	g_debug( "%s: gconf=%p, path=%s", thisfn, ( void * ) gconf, path );
 
-	gboolean ret_gconf = gconf_client_key_is_writable( gconf->private->gconf, path, &error );
+	/*remove_gconf_watched_dir( gconf );*/
+
+	key = gconf_concat_dir_and_key( path, "foo" );
+	is_writable = gconf_client_key_is_writable( gconf->private->gconf, key, &error );
+	g_debug( "%s: gconf_client_key_is_writable returns is_writable=%s", thisfn, is_writable ? "True":"False" );
 	if( error ){
 		g_warning( "%s: gconf_client_key_is_writable: %s", thisfn, error->message );
 		g_error_free( error );
 		error = NULL;
+		is_writable = FALSE;
 	}
-	gboolean ret_try = FALSE;
+	g_free( key );
+
+	/*gboolean ret_try = FALSE;
 	gchar *path_try = g_strdup_printf( "%s/%s", path, "fake_key" );
 	ret_try = gconf_client_set_string( gconf->private->gconf, path_try, "fake_value", &error );
 	if( error ){
@@ -325,7 +342,7 @@ nagp_key_is_writable( NagpGConfProvider *gconf, const gchar *path )
 	install_gconf_watched_dir( gconf );
 	return( ret_try );*/
 
-	return( TRUE );
+	return( is_writable );
 }
 
 static gboolean
diff --git a/nautilus-actions/private/na-object-action-fn.h b/nautilus-actions/private/na-object-action-fn.h
index e271c96..ac46cad 100644
--- a/nautilus-actions/private/na-object-action-fn.h
+++ b/nautilus-actions/private/na-object-action-fn.h
@@ -47,7 +47,6 @@ G_BEGIN_DECLS
 /* #NAObjectAction properties
  */
 #define NAACTION_PROP_VERSION				"na-action-version"
-#define NAACTION_PROP_READONLY				"na-action-read-only"
 #define NAACTION_PROP_LAST_ALLOCATED		"na-action-last-allocated"
 #define NAACTION_PROP_TOOLBAR_SAME_LABEL	"na-action-toolbar-use-same-label"
 #define NAACTION_PROP_TOOLBAR_LABEL			"na-action-toolbar-label"
@@ -72,7 +71,6 @@ NAObjectAction *na_object_action_new( void );
 NAObjectAction *na_object_action_new_with_profile( void );
 
 gchar          *na_object_action_get_version( const NAObjectAction *action );
-gboolean        na_object_action_is_readonly( const NAObjectAction *action );
 gboolean        na_object_action_is_target_selection( const NAObjectAction *action );
 gboolean        na_object_action_is_target_background( const NAObjectAction *action );
 gboolean        na_object_action_is_target_toolbar( const NAObjectAction *action );
@@ -80,7 +78,6 @@ gboolean        na_object_action_toolbar_use_same_label( const NAObjectAction *a
 gchar          *na_object_action_toolbar_get_label( const NAObjectAction *action );
 
 void            na_object_action_set_version( NAObjectAction *action, const gchar *version );
-void            na_object_action_set_readonly( NAObjectAction *action, gboolean readonly );
 void            na_object_action_set_target_selection( NAObjectAction *action, gboolean targeting );
 void            na_object_action_set_target_background( NAObjectAction *action, gboolean targeting );
 void            na_object_action_set_target_toolbar( NAObjectAction *action, gboolean targeting );
diff --git a/nautilus-actions/private/na-object-action-priv.h b/nautilus-actions/private/na-object-action-priv.h
index 03285a7..e9b8367 100644
--- a/nautilus-actions/private/na-object-action-priv.h
+++ b/nautilus-actions/private/na-object-action-priv.h
@@ -44,12 +44,6 @@ struct NAObjectActionPrivate {
 	 */
 	gchar   *version;
 
-	/* dynamically set when reading the actions from the I/O storage
-	 * subsystem
-	 * defaults to FALSE unless a write has already returned an error
-	 */
-	gboolean read_only;
-
 	/* last allocated profile name in na_object_action_get_new_profile_name()
 	 * reset to zero when saving the action
 	 */
diff --git a/nautilus-actions/private/na-object-action.c b/nautilus-actions/private/na-object-action.c
index 238a7ac..ecc736a 100644
--- a/nautilus-actions/private/na-object-action.c
+++ b/nautilus-actions/private/na-object-action.c
@@ -51,7 +51,6 @@ struct NAObjectActionClassPrivate {
  */
 enum {
 	NAACTION_PROP_VERSION_ID = 1,
-	NAACTION_PROP_READONLY_ID,
 	NAACTION_PROP_LAST_ALLOCATED_ID,
 	NAACTION_PROP_TARGET_SELECTION_ID,
 	NAACTION_PROP_TARGET_BACKGROUND_ID,
@@ -137,13 +136,6 @@ class_init( NAObjectActionClass *klass )
 			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
 	g_object_class_install_property( object_class, NAACTION_PROP_VERSION_ID, spec );
 
-	spec = g_param_spec_boolean(
-			NAACTION_PROP_READONLY,
-			"Read-only flag",
-			"Is this action only readable", FALSE,
-			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
-	g_object_class_install_property( object_class, NAACTION_PROP_READONLY_ID, spec );
-
 	spec = g_param_spec_int(
 			NAACTION_PROP_LAST_ALLOCATED,
 			"Last allocated counter",
@@ -216,7 +208,6 @@ instance_init( GTypeInstance *instance, gpointer klass )
 	/* initialize suitable default values
 	 */
 	self->private->version = g_strdup( NAUTILUS_ACTIONS_CONFIG_VERSION );
-	self->private->read_only = FALSE;
 	self->private->last_allocated = 0;
 	self->private->target_selection = TRUE;
 	self->private->target_background = FALSE;
@@ -240,10 +231,6 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
 				g_value_set_string( value, self->private->version );
 				break;
 
-			case NAACTION_PROP_READONLY_ID:
-				g_value_set_boolean( value, self->private->read_only );
-				break;
-
 			case NAACTION_PROP_LAST_ALLOCATED_ID:
 				g_value_set_int( value, self->private->last_allocated );
 				break;
@@ -291,10 +278,6 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
 				self->private->version = g_value_dup_string( value );
 				break;
 
-			case NAACTION_PROP_READONLY_ID:
-				self->private->read_only = g_value_get_boolean( value );
-				break;
-
 			case NAACTION_PROP_LAST_ALLOCATED_ID:
 				self->private->last_allocated = g_value_get_int( value );
 				break;
@@ -456,30 +439,6 @@ na_object_action_get_version( const NAObjectAction *action )
 }
 
 /**
- * na_object_action_is_readonly:
- * @action: the #NAObjectAction object to be requested.
- *
- * Is the specified action only readable ?
- * Or, in other words, may this action be edited and then saved to the
- * original I/O storage subsystem ?
- *
- * Returns: %TRUE if the action is read-only, %FALSE else.
- */
-gboolean
-na_object_action_is_readonly( const NAObjectAction *action )
-{
-	gboolean readonly = FALSE;
-
-	g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), FALSE );
-
-	if( !action->private->dispose_has_run ){
-		g_object_get( G_OBJECT( action ), NAACTION_PROP_READONLY, &readonly, NULL );
-	}
-
-	return( readonly );
-}
-
-/**
  * na_object_action_is_target_selection:
  * @action: the #NAObjectAction to be requested.
  *
@@ -628,23 +587,6 @@ na_object_action_set_version( NAObjectAction *action, const gchar *version )
 }
 
 /**
- * na_object_action_set_readonly:
- * @action: the #NAObjectAction object to be updated.
- * @readonly: the indicator to be set.
- *
- * Sets whether the action is readonly.
- */
-void
-na_object_action_set_readonly( NAObjectAction *action, gboolean readonly )
-{
-	g_return_if_fail( NA_IS_OBJECT_ACTION( action ));
-
-	if( !action->private->dispose_has_run ){
-		g_object_set( G_OBJECT( action ), NAACTION_PROP_READONLY, readonly, NULL );
-	}
-}
-
-/**
  * na_object_action_set_target_selection:
  * @action: the #NAObjectAction to be updated.
  * @targeting: whether @action targets selection menus.
@@ -865,7 +807,6 @@ object_dump( const NAObject *action )
 	if( !self->private->dispose_has_run ){
 
 		g_debug( "%s:           version='%s'", thisfn, self->private->version );
-		g_debug( "%s:         read-only='%s'", thisfn, self->private->read_only ? "True" : "False" );
 		g_debug( "%s:    last-allocated=%d", thisfn, self->private->last_allocated );
 		g_debug( "%s:  target-selection='%s'", thisfn, self->private->target_selection ? "True" : "False" );
 		g_debug( "%s: target-background='%s'", thisfn, self->private->target_background ? "True" : "False" );
@@ -885,7 +826,6 @@ void
 object_copy( NAObject *target, const NAObject *source )
 {
 	gchar *version;
-	gboolean readonly;
 	gint last_allocated;
 	GList *profiles, *ip;
 	gboolean target_selection, target_background, target_toolbar;
@@ -900,7 +840,6 @@ object_copy( NAObject *target, const NAObject *source )
 
 		g_object_get( G_OBJECT( source ),
 				NAACTION_PROP_VERSION, &version,
-				NAACTION_PROP_READONLY, &readonly,
 				NAACTION_PROP_LAST_ALLOCATED, &last_allocated,
 				NAACTION_PROP_TARGET_SELECTION, &target_selection,
 				NAACTION_PROP_TARGET_BACKGROUND, &target_background,
@@ -911,7 +850,6 @@ object_copy( NAObject *target, const NAObject *source )
 
 		g_object_set( G_OBJECT( target ),
 				NAACTION_PROP_VERSION, version,
-				NAACTION_PROP_READONLY, readonly,
 				NAACTION_PROP_LAST_ALLOCATED, last_allocated,
 				NAACTION_PROP_TARGET_SELECTION, target_selection,
 				NAACTION_PROP_TARGET_BACKGROUND, target_background,
diff --git a/nautilus-actions/private/na-object-item-fn.h b/nautilus-actions/private/na-object-item-fn.h
index cbe53e4..419f13b 100644
--- a/nautilus-actions/private/na-object-item-fn.h
+++ b/nautilus-actions/private/na-object-item-fn.h
@@ -59,6 +59,7 @@ GdkPixbuf     *na_object_item_get_pixbuf( const NAObjectItem *object, GtkWidget
 gint           na_object_item_get_position( const NAObjectItem *object, const NAObject *child );
 NAIIOProvider *na_object_item_get_provider( const NAObjectItem *item );
 gboolean       na_object_item_is_enabled( const NAObjectItem *item );
+gboolean       na_object_item_is_readonly( const NAObjectItem *action );
 NAObject      *na_object_item_get_item( const NAObjectItem *item, const gchar *id );
 GList         *na_object_item_get_items_list( const NAObjectItem *item );
 guint          na_object_item_get_items_count( const NAObjectItem *item );
@@ -69,6 +70,7 @@ void           na_object_item_set_tooltip( NAObjectItem *item, const gchar *tool
 void           na_object_item_set_icon( NAObjectItem *item, const gchar *icon_name );
 void           na_object_item_set_provider( NAObjectItem *item, const NAIIOProvider *provider );
 void           na_object_item_set_enabled( NAObjectItem *item, gboolean enabled );
+void           na_object_item_set_readonly( NAObjectItem *action, gboolean readonly );
 void           na_object_item_set_items_list( NAObjectItem *item, GList *items );
 
 void           na_object_item_append_item( NAObjectItem *object, const NAObject *item );
diff --git a/nautilus-actions/private/na-object-item-priv.h b/nautilus-actions/private/na-object-item-priv.h
index 2c0a31e..d1d43b7 100644
--- a/nautilus-actions/private/na-object-item-priv.h
+++ b/nautilus-actions/private/na-object-item-priv.h
@@ -54,6 +54,12 @@ struct NAObjectItemPrivate {
 	GList         *items;
 	GSList        *items_ids;
 
+	/* dynamically set when reading the actions from the I/O storage
+	 * subsystem
+	 * defaults to FALSE unless a write has already returned an error
+	 */
+	gboolean read_only;
+
 	/* the original provider
 	 * required to be able to edit/delete the item
 	 */
diff --git a/nautilus-actions/private/na-object-item.c b/nautilus-actions/private/na-object-item.c
index 95199a5..7e96829 100644
--- a/nautilus-actions/private/na-object-item.c
+++ b/nautilus-actions/private/na-object-item.c
@@ -54,6 +54,7 @@ enum {
 	NAOBJECT_ITEM_PROP_TOOLTIP_ID = 1,
 	NAOBJECT_ITEM_PROP_ICON_ID,
 	NAOBJECT_ITEM_PROP_ENABLED_ID,
+	NAOBJECT_ITEM_PROP_READONLY_ID,
 	NAOBJECT_ITEM_PROP_PROVIDER_ID,
 	NAOBJECT_ITEM_PROP_ITEMS_ID,
 };
@@ -61,6 +62,7 @@ enum {
 #define NAOBJECT_ITEM_PROP_TOOLTIP				"na-object-item-tooltip"
 #define NAOBJECT_ITEM_PROP_ICON					"na-object-item-icon"
 #define NAOBJECT_ITEM_PROP_ENABLED				"na-object-item-enabled"
+#define NAOBJECT_ITEM_PROP_READONLY				"na-object-item-read-only"
 #define NAOBJECT_ITEM_PROP_PROVIDER				"na-object-item-provider"
 #define NAOBJECT_ITEM_PROP_ITEMS				"na-object-item-items"
 
@@ -158,6 +160,13 @@ class_init( NAObjectItemClass *klass )
 			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
 	g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_ENABLED_ID, spec );
 
+	spec = g_param_spec_boolean(
+			NAOBJECT_ITEM_PROP_READONLY,
+			"Read-only flag",
+			"Is this item only readable", FALSE,
+			G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE );
+	g_object_class_install_property( object_class, NAOBJECT_ITEM_PROP_READONLY_ID, spec );
+
 	spec = g_param_spec_pointer(
 			NAOBJECT_ITEM_PROP_PROVIDER,
 			"Original provider",
@@ -200,6 +209,7 @@ instance_init( GTypeInstance *instance, gpointer klass )
 	self->private->tooltip = g_strdup( "" );
 	self->private->icon = g_strdup( "" );
 	self->private->enabled = TRUE;
+	self->private->read_only = FALSE;
 	self->private->provider = NULL;
 }
 
@@ -226,6 +236,10 @@ instance_get_property( GObject *object, guint property_id, GValue *value, GParam
 				g_value_set_boolean( value, self->private->enabled );
 				break;
 
+			case NAOBJECT_ITEM_PROP_READONLY_ID:
+				g_value_set_boolean( value, self->private->read_only );
+				break;
+
 			case NAOBJECT_ITEM_PROP_PROVIDER_ID:
 				g_value_set_pointer( value, self->private->provider );
 				break;
@@ -262,6 +276,10 @@ instance_set_property( GObject *object, guint property_id, const GValue *value,
 				self->private->enabled = g_value_get_boolean( value );
 				break;
 
+			case NAOBJECT_ITEM_PROP_READONLY_ID:
+				self->private->read_only = g_value_get_boolean( value );
+				break;
+
 			case NAOBJECT_ITEM_PROP_PROVIDER_ID:
 				self->private->provider = g_value_get_pointer( value );
 				break;
@@ -516,6 +534,30 @@ na_object_item_is_enabled( const NAObjectItem *item )
 }
 
 /**
+ * na_object_item_is_readonly:
+ * @item: the #NAObjectItem-derived object to be requested.
+ *
+ * Is the specified item only readable ?
+ * Or, in other words, may this item be edited and then saved to the
+ * original I/O storage subsystem ?
+ *
+ * Returns: %TRUE if the item is read-only, %FALSE else.
+ */
+gboolean
+na_object_item_is_readonly( const NAObjectItem *item )
+{
+	gboolean readonly = FALSE;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), FALSE );
+
+	if( !item->private->dispose_has_run ){
+		g_object_get( G_OBJECT( item ), NAOBJECT_ITEM_PROP_READONLY, &readonly, NULL );
+	}
+
+	return( readonly );
+}
+
+/**
  * na_object_item_get_item:
  * @item: the #NAObjectItem from which we want retrieve a subitem.
  * @id: the id of the searched subitem.
@@ -712,6 +754,23 @@ na_object_item_set_enabled( NAObjectItem *item, gboolean enabled )
 }
 
 /**
+ * na_object_item_set_readonly:
+ * @item: the #NAObjectItem-derived object to be updated.
+ * @readonly: the indicator to be set.
+ *
+ * Sets whether the item is readonly.
+ */
+void
+na_object_item_set_readonly( NAObjectItem *item, gboolean readonly )
+{
+	g_return_if_fail( NA_IS_OBJECT_ITEM( item ));
+
+	if( !item->private->dispose_has_run ){
+		g_object_set( G_OBJECT( item ), NAOBJECT_ITEM_PROP_READONLY, readonly, NULL );
+	}
+}
+
+/**
  * na_object_item_set_items_list:
  * @item: the #NAObjectItem whose subitems have to be set.
  * @list: a #GList list of #NAObject subitems to be installed.
@@ -945,10 +1004,11 @@ object_dump( const NAObject *item )
 
 	if( !NA_OBJECT_ITEM( item )->private->dispose_has_run ){
 
-		g_debug( "%s:  tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
-		g_debug( "%s:     icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
-		g_debug( "%s:  enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
-		g_debug( "%s: provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
+		g_debug( "%s:   tooltip='%s'", thisfn, NA_OBJECT_ITEM( item )->private->tooltip );
+		g_debug( "%s:      icon='%s'", thisfn, NA_OBJECT_ITEM( item )->private->icon );
+		g_debug( "%s:   enabled='%s'", thisfn, NA_OBJECT_ITEM( item )->private->enabled ? "True" : "False" );
+		g_debug( "%s: read-only='%s'", thisfn, NA_OBJECT_ITEM( item )->private->read_only ? "True" : "False" );
+		g_debug( "%s:  provider=%p", thisfn, ( void * ) NA_OBJECT_ITEM( item )->private->provider );
 
 		/* dump subitems */
 		g_debug( "%s: %d subitem(s) at %p",
@@ -968,6 +1028,7 @@ object_copy( NAObject *target, const NAObject *source )
 {
 	gchar *tooltip, *icon;
 	gboolean enabled;
+	gboolean readonly;
 	gpointer provider;
 	GList *subitems, *it;
 
@@ -981,6 +1042,7 @@ object_copy( NAObject *target, const NAObject *source )
 				NAOBJECT_ITEM_PROP_TOOLTIP, &tooltip,
 				NAOBJECT_ITEM_PROP_ICON, &icon,
 				NAOBJECT_ITEM_PROP_ENABLED, &enabled,
+				NAOBJECT_ITEM_PROP_READONLY, &readonly,
 				NAOBJECT_ITEM_PROP_PROVIDER, &provider,
 				NULL );
 
@@ -988,6 +1050,7 @@ object_copy( NAObject *target, const NAObject *source )
 				NAOBJECT_ITEM_PROP_TOOLTIP, tooltip,
 				NAOBJECT_ITEM_PROP_ICON, icon,
 				NAOBJECT_ITEM_PROP_ENABLED, enabled,
+				NAOBJECT_ITEM_PROP_READONLY, readonly,
 				NAOBJECT_ITEM_PROP_PROVIDER, provider,
 				NULL );
 
@@ -1008,7 +1071,7 @@ object_copy( NAObject *target, const NAObject *source )
  * @b: the object which has been initially duplicated from @a, and is
  * being checked for modification status.
  *
- * note 1: The provider is not considered as pertinent here
+ * note 1: The provider is not considered as relevant here
  *
  * note 2: as a particular case, this function is not recursive
  * because the equality test will stop as soon as it fails, and we so
@@ -1023,6 +1086,8 @@ object_copy( NAObject *target, const NAObject *source )
  * note 3: #NAObjectAction is considered as modified when at least one
  * of the profiles is itself modified (because they are saved as a
  * whole). See #NAObjectAction.
+ *
+ * note 4: the 'read-only' flag is not considered as relevant here
  */
 static gboolean
 object_are_equal( const NAObject *a, const NAObject *b )



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