[nautilus-actions] NactMenubar: fix cut/delete menu items sensitivity after item insertion
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] NactMenubar: fix cut/delete menu items sensitivity after item insertion
- Date: Fri, 11 Feb 2011 00:18:29 +0000 (UTC)
commit 54b700a520fedd0bdcae8d98800d0a0640093077
Author: Pierre Wieser <pwieser trychlos org>
Date: Sat Feb 5 00:26:29 2011 +0100
NactMenubar: fix cut/delete menu items sensitivity after item insertion
src/nact/nact-assistant-import.c | 1 -
src/nact/nact-main-statusbar.c | 3 -
src/nact/nact-menubar-edit.c | 34 ++++----
src/nact/nact-menubar.c | 56 +++++++-----
src/nact/nact-tree-ieditable.c | 183 ++++++++++++++++++++------------------
src/nact/nact-tree-ieditable.h | 13 +---
src/nact/nact-tree-model-dnd.c | 14 ++--
src/nact/nact-tree-model.c | 112 +++++++++--------------
src/nact/nact-tree-model.h | 2 +-
9 files changed, 199 insertions(+), 219 deletions(-)
---
diff --git a/src/nact/nact-assistant-import.c b/src/nact/nact-assistant-import.c
index 70bb083..8e5a664 100644
--- a/src/nact/nact-assistant-import.c
+++ b/src/nact/nact-assistant-import.c
@@ -668,7 +668,6 @@ assistant_apply( BaseAssistant *wnd, GtkAssistant *assistant )
result = ( NAImporterResult * ) it->data;
if( result->imported ){
- na_object_check_status( result->imported );
imported_items = g_list_prepend( imported_items, result->imported );
}
}
diff --git a/src/nact/nact-main-statusbar.c b/src/nact/nact-main-statusbar.c
index 5e1c5df..309697f 100644
--- a/src/nact/nact-main-statusbar.c
+++ b/src/nact/nact-main-statusbar.c
@@ -172,11 +172,8 @@ nact_main_statusbar_display_with_timeout( NactMainWindow *window, const gchar *c
void
nact_main_statusbar_hide_status( NactMainWindow *window, const gchar *context )
{
- static const gchar *thisfn = "nact_main_statusbar_hide_status";
GtkStatusbar *bar;
- g_debug( "%s: window=%p, context=%s", thisfn, ( void * ) window, context );
-
bar = get_statusbar( window );
if( bar ){
diff --git a/src/nact/nact-menubar-edit.c b/src/nact/nact-menubar-edit.c
index 44741c8..e6da878 100644
--- a/src/nact/nact-menubar-edit.c
+++ b/src/nact/nact-menubar-edit.c
@@ -43,6 +43,7 @@
#include "nact-main-tab.h"
#include "nact-menubar-priv.h"
#include "nact-preferences-editor.h"
+#include "nact-tree-ieditable.h"
static GList *prepare_for_paste( BaseWindow *window );
static GList *get_deletables( NAUpdater *updater, GList *tree, GSList **not_deletable );
@@ -191,6 +192,7 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, BaseWindow *window )
NactClipboard *clipboard;
GList *to_delete;
GSList *non_deletables;
+ NactTreeView *view;
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
g_return_if_fail( GTK_IS_ACTION( gtk_action ));
@@ -216,9 +218,8 @@ nact_menubar_edit_on_cut( GtkAction *gtk_action, BaseWindow *window )
clipboard = nact_main_window_get_clipboard( NACT_MAIN_WINDOW( window ));
nact_clipboard_primary_set( clipboard, to_delete, CLIPBOARD_MODE_CUT );
update_clipboard_counters( window );
-#if 0
- nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
-#endif
+ view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_ieditable_delete( NACT_TREE_IEDITABLE( view ), to_delete, TRUE );
}
na_object_free_items( items );
@@ -279,14 +280,15 @@ nact_menubar_edit_on_paste( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_paste";
GList *items;
+ NactTreeView *view;
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
items = prepare_for_paste( window );
+
if( items ){
-#if 0
- nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), items, NULL );
-#endif
+ view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_ieditable_insert_items( NACT_TREE_IEDITABLE( view ), items, NULL );
na_object_free_items( items );
}
}
@@ -312,14 +314,14 @@ nact_menubar_edit_on_paste_into( GtkAction *gtk_action, BaseWindow *window )
{
static const gchar *thisfn = "nact_menubar_edit_on_paste_into";
GList *items;
+ NactTreeView *view;
g_debug( "%s: gtk_action=%p, window=%p", thisfn, ( void * ) gtk_action, ( void * ) window );
items = prepare_for_paste( window );
if( items ){
-#if 0
- nact_iactions_list_bis_insert_into( NACT_IACTIONS_LIST( window ), items );
-#endif
+ view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_ieditable_insert_items_into( NACT_TREE_IEDITABLE( window ), items );
na_object_free_items( items );
}
}
@@ -383,6 +385,7 @@ nact_menubar_edit_on_duplicate( GtkAction *gtk_action, BaseWindow *window )
GList *dup;
NAObject *obj;
gboolean relabel;
+ NactTreeView *view;
BAR_WINDOW_VOID( window );
@@ -408,9 +411,8 @@ nact_menubar_edit_on_duplicate( GtkAction *gtk_action, BaseWindow *window )
na_object_set_origin( obj, NULL );
na_object_check_status( obj );
dup = g_list_prepend( NULL, obj );
-#if 0
- nact_iactions_list_bis_insert_items( NACT_IACTIONS_LIST( window ), dup, it->data );
-#endif
+ view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_ieditable_insert_items( NACT_TREE_IEDITABLE( window ), dup, it->data );
na_object_free_items( dup );
}
@@ -441,6 +443,7 @@ nact_menubar_edit_on_delete( GtkAction *gtk_action, BaseWindow *window )
GList *items;
GList *to_delete;
GSList *non_deletables;
+ NactTreeView *view;
BAR_WINDOW_VOID( window );
@@ -463,10 +466,9 @@ nact_menubar_edit_on_delete( GtkAction *gtk_action, BaseWindow *window )
}
if( to_delete ){
- nact_main_window_move_to_deleted( NACT_MAIN_WINDOW( window ), to_delete );
-#if 0
- nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
-#endif
+ /*nact_main_window_move_to_deleted( NACT_MAIN_WINDOW( window ), to_delete );*/
+ view = nact_main_window_get_items_view( NACT_MAIN_WINDOW( window ));
+ nact_tree_ieditable_delete( NACT_TREE_IEDITABLE( view ), to_delete, TRUE );
}
na_object_free_items( items );
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index ce4f94b..521a9fd 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -736,8 +736,22 @@ on_tree_view_selection_changed( BaseWindow *window, NactTreeView *view, GList *s
g_debug( "%s: selected_items=%p (count=%d)", thisfn, ( void * ) selected, g_list_length( selected ));
+ /* count the items
+ */
bar->private->count_selected = g_list_length( selected );
+ bar->private->selected_menus = 0;
+ bar->private->selected_actions = 0;
+ bar->private->selected_profiles = 0;
+ if( selected ){
+ na_object_item_count_items( selected, &bar->private->selected_menus, &bar->private->selected_actions, &bar->private->selected_profiles, FALSE );
+ g_debug( "%s: selected_menus=%d, selected_actions=%d, selected_profiles=%d",
+ thisfn,
+ bar->private->selected_menus, bar->private->selected_actions, bar->private->selected_profiles );
+ }
+
+ /* take a ref of the list of selected items
+ */
if( bar->private->selected_items ){
bar->private->selected_items = na_object_free_items( bar->private->selected_items );
}
@@ -803,34 +817,28 @@ on_tree_view_selection_changed( BaseWindow *window, NactTreeView *view, GList *s
* (Edit: Cut/Delete)
*/
bar->private->are_parents_writable = TRUE;
- for( is = selected ; is ; is = is->next ){
- gchar *label = na_object_get_label( is->data );
- gboolean writable = na_object_is_finally_writable( is->data, NULL );
- g_debug( "%s: label=%s, writable=%s", thisfn, label, writable ? "True":"False" );
- if( !na_object_is_finally_writable( is->data, NULL )){
- bar->private->are_parents_writable = FALSE;
- break;
- }
- first = ( NAObject * ) na_object_get_parent( is->data );
- if( first ){
- if( !na_object_is_finally_writable( first, NULL )){
+ if( selected ){
+ for( is = selected ; is ; is = is->next ){
+ gchar *label = na_object_get_label( is->data );
+ gboolean writable = na_object_is_finally_writable( is->data, NULL );
+ g_debug( "%s: label=%s, writable=%s", thisfn, label, writable ? "True":"False" );
+ if( !na_object_is_finally_writable( is->data, NULL )){
+ bar->private->are_parents_writable = FALSE;
+ break;
+ }
+ first = ( NAObject * ) na_object_get_parent( is->data );
+ if( first ){
+ if( !na_object_is_finally_writable( first, NULL )){
+ bar->private->are_parents_writable = FALSE;
+ break;
+ }
+ } else if( !bar->private->is_level_zero_writable ){
bar->private->are_parents_writable = FALSE;
break;
}
- } else if( !bar->private->is_level_zero_writable ){
- bar->private->are_parents_writable = FALSE;
- break;
}
- }
-
- bar->private->selected_menus = 0;
- bar->private->selected_actions = 0;
- bar->private->selected_profiles = 0;
- if( selected ){
- na_object_item_count_items( selected, &bar->private->selected_menus, &bar->private->selected_actions, &bar->private->selected_profiles, FALSE );
- g_debug( "%s: selected_menus=%d, selected_actions=%d, selected_profiles=%d",
- thisfn,
- bar->private->selected_menus, bar->private->selected_actions, bar->private->selected_profiles );
+ } else {
+ bar->private->are_parents_writable = bar->private->is_level_zero_writable;
}
g_signal_emit_by_name( bar, MENUBAR_SIGNAL_UPDATE_SENSITIVITIES );
diff --git a/src/nact/nact-tree-ieditable.c b/src/nact/nact-tree-ieditable.c
index b858680..379469a 100644
--- a/src/nact/nact-tree-ieditable.c
+++ b/src/nact/nact-tree-ieditable.c
@@ -34,6 +34,9 @@
#include <api/na-object-api.h>
+#include <core/na-updater.h>
+
+#include "nact-application.h"
#include "nact-tree-ieditable.h"
#include "nact-tree-model.h"
@@ -46,6 +49,7 @@ struct _NactTreeIEditableInterfacePrivate {
/* data attached to the NactTreeView
*/
typedef struct {
+ NAUpdater *updater;
GtkTreeView *treeview;
guint count_modified;
}
@@ -64,6 +68,7 @@ static void do_insert_items( GtkTreeView *treeview, GtkTreeModel *mode
static NAObject *do_insert_into_first( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTreePath *insert_path, GtkTreePath **new_path );
static GtkTreePath *get_selection_first_path( GtkTreeView *treeview );
static IEditableData *get_instance_data( NactTreeIEditable *view );
+static void decrement_counters( NactTreeIEditable *instance, IEditableData *ialid, GList *items );
static void increment_counters( NactTreeIEditable *view, IEditableData *ied, GList *items );
static void increment_counters_modified( NAObject *object, IEditableData *ied );
@@ -145,11 +150,70 @@ nact_tree_ieditable_initialize( NactTreeIEditable *instance, GtkTreeView *treevi
{
static const gchar *thisfn = "nact_tree_ieditable_initialize";
IEditableData *ied;
+ NactApplication *application;
g_debug( "%s: instance=%p, window=%p", thisfn, ( void * ) instance, ( void * ) window );
ied = get_instance_data( instance );
ied->treeview = treeview;
+
+ application = NACT_APPLICATION( base_window_get_application( window ));
+ ied->updater = nact_application_get_updater( application );
+}
+
+/**
+ * nact_tree_ieditable_delete:
+ * @instance: this #NactTreeIEditable instance.
+ * @list: list of #NAObject to be deleted.
+ * @select_at_end: whether a row should be selected after delete.
+ *
+ * Deletes the specified list from the underlying tree store.
+ *
+ * This function takes care of repositionning a new selection if
+ * possible, and refilter the display model.
+ */
+void
+nact_tree_ieditable_delete( NactTreeIEditable *instance, GList *items, gboolean select_at_end )
+{
+ static const gchar *thisfn = "nact_tree_ieditable_delete";
+ IEditableData *ied;
+ GtkTreeModel *model;
+ GtkTreePath *path = NULL;
+ GList *it;
+
+ g_return_if_fail( NACT_IS_TREE_IEDITABLE( instance ));
+
+ if( st_tree_ieditable_initialized && !st_tree_ieditable_finalized ){
+ g_debug( "%s: instance=%p, items=%p (count=%d), select_at_end=%s",
+ thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ), select_at_end ? "True":"False" );
+
+ ied = get_instance_data( instance );
+ model = gtk_tree_view_get_model( ied->treeview );
+
+ decrement_counters( instance, ied, items );
+
+ for( it = items ; it ; it = it->next ){
+ if( path ){
+ gtk_tree_path_free( path );
+ }
+
+ path = nact_tree_model_delete( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ));
+
+ /*ialid->modified_items = nact_iactions_list_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 );
+ }
+
+ gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
+
+ if( path ){
+ if( select_at_end ){
+ nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), path );
+ }
+ gtk_tree_path_free( path );
+ }
+ }
}
/**
@@ -181,13 +245,12 @@ nact_tree_ieditable_insert_at_path( NactTreeIEditable *instance, GList *items, G
model = gtk_tree_view_get_model( ied->treeview );
g_return_if_fail( NACT_IS_TREE_MODEL( model ));
+ increment_counters( instance, ied, items );
do_insert_items( ied->treeview, model, items, insert_path, &parents );
g_list_foreach( parents, ( GFunc ) na_object_object_check_status, NULL );
g_list_free( parents );
- increment_counters( instance, ied, items );
-
gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), insert_path );
}
@@ -307,11 +370,7 @@ nact_tree_ieditable_insert_items_into( NactTreeIEditable *instance, GList *items
insert_path = get_selection_first_path( ied->treeview );
increment_counters( instance, ied, items );
-
parent = do_insert_into_first( ied->treeview, model, items, insert_path, &new_path );
-
- na_object_check_status( parent );
-
gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
nact_tree_view_select_row_at_path( NACT_TREE_VIEW( instance ), new_path );
@@ -449,6 +508,30 @@ get_instance_data( NactTreeIEditable *view )
}
static void
+decrement_counters( NactTreeIEditable *view, IEditableData *ied, GList *items )
+{
+ static const gchar *thisfn = "nact_tree_editable_decrement_counters";
+ gint menus, actions, profiles;
+ BaseWindow *window;
+
+ g_debug( "%s: view=%p, ied=%p, items=%p",
+ thisfn, ( void * ) view, ( void * ) ied, ( void * ) items );
+
+ menus = 0;
+ actions = 0;
+ profiles = 0;
+ na_object_item_count_items( items, &menus, &actions, &profiles, TRUE );
+ menus *= -1;
+ actions *= -1;
+ profiles *= -1;
+ window = nact_tree_view_get_window( NACT_TREE_VIEW( view ));
+ g_signal_emit_by_name( G_OBJECT( window ), TREE_SIGNAL_COUNT_CHANGED, view, FALSE, menus, actions, profiles );
+}
+
+/*
+ * we pass here before each insertion operation (apart initial fill)
+ */
+static void
increment_counters( NactTreeIEditable *view, IEditableData *ied, GList *items )
{
static const gchar *thisfn = "nact_tre_ieditablet_increment_counters";
@@ -476,10 +559,17 @@ increment_counters( NactTreeIEditable *view, IEditableData *ied, GList *items )
static void
increment_counters_modified( NAObject *object, IEditableData *ied )
{
+ gboolean writable;
+ guint reason;
+
if( NA_IS_OBJECT_ITEM( object )){
+
if( !na_object_get_provider( object )){
ied->count_modified += 1;
}
+
+ writable = na_updater_is_item_writable( ied->updater, NA_OBJECT_ITEM( object ), &reason );
+ na_object_set_writability_status( object, writable, reason );
}
}
@@ -558,66 +648,6 @@ nact_iactions_list_bis_collapse_to_parent( NactIActionsList *instance )
}
/**
- * nact_iactions_list_bis_delete:
- * @window: this #NactIActionsList instance.
- * @list: list of #NAObject to be deleted.
- *
- * Deletes the specified list from the underlying tree store.
- *
- * This function takes care of repositionning a new selection if
- * possible, and refilter the display model.
- */
-void
-nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items, gboolean select_at_end )
-{
- static const gchar *thisfn = "nact_iactions_list_bis_delete";
- GtkTreeView *treeview;
- GtkTreeModel *model;
- GtkTreePath *path = NULL;
- GList *it;
- IActionsListInstanceData *ialid;
-
- g_debug( "%s: instance=%p, items=%p (count=%d), select_at_end=%s",
- thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ), select_at_end ? "True":"False" );
- g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
-
- if( st_iactions_list_initialized && !st_iactions_list_finalized ){
-
- treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
- model = gtk_tree_view_get_model( treeview );
-
- ialid = nact_iactions_list_priv_get_instance_data( instance );
- ialid->selection_changed_allowed = FALSE;
-
- decrement_counters( instance, ialid, items );
-
- for( it = items ; it ; it = it->next ){
- if( path ){
- gtk_tree_path_free( path );
- }
-
- path = nact_tree_model_remove( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ));
-
- ialid->modified_items = nact_iactions_list_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 );
- }
-
- gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
-
- ialid->selection_changed_allowed = TRUE;
-
- if( path ){
- if( select_at_end ){
- nact_iactions_list_bis_select_row_at_path( instance, treeview, model, path );
- }
- gtk_tree_path_free( path );
- }
- }
-}
-
-/**
* nact_iactions_list_bis_expand_to_first_child:
* @instance: this #NactIActionsList interface.
*
@@ -840,27 +870,6 @@ nact_iactions_list_bis_toggle_collapse_object( NactIActionsList *instance, const
}
}
-static void
-decrement_counters( NactIActionsList *instance, IActionsListInstanceData *ialid, GList *items )
-{
- static const gchar *thisfn = "nact_iactions_list_decrement_counters";
- gint menus, actions, profiles;
-
- g_debug( "%s: instance=%p, ialid=%p, items=%p",
- thisfn, ( void * ) instance, ( void * ) ialid, ( void * ) items );
-
- menus = 0;
- actions = 0;
- profiles = 0;
- na_object_item_count_items( items, &menus, &actions, &profiles, TRUE );
-
- ialid->menus -= menus;
- ialid->actions -= actions;
- ialid->profiles -= profiles;
-
- nact_iactions_list_priv_send_list_count_updated_signal( instance, ialid );
-}
-
/*
* when expanding a selected row which has childs
*/
diff --git a/src/nact/nact-tree-ieditable.h b/src/nact/nact-tree-ieditable.h
index 0c63a23..fc4024d 100644
--- a/src/nact/nact-tree-ieditable.h
+++ b/src/nact/nact-tree-ieditable.h
@@ -72,31 +72,20 @@ GType nact_tree_ieditable_get_type( void );
void nact_tree_ieditable_initialize( NactTreeIEditable *instance, GtkTreeView *treeview, BaseWindow *window );
+void nact_tree_ieditable_delete ( NactTreeIEditable *instance, GList *items, gboolean select_at_end );
void nact_tree_ieditable_insert_at_path ( NactTreeIEditable *instance, GList *items, GtkTreePath *path );
void nact_tree_ieditable_insert_items ( NactTreeIEditable *instance, GList *items, NAObject *sibling );
void nact_tree_ieditable_insert_items_into( NactTreeIEditable *instance, GList *items );
#if 0
-
-void nact_tree_ieditable_initial_load_toplevel( NactTreeIEditable *instance );
-void nact_tree_ieditable_runtime_init_toplevel( NactTreeIEditable *instance, GList *actions );
-void nact_tree_ieditable_all_widgets_showed( NactTreeIEditable *instance );
-void nact_tree_ieditable_dispose( NactTreeIEditable *instance );
-
void nact_tree_ieditable_brief_tree_dump( NactTreeIEditable *instance );
-void nact_tree_ieditable_collapse_all( NactTreeIEditable *instance );
void nact_tree_ieditable_display_order_change( NactTreeIEditable *instance, gint order_mode );
-void nact_tree_ieditable_expand_all( NactTreeIEditable *instance );
-void nact_tree_ieditable_fill( NactTreeIEditable *instance, GList *items );
gint nact_tree_ieditable_get_management_mode( NactTreeIEditable *instance );
gboolean nact_tree_ieditable_has_modified_items( NactTreeIEditable *instance );
-void nact_tree_ieditable_on_treeview_selection_changed( GtkTreeSelection *selection, NactTreeIEditable *instance );
GList *nact_tree_ieditable_remove_rec( GList *list, NAObject *object );
-void nact_tree_ieditable_set_management_mode( NactTreeIEditable *instance, gint mode );
void nact_tree_ieditable_bis_clear_selection( NactTreeIEditable *instance, GtkTreeView *treeview );
void nact_tree_ieditable_bis_collapse_to_parent( NactTreeIEditable *instance );
-void nact_tree_ieditable_bis_delete( NactTreeIEditable *instance, GList *items, gboolean select_at_end );
void nact_tree_ieditable_bis_expand_to_first_child( NactTreeIEditable *instance );
NAObject *nact_tree_ieditable_bis_get_item( NactTreeIEditable *instance, const gchar *id );
GList *nact_tree_ieditable_bis_get_items( NactTreeIEditable *instance );
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index 09fdf91..b7b83eb 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -953,17 +953,15 @@ drop_uri_list( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData *selec
g_string_free( str, TRUE );
- /* check status of newly imported items, and insert them in the list view
+ /* insert newly imported items in the list view
*/
- for( it = imported ; it ; it = it->next ){
- na_object_check_status( it->data );
- na_object_dump( it->data );
- drop_done = TRUE;
+ if( imported ){
+ na_object_dump_tree( imported );
+ view = nact_main_window_get_items_view( main_window );
+ nact_tree_ieditable_insert_at_path( NACT_TREE_IEDITABLE( view ), imported, dest );
}
- view = nact_main_window_get_items_view( main_window );
- nact_tree_ieditable_insert_at_path( NACT_TREE_IEDITABLE( view ), imported, dest );
-
+ drop_done = TRUE;
na_object_free_items( imported );
na_core_utils_slist_free( parms.uris );
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index bc80646..b64901a 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -126,8 +126,6 @@ static void iter_on_store( const NactTreeModel *model, GtkTreeModel *s
static gboolean iter_on_store_item( const NactTreeModel *model, GtkTreeModel *store, GtkTreeIter *iter, FnIterOnStore fn, gpointer user_data );
static void remove_if_exists( NactTreeModel *model, GtkTreeModel *store, const NAObject *object );
static gboolean remove_items( GtkTreeStore *store, GtkTreeIter *iter );
-/*static gboolean search_for_object( NactTreeModel *model, GtkTreeModel *store, const NAObject *object, GtkTreeIter *iter );
-static gboolean search_for_object_iter( NactTreeModel *model, GtkTreePath *path, NAObject *object, ntmFindObject *ntm );*/
static gint sort_actions_list( GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data );
GType
@@ -501,6 +499,51 @@ nact_tree_model_display_order_change( NactTreeModel *model, gint order_mode )
}
/**
+ * nact_tree_model_delete:
+ * @model: this #NactTreeModel instance.
+ * @object: the #NAObject to be deleted.
+ *
+ * Recursively deletes the specified object.
+ *
+ * Returns: a path which may be suitable for the next selection.
+ */
+GtkTreePath *
+nact_tree_model_delete( NactTreeModel *model, NAObject *object )
+{
+ GtkTreePath *path;
+ static const gchar *thisfn = "nact_tree_model_delete";
+ GtkTreeIter iter;
+ GtkTreeStore *store;
+ NAObjectItem *parent;
+
+ g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
+
+ path = NULL;
+
+ if( !model->private->dispose_has_run ){
+ g_debug( "%s: model=%p, object=%p (%s)",
+ thisfn, ( void * ) model, ( void * ) object, object ? G_OBJECT_TYPE_NAME( object ) : "null" );
+
+ path = nact_tree_model_object_to_path( model, object );
+
+ if( path != NULL ){
+ gtk_tree_path_free( path );
+ store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
+ parent = na_object_get_parent( object );
+ g_debug( "%s: object=%p, parent=%p", thisfn, ( void * ) object, ( void * ) parent );
+ if( parent ){
+ na_object_remove_item( parent, object );
+ na_object_check_status( parent );
+ }
+ gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, path );
+ remove_items( store, &iter );
+ }
+ }
+
+ return( path );
+}
+
+/**
* nact_tree_model_fill:
* @model: this #NactTreeModel instance.
* @ŧreeview: the #GtkTreeView widget.
@@ -827,71 +870,6 @@ nact_tree_model_object_to_path( const NactTreeModel *model, const NAObject *obje
return( nfo.path );
}
-#if 0
-/**
- * nact_tree_model_iter:
- * @model: this #NactTreeModel instance.
- */
-void
-nact_tree_model_iter( NactTreeModel *model, FnIterOnStore fn, gpointer user_data )
-{
- GtkTreeStore *store;
-
- g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-
- if( !model->private->dispose_has_run ){
-
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- iter_on_store( model, GTK_TREE_MODEL( store ), NULL, fn, user_data );
- }
-}
-#endif
-
-/**
- * nact_tree_model_remove:
- * @model: this #NactTreeModel instance.
- * @object: the #NAObject to be deleted.
- *
- * Recursively deletes the specified object.
- *
- * Returns: a path which may be suitable for the next selection.
- */
-GtkTreePath *
-nact_tree_model_remove( NactTreeModel *model, NAObject *object )
-{
- GtkTreePath *path;
- static const gchar *thisfn = "nact_tree_model_remove";
- GtkTreeIter iter;
- GtkTreeStore *store;
- NAObjectItem *parent;
-
- g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
-
- path = NULL;
-
- if( !model->private->dispose_has_run ){
- g_debug( "%s: model=%p, object=%p (%s)",
- thisfn, ( void * ) model, ( void * ) object, object ? G_OBJECT_TYPE_NAME( object ) : "null" );
-
- path = nact_tree_model_object_to_path( model, object );
-
- if( path != NULL ){
- gtk_tree_path_free( path );
- store = GTK_TREE_STORE( gtk_tree_model_filter_get_model( GTK_TREE_MODEL_FILTER( model )));
- parent = na_object_get_parent( object );
- g_debug( "%s: object=%p, parent=%p", thisfn, ( void * ) object, ( void * ) parent );
- if( parent ){
- na_object_remove_item( parent, object );
- na_object_check_status_up( parent );
- }
- gtk_tree_model_get_iter( GTK_TREE_MODEL( store ), &iter, path );
- remove_items( store, &iter );
- }
- }
-
- return( path );
-}
-
static void
append_item( GtkTreeStore *model, GtkTreeView *treeview, GtkTreeIter *parent, GtkTreeIter *iter, const NAObject *object )
{
diff --git a/src/nact/nact-tree-model.h b/src/nact/nact-tree-model.h
index 4c18322..c9a9ca2 100644
--- a/src/nact/nact-tree-model.h
+++ b/src/nact/nact-tree-model.h
@@ -99,6 +99,7 @@ GType nact_tree_model_get_type( void );
NactTreeModel *nact_tree_model_new( BaseWindow *window, GtkTreeView *view, NactTreeMode mode );
+GtkTreePath *nact_tree_model_delete ( NactTreeModel *model, NAObject *object );
void nact_tree_model_fill ( NactTreeModel *model, GList *items );
GtkTreePath *nact_tree_model_insert ( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
GtkTreePath *nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
@@ -118,7 +119,6 @@ GtkTreePath *nact_tree_model_object_to_path( const NactTreeModel *model, const
/*void nact_tree_model_display( NactTreeModel *model, NAObject *object );*/
void nact_tree_model_display_order_change( NactTreeModel *model, gint order_mode );
/*void nact_tree_model_iter( NactTreeModel *model, FnIterOnStore fn, gpointer user_data );*/
-GtkTreePath *nact_tree_model_remove( NactTreeModel *model, NAObject *object );
/* *** */
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]