[nautilus-actions] Locked down is a property of the item provider



commit 3c2faf2d4594de3c2cb718ed42d2cc6104ae89a0
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Dec 13 01:03:52 2009 +0100

    Locked down is a property of the item provider

 ChangeLog                                  |    8 +++++++
 nautilus-actions/nact/nact-iactions-list.c |    2 +-
 nautilus-actions/nact/nact-main-menubar.c  |    2 +-
 nautilus-actions/nact/nact-window.c        |   29 ++++++++++++++++++++++-----
 nautilus-actions/nact/nact-window.h        |    2 +-
 5 files changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 588dd59..58a0761 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-12-12 Pierre Wieser <pwieser trychlos org>
 
+	* nautilus-actions/nact/nact-window.c:
+	* nautilus-actions/nact/nact-window.h (nact_window_is_lockdown):
+	Check if the provider of the current item is locked down.
+
+	* nautilus-actions/nact/nact-main-menubar.c (on_update_sensitivities):
+	* nautilus-actions/nact/nact-iactions-list.c (display_label):
+	Updated accordingly.
+
 	* nautilus-actions/io-provider-gconf/nagp-gconf-provider.c:
 	* nautilus-actions/io-provider-desktop/nadp-desktop-provider.c
 	(get_id, get_version): New functions.
diff --git a/nautilus-actions/nact/nact-iactions-list.c b/nautilus-actions/nact/nact-iactions-list.c
index a0311f8..d1198a9 100644
--- a/nautilus-actions/nact/nact-iactions-list.c
+++ b/nautilus-actions/nact/nact-iactions-list.c
@@ -1641,7 +1641,7 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
 	g_object_unref( object );
 	g_return_if_fail( NA_IS_OBJECT( object ));
 
-	lockdown = nact_window_is_lockdown( NACT_WINDOW( instance ));
+	lockdown = nact_window_is_lockdown( NACT_WINDOW( instance ), NA_OBJECT_ITEM( object ));
 
 	ialid = get_instance_data( instance );
 	label = na_object_get_label( object );
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index 4122ae1..c9797ae 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -613,7 +613,6 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
 
 	mis = ( MenubarIndicatorsStruct * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_INDICATORS );
-	locked = nact_window_is_lockdown( NACT_WINDOW( window ));
 
 	g_object_get(
 			G_OBJECT( window ),
@@ -626,6 +625,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 
 	has_modified = nact_main_window_has_modified_items( window );
 	readonly = item ? na_object_is_readonly( item ) : FALSE;
+	locked = item ? nact_window_is_lockdown( NACT_WINDOW( window ), NA_OBJECT_ITEM( item )) : FALSE;
 
 	/* new menu enabled if selection is a menu or an action */
 	/* new action enabled if selection is a menu or an action */
diff --git a/nautilus-actions/nact/nact-window.c b/nautilus-actions/nact/nact-window.c
index cf0ffcd..f556824 100644
--- a/nautilus-actions/nact/nact-window.c
+++ b/nautilus-actions/nact/nact-window.c
@@ -39,6 +39,7 @@
 #include <api/na-object-api.h>
 
 #include <runtime/na-gconf-utils.h>
+#include <runtime/na-io-provider.h>
 #include <runtime/na-iprefs.h>
 #include <runtime/na-utils.h>
 
@@ -199,28 +200,44 @@ nact_window_get_pivot( NactWindow *window )
 /**
  * nact_window_is_lockdown:
  * @window: this #NactWindow instance.
+ * @item: the current item.
  *
- * Returns: %TRUE if the configuration is locked to be read-only, %FALSE
- * else.
+ * Returns: %TRUE if the configuration of the item's provider is locked
+ * to be read-only, %FALSE else.
+ *
+ * If the provider item has not yet any provider, i.e. has never been
+ * saved elsewhere, then we return %FALSE, assuming that we eventually
+ * find a willing-to-write provider.
  */
 gboolean
-nact_window_is_lockdown( NactWindow *window )
+nact_window_is_lockdown( NactWindow *window, const NAObjectItem *item )
 {
 	static const gchar *thisfn = "nact_window_is_lockdown";
 	gboolean locked;
 	NAPivot *pivot;
+	NAIIOProvider *provider;
+	gchar *id;
+	gchar *key;
 	GConfClient *gconf;
 
 	locked = FALSE;
 
 	g_return_val_if_fail( NACT_IS_WINDOW( window ), locked );
+	g_return_val_if_fail( NA_IS_OBJECT_ITEM( item ), locked );
 
 	if( !window->private->dispose_has_run ){
 
 		pivot = nact_window_get_pivot( window );
-		gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
-		locked = na_gconf_utils_read_bool( gconf, NAUTILUS_ACTIONS_GCONF_BASEDIR "/mandatory/lockdown", TRUE, locked );
-		g_debug( "%s: locked=%s", thisfn, locked ? "True":"False" );
+		provider = na_object_get_provider( item );
+		if( provider ){
+			id = na_io_provider_get_id( pivot, provider );
+			key = g_strdup_printf( "%s/mandatory/%s/lockdown", NAUTILUS_ACTIONS_GCONF_BASEDIR, id );
+			gconf = na_iprefs_get_gconf_client( NA_IPREFS( pivot ));
+			locked = na_gconf_utils_read_bool( gconf, key, TRUE, locked );
+			g_debug( "%s: id=%s, locked=%s", thisfn, id, locked ? "True":"False" );
+			g_free( key );
+			g_free( id );
+		}
 	}
 
 	return( locked );
diff --git a/nautilus-actions/nact/nact-window.h b/nautilus-actions/nact/nact-window.h
index b9ae80c..64b2bba 100644
--- a/nautilus-actions/nact/nact-window.h
+++ b/nautilus-actions/nact/nact-window.h
@@ -75,7 +75,7 @@ GType    nact_window_get_type( void );
 
 NAPivot *nact_window_get_pivot( NactWindow *window );
 
-gboolean nact_window_is_lockdown( NactWindow *window );
+gboolean nact_window_is_lockdown( NactWindow *window, const NAObjectItem *item );
 
 gboolean nact_window_save_item( NactWindow *window, NAObjectItem *item );
 gboolean nact_window_delete_item( NactWindow *window, const NAObjectItem *item );



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