aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-09-07 15:13:24 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2012-09-10 13:14:27 +0800
commit399c91bc8724e0ca26370d7552b841c0669be87d (patch)
tree56bf496ead7c4df2cc358e70a0bd3decd83e8b4e /lib
parenta3361d48035eb48c49aff443dff634105a6bb6c7 (diff)
downloadgsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar.gz
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar.bz2
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar.lz
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar.xz
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.tar.zst
gsoc2013-epiphany-399c91bc8724e0ca26370d7552b841c0669be87d.zip
ephy-history-service: add urls-visited signal
This signal is emitted in bulks and is intended for clients that are not interested in every single URL that is visited but only to know that visits have happened. https://bugzilla.gnome.org/show_bug.cgi?id=683550
Diffstat (limited to 'lib')
-rw-r--r--lib/history/ephy-history-service-private.h1
-rw-r--r--lib/history/ephy-history-service.c53
2 files changed, 54 insertions, 0 deletions
diff --git a/lib/history/ephy-history-service-private.h b/lib/history/ephy-history-service-private.h
index 4235e9d93..7fb96bdc2 100644
--- a/lib/history/ephy-history-service-private.h
+++ b/lib/history/ephy-history-service-private.h
@@ -29,6 +29,7 @@ struct _EphyHistoryServicePrivate {
GAsyncQueue *queue;
gboolean scheduled_to_quit;
gboolean scheduled_to_commit;
+ int queue_urls_visited_id;
};
void ephy_history_service_schedule_commit (EphyHistoryService *self);
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 3d7a2fdbf..bfbe34823 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -50,6 +50,7 @@ typedef enum {
enum {
VISIT_URL,
+ URLS_VISITED,
CLEARED,
URL_TITLE_CHANGED,
URL_DELETED,
@@ -130,6 +131,36 @@ ephy_history_service_finalize (GObject *self)
G_OBJECT_CLASS (ephy_history_service_parent_class)->finalize (self);
}
+static void
+ephy_history_service_dispose (GObject *self)
+{
+ EphyHistoryServicePrivate *priv = EPHY_HISTORY_SERVICE (self)->priv;
+
+ if (priv->queue_urls_visited_id) {
+ g_source_remove (priv->queue_urls_visited_id);
+ priv->queue_urls_visited_id = 0;
+ }
+}
+
+static gboolean
+emit_urls_visited (EphyHistoryService *self)
+{
+ g_signal_emit (self, signals[URLS_VISITED], 0);
+ self->priv->queue_urls_visited_id = 0;
+
+ return FALSE;
+}
+
+static void
+ephy_history_service_queue_urls_visited (EphyHistoryService *self)
+{
+ if (self->priv->queue_urls_visited_id)
+ return;
+
+ self->priv->queue_urls_visited_id =
+ g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc)emit_urls_visited, self, NULL);
+}
+
static gboolean
impl_visit_url (EphyHistoryService *self, const char *url, EphyHistoryPageVisitType visit_type)
{
@@ -142,6 +173,8 @@ impl_visit_url (EphyHistoryService *self, const char *url, EphyHistoryPageVisitT
visit, NULL, NULL, NULL);
ephy_history_page_visit_free (visit);
+ ephy_history_service_queue_urls_visited (self);
+
return FALSE;
}
@@ -151,6 +184,7 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = ephy_history_service_finalize;
+ gobject_class->dispose = ephy_history_service_dispose;
gobject_class->get_property = ephy_history_service_get_property;
gobject_class->set_property = ephy_history_service_set_property;
@@ -168,6 +202,25 @@ ephy_history_service_class_init (EphyHistoryServiceClass *klass)
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
EPHY_TYPE_HISTORY_PAGE_VISIT_TYPE);
+/**
+ * EphyHistoryService::urls-visited:
+ * @service: the #EphyHistoryService that received the signal
+ *
+ * The ::urls-visited signal is emitted after one or more visits to
+ * URLS have taken place. This signal is intended for use-cases when
+ * precise information of the actual URLS visited is not important and
+ * there is only interest in the fact that there have been changes in
+ * the history. For more precise information, you can use ::visit-url
+ **/
+ signals[URLS_VISITED] =
+ g_signal_new ("urls-visited",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
signals[CLEARED] =
g_signal_new ("cleared",
G_OBJECT_CLASS_TYPE (gobject_class),