[epiphany] Get rid of EphyBrowseHistory
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Get rid of EphyBrowseHistory
- Date: Tue, 6 Mar 2012 20:53:37 +0000 (UTC)
commit 9666dba09d79cd88777e9066dbdb2ca5b5e7588f
Author: Xan Lopez <xan igalia com>
Date: Mon Mar 5 16:57:45 2012 +0100
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.
embed/Makefile.am | 2 -
embed/ephy-browse-history.c | 182 ------------------------------------
embed/ephy-browse-history.h | 86 -----------------
embed/ephy-embed-shell.c | 28 +++---
embed/ephy-embed-shell.h | 2 +-
embed/ephy-embed.c | 29 ++++--
embed/ephy-web-view.c | 6 +-
lib/history/ephy-history-service.c | 41 ++++++++
lib/history/ephy-history-service.h | 3 +
src/ephy-completion-model.c | 18 ++--
10 files changed, 93 insertions(+), 304 deletions(-)
---
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 44803fd..8476bfc 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-embed-shell.c b/embed/ephy-embed-shell.c
index 63fe5c1..cda96e2 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 a31d290..4bab3a4 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 b9f1f46..a64f154 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 6d4aeda..eb8dbc3 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);
}
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 6261a43..b8bd2c2 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -709,3 +709,44 @@ ephy_history_service_process_message (EphyHistoryService *self,
return;
}
+
+/* Public API. */
+
+void
+ephy_history_service_find_urls (EphyHistoryService *self,
+ gint64 from, gint64 to,
+ guint limit,
+ GList *substring_list,
+ EphyHistoryJobCallback callback,
+ gpointer user_data)
+{
+ EphyHistoryQuery *query;
+
+ g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
+
+ 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 (self,
+ query, callback, user_data);
+}
+
+void
+ephy_history_service_add_page (EphyHistoryService *self,
+ const char *url)
+{
+ EphyHistoryPageVisit *visit;
+
+ visit = ephy_history_page_visit_new (url,
+ time (NULL),
+ EPHY_PAGE_VISIT_TYPED);
+ ephy_history_service_add_visit (self,
+ visit, NULL, NULL);
+ ephy_history_page_visit_free (visit);
+}
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index b01dd07..049b3cd 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -64,6 +64,9 @@ void ephy_history_service_set_url_zoom_level (EphyHisto
void ephy_history_service_get_host_for_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_get_url (EphyHistoryService *self, const char *url, EphyHistoryJobCallback callback, gpointer user_data);
void ephy_history_service_delete_urls (EphyHistoryService *self, GList *urls, EphyHistoryJobCallback callback, gpointer user_data);
+void ephy_history_service_find_urls (EphyHistoryService *self, gint64 from, gint64 to, guint limit, GList *substring_list, EphyHistoryJobCallback callback, gpointer user_data);
+void ephy_history_service_add_page (EphyHistoryService *self, const char *orig_url);
+
G_END_DECLS
#endif /* EPHY_HISTORY_SERVICE_H */
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c
index 776f2dd..18def7d 100644
--- a/src/ephy-completion-model.c
+++ b/src/ephy-completion-model.c
@@ -21,10 +21,10 @@
#include "config.h"
#include "ephy-completion-model.h"
-#include "ephy-browse-history.h"
#include "ephy-embed-shell.h"
#include "ephy-favicon-cache.h"
#include "ephy-history.h"
+#include "ephy-history-service.h"
#include "ephy-shell.h"
#include <string.h>
@@ -34,7 +34,7 @@ G_DEFINE_TYPE (EphyCompletionModel, ephy_completion_model, GTK_TYPE_LIST_STORE)
#define EPHY_COMPLETION_MODEL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_COMPLETION_MODEL, EphyCompletionModelPrivate))
struct _EphyCompletionModelPrivate {
- EphyBrowseHistory *browse_history;
+ EphyHistoryService *history_service;
EphyHistory *legacy_history_service;
EphyFaviconCache *favicon_cache;
@@ -97,7 +97,7 @@ ephy_completion_model_init (EphyCompletionModel *model)
model->priv = priv = EPHY_COMPLETION_MODEL_GET_PRIVATE (model);
- priv->browse_history = EPHY_BROWSE_HISTORY (ephy_embed_shell_get_global_browse_history (embed_shell));
+ priv->history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service (embed_shell));
priv->legacy_history_service = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell));
priv->favicon_cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (embed_shell));
@@ -488,12 +488,12 @@ ephy_completion_model_update_for_string (EphyCompletionModel *model,
user_data->callback = callback;
user_data->user_data = data;
- ephy_browse_history_find_urls (priv->browse_history,
- 0, 0,
- MAX_COMPLETION_HISTORY_URLS,
- query,
- (EphyHistoryJobCallback)query_completed_cb,
- user_data);
+ ephy_history_service_find_urls (priv->history_service,
+ 0, 0,
+ MAX_COMPLETION_HISTORY_URLS,
+ query,
+ (EphyHistoryJobCallback)query_completed_cb,
+ user_data);
}
EphyCompletionModel *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]