[epiphany] bookmarks-popover: Exit tag detail view if removing tag's last bookmark



commit 02992ad08561e9432103995a4020a74dc0bf0208
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Feb 19 16:24:53 2017 -0600

    bookmarks-popover: Exit tag detail view if removing tag's last bookmark

 src/bookmarks/ephy-bookmarks-popover.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-popover.c b/src/bookmarks/ephy-bookmarks-popover.c
index 74bc48c..1882e1c 100644
--- a/src/bookmarks/ephy-bookmarks-popover.c
+++ b/src/bookmarks/ephy-bookmarks-popover.c
@@ -257,6 +257,7 @@ ephy_bookmarks_popover_bookmark_removed_cb (EphyBookmarksPopover *self,
   GtkWidget *row = NULL;
   GList *children;
   GList *l;
+  const char *visible_stack_child;
 
   g_assert (EPHY_IS_BOOKMARKS_POPOVER (self));
   g_assert (EPHY_IS_BOOKMARK (bookmark));
@@ -295,8 +296,20 @@ ephy_bookmarks_popover_bookmark_removed_cb (EphyBookmarksPopover *self,
   }
   gtk_container_remove (GTK_CONTAINER (self->tag_detail_list_box), row);
 
-  if (g_list_model_get_n_items (G_LIST_MODEL (self->list_model)) == 0)
+  visible_stack_child = gtk_stack_get_visible_child_name (GTK_STACK (self->toplevel_stack));
+
+  if (g_list_model_get_n_items (G_LIST_MODEL (self->list_model)) == 0) {
     gtk_stack_set_visible_child_name (GTK_STACK (self->toplevel_stack), "empty-state");
+  } else if (g_strcmp0 (visible_stack_child, "tag_detail") == 0 &&
+             g_sequence_is_empty (ephy_bookmarks_manager_get_bookmarks_with_tag (self->manager, 
self->tag_detail_tag))) {
+    /* If we removed the tag's last bookmark, switch back to the tags list. */
+    GActionGroup *group;
+    GAction *action;
+
+    group = gtk_widget_get_action_group (GTK_WIDGET (self), "popover");
+    action = g_action_map_lookup_action (G_ACTION_MAP (group), "tag-detail-back");
+    g_action_activate (action, NULL);
+  }
 }
 
 static void


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