[nautilus-actions] Do not allow edition when item is read-only



commit a33ed11b1bcd86c79c47d6d8b78e0b3b7d34767b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Dec 2 23:00:20 2009 +0100

    Do not allow edition when item is read-only

 ChangeLog                                    |   15 +++++++++++
 TODO                                         |    2 -
 nautilus-actions/nact/nact-iaction-tab.c     |   35 ++++++++++++++++++++------
 nautilus-actions/nact/nact-iadvanced-tab.c   |   15 +++++++++++
 nautilus-actions/nact/nact-ibackground-tab.c |   13 +++++++++
 nautilus-actions/nact/nact-icommand-tab.c    |   14 ++++++++++
 nautilus-actions/nact/nact-iconditions-tab.c |   33 ++++++++++++++++++++----
 nautilus-actions/nact/nact-main-menubar.c    |   11 +++++---
 8 files changed, 118 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b3aae59..194de10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2009-12-02 Pierre Wieser <pwieser trychlos org>
+
+	* nautilus-actions/nact/nact-iaction-tab.c
+	(on_tab_updatable_selection_changed):
+	* nautilus-actions/nact/nact-iadvanced-tab.c
+	(on_tab_updatable_selection_changed):
+	* nautilus-actions/nact/nact-ibackground-tab.c
+	(on_tab_updatable_selection_changed):
+	* nautilus-actions/nact/nact-icommand-tab.c
+	(on_tab_updatable_selection_changed):
+	* nautilus-actions/nact/nact-iconditions-tab.c
+	(on_tab_updatable_selection_changed):
+	* nautilus-actions/nact/nact-main-menubar.c (on_update_sensitivities):
+	Do not allow edition if item is read-only.
+
 2009-12-01 Pierre Wieser <pwieser trychlos org>
 
 	* nautilus-actions/nact/nact-iaction-tab.c
diff --git a/TODO b/TODO
index 5036e61..dfdefc4 100644
--- a/TODO
+++ b/TODO
@@ -95,8 +95,6 @@
   this implies dnd of an action inside of the menu would be forbidden
   id. for reordering if subitems
 
-- nact: if item is read-only, all fields should be disabled
-
 - nact: new action assistant
 
 - check that having an id which is not a UUID is supported
diff --git a/nautilus-actions/nact/nact-iaction-tab.c b/nautilus-actions/nact/nact-iaction-tab.c
index 73c8f0d..4e6c50f 100644
--- a/nautilus-actions/nact/nact-iaction-tab.c
+++ b/nautilus-actions/nact/nact-iaction-tab.c
@@ -369,10 +369,13 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 	gboolean same_label;
 	GtkWidget *label_widget, *tooltip_widget, *icon_widget, *title_widget;
 	gchar *label, *tooltip, *icon;
+	GtkButton *icon_button;
 	GtkButton *enabled_button;
+	GtkToggleButton *readonly_button;
 	gboolean enabled_item;
 	GtkToggleButton *toggle;
 	NAIIOProvider *provider;
+	gboolean readonly;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( BASE_IS_WINDOW( instance ));
@@ -404,13 +407,15 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		target_toolbar = (item && (
 				( NA_IS_OBJECT_ACTION( item ) && na_object_action_is_target_toolbar( NA_OBJECT_ACTION( item )))));
 
+		readonly = item ? na_object_is_readonly( item ) : FALSE;
+
 		toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetSelectionButton" ));
 		gtk_toggle_button_set_active( toggle, target_selection );
-		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ));
+		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ) && !readonly );
 
 		toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetBackgroundButton" ));
 		gtk_toggle_button_set_active( toggle, target_background );
-		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ));
+		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ) && !readonly );
 
 		enable_label = ( item && ( NA_IS_OBJECT_MENU( item ) || target_selection || target_background ));
 		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionMenuLabelEntry" );
@@ -420,11 +425,11 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 			check_for_label( instance, GTK_ENTRY( label_widget ), label );
 		}
 		g_free( label );
-		gtk_widget_set_sensitive( label_widget, enable_label );
+		gtk_widget_set_sensitive( label_widget, enable_label && !readonly );
 
 		toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionTargetToolbarButton" ));
 		gtk_toggle_button_set_active( toggle, target_toolbar );
-		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ));
+		gtk_widget_set_sensitive( GTK_WIDGET( toggle ), item && NA_IS_OBJECT_ACTION( item ) && !readonly );
 
 		toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ToolbarSameLabelButton" ));
 		same_label = item && NA_IS_OBJECT_ACTION( item ) ? na_object_action_toolbar_use_same_label( NA_OBJECT_ACTION( item )) : FALSE;
@@ -441,11 +446,16 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		tooltip = item ? na_object_get_tooltip( item ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( tooltip_widget ), tooltip );
 		g_free( tooltip );
+		gtk_widget_set_sensitive( tooltip_widget, item && !readonly );
 
 		icon_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconComboBoxEntry" );
 		icon = item ? na_object_get_icon( item ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( GTK_BIN( icon_widget )->child ), icon );
 		g_free( icon );
+		gtk_widget_set_sensitive( icon_widget, item && !readonly );
+
+		icon_button = GTK_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionIconBrowseButton" ));
+		gtk_widget_set_sensitive( GTK_WIDGET( icon_button ), item && !readonly );
 
 		title_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionPropertiesTitle" );
 		if( item && NA_IS_OBJECT_MENU( item )){
@@ -457,11 +467,17 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		enabled_button = get_enabled_button( instance );
 		enabled_item = item ? na_object_is_enabled( NA_OBJECT_ITEM( item )) : FALSE;
 		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( enabled_button ), enabled_item );
+		gtk_widget_set_sensitive( GTK_WIDGET( enabled_button ), item && !readonly );
+
+		readonly_button = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ActionReadonlyButton" ));
+		gtk_toggle_button_set_active( readonly_button, readonly );
+		gtk_widget_set_sensitive( GTK_WIDGET( readonly_button ), FALSE );
 
 		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemID" );
 		label = item ? na_object_get_id( item ) : g_strdup( "" );
 		gtk_label_set_text( GTK_LABEL( label_widget ), label );
 		g_free( label );
+		gtk_widget_set_sensitive( label_widget, item && !readonly );
 
 		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionItemProvider" );
 		label = NULL;
@@ -476,8 +492,7 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		}
 		gtk_label_set_text( GTK_LABEL( label_widget ), label );
 		g_free( label );
-
-		/* TODO: manage read-only flag */
+		gtk_widget_set_sensitive( label_widget, item && !readonly );
 	}
 }
 
@@ -661,10 +676,12 @@ toolbar_same_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item )
 {
 	GtkToggleButton *toggle;
 	gboolean target_toolbar;
+	gboolean readonly;
 
+	readonly = item ? na_object_is_readonly( item ) : FALSE;
 	toggle = GTK_TOGGLE_BUTTON( base_window_get_widget( BASE_WINDOW( instance ), "ToolbarSameLabelButton" ));
 	target_toolbar = item && NA_IS_OBJECT_ACTION( item ) ? na_object_action_is_target_toolbar( NA_OBJECT_ACTION( item )) : FALSE;
-	gtk_widget_set_sensitive( GTK_WIDGET( toggle ), target_toolbar );
+	gtk_widget_set_sensitive( GTK_WIDGET( toggle ), target_toolbar && !readonly );
 }
 
 static void
@@ -692,12 +709,14 @@ toolbar_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item )
 {
 	gboolean is_action;
 	gboolean same_label;
+	gboolean readonly;
 	GtkWidget *label_widget;
 
 	is_action = item && NA_IS_OBJECT_ACTION( item );
+	readonly = item ? na_object_is_readonly( item ) : FALSE;
 	same_label = is_action ? na_object_action_toolbar_use_same_label( NA_OBJECT_ACTION( item )) : FALSE;
 	label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
-	gtk_widget_set_sensitive( label_widget, is_action && !same_label );
+	gtk_widget_set_sensitive( label_widget, is_action && !same_label && !readonly );
 }
 
 static void
diff --git a/nautilus-actions/nact/nact-iadvanced-tab.c b/nautilus-actions/nact/nact-iadvanced-tab.c
index adbbc65..3077b40 100644
--- a/nautilus-actions/nact/nact-iadvanced-tab.c
+++ b/nautilus-actions/nact/nact-iadvanced-tab.c
@@ -417,10 +417,13 @@ static void
 on_tab_updatable_selection_changed( NactIAdvancedTab *instance, gint count_selected )
 {
 	static const gchar *thisfn = "nact_iadvanced_tab_on_tab_updatable_selection_changed";
+	NAObjectItem *item;
 	NAObjectProfile *profile;
 	gboolean enable_tab;
 	GSList *schemes;
 	GtkTreeModel *scheme_model;
+	gboolean readonly;
+	GtkWidget *widget;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( NACT_IS_IADVANCED_TAB( instance ));
@@ -432,15 +435,27 @@ on_tab_updatable_selection_changed( NactIAdvancedTab *instance, gint count_selec
 
 		g_object_get(
 				G_OBJECT( instance ),
+				TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
 				TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
 				NULL );
 
+		readonly = item ? na_object_is_readonly( item ) : FALSE;
+
 		enable_tab = tab_set_sensitive( instance );
 
 		if( profile ){
 			schemes = na_object_profile_get_schemes( profile );
 			g_slist_foreach( schemes, ( GFunc ) set_action_schemes, scheme_model );
 		}
+
+		widget = GTK_WIDGET( get_schemes_tree_view( instance ));
+		gtk_widget_set_sensitive( widget, item && !readonly );
+
+		widget = base_window_get_widget( BASE_WINDOW( instance ), "AddSchemeButton" );
+		gtk_widget_set_sensitive( widget, item && !readonly );
+
+		widget = base_window_get_widget( BASE_WINDOW( instance ), "RemoveSchemeButton" );
+		gtk_widget_set_sensitive( widget, item && !readonly );
 	}
 }
 
diff --git a/nautilus-actions/nact/nact-ibackground-tab.c b/nautilus-actions/nact/nact-ibackground-tab.c
index 74ac616..deede06 100644
--- a/nautilus-actions/nact/nact-ibackground-tab.c
+++ b/nautilus-actions/nact/nact-ibackground-tab.c
@@ -291,6 +291,8 @@ on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_sel
 	static const gchar *thisfn = "nact_ibackground_tab_on_tab_updatable_selection_changed";
 	NAObjectItem *item;
 	gboolean enable_tab;
+	gboolean readonly;
+	GtkWidget *widget;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( NACT_IS_IBACKGROUND_TAB( instance ));
@@ -306,11 +308,22 @@ on_tab_updatable_selection_changed( NactIBackgroundTab *instance, gint count_sel
 
 		g_return_if_fail( !item || NA_IS_OBJECT_ITEM( item ));
 
+		readonly = item ? na_object_is_readonly( item ) : FALSE;
+
 		enable_tab = tab_set_sensitive( instance );
 
 		if( item && NA_IS_OBJECT_ACTION( item )){
 			setup_folders( instance );
 		}
+
+		widget = base_window_get_widget( BASE_WINDOW( instance ), "FoldersTreeView" );
+		gtk_widget_set_sensitive( widget, item && !readonly );
+
+		widget = base_window_get_widget( BASE_WINDOW( instance ), "AddFolderButton" );
+		gtk_widget_set_sensitive( widget, item && !readonly );
+
+		widget = base_window_get_widget( BASE_WINDOW( instance ), "RemoveFolderButton" );
+		gtk_widget_set_sensitive( widget, item && !readonly );
 	}
 }
 
diff --git a/nautilus-actions/nact/nact-icommand-tab.c b/nautilus-actions/nact/nact-icommand-tab.c
index 6cf11bb..dcb99b9 100644
--- a/nautilus-actions/nact/nact-icommand-tab.c
+++ b/nautilus-actions/nact/nact-icommand-tab.c
@@ -319,6 +319,9 @@ on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_select
 	gboolean enable_tab;
 	GtkWidget *label_entry, *path_entry, *parameters_entry;
 	gchar *label, *path, *parameters;
+	gboolean readonly;
+	GtkButton *path_button;
+	GtkButton *legend_button;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( NACT_IS_ICOMMAND_TAB( instance ));
@@ -333,21 +336,32 @@ on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_select
 
 		enable_tab = tab_set_sensitive( instance );
 
+		readonly = item ? na_object_is_readonly( item ) : FALSE;
+
 		label_entry = get_label_entry( instance );
 		label = profile ? na_object_get_label( profile ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( label_entry ), label );
 		check_for_label( instance, GTK_ENTRY( label_entry ), label );
 		g_free( label );
+		gtk_widget_set_sensitive( label_entry, profile && !readonly );
 
 		path_entry = get_path_entry( instance );
 		path = profile ? na_object_profile_get_path( profile ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( path_entry ), path );
 		g_free( path );
+		gtk_widget_set_sensitive( path_entry, profile && !readonly );
+
+		path_button = get_path_button( instance );
+		gtk_widget_set_sensitive( GTK_WIDGET( path_button ), profile && !readonly );
 
 		parameters_entry = get_parameters_entry( instance );
 		parameters = profile ? na_object_profile_get_parameters( profile ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( parameters_entry ), parameters );
 		g_free( parameters );
+		gtk_widget_set_sensitive( parameters_entry, profile && !readonly );
+
+		legend_button = get_legend_button( instance );
+		gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile && !readonly );
 	}
 }
 
diff --git a/nautilus-actions/nact/nact-iconditions-tab.c b/nautilus-actions/nact/nact-iconditions-tab.c
index 78ec16e..8bfe311 100644
--- a/nautilus-actions/nact/nact-iconditions-tab.c
+++ b/nautilus-actions/nact/nact-iconditions-tab.c
@@ -73,7 +73,7 @@ static void       on_isfiledir_toggled( GtkToggleButton *button, NactIConditions
 static void       on_matchcase_toggled( GtkToggleButton *button, NactIConditionsTab *instance );
 static void       on_mimetypes_changed( GtkEntry *entry, NactIConditionsTab *instance );
 static void       on_multiple_toggled( GtkToggleButton *button, NactIConditionsTab *instance );
-static void       set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir );
+static void       set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir, gboolean readonly );
 
 GType
 nact_iconditions_tab_get_type( void )
@@ -298,6 +298,7 @@ static void
 on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_selected )
 {
 	static const gchar *thisfn = "nact_iconditions_tab_on_tab_updatable_selection_changed";
+	NAObjectItem *item;
 	NAObjectProfile *profile;
 	gboolean enable_tab;
 	GtkWidget *basenames_widget, *mimetypes_widget;
@@ -308,6 +309,7 @@ on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_sel
 	gboolean isfile, isdir;
 	GtkButton *multiple_button;
 	gboolean multiple;
+	gboolean readonly;
 
 	g_debug( "%s: instance=%p, count_selected=%d", thisfn, ( void * ) instance, count_selected );
 	g_return_if_fail( NACT_IS_ICONDITIONS_TAB( instance ));
@@ -316,9 +318,12 @@ on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_sel
 
 		g_object_get(
 				G_OBJECT( instance ),
+				TAB_UPDATABLE_PROP_EDITED_ACTION, &item,
 				TAB_UPDATABLE_PROP_EDITED_PROFILE, &profile,
 				NULL );
 
+		readonly = item ? na_object_is_readonly( item ) : FALSE;
+
 		enable_tab = tab_set_sensitive( instance );
 
 		basenames_widget = get_basenames_entry( instance );
@@ -327,10 +332,12 @@ on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_sel
 		gtk_entry_set_text( GTK_ENTRY( basenames_widget ), basenames_text );
 		g_free( basenames_text );
 		na_utils_free_string_list( basenames );
+		gtk_widget_set_sensitive( basenames_widget, item && !readonly );
 
 		matchcase_button = get_matchcase_button( instance );
 		matchcase = profile ? na_object_profile_get_matchcase( profile ) : FALSE;
 		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( matchcase_button ), matchcase );
+		gtk_widget_set_sensitive( GTK_WIDGET( matchcase_button ), item && !readonly );
 
 		mimetypes_widget = get_mimetypes_entry( instance );
 		mimetypes = profile ? na_object_profile_get_mimetypes( profile ) : NULL;
@@ -338,14 +345,16 @@ on_tab_updatable_selection_changed( NactIConditionsTab *instance, gint count_sel
 		gtk_entry_set_text( GTK_ENTRY( mimetypes_widget ), mimetypes_text );
 		g_free( mimetypes_text );
 		na_utils_free_string_list( mimetypes );
+		gtk_widget_set_sensitive( mimetypes_widget, item && !readonly );
 
 		isfile = profile ? na_object_profile_get_is_file( profile ) : FALSE;
 		isdir = profile ? na_object_profile_get_is_dir( profile ) : FALSE;
-		set_isfiledir( instance, isfile, isdir );
+		set_isfiledir( instance, isfile, isdir, readonly );
 
 		multiple_button = get_multiple_button( instance );
 		multiple = profile ? na_object_profile_get_multiple( profile ) : FALSE;
 		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( multiple_button ), multiple );
+		gtk_widget_set_sensitive( GTK_WIDGET( multiple_button ), item && !readonly );
 	}
 }
 
@@ -532,15 +541,27 @@ on_multiple_toggled( GtkToggleButton *button, NactIConditionsTab *instance )
 }
 
 static void
-set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir )
+set_isfiledir( NactIConditionsTab *instance, gboolean isfile, gboolean isdir, gboolean readonly )
 {
+	GtkButton *both_button;
+	GtkButton *file_button;
+	GtkButton *dirs_button;
+
+	both_button = get_both_button( instance );
+	file_button = get_isfile_button( instance );
+	dirs_button = get_isdir_button( instance );
+
 	if( isfile && isdir ){
-		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_both_button( instance )), TRUE );
+		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( both_button ), TRUE );
 
 	} else if( isfile ){
-		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_isfile_button( instance )), TRUE );
+		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( file_button ), TRUE );
 
 	} else if( isdir ){
-		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( get_isdir_button( instance )), TRUE );
+		gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( dirs_button ), TRUE );
 	}
+
+	gtk_widget_set_sensitive( GTK_WIDGET( both_button ), !readonly );
+	gtk_widget_set_sensitive( GTK_WIDGET( file_button ), !readonly );
+	gtk_widget_set_sensitive( GTK_WIDGET( dirs_button ), !readonly );
 }
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index 112665e..94d7949 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -601,6 +601,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	gboolean delete_enabled;
 	gboolean clipboard_is_empty;
 	gboolean new_item_enabled;
+	gboolean readonly;
 
 	g_debug( "%s: window=%p", thisfn, ( void * ) window );
 	g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -617,6 +618,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	g_return_if_fail( !profile || NA_IS_OBJECT_PROFILE( profile ));
 
 	has_modified = nact_main_window_has_modified_items( window );
+	readonly = item ? na_object_is_readonly( item ) : FALSE;
 
 	/* new menu enabled if selection is a menu or an action */
 	/* new action enabled if selection is a menu or an action */
@@ -624,8 +626,8 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	enable_item( window, "NewMenuItem", new_item_enabled );
 	enable_item( window, "NewActionItem", new_item_enabled );
 
-	/* new profile enabled if selection is relative to only one action */
-	enable_item( window, "NewProfileItem", item != NULL && !NA_IS_OBJECT_MENU( item ));
+	/* new profile enabled if selection is relative to only one writable action */
+	enable_item( window, "NewProfileItem", item != NULL && !NA_IS_OBJECT_MENU( item ) && !readonly );
 
 	/* save enabled if at least one item has been modified */
 	enable_item( window, "SaveItem", has_modified || mis->level_zero_order_changed );
@@ -639,10 +641,11 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 	count_selected = mis->selected_menus + mis->selected_actions + mis->selected_profiles;
 
 	/* cut/copy/duplicate/delete enabled when selection not empty */
-	cut_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0;
+	/* cut/delete require a writable item */
+	cut_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0 && !readonly;
 	copy_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0;
 	duplicate_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0;
-	delete_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0;
+	delete_enabled = ( mis->treeview_has_focus || mis->popup_handler ) && count_selected > 0 && !readonly;
 
 	/* paste enabled if
 	 * - simple selection



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