[epiphany/wip/bookmarks: 275/315] bookmarks-popover: Update all stacks accordingly when a bookmark/tag is added/modified/removed
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/bookmarks: 275/315] bookmarks-popover: Update all stacks accordingly when a bookmark/tag is added/modified/removed
- Date: Tue, 27 Sep 2016 17:37:20 +0000 (UTC)
commit 51dc8dc92ada49b45cf5f946cfdce24a34fb7f8d
Author: Iulian Radu <iulian radu67 gmail com>
Date: Wed Aug 10 00:43:34 2016 +0300
bookmarks-popover: Update all stacks accordingly when a bookmark/tag is added/modified/removed
src/ephy-bookmark-properties-grid.c | 2 -
src/ephy-bookmark.c | 22 ++-
src/ephy-bookmarks-manager.c | 57 +++++++
src/ephy-bookmarks-popover.c | 308 ++++++++++++++++++++++++++++-------
src/ephy-header-bar.c | 20 ++-
src/ephy-window.c | 26 +++
src/resources/gtk/bookmark-row.ui | 2 +
7 files changed, 359 insertions(+), 78 deletions(-)
---
diff --git a/src/ephy-bookmark-properties-grid.c b/src/ephy-bookmark-properties-grid.c
index 0f1548f..85b45b8 100644
--- a/src/ephy-bookmark-properties-grid.c
+++ b/src/ephy-bookmark-properties-grid.c
@@ -238,8 +238,6 @@ ephy_bookmarks_properties_grid_actions_remove_bookmark (GSimpleAction *action,
g_assert (EPHY_IS_BOOKMARK_PROPERTIES_GRID (self));
- g_signal_emit_by_name (self->bookmark, "removed");
-
ephy_bookmarks_manager_remove_bookmark (self->manager, self->bookmark);
gtk_widget_destroy (self->parent);
diff --git a/src/ephy-bookmark.c b/src/ephy-bookmark.c
index b02e0af..d43475d 100644
--- a/src/ephy-bookmark.c
+++ b/src/ephy-bookmark.c
@@ -40,7 +40,8 @@ enum {
};
enum {
- REMOVED,
+ TAG_ADDED,
+ TAG_REMOVED,
LAST_SIGNAL
};
@@ -152,13 +153,22 @@ ephy_bookmark_class_init (EphyBookmarkClass *klass)
g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
- signals[REMOVED] =
- g_signal_new ("removed",
+ signals[TAG_ADDED] =
+ g_signal_new ("tag-added",
EPHY_TYPE_BOOKMARK,
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE, 0);
+
+ signals[TAG_REMOVED] =
+ g_signal_new ("tag-removed",
+ EPHY_TYPE_BOOKMARK,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
}
static void
@@ -248,6 +258,8 @@ ephy_bookmark_add_tag (EphyBookmark *self,
if (g_sequence_iter_is_end (prev_tag_iter)
|| g_strcmp0 (g_sequence_get (prev_tag_iter), tag) != 0)
g_sequence_insert_before (tag_iter, g_strdup (tag));
+
+ g_signal_emit (self, signals[TAG_ADDED], 0);
}
void
@@ -266,6 +278,8 @@ ephy_bookmark_remove_tag (EphyBookmark *self,
if (tag_iter)
g_sequence_remove (tag_iter);
+
+ g_signal_emit (self, signals[TAG_REMOVED], 0, tag);
}
gboolean
@@ -278,7 +292,7 @@ ephy_bookmark_has_tag (EphyBookmark *self, const char *tag)
tag_iter = g_sequence_lookup (self->tags,
(gpointer)tag,
- (GCompareDataFunc)g_strcmp0,
+ (GCompareDataFunc)ephy_bookmark_tags_compare,
NULL);
return tag_iter != NULL;
diff --git a/src/ephy-bookmarks-manager.c b/src/ephy-bookmarks-manager.c
index 297a059..b6ec82e 100644
--- a/src/ephy-bookmarks-manager.c
+++ b/src/ephy-bookmarks-manager.c
@@ -40,6 +40,16 @@ static void list_model_iface_init (GListModelInterface *iface);
G_DEFINE_TYPE_EXTENDED (EphyBookmarksManager, ephy_bookmarks_manager, G_TYPE_OBJECT, 0,
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, list_model_iface_init))
+enum {
+ BOOKMARK_ADDED,
+ BOOKMARK_REMOVED,
+ TAG_ADDED,
+ TAG_REMOVED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
static void
gvdb_hash_table_insert_variant (GHashTable *table,
const char *key,
@@ -143,6 +153,42 @@ ephy_bookmarks_manager_class_init (EphyBookmarksManagerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ephy_bookmarks_manager_finalize;
+
+ signals[BOOKMARK_ADDED] =
+ g_signal_new ("bookmark-added",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ EPHY_TYPE_BOOKMARK);
+
+ signals[BOOKMARK_REMOVED] =
+ g_signal_new ("bookmark-removed",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ EPHY_TYPE_BOOKMARK);
+
+ signals[TAG_ADDED] =
+ g_signal_new ("tag-added",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ signals[TAG_REMOVED] =
+ g_signal_new ("tag-removed",
+ EPHY_TYPE_BOOKMARKS_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
}
static void
@@ -231,6 +277,8 @@ ephy_bookmarks_manager_add_bookmark (EphyBookmarksManager *self,
(GAsyncReadyCallback)data_saved_cb,
NULL);
}
+
+ g_signal_emit (self, signals[BOOKMARK_ADDED], 0, bookmark);
}
void
@@ -281,6 +329,8 @@ ephy_bookmarks_manager_remove_bookmark (EphyBookmarksManager *self,
break;
}
+ g_signal_emit (self, signals[BOOKMARK_REMOVED], 0, bookmark);
+
position = g_sequence_iter_get_position (iter);
g_sequence_remove (iter);
g_list_model_items_changed (G_LIST_MODEL (self), position, 1, 0);
@@ -329,12 +379,15 @@ ephy_bookmarks_manager_add_tag (EphyBookmarksManager *self, const char *tag)
if (g_sequence_iter_is_end (prev_tag_iter)
|| g_strcmp0 (g_sequence_get (prev_tag_iter), tag) != 0)
g_sequence_insert_before (tag_iter, g_strdup (tag));
+
+ g_signal_emit (self, signals[TAG_ADDED], 0, tag);
}
void
ephy_bookmarks_manager_remove_tag (EphyBookmarksManager *self, const char *tag)
{
GSequenceIter *iter = NULL;
+ int position;
g_return_if_fail (EPHY_IS_BOOKMARKS_MANAGER (self));
g_return_if_fail (tag != NULL);
@@ -345,10 +398,14 @@ ephy_bookmarks_manager_remove_tag (EphyBookmarksManager *self, const char *tag)
NULL);
g_assert (iter != NULL);
+ position = g_sequence_iter_get_position (iter);
+
g_sequence_remove (iter);
/* Also remove the tag from each bookmark if they have it */
g_sequence_foreach (self->bookmarks, (GFunc)ephy_bookmark_remove_tag, (gpointer)tag);
+
+ g_signal_emit (self, signals[TAG_REMOVED], 0, position);
}
gboolean
diff --git a/src/ephy-bookmarks-popover.c b/src/ephy-bookmarks-popover.c
index fcea7c0..91558ac 100644
--- a/src/ephy-bookmarks-popover.c
+++ b/src/ephy-bookmarks-popover.c
@@ -28,16 +28,17 @@
#include <glib/gi18n.h>
struct _EphyBookmarksPopover {
- GtkPopover parent_instance;
+ GtkPopover parent_instance;
- GtkWidget *toplevel_stack;
- GtkWidget *bookmarks_list_box;
- GtkWidget *tags_list_box;
- GtkWidget *tag_detail_list_box;
- GtkWidget *tag_detail_back_button;
- GtkWidget *tag_detail_label;
+ GtkWidget *toplevel_stack;
+ GtkWidget *bookmarks_list_box;
+ GtkWidget *tags_list_box;
+ GtkWidget *tag_detail_list_box;
+ GtkWidget *tag_detail_back_button;
+ GtkWidget *tag_detail_label;
- EphyWindow *window;
+ EphyBookmarksManager *manager;
+ EphyWindow *window;
};
G_DEFINE_TYPE (EphyBookmarksPopover, ephy_bookmarks_popover, GTK_TYPE_POPOVER)
@@ -53,6 +54,220 @@ enum {
static GParamSpec *obj_properties[LAST_PROP];
+static GtkWidget *create_bookmark_row (gpointer item, gpointer user_data);
+
+static void
+bookmark_tag_added_cb (EphyBookmark *bookmark,
+ EphyBookmarksPopover *popover)
+{
+ g_assert (EPHY_IS_BOOKMARK (bookmark));
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (popover));
+
+ /* If the bookmark no longer has 0 tags, we remove it from the tags list box */
+ if (g_sequence_get_length (ephy_bookmark_get_tags (bookmark)) == 1) {
+ GList *children;
+ GList *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (popover->tags_list_box));
+ for (l = children; l != NULL; l = l->next) {
+ const char *url;
+
+ url = g_object_get_data (G_OBJECT (l->data), "url");
+ if (g_strcmp0 (ephy_bookmark_get_url (bookmark), url) == 0)
+ gtk_container_remove (GTK_CONTAINER (popover->tags_list_box), GTK_WIDGET (l->data));
+ }
+ }
+}
+
+static void
+bookmark_tag_removed_cb (EphyBookmark *bookmark,
+ const char *tag,
+ EphyBookmarksPopover *popover)
+{
+ g_assert (EPHY_IS_BOOKMARK (bookmark));
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (popover));
+
+ /* If the bookmark has 0 tags after removing one, we add it to the tags list
+ * box */
+ if (g_sequence_is_empty (ephy_bookmark_get_tags (bookmark))) {
+ GtkWidget *row;
+ const char *visible_stack_child;
+
+ 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;
+
+ url = g_object_get_data (G_OBJECT (l->data), "url");
+ if (g_strcmp0 (ephy_bookmark_get_url (bookmark), url) == 0) {
+ gtk_container_remove (GTK_CONTAINER (popover->tag_detail_list_box), GTK_WIDGET (l->data));
+
+ /* If we removed a tag's last bookmark while on the tags detail box,
+ * we switch back to the tags list stack */
+ if (g_sequence_is_empty (ephy_bookmarks_manager_get_bookmarks_with_tag (popover->manager, tag))) {
+ GActionGroup *group;
+ GAction *action;
+
+ group = gtk_widget_get_action_group (GTK_WIDGET (popover), "popover");
+ action = g_action_map_lookup_action (G_ACTION_MAP (group), "tag-detail-back");
+ g_action_activate (action, NULL);
+ }
+ }
+ }
+ }
+ }
+
+ g_signal_stop_emission_by_name (bookmark, "tag-removed");
+}
+
+static GtkWidget *
+create_bookmark_row (gpointer item,
+ gpointer user_data)
+{
+ EphyBookmark *bookmark = EPHY_BOOKMARK (item);
+ GtkWidget *row;
+
+ row = ephy_bookmark_row_new (bookmark);
+ g_object_set_data (G_OBJECT (row), "type", g_strdup (EPHY_LIST_BOX_ROW_TYPE_BOOKMARK));
+ g_object_set_data (G_OBJECT (row), "title", g_strdup (ephy_bookmark_get_title (bookmark)));
+ g_object_set_data (G_OBJECT (row), "url", g_strdup (ephy_bookmark_get_url (bookmark)));
+
+ g_signal_connect (bookmark, "tag-added",
+ G_CALLBACK (bookmark_tag_added_cb),
+ user_data);
+ g_signal_connect (bookmark, "tag-removed",
+ G_CALLBACK (bookmark_tag_removed_cb),
+ user_data);
+
+ return row;
+}
+
+static GtkWidget *
+create_tag_row (const char *tag)
+{
+ GtkWidget *row;
+ GtkWidget *box;
+ GtkWidget *image;
+ GtkWidget *label;
+
+ row = gtk_list_box_row_new ();
+ g_object_set_data (G_OBJECT (row), "type", g_strdup (EPHY_LIST_BOX_ROW_TYPE_TAG));
+ g_object_set_data (G_OBJECT (row), "title", g_strdup (tag));
+ g_object_set (G_OBJECT (row), "height-request", 40, NULL);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+ gtk_widget_set_halign (box, GTK_ALIGN_START);
+
+ if (g_strcmp0 (tag, "Favorites") == 0)
+ image = gtk_image_new_from_icon_name ("user-bookmarks-symbolic", GTK_ICON_SIZE_MENU);
+ else
+ image = gtk_image_new_from_icon_name ("ephy-bookmark-tag-symbolic", GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 6);
+
+ label = gtk_label_new (tag);
+ gtk_box_pack_start (GTK_BOX (box),label, TRUE, FALSE, 6);
+
+ gtk_container_add (GTK_CONTAINER (row), box);
+ gtk_widget_show_all (row);
+
+ return row;
+}
+
+static void
+ephy_bookmarks_popover_bookmark_added_cb (EphyBookmarksPopover *self,
+ EphyBookmark *bookmark,
+ EphyBookmarksManager *manager)
+{
+ GtkWidget *row;
+
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (self));
+ g_assert (EPHY_IS_BOOKMARK (bookmark));
+ g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
+
+ if (g_sequence_is_empty (ephy_bookmark_get_tags (bookmark))) {
+ row = create_bookmark_row (bookmark, self);
+ gtk_container_add (GTK_CONTAINER (self->tags_list_box), row);
+ }
+}
+
+static void
+ephy_bookmarks_popover_bookmark_removed_cb (EphyBookmarksPopover *self,
+ EphyBookmark *bookmark,
+ EphyBookmarksManager *manager)
+{
+ GtkWidget *row;
+ GList *children;
+ GList *l;
+
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (self));
+ g_assert (EPHY_IS_BOOKMARK (bookmark));
+ g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
+
+ children = gtk_container_get_children (GTK_CONTAINER (self->tags_list_box));
+ for (l = children; l != NULL; l = l->next) {
+ const char *type;
+ const char *url;
+
+ row = GTK_WIDGET (l->data);
+ type = g_object_get_data (G_OBJECT (row), "type");
+ url = g_object_get_data (G_OBJECT (row), "url");
+ if (g_strcmp0 (type, EPHY_LIST_BOX_ROW_TYPE_BOOKMARK) == 0
+ && g_strcmp0 (ephy_bookmark_get_url (bookmark), url) == 0) {
+ break;
+ }
+ }
+
+ gtk_container_remove (GTK_CONTAINER (self->tags_list_box), row);
+}
+
+static void
+ephy_bookmarks_popover_tag_added_cb (EphyBookmarksPopover *self,
+ const char *tag,
+ EphyBookmarksManager *manager)
+{
+ GtkWidget *tag_row;
+
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (self));
+ g_assert (tag != NULL);
+ g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
+
+ tag_row = create_tag_row (tag);
+ gtk_container_add (GTK_CONTAINER (self->tags_list_box), tag_row);
+}
+
+static void
+ephy_bookmarks_popover_tag_removed_cb (EphyBookmarksPopover *self,
+ int position,
+ EphyBookmarksManager *manager)
+{
+ GtkListBoxRow *row;
+
+ g_assert (EPHY_IS_BOOKMARKS_POPOVER (self));
+ g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
+
+ row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->tags_list_box), position);
+ gtk_container_remove (GTK_CONTAINER (self->tags_list_box),
+ GTK_WIDGET (row));
+
+ if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (self->toplevel_stack)), "tag_detail") == 0) {
+ 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 int
tags_list_box_sort_func (GtkListBoxRow *row1, GtkListBoxRow *row2)
{
@@ -82,20 +297,6 @@ tags_list_box_sort_func (GtkListBoxRow *row1, GtkListBoxRow *row2)
return g_strcmp0 (title1, title2);
}
-static GtkWidget *
-create_bookmark_row (gpointer item,
- gpointer user_data)
-{
- EphyBookmark *bookmark = EPHY_BOOKMARK (item);
- GtkWidget *row;
-
- row = ephy_bookmark_row_new (bookmark);
- g_object_set_data (G_OBJECT (row), "type", g_strdup (EPHY_LIST_BOX_ROW_TYPE_BOOKMARK));
- g_object_set_data (G_OBJECT (row), "title", g_strdup (ephy_bookmark_get_title (bookmark)));
-
- return row;
-}
-
static void
ephy_bookmarks_popover_actions_tag_detail_back (GSimpleAction *action,
GVariant *value,
@@ -119,19 +320,17 @@ static void
ephy_bookmarks_popover_show_tag_detail (EphyBookmarksPopover *self,
const char *tag)
{
- EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
GSequence *bookmarks;
GSequenceIter *iter;
- bookmarks = ephy_bookmarks_manager_get_bookmarks_with_tag (manager, tag);
-
+ bookmarks = ephy_bookmarks_manager_get_bookmarks_with_tag (self->manager, tag);
for (iter = g_sequence_get_begin_iter (bookmarks);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter)) {
EphyBookmark *bookmark = g_sequence_get (iter);
GtkWidget *row;
- row = create_bookmark_row (bookmark, NULL);
+ row = create_bookmark_row (bookmark, self);
gtk_list_box_prepend (GTK_LIST_BOX (self->tag_detail_list_box), row);
}
@@ -173,37 +372,6 @@ ephy_bookmarks_popover_list_box_row_activated_cb (EphyBookmarksPopover *self,
}
}
-static GtkWidget *
-create_tag_row (const char *tag)
-{
- GtkWidget *row;
- GtkWidget *box;
- GtkWidget *image;
- GtkWidget *label;
-
- row = gtk_list_box_row_new ();
- g_object_set_data (G_OBJECT (row), "type", g_strdup (EPHY_LIST_BOX_ROW_TYPE_TAG));
- g_object_set_data (G_OBJECT (row), "title", g_strdup (tag));
- g_object_set (G_OBJECT (row), "height-request", 40, NULL);
-
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_set_halign (box, GTK_ALIGN_START);
-
- if (g_strcmp0 (tag, "Favorites") == 0)
- image = gtk_image_new_from_icon_name ("user-bookmarks-symbolic", GTK_ICON_SIZE_MENU);
- else
- image = gtk_image_new_from_icon_name ("ephy-bookmark-tag-symbolic", GTK_ICON_SIZE_MENU);
- gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 6);
-
- label = gtk_label_new (tag);
- gtk_box_pack_start (GTK_BOX (box),label, TRUE, FALSE, 6);
-
- gtk_container_add (GTK_CONTAINER (row), box);
- gtk_widget_show_all (row);
-
- return row;
-}
-
static void
ephy_bookmarks_popover_set_property (GObject *object,
guint prop_id,
@@ -267,7 +435,6 @@ static const GActionEntry entries[] = {
static void
ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
{
- EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
GSequence *tags;
GSequence *bookmarks;
GSequenceIter *iter;
@@ -275,6 +442,8 @@ ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
gtk_widget_init_template (GTK_WIDGET (self));
+ self->manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
+
group = g_simple_action_group_new ();
g_action_map_add_action_entries (G_ACTION_MAP (group), entries,
G_N_ELEMENTS (entries), self);
@@ -283,15 +452,15 @@ ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
g_object_unref (group);
gtk_list_box_bind_model (GTK_LIST_BOX (self->bookmarks_list_box),
- G_LIST_MODEL (manager),
+ G_LIST_MODEL (self->manager),
create_bookmark_row,
- NULL, NULL);
+ self, NULL);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->tags_list_box),
(GtkListBoxSortFunc)tags_list_box_sort_func,
NULL, NULL);
- tags = ephy_bookmarks_manager_get_tags (manager);
+ tags = ephy_bookmarks_manager_get_tags (self->manager);
for (iter = g_sequence_get_begin_iter (tags);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter)) {
@@ -302,18 +471,31 @@ ephy_bookmarks_popover_init (EphyBookmarksPopover *self)
gtk_container_add (GTK_CONTAINER (self->tags_list_box), tag_row);
}
- bookmarks = ephy_bookmarks_manager_get_bookmarks_with_tag (manager, NULL);
+ bookmarks = ephy_bookmarks_manager_get_bookmarks_with_tag (self->manager, NULL);
for (iter = g_sequence_get_begin_iter (bookmarks);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter)) {
EphyBookmark *bookmark = g_sequence_get (iter);
GtkWidget *bookmark_row;
- bookmark_row = create_bookmark_row (bookmark, NULL);
+ bookmark_row = create_bookmark_row (bookmark, self);
gtk_widget_show_all (bookmark_row);
gtk_container_add (GTK_CONTAINER (self->tags_list_box), bookmark_row);
}
+ g_signal_connect_object (self->manager, "bookmark-added",
+ G_CALLBACK (ephy_bookmarks_popover_bookmark_added_cb),
+ self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->manager, "bookmark-removed",
+ G_CALLBACK (ephy_bookmarks_popover_bookmark_removed_cb),
+ self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->manager, "tag-added",
+ G_CALLBACK (ephy_bookmarks_popover_tag_added_cb),
+ self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->manager, "tag-removed",
+ G_CALLBACK (ephy_bookmarks_popover_tag_removed_cb),
+ self, G_CONNECT_SWAPPED);
+
g_signal_connect_object (self->bookmarks_list_box, "row-activated",
G_CALLBACK (ephy_bookmarks_popover_list_box_row_activated_cb),
self, G_CONNECT_SWAPPED);
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 198598e..d468ae6 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -550,31 +550,33 @@ ephy_header_bar_change_combined_stop_reload_state (GSimpleAction *action,
/**
* update_bookmarked_status_cb:
- * @bookmark: an #EphyBookmark pbject
- * @toolbar: an #EphyToolbar widget
+ * @bookmark: an #EphyBookmark object
+ * @header_bar: an #EphyHeaderBar widget
*
* Remove bookmarked status if the @bookmark was removed.
*
**/
static void
-update_bookmarked_status_cb (EphyBookmark *bookmark,
- EphyToolbar *toolbar)
+update_bookmarked_status_cb (EphyBookmarksManager *manager,
+ EphyBookmark *bookmark,
+ EphyHeaderBar *header_bar)
{
EphyEmbed *embed;
EphyWebView *view;
const char *address;
+ g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
g_assert (EPHY_IS_BOOKMARK (bookmark));
- g_assert (EPHY_IS_TOOLBAR (toolbar));
+ g_assert (EPHY_IS_HEADER_BAR (header_bar));
embed = ephy_embed_container_get_active_child
- (EPHY_EMBED_CONTAINER (toolbar->window));
+ (EPHY_EMBED_CONTAINER (header_bar->window));
view = ephy_embed_get_web_view (embed);
address = ephy_web_view_get_address (view);
if (g_strcmp0 (ephy_bookmark_get_url (bookmark), address) == 0) {
- ephy_location_entry_set_bookmarked_status (EPHY_LOCATION_ENTRY (toolbar->entry),
+ ephy_location_entry_set_bookmarked_status (EPHY_LOCATION_ENTRY (header_bar->entry),
FALSE);
}
}
@@ -600,9 +602,9 @@ add_bookmark_button_clicked_cb (EphyLocationEntry *entry,
g_strdup (ephy_embed_get_title (embed)),
g_sequence_new (g_free));
- g_signal_connect_object (bookmark, "removed",
+ g_signal_connect_object (manager, "bookmark-removed",
G_CALLBACK (update_bookmarked_status_cb),
- toolbar, 0);
+ header_bar, 0);
ephy_bookmarks_manager_add_bookmark (manager, bookmark);
ephy_location_entry_set_bookmarked_status (entry, TRUE);
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 3e6e09a..a76eb54 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2782,6 +2782,32 @@ title_widget_lock_clicked_cb (EphyTitleWidget *title_widget,
gtk_widget_show (security_popover);
}
+<<<<<<< 1e82cb5ec66b886ceb75c078fbd20f2fd7d5f89f
+=======
+static void
+location_controller_lock_clicked_cb (EphyLocationController *controller,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+ GtkWidget *location_entry;
+ GdkRectangle lock_position;
+
+ location_entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
+ gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_PRIMARY, &lock_position);
+ open_security_popover (window, location_entry, &lock_position);
+}
+
+static void
+title_box_lock_clicked_cb (EphyTitleBox *title_box,
+ GdkRectangle *lock_position,
+ gpointer user_data)
+{
+ EphyWindow *window = EPHY_WINDOW (user_data);
+
+ open_security_popover (window, GTK_WIDGET (title_box), lock_position);
+}
+
+>>>>>>> bookmarks-popover: Update all stacks accordingly when a bookmark/tag is added/modified/removed
static GtkWidget *
setup_header_bar (EphyWindow *window)
{
diff --git a/src/resources/gtk/bookmark-row.ui b/src/resources/gtk/bookmark-row.ui
index dfbf8a9..5fd39be 100644
--- a/src/resources/gtk/bookmark-row.ui
+++ b/src/resources/gtk/bookmark-row.ui
@@ -23,6 +23,8 @@
<object class="GtkLabel" id="title_label">
<property name="expand">true</property>
<property name="halign">start</property>
+ <property name="max-width-chars">40</property>
+ <property name="ellipsize">end</property>
<property name="visible">true</property>
</object>
<packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]