aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-01-12 02:21:23 +0800
committerXan Lopez <xan@igalia.com>2012-01-14 04:21:46 +0800
commit042f09bcf84db2ade9aa18f881ac5064aacbf116 (patch)
tree00a2a71a94d286561b5773387e1a7a5afc79a4b6 /src
parentade53ab2fdcec609ca42b1277be1f8889bafbaa7 (diff)
downloadgsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar.gz
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar.bz2
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar.lz
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar.xz
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.tar.zst
gsoc2013-epiphany-042f09bcf84db2ade9aa18f881ac5064aacbf116.zip
Drop menubar and create an actions menu button in the toolbar
Similar to Chrome's wrench menu, but used only (in the future) for page-related actions. For now we have mechanically moved most stuff there, now we need to start removing them one by one when appropriate.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bookmarks/ephy-bookmarks-ui.c4
-rw-r--r--src/ephy-encoding-menu.c4
-rw-r--r--src/ephy-page-menu-action.c90
-rw-r--r--src/ephy-page-menu-action.h52
-rw-r--r--src/ephy-window.c72
6 files changed, 170 insertions, 54 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 57267d8d9..d916499be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,7 @@ NOINST_H_FILES = \
ephy-location-action.h \
ephy-navigation-action.h \
ephy-navigation-history-action.h \
+ ephy-page-menu-action.h \
ephy-password-info.h \
languages.h \
pdm-dialog.h \
@@ -65,6 +66,7 @@ libephymain_la_SOURCES = \
ephy-navigation-action.c \
ephy-navigation-history-action.c \
ephy-notebook.c \
+ ephy-page-menu-action.c \
ephy-password-info.c \
ephy-session.c \
ephy-shell.c \
diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c
index 66d675df7..994b32213 100644
--- a/src/bookmarks/ephy-bookmarks-ui.c
+++ b/src/bookmarks/ephy-bookmarks-ui.c
@@ -93,9 +93,9 @@ activate_bookmarks_menu (GtkAction *action, EphyWindow *window)
if (!bookmarks_menu_string->len)
{
g_string_append (bookmarks_menu_string,
- "<ui><menubar><menu name=\"BookmarksMenu\" action=\"Bookmarks\">");
+ "<ui><popup name=\"PagePopup\" action=\"PopupAction\"><menu name=\"BookmarksMenu\" action=\"Bookmarks\">");
ephy_bookmarks_menu_build (bookmarks_menu_string, 0);
- g_string_append (bookmarks_menu_string, "</menu></menubar></ui>");
+ g_string_append (bookmarks_menu_string, "</menu></popup></ui>");
}
data->bookmarks_menu = gtk_ui_manager_add_ui_from_string
diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c
index 7811842d2..4fa7abe82 100644
--- a/src/ephy-encoding-menu.c
+++ b/src/ephy-encoding-menu.c
@@ -51,7 +51,7 @@ struct _EphyEncodingMenuPrivate
EphyEncodingDialog *dialog;
};
-#define ENCODING_PLACEHOLDER_PATH "/menubar/ViewMenu/ViewEncodingMenu/ViewEncodingPlaceholder"
+#define ENCODING_PLACEHOLDER_PATH "/ui/PagePopup/ViewEncodingMenu/ViewEncodingPlaceholder"
static void ephy_encoding_menu_class_init (EphyEncodingMenuClass *klass);
static void ephy_encoding_menu_init (EphyEncodingMenu *menu);
@@ -387,7 +387,7 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
g_object_unref (action_group);
action = gtk_ui_manager_get_action (menu->priv->manager,
- "/menubar/ViewMenu");
+ "/ui/PagePopup/ViewEncodingMenu");
g_signal_connect_object (action, "activate",
G_CALLBACK (update_encoding_menu_cb),
menu, 0);
diff --git a/src/ephy-page-menu-action.c b/src/ephy-page-menu-action.c
new file mode 100644
index 000000000..d5c6592b4
--- /dev/null
+++ b/src/ephy-page-menu-action.c
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2012 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "ephy-page-menu-action.h"
+
+G_DEFINE_TYPE (EphyPageMenuAction, ephy_page_menu_action, EPHY_TYPE_NAVIGATION_ACTION);
+
+static void
+menu_position_func (GtkMenu *menu,
+ int *x,
+ int *y,
+ gboolean *push_in,
+ GtkMenuToolButton *button)
+{
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (button);
+ GtkRequisition menu_req;
+ GtkTextDirection direction;
+ GdkWindow *window;
+
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu),
+ &menu_req, NULL);
+
+ direction = gtk_widget_get_direction (widget);
+ window = gtk_widget_get_window (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gdk_window_get_origin (window, x, y);
+ *x += allocation.x;
+ *y += allocation.y + allocation.height;
+
+ if (direction == GTK_TEXT_DIR_LTR)
+ *x += allocation.width - menu_req.width;
+
+ *push_in = FALSE;
+}
+
+static void
+ephy_page_menu_action_activate (GtkAction *action)
+{
+ GtkWidget *menu;
+ EphyWindow *window;
+ GtkUIManager *manager;
+ GSList *list;
+ GtkWidget *button;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
+ menu = gtk_ui_manager_get_widget (manager, "/PagePopup");
+
+ list = gtk_action_get_proxies (action);
+ if (GTK_IS_TOOL_BUTTON (list->data))
+ button = GTK_WIDGET (list->data);
+
+ gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
+ (GtkMenuPositionFunc)menu_position_func, button,
+ 1, 0);
+}
+
+static void
+ephy_page_menu_action_class_init (EphyPageMenuActionClass *klass)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+
+ action_class->activate = ephy_page_menu_action_activate;
+}
+
+static void
+ephy_page_menu_action_init (EphyPageMenuAction *self)
+{
+}
diff --git a/src/ephy-page-menu-action.h b/src/ephy-page-menu-action.h
new file mode 100644
index 000000000..c7239b655
--- /dev/null
+++ b/src/ephy-page-menu-action.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2012 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __EPHY_PAGE_MENU_ACTION_H__
+#define __EPHY_PAGE_MENU_ACTION_H__
+
+#include "ephy-navigation-action.h"
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_PAGE_MENU_ACTION (ephy_page_menu_action_get_type())
+#define EPHY_PAGE_MENU_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_PAGE_MENU_ACTION, EphyPageMenuAction))
+#define EPHY_PAGE_MENU_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_PAGE_MENU_ACTION, EphyPageMenuActionClass))
+#define EPHY_IS_PAGE_MENU_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_PAGE_MENU_ACTION))
+#define EPHY_IS_PAGE_MENU_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TYPE_PAGE_MENU_ACTION))
+#define EPHY_PAGE_MENU_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_PAGE_MENU_ACTION, EphyPageMenuActionClass))
+
+typedef struct _EphyPageMenuAction EphyPageMenuAction;
+typedef struct _EphyPageMenuActionClass EphyPageMenuActionClass;
+
+struct _EphyPageMenuActionClass {
+ EphyNavigationActionClass parent_class;
+};
+
+struct _EphyPageMenuAction {
+ EphyNavigationAction parent_instance;
+};
+
+GType ephy_page_menu_action_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __EPHY_PAGE_MENU_ACTION_H__ */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0b0005f7d..fe27a9b10 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -48,6 +48,7 @@
#include "ephy-navigation-action.h"
#include "ephy-navigation-history-action.h"
#include "ephy-notebook.h"
+#include "ephy-page-menu-action.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
@@ -111,6 +112,7 @@ static const GtkActionEntry ephy_menu_entries [] = {
{ "Tools", NULL, N_("T_ools") },
{ "Toolbar", NULL, N_("_Toolbars") },
{ "PopupAction", NULL, "" },
+ { "PagePopupAction", NULL, "" },
{ "NotebookPopupAction", NULL, "" },
/* File menu */
@@ -774,7 +776,6 @@ static void
sync_chromes_visibility (EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
- GtkWidget *menubar;
gboolean show_menubar, show_toolbar, show_tabsbar;
if (priv->closing) return;
@@ -783,10 +784,6 @@ sync_chromes_visibility (EphyWindow *window)
&show_toolbar,
&show_tabsbar);
- menubar = gtk_ui_manager_get_widget (window->priv->manager, "/menubar");
- g_assert (menubar != NULL);
-
- g_object_set (menubar, "visible", show_menubar, NULL);
g_object_set (priv->toolbar, "visible", show_toolbar, NULL);
ephy_notebook_set_show_tabs (EPHY_NOTEBOOK (priv->notebook), show_tabsbar);
@@ -860,18 +857,6 @@ ephy_window_unfullscreen (EphyWindow *window)
sync_chromes_visibility (window);
}
-static void
-menubar_deactivate_cb (GtkWidget *menubar,
- EphyWindow *window)
-{
- g_signal_handlers_disconnect_by_func
- (menubar, G_CALLBACK (menubar_deactivate_cb), window);
-
- gtk_menu_shell_deselect (GTK_MENU_SHELL (menubar));
-
- sync_chromes_visibility (window);
-}
-
static gboolean
scroll_event_cb (GtkWidget *widget,
GdkEventScroll *event,
@@ -896,7 +881,7 @@ ephy_window_key_press_event (GtkWidget *widget,
{
EphyWindow *window = EPHY_WINDOW (widget);
EphyWindowPrivate *priv = window->priv;
- GtkWidget *menubar, *focus_widget;
+ GtkWidget *focus_widget;
gboolean shortcircuit = FALSE, force_chain = FALSE, handled = FALSE;
guint modifier = event->state & gtk_accelerator_get_default_mod_mask ();
guint i;
@@ -978,26 +963,6 @@ ephy_window_key_press_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
- /* Show and activate the menubar, if it isn't visible */
- if (priv->menubar_accel_keyval != 0 &&
- event->keyval == priv->menubar_accel_keyval &&
- modifier == priv->menubar_accel_modifier)
- {
- menubar = gtk_ui_manager_get_widget (window->priv->manager, "/menubar");
- g_return_val_if_fail (menubar != NULL , FALSE);
-
- if (!gtk_widget_get_visible (menubar))
- {
- g_signal_connect (menubar, "deactivate",
- G_CALLBACK (menubar_deactivate_cb), window);
-
- gtk_widget_show (menubar);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menubar), FALSE);
-
- return TRUE;
- }
- }
-
return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
@@ -1290,31 +1255,30 @@ enable_edit_actions_sensitivity (EphyWindow *window)
static void
edit_menu_show_cb (GtkWidget *menu,
- EphyWindow *window)
+ EphyWindow *window)
{
- update_edit_actions_sensitivity (window, FALSE);
+ update_edit_actions_sensitivity (window, FALSE);
}
static void
edit_menu_hide_cb (GtkWidget *menu,
- EphyWindow *window)
+ EphyWindow *window)
{
- enable_edit_actions_sensitivity (window);
+ enable_edit_actions_sensitivity (window);
}
static void
init_menu_updaters (EphyWindow *window)
{
- GtkWidget *edit_menu_item, *edit_menu;
+ GtkWidget *edit_menu;
- edit_menu_item = gtk_ui_manager_get_widget
- (window->priv->manager, "/menubar/EditMenu");
- edit_menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (edit_menu_item));
+ edit_menu = gtk_ui_manager_get_widget
+ (window->priv->manager, "/ui/PagePopup");
- g_signal_connect (edit_menu, "show",
- G_CALLBACK (edit_menu_show_cb), window);
- g_signal_connect (edit_menu, "hide",
- G_CALLBACK (edit_menu_hide_cb), window);
+ g_signal_connect (edit_menu, "show",
+ G_CALLBACK (edit_menu_show_cb), window);
+ g_signal_connect (edit_menu, "hide",
+ G_CALLBACK (edit_menu_hide_cb), window);
}
static EphyWebView*
@@ -1627,6 +1591,14 @@ setup_ui_manager (EphyWindow *window)
gtk_action_group_add_action (action_group, action);
g_object_unref (action);
+ action = g_object_new (EPHY_TYPE_PAGE_MENU_ACTION,
+ "name", "PageMenu",
+ "icon-name", "send-to-symbolic",
+ "window", window,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, "<alt>E");
+ g_object_unref (action);
+
gtk_ui_manager_insert_action_group (manager, action_group, 0);
window->priv->toolbar_action_group = action_group;
g_object_unref (action_group);