[epiphany: 3/3] Refresh completion model actions if smart bookmark changes
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany: 3/3] Refresh completion model actions if smart bookmark changes
- Date: Mon, 31 Oct 2016 21:58:57 +0000 (UTC)
commit 4350e43d7423c8f438b877b9ff88a1c3c5c0d0d7
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Oct 31 16:54:23 2016 -0500
Refresh completion model actions if smart bookmark changes
https://bugzilla.gnome.org/show_bug.cgi?id=772407
src/bookmarks/ephy-bookmarks-manager.c | 44 ++++++++++++++++++++++++++++++++
src/ephy-location-controller.c | 25 ++++++-----------
2 files changed, 53 insertions(+), 16 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-manager.c b/src/bookmarks/ephy-bookmarks-manager.c
index 161142e..4136892 100644
--- a/src/bookmarks/ephy-bookmarks-manager.c
+++ b/src/bookmarks/ephy-bookmarks-manager.c
@@ -46,6 +46,8 @@ G_DEFINE_TYPE_EXTENDED (EphyBookmarksManager, ephy_bookmarks_manager, G_TYPE_OBJ
enum {
BOOKMARK_ADDED,
BOOKMARK_REMOVED,
+ BOOKMARK_TITLE_CHANGED,
+ BOOKMARK_URL_CHANGED,
TAG_CREATED,
TAG_DELETED,
LAST_SIGNAL
@@ -165,6 +167,24 @@ ephy_bookmarks_manager_class_init (EphyBookmarksManagerClass *klass)
G_TYPE_NONE, 1,
EPHY_TYPE_BOOKMARK);
+ signals[BOOKMARK_TITLE_CHANGED] =
+ g_signal_new ("bookmark-title-changed",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ EPHY_TYPE_BOOKMARK);
+
+ signals[BOOKMARK_URL_CHANGED] =
+ g_signal_new ("bookmark-url-changed",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ EPHY_TYPE_BOOKMARK);
+
signals[TAG_CREATED] =
g_signal_new ("tag-created",
EPHY_TYPE_BOOKMARKS_MANAGER,
@@ -256,6 +276,22 @@ list_model_iface_init (GListModelInterface *iface)
iface->get_item = ephy_bookmarks_manager_list_model_get_item;
}
+static void
+bookmark_title_changed_cb (EphyBookmark *bookmark,
+ GParamSpec *pspec,
+ EphyBookmarksManager *self)
+{
+ g_signal_emit (self, signals[BOOKMARK_TITLE_CHANGED], 0, bookmark);
+}
+
+static void
+bookmark_url_changed_cb (EphyBookmark *bookmark,
+ GParamSpec *pspec,
+ EphyBookmarksManager *self)
+{
+ g_signal_emit (self, signals[BOOKMARK_URL_CHANGED], 0, bookmark);
+}
+
void
ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
EphyBookmark *bookmark)
@@ -288,6 +324,11 @@ ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
(GAsyncReadyCallback)ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
}
+
+ g_signal_connect_object (bookmark, "notify::title",
+ G_CALLBACK (bookmark_title_changed_cb), self, 0);
+ g_signal_connect_object (bookmark, "notify::url",
+ G_CALLBACK (bookmark_url_changed_cb), self, 0);
}
void
@@ -347,6 +388,9 @@ ephy_bookmarks_manager_remove_bookmark (EphyBookmarksManager *self,
ephy_bookmarks_manager_save_to_file_async (self, NULL,
(GAsyncReadyCallback)ephy_bookmarks_manager_save_to_file_warn_on_error_cb,
NULL);
+
+ g_signal_handlers_disconnect_by_func (bookmark, bookmark_title_changed_cb, self);
+ g_signal_handlers_disconnect_by_func (bookmark, bookmark_url_changed_cb, self);
}
EphyBookmark *
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index ea46e54..8404338 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -338,18 +338,9 @@ update_actions_list (EphyLocationController *controller)
}
static void
-bookmark_added_cb (EphyBookmarksManager *manager,
- EphyBookmark *bookmark,
- EphyLocationController *controller)
-{
- if (ephy_bookmark_is_smart (bookmark))
- update_actions_list (controller);
-}
-
-static void
-bookmark_removed_cb (EphyBookmarksManager *manager,
- EphyBookmark *bookmark,
- EphyLocationController *controller)
+bookmark_modified_cb (EphyBookmarksManager *manager,
+ EphyBookmark *bookmark,
+ EphyLocationController *controller)
{
if (ephy_bookmark_is_smart (bookmark))
update_actions_list (controller);
@@ -439,12 +430,14 @@ ephy_location_controller_constructed (GObject *object)
refresh_smart_bookmarks (controller);
add_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
- /* FIXME: This is not enough. We miss when an existing bookmark is edited.
- * Need to add a bookmark-modified signal to EphyBookmarksManager. */
g_signal_connect_object (controller->bookmarks_manager, "bookmark-added",
- G_CALLBACK (bookmark_added_cb), controller, 0);
+ G_CALLBACK (bookmark_modified_cb), controller, 0);
g_signal_connect_object (controller->bookmarks_manager, "bookmark-removed",
- G_CALLBACK (bookmark_removed_cb), controller, 0);
+ G_CALLBACK (bookmark_modified_cb), controller, 0);
+ g_signal_connect_object (controller->bookmarks_manager, "bookmark-title-changed",
+ G_CALLBACK (bookmark_modified_cb), controller, 0);
+ g_signal_connect_object (controller->bookmarks_manager, "bookmark-url-changed",
+ G_CALLBACK (bookmark_modified_cb), controller, 0);
g_object_bind_property (controller, "editable",
controller->title_widget, "editable",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]