aboutsummaryrefslogtreecommitdiffstats
path: root/lib/history
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-03-06 01:43:04 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:45 +0800
commitfcf33bc89394ab0f0dca5b776c11b9ee5036c62e (patch)
tree34ac1e7719d95ebf268f980d36513800d2d84610 /lib/history
parent7c6abe5cb07313cf8cd57d34c8fc8d26dfcf1203 (diff)
downloadgsoc2013-epiphany-fcf33bc89394ab0f0dca5b776c11b9ee5036c62e.tar.gz
gsoc2013-epiphany-fcf33bc89394ab0f0dca5b776c11b9ee5036c62e.tar.zst
gsoc2013-epiphany-fcf33bc89394ab0f0dca5b776c11b9ee5036c62e.zip
ephy-history-service: add 'visit-url' signal
Similar to the old EphyHistory 'add-page' signal. It allows blocking the visit by handling the signal, since the actual logic to add the visit is in the class' default handler. The add_visit(s) methods won't emit this signal, but for now we'll assume that whoever is using those knows what he's doing.
Diffstat (limited to 'lib/history')
-rw-r--r--lib/history/ephy-history-service.c45
-rw-r--r--lib/history/ephy-history-service.h6
2 files changed, 43 insertions, 8 deletions
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 0677bfbe8..1d5f06ac2 100644
--- a/lib/history/ephy-history-service.c
+++ b/lib/history/ephy-history-service.c
@@ -40,6 +40,13 @@ typedef enum {
QUERY_URLS,
QUERY_VISITS,
} EphyHistoryServiceMessageType;
+
+enum {
+ VISIT_URL,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
typedef struct _EphyHistoryServiceMessage {
EphyHistoryService *service;
@@ -111,14 +118,43 @@ ephy_history_service_finalize (GObject *self)
G_OBJECT_CLASS (ephy_history_service_parent_class)->finalize (self);
}
+static gboolean
+impl_visit_url (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);
+
+ return TRUE;
+}
+
static void
ephy_history_service_class_init (EphyHistoryServiceClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
gobject_class->finalize = ephy_history_service_finalize;
gobject_class->get_property = ephy_history_service_get_property;
gobject_class->set_property = ephy_history_service_set_property;
+ klass->visit_url = impl_visit_url;
+
+ signals[VISIT_URL] =
+ g_signal_new ("visit-url",
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EphyHistoryServiceClass, visit_url),
+ g_signal_accumulator_true_handled, NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_BOOLEAN,
+ 1,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
g_object_class_install_property (gobject_class,
PROP_HISTORY_FILENAME,
g_param_spec_string ("history-filename",
@@ -741,15 +777,10 @@ void
ephy_history_service_visit_url (EphyHistoryService *self,
const char *url)
{
- EphyHistoryPageVisit *visit;
+ gboolean result;
g_return_if_fail (EPHY_IS_HISTORY_SERVICE (self));
g_return_if_fail (url != NULL);
- 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);
+ g_signal_emit (self, signals[VISIT_URL], 0, url, &result);
}
diff --git a/lib/history/ephy-history-service.h b/lib/history/ephy-history-service.h
index 9d8ed2f15..50d79f31f 100644
--- a/lib/history/ephy-history-service.h
+++ b/lib/history/ephy-history-service.h
@@ -48,7 +48,11 @@ struct _EphyHistoryService {
};
struct _EphyHistoryServiceClass {
- GObjectClass parent_class;
+ GObjectClass parent_class;
+
+ /* Signals */
+ gboolean (* visit_url) (EphyHistoryService *self,
+ const char *url);
};
GType ephy_history_service_get_type (void);