[nautilus-actions] nact_main_menubar_enable_item() renamed as nact_menubar_enabled_item()



commit e8628fa33db3e4e8560a033f16c261f3043ebaeb
Author: Pierre Wieser <pwieser trychlos org>
Date:   Tue Feb 1 02:03:46 2011 +0100

    nact_main_menubar_enable_item() renamed as nact_menubar_enabled_item()
    
    The function is moved to private area.

 ChangeLog                          |   11 +++++++++++
 src/nact/nact-main-menubar-edit.c  |   12 ++++++------
 src/nact/nact-main-menubar-file.c  |    8 ++++----
 src/nact/nact-main-menubar-help.c  |    2 +-
 src/nact/nact-main-menubar-tools.c |    4 ++--
 src/nact/nact-main-menubar-view.c  |    4 ++--
 src/nact/nact-menubar-priv.h       |    5 +++++
 src/nact/nact-menubar.c            |   13 +++++++------
 src/nact/nact-menubar.h            |    1 -
 9 files changed, 38 insertions(+), 22 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 83fefa6..008ca89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-01-31 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-menubar.c (nact_main_menubar_enable_item):
+	Renamed as nact_menubar_enable_item() and moved to private resources.
+
+	* src/nact/nact-main-menubar-edit.c:
+	* src/nact/nact-main-menubar-file.c:
+	* src/nact/nact-main-menubar-help.c:
+	* src/nact/nact-main-menubar-tools.c:
+	* src/nact/nact-main-menubar-view.c:
+	* src/nact/nact-menubar-priv.h:
+	* src/nact/nact-menubar.h: Updated accordingly.
+
 	Move MenubarIndicatorsStruct structure to private instance data
 
 	* src/nact/nact-menubar-priv.h: New file.
diff --git a/src/nact/nact-main-menubar-edit.c b/src/nact/nact-main-menubar-edit.c
index 8bcc5ac..3111baf 100644
--- a/src/nact/nact-main-menubar-edit.c
+++ b/src/nact/nact-main-menubar-edit.c
@@ -97,12 +97,12 @@ nact_main_menubar_edit_on_update_sensitivities( NactMenubar *bar )
 		}
 	}
 	cut_enabled &= are_parents_writable;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "CutItem", cut_enabled );
+	nact_menubar_enable_item( bar, "CutItem", cut_enabled );
 
 	/* copy only requires a non-empty selection */
 	copy_enabled = bar->private->treeview_has_focus || bar->private->popup_handler;
 	copy_enabled &= bar->private->count_selected > 0;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "CopyItem", copy_enabled );
+	nact_menubar_enable_item( bar, "CopyItem", copy_enabled );
 
 	/* paste enabled if
 	 * - clipboard is not empty
@@ -142,7 +142,7 @@ nact_main_menubar_edit_on_update_sensitivities( NactMenubar *bar )
 			paste_enabled &= bar->private->is_level_zero_writable;
 		}
 	}
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "PasteItem", paste_enabled );
+	nact_menubar_enable_item( bar, "PasteItem", paste_enabled );
 
 	/* paste into enabled if
 	 * - clipboard is not empty
@@ -179,7 +179,7 @@ nact_main_menubar_edit_on_update_sensitivities( NactMenubar *bar )
 			paste_into_enabled &= bar->private->is_level_zero_writable;
 		}
 	}
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "PasteIntoItem", paste_into_enabled );
+	nact_menubar_enable_item( bar, "PasteIntoItem", paste_into_enabled );
 
 	/* duplicate items will be duplicated besides each one
 	 * selection must be non-empty
@@ -187,14 +187,14 @@ nact_main_menubar_edit_on_update_sensitivities( NactMenubar *bar )
 	 * -> so this is the same than cut
 	 */
 	duplicate_enabled = cut_enabled;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "DuplicateItem", duplicate_enabled );
+	nact_menubar_enable_item( bar, "DuplicateItem", duplicate_enabled );
 
 	/* delete is same that cut
 	 * but items themselves must be writable (because physically deleted)
 	 * this will be checked on delete activated
 	 */
 	delete_enabled = cut_enabled;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "DeleteItem", delete_enabled );
+	nact_menubar_enable_item( bar, "DeleteItem", delete_enabled );
 
 	/* reload items always enabled */
 
diff --git a/src/nact/nact-main-menubar-file.c b/src/nact/nact-main-menubar-file.c
index e9e5bf2..0f67432 100644
--- a/src/nact/nact-main-menubar-file.c
+++ b/src/nact/nact-main-menubar-file.c
@@ -104,8 +104,8 @@ nact_main_menubar_file_on_update_sensitivities( NactMenubar *bar )
 	 * we must have at least one writable provider
 	 */
 	new_item_enabled = is_first_parent_writable && bar->private->has_writable_providers;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "NewMenuItem", new_item_enabled );
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "NewActionItem", new_item_enabled );
+	nact_menubar_enable_item( bar, "NewMenuItem", new_item_enabled );
+	nact_menubar_enable_item( bar, "NewActionItem", new_item_enabled );
 
 	/* new profile enabled if selection is relative to only one writable action
 	 * i.e. contains profile(s) of the same action, or only contains one action
@@ -137,7 +137,7 @@ nact_main_menubar_file_on_update_sensitivities( NactMenubar *bar )
 			}
 		}
 	}
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "NewProfileItem",
+	nact_menubar_enable_item( bar, "NewProfileItem",
 			new_profile_enabled &&
 			selected_action != NULL &&
 			na_updater_is_item_writable( bar->private->updater, NA_OBJECT_ITEM( selected_action ), NULL ));
@@ -145,7 +145,7 @@ nact_main_menubar_file_on_update_sensitivities( NactMenubar *bar )
 	/* save enabled if at least one item has been modified
 	 * or level-zero has been resorted and is writable
 	 */
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "SaveItem",
+	nact_menubar_enable_item( bar, "SaveItem",
 			has_modified_items || ( bar->private->level_zero_order_changed && bar->private->is_level_zero_writable ));
 
 	/* quit always enabled */
diff --git a/src/nact/nact-main-menubar-help.c b/src/nact/nact-main-menubar-help.c
index 2c2a469..906ba9e 100644
--- a/src/nact/nact-main-menubar-help.c
+++ b/src/nact/nact-main-menubar-help.c
@@ -48,7 +48,7 @@
 void
 nact_main_menubar_help_on_update_sensitivities( NactMenubar *bar )
 {
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "HelpItem", TRUE );
+	nact_menubar_enable_item( bar, "HelpItem", TRUE );
 	/* about always enabled */
 }
 
diff --git a/src/nact/nact-main-menubar-tools.c b/src/nact/nact-main-menubar-tools.c
index 8831524..ff061bf 100644
--- a/src/nact/nact-main-menubar-tools.c
+++ b/src/nact/nact-main-menubar-tools.c
@@ -49,10 +49,10 @@ void
 nact_main_menubar_tools_on_update_sensitivities( NactMenubar *bar )
 {
 	/* import item enabled if at least one writable provider */
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "ImportItem", bar->private->has_writable_providers );
+	nact_menubar_enable_item( bar, "ImportItem", bar->private->has_writable_providers );
 
 	/* export item enabled if IActionsList store contains actions */
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "ExportItem", bar->private->have_exportables );
+	nact_menubar_enable_item( bar, "ExportItem", bar->private->have_exportables );
 }
 
 /**
diff --git a/src/nact/nact-main-menubar-view.c b/src/nact/nact-main-menubar-view.c
index 80c55bd..7a142ae 100644
--- a/src/nact/nact-main-menubar-view.c
+++ b/src/nact/nact-main-menubar-view.c
@@ -54,8 +54,8 @@ nact_main_menubar_view_on_update_sensitivities( NactMenubar *bar )
 
 	/* expand all/collapse all requires at least one item in the list */
 	count_list = bar->private->list_menus + bar->private->list_actions + bar->private->list_profiles;
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "ExpandAllItem", count_list > 0 );
-	nact_main_menubar_enable_item( NACT_MAIN_WINDOW( bar->private->window ), "CollapseAllItem", count_list > 0 );
+	nact_menubar_enable_item( bar, "ExpandAllItem", count_list > 0 );
+	nact_menubar_enable_item( bar, "CollapseAllItem", count_list > 0 );
 }
 
 /**
diff --git a/src/nact/nact-menubar-priv.h b/src/nact/nact-menubar-priv.h
index fbca480..b3af964 100644
--- a/src/nact/nact-menubar-priv.h
+++ b/src/nact/nact-menubar-priv.h
@@ -45,6 +45,7 @@
 G_BEGIN_DECLS
 
 struct _NactMenubarPrivate {
+	/*< private >*/
 	gboolean        dispose_has_run;
 	BaseWindow     *window;
 	GtkUIManager   *ui_manager;
@@ -88,6 +89,10 @@ struct _NactMenubarPrivate {
 		NactMenubar *bar = ( NactMenubar * ) g_object_get_data( G_OBJECT( window ), WINDOW_DATA_MENUBAR ); \
 		g_return_val_if_fail( NACT_IS_MENUBAR( bar ), value );
 
+/* These functions should only be called from a nact-menubar-derived file
+ */
+void nact_menubar_enable_item( const NactMenubar *bar, const gchar *name, gboolean enabled );
+
 G_END_DECLS
 
 #endif /* __NACT_MENUBAR__PRIV_H__ */
diff --git a/src/nact/nact-menubar.c b/src/nact/nact-menubar.c
index f8ffacd..e55bb52 100644
--- a/src/nact/nact-menubar.c
+++ b/src/nact/nact-menubar.c
@@ -745,22 +745,23 @@ on_update_sensitivities( NactMainWindow *window, gpointer user_data )
 }
 
 /**
- * nact_main_menubar_enable_item:
- * @window: the #NactMainWindow main application window.
+ * nact_menubar_enable_item:
+ * @bar: this #NactMenubar instance.
  * @name: the name of the item in a menu.
  * @enabled: whether this item should be enabled or not.
  *
  * Enable/disable an item in an menu.
  */
 void
-nact_main_menubar_enable_item( NactMainWindow *window, const gchar *name, gboolean enabled )
+nact_menubar_enable_item( const NactMenubar *bar, const gchar *name, gboolean enabled )
 {
 	GtkAction *action;
 
-	BAR_WINDOW_VOID( window );
+	if( !bar->private->dispose_has_run ){
 
-	action = gtk_action_group_get_action( bar->private->action_group, name );
-	gtk_action_set_sensitive( action, enabled );
+		action = gtk_action_group_get_action( bar->private->action_group, name );
+		gtk_action_set_sensitive( action, enabled );
+	}
 }
 
 static void
diff --git a/src/nact/nact-menubar.h b/src/nact/nact-menubar.h
index bce55b7..8df206b 100644
--- a/src/nact/nact-menubar.h
+++ b/src/nact/nact-menubar.h
@@ -92,7 +92,6 @@ NactMenubar *nact_menubar_new     ( BaseWindow *window );
 /* *** */
 gboolean nact_main_menubar_is_level_zero_order_changed( const NactMainWindow *window );
 void     nact_main_menubar_open_popup( NactMainWindow *window, GdkEventButton *event );
-void     nact_main_menubar_enable_item( NactMainWindow *window, const gchar *name, gboolean enabled );
 /* *** */
 
 G_END_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]