[nautilus-actions] Also save non-valid items
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Also save non-valid items
- Date: Fri, 9 Oct 2009 12:38:38 +0000 (UTC)
commit 70d6d13c3b926fa3ae61d16b62be881756898a2f
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Oct 9 14:30:04 2009 +0200
Also save non-valid items
ChangeLog | 8 ++++++++
src/nact/nact-main-menubar.c | 13 ++-----------
src/nact/nact-tree-model.c | 1 +
src/nact/nact-window.c | 2 +-
src/runtime/na-object-action.c | 13 +++++++++++--
src/runtime/na-object-profile.c | 5 +++--
src/runtime/na-object.c | 2 +-
7 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9ce5326..0c715a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,9 +15,14 @@
Display a Maintainer menu when in maintainer mode.
Add BriefTreeStoreDumpItem new item.
Display a first toolbar.
+ (on_save_activated): Also save non-valid items.
* src/nact/nact-tree-model.c (nact_tree_model_insert):
Add debug traces.
+ (nact_tree_model_fill): Check validity status at load time.
+
+ * src/nact/nact-window.c (nact_window_save_item):
+ Full dump of the saved item.
* src/nact/nautilus-actions-config-tool.actions:
Define a placeholder for the Maintainer menu.
@@ -30,6 +35,9 @@
* src/nact/Makefile.am: Updated accordingly.
+ * src/runtime/na-object-action.c (object_is_valid):
+ An action is valid if it has at least one valid profile.
+
* src/runtime/na-object-profile.c (object_is_valid):
A profile requires rather a command to be valid that a label.
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 7bf07b2..bb4ac9d 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -555,9 +555,6 @@ on_new_profile_activated( GtkAction *gtk_action, NactMainWindow *window )
/*
* saving is not only saving modified items, but also saving hierarchy
* (and order if alpha order is not set)
- *
- * note that we only go down in the hierarchy if parent is valid and not
- * modified (or has been successfully saved)
*/
static void
on_save_activated( GtkAction *gtk_action, NactMainWindow *window )
@@ -581,7 +578,7 @@ on_save_activated( GtkAction *gtk_action, NactMainWindow *window )
items = nact_iactions_list_get_items( NACT_IACTIONS_LIST( window ));
na_pivot_write_level_zero( pivot, items );
- /* recursively save the valid modified items
+ /* recursively save the modified items
*/
save_items( window, pivot, items );
g_list_free( items );
@@ -631,8 +628,7 @@ save_item( NactMainWindow *window, NAPivot *pivot, NAObjectItem *item )
save_items( window, pivot, subitems );
}
- if( na_object_is_modified( item ) &&
- na_object_is_valid( item )){
+ if( na_object_is_modified( item )){
if( nact_window_save_item( NACT_WINDOW( window ), item )){
@@ -651,11 +647,6 @@ save_item( NactMainWindow *window, NAPivot *pivot, NAObjectItem *item )
dup_pivot = NA_OBJECT_ITEM( na_object_duplicate( item ));
na_object_reset_origin( item, dup_pivot );
- g_debug( "save_item: un" );
- na_object_dump( item );
- g_debug( "save_item: deux" );
- na_object_dump( dup_pivot );
- g_debug( "save_item: trois" );
na_pivot_add_item( pivot, NA_OBJECT( dup_pivot ));
na_object_check_edition_status( item );
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index e4301fa..774186c 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -673,6 +673,7 @@ nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean only_actions)
for( it = items ; it ; it = it->next ){
duplicate = na_object_duplicate( it->data );
+ na_object_check_edition_status( duplicate );
fill_tree_store( ts_model, model->private->treeview, duplicate, only_actions, NULL );
na_object_unref( duplicate );
}
diff --git a/src/nact/nact-window.c b/src/nact/nact-window.c
index 5b0174f..1da7d29 100644
--- a/src/nact/nact-window.c
+++ b/src/nact/nact-window.c
@@ -227,7 +227,7 @@ nact_window_save_item( NactWindow *window, NAObjectItem *item )
pivot = nact_window_get_pivot( window );
g_assert( NA_IS_PIVOT( pivot ));
- na_object_dump_norec( item );
+ na_object_dump( item );
ret = na_pivot_write_item( pivot, NA_OBJECT( item ), &msg );
diff --git a/src/runtime/na-object-action.c b/src/runtime/na-object-action.c
index a6820d7..5ce3d8d 100644
--- a/src/runtime/na-object-action.c
+++ b/src/runtime/na-object-action.c
@@ -567,7 +567,7 @@ object_are_equal( const NAObject *a, const NAObject *b )
* a valid NAObjectAction requires a not null, not empty label
* this is checked here as NAObjectId doesn't have this condition
*
- * and at least one profile
+ * and at least one valid profile
* checked here because NAObjectItem doesn't have this condition
*/
gboolean
@@ -575,6 +575,8 @@ object_is_valid( const NAObject *action )
{
gchar *label;
gboolean is_valid = TRUE;
+ GList *profiles, *ip;
+ gint valid_profiles;
g_return_val_if_fail( NA_IS_OBJECT_ACTION( action ), FALSE );
@@ -587,7 +589,14 @@ object_is_valid( const NAObject *action )
}
if( is_valid ){
- is_valid = ( na_object_get_items_count( action ) >= 1 );
+ valid_profiles = 0;
+ profiles = na_object_get_items_list( action );
+ for( ip = profiles ; ip ; ip = ip->next ){
+ if( na_iduplicable_is_valid( ip->data )){
+ valid_profiles += 1;
+ }
+ }
+ is_valid = ( valid_profiles > 0 );
}
}
diff --git a/src/runtime/na-object-profile.c b/src/runtime/na-object-profile.c
index deceddd..08b12cc 100644
--- a/src/runtime/na-object-profile.c
+++ b/src/runtime/na-object-profile.c
@@ -1487,8 +1487,8 @@ object_is_valid( const NAObject *profile )
if( !NA_OBJECT_PROFILE( profile )->private->dispose_has_run ){
if( is_valid ){
- path = na_object_get_path( profile );
- parameters = na_object_get_parameters( profile );
+ path = na_object_profile_get_path( NA_OBJECT_PROFILE( profile ));
+ parameters = na_object_profile_get_parameters( NA_OBJECT_PROFILE( profile ));
is_valid = ( path && g_utf8_strlen( path, -1 ) > 0 ) ||
( parameters && g_utf8_strlen( parameters, -1 ) > 0 );
@@ -1498,6 +1498,7 @@ object_is_valid( const NAObject *profile )
}
}
+ g_debug( "na_object_profile_object_is_valid: profile=%p, valid=%s", ( void * ) profile, is_valid ? "True":"False" );
return( is_valid );
}
diff --git a/src/runtime/na-object.c b/src/runtime/na-object.c
index 2964652..898795e 100644
--- a/src/runtime/na-object.c
+++ b/src/runtime/na-object.c
@@ -318,7 +318,7 @@ na_object_iduplicable_are_equal( const NAObject *a, const NAObject *b )
* to get benefits provided by the IDuplicable interface.
*
* This suppose also that the edition status of @object has previously
- * been checked via na_object_check_edited_status().
+ * been checked via na_object_check_edition_status().
*
* Returns: %TRUE is the provided object has been modified regarding to
* the original one, %FALSE else.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]