summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Radu <iulian.radu67@gmail.com>2016-09-28 13:35:16 +0300
committerIulian Radu <iulian.radu67@gmail.com>2016-09-28 16:15:13 +0300
commit72adb8045e5e11fc5d7229140603a2555dc34d77 (patch)
tree792ba03d22cacf1b5a6fe98ca16c92ae04971baf
parentc74cb8506bec8a3a78ba7a3efe2b1f24c4e07655 (diff)
downloadepiphany-72adb8045e5e11fc5d7229140603a2555dc34d77.tar.gz
bookmarks-popover: Ensure there are no duplicates added in 'Tags' stack of bookmarks popover
-rw-r--r--src/bookmarks/ephy-bookmarks-popover.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/bookmarks/ephy-bookmarks-popover.c b/src/bookmarks/ephy-bookmarks-popover.c
index c10296a1c..bacf94938 100644
--- a/src/bookmarks/ephy-bookmarks-popover.c
+++ b/src/bookmarks/ephy-bookmarks-popover.c
@@ -92,18 +92,35 @@ bookmark_tag_removed_cb (EphyBookmark *bookmark,
* box */
if (g_sequence_is_empty (ephy_bookmark_get_tags (bookmark))) {
GtkWidget *row;
+ GList *children;
+ GList *l;
const char *visible_stack_child;
+ gboolean exists;
+
+ exists = FALSE;
+ children = gtk_container_get_children (GTK_CONTAINER (popover->tags_list_box));
+ for (l = children; l != NULL; l = l->next) {
+ const char *url;
- row = create_bookmark_row (bookmark, popover);
- gtk_container_add (GTK_CONTAINER (popover->tags_list_box), row);
+ url = g_object_get_data (G_OBJECT(l->data), "url");
+ if (g_strcmp0 (ephy_bookmark_get_url (bookmark), url) == 0) {
+ exists = TRUE;
+ break;
+ }
+ }
+
+ if (!exists) {
+ /* Disconnect the previous handler on the instance as create bookmark row
+ * connects another one */
+ g_signal_handlers_disconnect_by_data (bookmark, popover);
+ row = create_bookmark_row (bookmark, popover);
+ gtk_container_add (GTK_CONTAINER (popover->tags_list_box), row);
+ }
/* If we are on tag detail list box, we remove the tag from it to reflect
* the changes */
visible_stack_child = gtk_stack_get_visible_child_name (GTK_STACK (popover->toplevel_stack));
if (g_strcmp0 (visible_stack_child, "tag_detail") == 0) {
- GList *children;
- GList *l;
-
children = gtk_container_get_children (GTK_CONTAINER (popover->tag_detail_list_box));
for (l = children; l != NULL; l = l->next) {
const char *url;
@@ -126,8 +143,6 @@ bookmark_tag_removed_cb (EphyBookmark *bookmark,
}
}
}
-
- g_signal_stop_emission_by_name (bookmark, "tag-removed");
}
static GtkWidget *