diff options
author | Xan Lopez <xan@src.gnome.org> | 2008-06-30 15:23:47 +0800 |
---|---|---|
committer | Xan Lopez <xan@src.gnome.org> | 2008-06-30 15:23:47 +0800 |
commit | faf45b0b6340ea93e9d4e8cfef7862885fc816c5 (patch) | |
tree | b2ed05f6b20d3d989858d910467e64e422d5ff39 | |
parent | 4a90a2c33e4dd205aed50cd89a18bca5a8721995 (diff) | |
download | gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar.gz gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar.bz2 gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar.lz gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar.xz gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.tar.zst gsoc2013-epiphany-faf45b0b6340ea93e9d4e8cfef7862885fc816c5.zip |
embed: remove ephy_embed_get_{backward,forward}_history.
Use WebKit APIs directly.
svn path=/trunk/; revision=8311
-rw-r--r-- | doc/reference/tmpl/ephy-embed.sgml | 2 | ||||
-rw-r--r-- | embed/ephy-embed.c | 32 | ||||
-rw-r--r-- | embed/ephy-embed.h | 4 | ||||
-rw-r--r-- | embed/webkit/webkit-embed.c | 47 | ||||
-rw-r--r-- | src/ephy-navigation-action.c | 65 |
5 files changed, 46 insertions, 104 deletions
diff --git a/doc/reference/tmpl/ephy-embed.sgml b/doc/reference/tmpl/ephy-embed.sgml index 4a17ca675..bea932651 100644 --- a/doc/reference/tmpl/ephy-embed.sgml +++ b/doc/reference/tmpl/ephy-embed.sgml @@ -327,8 +327,6 @@ be done by casting). @get_is_blank: @get_loading_title: @get_visibility: -@get_backward_history: -@get_forward_history: @get_next_history_item: @get_previous_history_item: @go_to_history_item: diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 29d7a0859..fd7e223f6 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -995,38 +995,6 @@ ephy_embed_get_visibility (EphyEmbed *embed) } /** - * ephy_embed_get_backward_history: - * @embed: an #EphyEmbed - * - * Returns a #GList of #EphyHistoryItem compromising the - * history items preceding the current location. - * - * Return value: a #GList with the preceding history items - **/ -GList* -ephy_embed_get_backward_history (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_backward_history (embed); -} - -/** - * ephy_embed_get_forward_history: - * @embed: an #EphyEmbed - * - * Returns a #GList of #EphyHistoryItem compromising the - * history items succeeding the current location. - * - * Return value: a #GList with the succeeding history items - **/ -GList* -ephy_embed_get_forward_history (EphyEmbed *embed) -{ - EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); - return iface->get_forward_history (embed); -} - -/** * ephy_embed_get_previous_history_item: * @embed: an #EphyEmbed * diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index ec8b4db65..b3da8da14 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -224,8 +224,6 @@ struct _EphyEmbedIface gboolean (* get_is_blank) (EphyEmbed *embed); const char * (* get_loading_title) (EphyEmbed *embed); gboolean (* get_visibility) (EphyEmbed *embed); - GList * (* get_backward_history) (EphyEmbed *embed); - GList * (* get_forward_history) (EphyEmbed *embed); EphyHistoryItem * (* get_next_history_item) (EphyEmbed *embed); EphyHistoryItem * (* get_previous_history_item) (EphyEmbed *embed); void (* go_to_history_item) (EphyEmbed *embed, @@ -354,8 +352,6 @@ void ephy_embed_close (EphyEmbed *embed); gboolean ephy_embed_has_modified_forms (EphyEmbed *embed); /* History */ -GList *ephy_embed_get_backward_history (EphyEmbed *embed); -GList *ephy_embed_get_forward_history (EphyEmbed *embed); EphyHistoryItem *ephy_embed_get_next_history_item (EphyEmbed *embed); EphyHistoryItem *ephy_embed_get_previous_history_item (EphyEmbed *embed); void ephy_embed_go_to_history_item (EphyEmbed *embed, EphyHistoryItem *history_item); diff --git a/embed/webkit/webkit-embed.c b/embed/webkit/webkit-embed.c index 7e48c56c2..ef6b677d8 100644 --- a/embed/webkit/webkit-embed.c +++ b/embed/webkit/webkit-embed.c @@ -45,8 +45,6 @@ static void ephy_embed_iface_init (EphyEmbedIface *iface); #define WEBKIT_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), WEBKIT_TYPE_EMBED, WebKitEmbedPrivate)) -#define WEBKIT_BACK_FORWARD_LIMIT 100 - typedef enum { WEBKIT_EMBED_LOAD_STARTED, @@ -71,34 +69,6 @@ struct WebKitEmbedPrivate EphyHistory *history; }; -static GList* -webkit_construct_history_list (WebKitEmbed *embed, WebKitHistoryType hist_type) -{ - WebKitWebBackForwardList *web_back_forward_list; - GList *webkit_items, *iter, *ephy_items = NULL; - - g_return_val_if_fail (WEBKIT_IS_EMBED (embed), NULL); - - web_back_forward_list = webkit_web_view_get_back_forward_list (embed->priv->web_view); - - if (hist_type == WEBKIT_HISTORY_FORWARD) - webkit_items = webkit_web_back_forward_list_get_forward_list_with_limit (web_back_forward_list, - WEBKIT_BACK_FORWARD_LIMIT); - else - webkit_items = webkit_web_back_forward_list_get_back_list_with_limit (web_back_forward_list, - WEBKIT_BACK_FORWARD_LIMIT); - - for (iter = webkit_items; iter != NULL; iter = iter->next) { - EphyHistoryItem *item = webkit_history_item_new (WEBKIT_WEB_HISTORY_ITEM (iter->data)); - if (item) - ephy_items = g_list_prepend (ephy_items, item); - } - - g_list_free (webkit_items); - - return ephy_items; -} - static EphyHistoryItem* webkit_construct_history_item (WebKitEmbed *embed, WebKitHistoryType hist_type) { @@ -506,21 +476,6 @@ impl_has_modified_forms (EphyEmbed *embed) return FALSE; } -static GList* -impl_get_backward_history (EphyEmbed *embed) -{ - return webkit_construct_history_list (WEBKIT_EMBED (embed), - WEBKIT_HISTORY_BACKWARD); -} - -static GList* -impl_get_forward_history (EphyEmbed *embed) -{ - return webkit_construct_history_list (WEBKIT_EMBED (embed), - WEBKIT_HISTORY_FORWARD); - -} - static EphyHistoryItem* impl_get_next_history_item (EphyEmbed *embed) { @@ -569,8 +524,6 @@ ephy_embed_iface_init (EphyEmbedIface *iface) iface->print_preview_navigate = impl_print_preview_navigate; iface->has_modified_forms = impl_has_modified_forms; iface->get_security_level = impl_get_security_level; - iface->get_backward_history = impl_get_backward_history; - iface->get_forward_history = impl_get_forward_history; iface->get_next_history_item = impl_get_next_history_item; iface->get_previous_history_item = impl_get_previous_history_item; iface->go_to_history_item = impl_go_to_history_item; diff --git a/src/ephy-navigation-action.c b/src/ephy-navigation-action.c index 7677f8598..d2b257675 100644 --- a/src/ephy-navigation-action.c +++ b/src/ephy-navigation-action.c @@ -2,6 +2,7 @@ /* * Copyright © 2003, 2004 Marco Pesenti Gritti * Copyright © 2003, 2004 Christian Persch + * Copyright © 2008 Jan Alonzo * * 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 @@ -36,12 +37,20 @@ #include "ephy-debug.h" #include <gtk/gtk.h> +#include <webkit/webkit.h> -#define HISTORY_ITEM_DATA_KEY "HistoryItem" -#define URL_DATA_KEY "GoURL" +#define HISTORY_ITEM_DATA_KEY "HistoryItem" +#define URL_DATA_KEY "GoURL" +#define WEBKIT_BACK_FORWARD_LIMIT 100 #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; @@ -132,16 +141,14 @@ static void select_menu_item_cb (GtkWidget *menuitem, EphyNavigationAction *action) { - char *url; + const char *url; GtkWidget *statusbar; - EphyHistoryItem *item; - char *freeme = NULL; + WebKitWebHistoryItem *item; - item = (EphyHistoryItem*)g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY); + item = (WebKitWebHistoryItem*)g_object_get_data (G_OBJECT (menuitem), HISTORY_ITEM_DATA_KEY); if (item) { - url = ephy_history_item_get_url (item); - freeme = url; + url = webkit_web_history_item_get_uri (item); } else { @@ -152,8 +159,6 @@ select_menu_item_cb (GtkWidget *menuitem, statusbar = ephy_window_get_statusbar (action->priv->window); gtk_statusbar_push (GTK_STATUSBAR (statusbar), action->priv->statusbar_cid, url); - - g_free (freeme); } static void @@ -184,6 +189,24 @@ activate_up_menu_item_cb (GtkWidget *menuitem, 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 = webkit_web_back_forward_list_get_forward_list_with_limit (web_back_forward_list, + WEBKIT_BACK_FORWARD_LIMIT); + else + webkit_items = webkit_web_back_forward_list_get_back_list_with_limit (web_back_forward_list, + WEBKIT_BACK_FORWARD_LIMIT); + + return webkit_items; +} + static GtkWidget * build_back_or_forward_menu (EphyNavigationAction *action) { @@ -191,14 +214,20 @@ build_back_or_forward_menu (EphyNavigationAction *action) 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 = ephy_embed_get_backward_history (embed); + list = webkit_construct_history_list (web_view, + WEBKIT_HISTORY_BACKWARD); else - list = ephy_embed_get_forward_history (embed); + list = webkit_construct_history_list (web_view, + WEBKIT_HISTORY_FORWARD); menu = GTK_MENU_SHELL (gtk_menu_new ()); @@ -207,17 +236,15 @@ build_back_or_forward_menu (EphyNavigationAction *action) for (l = list; l != NULL; l = l->next) { GtkWidget *item; - EphyHistoryItem *hitem; - char *title, *url; + WebKitWebHistoryItem *hitem; + const char *title, *url; - hitem = (EphyHistoryItem*)l->data; - url = ephy_history_item_get_url (hitem); - title = ephy_history_item_get_title (hitem); + hitem = (WebKitWebHistoryItem*)l->data; + url = webkit_web_history_item_get_uri (hitem); + title = webkit_web_history_item_get_title (hitem); item = new_history_menu_item (title ? title : url, url); - g_free (title); - g_object_set_data_full (G_OBJECT (item), HISTORY_ITEM_DATA_KEY, hitem, (GDestroyNotify) g_object_unref); |