[nautilus-actions] Doesn't update the selection while removing items from the tree
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Doesn't update the selection while removing items from the tree
- Date: Sat, 26 Sep 2009 22:47:15 +0000 (UTC)
commit 91de0855905c1dc5ffb67a469f246fb4c2a0ae4b
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Sep 18 00:22:44 2009 +0200
Doesn't update the selection while removing items from the tree
ChangeLog | 3 +++
src/nact/nact-iactions-list.c | 30 +++++++++++++++++++++++++++---
src/nact/nact-main-menubar.c | 21 ++++-----------------
3 files changed, 34 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8f5585a..27816c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,9 @@
we are only able to select profiles, or actions/menus.
Define new nact_iactions_list_set_filter_selection_mode() api.
+ * src/nact/nact-iactions-list.c (is_removing, set_remove_operation):
+ Doesn't update the selection while removing items.
+
* src/common/na-object.c:
* src/common/na-object-fn.h
(na_object_get_hierarchy, na_object_free_hierarchy): New functions.
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 9bea2ab..49af0cd 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -90,6 +90,7 @@ typedef struct {
#define IS_FILLING_LIST "nact-iactions-list-is-filling-list"
#define HAVE_DND_MODE "nact-iactions-list-dnd-mode"
#define FILTER_SELECTION_MODE "nact-iactions-list-filter-selection-mode"
+#define REMOVE_OPERATION "nact-iactions-list-removing"
static gint st_signals[ LAST_SIGNAL ] = { 0 };
@@ -109,6 +110,7 @@ static gboolean have_dnd_mode( NactIActionsList *instance );
static gboolean have_filter_selection_mode( NactIActionsList *instance );
static void insert_item( NactIActionsList *instance, NAObject *item );
static gboolean is_modified_item( NactTreeModel *model, GtkTreePath *path, NAObject *object, GList **items );
+static gboolean is_removing( NactIActionsList *instance );
static void iter_on_selection( NactIActionsList *instance, FnIterOnSelection fn_iter, gpointer user_data );
static gboolean on_button_press_event( GtkWidget *widget, GdkEventButton *event, NactIActionsList *instance );
static gboolean on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, NactIActionsList *instance );
@@ -118,6 +120,7 @@ static void on_iactions_list_item_updated_treeview( NactIActionsList *in
static void on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
static void select_first_row( NactIActionsList *instance );
static void set_is_filling_list( NactIActionsList *instance, gboolean is_filling );
+static void set_remove_operation( NactIActionsList *instance, gboolean removing );
static void toggle_collapse( NactIActionsList *instance );
static gboolean toggle_collapse_iter( NactIActionsList *instance, GtkTreeView *treeview, GtkTreeModel *model, GtkTreeIter *iter, NAObject *object, gpointer user_data );
static void toggle_collapse_row( GtkTreeView *treeview, GtkTreePath *path, guint *toggle );
@@ -418,7 +421,9 @@ nact_iactions_list_dispose( NactIActionsList *instance )
*
* Deletes the current selection from the underlying tree store.
*
- * The returned @path should be gtk_tree_path_free() by the caller.
+ * The returned @path tries to represent the most probable available
+ * selection after deletion has occured.
+ * It should be gtk_tree_path_free() by the caller.
*/
void
nact_iactions_list_delete_selection( NactIActionsList *instance, GtkTreePath **path )
@@ -434,11 +439,15 @@ nact_iactions_list_delete_selection( NactIActionsList *instance, GtkTreePath **p
selection = gtk_tree_view_get_selection( treeview );
selected = gtk_tree_selection_get_selected_rows( selection, &model );
+ set_remove_operation( instance, TRUE );
+
if( g_list_length( selected )){
*path = gtk_tree_path_copy(( GtkTreePath * ) selected->data );
nact_tree_model_remove( NACT_TREE_MODEL( model ), selected );
}
+ set_remove_operation( instance, FALSE );
+
g_list_foreach( selected, ( GFunc ) gtk_tree_path_free, NULL );
g_list_free( selected );
}
@@ -1212,6 +1221,12 @@ is_modified_item( NactTreeModel *model, GtkTreePath *path, NAObject *object, GLi
return( FALSE );
}
+static gboolean
+is_removing( NactIActionsList *instance )
+{
+ return(( gboolean ) GPOINTER_TO_INT( g_object_get_data( G_OBJECT( instance ), REMOVE_OPERATION )));
+}
+
static void
iter_on_selection( NactIActionsList *instance, FnIterOnSelection fn_iter, gpointer user_data )
{
@@ -1278,6 +1293,8 @@ on_key_pressed_event( GtkWidget *widget, GdkEventKey *event, NactIActionsList *i
/*
* this is our handler of "changed" signal emitted by the treeview
+ * it is inhibited while filling the list (usually only at runtime init)
+ * and while deleting a selection
*/
static void
on_treeview_selection_changed( GtkTreeSelection *selection, NactIActionsList *instance )
@@ -1286,8 +1303,9 @@ on_treeview_selection_changed( GtkTreeSelection *selection, NactIActionsList *in
selected_items = nact_iactions_list_get_selected_items( instance );
- if( !nact_iactions_list_is_filling_list( instance )){
- g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, selected_items );
+ if( !nact_iactions_list_is_filling_list( instance ) &&
+ !is_removing( instance )){
+ g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, selected_items );
}
}
@@ -1367,6 +1385,12 @@ set_is_filling_list( NactIActionsList *instance, gboolean is_filling )
}
static void
+set_remove_operation( NactIActionsList *instance, gboolean removing )
+{
+ g_object_set_data( G_OBJECT( instance ), REMOVE_OPERATION, GINT_TO_POINTER( removing ));
+}
+
+static void
toggle_collapse( NactIActionsList *instance )
{
int toggle = TOGGLE_UNDEFINED;
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 1974fe8..a42d074 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -280,13 +280,8 @@ on_new_menu_activated( GtkAction *gtk_action, NactMainWindow *window )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
menu = na_object_menu_new();
- na_object_check_edition_status( menu );
items = g_list_prepend( items, menu );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items );
-
- /*updates = g_slist_prepend( updates, g_object_ref( menu ));
- g_signal_emit_by_name( window, IACTIONS_LIST_SIGNAL_ITEM_UPDATED, updates );*/
-
na_object_free_items( items );
}
@@ -300,14 +295,8 @@ on_new_action_activated( GtkAction *gtk_action, NactMainWindow *window )
g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
action = na_object_action_new_with_profile();
- na_object_check_edition_status( action );
- /*na_object_check_edition_status( na_object_action_get_profiles( action )->data );*/
items = g_list_prepend( items, action );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items );
-
- /*updates = g_slist_prepend( updates, g_object_ref( action ));
- g_signal_emit_by_name( window, IACTIONS_LIST_SIGNAL_ITEM_UPDATED, updates );*/
-
na_object_free_items( items );
}
@@ -328,18 +317,14 @@ on_new_profile_activated( GtkAction *gtk_action, NactMainWindow *window )
NULL );
profile = na_object_profile_new();
- name = na_object_action_get_new_profile_name( action );
+ name = na_object_action_get_new_profile_name( action );
na_object_action_attach_profile( action, profile );
na_object_set_id( profile, name );
- na_object_check_edition_status( NA_OBJECT( profile ));
- /*na_object_check_edited_status( NA_OBJECT( action ));*/
+
items = g_list_prepend( items, profile );
nact_iactions_list_insert_items( NACT_IACTIONS_LIST( window ), items );
- /*updates = g_slist_prepend( updates, g_object_ref( profile ));
- g_signal_emit_by_name( window, IACTIONS_LIST_SIGNAL_ITEM_UPDATED, updates );*/
-
na_object_free_items( items );
g_free( name );
}
@@ -539,6 +524,8 @@ on_delete_activated( GtkAction *gtk_action, NactMainWindow *window )
nact_main_window_move_to_deleted( window, items );
nact_iactions_list_select_row( NACT_IACTIONS_LIST( window ), path );
+ /* do not unref selected items as the ref has been moved to main_deleted
+ */
g_list_free( items );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]