[nautilus-actions: 27/30] Fix content of modified items list
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions: 27/30] Fix content of modified items list
- Date: Sat, 21 Nov 2009 18:03:32 +0000 (UTC)
commit 88d89d96649e74609954a8042e995b6e41aebabc
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Nov 21 14:26:21 2009 +0100
Fix content of modified items list
Recursively remove subitems when an object is no more marked as modified.
Add a maintainer function to dump currently modified objects.
ChangeLog | 13 +++++
TODO | 2 -
nautilus-actions/nact/nact-iactions-list.c | 51 +++++++++++++++++++-
nautilus-actions/nact/nact-iactions-list.h | 1 +
nautilus-actions/nact/nact-main-menubar.c | 11 ++++
.../nact/nautilus-actions-maintainer.actions | 2 +
6 files changed, 76 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ee4eb93..aa90ae9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,19 @@
* nautilus-actions/nact/nact-xml-reader.c (propagate_default_values):
Propagate default values to the newly imported action.
+ Fix list of modified items in NACT.
+
+ * nautilus-actions/nact/nact-iactions-list.c:
+ * nautilus-actions/nact/nact-iactions-list.h
+ (nact_iactions_list_list_modified_items): New maintainer function.
+
+ * nautilus-actions/nact/nact-iactions-list.c (remove_rec):
+ Recursively remove no-more modified sub-objects.
+
+ * nautilus-actions/nact/nact-main-menubar.c:
+ * nautilus-actions/nact/nautilus-actions-maintainer.actions:
+ New maintainer function.
+
2009-11-20 Pierre Wieser <pwieser trychlos org>
Define functions with actual type for arguments.
diff --git a/TODO b/TODO
index 361e911..2ea6141 100644
--- a/TODO
+++ b/TODO
@@ -90,5 +90,3 @@
- bug when dnd to nautilus
see https://bugzilla.gnome.org/show_bug.cgi?id=593453
-
-- nact: dnd an action into nact, then deleting it: the '*' is always here
diff --git a/nautilus-actions/nact/nact-iactions-list.c b/nautilus-actions/nact/nact-iactions-list.c
index 7fe40ac..fdb05da 100644
--- a/nautilus-actions/nact/nact-iactions-list.c
+++ b/nautilus-actions/nact/nact-iactions-list.c
@@ -184,6 +184,7 @@ static void on_label_edited( GtkCellRendererText *renderer, const gchar
static void on_tab_updatable_item_updated( NactIActionsList *instance, NAObject *object, gboolean force_display );
static void on_treeview_selection_changed( GtkTreeSelection *selection, NactIActionsList *instance );
static void open_popup( NactIActionsList *instance, GdkEventButton *event );
+static GList *remove_rec( GList *list, NAObject *object );
static void select_first_row( NactIActionsList *instance );
static void select_row_at_path( NactIActionsList *instance, GtkTreeView *treeview, GtkTreeModel *model, GtkTreePath *path );
static void send_list_count_updated_signal( NactIActionsList *instance, IActionsListInstanceData *ialid );
@@ -729,7 +730,7 @@ nact_iactions_list_delete( NactIActionsList *instance, GList *items )
path = nact_tree_model_remove( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ));
- ialid->modified_items = g_list_remove( ialid->modified_items, it->data );
+ ialid->modified_items = remove_rec( ialid->modified_items, NA_OBJECT( it->data ));
g_debug( "%s: object=%p (%s, ref_count=%d)", thisfn,
( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count );
@@ -1438,6 +1439,31 @@ nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item
}
/**
+ * nact_iactions_list_list_modified_items:
+ * @instance: this #NactIActionsList instance.
+ *
+ * Dumps the modified items list.
+ */
+void
+nact_iactions_list_list_modified_items( NactIActionsList *instance )
+{
+ static const gchar *thisfn = "nact_iactions_list_list_modified_items";
+ IActionsListInstanceData *ialid;
+ GList *it;
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+ g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ ialid = get_instance_data( instance );
+ for( it = ialid->modified_items ; it ; it = it->next ){
+ na_object_dump( it->data );
+ }
+ }
+}
+
+/**
* nact_iactions_list_removed_modified:
* @instance: this #NactIActionsList instance.
*
@@ -2054,7 +2080,7 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
ialid->modified_items = g_list_prepend( ialid->modified_items, object );
}
} else {
- ialid->modified_items = g_list_remove( ialid->modified_items, object );
+ ialid->modified_items = remove_rec( ialid->modified_items, NA_OBJECT( object ));
}
/* do not send status-changed signal while filling the tree
@@ -2232,6 +2258,27 @@ open_popup( NactIActionsList *instance, GdkEventButton *event )
}
}
+/*
+ * when removing from modified list an object which is no more modified,
+ * then all subitems of the object have also to be removed
+ */
+static GList *
+remove_rec( GList *list, NAObject *object )
+{
+ GList *subitems, *it;
+
+ if( NA_IS_OBJECT_ITEM( object )){
+ subitems = na_object_get_items_list( object );
+ for( it = subitems ; it ; it = it->next ){
+ list = remove_rec( list, it->data );
+ }
+ }
+
+ list = g_list_remove( list, object );
+
+ return( list );
+}
+
static void
select_first_row( NactIActionsList *instance )
{
diff --git a/nautilus-actions/nact/nact-iactions-list.h b/nautilus-actions/nact/nact-iactions-list.h
index 6be774d..e8cb0ed 100644
--- a/nautilus-actions/nact/nact-iactions-list.h
+++ b/nautilus-actions/nact/nact-iactions-list.h
@@ -142,6 +142,7 @@ void nact_iactions_list_insert_at_path( NactIActionsList *instance, GList *
void nact_iactions_list_insert_items( NactIActionsList *instance, GList *items, NAObject *sibling );
void nact_iactions_list_insert_into( NactIActionsList *instance, GList *items );
gboolean nact_iactions_list_is_expanded( NactIActionsList *instance, const NAObject *item );
+void nact_iactions_list_list_modified_items( NactIActionsList *instance );
void nact_iactions_list_removed_modified( NactIActionsList *instance );
void nact_iactions_list_set_management_mode( NactIActionsList *instance, gint mode );
void nact_iactions_list_toggle_collapse( NactIActionsList *instance, const NAObject *item );
diff --git a/nautilus-actions/nact/nact-main-menubar.c b/nautilus-actions/nact/nact-main-menubar.c
index 72d672e..7aa46fa 100644
--- a/nautilus-actions/nact/nact-main-menubar.c
+++ b/nautilus-actions/nact/nact-main-menubar.c
@@ -134,6 +134,7 @@ static void on_export_activated( GtkAction *action, NactMainWindow *window )
static void on_dump_selection_activated( GtkAction *action, NactMainWindow *window );
static void on_brief_tree_store_dump_activated( GtkAction *action, NactMainWindow *window );
+static void on_list_modified_items_activated( GtkAction *action, NactMainWindow *window );
static void on_help_activated( GtkAction *action, NactMainWindow *window );
static void on_about_activated( GtkAction *action, NactMainWindow *window );
@@ -235,6 +236,10 @@ static const GtkActionEntry entries[] = {
/* i18n: tooltip displayed in the status bar when selecting the BriefTreeStoreDump item */
N_( "Briefly dump the tree store" ),
G_CALLBACK( on_brief_tree_store_dump_activated ) },
+ { "ListModifiedItems", NULL, N_( "_List modified items" ), NULL,
+ /* i18n: tooltip displayed in the status bar when selecting the ListModifiedItems item */
+ N_( "List the modified items" ),
+ G_CALLBACK( on_list_modified_items_activated ) },
{ "HelpItem" , GTK_STOCK_HELP, NULL, NULL,
/* i18n: tooltip displayed in the status bar when selecting the Help item */
N_( "Display help about this program" ),
@@ -1231,6 +1236,12 @@ on_brief_tree_store_dump_activated( GtkAction *action, NactMainWindow *window )
}
static void
+on_list_modified_items_activated( GtkAction *action, NactMainWindow *window )
+{
+ nact_iactions_list_list_modified_items( NACT_IACTIONS_LIST( window ));
+}
+
+static void
on_help_activated( GtkAction *gtk_action, NactMainWindow *window )
{
}
diff --git a/nautilus-actions/nact/nautilus-actions-maintainer.actions b/nautilus-actions/nact/nautilus-actions-maintainer.actions
index f03cff9..9077381 100644
--- a/nautilus-actions/nact/nautilus-actions-maintainer.actions
+++ b/nautilus-actions/nact/nautilus-actions-maintainer.actions
@@ -5,6 +5,7 @@
<menu action="MaintainerMenu">
<menuitem action="DumpSelectionItem" />
<menuitem action="BriefTreeStoreDumpItem" />
+ <menuitem action="ListModifiedItems" />
</menu>
</placeholder>
</menubar>
@@ -12,5 +13,6 @@
<toolbar name="MaintainerToolbar">
<toolitem action="DumpSelectionItem" />
<toolitem action="BriefTreeStoreDumpItem" />
+ <toolitem action="ListModifiedItems" />
</toolbar>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]