[nautilus-actions] Fix action sensitivities in menubar
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Fix action sensitivities in menubar
- Date: Fri, 9 Oct 2009 00:16:29 +0000 (UTC)
commit 38e1cc0528a8a17a13c7595396be34097bab02b2
Author: Pierre Wieser <pwieser trychlos org>
Date: Fri Oct 9 02:18:22 2009 +0200
Fix action sensitivities in menubar
ChangeLog | 12 ++++++++++++
src/nact/nact-iactions-list.c | 8 +++++---
src/nact/nact-main-menubar.c | 17 ++++++++++-------
src/nact/nact-main-window.c | 10 +++++-----
src/nact/nact-tree-model.c | 3 +++
src/runtime/na-object-item.c | 36 ++++++++++++++++++------------------
6 files changed, 53 insertions(+), 33 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 021568a..9c5ddf9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,18 @@
* src/common/na-object-item.c (na_object_item_remove_item):
Moved to runtime library.
+ * src/nact/nact-iactions-list.c (do_insert_items):
+ Marks the item itself as modified if it has no parent.
+
+ * src/nact/nact-main-menubar.c (on_update_sensitivities):
+ Enable Paste a profile if an action is selected.
+ Always disable Paste into a profile.
+
+ * src/nact/nact-main-window.c (actually_delete_item):
+ Delete childs before removing from pivot.
+ (nact_tree_model_insert, nact_tree_model_insert_into):
+ Set parent on newly inserted child.
+
* src/nact/nact-tree-model.c (fill_tree_store):
Rewrite duplication code to get reference counts equal to 1 in the store.
Install parent pointer in childs.
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 8160c23..bea9424 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -1060,6 +1060,7 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
GList *it;
GList *subitems;
NAObject *obj_parent;
+ gpointer updatable;
obj_parent = NULL;
if( list_parents ){
@@ -1075,9 +1076,10 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
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 );
- if( list_parents && obj_parent ){
- if( !g_list_find( *list_parents, obj_parent )){
- *list_parents = g_list_prepend( *list_parents, obj_parent );
+ if( list_parents ){
+ updatable = obj_parent ? obj_parent : it->data;
+ if( !g_list_find( *list_parents, updatable )){
+ *list_parents = g_list_prepend( *list_parents, updatable );
}
}
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index 12edadb..ca2049b 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -409,18 +409,20 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
paste_enabled = FALSE;
if( !clipboard_is_empty ){
if( mis->clipboard_profiles ){
- paste_enabled = profile && NA_IS_OBJECT_PROFILE( profile );
+ paste_enabled = item && NA_IS_OBJECT_ACTION( item );
} else {
paste_enabled = ( item != NULL );
}
}
paste_into_enabled = FALSE;
- if( !clipboard_is_empty ){
- if( mis->clipboard_profiles ){
- paste_into_enabled = item && NA_IS_OBJECT_ACTION( item );
- } else {
- paste_into_enabled = item && NA_IS_OBJECT_MENU( item );
+ if( mis->selected_menus + mis->selected_actions ){
+ if( !clipboard_is_empty ){
+ if( mis->clipboard_profiles ){
+ paste_into_enabled = item && NA_IS_OBJECT_ACTION( item );
+ } else {
+ paste_into_enabled = item && NA_IS_OBJECT_MENU( item );
+ }
}
}
@@ -440,7 +442,8 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
enable_item( window, "PasteItem", count_selected <= 1 && paste_enabled );
/* paste into enabled if
* - clipboard has profiles and current item is an action
- * - or current item is a menu */
+ * - or current item is a menu
+ * do not paste into if current selection is a profile */
enable_item( window, "PasteIntoItem", count_selected <= 1 && paste_into_enabled );
/* duplicate/delete enabled if selection not empty */
enable_item( window, "DuplicateItem", count_selected > 0 );
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 4a48b64..b1c8b10 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -811,17 +811,17 @@ actually_delete_item( NactMainWindow *window, NAObject *item, NAPivot *pivot )
if( NA_IS_OBJECT_ITEM( item )){
nact_window_delete_item( NACT_WINDOW( window ), NA_OBJECT_ITEM( item ));
- origin = na_object_get_origin( item );
- if( origin ){
- na_pivot_remove_item( pivot, origin );
- }
-
if( NA_IS_OBJECT_MENU( item )){
items = na_object_get_items_list( item );
for( it = items ; it ; it = it->next ){
actually_delete_item( window, NA_OBJECT( it->data ), pivot );
}
}
+
+ origin = na_object_get_origin( item );
+ if( origin ){
+ na_pivot_remove_item( pivot, origin );
+ }
}
}
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index a6869c5..b9fd3f6 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -791,6 +791,8 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
} else {
na_object_append_item( parent_obj, object );
}
+
+ na_object_set_parent( object, parent_obj );
}
gtk_tree_store_insert_before(
@@ -831,6 +833,7 @@ nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTr
g_object_unref( *parent );
na_object_insert_item( *parent, object, NULL );
+ na_object_set_parent( object, *parent );
gtk_tree_store_insert_after( GTK_TREE_STORE( store ), &iter, &parent_iter, NULL );
gtk_tree_store_set( GTK_TREE_STORE( store ), &iter, IACTIONS_LIST_NAOBJECT_COLUMN, object, -1 );
diff --git a/src/runtime/na-object-item.c b/src/runtime/na-object-item.c
index 47ab924..9ab9106 100644
--- a/src/runtime/na-object-item.c
+++ b/src/runtime/na-object-item.c
@@ -316,6 +316,24 @@ instance_finalize( GObject *object )
}
/**
+ * na_object_item_free_items_list:
+ * @list: a list of #NAObject items.
+ *
+ * Recursively unref the #NAObject of the list, freeing the list at last.
+ */
+void
+na_object_item_free_items_list( GList *items )
+{
+ GList *it;
+
+ for( it = items ; it ; it = it->next ){
+ na_object_unref( it->data );
+ }
+
+ g_list_free( items );
+}
+
+/**
* na_object_item_get_tooltip:
* @item: the #NAObjectItem object to be requested.
*
@@ -470,24 +488,6 @@ na_object_item_get_items_count( const NAObjectItem *item )
}
/**
- * na_object_item_free_items_list:
- * @list: a list of #NAObject items.
- *
- * Recursively unref the #NAObject of the list, freeing the list at last.
- */
-void
-na_object_item_free_items_list( GList *items )
-{
- GList *it;
-
- for( it = items ; it ; it = it->next ){
- na_object_unref( it->data );
- }
-
- g_list_free( items );
-}
-
-/**
* na_object_item_is_enabled:
* @item: the #NAObjectItem object to be requested.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]