diff options
author | Xan Lopez <xan@igalia.com> | 2012-01-11 00:02:10 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-01-14 04:21:46 +0800 |
commit | ade53ab2fdcec609ca42b1277be1f8889bafbaa7 (patch) | |
tree | ea7bc39e9989e9b406cdd1cd2655d2522a7d02b6 /src | |
parent | fdf4c638525301e2bd45fe1d6851830e826b1b9a (diff) | |
download | gsoc2013-epiphany-ade53ab2fdcec609ca42b1277be1f8889bafbaa7.tar.gz gsoc2013-epiphany-ade53ab2fdcec609ca42b1277be1f8889bafbaa7.tar.zst gsoc2013-epiphany-ade53ab2fdcec609ca42b1277be1f8889bafbaa7.zip |
Use the new Shell global menu for global actions
And remove them from the existing menubar.
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-lockdown.c | 4 | ||||
-rw-r--r-- | src/ephy-shell.c | 148 | ||||
-rw-r--r-- | src/ephy-window.c | 51 | ||||
-rw-r--r-- | src/ephy-window.h | 4 | ||||
-rw-r--r-- | src/window-commands.c | 67 | ||||
-rw-r--r-- | src/window-commands.h | 15 |
6 files changed, 140 insertions, 149 deletions
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c index e94659872..73d9741ec 100644 --- a/src/ephy-lockdown.c +++ b/src/ephy-lockdown.c @@ -108,12 +108,10 @@ static const BindAction window_actions[] = { { EPHY_PREFS_LOCKDOWN_PRINT_SETUP, "FilePrintSetup", "sensitive" }, { EPHY_PREFS_LOCKDOWN_COMMAND_LINE, "FilePrintSetup", "sensitive" }, - { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "GoBookmarks", "sensitive" }, { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "FileBookmarkPage", "sensitive" }, { EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "GoLocation", "sensitive" }, { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "FileSaveAs", "sensitive" }, - { EPHY_PREFS_LOCKDOWN_HISTORY, "GoHistory", "sensitive" }, { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "ViewFullscreen", "sensitive" }, { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "TabsDetach", "sensitive" } @@ -134,8 +132,6 @@ static const BindAction special_toolbar_actions[] = { { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "sensitive" }, { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "visible" }, { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "sensitive" }, - - { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "FileNewWindow", "sensitive" } }; static gboolean diff --git a/src/ephy-shell.c b/src/ephy-shell.c index c9eee946b..40d2f7286 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -34,6 +34,7 @@ #include "ephy-file-helpers.h" #include "ephy-gui.h" #include "ephy-history-window.h" +#include "ephy-home-action.h" #include "ephy-lockdown.h" #include "ephy-prefs.h" #include "ephy-profile-utils.h" @@ -44,6 +45,7 @@ #include "ephy-window.h" #include "pdm-dialog.h" #include "prefs-dialog.h" +#include "window-commands.h" #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -160,6 +162,111 @@ queue_commands (EphyShell *shell) } static void +new_window (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + ephy_shell_new_tab (ephy_shell, NULL, NULL, NULL, + EPHY_NEW_TAB_IN_NEW_WINDOW); +} + +static void +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)); +} + +static void +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)); +} + +static void +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); +} + +static void +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); +} + +static void +show_about (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + window_cmd_help_about (NULL, NULL); +} + +static void +show_help (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + ephy_gui_help (NULL, NULL); +} + +static void +quit_application (GSimpleAction *action, + GVariant *parameter, + gpointer user_data) +{ + GList *list, *next; + GtkWindow *win; + + list = gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ())); + while (list) { + win = list->data; + next = list->next; + + gtk_widget_destroy (GTK_WIDGET (win)); + + list = next; + } +} + +static GActionEntry app_entries[] = { + { "new", new_window, NULL, NULL, NULL }, + { "bookmarks", show_bookmarks, NULL, NULL, NULL }, + { "history", show_history, NULL, NULL, NULL }, + { "preferences", show_preferences, NULL, NULL, NULL }, + { "pdm", show_pdm, NULL, NULL, NULL }, + { "help", show_help, NULL, NULL, NULL }, + { "about", show_about, NULL, NULL, NULL }, + { "quit", quit_application, NULL, NULL, NULL }, +}; + +static void ephy_shell_startup (GApplication* application) { G_APPLICATION_CLASS (ephy_shell_parent_class)->startup (application); @@ -167,20 +274,35 @@ ephy_shell_startup (GApplication* application) /* We're not remoting; start our services */ /* Migrate profile if we are not running a private instance */ /* TODO: we want to migrate each WebApp profile too */ - if (ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (application)) == EPHY_EMBED_SHELL_MODE_BROWSER && - ephy_profile_utils_get_migration_version () < EPHY_PROFILE_MIGRATION_VERSION) { - GError *error = NULL; - char *argv[1] = { "ephy-profile-migrator" }; - char *envp[1] = { "EPHY_LOG_MODULES=ephy-profile" }; - - g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH, - NULL, NULL, NULL, NULL, - NULL, &error); - - if (error) { - LOG ("Failed to run migrator: %s", error->message); - g_error_free (error); + if (ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (application)) == EPHY_EMBED_SHELL_MODE_BROWSER) { + GtkBuilder *builder; + + if (ephy_profile_utils_get_migration_version () < EPHY_PROFILE_MIGRATION_VERSION) { + GError *error = NULL; + char *argv[1] = { "ephy-profile-migrator" }; + char *envp[1] = { "EPHY_LOG_MODULES=ephy-profile" }; + + g_spawn_sync (NULL, argv, envp, G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, NULL, + NULL, &error); + + if (error) { + LOG ("Failed to run migrator: %s", error->message); + g_error_free (error); + } } + + g_action_map_add_action_entries (G_ACTION_MAP (application), + app_entries, G_N_ELEMENTS (app_entries), + application); + + builder = gtk_builder_new (); + gtk_builder_add_from_file (builder, + ephy_file ("epiphany-application-menu.ui"), + NULL); + gtk_application_set_app_menu (GTK_APPLICATION (application), + G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"))); + g_object_unref (builder); } } diff --git a/src/ephy-window.c b/src/ephy-window.c index 3b711aaa0..0b0005f7d 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -109,7 +109,6 @@ static const GtkActionEntry ephy_menu_entries [] = { { "View", NULL, N_("_View") }, { "Bookmarks", NULL, N_("_Bookmarks") }, { "Tools", NULL, N_("T_ools") }, - { "Help", NULL, N_("_Help") }, { "Toolbar", NULL, N_("_Toolbars") }, { "PopupAction", NULL, "" }, { "NotebookPopupAction", NULL, "" }, @@ -173,12 +172,6 @@ static const GtkActionEntry ephy_menu_entries [] = { { "EditFindPrev", NULL, N_("Find Pre_vious"), "<shift><control>G", N_("Find previous occurrence of the word or phrase"), G_CALLBACK (window_cmd_edit_find_prev) }, - { "EditPersonalData", NULL, N_("P_ersonal Data"), NULL, - N_("View and remove cookies and passwords"), - G_CALLBACK (window_cmd_edit_personal_data) }, - { "EditPrefs", GTK_STOCK_PREFERENCES, N_("P_references"), NULL, - N_("Configure the web browser"), - G_CALLBACK (window_cmd_edit_prefs) }, /* View menu */ @@ -214,18 +207,12 @@ static const GtkActionEntry ephy_menu_entries [] = { { "FileBookmarkPage", STOCK_ADD_BOOKMARK, N_("_Add Bookmark…"), "<control>D", N_("Add a bookmark for the current page"), G_CALLBACK (window_cmd_file_bookmark_page) }, - { "GoBookmarks", EPHY_STOCK_BOOKMARKS, N_("_Edit Bookmarks"), "<control>B", - N_("Open the bookmarks window"), - G_CALLBACK (window_cmd_go_bookmarks) }, /* Go menu */ { "GoLocation", NULL, N_("_Location…"), "<control>L", N_("Go to a specified location"), G_CALLBACK (window_cmd_go_location) }, - { "GoHistory", EPHY_STOCK_HISTORY, N_("Hi_story"), "<control>H", - N_("Open the history window"), - G_CALLBACK (window_cmd_go_history) }, /* Tabs menu */ @@ -244,15 +231,6 @@ static const GtkActionEntry ephy_menu_entries [] = { { "TabsDetach", NULL, N_("_Detach Tab"), NULL, N_("Detach current tab"), G_CALLBACK (window_cmd_tabs_detach) }, - - /* Help menu */ - - {"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1", - N_("Display web browser help"), - G_CALLBACK (window_cmd_help_contents) }, - { "HelpAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, - N_("Display credits for the web browser creators"), - G_CALLBACK (window_cmd_help_about) }, }; static const GtkToggleActionEntry ephy_menu_toggle_entries [] = @@ -373,7 +351,6 @@ static const struct GDK_SHIFT_MASK, "TabsMoveRight", FALSE }, /* Go */ { GDK_KEY_l, GDK_CONTROL_MASK, "GoLocation", FALSE }, - { GDK_KEY_h, GDK_CONTROL_MASK, "GoHistory", FALSE }, /* Support all the MSIE tricks as well ;) */ { GDK_KEY_F5, 0, "ViewReload", FALSE }, { GDK_KEY_F5, GDK_CONTROL_MASK, "ViewReload", FALSE }, @@ -403,10 +380,8 @@ static const struct { GDK_KEY_KP_3, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "TabsMoveRight", FALSE }, #ifdef HAVE_X11_XF86KEYSYM_H { XF86XK_Back, 0, "NavigationBack", TRUE }, - { XF86XK_Favorites, 0, "GoBookmarks", FALSE }, { XF86XK_Forward, 0, "NavigationForward", TRUE }, { XF86XK_Go, 0, "GoLocation", FALSE }, - { XF86XK_History, 0, "GoHistory", FALSE }, { XF86XK_OpenURL, 0, "GoLocation", FALSE }, { XF86XK_AddFavorite, 0, "FileBookmarkPage", FALSE }, { XF86XK_Refresh, 0, "ViewReload", FALSE }, @@ -655,7 +630,7 @@ ephy_window_link_iface_init (EphyLinkIface *iface) iface->open_link = ephy_window_open_link; } -G_DEFINE_TYPE_WITH_CODE (EphyWindow, ephy_window, GTK_TYPE_WINDOW, +G_DEFINE_TYPE_WITH_CODE (EphyWindow, ephy_window, GTK_TYPE_APPLICATION_WINDOW, G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK, ephy_window_link_iface_init) G_IMPLEMENT_INTERFACE (EPHY_TYPE_EMBED_CONTAINER, @@ -1560,13 +1535,9 @@ setup_ui_manager (EphyWindow *window) g_object_set (action, "short_label", _("Bookmark"), NULL); action = gtk_action_group_get_action (action_group, "EditFind"); g_object_set (action, "short_label", _("Find"), NULL); - action = gtk_action_group_get_action (action_group, "GoBookmarks"); - g_object_set (action, "short_label", _("Bookmarks"), NULL); action = gtk_action_group_get_action (action_group, "EditFind"); g_object_set (action, "is_important", TRUE, NULL); - action = gtk_action_group_get_action (action_group, "GoBookmarks"); - g_object_set (action, "is_important", TRUE, NULL); action = gtk_action_group_get_action (action_group, "ViewEncoding"); g_object_set (action, "hide_if_empty", FALSE, NULL); @@ -1648,15 +1619,6 @@ setup_ui_manager (EphyWindow *window) g_object_unref (action); - action = g_object_new (EPHY_TYPE_HOME_ACTION, - "name", "FileNewWindow", - "label", _("_New Window"), - "stock_id", STOCK_NEW_WINDOW, - "tooltip", _("Open a new window"), - NULL); - gtk_action_group_add_action_with_accel (action_group, action, "<control>N"); - g_object_unref (action); - action = g_object_new (EPHY_TYPE_COMBINED_STOP_RELOAD_ACTION, "name", "ViewCombinedStopReload", "loading", FALSE, @@ -3725,10 +3687,6 @@ setup_toolbar (EphyWindow *window) "FileNewTab"); g_signal_connect_swapped (action, "open-link", G_CALLBACK (ephy_link_open), window); - action = gtk_action_group_get_action (priv->toolbar_action_group, - "FileNewWindow"); - g_signal_connect_swapped (action, "open-link", - G_CALLBACK (ephy_link_open), window); action = gtk_action_group_get_action (priv->toolbar_action_group, "Zoom"); @@ -3742,8 +3700,7 @@ static const char* disabled_actions_for_app_mode[] = { "FileOpen", "FileSaveAs", "FileSaveAsApplication", "ViewEncoding", - "FileBookmarkPage", - "GoBookmarks" }; + "FileBookmarkPage" }; static GObject * ephy_window_constructor (GType type, @@ -3903,10 +3860,6 @@ ephy_window_constructor (GType type, ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, TRUE); - action = gtk_action_group_get_action (toolbar_action_group, "FileNewWindow"); - ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME, - TRUE); - for (i = 0; i < G_N_ELEMENTS (disabled_actions_for_app_mode); i++) { action = gtk_action_group_get_action (priv->action_group, diff --git a/src/ephy-window.h b/src/ephy-window.h index 40c1d8d2a..c0f6747de 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -45,7 +45,7 @@ typedef struct _EphyWindowPrivate EphyWindowPrivate; struct _EphyWindow { - GtkWindow parent; + GtkApplicationWindow parent; /*< private >*/ EphyWindowPrivate *priv; @@ -53,7 +53,7 @@ struct _EphyWindow struct _EphyWindowClass { - GtkWindowClass parent_class; + GtkApplicationWindowClass parent_class; }; GType ephy_window_get_type (void); diff --git a/src/window-commands.c b/src/window-commands.c index f39d71c72..8e7ded6c7 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -227,18 +227,6 @@ window_cmd_view_reload (GtkAction *action, } void -window_cmd_go_bookmarks (GtkAction *action, - EphyWindow *window) -{ - GtkWidget *bwindow; - - bwindow = ephy_shell_get_bookmarks_editor (ephy_shell); - ephy_bookmarks_editor_set_parent (EPHY_BOOKMARKS_EDITOR (bwindow), - GTK_WIDGET (window)); - gtk_window_present (GTK_WINDOW (bwindow)); -} - -void window_cmd_file_bookmark_page (GtkAction *action, EphyWindow *window) { @@ -1163,59 +1151,6 @@ window_cmd_view_page_security_info (GtkAction *action, ephy_web_view_show_page_certificate (ephy_embed_get_web_view (embed)); } -void -window_cmd_go_history (GtkAction *action, - EphyWindow *window) -{ - GtkWidget *hwindow; - - hwindow = ephy_shell_get_history_window (ephy_shell); - ephy_history_window_set_parent (EPHY_HISTORY_WINDOW (hwindow), - GTK_WIDGET (window)); - gtk_window_present (GTK_WINDOW (hwindow)); -} - -void -window_cmd_edit_personal_data (GtkAction *action, - EphyWindow *window) -{ - PdmDialog *dialog; - EphyEmbed *embed; - const char *address; - char *host; - - embed = ephy_embed_container_get_active_child - (EPHY_EMBED_CONTAINER (window)); - if (embed == NULL) return; - - address = ephy_web_view_get_address (ephy_embed_get_web_view (embed)); - - host = address != NULL ? ephy_string_get_host_name (address) : NULL; - - dialog = EPHY_PDM_DIALOG (ephy_shell_get_pdm_dialog (ephy_shell)); - pdm_dialog_open (dialog, host); - - g_free (host); -} - -void -window_cmd_edit_prefs (GtkAction *action, - EphyWindow *window) -{ - EphyDialog *dialog; - - dialog = EPHY_DIALOG (ephy_shell_get_prefs_dialog (ephy_shell)); - - ephy_dialog_show (dialog); -} - -void -window_cmd_help_contents (GtkAction *action, - EphyWindow *window) -{ - ephy_gui_help (GTK_WIDGET (window), NULL); -} - #define ABOUT_GROUP "About" void @@ -1325,7 +1260,7 @@ window_cmd_help_about (GtkAction *action, _(licence_part[2]), NULL); - gtk_show_about_dialog (GTK_WINDOW (window), + gtk_show_about_dialog (window ? GTK_WINDOW (window) : NULL, "program-name", _("GNOME Web Browser"), "version", VERSION, "copyright", "Copyright © 2002–2004 Marco Pesenti Gritti\n" diff --git a/src/window-commands.h b/src/window-commands.h index 1261fa41f..e9ee7197f 100644 --- a/src/window-commands.h +++ b/src/window-commands.h @@ -45,9 +45,6 @@ void window_cmd_new (GtkAction *action, void window_cmd_file_bookmark_page(GtkAction *action, EphyWindow *window); -void window_cmd_go_bookmarks (GtkAction *action, - EphyWindow *window); - void window_cmd_file_open (GtkAction *action, EphyWindow *window); @@ -120,21 +117,9 @@ void window_cmd_view_page_source(GtkAction *action, void window_cmd_view_page_security_info (GtkAction *action, EphyWindow *window); -void window_cmd_go_history (GtkAction *action, - EphyWindow *window); - -void window_cmd_edit_personal_data (GtkAction *action, - EphyWindow *window); - -void window_cmd_edit_prefs (GtkAction *action, - EphyWindow *window); - void window_cmd_edit_toolbar (GtkAction *action, EphyWindow *window); -void window_cmd_help_contents (GtkAction *action, - EphyWindow *window); - void window_cmd_help_about (GtkAction *action, GtkWidget *window); |