[epiphany/history-rewrite] ephy-history-service: add 'visit-url' signal
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/history-rewrite] ephy-history-service: add 'visit-url' signal
- Date: Mon, 5 Mar 2012 17:46:53 +0000 (UTC)
commit 939f173a071613dc9d7c815fe72c4a176e1afd21
Author: Xan Lopez <xan igalia com>
Date: Mon Mar 5 18:43:04 2012 +0100
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.
lib/history/ephy-history-service.c | 45 ++++++++++++++++++++++++++++++-----
lib/history/ephy-history-service.h | 6 ++++-
2 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/lib/history/ephy-history-service.c b/lib/history/ephy-history-service.c
index 0677bfb..1d5f06a 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 9d8ed2f..50d79f3 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]