aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMario Sanchez Prada <msanchez@igalia.com>2010-04-07 23:19:25 +0800
committerXan Lopez <xan@gnome.org>2010-04-20 21:07:58 +0800
commitede59b054c4af72cc41108db8aedafbcae1996de (patch)
tree3a5581d41025e4687777d376d53c4de490ebe5a3 /src
parent384588b86e68ea692a8f99db86b45ca0cc54f804 (diff)
downloadgsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar.gz
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar.bz2
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar.lz
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar.xz
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.tar.zst
gsoc2013-epiphany-ede59b054c4af72cc41108db8aedafbcae1996de.zip
Split EphyNavigationAction in one abstract class and two subclasses
To ease understanding and further modification of the two different usages for the EphyNavigationAction class (Back/Forward and Up buttons), all the code there was split so the common one is kept in the superclass, delegating the more specific parts in the implementations of the subclasses: History (back/forward) and Up buttons. Also updated usage of this class in EphyToolbar. Bug #539716 Signed-off-by: Xan Lopez <xan@gnome.org>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am120
-rw-r--r--src/ephy-navigation-action.c429
-rw-r--r--src/ephy-navigation-action.h21
-rw-r--r--src/ephy-navigation-history-action.c359
-rw-r--r--src/ephy-navigation-history-action.h67
-rw-r--r--src/ephy-navigation-up-action.c196
-rw-r--r--src/ephy-navigation-up-action.h57
-rw-r--r--src/ephy-toolbar.c13
8 files changed, 825 insertions, 437 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index fd626dad5..44823a6b1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,28 +14,30 @@ header_DATA = \
$(INST_H_FILES)
NOINST_H_FILES = \
- ephy-action-helper.h \
- ephy-activation.h \
- ephy-encoding-dialog.h \
- ephy-encoding-menu.h \
- ephy-find-toolbar.h \
- ephy-fullscreen-popup.h \
- ephy-go-action.h \
- ephy-history-window.h \
- ephy-home-action.h \
- ephy-link-action.h \
- ephy-lockdown.h \
- ephy-location-action.h \
- ephy-navigation-action.h \
- ephy-password-info.h \
- ephy-tabs-menu.h \
- ephy-toolbars-model.h \
- ephy-toolbar.h \
- ephy-toolbar-editor.h \
- languages.h \
- pdm-dialog.h \
- popup-commands.h \
- prefs-dialog.h \
+ ephy-action-helper.h \
+ ephy-activation.h \
+ ephy-encoding-dialog.h \
+ ephy-encoding-menu.h \
+ ephy-find-toolbar.h \
+ ephy-fullscreen-popup.h \
+ ephy-go-action.h \
+ ephy-history-window.h \
+ ephy-home-action.h \
+ ephy-link-action.h \
+ ephy-lockdown.h \
+ ephy-location-action.h \
+ ephy-navigation-action.h \
+ ephy-navigation-history-action.h \
+ ephy-navigation-up-action.h \
+ ephy-password-info.h \
+ ephy-tabs-menu.h \
+ ephy-toolbars-model.h \
+ ephy-toolbar.h \
+ ephy-toolbar-editor.h \
+ languages.h \
+ pdm-dialog.h \
+ popup-commands.h \
+ prefs-dialog.h \
window-commands.h
INST_H_FILES = \
@@ -52,42 +54,44 @@ INST_H_FILES = \
$(NULL)
libephymain_la_SOURCES = \
- ephy-activation.c \
- ephy-action-helper.c \
- ephy-completion-model.c \
- ephy-completion-model.h \
- ephy-dbus.c \
- ephy-dbus.h \
- ephy-encoding-dialog.c \
- ephy-encoding-menu.c \
- ephy-extension.c \
- ephy-extensions-manager.c \
- ephy-find-toolbar.c \
- ephy-fullscreen-popup.c \
- ephy-go-action.c \
- ephy-home-action.c \
- ephy-history-window.c \
- ephy-link.c \
- ephy-link-action.c \
- ephy-location-action.c \
- ephy-lockdown.c \
- ephy-navigation-action.c \
- ephy-notebook.c \
- ephy-password-info.c \
- ephy-session.c \
- ephy-shell.c \
- ephy-statusbar.c \
- ephy-tabs-menu.c \
- ephy-toolbars-model.c \
- ephy-toolbar.c \
- ephy-toolbar-editor.c \
- ephy-window.c \
- pdm-dialog.c \
- popup-commands.c \
- prefs-dialog.c \
- window-commands.c \
- $(INST_H_FILES) \
- $(NOINST_H_FILES) \
+ ephy-activation.c \
+ ephy-action-helper.c \
+ ephy-completion-model.c \
+ ephy-completion-model.h \
+ ephy-dbus.c \
+ ephy-dbus.h \
+ ephy-encoding-dialog.c \
+ ephy-encoding-menu.c \
+ ephy-extension.c \
+ ephy-extensions-manager.c \
+ ephy-find-toolbar.c \
+ ephy-fullscreen-popup.c \
+ ephy-go-action.c \
+ ephy-home-action.c \
+ ephy-history-window.c \
+ ephy-link.c \
+ ephy-link-action.c \
+ ephy-location-action.c \
+ ephy-lockdown.c \
+ ephy-navigation-action.c \
+ ephy-navigation-history-action.c \
+ ephy-navigation-up-action.c \
+ ephy-notebook.c \
+ ephy-password-info.c \
+ ephy-session.c \
+ ephy-shell.c \
+ ephy-statusbar.c \
+ ephy-tabs-menu.c \
+ ephy-toolbars-model.c \
+ ephy-toolbar.c \
+ ephy-toolbar-editor.c \
+ ephy-window.c \
+ pdm-dialog.c \
+ popup-commands.c \
+ prefs-dialog.c \
+ window-commands.c \
+ $(INST_H_FILES) \
+ $(NOINST_H_FILES) \
$(NULL)
nodist_libephymain_la_SOURCES = \
diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c
index 35644ab0c..943126fbf 100644
--- a/src/ephy-navigation-action.c
+++ b/src/ephy-navigation-action.c
@@ -25,11 +25,8 @@
#include "ephy-navigation-action.h"
#include "ephy-debug.h"
-#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
-#include "ephy-embed-utils.h"
#include "ephy-favicon-cache.h"
-#include "ephy-gui.h"
#include "ephy-history.h"
#include "ephy-link.h"
#include "ephy-shell.h"
@@ -39,21 +36,11 @@
#include <gtk/gtk.h>
#include <webkit/webkit.h>
-#define HISTORY_ITEM_DATA_KEY "HistoryItem"
-#define URL_DATA_KEY "GoURL"
-
#define EPHY_NAVIGATION_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_NAVIGATION_ACTION, EphyNavigationActionPrivate))
-typedef enum
-{
- WEBKIT_HISTORY_BACKWARD,
- WEBKIT_HISTORY_FORWARD
-} WebKitHistoryType;
-
struct _EphyNavigationActionPrivate
{
EphyWindow *window;
- EphyNavigationDirection direction;
char *arrow_tooltip;
guint statusbar_cid;
};
@@ -62,7 +49,6 @@ enum
{
PROP_0,
PROP_ARROW_TOOLTIP,
- PROP_DIRECTION,
PROP_WINDOW
};
@@ -71,264 +57,15 @@ static void ephy_navigation_action_class_init (EphyNavigationActionClass *class)
G_DEFINE_TYPE (EphyNavigationAction, ephy_navigation_action, EPHY_TYPE_LINK_ACTION)
-#define MAX_LABEL_LENGTH 48
-
-static GtkWidget *
-new_history_menu_item (const char *origtext,
- const char *address)
-{
- EphyFaviconCache *cache;
- EphyHistory *history;
- GtkWidget *item, *image;
- GdkPixbuf *icon = NULL;
- GtkLabel *label;
- const char *icon_address;
-
- g_return_val_if_fail (address != NULL && origtext != NULL, NULL);
-
- item = gtk_image_menu_item_new_with_label (origtext);
-
- label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (item)));
- gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
- gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
-
- history = EPHY_HISTORY
- (ephy_embed_shell_get_global_history (embed_shell));
- icon_address = ephy_history_get_icon (history, address);
-
- cache = EPHY_FAVICON_CACHE
- (ephy_embed_shell_get_favicon_cache (embed_shell));
- icon = ephy_favicon_cache_get (cache, icon_address);
-
- if (icon != NULL)
- {
- image = gtk_image_new_from_pixbuf (icon);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
- gtk_widget_show (image);
- g_object_unref (icon);
- }
-
- gtk_widget_show (item);
-
- return item;
-}
-
-static void
-activate_back_or_forward_menu_item_cb (GtkWidget *menuitem,
- EphyNavigationAction *action)
-{
- WebKitWebHistoryItem *item;
- EphyEmbed *embed;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (action->priv->window));
- g_return_if_fail (embed != NULL);
-
- if (ephy_gui_is_middle_click ())
- {
- embed = ephy_link_open (EPHY_LINK (action), "about:blank", NULL,
- EPHY_LINK_NEW_TAB);
- g_return_if_fail (embed != NULL);
- }
-
- item = (WebKitWebHistoryItem*)g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY);
- g_return_if_fail (item != NULL);
-
- webkit_web_view_go_to_back_forward_item (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), item);
-}
-
-static void
-select_menu_item_cb (GtkWidget *menuitem,
- EphyNavigationAction *action)
-{
- const char *url;
- GtkWidget *statusbar;
- WebKitWebHistoryItem *item;
-
- item = (WebKitWebHistoryItem*)g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY);
- if (item)
- {
- url = webkit_web_history_item_get_uri (item);
- }
- else
- {
- url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY);
- g_return_if_fail (url != NULL);
- }
-
- statusbar = ephy_window_get_statusbar (action->priv->window);
-
- gtk_statusbar_push (GTK_STATUSBAR (statusbar), action->priv->statusbar_cid, url);
-}
-
-static void
-deselect_menu_item_cb (GtkWidget *menuitem,
- EphyNavigationAction *action)
-{
- GtkWidget *statusbar;
-
- statusbar = ephy_window_get_statusbar (action->priv->window);
-
- gtk_statusbar_pop (GTK_STATUSBAR (statusbar), action->priv->statusbar_cid);
-}
-
-static void
-activate_up_menu_item_cb (GtkWidget *menuitem,
- EphyNavigationAction *action)
-{
- EphyEmbed *embed;
- char *url;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (action->priv->window));
- g_return_if_fail (embed != NULL);
-
- url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY);
- g_return_if_fail (url != NULL);
-
- ephy_link_open (EPHY_LINK (action), url, NULL,
- ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
-}
-
-static GList*
-webkit_construct_history_list (WebKitWebView *web_view, WebKitHistoryType hist_type)
-{
- WebKitWebBackForwardList *web_back_forward_list;
- GList *webkit_items;
-
- web_back_forward_list = webkit_web_view_get_back_forward_list (web_view);
-
- if (hist_type == WEBKIT_HISTORY_FORWARD)
- webkit_items = g_list_reverse (webkit_web_back_forward_list_get_forward_list_with_limit (web_back_forward_list,
- EPHY_WEBKIT_BACK_FORWARD_LIMIT));
- else
- webkit_items = webkit_web_back_forward_list_get_back_list_with_limit (web_back_forward_list,
- EPHY_WEBKIT_BACK_FORWARD_LIMIT);
-
- return webkit_items;
-}
-
-static GtkWidget *
-build_back_or_forward_menu (EphyNavigationAction *action)
-{
- EphyWindow *window = action->priv->window;
- GtkMenuShell *menu;
- EphyEmbed *embed;
- GList *list, *l;
- WebKitWebView *web_view;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_val_if_fail (embed != NULL, NULL);
-
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- g_return_val_if_fail (web_view != NULL, NULL);
-
- if (action->priv->direction == EPHY_NAVIGATION_DIRECTION_BACK)
- list = webkit_construct_history_list (web_view,
- WEBKIT_HISTORY_BACKWARD);
- else
- list = webkit_construct_history_list (web_view,
- WEBKIT_HISTORY_FORWARD);
-
- menu = GTK_MENU_SHELL (gtk_menu_new ());
-
- l = list;
- for (l = list; l != NULL; l = l->next)
- {
- GtkWidget *item;
- WebKitWebHistoryItem *hitem;
- const char *url;
- char *title;
-
- hitem = (WebKitWebHistoryItem*)l->data;
- url = webkit_web_history_item_get_uri (hitem);
-
- title = g_strdup (webkit_web_history_item_get_title (hitem));
-
- if ((title == NULL || g_strstrip (title)[0] == '\0'))
- item = new_history_menu_item (url, url);
- else
- item = new_history_menu_item (title, url);
-
- g_free (title);
-
- g_object_set_data_full (G_OBJECT (item), HISTORY_ITEM_DATA_KEY,
- g_object_ref (hitem), g_object_unref);
-
- g_signal_connect (item, "activate",
- G_CALLBACK (activate_back_or_forward_menu_item_cb),
- action);
- g_signal_connect (item, "select",
- G_CALLBACK (select_menu_item_cb),
- action);
- g_signal_connect (item, "deselect",
- G_CALLBACK (deselect_menu_item_cb),
- action);
-
- gtk_menu_shell_append (menu, item);
- gtk_widget_show_all (item);
- }
-
- g_list_free (list);
-
- return GTK_WIDGET (menu);
-}
+#define MAX_LABEL_LENGTH 48
static GtkWidget *
-build_up_menu (EphyNavigationAction *action)
+build_dropdown_menu (EphyNavigationAction *action)
{
- EphyWindow *window = action->priv->window;
- EphyEmbed *embed;
- EphyHistory *history;
- GtkMenuShell *menu;
- GtkWidget *item;
- GSList *list, *l;
- char *url;
+ EphyNavigationActionClass *class = EPHY_NAVIGATION_ACTION_GET_CLASS (action);
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_val_if_fail (embed != NULL, NULL);
-
- menu = GTK_MENU_SHELL (gtk_menu_new ());
-
- history = EPHY_HISTORY
- (ephy_embed_shell_get_global_history (embed_shell));
-
- list = ephy_web_view_get_go_up_list (ephy_embed_get_web_view (embed));
-
- for (l = list; l != NULL; l = l->next)
- {
- EphyNode *node;
- const char *title = NULL;
-
- url = g_strdup (l->data);
-
- if (url == NULL) continue;
-
- node = ephy_history_get_page (history, url);
- if (node != NULL)
- {
- title = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_TITLE);
- }
-
- item = new_history_menu_item (title ? title : url, url);
-
- g_object_set_data_full (G_OBJECT (item), URL_DATA_KEY, url,
- (GDestroyNotify) g_free);
- g_signal_connect (item, "activate",
- G_CALLBACK (activate_up_menu_item_cb), action);
- g_signal_connect (item, "select",
- G_CALLBACK (select_menu_item_cb), action);
- g_signal_connect (item, "deselect",
- G_CALLBACK (deselect_menu_item_cb), action);
-
- gtk_menu_shell_append (menu, item);
- gtk_widget_show (item);
- }
-
- /* the list data has been consumed */
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
-
- return GTK_WIDGET (menu);
+ return class->build_dropdown_menu (action);
}
static void
@@ -337,22 +74,9 @@ menu_activated_cb (GtkMenuToolButton *button,
{
GtkWidget *menu = NULL;
- LOG ("menu_activated_cb dir %d", action->priv->direction);
-
- switch (action->priv->direction)
- {
- case EPHY_NAVIGATION_DIRECTION_UP:
- menu = build_up_menu (action);
- break;
- case EPHY_NAVIGATION_DIRECTION_FORWARD:
- case EPHY_NAVIGATION_DIRECTION_BACK:
- menu = build_back_or_forward_menu (action);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
+ LOG ("menu_activated_cb");
+ menu = build_dropdown_menu (action);
gtk_menu_tool_button_set_menu (button, menu);
}
@@ -382,75 +106,6 @@ connect_proxy (GtkAction *gaction,
}
static void
-ephy_navigation_action_activate (GtkAction *gtk_action)
-{
- EphyNavigationAction *action = EPHY_NAVIGATION_ACTION (gtk_action);
- EphyWindow *window = action->priv->window;
- EphyEmbed *embed;
- WebKitWebView *web_view;
-
- embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
- g_return_if_fail (embed != NULL);
-
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
-
- if (action->priv->direction == EPHY_NAVIGATION_DIRECTION_BACK)
- {
- if (ephy_gui_is_middle_click ())
- {
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
- embed,
- NULL,
- EPHY_NEW_TAB_IN_EXISTING_WINDOW);
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- }
- webkit_web_view_go_back (web_view);
- }
- else if (action->priv->direction == EPHY_NAVIGATION_DIRECTION_FORWARD)
- {
- if (ephy_gui_is_middle_click ())
- {
- const char *forward_uri;
- WebKitWebHistoryItem *forward_item;
- WebKitWebBackForwardList *history;
-
- /* Forward history is not copied when opening
- a new tab, so get the forward URI manually
- and load it */
- history = webkit_web_view_get_back_forward_list (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
- forward_item = webkit_web_back_forward_list_get_forward_item (history);
- forward_uri = webkit_web_history_item_get_original_uri (forward_item);
-
- embed = ephy_shell_new_tab (ephy_shell_get_default (),
- EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
- embed,
- NULL,
- EPHY_NEW_TAB_IN_EXISTING_WINDOW);
-
- web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
- webkit_web_view_load_uri (web_view, forward_uri);
- }
- else
- {
- webkit_web_view_go_forward (web_view);
- }
- }
- else if (action->priv->direction == EPHY_NAVIGATION_DIRECTION_UP)
- {
- GSList *up_list;
-
- up_list = ephy_web_view_get_go_up_list (ephy_embed_get_web_view (embed));
- ephy_link_open (EPHY_LINK (action),
- up_list->data,
- NULL,
- ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
- g_slist_foreach (up_list, (GFunc) g_free, NULL);
- g_slist_free (up_list);
- }
-}
-
-static void
ephy_navigation_action_init (EphyNavigationAction *action)
{
action->priv = EPHY_NAVIGATION_ACTION_GET_PRIVATE (action);
@@ -480,9 +135,6 @@ ephy_navigation_action_set_property (GObject *object,
nav->priv->arrow_tooltip = g_value_dup_string (value);
g_object_notify (object, "tooltip");
break;
- case PROP_DIRECTION:
- nav->priv->direction = g_value_get_int (value);
- break;
case PROP_WINDOW:
{
GtkWidget *statusbar;
@@ -513,9 +165,6 @@ ephy_navigation_action_get_property (GObject *object,
case PROP_ARROW_TOOLTIP:
g_value_set_string (value, nav->priv->arrow_tooltip);
break;
- case PROP_DIRECTION:
- g_value_set_int (value, nav->priv->direction);
- break;
case PROP_WINDOW:
g_value_set_object (value, nav->priv->window);
break;
@@ -534,7 +183,8 @@ ephy_navigation_action_class_init (EphyNavigationActionClass *class)
action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
action_class->connect_proxy = connect_proxy;
- action_class->activate = ephy_navigation_action_activate;
+
+ class->build_dropdown_menu = NULL;
g_object_class_install_property (object_class,
PROP_ARROW_TOOLTIP,
@@ -543,13 +193,6 @@ ephy_navigation_action_class_init (EphyNavigationActionClass *class)
G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
- PROP_DIRECTION,
- g_param_spec_int ("direction", NULL, NULL,
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
- g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window", NULL, NULL,
G_TYPE_OBJECT,
@@ -557,3 +200,59 @@ ephy_navigation_action_class_init (EphyNavigationActionClass *class)
g_type_class_add_private (object_class, sizeof (EphyNavigationActionPrivate));
}
+
+EphyWindow *
+_ephy_navigation_action_get_window (EphyNavigationAction *action)
+{
+ g_return_val_if_fail (EPHY_IS_NAVIGATION_ACTION (action), NULL);
+
+ return action->priv->window;
+}
+
+guint
+_ephy_navigation_action_get_statusbar_context_id (EphyNavigationAction *action)
+{
+ g_return_val_if_fail (EPHY_IS_NAVIGATION_ACTION (action), 0);
+
+ return action->priv->statusbar_cid;
+}
+
+GtkWidget *
+_ephy_navigation_action_new_history_menu_item (const char *origtext,
+ const char *address)
+{
+ EphyFaviconCache *cache;
+ EphyHistory *history;
+ GtkWidget *item, *image;
+ GdkPixbuf *icon = NULL;
+ GtkLabel *label;
+ const char *icon_address;
+
+ g_return_val_if_fail (address != NULL && origtext != NULL, NULL);
+
+ item = gtk_image_menu_item_new_with_label (origtext);
+
+ label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (item)));
+ gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
+
+ history = EPHY_HISTORY
+ (ephy_embed_shell_get_global_history (embed_shell));
+ icon_address = ephy_history_get_icon (history, address);
+
+ cache = EPHY_FAVICON_CACHE
+ (ephy_embed_shell_get_favicon_cache (embed_shell));
+ icon = ephy_favicon_cache_get (cache, icon_address);
+
+ if (icon != NULL)
+ {
+ image = gtk_image_new_from_pixbuf (icon);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
+ g_object_unref (icon);
+ }
+
+ gtk_widget_show (item);
+
+ return item;
+}
diff --git a/src/ephy-navigation-action.h b/src/ephy-navigation-action.h
index cac5cb995..d3f3cbfc4 100644
--- a/src/ephy-navigation-action.h
+++ b/src/ephy-navigation-action.h
@@ -26,6 +26,7 @@
#define EPHY_NAVIGATION_ACTION_H
#include "ephy-link-action.h"
+#include "ephy-window.h"
G_BEGIN_DECLS
@@ -40,17 +41,10 @@ typedef struct _EphyNavigationAction EphyNavigationAction;
typedef struct _EphyNavigationActionPrivate EphyNavigationActionPrivate;
typedef struct _EphyNavigationActionClass EphyNavigationActionClass;
-typedef enum
-{
- EPHY_NAVIGATION_DIRECTION_UP,
- EPHY_NAVIGATION_DIRECTION_BACK,
- EPHY_NAVIGATION_DIRECTION_FORWARD
-} EphyNavigationDirection;
-
struct _EphyNavigationAction
{
EphyLinkAction parent;
-
+
/*< private >*/
EphyNavigationActionPrivate *priv;
};
@@ -58,10 +52,21 @@ struct _EphyNavigationAction
struct _EphyNavigationActionClass
{
EphyLinkActionClass parent_class;
+
+ /*< virtual >*/
+ GtkWidget *(*build_dropdown_menu) (EphyNavigationAction *action);
};
GType ephy_navigation_action_get_type (void);
+/*< Protected >*/
+
+EphyWindow *_ephy_navigation_action_get_window (EphyNavigationAction *action);
+
+guint _ephy_navigation_action_get_statusbar_context_id (EphyNavigationAction *action);
+
+GtkWidget *_ephy_navigation_action_new_history_menu_item (const char *origtext,
+ const char *address);
G_END_DECLS
#endif
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
new file mode 100644
index 000000000..90345b2e6
--- /dev/null
+++ b/src/ephy-navigation-history-action.c
@@ -0,0 +1,359 @@
+/*
+ * Copyright © 2003, 2004 Marco Pesenti Gritti
+ * Copyright © 2003, 2004 Christian Persch
+ * Copyright © 2008 Jan Alonzo
+ * Copyright © 2009 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-navigation-history-action.h"
+
+#include "ephy-debug.h"
+#include "ephy-embed-container.h"
+#include "ephy-embed-shell.h"
+#include "ephy-embed-utils.h"
+#include "ephy-gui.h"
+#include "ephy-history.h"
+#include "ephy-link.h"
+#include "ephy-shell.h"
+#include "ephy-type-builtins.h"
+#include "ephy-window.h"
+
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#define HISTORY_ITEM_DATA_KEY "HistoryItem"
+
+#define EPHY_NAVIGATION_HISTORY_ACTION_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), \
+ EPHY_TYPE_NAVIGATION_HISTORY_ACTION, \
+ EphyNavigationHistoryActionPrivate))
+
+typedef enum {
+ WEBKIT_HISTORY_BACKWARD,
+ WEBKIT_HISTORY_FORWARD
+} WebKitHistoryType;
+
+struct _EphyNavigationHistoryActionPrivate {
+ EphyNavigationHistoryDirection direction;
+ EphyHistory *history;
+};
+
+enum {
+ PROP_0,
+ PROP_DIRECTION
+};
+
+static void ephy_navigation_history_action_init (EphyNavigationHistoryAction *action);
+static void ephy_navigation_history_action_class_init (EphyNavigationHistoryActionClass *klass);
+
+G_DEFINE_TYPE (EphyNavigationHistoryAction, ephy_navigation_history_action, EPHY_TYPE_NAVIGATION_ACTION)
+
+static void
+activate_back_or_forward_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationHistoryAction *action)
+{
+ WebKitWebHistoryItem *item;
+ EphyWindow *window;
+ EphyEmbed *embed;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ if (ephy_gui_is_middle_click ()) {
+ embed = ephy_link_open (EPHY_LINK (action), "about:blank", NULL,
+ EPHY_LINK_NEW_TAB);
+ g_return_if_fail (embed != NULL);
+ }
+
+ item = (WebKitWebHistoryItem*)g_object_get_data (G_OBJECT (menuitem),
+ HISTORY_ITEM_DATA_KEY);
+ g_return_if_fail (item != NULL);
+
+ webkit_web_view_go_to_back_forward_item (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), item);
+}
+
+static void
+select_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationHistoryAction *action)
+{
+ WebKitWebHistoryItem *item;
+
+ item = (WebKitWebHistoryItem*)g_object_get_data (G_OBJECT (menuitem),
+ HISTORY_ITEM_DATA_KEY);
+ if (item) {
+ const char *url;
+ EphyWindow *window;
+ EphyNavigationAction *nav_action;
+ GtkWidget *statusbar;
+ guint statusbar_cid;
+
+ url = webkit_web_history_item_get_uri (item);
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ statusbar = ephy_window_get_statusbar (window);
+
+ /* Update status bar */
+ nav_action = EPHY_NAVIGATION_ACTION (action);
+ statusbar_cid = _ephy_navigation_action_get_statusbar_context_id (nav_action);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), statusbar_cid, url);
+ }
+}
+
+static void
+deselect_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationAction *action)
+{
+ GtkWidget *statusbar;
+ EphyWindow *window;
+ EphyNavigationAction *nav_action;
+ guint statusbar_cid;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ statusbar = ephy_window_get_statusbar (window);
+
+ /* Update status bar */
+ nav_action = EPHY_NAVIGATION_ACTION (action);
+ statusbar_cid = _ephy_navigation_action_get_statusbar_context_id (nav_action);
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), statusbar_cid);
+}
+
+static GList*
+webkit_construct_history_list (WebKitWebView *web_view, WebKitHistoryType hist_type)
+{
+ WebKitWebBackForwardList *web_back_forward_list;
+ GList *webkit_items;
+
+ web_back_forward_list = webkit_web_view_get_back_forward_list (web_view);
+
+ if (hist_type == WEBKIT_HISTORY_FORWARD) {
+ webkit_items =
+ g_list_reverse (webkit_web_back_forward_list_get_forward_list_with_limit (web_back_forward_list,
+ EPHY_WEBKIT_BACK_FORWARD_LIMIT));
+ } else {
+ webkit_items =
+ webkit_web_back_forward_list_get_back_list_with_limit (web_back_forward_list,
+ EPHY_WEBKIT_BACK_FORWARD_LIMIT);
+ }
+
+ return webkit_items;
+}
+
+static GtkWidget *
+build_dropdown_menu (EphyNavigationAction *nav_action)
+{
+ EphyNavigationHistoryAction *action;
+ EphyWindow *window;
+ GtkMenuShell *menu;
+ EphyEmbed *embed;
+ GList *list, *l;
+ WebKitWebView *web_view;
+
+ action = EPHY_NAVIGATION_HISTORY_ACTION (nav_action);
+ window = _ephy_navigation_action_get_window (nav_action);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_val_if_fail (embed != NULL, NULL);
+
+ menu = GTK_MENU_SHELL (gtk_menu_new ());
+
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ g_return_val_if_fail (web_view != NULL, NULL);
+
+ if (action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_BACK) {
+ list = webkit_construct_history_list (web_view,
+ WEBKIT_HISTORY_BACKWARD);
+ } else {
+ list = webkit_construct_history_list (web_view,
+ WEBKIT_HISTORY_FORWARD);
+ }
+
+ for (l = list; l != NULL; l = l->next) {
+ GtkWidget *item;
+ WebKitWebHistoryItem *hitem;
+ const char *url;
+ char *title;
+
+ hitem = (WebKitWebHistoryItem*)l->data;
+ url = webkit_web_history_item_get_uri (hitem);
+
+ title = g_strdup (webkit_web_history_item_get_title (hitem));
+
+ if ((title == NULL || g_strstrip (title)[0] == '\0'))
+ item = _ephy_navigation_action_new_history_menu_item (url, url);
+ else
+ item = _ephy_navigation_action_new_history_menu_item (title, url);
+
+ g_free (title);
+
+ g_object_set_data_full (G_OBJECT (item), HISTORY_ITEM_DATA_KEY,
+ g_object_ref (hitem), g_object_unref);
+
+ g_signal_connect (item, "activate",
+ G_CALLBACK (activate_back_or_forward_menu_item_cb),
+ action);
+ g_signal_connect (item, "select",
+ G_CALLBACK (select_menu_item_cb),
+ action);
+ g_signal_connect (item, "deselect",
+ G_CALLBACK (deselect_menu_item_cb),
+ action);
+
+ gtk_menu_shell_append (menu, item);
+ gtk_widget_show_all (item);
+ }
+
+ g_list_free (list);
+
+ return GTK_WIDGET (menu);
+}
+
+static void
+action_activate (GtkAction *action)
+{
+ EphyNavigationHistoryAction *history_action;
+ EphyWindow *window;
+ EphyEmbed *embed;
+ WebKitWebView *web_view;
+
+ history_action = EPHY_NAVIGATION_HISTORY_ACTION (action);
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+
+ if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_BACK) {
+ if (ephy_gui_is_middle_click ()) {
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
+ embed,
+ NULL,
+ EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ }
+ webkit_web_view_go_back (web_view);
+ } else if (history_action->priv->direction == EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD) {
+ if (ephy_gui_is_middle_click ()) {
+ const char *forward_uri;
+ WebKitWebHistoryItem *forward_item;
+ WebKitWebBackForwardList *history;
+
+ /* Forward history is not copied when opening
+ a new tab, so get the forward URI manually
+ and load it */
+ history = webkit_web_view_get_back_forward_list (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
+ forward_item = webkit_web_back_forward_list_get_forward_item (history);
+ forward_uri = webkit_web_history_item_get_original_uri (forward_item);
+
+ embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
+ embed,
+ NULL,
+ EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+
+ web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+ webkit_web_view_load_uri (web_view, forward_uri);
+ } else {
+ webkit_web_view_go_forward (web_view);
+ }
+ }
+}
+
+static void
+ephy_navigation_history_action_init (EphyNavigationHistoryAction *action)
+{
+ EphyHistory *history;
+
+ action->priv = EPHY_NAVIGATION_HISTORY_ACTION_GET_PRIVATE (action);
+
+ history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
+ action->priv->history = EPHY_HISTORY (g_object_ref (history));
+}
+
+static void
+ephy_navigation_history_action_finalize (GObject *object)
+{
+ EphyNavigationHistoryAction *action = EPHY_NAVIGATION_HISTORY_ACTION (object);
+
+ g_object_unref (action->priv->history);
+ action->priv->history = NULL;
+
+ G_OBJECT_CLASS (ephy_navigation_history_action_parent_class)->finalize (object);
+}
+
+static void
+ephy_navigation_history_action_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNavigationHistoryAction *nav = EPHY_NAVIGATION_HISTORY_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_DIRECTION:
+ nav->priv->direction = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ephy_navigation_history_action_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyNavigationHistoryAction *nav = EPHY_NAVIGATION_HISTORY_ACTION (object);
+
+ switch (prop_id) {
+ case PROP_DIRECTION:
+ g_value_set_int (value, nav->priv->direction);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ephy_navigation_history_action_class_init (EphyNavigationHistoryActionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+ EphyNavigationActionClass *nav_action_class = EPHY_NAVIGATION_ACTION_CLASS (klass);
+
+ object_class->finalize = ephy_navigation_history_action_finalize;
+ object_class->set_property = ephy_navigation_history_action_set_property;
+ object_class->get_property = ephy_navigation_history_action_get_property;
+
+ action_class->activate = action_activate;
+
+ nav_action_class->build_dropdown_menu = build_dropdown_menu;
+
+ g_object_class_install_property (object_class,
+ PROP_DIRECTION,
+ g_param_spec_int ("direction", NULL, NULL,
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private (object_class, sizeof (EphyNavigationHistoryActionPrivate));
+}
diff --git a/src/ephy-navigation-history-action.h b/src/ephy-navigation-history-action.h
new file mode 100644
index 000000000..6388b4da3
--- /dev/null
+++ b/src/ephy-navigation-history-action.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2003, 2004 Marco Pesenti Gritti
+ * Copyright © 2003, 2004 Christian Persch
+ * Copyright © 2010, 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.
+ *
+ */
+
+#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
+#error "Only <epiphany/epiphany.h> can be included directly."
+#endif
+
+#ifndef EPHY_NAVIGATION_HISTORY_ACTION_H
+#define EPHY_NAVIGATION_HISTORY_ACTION_H
+
+#include "ephy-navigation-action.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_NAVIGATION_HISTORY_ACTION (ephy_navigation_history_action_get_type ())
+#define EPHY_NAVIGATION_HISTORY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_NAVIGATION_HISTORY_ACTION, EphyNavigationHistoryAction))
+#define EPHY_NAVIGATION_HISTORY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_NAVIGATION_HISTORY_ACTION, EphyNavigationHistoryActionClass))
+#define EPHY_IS_NAVIGATION_HISTORY_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_NAVIGATION_HISTORY_ACTION))
+#define EPHY_IS_NAVIGATION_HISTORY_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_NAVIGATION_HISTORY_ACTION))
+#define EPHY_NAVIGATION_HISTORY_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_NAVIGATION_HISTORY_ACTION, EphyNavigationHistoryActionClass))
+
+typedef enum
+{
+ EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
+ EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD
+} EphyNavigationHistoryDirection;
+
+typedef struct _EphyNavigationHistoryAction EphyNavigationHistoryAction;
+typedef struct _EphyNavigationHistoryActionPrivate EphyNavigationHistoryActionPrivate;
+typedef struct _EphyNavigationHistoryActionClass EphyNavigationHistoryActionClass;
+
+struct _EphyNavigationHistoryAction
+{
+ EphyNavigationAction parent;
+
+ /*< private >*/
+ EphyNavigationHistoryActionPrivate *priv;
+};
+
+struct _EphyNavigationHistoryActionClass
+{
+ EphyNavigationActionClass parent_class;
+};
+
+GType ephy_navigation_history_action_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/ephy-navigation-up-action.c b/src/ephy-navigation-up-action.c
new file mode 100644
index 000000000..8934a9efa
--- /dev/null
+++ b/src/ephy-navigation-up-action.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright © 2003, 2004 Marco Pesenti Gritti
+ * Copyright © 2003, 2004 Christian Persch
+ * Copyright © 2008 Jan Alonzo
+ * Copyright © 2009 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-navigation-up-action.h"
+
+#include "ephy-debug.h"
+#include "ephy-embed-container.h"
+#include "ephy-embed-shell.h"
+#include "ephy-embed-utils.h"
+#include "ephy-gui.h"
+#include "ephy-history.h"
+#include "ephy-link.h"
+#include "ephy-shell.h"
+#include "ephy-type-builtins.h"
+#include "ephy-window.h"
+
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#define URL_DATA_KEY "GoURL"
+
+static void ephy_navigation_up_action_init (EphyNavigationUpAction *action);
+static void ephy_navigation_up_action_class_init (EphyNavigationUpActionClass *klass);
+
+G_DEFINE_TYPE (EphyNavigationUpAction, ephy_navigation_up_action, EPHY_TYPE_NAVIGATION_ACTION)
+
+static void
+activate_up_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationUpAction *action)
+{
+ EphyWindow *window;
+ EphyEmbed *embed;
+ char *url;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY);
+ g_return_if_fail (url != NULL);
+
+ ephy_link_open (EPHY_LINK (action), url, NULL,
+ ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
+}
+
+static void
+select_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationUpAction *action)
+{
+ const char *url;
+ EphyWindow *window;
+ EphyNavigationAction *nav_action;
+ GtkWidget *statusbar;
+ guint statusbar_cid;
+
+ url = g_object_get_data (G_OBJECT (menuitem), URL_DATA_KEY);
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ statusbar = ephy_window_get_statusbar (window);
+ g_return_if_fail (url != NULL);
+
+ /* Update status bar */
+ nav_action = EPHY_NAVIGATION_ACTION (action);
+ statusbar_cid = _ephy_navigation_action_get_statusbar_context_id (nav_action);
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar), statusbar_cid, url);
+}
+
+static void
+deselect_menu_item_cb (GtkWidget *menuitem,
+ EphyNavigationAction *action)
+{
+ GtkWidget *statusbar;
+ EphyWindow *window;
+ EphyNavigationAction *nav_action;
+ guint statusbar_cid;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ statusbar = ephy_window_get_statusbar (window);
+
+ /* Update status bar */
+ nav_action = EPHY_NAVIGATION_ACTION (action);
+ statusbar_cid = _ephy_navigation_action_get_statusbar_context_id (nav_action);
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar), statusbar_cid);
+}
+
+static GtkWidget *
+build_dropdown_menu (EphyNavigationAction *nav_action)
+{
+ EphyNavigationUpAction *action;
+ EphyWindow *window;
+ EphyEmbed *embed;
+ EphyHistory *history;
+ GtkMenuShell *menu;
+ GtkWidget *item;
+ GSList *list, *l;
+ char *url;
+
+ action = EPHY_NAVIGATION_UP_ACTION (nav_action);
+ window = _ephy_navigation_action_get_window (nav_action);
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_val_if_fail (embed != NULL, NULL);
+
+ menu = GTK_MENU_SHELL (gtk_menu_new ());
+ history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
+
+ list = ephy_web_view_get_go_up_list (ephy_embed_get_web_view (embed));
+ for (l = list; l != NULL; l = l->next) {
+ EphyNode *node;
+ const char *title = NULL;
+
+ url = g_strdup (l->data);
+
+ if (url == NULL) continue;
+
+ node = ephy_history_get_page (history, url);
+ if (node != NULL) {
+ title = ephy_node_get_property_string (node, EPHY_NODE_PAGE_PROP_TITLE);
+ }
+
+ item = _ephy_navigation_action_new_history_menu_item (title ? title : url, url);
+
+ g_object_set_data_full (G_OBJECT (item), URL_DATA_KEY, url,
+ (GDestroyNotify) g_free);
+ g_signal_connect (item, "activate",
+ G_CALLBACK (activate_up_menu_item_cb), action);
+ g_signal_connect (item, "select",
+ G_CALLBACK (select_menu_item_cb),
+ action);
+ g_signal_connect (item, "deselect",
+ G_CALLBACK (deselect_menu_item_cb),
+ action);
+
+ gtk_menu_shell_append (menu, item);
+ gtk_widget_show (item);
+ }
+
+ /* the list data has been consumed */
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_slist_free (list);
+
+ return GTK_WIDGET (menu);
+}
+
+static void
+action_activate (GtkAction *action)
+{
+ EphyWindow *window;
+ EphyEmbed *embed;
+ GSList *up_list;
+
+ window = _ephy_navigation_action_get_window (EPHY_NAVIGATION_ACTION (action));
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+ g_return_if_fail (embed != NULL);
+
+ up_list = ephy_web_view_get_go_up_list (ephy_embed_get_web_view (embed));
+ ephy_link_open (EPHY_LINK (action),
+ up_list->data,
+ NULL,
+ ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
+ g_slist_foreach (up_list, (GFunc) g_free, NULL);
+ g_slist_free (up_list);
+}
+
+static void
+ephy_navigation_up_action_init (EphyNavigationUpAction *action)
+{
+}
+
+static void
+ephy_navigation_up_action_class_init (EphyNavigationUpActionClass *klass)
+{
+ GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
+ EphyNavigationActionClass *nav_action_class = EPHY_NAVIGATION_ACTION_CLASS (klass);
+
+ action_class->activate = action_activate;
+ nav_action_class->build_dropdown_menu = build_dropdown_menu;
+}
diff --git a/src/ephy-navigation-up-action.h b/src/ephy-navigation-up-action.h
new file mode 100644
index 000000000..66c19190f
--- /dev/null
+++ b/src/ephy-navigation-up-action.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2003, 2004 Marco Pesenti Gritti
+ * Copyright © 2003, 2004 Christian Persch
+ * Copyright © 2010, 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.
+ *
+ */
+
+#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
+#error "Only <epiphany/epiphany.h> can be included directly."
+#endif
+
+#ifndef EPHY_NAVIGATION_UP_ACTION_H
+#define EPHY_NAVIGATION_UP_ACTION_H
+
+#include "ephy-navigation-action.h"
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_NAVIGATION_UP_ACTION (ephy_navigation_up_action_get_type ())
+#define EPHY_NAVIGATION_UP_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_NAVIGATION_UP_ACTION, EphyNavigationUpAction))
+#define EPHY_NAVIGATION_UP_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_NAVIGATION_UP_ACTION, EphyNavigationUpActionClass))
+#define EPHY_IS_NAVIGATION_UP_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_NAVIGATION_UP_ACTION))
+#define EPHY_IS_NAVIGATION_UP_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EPHY_TYPE_NAVIGATION_UP_ACTION))
+#define EPHY_NAVIGATION_UP_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), EPHY_TYPE_NAVIGATION_UP_ACTION, EphyNavigationUpActionClass))
+
+typedef struct _EphyNavigationUpAction EphyNavigationUpAction;
+typedef struct _EphyNavigationUpActionClass EphyNavigationUpActionClass;
+
+struct _EphyNavigationUpAction
+{
+ EphyNavigationAction parent;
+};
+
+struct _EphyNavigationUpActionClass
+{
+ EphyNavigationActionClass parent_class;
+};
+
+GType ephy_navigation_up_action_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 9bb1e61e7..c82b93276 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -30,6 +30,8 @@
#include "ephy-location-entry.h"
#include "ephy-location-action.h"
#include "ephy-navigation-action.h"
+#include "ephy-navigation-history-action.h"
+#include "ephy-navigation-up-action.h"
#include "ephy-topic-action.h"
#include "ephy-zoom-action.h"
#include "ephy-spinner-tool-item.h"
@@ -226,7 +228,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
g_object_unref (priv->action_group);
action = priv->actions[BACK_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
"name", "NavigationBack",
"label", _("_Back"),
"stock_id", GTK_STOCK_GO_BACK,
@@ -236,7 +238,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
*/
"arrow-tooltip", _("Back history"),
"window", priv->window,
- "direction", EPHY_NAVIGATION_DIRECTION_BACK,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_BACK,
"is_important", TRUE,
NULL);
g_signal_connect_swapped (action, "open-link",
@@ -246,7 +248,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
g_object_unref (action);
action = priv->actions[FORWARD_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
+ g_object_new (EPHY_TYPE_NAVIGATION_HISTORY_ACTION,
"name", "NavigationForward",
"label", _("_Forward"),
"stock_id", GTK_STOCK_GO_FORWARD,
@@ -256,7 +258,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
*/
"arrow-tooltip", _("Forward history"),
"window", priv->window,
- "direction", EPHY_NAVIGATION_DIRECTION_FORWARD,
+ "direction", EPHY_NAVIGATION_HISTORY_DIRECTION_FORWARD,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);
@@ -265,7 +267,7 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
g_object_unref (action);
action = priv->actions[UP_ACTION] =
- g_object_new (EPHY_TYPE_NAVIGATION_ACTION,
+ g_object_new (EPHY_TYPE_NAVIGATION_UP_ACTION,
"name", "NavigationUp",
"label", _("_Up"),
"stock_id", GTK_STOCK_GO_UP,
@@ -275,7 +277,6 @@ ephy_toolbar_set_window (EphyToolbar *toolbar,
*/
"arrow-tooltip", _("List of upper levels"),
"window", priv->window,
- "direction", EPHY_NAVIGATION_DIRECTION_UP,
NULL);
g_signal_connect_swapped (action, "open-link",
G_CALLBACK (ephy_link_open), toolbar);