aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2011-12-13 23:45:10 +0800
committerXan Lopez <xan@igalia.com>2011-12-14 23:30:21 +0800
commitc1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9 (patch)
tree407b07bc318b263f518747ece8e668b933f9ed04 /src
parent1ce161d56a3db3c436e5fbf888472c1f864cebb8 (diff)
downloadgsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar.gz
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar.bz2
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar.lz
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar.xz
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.tar.zst
gsoc2013-epiphany-c1c74c929c1e773d1f79d1b3bd0cf10bb572f8f9.zip
Remove custom EphyToolbar in favor of a vanilla GtkToolbar
This allows us to stop using EggEditableToolbar here, we just load a normal toolbar from GtkUIManager in EphyWindow. The special toolbar actions and methods have been moved to EphyWindow too, mostly in a mechanical fashion (probably some simplifications are possible). The code in the bookmarks UI that depended on EphyToolbar has been #if zeroed instead of porting it, since it will go away in the near future too. https://bugzilla.gnome.org/show_bug.cgi?id=664483
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/bookmarks/ephy-bookmarks-ui.c12
-rw-r--r--src/ephy-lockdown.c5
-rw-r--r--src/ephy-shell.c9
-rw-r--r--src/ephy-toolbar.c765
-rw-r--r--src/ephy-toolbar.h106
-rw-r--r--src/ephy-window.c504
-rw-r--r--src/ephy-window.h4
-rw-r--r--src/window-commands.c5
9 files changed, 459 insertions, 955 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 97418adb0..84b707883 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,6 @@ NOINST_H_FILES = \
ephy-navigation-up-action.h \
ephy-password-info.h \
ephy-toolbars-model.h \
- ephy-toolbar.h \
languages.h \
pdm-dialog.h \
popup-commands.h \
@@ -73,7 +72,6 @@ libephymain_la_SOURCES = \
ephy-session.c \
ephy-shell.c \
ephy-toolbars-model.c \
- ephy-toolbar.c \
ephy-window.c \
pdm-dialog.c \
popup-commands.c \
@@ -243,7 +241,6 @@ EPHY_GIR_H_FILES = \
$(top_srcdir)/src/ephy-notebook.h \
$(top_srcdir)/src/ephy-session.h \
$(top_srcdir)/src/ephy-shell.h \
- $(top_srcdir)/src/ephy-toolbar.h \
$(top_srcdir)/src/ephy-window.h \
$(NULL)
@@ -274,7 +271,6 @@ EPHY_GIR_C_FILES = \
$(top_srcdir)/src/ephy-notebook.c \
$(top_srcdir)/src/ephy-session.c \
$(top_srcdir)/src/ephy-shell.c \
- $(top_srcdir)/src/ephy-toolbar.c \
$(top_srcdir)/src/ephy-window.c \
$(NULL)
diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c
index 1f97eddb3..7ce3a0d0b 100644
--- a/src/bookmarks/ephy-bookmarks-ui.c
+++ b/src/bookmarks/ephy-bookmarks-ui.c
@@ -108,6 +108,7 @@ activate_bookmarks_menu (GtkAction *action, EphyWindow *window)
}
}
+#if 0
static void
activate_bookmark_properties (GtkAction *action,
EggEditableToolbar *etoolbar)
@@ -177,6 +178,7 @@ selected_bookmark_action (EggEditableToolbar *etoolbar,
gtk_action_set_visible (action, visible);
}
+#endif
static void
erase_bookmarks_menu (EphyWindow *window)
@@ -241,7 +243,9 @@ ephy_bookmarks_ui_attach_window (EphyWindow *window)
EphyNode *topics;
BookmarksWindowData *data;
GtkUIManager *manager;
+#if 0
EggEditableToolbar *etoolbar;
+#endif
GtkActionGroup *actions;
GtkAction *action;
@@ -252,7 +256,9 @@ ephy_bookmarks_ui_attach_window (EphyWindow *window)
g_return_if_fail (data == NULL);
manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
+#if 0
etoolbar = EGG_EDITABLE_TOOLBAR (ephy_window_get_toolbar (window));
+#endif
data = g_new0 (BookmarksWindowData, 1);
g_object_set_data_full (G_OBJECT (window), BM_WINDOW_DATA_KEY, data, g_free);
@@ -298,36 +304,42 @@ ephy_bookmarks_ui_attach_window (EphyWindow *window)
/* Add popup menu actions that are specific to the bookmark widgets */
action = gtk_action_new ("ToolbarBookmarkProperties", _("_Properties"),
_("Show properties for this bookmark"), GTK_STOCK_PROPERTIES);
+#if 0
g_signal_connect_object (action, "activate",
G_CALLBACK (activate_bookmark_properties),
G_OBJECT (etoolbar), 0);
g_signal_connect_object (etoolbar, "notify::selected",
G_CALLBACK (selected_bookmark_action),
G_OBJECT (action), 0);
+#endif
gtk_action_group_add_action (actions, action);
g_object_unref (action);
/* FIXME ngettext */
action = gtk_action_new ("ToolbarBookmarkOpenInTab", _("Open in New _Tab"),
_("Open this bookmark in a new tab"), STOCK_NEW_TAB);
+#if 0
g_signal_connect_object (action, "activate",
G_CALLBACK (activate_bookmark_open_tab),
G_OBJECT (etoolbar), 0);
g_signal_connect_object (etoolbar, "notify::selected",
G_CALLBACK (selected_bookmark_action),
G_OBJECT (action), 0);
+#endif
gtk_action_group_add_action (actions, action);
g_object_unref (action);
/* FIXME ngettext */
action = gtk_action_new ("ToolbarBookmarkOpenInWindow", _("Open in New _Window"),
_("Open this bookmark in a new window"), GTK_STOCK_NEW);
+#if 0
g_signal_connect_object (action, "activate",
G_CALLBACK (activate_bookmark_open_window),
G_OBJECT (etoolbar), 0);
g_signal_connect_object (etoolbar, "notify::selected",
G_CALLBACK (selected_bookmark_action),
G_OBJECT (action), 0);
+#endif
gtk_action_group_add_action (actions, action);
g_object_unref (action);
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 54eb58a29..801b08ad1 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -30,7 +30,6 @@
#include "ephy-lockdown.h"
#include "ephy-extension.h"
#include "ephy-settings.h"
-#include "ephy-toolbar.h"
#include "ephy-prefs.h"
#include "ephy-debug.h"
@@ -68,7 +67,6 @@ arbitrary_url_cb (GSettings *settings,
EphyWindow *window)
{
EphyEmbed *embed;
- GtkWidget *toolbar;
char *address;
/* Restore the real web page address when disabling entry */
@@ -79,9 +77,8 @@ arbitrary_url_cb (GSettings *settings,
if (embed == NULL)
return;
- toolbar = ephy_window_get_toolbar (window);
address = ephy_web_view_get_location (ephy_embed_get_web_view (embed), TRUE);
- ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address);
+ ephy_window_set_location (window, address);
ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
g_free (address);
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 6643e90e2..664ffc1d9 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -41,7 +41,6 @@
#include "ephy-profile-utils.h"
#include "ephy-session.h"
#include "ephy-settings.h"
-#include "ephy-toolbar.h"
#include "ephy-toolbars-model.h"
#include "ephy-type-builtins.h"
#include "ephy-web-view.h"
@@ -631,7 +630,6 @@ ephy_shell_new_tab_full (EphyShell *shell,
GtkWidget *nb;
int position = -1;
gboolean is_empty = FALSE;
- EphyToolbar *toolbar;
if (flags & EPHY_NEW_TAB_OPEN_PAGE) open_page = TRUE;
if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE;
@@ -655,8 +653,6 @@ ephy_shell_new_tab_full (EphyShell *shell,
window = ephy_window_new_with_chrome (chrome, is_popup);
}
- toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));
-
if ((flags & EPHY_NEW_TAB_APPEND_AFTER) && previous_embed != NULL) {
nb = ephy_window_get_notebook (window);
/* FIXME this assumes the tab is the direct notebook child */
@@ -703,7 +699,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
flags & EPHY_NEW_TAB_NEW_PAGE) {
EphyWebView *view = ephy_embed_get_web_view (embed);
ephy_web_view_set_typed_address (view, "");
- ephy_toolbar_activate_location (toolbar);
+ ephy_window_activate_location (window);
ephy_web_view_load_homepage (view);
is_empty = TRUE;
} else if (flags & EPHY_NEW_TAB_OPEN_PAGE) {
@@ -721,8 +717,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
* page was a copy */
if (is_empty) {
/* empty page, focus location entry */
- toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));
- ephy_toolbar_activate_location (toolbar);
+ ephy_window_activate_location (window);
} else if (embed != NULL) {
/* non-empty page, focus the page. but make sure the widget is realised first! */
gtk_widget_realize (GTK_WIDGET (embed));
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
deleted file mode 100644
index 21f4bdf06..000000000
--- a/src/ephy-toolbar.c
+++ /dev/null
@@ -1,765 +0,0 @@
-/*
- * Copyright © 2000-2004 Marco Pesenti Gritti
- * Copyright © 2001, 2002 Jorn Baayen
- * Copyright © 2003, 2004, 2005 Christian Persch
- *
- * 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-toolbar.h"
-
-#include "ephy-action-helper.h"
-#include "ephy-debug.h"
-#include "ephy-dnd.h"
-#include "ephy-embed-container.h"
-#include "ephy-embed-utils.h"
-#include "ephy-go-action.h"
-#include "ephy-home-action.h"
-#include "ephy-link.h"
-#include "ephy-location-action.h"
-#include "ephy-location-entry.h"
-#include "ephy-navigation-action.h"
-#include "ephy-navigation-history-action.h"
-#include "ephy-navigation-up-action.h"
-#include "ephy-shell.h"
-#include "ephy-stock-icons.h"
-#include "ephy-topic-action.h"
-#include "ephy-zoom-action.h"
-#include "window-commands.h"
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <string.h>
-
-/**
- * SECTION:ephy-toolbar
- * @short_description: Epiphany's toolbar widget
- *
- * #EphyToolbar is a customized #EggEditableToolbar.
- */
-
-enum
-{
- BACK_ACTION,
- FORWARD_ACTION,
- UP_ACTION,
- LOCATION_ACTION,
- ZOOM_ACTION,
- LAST_ACTION
-};
-
-#define EPHY_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOOLBAR, EphyToolbarPrivate))
-
-struct _EphyToolbarPrivate
-{
- EphyWindow *window;
- GtkActionGroup *action_group;
- GtkAction *actions[LAST_ACTION];
- GtkWidget *fixed_toolbar;
- GtkToolItem *sep_item;
- GtkToolItem *exit_button;
- gulong set_focus_handler;
-
- guint updating_address : 1;
- guint show_lock : 1;
- guint leave_fullscreen_visible : 1;
- guint spinning : 1;
-};
-
-static const GtkTargetEntry drag_targets [] =
-{
- { EGG_TOOLBAR_ITEM_TYPE, GTK_TARGET_SAME_APP, 0 },
- { EPHY_DND_TOPIC_TYPE, 0, 1 },
- { EPHY_DND_URL_TYPE, 0, 2 }
-};
-
-enum
-{
- PROP_0,
- PROP_WINDOW
-};
-
-enum
-{
- ACTIVATION_FINISHED,
- EXIT_CLICKED,
- LOCK_CLICKED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-static void
-ephy_toolbar_iface_init (EphyLinkIface *iface)
-{
-}
-
-G_DEFINE_TYPE_WITH_CODE (EphyToolbar, ephy_toolbar, EGG_TYPE_EDITABLE_TOOLBAR,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
- ephy_toolbar_iface_init))
-
-/* helper functions */
-
-static void
-exit_button_clicked_cb (GtkWidget *button,
- EphyToolbar *toolbar)
-{
- g_signal_emit (toolbar, signals[EXIT_CLICKED], 0);
-}
-
-static void
-ephy_toolbar_update_fixed_visibility (EphyToolbar *toolbar)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- gboolean show;
-
- show = priv->leave_fullscreen_visible;
- g_object_set (priv->sep_item, "visible", show, NULL);
- g_object_set (priv->exit_button, "visible", show, NULL);
- g_object_set (priv->fixed_toolbar, "visible", show, NULL);
-}
-
-static void
-maybe_finish_activation_cb (EphyWindow *window,
- GtkWidget *widget,
- EphyToolbar *toolbar)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- GtkWidget *wtoolbar = GTK_WIDGET (toolbar);
-
- while (widget != NULL && widget != wtoolbar)
- {
- widget = gtk_widget_get_parent (widget);
- }
-
- /* if widget == toolbar, the new focus widget is in the toolbar, so we
- * don't deactivate.
- */
- if (widget != wtoolbar)
- {
- g_signal_handler_disconnect (window, priv->set_focus_handler);
- toolbar->priv->set_focus_handler = 0;
-
- g_signal_emit (toolbar, signals[ACTIVATION_FINISHED], 0);
- }
-}
-
-static void
-sync_user_input_cb (EphyLocationAction *action,
- GParamSpec *pspec,
- EphyToolbar *toolbar)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- EphyEmbed *embed;
- const char *address;
-
- LOG ("sync_user_input_cb");
-
- if (priv->updating_address) return;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->window));
- g_assert (EPHY_IS_EMBED (embed));
-
- address = ephy_location_action_get_address (action);
-
- priv->updating_address = TRUE;
- ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), address);
- priv->updating_address = FALSE;
-}
-
-static void
-lock_clicked_cb (EphyLocationAction *action,
- EphyToolbar *toolbar)
-{
- g_signal_emit (toolbar, signals[LOCK_CLICKED], 0);
-}
-
-static void
-zoom_to_level_cb (GtkAction *action,
- float zoom,
- EphyToolbar *toolbar)
-{
- ephy_window_set_zoom (toolbar->priv->window, zoom);
-}
-
-static void
-ephy_toolbar_set_window (EphyToolbar *toolbar,
- EphyWindow *window)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- GtkUIManager *manager;
- GtkAction *action;
-
- priv->window = window;
- manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
-
- priv->action_group = gtk_action_group_new ("SpecialToolbarActions");
- gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
- g_object_unref (priv->action_group);
-
- action = priv->actions[BACK_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
- "name", "NavigationBack",
- "label", _("_Back"),
- "stock_id", GTK_STOCK_GO_BACK,
- "tooltip", _("Go to the previous visited page"),
- "window", priv->window,
- "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
- "is_important", TRUE,
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
- gtk_action_group_add_action_with_accel (priv->action_group, action,
- "<alt>Left");
- g_object_unref (action);
-
- action = priv->actions[FORWARD_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
- "name", "NavigationForward",
- "label", _("_Forward"),
- "stock_id", GTK_STOCK_GO_FORWARD,
- "tooltip", _("Go to the next visited page"),
- "window", priv->window,
- "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD,
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
- gtk_action_group_add_action_with_accel (priv->action_group, action,
- "<alt>Right");
- g_object_unref (action);
-
- action = priv->actions[UP_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_UP_ACTION,
- "name", "NavigationUp",
- "label", _("_Up"),
- "stock_id", GTK_STOCK_GO_UP,
- "tooltip", _("Go up one level"),
- "window", priv->window,
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
- gtk_action_group_add_action_with_accel (priv->action_group, action,
- "<alt>Up");
- g_object_unref (action);
-
- /* FIXME: I'm still waiting for the exact term to
- * user here from the docs team.
- */
- action = priv->actions[LOCATION_ACTION] =
- g_object_new (EPHY_TYPE_LOCATION_ACTION,
- "name", "Location",
- "label", _("Address Entry"),
- "stock_id", EPHY_STOCK_ENTRY,
- "tooltip", _("Enter a web address to open, or a phrase to search for"),
- "visible-overflown", FALSE,
- "window", priv->window,
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
- g_signal_connect (action, "notify::address",
- G_CALLBACK (sync_user_input_cb), toolbar);
- g_signal_connect (action, "lock-clicked",
- G_CALLBACK (lock_clicked_cb), toolbar);
- gtk_action_group_add_action (priv->action_group, action);
- g_object_unref (action);
-
- action = priv->actions[ZOOM_ACTION] =
- g_object_new (EPHY_TYPE_ZOOM_ACTION,
- "name", "Zoom",
- "label", _("Zoom"),
- "stock_id", GTK_STOCK_ZOOM_IN,
- "tooltip", _("Adjust the text size"),
- "zoom", 1.0,
- NULL);
- g_signal_connect (action, "zoom_to_level",
- G_CALLBACK (zoom_to_level_cb), toolbar);
- gtk_action_group_add_action (priv->action_group, action);
- g_object_unref (action);
-
- action = g_object_new (EPHY_TYPE_GO_ACTION,
- "name", "ToolbarGo",
- "label", _("Go"),
- "stock_id", GTK_STOCK_JUMP_TO,
- "tooltip", _("Go to the address entered in the address entry"),
- NULL);
- g_signal_connect (action, "activate",
- G_CALLBACK (window_cmd_load_location), priv->window);
- gtk_action_group_add_action (priv->action_group, action);
- g_object_unref (action);
-
- action = g_object_new (EPHY_TYPE_HOME_ACTION,
- "name", "GoHome",
- "label", _("_Home"),
- "stock_id", GTK_STOCK_HOME,
- "tooltip", _("Go to the home page"),
- "is_important", TRUE,
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
- gtk_action_group_add_action_with_accel (priv->action_group, action, "<alt>Home");
- g_object_unref (action);
-
- action = g_object_new (EPHY_TYPE_HOME_ACTION,
- "name", "FileNewTab",
- "label", _("New _Tab"),
- "stock_id", STOCK_NEW_TAB,
- "tooltip", _("Open a new tab"),
- NULL);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
-
- gtk_action_group_add_action_with_accel (priv->action_group, action, "<control>T");
-
- 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);
- g_signal_connect_swapped (action, "open-link",
- G_CALLBACK (ephy_link_open), toolbar);
-
- gtk_action_group_add_action_with_accel (priv->action_group, action, "<control>N");
-
- g_object_unref (action);
-
-}
-
-/* public functions */
-
-/**
- * ephy_toolbar_get_action_group:
- * @toolbar: an #EphyToolbar widget
- *
- * Gets the #GtkActionGroup for @toolbar.
- *
- * Return value: (transfer none): the #GtkActionGroup associated with @toolbar
- **/
-GtkActionGroup *
-ephy_toolbar_get_action_group (EphyToolbar *toolbar)
-{
- return toolbar->priv->action_group;
-}
-
-/**
- * ephy_toolbar_set_favicon:
- * @toolbar: an #EphyToolbar widget
- * @icon: a #GdkPixbuf icon
- *
- * Sets @icon to be the favicon of @toolbar's internal #EphyLocationEntry.
- **/
-void
-ephy_toolbar_set_favicon (EphyToolbar *toolbar,
- GdkPixbuf *icon)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
-
- g_object_set (priv->actions[LOCATION_ACTION], "icon", icon, NULL);
-}
-
-/**
- * ephy_toolbar_set_show_leave_fullscreen:
- * @toolbar: an #EphyToolbar widget
- * @show: %TRUE to show the leave fullscreen button
- *
- * Tells @toolbar if it should show the leave fullscreen button or not.
- **/
-void
-ephy_toolbar_set_show_leave_fullscreen (EphyToolbar *toolbar,
- gboolean show)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
-
- priv->leave_fullscreen_visible = show != FALSE;
-
- ephy_toolbar_update_fixed_visibility (toolbar);
-}
-
-/**
- * ephy_toolbar_activate_location:
- * @toolbar: an #EphyToolbar widget
- *
- * Calls ephy_location_entry_activate on @toolbar's internal #EphyLocationEntry.
- **/
-void
-ephy_toolbar_activate_location (EphyToolbar *toolbar)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- GSList *proxies;
- GtkWidget *entry = NULL;
- gboolean visible;
-
- proxies = gtk_action_get_proxies (priv->actions[LOCATION_ACTION]);
-
- if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
- {
- entry = GTK_WIDGET (proxies->data);
- }
-
- if (entry == NULL)
- {
- /* happens when the user has removed the location entry from
- * the toolbars.
- */
- return;
- }
-
- g_object_get (G_OBJECT (toolbar), "visible", &visible, NULL);
- if (visible == FALSE)
- {
- gtk_widget_show (GTK_WIDGET (toolbar));
- toolbar->priv->set_focus_handler =
- g_signal_connect (toolbar->priv->window, "set-focus",
- G_CALLBACK (maybe_finish_activation_cb),
- toolbar);
- }
-
- ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
-}
-
-/**
- * ephy_toolbar_get_location:
- * @toolbar: an #EphyToolbar widget
- *
- * Gets the current address according to @toolbar's #EphyLocationAction.
- *
- * Returns: current @toolbar address
- **/
-const char *
-ephy_toolbar_get_location (EphyToolbar *toolbar)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]);
-
- return ephy_location_action_get_address (action);
-}
-
-/**
- * ephy_toolbar_set_location:
- * @toolbar: an #EphyToolbar widget
- * @address: new address
- *
- * Sets the internal #EphyLocationAction address to @address.
- **/
-void
-ephy_toolbar_set_location (EphyToolbar *toolbar,
- const char *address)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]);
-
- if (priv->updating_address) return;
-
- priv->updating_address = TRUE;
- ephy_location_action_set_address (action, address);
- priv->updating_address = FALSE;
-}
-
-/**
- * ephy_toolbar_set_navigation_actions:
- * @toolbar: an #EphyToolbar widget
- * @back: %TRUE if possible to go backward
- * @forward: %TRUE if possible to go forward
- * @up: %TRUE if possible to go up
- *
- * Sets the sensivity of navigation buttons in the @toolbar.
- **/
-void
-ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
- gboolean back,
- gboolean forward,
- gboolean up)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
-
- ephy_action_change_sensitivity_flags (priv->actions[BACK_ACTION], SENS_FLAG, !back);
- ephy_action_change_sensitivity_flags (priv->actions[FORWARD_ACTION], SENS_FLAG, !forward);
- ephy_action_change_sensitivity_flags (priv->actions[UP_ACTION], SENS_FLAG, !up);
-}
-
-/**
- * ephy_toolbar_set_navigation_tooltips:
- * @toolbar: an #EphyToolbar widget
- * @back_title: text for back button tooltip
- * @forward_title: text for forward button tooltip
- *
- * Sets the titles of back and forward pages as the tooltips of its corresponding
- * navigation buttons.
- **/
-void
-ephy_toolbar_set_navigation_tooltips (EphyToolbar *toolbar,
- const char *back_title,
- const char *forward_title)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
- GValue value = { 0 };
-
- g_value_init (&value, G_TYPE_STRING);
-
- g_value_set_static_string (&value, back_title);
- g_object_set_property (G_OBJECT (priv->actions[BACK_ACTION]),
- "tooltip", &value);
-
- g_value_set_static_string (&value, forward_title);
- g_object_set_property (G_OBJECT (priv->actions[FORWARD_ACTION]),
- "tooltip", &value);
- g_value_unset (&value);
-}
-
-/**
- * ephy_toolbar_set_security_state:
- * @toolbar: an #EphyToolbar widget
- * @show_lock: %TRUE to show the lock icon in the location entry
- * @stock_id: stock-id to be used as the lock icon
- * @tooltip: tooltip for the lock icon
- *
- * Sets properties on the lock icon inside the internal #EphyLocationEntry.
- **/
-void
-ephy_toolbar_set_security_state (EphyToolbar *toolbar,
- gboolean show_lock,
- const char *stock_id,
- const char *tooltip)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
-
- priv->show_lock = show_lock != FALSE;
-
- g_object_set (priv->actions[LOCATION_ACTION],
- "lock-stock-id", stock_id,
- "lock-tooltip", tooltip,
- "show-lock", priv->show_lock,
- NULL);
-}
-
-/**
- * ephy_toolbar_set_zoom:
- * @toolbar: an #EphyToolbar widget
- * @can_zoom: %TRUE if the current #EphyWebView can zoom
- * @zoom: new zoom level
- *
- * Sets the zoom level to @zoom, but only if @can_zoom is %TRUE.
- **/
-void
-ephy_toolbar_set_zoom (EphyToolbar *toolbar,
- gboolean can_zoom,
- float zoom)
-{
- EphyToolbarPrivate *priv = toolbar->priv;
-
- gtk_action_set_sensitive (priv->actions[ZOOM_ACTION], can_zoom);
- g_object_set (priv->actions[ZOOM_ACTION], "zoom", can_zoom ? zoom : 1.0, NULL);
-}
-
-/* Class implementation */
-
-static void
-ephy_toolbar_init (EphyToolbar *toolbar)
-{
- toolbar->priv = EPHY_TOOLBAR_GET_PRIVATE (toolbar);
-
- egg_editable_toolbar_set_primary_class (EGG_EDITABLE_TOOLBAR (toolbar), TRUE, NULL);
-}
-
-static GObject *
-ephy_toolbar_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
- EphyToolbar *toolbar;
- EphyToolbarPrivate *priv;
- GtkToolbar *gtoolbar;
-
- object = G_OBJECT_CLASS (ephy_toolbar_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
-
- toolbar = EPHY_TOOLBAR (object);
- priv = toolbar->priv;
-
- priv->fixed_toolbar = gtk_toolbar_new ();
- gtoolbar = GTK_TOOLBAR (priv->fixed_toolbar);
- gtk_toolbar_set_show_arrow (gtoolbar, FALSE);
-
- priv->sep_item = gtk_separator_tool_item_new ();
- gtk_toolbar_insert (gtoolbar, priv->sep_item, -1);
-
- priv->exit_button = gtk_tool_button_new_from_stock (GTK_STOCK_LEAVE_FULLSCREEN);
- gtk_tool_button_set_label (GTK_TOOL_BUTTON (priv->exit_button), _("Leave Fullscreen"));
- gtk_tool_item_set_is_important (priv->exit_button, TRUE);
- g_signal_connect (priv->exit_button, "clicked",
- G_CALLBACK (exit_button_clicked_cb), toolbar);
- gtk_toolbar_insert (gtoolbar, priv->exit_button, -1);
-
- egg_editable_toolbar_set_fixed (EGG_EDITABLE_TOOLBAR (toolbar), gtoolbar);
-
- ephy_toolbar_update_fixed_visibility (toolbar);
-
- return object;
-}
-
-static void
-ephy_toolbar_finalize (GObject *object)
-{
- EphyToolbar *toolbar = EPHY_TOOLBAR (object);
- EphyToolbarPrivate *priv = toolbar->priv;
-
- if (priv->set_focus_handler != 0)
- {
- g_signal_handler_disconnect (priv->window,
- priv->set_focus_handler);
- }
-
- G_OBJECT_CLASS (ephy_toolbar_parent_class)->finalize (object);
-}
-
-static void
-ephy_toolbar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- /* no readable properties */
- g_assert_not_reached ();
-}
-
-static void
-ephy_toolbar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EphyToolbar *toolbar = EPHY_TOOLBAR (object);
-
- switch (prop_id)
- {
- case PROP_WINDOW:
- ephy_toolbar_set_window (toolbar, g_value_get_object (value));
- break;
- }
-}
-
-static void
-ephy_toolbar_class_init (EphyToolbarClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructor = ephy_toolbar_constructor;
- object_class->finalize = ephy_toolbar_finalize;
- object_class->set_property = ephy_toolbar_set_property;
- object_class->get_property = ephy_toolbar_get_property;
-
- /**
- * EphyToolbar::activation-finished:
- * @toolbar: the object which received the signal.
- *
- * Emitted when the user clicks on the security icon of the internal
- * #EphyLocationEntry.
- */
- signals[ACTIVATION_FINISHED] =
- g_signal_new ("activation-finished",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyToolbarClass, activation_finished),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyToolbar::exit-clicked:
- * @toolbar: the object which received the signal.
- *
- * Emitted when the user clicks on the security icon of the internal
- * #EphyLocationEntry.
- */
- signals[EXIT_CLICKED] =
- g_signal_new
- ("exit-clicked",
- EPHY_TYPE_TOOLBAR,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyToolbarClass, exit_clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
-
- /**
- * EphyToolbar::lock-clicked:
- * @toolbar: the object which received the signal.
- *
- * Emitted when the user clicks on the security icon of the internal
- * #EphyLocationEntry.
- */
- signals[LOCK_CLICKED] =
- g_signal_new
- ("lock-clicked",
- EPHY_TYPE_TOOLBAR,
- G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EphyToolbarClass, lock_clicked),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- /**
- * EphyToolbar:window:
- * @toolbar: the object which received the signal.
- *
- * Parent window of the toolbar.
- */
- g_object_class_install_property (object_class,
- PROP_WINDOW,
- g_param_spec_object ("window",
- "Window",
- "Parent window",
- EPHY_TYPE_WINDOW,
- G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
- G_PARAM_CONSTRUCT_ONLY));
-
- g_type_class_add_private (object_class, sizeof(EphyToolbarPrivate));
-}
-
-/**
- * ephy_toolbar_new:
- * @window: parent window for the toolbar
- *
- * Creates a new #EphyToolbar and associates it with @window.
- *
- * Returns: a new #EphyToolbar
- **/
-EphyToolbar *
-ephy_toolbar_new (EphyWindow *window)
-{
- EggEditableToolbar *etoolbar;
-
- etoolbar = EGG_EDITABLE_TOOLBAR
- (g_object_new (EPHY_TYPE_TOOLBAR,
- "window", window,
- "ui-manager", ephy_window_get_ui_manager (window),
- "popup-path", "/ToolbarPopup",
- NULL));
-
- egg_editable_toolbar_add_visibility
- (etoolbar, "/menubar/ViewMenu/ViewTogglesGroup/ToolbarMenu/ViewToolbarsGroup");
- egg_editable_toolbar_add_visibility
- (etoolbar, "/ToolbarPopup/ViewToolbarsGroup");
-
- return EPHY_TOOLBAR (etoolbar);
-}
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
deleted file mode 100644
index 6b95c6421..000000000
--- a/src/ephy-toolbar.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright © 2002 Jorn Baayen
- * Copyright © 2003-2004 Marco Pesenti Gritti
- * Copyright © 2003, 2004, 2005 Christian Persch
- *
- * 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.
- *
- */
-
-#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
-#error "Only <epiphany/epiphany.h> can be included directly."
-#endif
-
-#ifndef EPHY_TOOLBAR_H
-#define EPHY_TOOLBAR_H
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include "egg-editable-toolbar.h"
-#include "ephy-window.h"
-
-G_BEGIN_DECLS
-
-#define EPHY_TYPE_TOOLBAR (ephy_toolbar_get_type ())
-#define EPHY_TOOLBAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_TOOLBAR, EphyToolbar))
-#define EPHY_TOOLBAR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_TOOLBAR, EphyToolbarClass))
-#define EPHY_IS_TOOLBAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_TOOLBAR))
-#define EPHY_IS_TOOLBAR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_TOOLBAR))
-#define EPHY_TOOLBAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_TOOLBAR, EphyToolbarClass))
-
-typedef struct _EphyToolbar EphyToolbar;
-typedef struct _EphyToolbarClass EphyToolbarClass;
-typedef struct _EphyToolbarPrivate EphyToolbarPrivate;
-
-struct _EphyToolbar
-{
- EggEditableToolbar parent_object;
-
- /*< private >*/
- EphyToolbarPrivate *priv;
-};
-
-struct _EphyToolbarClass
-{
- EggEditableToolbarClass parent_class;
-
- /* Signals */
- void (* activation_finished) (EphyToolbar *toolbar);
- void (* exit_clicked) (EphyToolbar *toolbar);
- void (* lock_clicked) (EphyToolbar *toolbar);
-};
-
-GType ephy_toolbar_get_type (void);
-
-EphyToolbar *ephy_toolbar_new (EphyWindow *window);
-
-GtkActionGroup *ephy_toolbar_get_action_group (EphyToolbar *toolbar);
-
-void ephy_toolbar_set_favicon (EphyToolbar *toolbar,
- GdkPixbuf *icon);
-
-void ephy_toolbar_set_show_leave_fullscreen (EphyToolbar *toolbar,
- gboolean show);
-
-void ephy_toolbar_activate_location (EphyToolbar *toolbar);
-
-const char *ephy_toolbar_get_location (EphyToolbar *toolbar);
-
-void ephy_toolbar_set_location (EphyToolbar *toolbar,
- const char *address);
-
-void ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
- gboolean back,
- gboolean forward,
- gboolean up);
-
-void ephy_toolbar_set_navigation_tooltips (EphyToolbar *toolbar,
- const char *back_title,
- const char *forward_title);
-
-void ephy_toolbar_set_security_state (EphyToolbar *toolbar,
- gboolean show_lock,
- const char *stock_id,
- const char *tooltip);
-
-void ephy_toolbar_set_zoom (EphyToolbar *toolbar,
- gboolean can_zoom,
- float zoom);
-
-G_END_DECLS
-
-#endif /* !EPHY_TOOLBAR_H */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index da7621ac3..90a53bc0d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -39,18 +39,25 @@
#include "ephy-file-helpers.h"
#include "ephy-find-toolbar.h"
#include "ephy-fullscreen-popup.h"
+#include "ephy-go-action.h"
#include "ephy-gui.h"
+#include "ephy-home-action.h"
#include "ephy-link.h"
+#include "ephy-location-action.h"
#include "ephy-location-entry.h"
+#include "ephy-navigation-action.h"
+#include "ephy-navigation-history-action.h"
+#include "ephy-navigation-up-action.h"
#include "ephy-notebook.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-state.h"
#include "ephy-stock-icons.h"
-#include "ephy-toolbar.h"
+#include "ephy-topic-action.h"
#include "ephy-type-builtins.h"
#include "ephy-web-view.h"
+#include "ephy-zoom-action.h"
#include "ephy-zoom.h"
#include "popup-commands.h"
#include "window-commands.h"
@@ -438,10 +445,11 @@ struct _EphyWindowPrivate
GtkWidget *main_vbox;
GtkWidget *menu_dock;
GtkWidget *fullscreen_popup;
- EphyToolbar *toolbar;
+ GtkWidget *toolbar;
GtkUIManager *manager;
GtkActionGroup *action_group;
GtkActionGroup *popups_action_group;
+ GtkActionGroup *toolbar_action_group;
EphyEncodingMenu *enc_menu;
GtkNotebook *notebook;
EphyEmbed *active_embed;
@@ -456,6 +464,8 @@ struct _EphyWindowPrivate
GtkWidget *entry;
GtkWidget *downloads_box;
+ guint clear_progress_timeout_id;
+ gulong set_focus_handler;
guint menubar_accel_keyval;
guint menubar_accel_modifier;
@@ -466,6 +476,8 @@ struct _EphyWindowPrivate
guint is_popup : 1;
guint present_on_insert : 1;
guint key_theme_is_emacs : 1;
+ guint updating_address : 1;
+ guint show_lock : 1;
};
enum
@@ -829,7 +841,7 @@ ensure_location_entry (EphyWindow *window)
GtkWidget *proxy;
EphyWindowPrivate *priv = window->priv;
- toolbar_action_group = ephy_toolbar_get_action_group (priv->toolbar);
+ toolbar_action_group = priv->toolbar_action_group;
action = gtk_action_group_get_action (toolbar_action_group,
"Location");
proxies = gtk_action_get_proxies (action);
@@ -871,15 +883,8 @@ ephy_window_fullscreen (EphyWindow *window)
sync_tab_load_status (ephy_embed_get_web_view (embed), NULL, window);
sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
- egg_editable_toolbar_set_model
- (EGG_EDITABLE_TOOLBAR (priv->toolbar),
- EGG_TOOLBARS_MODEL (
- ephy_shell_get_toolbars_model (ephy_shell, TRUE)));
ensure_location_entry (window);
- ephy_toolbar_set_show_leave_fullscreen (priv->toolbar,
- !lockdown_fs);
-
sync_chromes_visibility (window);
}
@@ -890,14 +895,8 @@ ephy_window_unfullscreen (EphyWindow *window)
destroy_fullscreen_popup (window);
- egg_editable_toolbar_set_model
- (EGG_EDITABLE_TOOLBAR (window->priv->toolbar),
- EGG_TOOLBARS_MODEL (
- ephy_shell_get_toolbars_model (ephy_shell, FALSE)));
ensure_location_entry (window);
- ephy_toolbar_set_show_leave_fullscreen (window->priv->toolbar, FALSE);
-
sync_chromes_visibility (window);
}
@@ -1000,7 +999,7 @@ ephy_window_key_press_event (GtkWidget *widget,
{
GtkAction * action = gtk_action_group_get_action
(extra_keybindings[i].fromToolbar ?
- ephy_toolbar_get_action_group (priv->toolbar) :
+ priv->toolbar_action_group :
priv->action_group,
extra_keybindings[i].action);
if (gtk_action_is_sensitive (action))
@@ -1243,7 +1242,7 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
GSList *proxies;
GtkWidget *proxy;
- action_group = ephy_toolbar_get_action_group (window->priv->toolbar);
+ action_group = window->priv->toolbar_action_group;
location_action = gtk_action_group_get_action (action_group,
"Location");
proxies = gtk_action_get_proxies (location_action);
@@ -1631,6 +1630,106 @@ setup_ui_manager (EphyWindow *window)
window->priv->popups_action_group = action_group;
g_object_unref (action_group);
+ action_group = gtk_action_group_new ("SpecialToolbarActions");
+ action =
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
+ "name", "NavigationBack",
+ "label", _("_Back"),
+ "stock_id", GTK_STOCK_GO_BACK,
+ "tooltip", _("Go to the previous visited page"),
+ "window", window,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
+ "is_important", TRUE,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action,
+ "<alt>Left");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
+ "name", "NavigationForward",
+ "label", _("_Forward"),
+ "stock_id", GTK_STOCK_GO_FORWARD,
+ "tooltip", _("Go to the next visited page"),
+ "window", window,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action,
+ "<alt>Right");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_NAVIGATION_UP_ACTION,
+ "name", "NavigationUp",
+ "label", _("_Up"),
+ "stock_id", GTK_STOCK_GO_UP,
+ "tooltip", _("Go up one level"),
+ "window", window,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action,
+ "<alt>Up");
+ g_object_unref (action);
+
+ /* FIXME: I'm still waiting for the exact term to
+ * user here from the docs team.
+ */
+ action =
+ g_object_new (EPHY_TYPE_LOCATION_ACTION,
+ "name", "Location",
+ "label", _("Address Entry"),
+ "stock_id", EPHY_STOCK_ENTRY,
+ "tooltip", _("Enter a web address to open, or a phrase to search for"),
+ "visible-overflown", FALSE,
+ "window", window,
+ NULL);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
+
+
+ action = g_object_new (EPHY_TYPE_HOME_ACTION,
+ "name", "GoHome",
+ "label", _("_Home"),
+ "stock_id", GTK_STOCK_HOME,
+ "tooltip", _("Go to the home page"),
+ "is_important", TRUE,
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, "<alt>Home");
+ g_object_unref (action);
+
+ action =
+ g_object_new (EPHY_TYPE_ZOOM_ACTION,
+ "name", "Zoom",
+ "label", _("Zoom"),
+ "stock_id", GTK_STOCK_ZOOM_IN,
+ "tooltip", _("Adjust the text size"),
+ "zoom", 1.0,
+ NULL);
+ gtk_action_group_add_action (action_group, action);
+ g_object_unref (action);
+
+ action = g_object_new (EPHY_TYPE_HOME_ACTION,
+ "name", "FileNewTab",
+ "label", _("New _Tab"),
+ "stock_id", STOCK_NEW_TAB,
+ "tooltip", _("Open a new tab"),
+ NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, "<control>T");
+
+ 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);
+
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ window->priv->toolbar_action_group = action_group;
+ g_object_unref (action_group);
+
window->priv->manager = manager;
g_signal_connect (manager, "add_widget", G_CALLBACK (add_widget), window);
gtk_window_add_accel_group (GTK_WINDOW (window),
@@ -1638,6 +1737,22 @@ setup_ui_manager (EphyWindow *window)
}
static void
+_ephy_window_set_location (EphyWindow *window,
+ const char *address)
+{
+ EphyWindowPrivate *priv = window->priv;
+ EphyLocationAction *action;
+
+ if (priv->updating_address) return;
+
+ action = EPHY_LOCATION_ACTION (gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location"));
+ priv->updating_address = TRUE;
+ ephy_location_action_set_address (action, address);
+ priv->updating_address = FALSE;
+}
+
+static void
sync_tab_address (EphyWebView *view,
GParamSpec *pspec,
EphyWindow *window)
@@ -1651,7 +1766,7 @@ sync_tab_address (EphyWebView *view,
address = ephy_web_view_get_address (view);
typed_address = ephy_web_view_get_typed_address (view);
- ephy_toolbar_set_location (priv->toolbar, typed_address ? typed_address : address);
+ _ephy_window_set_location (window, typed_address ? typed_address : address);
ephy_find_toolbar_request_close (priv->find_toolbar);
}
@@ -1694,6 +1809,18 @@ sync_tab_document_type (EphyWebView *view,
}
static void
+_ephy_window_action_set_favicon (EphyWindow *window,
+ GdkPixbuf *icon)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location");
+ g_object_set (action, "icon", icon, NULL);
+}
+
+static void
sync_tab_icon (EphyWebView *view,
GParamSpec *pspec,
EphyWindow *window)
@@ -1705,7 +1832,49 @@ sync_tab_icon (EphyWebView *view,
icon = ephy_web_view_get_icon (view);
- ephy_toolbar_set_favicon (priv->toolbar, icon);
+ _ephy_window_action_set_favicon (window, icon);
+}
+
+static void
+_ephy_window_set_navigation_actions (EphyWindow *window,
+ gboolean back,
+ gboolean forward,
+ gboolean up)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group, "NavigationBack");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG, !back);
+ action = gtk_action_group_get_action (priv->toolbar_action_group, "NavigationForward");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG, !forward);
+ action = gtk_action_group_get_action (priv->toolbar_action_group, "NavigationUp");
+ ephy_action_change_sensitivity_flags (action, SENS_FLAG, !up);
+}
+
+static void
+_ephy_window_set_navigation_tooltips (EphyWindow *window,
+ const char *back_title,
+ const char *forward_title)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action;
+ GValue value = { 0 };
+
+ g_value_init (&value, G_TYPE_STRING);
+
+ g_value_set_static_string (&value, back_title);
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "NavigationBack");
+ g_object_set_property (G_OBJECT (action),
+ "tooltip", &value);
+
+ g_value_set_static_string (&value, forward_title);
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "NavigationForward");
+ g_object_set_property (G_OBJECT (action),
+ "tooltip", &value);
+ g_value_unset (&value);
}
static void
@@ -1737,8 +1906,7 @@ sync_tab_navigation (EphyWebView *view,
forward = TRUE;
}
- ephy_toolbar_set_navigation_actions (window->priv->toolbar,
- back, forward, up);
+ _ephy_window_set_navigation_actions (window, back, forward, up);
web_view = WEBKIT_WEB_VIEW (view);
web_back_forward_list = webkit_web_view_get_back_forward_list (web_view);
@@ -1757,12 +1925,32 @@ sync_tab_navigation (EphyWebView *view,
forward_title = webkit_web_history_item_get_title (item);
}
- ephy_toolbar_set_navigation_tooltips (window->priv->toolbar,
+ _ephy_window_set_navigation_tooltips (window,
back_title,
forward_title);
}
static void
+_ephy_window_set_security_state (EphyWindow *window,
+ gboolean show_lock,
+ const char *stock_id,
+ const char *tooltip)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action;
+
+ priv->show_lock = show_lock != FALSE;
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location");
+ g_object_set (action,
+ "lock-stock-id", stock_id,
+ "lock-tooltip", tooltip,
+ "show-lock", priv->show_lock,
+ NULL);
+}
+
+static void
sync_tab_security (EphyWebView *view,
GParamSpec *pspec,
EphyWindow *window)
@@ -1826,7 +2014,7 @@ sync_tab_security (EphyWebView *view,
g_free (tmp);
}
- ephy_toolbar_set_security_state (priv->toolbar, show_lock, stock_id, tooltip);
+ _ephy_window_set_security_state (window, show_lock, stock_id, tooltip);
if (priv->fullscreen_popup != NULL)
{
@@ -1917,6 +2105,19 @@ sync_tab_title (EphyWebView *view,
}
static void
+_ephy_window_action_set_zoom (EphyWindow *window,
+ gboolean can_zoom,
+ float zoom)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Zoom");
+
+ gtk_action_set_sensitive (action, can_zoom);
+ g_object_set (action, "zoom", can_zoom ? zoom : 1.0, NULL);
+}
+
+static void
sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window)
{
GtkActionGroup *action_group;
@@ -1948,7 +2149,7 @@ sync_tab_zoom (WebKitWebView *web_view, GParamSpec *pspec, EphyWindow *window)
can_zoom_normal = TRUE;
}
- ephy_toolbar_set_zoom (window->priv->toolbar, can_zoom, zoom);
+ _ephy_window_action_set_zoom (window, can_zoom, zoom);
action_group = window->priv->action_group;
action = gtk_action_group_get_action (action_group, "ViewZoomIn");
@@ -2829,7 +3030,6 @@ static gboolean
embed_modal_alert_cb (EphyEmbed *embed,
EphyWindow *window)
{
- EphyWindowPrivate *priv = window->priv;
const char *address;
/* switch the window to the tab, and bring the window to the foreground
@@ -2841,7 +3041,7 @@ embed_modal_alert_cb (EphyEmbed *embed,
/* make sure the location entry shows the real URL of the tab's page */
address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
- ephy_toolbar_set_location (priv->toolbar, address);
+ _ephy_window_set_location (window, address);
/* don't suppress alert */
return FALSE;
@@ -3447,6 +3647,13 @@ ephy_window_finalize (GObject *object)
g_hash_table_destroy (priv->tabs_to_remove);
+ if (priv->clear_progress_timeout_id)
+ g_source_remove (priv->clear_progress_timeout_id);
+
+ if (priv->set_focus_handler != 0)
+ g_signal_handler_disconnect (window,
+ priv->set_focus_handler);
+
G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
LOG ("EphyWindow finalised %p", object);
@@ -3499,6 +3706,102 @@ allow_popups_notifier (GSettings *settings,
g_list_free (tabs);
}
+static void
+sync_user_input_cb (EphyLocationAction *action,
+ GParamSpec *pspec,
+ EphyWindow *window)
+{
+ EphyWindowPrivate *priv = window->priv;
+ EphyEmbed *embed;
+ const char *address;
+
+ LOG ("sync_user_input_cb");
+
+ if (priv->updating_address) return;
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_assert (EPHY_IS_EMBED (embed));
+
+ address = ephy_location_action_get_address (action);
+
+ priv->updating_address = TRUE;
+ ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), address);
+ priv->updating_address = FALSE;
+}
+
+static void
+zoom_to_level_cb (GtkAction *action,
+ float zoom,
+ EphyWindow *window)
+{
+ ephy_window_set_zoom (window, zoom);
+}
+
+static GtkWidget *
+setup_toolbar (EphyWindow *window)
+{
+ GtkWidget *toolbar;
+ GtkUIManager *manager;
+ GtkAction *action;
+ EphyWindowPrivate *priv = window->priv;
+
+ manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
+
+ toolbar = gtk_ui_manager_get_widget (manager, "/DefaultToolbar");
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (toolbar),
+ GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "NavigationBack");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "NavigationForward");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "NavigationUp");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location");
+ g_signal_connect (action, "notify::address",
+ G_CALLBACK (sync_user_input_cb), window);
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+
+ /* FIXME: No one seems to be using this atm. When we need it, the
+ * signal should be added to EphyWindow. */
+#if 0
+ g_signal_connect (action, "lock-clicked",
+ G_CALLBACK (lock_clicked_cb), toolbar);
+#endif
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "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,
+ "GoHome");
+ g_signal_connect_swapped (action, "open-link",
+ G_CALLBACK (ephy_link_open), window);
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Zoom");
+ g_signal_connect (action, "zoom-to-level",
+ G_CALLBACK (zoom_to_level_cb), window);
+
+ return toolbar;
+}
+
static const char* disabled_actions_for_app_mode[] = { "FileOpen",
"FileSaveAs",
"FileSaveAsApplication",
@@ -3517,7 +3820,6 @@ ephy_window_constructor (GType type,
EphyWindowPrivate *priv;
EphyExtension *manager;
EphyEmbedSingle *single;
- EggToolbarsModel *model;
GtkSettings *settings;
GtkAction *action;
GtkActionGroup *toolbar_action_group;
@@ -3586,24 +3888,7 @@ ephy_window_constructor (GType type,
g_object_bind_property (action, "active",
priv->downloads_box, "visible",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
- /* don't show the find toolbar here! */
- /* get the toolbars model *before* getting the bookmarksbar model
- * (via ephy_bookmarsbar_new()), so that the toolbars model is
- * instantiated *before* the bookmarksbarmodel, to make forwarding
- * works. See bug #151267.
- */
- model= EGG_TOOLBARS_MODEL (ephy_shell_get_toolbars_model (ephy_shell, FALSE));
-
- /* create the toolbars */
- priv->toolbar = ephy_toolbar_new (window);
- g_signal_connect_swapped (priv->toolbar, "open-link",
- G_CALLBACK (ephy_link_open), window);
- g_signal_connect_swapped (priv->toolbar, "exit-clicked",
- G_CALLBACK (exit_fullscreen_clicked_cb), window);
- g_signal_connect_swapped (priv->toolbar, "activation-finished",
- G_CALLBACK (sync_chromes_visibility), window);
-
/* now load the UI definition */
gtk_ui_manager_add_ui_from_file
(priv->manager, ephy_file ("epiphany-ui.xml"), &error);
@@ -3634,28 +3919,17 @@ ephy_window_constructor (GType type,
g_object_unref (css_provider);
g_object_unref (css_file);
+ /* create the toolbars */
+ priv->toolbar = setup_toolbar (window);
+
/* Initialize the menus */
priv->enc_menu = ephy_encoding_menu_new (window);
- /* Add the toolbars to the window */
- gtk_box_pack_end (GTK_BOX (priv->menu_dock),
- GTK_WIDGET (priv->toolbar),
- FALSE, FALSE, 0);
-
/* Once the window is sufficiently created let the extensions attach to it */
manager = EPHY_EXTENSION (ephy_shell_get_extensions_manager (ephy_shell));
ephy_extension_attach_window (manager, window);
ephy_bookmarks_ui_attach_window (window);
- /* We only set the model now after attaching the extensions, so that
- * extensions already have created their actions which may be on
- * the toolbar
- */
- egg_editable_toolbar_set_model
- (EGG_EDITABLE_TOOLBAR (priv->toolbar), model);
-
- ephy_toolbar_set_show_leave_fullscreen (priv->toolbar, FALSE);
-
/* other notifiers */
action = gtk_action_group_get_action (window->priv->action_group,
"BrowseWithCaret");
@@ -3676,7 +3950,7 @@ ephy_window_constructor (GType type,
G_CALLBACK (sync_network_status), window);
/* Disable actions not needed for popup mode. */
- toolbar_action_group = ephy_toolbar_get_action_group (priv->toolbar);
+ toolbar_action_group = priv->toolbar_action_group;
action = gtk_action_group_get_action (toolbar_action_group, "FileNewTab");
ephy_action_change_sensitivity_flags (action, SENS_FLAG_CHROME,
priv->is_popup);
@@ -3708,8 +3982,12 @@ ephy_window_constructor (GType type,
/* Connect lock clicks */
action = gtk_action_group_get_action (priv->action_group, "ViewPageSecurityInfo");
+ /* FIXME: No one seems to be using this atm. When we need it, the
+ * signal should be added to EphyWindow. */
+#if 0
g_signal_connect_swapped (priv->toolbar, "lock-clicked",
G_CALLBACK (gtk_action_activate), action);
+#endif
/* ensure the UI is updated */
gtk_ui_manager_ensure_update (priv->manager);
@@ -3759,6 +4037,65 @@ ephy_window_class_init (EphyWindowClass *klass)
g_type_class_add_private (object_class, sizeof (EphyWindowPrivate));
}
+static void
+maybe_finish_activation_cb (EphyWindow *window,
+ GtkWidget *widget,
+ GtkWidget *toolbar)
+{
+ while (widget != NULL && widget != toolbar)
+ {
+ widget = gtk_widget_get_parent (widget);
+ }
+
+ /* if widget == toolbar, the new focus widget is in the toolbar, so we
+ * don't deactivate.
+ */
+ if (widget != toolbar)
+ {
+ g_signal_handler_disconnect (window, window->priv->set_focus_handler);
+ window->priv->set_focus_handler = 0;
+ sync_chromes_visibility (window);
+ }
+}
+
+static void
+_ephy_window_activate_location (EphyWindow *window)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action;
+ GSList *proxies;
+ GtkWidget *entry = NULL;
+ gboolean visible;
+
+ action = gtk_action_group_get_action (priv->toolbar_action_group, "Location");
+ proxies = gtk_action_get_proxies (action);
+
+ if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
+ {
+ entry = GTK_WIDGET (proxies->data);
+ }
+
+ if (entry == NULL)
+ {
+ /* happens when the user has removed the location entry from
+ * the toolbars.
+ */
+ return;
+ }
+
+ g_object_get (G_OBJECT (priv->toolbar), "visible", &visible, NULL);
+ if (visible == FALSE)
+ {
+ gtk_widget_show (GTK_WIDGET (priv->toolbar));
+ window->priv->set_focus_handler =
+ g_signal_connect (window, "set-focus",
+ G_CALLBACK (maybe_finish_activation_cb),
+ priv->toolbar);
+ }
+
+ ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
+}
+
static EphyEmbed *
ephy_window_open_link (EphyLink *link,
const char *address,
@@ -3810,7 +4147,7 @@ ephy_window_open_link (EphyLink *link,
if (address == NULL || address[0] == '\0' || strcmp (address, "about:blank") == 0)
{
- ephy_toolbar_activate_location (priv->toolbar);
+ _ephy_window_activate_location (window);
}
else
{
@@ -3890,9 +4227,9 @@ ephy_window_get_ui_manager (EphyWindow *window)
* ephy_window_get_toolbar:
* @window: an #EphyWindow
*
- * Returns this window's toolbar as an #EggEditableToolbar.
+ * Returns this window's toolbar
*
- * Return value: (transfer none): an #EggEditableToolbar
+ * Return value: (transfer none): an #EphyToolbar
**/
GtkWidget *
ephy_window_get_toolbar (EphyWindow *window)
@@ -3983,7 +4320,7 @@ ephy_window_activate_location (EphyWindow *window)
gtk_widget_hide (window->priv->fullscreen_popup);
}
- ephy_toolbar_activate_location (window->priv->toolbar);
+ _ephy_window_activate_location (window);
}
static void
@@ -4169,3 +4506,42 @@ ephy_window_get_context_event (EphyWindow *window)
return window->priv->context_event;
}
+
+/**
+ * ephy_window_get_location:
+ * @window: an #EphyWindow widget
+ *
+ * Gets the current address according to @window's #EphyLocationAction.
+ *
+ * Returns: current @window address
+ **/
+const char *
+ephy_window_get_location (EphyWindow *window)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction * action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location");
+ return ephy_location_action_get_address (EPHY_LOCATION_ACTION (action));
+}
+
+/**
+ * ephy_window_set_location:
+ * @window: an #EphyWindow widget
+ * @address: new address
+ *
+ * Sets the internal #EphyLocationAction address to @address.
+ **/
+void
+ephy_window_set_location (EphyWindow *window,
+ const char *address)
+{
+ EphyWindowPrivate *priv = window->priv;
+ GtkAction *action = gtk_action_group_get_action (priv->toolbar_action_group,
+ "Location");
+
+ if (priv->updating_address) return;
+
+ priv->updating_address = TRUE;
+ ephy_location_action_set_address (EPHY_LOCATION_ACTION (action), address);
+ priv->updating_address = FALSE;
+}
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 42aab9a88..1c2a3c600 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -78,7 +78,9 @@ void ephy_window_set_zoom (EphyWindow *window,
float zoom);
void ephy_window_activate_location (EphyWindow *window);
-
+const char *ephy_window_get_location (EphyWindow *window);
+void ephy_window_set_location (EphyWindow *window,
+ const char *address);
EphyEmbedEvent *ephy_window_get_context_event (EphyWindow *window);
diff --git a/src/window-commands.c b/src/window-commands.c
index ace995d9d..3fb876513 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -38,7 +38,6 @@
#include "ephy-history-window.h"
#include "ephy-file-chooser.h"
#include "ephy-file-helpers.h"
-#include "ephy-toolbar.h"
#include "ephy-state.h"
#include "ephy-gui.h"
#include "ephy-zoom.h"
@@ -1447,11 +1446,9 @@ void
window_cmd_load_location (GtkAction *action,
EphyWindow *window)
{
- EphyToolbar *toolbar;
const char *location;
- toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window));
- location = ephy_toolbar_get_location (toolbar);
+ location = ephy_window_get_location (window);
if (location)
{