[epiphany/gnome-3-6] Merge the app menu into the gear menu when we are not in the Shell



commit 03c0677e0fe78d7a398bec28c9b5a5031b134f9c
Author: Xan Lopez <xan igalia com>
Date:   Sun Oct 7 10:37:57 2012 -0400

    Merge the app menu into the gear menu when we are not in the Shell
    
    Gets rid of the ugly menubar with a single menu.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673054

 src/ephy-shell.c              |   35 ++++-------------------
 src/ephy-window.c             |   63 +++++++++++++++++++++++++++++++++++++++++
 src/resources/epiphany-ui.xml |    7 ++++-
 src/window-commands.c         |   63 +++++++++++++++++++++++++++++++++++++++++
 src/window-commands.h         |   12 ++++++++
 5 files changed, 150 insertions(+), 30 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 7bd305e..da44fc9 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -165,8 +165,7 @@ new_window (GSimpleAction *action,
             GVariant *parameter,
             gpointer user_data)
 {
-  ephy_shell_new_tab (ephy_shell, NULL, NULL, NULL,
-                      EPHY_NEW_TAB_IN_NEW_WINDOW | EPHY_NEW_TAB_HOME_PAGE);
+  window_cmd_file_new_window (NULL, NULL);
 }
 
 static void
@@ -174,10 +173,7 @@ show_bookmarks (GSimpleAction *action,
                 GVariant *parameter,
                 gpointer user_data)
 {
-  GtkWidget *bwindow;
-
-  bwindow = ephy_shell_get_bookmarks_editor (ephy_shell);
-  gtk_window_present (GTK_WINDOW (bwindow));
+  window_cmd_edit_bookmarks (NULL, NULL);
 }
 
 static void
@@ -185,10 +181,7 @@ show_history (GSimpleAction *action,
               GVariant *parameter,
               gpointer user_data)
 {
-  GtkWidget *hwindow;
-
-  hwindow = ephy_shell_get_history_window (ephy_shell);
-  gtk_window_present (GTK_WINDOW (hwindow));
+  window_cmd_edit_history (NULL, NULL);
 }
 
 static void
@@ -196,11 +189,7 @@ show_preferences (GSimpleAction *action,
                   GVariant *parameter,
                   gpointer user_data)
 {
-  EphyDialog *dialog;
-
-  dialog = EPHY_DIALOG (ephy_shell_get_prefs_dialog (ephy_shell));
-
-  ephy_dialog_show (dialog);
+  window_cmd_edit_preferences (NULL, NULL);
 }
 
 static void
@@ -208,15 +197,7 @@ show_pdm (GSimpleAction *action,
           GVariant *parameter,
           gpointer user_data)
 {
-  PdmDialog *dialog;
-
-  dialog = EPHY_PDM_DIALOG (ephy_shell_get_pdm_dialog (ephy_shell));
-  /* FIXME?: pdm_dialog_open is supposed to scroll to the host passed
-   * as second parameters in the cookies tab. Honestly I think this
-   * has been broken for a while. In any case it's probably not
-   * relevant here, although we could get the host of the last active
-   * ephy window, I guess. */
-  pdm_dialog_open (dialog, NULL);
+  window_cmd_edit_personal_data (NULL, NULL);
 }
 
 static void
@@ -238,11 +219,7 @@ quit_application (GSimpleAction *action,
                   GVariant *parameter,
                   gpointer user_data)
 {
-  if (!g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
-                               EPHY_PREFS_LOCKDOWN_QUIT)) {
-    ephy_session_close (EPHY_SESSION (ephy_shell_get_session (ephy_shell)));
-    g_application_quit (g_application_get_default ());
-  }
+  window_cmd_file_quit (NULL, NULL);
 }
 
 static GActionEntry app_entries[] = {
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 898c7d7..8fd60aa 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -98,6 +98,8 @@ static const GtkActionEntry ephy_menu_entries [] = {
 
 	/* File actions. */
 
+	{ "FileNewWindow", NULL, N_("_New Window"), "<control>N", NULL,
+	  G_CALLBACK (window_cmd_file_new_window) },
 	{ "FileOpen", NULL, N_("_Openâ"), "<control>O", NULL,
 	  G_CALLBACK (window_cmd_file_open) },
 	{ "FileSaveAs", NULL, N_("Save _Asâ"), "<shift><control>S", NULL,
@@ -110,6 +112,8 @@ static const GtkActionEntry ephy_menu_entries [] = {
 	  G_CALLBACK (window_cmd_file_send_to) },
 	{ "FileCloseTab", NULL, N_("_Close"), "<control>W", NULL,
 	  G_CALLBACK (window_cmd_file_close_window) },
+	{ "FileQuit", NULL, N_("_Quit"), "<control>Q", NULL,
+	  G_CALLBACK (window_cmd_file_quit) },
 
 	/* Edit actions. */
 
@@ -133,6 +137,14 @@ static const GtkActionEntry ephy_menu_entries [] = {
 	  G_CALLBACK (window_cmd_edit_find_next) },
 	{ "EditFindPrev", NULL, N_("Find Pre_vious"), "<shift><control>G", NULL,
 	  G_CALLBACK (window_cmd_edit_find_prev) },
+	{ "EditBookmarks", NULL, N_("Edit _Bookmarksâ"), "<control>B", NULL,
+	  G_CALLBACK (window_cmd_edit_bookmarks) },
+	{ "EditHistory", NULL, N_("Edit _Historyâ"), "<control>H", NULL,
+	  G_CALLBACK (window_cmd_edit_history) },
+	{ "EditPreferences", NULL, N_("Preferences"), "<control>e", NULL,
+	  G_CALLBACK (window_cmd_edit_preferences) },
+	{ "EditPersonalData", NULL, N_("Personal Data"), "<control>m", NULL,
+	  G_CALLBACK (window_cmd_edit_personal_data) },
 
 	/* View actions. */
 
@@ -174,6 +186,11 @@ static const GtkActionEntry ephy_menu_entries [] = {
 	  G_CALLBACK (window_cmd_tabs_move_right) },
         { "TabsDetach", NULL, N_("_Detach Tab"), NULL, NULL,
           G_CALLBACK (window_cmd_tabs_detach) },
+
+	/* Help. */
+
+	{ "HelpAbout", NULL, N_("_About"), NULL, NULL,
+	  G_CALLBACK (window_cmd_help_about) }
 };
 
 static const GtkToggleActionEntry ephy_menu_toggle_entries [] =
@@ -354,6 +371,7 @@ struct _EphyWindowPrivate
 	EphyLocationController *location_controller;
 
 	gulong set_focus_handler;
+	gulong app_menu_visibility_handler;
 
 	guint closing : 1;
 	guint has_size : 1;
@@ -3414,6 +3432,10 @@ ephy_window_finalize (GObject *object)
 		g_signal_handler_disconnect (window,
 					     priv->set_focus_handler);
 
+	if (priv->app_menu_visibility_handler != 0)
+		g_signal_handler_disconnect (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+					     priv->app_menu_visibility_handler);
+
 	G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
 
 	LOG ("EphyWindow finalised %p", object);
@@ -3590,6 +3612,38 @@ _gtk_css_provider_load_from_resource (GtkCssProvider* provider,
 	return res;
 }
 
+static const gchar* app_actions[] = {
+	"FileNewWindow",
+	"EditPreferences",
+	"EditPersonalData",
+	"EditBookmarks",
+	"EditHistory",
+	"FileQuit",
+	"HelpAbout"
+};
+
+static void
+ephy_window_toggle_visibility_for_app_menu (EphyWindow *window)
+{
+	const gchar *action_name;
+	gboolean shows_app_menu;
+	GtkSettings *settings;
+	GtkAction *action;
+	gint idx;
+
+	settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window)));
+	g_object_get (settings,
+		      "gtk-shell-shows-app-menu", &shows_app_menu,
+		      NULL);
+
+	for (idx = 0; idx < G_N_ELEMENTS (app_actions); idx++) {
+		action_name = app_actions[idx];
+		action = gtk_action_group_get_action (window->priv->action_group, action_name);
+
+		gtk_action_set_visible (action, !shows_app_menu);
+	}
+}
+
 static GObject *
 ephy_window_constructor (GType type,
 			 guint n_construct_properties,
@@ -3771,6 +3825,15 @@ ephy_window_constructor (GType type,
 		}
 	}
 
+	/* We never want the menubar shown, we merge the app menu into
+	 * our super menu manually when running outside the Shell. */
+	gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window), FALSE);
+
+	ephy_window_toggle_visibility_for_app_menu (window);
+	priv->app_menu_visibility_handler =  g_signal_connect_swapped (gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (window))),
+								       "notify::gtk-shell-shows-app-menu",
+								       G_CALLBACK (ephy_window_toggle_visibility_for_app_menu), window);
+
 	/* ensure the UI is updated */
 	gtk_ui_manager_ensure_update (priv->manager);
 
diff --git a/src/resources/epiphany-ui.xml b/src/resources/epiphany-ui.xml
index c478903..5a2446c 100644
--- a/src/resources/epiphany-ui.xml
+++ b/src/resources/epiphany-ui.xml
@@ -68,6 +68,7 @@
 	</popup>
 
 	<popup name="PagePopup" action="PagePopupAction" accelerators="true">
+                <menuitem name="FileNewWindowMenu" action="FileNewWindow"/>
                 <menuitem name="FileNewTabMenu" action="FileNewTab"/>
                 <menuitem name="FileOpenMenu" action="FileOpen"/>
                 <separator name="FileSep1"/>	
@@ -79,9 +80,11 @@
                 <menuitem name="EditPasteMenu" action="EditPaste"/>
                 <separator name="EditSep3"/> 
                 <menuitem name="FilePrintMenu" action="FilePrint"/>
-                <separator name="FileSep4"/>
                 <menuitem name="EditFindMenu" action="EditFind"/>
+                <menuitem name="EditPreferencesMenu" action="EditPreferences"/>
+                <menuitem name="EditPersonalDataMenu" action="EditPersonalData"/>
                 <separator name="FileSep5"/>
+                <menuitem name="BookmarksEditMenu" action="EditBookmarks"/>
 		<menu name="BookmarksMenu" action="Bookmarks">
 			<menuitem name="BookmarksAddBookmarkMenu" action="FileBookmarkPage"/>
 			<separator name="BookmarksSep1"/>
@@ -93,7 +96,9 @@
                 <menuitem name="ViewPageSourceMenu" action="ViewPageSource"/>
 		<menu name="ExtensionsMenu" action="Extensions"/>
                 <separator name="FileSep7"/>
+                <menuitem name="HelpAboutMenu" action="HelpAbout"/>
                 <menuitem name="FileCloseWindowMenu" action="FileCloseTab"/>
+                <menuitem name="FileQuitMenu" action="FileQuit"/>
 	</popup>
 
 	<accelerator name="AlwaysStopAccel" action="ViewAlwaysStop"/>
diff --git a/src/window-commands.c b/src/window-commands.c
index 4b4fcb2..81ba0f0 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -43,6 +43,7 @@
 #include "ephy-notebook.h"
 #include "ephy-prefs.h"
 #include "ephy-private.h"
+#include "ephy-session.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-state.h"
@@ -718,6 +719,22 @@ window_cmd_file_close_window (GtkAction *action,
 }
 
 void
+window_cmd_file_quit (GtkAction *action,
+		      EphyWindow *window)
+{
+	if (ephy_session_close_all_windows (EPHY_SESSION (ephy_shell_get_session (ephy_shell))))
+		g_application_quit (g_application_get_default ());
+}
+
+void
+window_cmd_file_new_window (GtkAction *action,
+			    EphyWindow *window)
+{
+	ephy_shell_new_tab (ephy_shell, NULL, NULL, NULL,
+			    EPHY_NEW_TAB_IN_NEW_WINDOW | EPHY_NEW_TAB_HOME_PAGE);
+}
+
+void
 window_cmd_edit_undo (GtkAction *action,
 		      EphyWindow *window)
 {
@@ -930,6 +947,52 @@ window_cmd_edit_find_prev (GtkAction *action,
 }
 
 void
+window_cmd_edit_bookmarks (GtkAction *action,
+			   EphyWindow *window)
+{
+	GtkWidget *bwindow;
+	
+	bwindow = ephy_shell_get_bookmarks_editor (ephy_shell);
+	gtk_window_present (GTK_WINDOW (bwindow));
+}
+
+void
+window_cmd_edit_history (GtkAction *action,
+			 EphyWindow *window)
+{
+	GtkWidget *hwindow;
+	
+	hwindow = ephy_shell_get_history_window (ephy_shell);
+	gtk_window_present (GTK_WINDOW (hwindow));
+}
+
+void
+window_cmd_edit_preferences (GtkAction *action,
+			     EphyWindow *window)
+{
+	EphyDialog *dialog;
+	
+	dialog = EPHY_DIALOG (ephy_shell_get_prefs_dialog (ephy_shell));
+	
+	ephy_dialog_show (dialog);
+}
+
+void
+window_cmd_edit_personal_data (GtkAction *action,
+			       EphyWindow *window)
+{
+	PdmDialog *dialog;
+	
+	dialog = EPHY_PDM_DIALOG (ephy_shell_get_pdm_dialog (ephy_shell));
+	/* FIXME?: pdm_dialog_open is supposed to scroll to the host passed
+	 * as second parameters in the cookies tab. Honestly I think this
+	 * has been broken for a while. In any case it's probably not
+	 * relevant here, although we could get the host of the last active
+	 * ephy window, I guess. */
+	pdm_dialog_open (dialog, NULL);
+}
+
+void
 window_cmd_view_fullscreen (GtkAction *action,
 			    EphyWindow *window)
 {
diff --git a/src/window-commands.h b/src/window-commands.h
index 8c1840b..b689bb4 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -100,6 +100,18 @@ void window_cmd_load_location            (GtkAction  *action,
                                           EphyWindow *window);
 void window_cmd_browse_with_caret        (GtkAction  *action,
                                           EphyWindow *window);
+void window_cmd_file_quit                (GtkAction *action,
+                                          EphyWindow *window);
+void window_cmd_edit_bookmarks           (GtkAction *action,
+                                          EphyWindow *window);
+void window_cmd_edit_history             (GtkAction *action,
+                                          EphyWindow *window);
+void window_cmd_file_new_window          (GtkAction *action,
+                                          EphyWindow *window);
+void window_cmd_edit_preferences         (GtkAction *action,
+                                          EphyWindow *window);
+void window_cmd_edit_personal_data       (GtkAction *action,
+                                          EphyWindow *window);
 
 G_END_DECLS
 



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