[gedit] Move panes actions to a separate action group



commit 4c6034d8700192cbd5a9b9beeb87dc172e422171
Author: Paolo Borelli <porelli gnome org>
Date:   Sat Jul 4 12:36:15 2009 +0200

    Move panes actions to a separate action group
    
    Move panes actions to a separate action group since thei sensitivity
    depends only on the fact that there are items in the pane itself and not
    on the fact that there are documents open.

 gedit/gedit-ui.h             |    9 +++++----
 gedit/gedit-window-private.h |    3 ++-
 gedit/gedit-window.c         |   32 +++++++++++++++++++-------------
 3 files changed, 26 insertions(+), 18 deletions(-)
---
diff --git a/gedit/gedit-ui.h b/gedit/gedit-ui.h
index 5a6f77e..ef50668 100644
--- a/gedit/gedit-ui.h
+++ b/gedit/gedit-ui.h
@@ -155,16 +155,17 @@ static const GtkToggleActionEntry gedit_always_sensitive_toggle_menu_entries[] =
 	{ "ViewStatusbar", NULL, N_("_Statusbar"), NULL,
 	  N_("Show or hide the statusbar in the current window"),
 	  G_CALLBACK (_gedit_cmd_view_show_statusbar), TRUE },
-	{ "ViewSidePane", NULL, N_("Side _Pane"), "F9",
-	  N_("Show or hide the side pane in the current window"),
-	  G_CALLBACK (_gedit_cmd_view_show_side_pane), FALSE },
 	{ "ViewFullscreen", GTK_STOCK_FULLSCREEN, NULL, "F11",
 	  N_("Edit text at fullscreen"),
 	  G_CALLBACK (_gedit_cmd_view_toggle_fullscreen_mode), FALSE }
 };
 
-static const GtkToggleActionEntry gedit_toggle_menu_entries[] =
+/* separate group, should be always sensitive except when there are no panes */
+static const GtkToggleActionEntry gedit_panes_toggle_menu_entries[] =
 {
+	{ "ViewSidePane", NULL, N_("Side _Pane"), "F9",
+	  N_("Show or hide the side pane in the current window"),
+	  G_CALLBACK (_gedit_cmd_view_show_side_pane), FALSE },
 	{ "ViewBottomPane", NULL, N_("_Bottom Pane"), "<control>F9",
 	  N_("Show or hide the bottom pane in the current window"),
 	  G_CALLBACK (_gedit_cmd_view_show_bottom_pane), FALSE }
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index 1f64a51..0467d8e 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -70,8 +70,9 @@ struct _GeditWindowPrivate
 	/* Menus & Toolbars */
 	GtkUIManager   *manager;
 	GtkActionGroup *action_group;
-	GtkActionGroup *quit_action_group;
 	GtkActionGroup *always_sensitive_action_group;
+	GtkActionGroup *quit_action_group;
+	GtkActionGroup *panes_action_group;
 	GtkActionGroup *languages_action_group;
 	GtkActionGroup *documents_list_action_group;
 	guint           documents_list_menu_ui_id;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 81164fc..cb0115a 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -1442,11 +1442,6 @@ create_menu_bar_and_toolbar (GeditWindow *window,
 				      gedit_menu_entries,
 				      G_N_ELEMENTS (gedit_menu_entries),
 				      window);
-	gtk_action_group_add_toggle_actions (action_group,
-					     gedit_toggle_menu_entries,
-					     G_N_ELEMENTS (gedit_toggle_menu_entries),
-					     window);
-
 	gtk_ui_manager_insert_action_group (manager, action_group, 0);
 	g_object_unref (action_group);
 	window->priv->action_group = action_group;
@@ -1478,6 +1473,17 @@ create_menu_bar_and_toolbar (GeditWindow *window,
 	g_object_unref (action_group);
 	window->priv->quit_action_group = action_group;
 
+	action_group = gtk_action_group_new ("GeditWindowPanesActions");
+	gtk_action_group_set_translation_domain (action_group, NULL);
+	gtk_action_group_add_toggle_actions (action_group,
+					     gedit_panes_toggle_menu_entries,
+					     G_N_ELEMENTS (gedit_panes_toggle_menu_entries),
+					     window);
+
+	gtk_ui_manager_insert_action_group (manager, action_group, 0);
+	g_object_unref (action_group);
+	window->priv->panes_action_group = action_group;
+
 	/* now load the UI definition */
 	ui_file = gedit_dirs_get_ui_file (GEDIT_UIFILE);
 	gtk_ui_manager_add_ui_from_file (manager, ui_file, &error);
@@ -3484,7 +3490,7 @@ side_panel_visibility_changed (GtkWidget   *side_panel,
 	if (gedit_prefs_manager_side_pane_visible_can_set ())
 		gedit_prefs_manager_set_side_pane_visible (visible);
 
-	action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+	action = gtk_action_group_get_action (window->priv->panes_action_group,
 	                                      "ViewSidePane");
 
 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
@@ -3538,7 +3544,7 @@ bottom_panel_visibility_changed (GeditPanel  *bottom_panel,
 	if (gedit_prefs_manager_bottom_panel_visible_can_set ())
 		gedit_prefs_manager_set_bottom_panel_visible (visible);
 
-	action = gtk_action_group_get_action (window->priv->action_group,
+	action = gtk_action_group_get_action (window->priv->panes_action_group,
 					      "ViewBottomPane");
 
 	if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
@@ -3561,7 +3567,7 @@ bottom_panel_item_removed (GeditPanel  *panel,
 
 		gtk_widget_hide (GTK_WIDGET (panel));
 
-		action = gtk_action_group_get_action (window->priv->action_group,
+		action = gtk_action_group_get_action (window->priv->panes_action_group,
 						      "ViewBottomPane");
 		gtk_action_set_sensitive (action, FALSE);
 	}
@@ -3579,7 +3585,7 @@ bottom_panel_item_added (GeditPanel  *panel,
 		GtkAction *action;
 		gboolean show;
 
-		action = gtk_action_group_get_action (window->priv->action_group,
+		action = gtk_action_group_get_action (window->priv->panes_action_group,
 						      "ViewBottomPane");
 		gtk_action_set_sensitive (action, TRUE);
 
@@ -3637,25 +3643,25 @@ init_panels_visibility (GeditWindow *window)
 
 		if (gedit_prefs_manager_get_bottom_panel_visible ())
 		{
-  			gtk_widget_show (window->priv->bottom_panel);
+			gtk_widget_show (window->priv->bottom_panel);
 		}
 	}
 	else
 	{
 		GtkAction *action;
-		action = gtk_action_group_get_action (window->priv->action_group,
+		action = gtk_action_group_get_action (window->priv->panes_action_group,
 						      "ViewBottomPane");
 		gtk_action_set_sensitive (action, FALSE);
 	}
 
 	/* start track sensitivity after the initial state is set */
-  	window->priv->bottom_panel_item_removed_handler_id =
+	window->priv->bottom_panel_item_removed_handler_id =
 		g_signal_connect (window->priv->bottom_panel,
 				  "item_removed",
 				  G_CALLBACK (bottom_panel_item_removed),
 				  window);
 
-  	g_signal_connect (window->priv->bottom_panel,
+	g_signal_connect (window->priv->bottom_panel,
 			  "item_added",
 			  G_CALLBACK (bottom_panel_item_added),
 			  window);



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