aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2007-12-30 08:24:40 +0800
committerXan Lopez <xan@src.gnome.org>2007-12-30 08:24:40 +0800
commite63a085bb01b783057e0cba91725f3af884d3292 (patch)
tree233f547200605c4001be2972b40ba516f976ce46
parent2a776b7f4ea30e814b2703a50633143b5b0ebc95 (diff)
downloadgsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar.gz
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar.bz2
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar.lz
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar.xz
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.tar.zst
gsoc2013-epiphany-e63a085bb01b783057e0cba91725f3af884d3292.zip
Port ephy-window.c to the new API, remove old API.
Closes bug #506005 svn path=/trunk/; revision=7836
-rw-r--r--embed/ephy-embed.c75
-rw-r--r--embed/ephy-embed.h22
-rw-r--r--embed/mozilla/mozilla-embed.cpp59
-rw-r--r--src/ephy-window.c22
-rw-r--r--src/epiphany.defs33
-rw-r--r--src/epiphany.override54
6 files changed, 19 insertions, 246 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 48fcee4e9..267b353fc 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -677,81 +677,6 @@ ephy_embed_scroll_pixels (EphyEmbed *embed,
}
/**
- * ephy_embed_shistory_n_items:
- * @embed: an #EphyEmbed
- *
- * Returns the number of items in @embed's history. In other words, returns the
- * number of pages @embed has visited.
- *
- * The number is upper-bound by Mozilla's browser.sessionhistory.max_entries
- * preference.
- *
- * Return value: the number of items in @embed's history
- **/
-int
-ephy_embed_shistory_n_items (EphyEmbed *embed)
-{
- EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- return iface->shistory_n_items (embed);
-}
-
-/**
- * ephy_embed_shistory_get_nth:
- * @embed: an #EphyEmbed
- * @nth: index of the desired page in @embed's browser history
- * @is_relative: if %TRUE, add @embed's current history position to @nth
- * @url: returned value of the history entry's URL
- * @title: returned value of the history entry's title
- *
- * Fetches the @url and @title of the @nth item in @embed's session history.
- * If @is_relative is %TRUE, @nth is an offset from the browser's current
- * history position. For example, calling this function with @is_relative %TRUE
- * and @nth %0 will return the URL and title of the current page.
- **/
-void
-ephy_embed_shistory_get_nth (EphyEmbed *embed,
- int nth,
- gboolean is_relative,
- char **url,
- char **title)
-{
- EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- iface->shistory_get_nth (embed, nth, is_relative, url, title);
-}
-
-/**
- * ephy_embed_shistory_get_pos:
- * @embed: an #EphyEmbed
- *
- * Returns @embed's current position in its history. If the user never uses the
- * "Back" button, this number will be the same as the return value of
- * ephy_embed_shistory_n_items().
- *
- * Return value: @embed's current position in its history
- **/
-int
-ephy_embed_shistory_get_pos (EphyEmbed *embed)
-{
- EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- return iface->shistory_get_pos (embed);
-}
-
-/**
- * ephy_embed_shistory_go_nth:
- * @embed: an #EphyEmbed
- * @nth: desired history index
- *
- * Opens the webpage at location @nth in @embed's history.
- **/
-void
-ephy_embed_shistory_go_nth (EphyEmbed *embed,
- int nth)
-{
- EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
- iface->shistory_go_nth (embed, nth);
-}
-
-/**
* ephy_embed_shistory_copy:
* @source: the #EphyEmbed to copy the history from
* @dest: the #EphyEmbed to copy the history to
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 35f28240e..560a2f9cd 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -178,15 +178,6 @@ struct _EphyEmbedIface
gboolean toplevel);
const char * (* get_link_message) (EphyEmbed *embed);
char * (* get_js_status) (EphyEmbed *embed);
- int (* shistory_n_items) (EphyEmbed *embed);
- void (* shistory_get_nth) (EphyEmbed *embed,
- int nth,
- gboolean is_relative,
- char **url,
- char **title);
- int (* shistory_get_pos) (EphyEmbed *embed);
- void (* shistory_go_nth) (EphyEmbed *embed,
- int nth);
void (* shistory_copy) (EphyEmbed *source,
EphyEmbed *dest,
gboolean copy_back,
@@ -290,19 +281,6 @@ void ephy_embed_go_forward (EphyEmbed *embed);
void ephy_embed_go_up (EphyEmbed *embed);
-int ephy_embed_shistory_n_items (EphyEmbed *embed);
-
-void ephy_embed_shistory_get_nth (EphyEmbed *embed,
- int nth,
- gboolean is_relative,
- char **url,
- char **title);
-
-int ephy_embed_shistory_get_pos (EphyEmbed *embed);
-
-void ephy_embed_shistory_go_nth (EphyEmbed *embed,
- int nth);
-
void ephy_embed_shistory_copy (EphyEmbed *source,
EphyEmbed *dest,
gboolean copy_back,
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index b9badb6b2..d8ffc136b 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -669,43 +669,6 @@ impl_shistory_n_items (EphyEmbed *embed)
return NS_SUCCEEDED(rv) ? count : 0;
}
-static void
-impl_shistory_get_nth (EphyEmbed *embed,
- int nth,
- gboolean is_relative,
- char **aUrl,
- char **aTitle)
-{
- nsresult rv;
- nsCString url;
- PRUnichar *title;
- MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
-
- if (is_relative)
- {
- nth += ephy_embed_shistory_get_pos (embed);
- }
-
- rv = mpriv->browser->GetSHUrlAtIndex(nth, url);
-
- *aUrl = (NS_SUCCEEDED (rv) && url.Length()) ? g_strdup(url.get()) : NULL;
-
- rv = mpriv->browser->GetSHTitleAtIndex(nth, &title);
-
- if (title)
- {
- nsCString cTitle;
- NS_UTF16ToCString (nsString(title),
- NS_CSTRING_ENCODING_UTF8, cTitle);
- *aTitle = g_strdup (cTitle.get());
- nsMemory::Free (title);
- }
- else
- {
- *aTitle = NULL;
- }
-}
-
static int
impl_shistory_get_pos (EphyEmbed *embed)
{
@@ -719,15 +682,6 @@ impl_shistory_get_pos (EphyEmbed *embed)
}
static void
-impl_shistory_go_nth (EphyEmbed *embed,
- int nth)
-{
- MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
-
- mpriv->browser->GoToHistoryIndex (nth);
-}
-
-static void
impl_shistory_copy (EphyEmbed *source,
EphyEmbed *dest,
gboolean copy_back,
@@ -882,12 +836,19 @@ mozilla_get_nth_history_item (MozillaEmbed *embed,
gboolean is_relative,
int nth)
{
+ EphyHistoryItem *item = NULL;
+
if (is_relative)
{
nth += impl_shistory_get_pos (EPHY_EMBED (embed));
}
- return (EphyHistoryItem*)mozilla_history_item_new (embed, nth);
+ if (nth >= 0 && nth <= impl_shistory_n_items (EPHY_EMBED (embed)))
+ {
+ item = (EphyHistoryItem*)mozilla_history_item_new (embed, nth);
+ }
+
+ return item;
}
static GList*
@@ -1448,10 +1409,6 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
iface->scroll_lines = impl_scroll_lines;
iface->scroll_pages = impl_scroll_pages;
iface->scroll_pixels = impl_scroll_pixels;
- iface->shistory_n_items = impl_shistory_n_items;
- iface->shistory_get_nth = impl_shistory_get_nth;
- iface->shistory_get_pos = impl_shistory_get_pos;
- iface->shistory_go_nth = impl_shistory_go_nth;
iface->shistory_copy = impl_shistory_copy;
iface->show_page_certificate = impl_show_page_certificate;
iface->close = impl_close;
diff --git a/src/ephy-window.c b/src/ephy-window.c
index b7d4d4be7..ef8935bea 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1590,10 +1590,9 @@ sync_tab_navigation (EphyEmbed *embed,
EphyWindow *window)
{
EphyEmbedNavigationFlags flags;
+ EphyHistoryItem *item;
gboolean up = FALSE, back = FALSE, forward = FALSE;
- char *back_url = NULL, *forward_url = NULL;
char *back_title = NULL, *forward_title = NULL;
- gint position;
if (window->priv->closing) return;
@@ -1615,18 +1614,21 @@ sync_tab_navigation (EphyEmbed *embed,
ephy_toolbar_set_navigation_actions (window->priv->toolbar,
back, forward, up);
- position = ephy_embed_shistory_get_pos (embed);
+ item = ephy_embed_get_previous_history_item (embed);
- if (position > 0)
+ if (item)
{
- ephy_embed_shistory_get_nth (embed, -1, TRUE,
- &back_url, &back_title);
+ back_title = ephy_history_item_get_title (item);
+ g_object_unref (item);
}
- if (position < ephy_embed_shistory_n_items (embed) - 1)
+
+ item = ephy_embed_get_next_history_item (embed);
+
+ if (item)
{
- ephy_embed_shistory_get_nth (embed, 1, TRUE,
- &forward_url, &forward_title);
+ forward_title = ephy_history_item_get_title (item);
+ g_object_unref (item);
}
ephy_toolbar_set_navigation_tooltips (window->priv->toolbar,
@@ -1634,9 +1636,7 @@ sync_tab_navigation (EphyEmbed *embed,
forward_title);
g_free (back_title);
- g_free (back_url);
g_free (forward_title);
- g_free (forward_url);
}
static void
diff --git a/src/epiphany.defs b/src/epiphany.defs
index 0317bf28b..d7a7747e1 100644
--- a/src/epiphany.defs
+++ b/src/epiphany.defs
@@ -1196,39 +1196,6 @@
(return-type "none")
)
-(define-method shistory_n_items
- (of-object "EphyEmbed")
- (c-name "ephy_embed_shistory_n_items")
- (return-type "int")
-)
-
-(define-method shistory_get_nth
- (of-object "EphyEmbed")
- (c-name "ephy_embed_shistory_get_nth")
- (return-type "none")
- (parameters
- '("int" "nth")
- '("gboolean" "is_relative")
- '("char**" "url")
- '("char**" "title")
- )
-)
-
-(define-method shistory_get_pos
- (of-object "EphyEmbed")
- (c-name "ephy_embed_shistory_get_pos")
- (return-type "int")
-)
-
-(define-method shistory_go_nth
- (of-object "EphyEmbed")
- (c-name "ephy_embed_shistory_go_nth")
- (return-type "none")
- (parameters
- '("int" "nth")
- )
-)
-
(define-method shistory_copy
(of-object "EphyEmbed")
(c-name "ephy_embed_shistory_copy")
diff --git a/src/epiphany.override b/src/epiphany.override
index f669da9c4..44b60d66d 100644
--- a/src/epiphany.override
+++ b/src/epiphany.override
@@ -270,60 +270,6 @@ _wrap_ephy_window_get_tabs(PyGObject *self)
return py_list;
}
%%
-override ephy_embed_shistory_get_nth kwargs
-static PyObject*
-_wrap_ephy_embed_shistory_get_nth (PyGObject *self,
- PyObject *args, PyObject *kwargs)
-{
- static char *kwlist[] = {"nth", "is_relative", NULL};
- int nth, is_relative;
- char *url, *title;
- PyObject *py_url, *py_title;
- PyObject *py_list;
-
- if (!PyArg_ParseTupleAndKeywords(args, kwargs,
- "ii:EphyEmbed.shistory_get_nth", kwlist,
- &nth, &is_relative)) {
- return NULL;
- }
-
- ephy_embed_shistory_get_nth (EPHY_EMBED (self->obj), nth, is_relative,
- &url, &title);
-
- if (!url || !title) {
- return Py_None;
- }
-
- if ((py_list = PyList_New(0)) == NULL) {
- g_free (url);
- g_free (title);
- return NULL;
- }
-
- py_url = PyString_FromString (url);
- g_free (url);
- if (!py_url) {
- g_free (title);
- Py_DECREF(py_list);
- return NULL;
- }
-
- PyList_Append(py_list, py_url);
- Py_DECREF(py_url);
-
- py_title = PyString_FromString (title);
- g_free (title);
-
- if (!py_title) {
- Py_DECREF(py_list);
- return NULL;
- }
-
- PyList_Append(py_list, py_title);
- Py_DECREF(py_title);
- return py_list;
-}
-%%
override ephy_embed_get_go_up_list noargs
static PyObject*
_wrap_ephy_embed_get_go_up_list (PyGObject *self)