aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-03-05 23:57:45 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:45 +0800
commit9666dba09d79cd88777e9066dbdb2ca5b5e7588f (patch)
tree0ef70074aa9f6bf5875440b6fc371083c9cd47e3 /embed
parent222b98ba6644addc080cccbd536d9b90bc27d3ba (diff)
downloadgsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar.gz
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar.bz2
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar.lz
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar.xz
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.tar.zst
gsoc2013-epiphany-9666dba09d79cd88777e9066dbdb2ca5b5e7588f.zip
Get rid of EphyBrowseHistory
It was a very thin wrapper on top of the history service, it does not seem to make much sense. For now move the two useful helper methods down to the service without further changes.
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am2
-rw-r--r--embed/ephy-browse-history.c182
-rw-r--r--embed/ephy-browse-history.h86
-rw-r--r--embed/ephy-embed-shell.c28
-rw-r--r--embed/ephy-embed-shell.h2
-rw-r--r--embed/ephy-embed.c29
-rw-r--r--embed/ephy-web-view.c6
7 files changed, 40 insertions, 295 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 44803fdc8..8476bfc39 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -26,7 +26,6 @@ INST_H_FILES = \
ephy-embed-shell.h \
ephy-embed-utils.h \
ephy-history.h \
- ephy-browse-history.h \
ephy-permission-manager.h \
ephy-web-view.h
@@ -49,7 +48,6 @@ libephyembed_la_SOURCES = \
ephy-encodings.c \
ephy-favicon-cache.c \
ephy-history.c \
- ephy-browse-history.c \
ephy-permission-manager.c \
ephy-request-about.c \
ephy-embed-prefs.c \
diff --git a/embed/ephy-browse-history.c b/embed/ephy-browse-history.c
deleted file mode 100644
index c6a0669c6..000000000
--- a/embed/ephy-browse-history.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/* vim: set sw=2 ts=2 sts=2 et: */
-/*
- * Copyright © 2011, 2012 Igalia S.L.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "ephy-browse-history.h"
-
-#include "ephy-file-helpers.h"
-#include "ephy-request-about.h"
-
-G_DEFINE_TYPE (EphyBrowseHistory, ephy_browse_history, G_TYPE_OBJECT)
-
-#define EPHY_BROWSE_HISTORY_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EPHY_TYPE_BROWSE_HISTORY, EphyBrowseHistoryPrivate))
-
-struct _EphyBrowseHistoryPrivate {
- EphyHistoryService *history_service;
-};
-
-static void
-ephy_browse_history_dispose (GObject *object)
-{
- EphyBrowseHistory *history = EPHY_BROWSE_HISTORY (object);
-
- g_clear_object (&history->priv->history_service);
-
- G_OBJECT_CLASS (ephy_browse_history_parent_class)->dispose (object);
-}
-
-static void
-ephy_browse_history_class_init (EphyBrowseHistoryClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (EphyBrowseHistoryPrivate));
-
- object_class->dispose = ephy_browse_history_dispose;
-}
-
-static void
-ephy_browse_history_init (EphyBrowseHistory *history)
-{
- gchar *filename;
-
- history->priv = EPHY_BROWSE_HISTORY_PRIVATE (history);
-
- filename = g_build_filename (ephy_dot_dir (), "ephy-history.db", NULL);
- history->priv->history_service = ephy_history_service_new (filename);
- g_free (filename);
-}
-
-EphyBrowseHistory *
-ephy_browse_history_new (void)
-{
- return g_object_new (EPHY_TYPE_BROWSE_HISTORY, NULL);
-}
-
-void
-ephy_browse_history_add_page (EphyBrowseHistory *history,
- const char *orig_url)
-{
- EphyHistoryPageVisit *visit;
- char *url;
-
- if (g_str_has_prefix (orig_url, EPHY_ABOUT_SCHEME))
- url = g_strdup_printf ("about:%s", orig_url + EPHY_ABOUT_SCHEME_LEN + 1);
- else
- url = g_strdup (orig_url);
-
- visit = ephy_history_page_visit_new (url,
- time (NULL),
- EPHY_PAGE_VISIT_TYPED);
- ephy_history_service_add_visit (history->priv->history_service,
- visit, NULL, NULL);
- ephy_history_page_visit_free (visit);
-}
-
-void
-ephy_browse_history_set_page_title (EphyBrowseHistory *history,
- const char *url,
- const char *title)
-{
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
- g_return_if_fail (url != NULL);
-
- ephy_history_service_set_url_title (history->priv->history_service,
- url,
- title,
- NULL, NULL);
-}
-
-void
-ephy_browse_history_set_page_zoom_level (EphyBrowseHistory *history,
- const char *url,
- const double zoom_level)
-{
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
- g_return_if_fail (url != NULL);
-
- ephy_history_service_set_url_zoom_level (history->priv->history_service,
- url,
- zoom_level,
- NULL, NULL);
-}
-
-void
-ephy_browse_history_get_url (EphyBrowseHistory *history,
- const char *url,
- EphyHistoryJobCallback callback,
- gpointer user_data)
-{
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
- g_return_if_fail (url != NULL);
-
- ephy_history_service_get_url (history->priv->history_service,
- url, callback, user_data);
-}
-
-void
-ephy_browse_history_find_urls (EphyBrowseHistory *history,
- gint64 from, gint64 to,
- guint limit,
- GList *substring_list,
- EphyHistoryJobCallback callback,
- gpointer user_data)
-{
- EphyHistoryQuery *query;
-
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
-
- query = ephy_history_query_new ();
- query->from = from;
- query->to = to;
- query->substring_list = substring_list;
- query->sort_type = EPHY_HISTORY_SORT_MV;
-
- if (limit != 0)
- query->limit = limit;
-
- ephy_history_service_query_urls (history->priv->history_service,
- query, callback, user_data);
-}
-
-void
-ephy_browse_history_delete_urls (EphyBrowseHistory *history,
- GList *urls,
- EphyHistoryJobCallback callback,
- gpointer user_data)
-{
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
-
- ephy_history_service_delete_urls (history->priv->history_service,
- urls, callback, user_data);
-}
-
-void
-ephy_browse_history_get_host_for_url (EphyBrowseHistory *history,
- const char *url,
- EphyHistoryJobCallback callback,
- gpointer user_data)
-{
- g_return_if_fail (EPHY_IS_BROWSE_HISTORY (history));
-
- ephy_history_service_get_host_for_url (history->priv->history_service,
- url, callback, user_data);
-}
diff --git a/embed/ephy-browse-history.h b/embed/ephy-browse-history.h
deleted file mode 100644
index bbab28c98..000000000
--- a/embed/ephy-browse-history.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/* vim: set sw=2 ts=2 sts=2 et: */
-/*
- * Copyright © 2011, 2012 Igalia S.L.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
-#error "Only <epiphany/epiphany.h> can be included directly."
-#endif
-
-#ifndef _EPHY_BROWSE_HISTORY_H
-#define _EPHY_BROWSE_HISTORY_H
-
-#include "ephy-history-service.h"
-
-G_BEGIN_DECLS
-
-#define EPHY_TYPE_BROWSE_HISTORY (ephy_browse_history_get_type())
-#define EPHY_BROWSE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_BROWSE_HISTORY, EphyBrowseHistory))
-#define EPHY_BROWSE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EPHY_TYPE_BROWSE_HISTORY, EphyBrowseHistoryClass))
-#define EPHY_IS_BROWSE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EPHY_TYPE_BROWSE_HISTORY))
-#define EPHY_IS_BROWSE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EPHY_TYPE_BROWSE_HISTORY))
-#define EPHY_BROWSE_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EPHY_TYPE_BROWSE_HISTORY, EphyBrowseHistoryClass))
-
-typedef struct _EphyBrowseHistory EphyBrowseHistory;
-typedef struct _EphyBrowseHistoryClass EphyBrowseHistoryClass;
-typedef struct _EphyBrowseHistoryPrivate EphyBrowseHistoryPrivate;
-
-struct _EphyBrowseHistory {
- GObject parent;
-
- EphyBrowseHistoryPrivate *priv;
-};
-
-struct _EphyBrowseHistoryClass {
- GObjectClass parent_class;
-};
-
-GType ephy_browse_history_get_type (void) G_GNUC_CONST;
-EphyBrowseHistory *ephy_browse_history_new (void);
-void ephy_browse_history_add_page (EphyBrowseHistory *history,
- const char *orig_url);
-void ephy_browse_history_set_page_title (EphyBrowseHistory *history,
- const char *url,
- const char *title);
-void ephy_browse_history_set_page_zoom_level (EphyBrowseHistory *history,
- const char *url,
- const double zoom_level);
-void ephy_browse_history_get_url (EphyBrowseHistory *history,
- const char *url,
- EphyHistoryJobCallback callback,
- gpointer user_data);
-void ephy_browse_history_find_urls (EphyBrowseHistory *history,
- gint64 from,
- gint64 to,
- guint limit,
- GList *substring_list,
- EphyHistoryJobCallback callback,
- gpointer user_data);
-void ephy_browse_history_delete_urls (EphyBrowseHistory *history,
- GList *urls,
- EphyHistoryJobCallback callback,
- gpointer user_data);
-void ephy_browse_history_get_host_for_url (EphyBrowseHistory *history,
- const char *url,
- EphyHistoryJobCallback callback,
- gpointer user_data);
-
-G_END_DECLS
-
-#endif /* _EPHY_BROWSE_HISTORY_H */
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 63fe5c1d3..cda96e2e0 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -37,8 +37,7 @@
#include "ephy-favicon-cache.h"
#include "ephy-file-helpers.h"
#include "ephy-history.h"
-#include "ephy-browse-history.h"
-
+#include "ephy-history-service.h"
#include "ephy-print-utils.h"
#define PAGE_SETUP_FILENAME "page-setup-gtk.ini"
@@ -53,7 +52,7 @@
struct _EphyEmbedShellPrivate
{
EphyHistory *global_history;
- EphyBrowseHistory *global_browse_history;
+ EphyHistoryService *global_history_service;
GList *downloads;
EphyFaviconCache *favicon_cache;
EphyEmbedSingle *embed_single;
@@ -145,10 +144,10 @@ ephy_embed_shell_finalize (GObject *object)
g_object_unref (shell->priv->global_history);
}
- if (shell->priv->global_browse_history)
+ if (shell->priv->global_history_service)
{
- LOG ("Unref browse history");
- g_object_unref (shell->priv->global_browse_history);
+ LOG ("Unref history service");
+ g_object_unref (shell->priv->global_history_service);
}
if (shell->priv->embed_single)
@@ -208,22 +207,27 @@ ephy_embed_shell_get_global_history (EphyEmbedShell *shell)
}
/**
- * ephy_embed_shell_get_global_browse_history:
+ * ephy_embed_shell_get_global_history_service:
* @shell: the #EphyEmbedShell
*
- * Return value: (transfer none):
+ * Return value: (transfer none): the global #EphyHistoryService
**/
GObject *
-ephy_embed_shell_get_global_browse_history (EphyEmbedShell *shell)
+ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell)
{
g_return_val_if_fail (EPHY_IS_EMBED_SHELL (shell), NULL);
- if (shell->priv->global_browse_history == NULL)
+ if (shell->priv->global_history_service == NULL)
{
- shell->priv->global_browse_history = ephy_browse_history_new ();
+ char *filename;
+
+ filename = g_build_filename (ephy_dot_dir (), "ephy-history.db", NULL);
+ shell->priv->global_history_service = ephy_history_service_new (filename);
+ g_free (filename);
+ g_return_val_if_fail (shell->priv->global_history_service, NULL);
}
- return G_OBJECT (shell->priv->global_browse_history);
+ return G_OBJECT (shell->priv->global_history_service);
}
static GObject *
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index a31d290e5..4bab3a4ed 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -83,7 +83,7 @@ GObject *ephy_embed_shell_get_favicon_cache (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_global_history (EphyEmbedShell *shell);
-GObject *ephy_embed_shell_get_global_browse_history (EphyEmbedShell *shell);
+GObject *ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_encodings (EphyEmbedShell *shell);
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index b9f1f46d6..a64f154ca 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -36,9 +36,10 @@
#include "ephy-embed-utils.h"
#include "ephy-file-helpers.h"
#include "ephy-history.h"
-#include "ephy-browse-history.h"
+#include "ephy-history-service.h"
#include "ephy-history-types.h"
#include "ephy-prefs.h"
+#include "ephy-request-about.h"
#include "ephy-settings.h"
#include "ephy-string.h"
#include "ephy-web-view.h"
@@ -72,7 +73,7 @@ struct _EphyEmbedPrivate
GtkPaned *paned;
WebKitWebView *web_view;
EphyHistory *history;
- EphyBrowseHistory *browse_history;
+ EphyHistoryService *history_service;
GtkWidget *inspector_window;
GtkWidget *inspector_web_view;
GtkWidget *inspector_scrolled_window;
@@ -267,9 +268,9 @@ restore_zoom_level (EphyEmbed *embed,
{
/* restore zoom level */
if (ephy_embed_utils_address_has_web_scheme (address)) {
- ephy_browse_history_get_host_for_url (embed->priv->browse_history,
- address,
- (EphyHistoryJobCallback)get_host_for_url_cb, embed);
+ ephy_history_service_get_host_for_url (embed->priv->history_service,
+ address,
+ (EphyHistoryJobCallback)get_host_for_url_cb, embed);
}
}
@@ -324,13 +325,22 @@ load_status_changed_cb (WebKitWebView *view,
if (status == WEBKIT_LOAD_COMMITTED) {
const gchar* uri;
+ char *history_uri;
uri = webkit_web_view_get_uri (view);
ephy_embed_destroy_top_widgets (embed);
restore_zoom_level (embed, uri);
- ephy_browse_history_add_page (embed->priv->browse_history, uri);
+
+ /* TODO: move the normaliztion down to the history service? */
+ if (g_str_has_prefix (uri, EPHY_ABOUT_SCHEME))
+ history_uri = g_strdup_printf ("about:%s", uri + EPHY_ABOUT_SCHEME_LEN + 1);
+ else
+ history_uri = g_strdup (uri);
+
+ ephy_history_service_add_page (embed->priv->history_service, history_uri);
+ g_free (history_uri);
}
}
@@ -352,8 +362,9 @@ zoom_changed_cb (WebKitWebView *web_view,
address = ephy_web_view_get_location (EPHY_WEB_VIEW (web_view), TRUE);
if (ephy_embed_utils_address_has_web_scheme (address)) {
- ephy_browse_history_set_page_zoom_level (embed->priv->browse_history,
- address, zoom);
+ ephy_history_service_set_url_zoom_level (embed->priv->history_service,
+ address, zoom,
+ NULL, NULL);
}
g_free (address);
@@ -815,7 +826,7 @@ ephy_embed_constructed (GObject *object)
ephy_embed_prefs_add_embed (embed);
priv->history = EPHY_HISTORY (ephy_embed_shell_get_global_history (ephy_embed_shell_get_default ()));
- priv->browse_history = EPHY_BROWSE_HISTORY (ephy_embed_shell_get_global_browse_history (ephy_embed_shell_get_default ()));
+ priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ()));
g_signal_connect (priv->history,
"cleared", G_CALLBACK (ephy_embed_history_cleared_cb),
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 6d4aedaa1..eb8dbc361 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -24,7 +24,6 @@
#include "ephy-web-view.h"
#include "ephy-debug.h"
-#include "ephy-browse-history.h"
#include "ephy-embed-container.h"
#include "ephy-embed-prefs.h"
#include "ephy-embed-shell.h"
@@ -35,6 +34,7 @@
#include "ephy-favicon-cache.h"
#include "ephy-file-helpers.h"
#include "ephy-history.h"
+#include "ephy-history-service.h"
#include "ephy-permission-manager.h"
#include "ephy-prefs.h"
#include "ephy-profile-utils.h"
@@ -1066,7 +1066,7 @@ title_changed_cb (WebKitWebView *web_view,
const char *uri;
char *title;
WebKitWebFrame *frame;
- EphyBrowseHistory *browse_history = EPHY_BROWSE_HISTORY (ephy_embed_shell_get_global_browse_history (ephy_embed_shell_get_default ()));
+ EphyHistoryService *history = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ()));
frame = webkit_web_view_get_main_frame (web_view);
uri = webkit_web_frame_get_uri (frame);
@@ -1081,7 +1081,7 @@ title_changed_cb (WebKitWebView *web_view,
ephy_web_view_set_title (EPHY_WEB_VIEW (web_view),
title);
- ephy_browse_history_set_page_title (browse_history, uri, title);
+ ephy_history_service_set_url_title (history, uri, title, NULL, NULL);
g_free (title);
}