aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2011-08-26 00:34:18 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:43 +0800
commit428ae4cb1c656f2c05121b1889b88435306b7334 (patch)
treef38661016b0965872e5c0c09b08bb24c24937020 /embed
parent0754cc9ceb8259ae22ce751d068ad132f790adc2 (diff)
downloadgsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar.gz
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar.bz2
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar.lz
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar.xz
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.tar.zst
gsoc2013-epiphany-428ae4cb1c656f2c05121b1889b88435306b7334.zip
Add initial implementation of the browse history frontend
This will eventually replace the old EphyHistory class
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am3
-rw-r--r--embed/ephy-browse-history.c211
-rw-r--r--embed/ephy-browse-history.h107
3 files changed, 321 insertions, 0 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index c0e21e0a7..44803fdc8 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -26,6 +26,7 @@ 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
@@ -48,6 +49,7 @@ 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 \
@@ -63,6 +65,7 @@ libephyembed_la_CPPFLAGS = \
-I$(top_builddir)/lib \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/egg \
+ -I$(top_srcdir)/lib/history \
-I$(top_srcdir)/lib/widgets \
$(AM_CPPFLAGS)
diff --git a/embed/ephy-browse-history.c b/embed/ephy-browse-history.c
new file mode 100644
index 000000000..3295f8517
--- /dev/null
+++ b/embed/ephy-browse-history.c
@@ -0,0 +1,211 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
+/*
+ * Copyright © 2002, 2003 Marco Pesenti Gritti
+ * Copyright © 2011 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-history-service.h"
+#include "ephy-history-types.h"
+#include "ephy-request-about.h"
+#include "ephy-file-helpers.h"
+#include "ephy-browse-history.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_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+ephy_browse_history_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ }
+}
+
+static void
+ephy_browse_history_dispose (GObject *object)
+{
+ G_OBJECT_CLASS (ephy_browse_history_parent_class)->dispose (object);
+}
+
+static void
+ephy_browse_history_finalize (GObject *object)
+{
+ EphyBrowseHistory *history = EPHY_BROWSE_HISTORY (object);
+
+ if (history->priv->history_service) {
+ g_object_unref (history->priv->history_service);
+ }
+
+ G_OBJECT_CLASS (ephy_browse_history_parent_class)->finalize (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->get_property = ephy_browse_history_get_property;
+ object_class->set_property = ephy_browse_history_set_property;
+ object_class->dispose = ephy_browse_history_dispose;
+ object_class->finalize = ephy_browse_history_finalize;
+}
+
+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_property (history->priv->history_service,
+ url,
+ EPHY_HISTORY_URL_TITLE,
+ g_variant_new_maybe (G_VARIANT_TYPE_STRING,
+ title ? g_variant_new_string (title) : NULL),
+ 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_property (history->priv->history_service,
+ url,
+ EPHY_HISTORY_URL_ZOOM_LEVEL,
+ g_variant_new_double (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,
+ 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;
+
+ 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);
+}
diff --git a/embed/ephy-browse-history.h b/embed/ephy-browse-history.h
new file mode 100644
index 000000000..abb61343d
--- /dev/null
+++ b/embed/ephy-browse-history.h
@@ -0,0 +1,107 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
+/*
+ * Copyright © 2000-2003 Marco Pesenti Gritti
+ * Copyright © 2011 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 <glib-object.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,
+ GList *substring_list,
+ EphyHistoryJobCallback callback,
+ gpointer user_data);
+
+void ephy_browse_history_delete_urls (EphyBrowseHistory *history,
+ GList *urls,
+ EphyHistoryJobCallback callback,
+ gpointer user_data);
+
+G_END_DECLS
+
+#endif /* _EPHY_BROWSE_HISTORY_H */