[nautilus-actions] Fix profile label edition when action is not writable
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix profile label edition when action is not writable
- Date: Mon, 14 Dec 2009 18:47:39 +0000 (UTC)
commit 08f862f144867c42994d43da78ae7246a0eba55e
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Dec 13 12:48:17 2009 +0100
Fix profile label edition when action is not writable
ChangeLog | 19 ++++++++++++++++
TODO | 6 -----
nautilus-actions/io-provider-desktop/nadp-write.c | 3 +-
nautilus-actions/io-provider-gconf/nagp-write.c | 17 +++++---------
nautilus-actions/nact/nact-iactions-list.c | 6 +++-
nautilus-actions/nact/nact-main-menubar.c | 25 +++++++++++++++------
nautilus-actions/runtime/na-io-provider.c | 4 +-
nautilus-actions/runtime/na-pivot.c | 14 ++++++-----
8 files changed, 59 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7305113..52c7bfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2009-12-13 Pierre Wieser <pwieser trychlos org>
+
+ * nautilus-actions/io-provider-desktop/nadp-write.c
+ (nadp_iio_provider_is_willing_to_write):
+ * nautilus-actions/io-provider-gconf/nagp-write.c
+ (nagp_iio_provider_is_willing_to_write):
+ * nautilus-actions/runtime/na-io-provider.c
+ (na_io_provider_is_willing_to_write):
+ Remove too verbose debug traces.
+
+ * nautilus-actions/runtime/na-pivot.c
+ (na_pivot_has_writable_providers): Add a debug trace.
+
+ * nautilus-actions/nact/nact-iactions-list.c (display_label):
+ Profile label is editable only if parent action is writable.
+
+ * nautilus-actions/nact/nact-main-menubar.c (on_update_sensitivities):
+ Enable item insertion only if parent is writable.
+
2009-12-12 Pierre Wieser <pwieser trychlos org>
* nautilus-actions/nact/nact-window.c:
diff --git a/TODO b/TODO
index 5b2a01f..1c32c8f 100644
--- a/TODO
+++ b/TODO
@@ -103,9 +103,3 @@
all entry/button fields should be readonly
- add get_id/get_version to module api
-
-- when duplicating a profile
- na_object_item_is_readonly: assertion `NA_IS_OBJECT_ITEM( item )' failed
- GLib-GObject-WARNING **: invalid cast from `NAObjectProfile' to `NAObjectItem'
-
-- new/edit options depend of writability status of the parent menu if any
diff --git a/nautilus-actions/io-provider-desktop/nadp-write.c b/nautilus-actions/io-provider-desktop/nadp-write.c
index 80ed0d4..395726f 100644
--- a/nautilus-actions/io-provider-desktop/nadp-write.c
+++ b/nautilus-actions/io-provider-desktop/nadp-write.c
@@ -56,7 +56,8 @@ nadp_iio_provider_is_willing_to_write( const NAIIOProvider *provider )
willing_to = FALSE;
messages = NULL;
- g_debug( "%s: provider=%p", thisfn, ( void * ) provider );
+
+ /*g_debug( "%s: provider=%p", thisfn, ( void * ) provider );*/
g_return_val_if_fail( NADP_IS_DESKTOP_PROVIDER( provider ), willing_to );
userdir = nadp_xdg_data_dirs_get_user_dir( NADP_DESKTOP_PROVIDER( provider ), &messages );
diff --git a/nautilus-actions/io-provider-gconf/nagp-write.c b/nautilus-actions/io-provider-gconf/nagp-write.c
index 42146dd..76f2e2d 100644
--- a/nautilus-actions/io-provider-gconf/nagp-write.c
+++ b/nautilus-actions/io-provider-gconf/nagp-write.c
@@ -60,22 +60,20 @@ static void free_gslist( GSList *list );
gboolean
nagp_iio_provider_is_willing_to_write( const NAIIOProvider *provider )
{
- static const gchar *thisfn = "nagp_iio_provider_is_willing_to_write";
- static const gchar *path = "/apps/no-nautilus-actions";
+ /*static const gchar *thisfn = "nagp_iio_provider_is_willing_to_write";*/
+ static const gchar *path = "/apps/nautilus-actions/foo";
NagpGConfProvider *self;
gboolean willing_to = FALSE;
- gchar *key;
- g_debug( "%s: provider=%p", thisfn, ( void * ) provider );
+ /*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 );
if( !self->private->dispose_has_run ){
- key = gconf_concat_dir_and_key( path, thisfn );
-
- if( !na_gconf_utils_write_string( self->private->gconf, key, "1", NULL )){
+ if( !na_gconf_utils_write_string( self->private->gconf, path, "1", NULL )){
willing_to = FALSE;
} else if( !gconf_client_recursive_unset( self->private->gconf, path, 0, NULL )){
@@ -84,12 +82,9 @@ nagp_iio_provider_is_willing_to_write( const NAIIOProvider *provider )
} else {
willing_to = TRUE;
}
-
- g_free( key );
}
- g_debug( "%s: provider=%p, willing_to=%s", thisfn, ( void * ) provider, willing_to ? "True":"False" );
-
+ /*g_debug( "%s: provider=%p, willing_to=%s", thisfn, ( void * ) provider, willing_to ? "True":"False" );*/
return( willing_to );
}
diff --git a/nautilus-actions/nact/nact-iactions-list.c b/nautilus-actions/nact/nact-iactions-list.c
index dff13f8..a054139 100644
--- a/nautilus-actions/nact/nact-iactions-list.c
+++ b/nautilus-actions/nact/nact-iactions-list.c
@@ -1634,6 +1634,7 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
gboolean modified = FALSE;
gboolean valid = TRUE;
IActionsListInstanceData *ialid;
+ NAObjectItem *item;
gboolean writable_provider;
gboolean readonly_item;
@@ -1650,8 +1651,9 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
modified = na_object_is_modified( object );
valid = na_object_is_valid( object );
- readonly_item = na_object_is_readonly( object );
- writable_provider = nact_window_is_writable_provider( NACT_WINDOW( instance ), NA_OBJECT_ITEM( object ));
+ item = NA_IS_OBJECT_PROFILE( object ) ? na_object_get_parent( object ) : NA_OBJECT_ITEM( object );
+ readonly_item = na_object_is_readonly( item );
+ writable_provider = nact_window_is_writable_provider( NACT_WINDOW( instance ), item );
if( modified ){
g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index f10bf19..7799231 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -610,6 +610,8 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
gboolean writable_provider;
gboolean writable_item;
gboolean has_writables;
+ NAObjectItem *parent;
+ gboolean writable_parent;
g_debug( "%s: window=%p", thisfn, ( void * ) window );
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -631,11 +633,20 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
writable_provider = item ? nact_window_is_writable_provider( NACT_WINDOW( window ), NA_OBJECT_ITEM( item )) : FALSE;
writable_item = writable_provider && !readonly_item;
- /* new menu enabled if selection is a menu or an action */
- /* new action enabled if selection is a menu or an action */
+ parent = item ? na_object_get_parent( item ) : NULL;
+ writable_parent = parent
+ ? nact_window_is_writable_provider( NACT_WINDOW( window ), parent ) && !na_object_is_readonly( parent )
+ : FALSE;
+
+ /* new menu enabled if selection is a menu or an action
+ * new action enabled if selection is a menu or an action
+ * adding a new item requires that parent be writable
+ */
new_item_enabled = ( selected_row == NULL || NA_IS_OBJECT_ITEM( selected_row ));
- enable_item( window, "NewMenuItem", new_item_enabled && has_writables );
- enable_item( window, "NewActionItem", new_item_enabled && has_writables );
+ new_item_enabled = new_item_enabled && has_writables;
+ new_item_enabled = new_item_enabled && ( parent ? writable_parent : TRUE );
+ enable_item( window, "NewMenuItem", new_item_enabled );
+ enable_item( window, "NewActionItem", new_item_enabled );
/* new profile enabled if selection is relative to only one writable action */
enable_item( window, "NewProfileItem",
@@ -669,7 +680,7 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
if( mis->clipboard_profiles ){
paste_enabled = item && NA_IS_OBJECT_ACTION( item ) && writable_item;
} else {
- paste_enabled = ( item != NULL ) && has_writables;
+ paste_enabled = ( item != NULL ) && has_writables && ( parent ? writable_parent : TRUE );
}
}
}
@@ -1120,7 +1131,7 @@ on_duplicate_activated( GtkAction *gtk_action, NactMainWindow *window )
* as we insert in sibling mode, the parent doesn't change
*/
if( NA_IS_OBJECT_PROFILE( obj )){
- action = NA_OBJECT_ACTION( na_object_get_parent( NA_OBJECT_PROFILE( obj )));
+ action = NA_OBJECT_ACTION( na_object_get_parent( it->data ));
}
relabel = nact_main_menubar_is_pasted_object_relabeled( obj, pivot );
@@ -1420,7 +1431,7 @@ on_proxy_connect( GtkActionGroup *action_group, GtkAction *action, GtkWidget *pr
static void
on_proxy_disconnect( GtkActionGroup *action_group, GtkAction *action, GtkWidget *proxy, NactMainWindow *window )
{
- /* signal handlers will be automagically disconnected on NactWindow::dispose */
+ /* signal handlers will be automagically disconnected on BaseWindow::dispose */
}
static void
diff --git a/nautilus-actions/runtime/na-io-provider.c b/nautilus-actions/runtime/na-io-provider.c
index b4d4e49..1372150 100644
--- a/nautilus-actions/runtime/na-io-provider.c
+++ b/nautilus-actions/runtime/na-io-provider.c
@@ -146,7 +146,7 @@ na_io_provider_get_version( const NAPivot *pivot, const NAIIOProvider *provider
gboolean
na_io_provider_is_willing_to_write( const NAPivot *pivot, const NAIIOProvider *provider )
{
- static const gchar *thisfn = "na_io_provider_is_willing_to_write";
+ /*static const gchar *thisfn = "na_io_provider_is_willing_to_write";*/
gboolean writable;
gboolean locked;
GConfClient *gconf;
@@ -165,7 +165,7 @@ na_io_provider_is_willing_to_write( const NAPivot *pivot, const NAIIOProvider *p
key = g_strdup_printf( "%s/mandatory/%s/locked", 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_debug( "%s: id=%s, locked=%s", thisfn, id, locked ? "True":"False" );*/
g_free( key );
g_free( id );
}
diff --git a/nautilus-actions/runtime/na-pivot.c b/nautilus-actions/runtime/na-pivot.c
index beeb670..d680ccf 100644
--- a/nautilus-actions/runtime/na-pivot.c
+++ b/nautilus-actions/runtime/na-pivot.c
@@ -482,23 +482,25 @@ na_pivot_free_providers( GList *providers )
gboolean
na_pivot_has_writable_providers( const NAPivot *pivot )
{
- gboolean has_writable;
+ static const gchar *thisfn = "na_pivot_has_writable_providers";
+ gboolean writable;
GList *providers, *ip;
- has_writable = FALSE;
+ writable = FALSE;
- g_return_val_if_fail( NA_IS_PIVOT( pivot ), has_writable );
+ g_return_val_if_fail( NA_IS_PIVOT( pivot ), writable );
if( !pivot->private->dispose_has_run ){
providers = na_pivot_get_providers( pivot, NA_IIO_PROVIDER_TYPE );
- for( ip = providers ; ip && !has_writable ; ip = ip->next ){
- has_writable = na_io_provider_is_willing_to_write( pivot, NA_IIO_PROVIDER( ip->data ));
+ for( ip = providers ; ip && !writable ; ip = ip->next ){
+ writable = na_io_provider_is_willing_to_write( pivot, NA_IIO_PROVIDER( ip->data ));
}
na_pivot_free_providers( providers );
}
- return( has_writable );
+ g_debug( "%s: pivot=%p, writable=%s", thisfn, ( void * ) pivot, writable ? "True":"False" );
+ return( writable );
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]