[epiphany/wip/bookmarks] bookmarks-popover: Ensure there are no duplicates added in 'Tags' stack of bookmarks popover



commit 48c2592b705a99c54d139a06a6347b801f2aede5
Author: Iulian Radu <iulian radu67 gmail com>
Date:   Wed Sep 28 13:35:16 2016 +0300

    bookmarks-popover: Ensure there are no duplicates added in 'Tags' stack of bookmarks popover

 src/bookmarks/ephy-bookmarks-popover.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-popover.c b/src/bookmarks/ephy-bookmarks-popover.c
index c10296a..bacf949 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 *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]