[epiphany] Move bookmark star to bottom bar in mobile mode



commit e16eef473f27dc836d4f8aaed54bb3749045c3fd
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sat Jun 19 20:56:38 2021 +0200

    Move bookmark star to bottom bar in mobile mode
    
    URL entry width is very limited in mobile mode, so let's make more space
    available: move bookmark star to action bar at the bottom as requested
    in #1172
    
    Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/979>

 lib/ephy-bookmark-states.h                |  28 +++++++
 lib/widgets/ephy-location-entry.c         |  47 ++++++++----
 lib/widgets/ephy-location-entry.h         |  10 +--
 src/bookmarks/ephy-add-bookmark-popover.c |  87 +++++++++++++---------
 src/bookmarks/ephy-add-bookmark-popover.h |   3 +-
 src/ephy-action-bar-end.c                 |  60 +++++++++++++++
 src/ephy-action-bar-end.h                 |   8 ++
 src/ephy-action-bar.c                     |   4 +
 src/ephy-header-bar.c                     |  10 ++-
 src/ephy-window.c                         |  29 +++++++-
 src/ephy-window.h                         |   4 +
 src/resources/ephy-bookmarks-symbolic.svg |  83 ---------------------
 src/resources/ephy-library-symbolic.svg   | 117 ++++++++++++++++++++++++++++++
 src/resources/epiphany.gresource.xml      |   2 +-
 src/resources/gtk/action-bar-end.ui       |  23 +++++-
 15 files changed, 367 insertions(+), 148 deletions(-)
---
diff --git a/lib/ephy-bookmark-states.h b/lib/ephy-bookmark-states.h
new file mode 100644
index 000000000..a0d6ba6e5
--- /dev/null
+++ b/lib/ephy-bookmark-states.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ *  Copyright © 2020 Jan-Michael Brummer <jan brummer tabos org>
+ *
+ *  This file is part of Epiphany.
+ *
+ *  Epiphany is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  Epiphany is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+typedef enum {
+  EPHY_BOOKMARK_ICON_HIDDEN,
+  EPHY_BOOKMARK_ICON_EMPTY,
+  EPHY_BOOKMARK_ICON_BOOKMARKED
+} EphyBookmarkIconState;
+
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 912e904c8..0b7886dd8 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -79,6 +79,7 @@ struct _EphyLocationEntry {
   guint progress_timeout;
   gdouble progress_fraction;
   guint update_url_id;
+  guint update_bookmark_id;
 
   guint dns_prefetch_handle_id;
 
@@ -89,6 +90,7 @@ struct _EphyLocationEntry {
 
   EphySecurityLevel security_level;
   EphyAdaptiveMode adaptive_mode;
+  EphyBookmarkIconState icon_state;
 };
 
 static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *,
@@ -503,6 +505,7 @@ ephy_location_entry_dispose (GObject *object)
 
   g_clear_handle_id (&entry->progress_timeout, g_source_remove);
   g_clear_handle_id (&entry->update_url_id, g_source_remove);
+  g_clear_handle_id (&entry->update_bookmark_id, g_source_remove);
 
   g_clear_object (&entry->css_provider);
 
@@ -1399,33 +1402,37 @@ ephy_location_entry_focus (EphyLocationEntry *entry)
   gtk_widget_grab_focus (GTK_WIDGET (entry->url_entry));
 }
 
-void
-ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry                  *entry,
-                                             EphyLocationEntryBookmarkIconState  state)
+gboolean
+ephy_location_entry_set_bookmark_icon_state_idle (gpointer user_data)
 {
+  EphyLocationEntry *self = EPHY_LOCATION_ENTRY (user_data);
   GtkStyleContext *context;
+  EphyBookmarkIconState state = self->icon_state;
 
-  g_assert (EPHY_IS_LOCATION_ENTRY (entry));
+  g_assert (EPHY_IS_LOCATION_ENTRY (self));
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (self->bookmark_icon));
 
-  context = gtk_widget_get_style_context (GTK_WIDGET (entry->bookmark_icon));
+  if (self->adaptive_mode == EPHY_ADAPTIVE_MODE_NARROW)
+    state = EPHY_BOOKMARK_ICON_HIDDEN;
 
   switch (state) {
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN:
-      gtk_widget_set_visible (entry->bookmark_button, FALSE);
+    case EPHY_BOOKMARK_ICON_HIDDEN:
+      gtk_widget_set_visible (self->bookmark_button, FALSE);
       gtk_style_context_remove_class (context, "starred");
       gtk_style_context_remove_class (context, "non-starred");
       break;
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY:
-      gtk_widget_set_visible (entry->bookmark_button, TRUE);
-      gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark_icon),
+    case EPHY_BOOKMARK_ICON_EMPTY:
+      gtk_widget_set_visible (self->bookmark_button, TRUE);
+      gtk_image_set_from_icon_name (GTK_IMAGE (self->bookmark_icon),
                                     "non-starred-symbolic",
                                     GTK_ICON_SIZE_MENU);
       gtk_style_context_remove_class (context, "starred");
       gtk_style_context_add_class (context, "non-starred");
       break;
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED:
-      gtk_widget_set_visible (entry->bookmark_button, TRUE);
-      gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark_icon),
+    case EPHY_BOOKMARK_ICON_BOOKMARKED:
+      gtk_widget_set_visible (self->bookmark_button, TRUE);
+      gtk_image_set_from_icon_name (GTK_IMAGE (self->bookmark_icon),
                                     "starred-symbolic",
                                     GTK_ICON_SIZE_MENU);
       gtk_style_context_remove_class (context, "non-starred");
@@ -1434,6 +1441,18 @@ ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry
     default:
       g_assert_not_reached ();
   }
+
+  self->update_bookmark_id = 0;
+  return G_SOURCE_REMOVE;
+}
+
+void
+ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry     *self,
+                                             EphyBookmarkIconState  state)
+{
+  self->icon_state = state;
+  g_clear_handle_id (&self->update_bookmark_id, g_source_remove);
+  self->update_bookmark_id = g_idle_add (ephy_location_entry_set_bookmark_icon_state_idle, self);
 }
 
 /**
@@ -1588,6 +1607,8 @@ ephy_location_entry_set_adaptive_mode (EphyLocationEntry *entry,
   entry->adaptive_mode = adaptive_mode;
 
   update_entry_style (entry);
+
+  ephy_location_entry_set_bookmark_icon_state (entry, entry->icon_state);
 }
 
 void
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 025f4389b..1284b30f6 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -26,6 +26,7 @@
 #include <gtk/gtk.h>
 
 #include "ephy-adaptive-mode.h"
+#include "ephy-bookmark-states.h"
 #include "ephy-security-levels.h"
 
 G_BEGIN_DECLS
@@ -34,11 +35,6 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyLocationEntry, ephy_location_entry, EPHY, LOCATION_ENTRY, GtkOverlay)
 
-typedef enum {
-  EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN,
-  EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY,
-  EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED
-} EphyLocationEntryBookmarkIconState;
 
 GtkWidget      *ephy_location_entry_new                        (void);
 
@@ -52,8 +48,8 @@ void            ephy_location_entry_undo_reset                 (EphyLocationEntr
 
 void            ephy_location_entry_focus                      (EphyLocationEntry *entry);
 
-void            ephy_location_entry_set_bookmark_icon_state    (EphyLocationEntry                  *entry,
-                                                                EphyLocationEntryBookmarkIconState  state);
+void            ephy_location_entry_set_bookmark_icon_state    (EphyLocationEntry     *entry,
+                                                                EphyBookmarkIconState  state);
 
 void            ephy_location_entry_set_lock_tooltip           (EphyLocationEntry *entry,
                                                                 const char        *tooltip);
diff --git a/src/bookmarks/ephy-add-bookmark-popover.c b/src/bookmarks/ephy-add-bookmark-popover.c
index 8f25bf482..71bb3fd50 100644
--- a/src/bookmarks/ephy-add-bookmark-popover.c
+++ b/src/bookmarks/ephy-add-bookmark-popover.c
@@ -35,17 +35,26 @@ struct _EphyAddBookmarkPopover {
   char *address;
 
   GtkWidget *grid;
-  EphyHeaderBar *header_bar;
+  GtkWidget *relative_to;
+  GtkWindow *window;
 };
 
 G_DEFINE_TYPE (EphyAddBookmarkPopover, ephy_add_bookmark_popover, GTK_TYPE_POPOVER)
 
 enum {
   PROP_0,
-  PROP_HEADER_BAR,
+  PROP_RELATIVE_TO,
+  PROP_WINDOW,
   LAST_PROP
 };
 
+enum signalsEnum {
+  UPDATE_STATE,
+  LAST_SIGNAL
+};
+
+static gint signals[LAST_SIGNAL] = { 0 };
+
 static GParamSpec *obj_properties[LAST_PROP];
 
 static void
@@ -57,8 +66,11 @@ ephy_bookmarks_popover_set_property (GObject      *object,
   EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
 
   switch (prop_id) {
-    case PROP_HEADER_BAR:
-      self->header_bar = g_value_get_object (value);
+    case PROP_RELATIVE_TO:
+      self->relative_to = g_value_get_object (value);
+      break;
+    case PROP_WINDOW:
+      self->window = g_value_get_object (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -80,16 +92,10 @@ static void
 ephy_add_bookmark_popover_constructed (GObject *object)
 {
   EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
-  GtkWidget *location_entry;
-  GtkWidget *bookmark;
 
   G_OBJECT_CLASS (ephy_add_bookmark_popover_parent_class)->constructed (object);
 
-  location_entry = GTK_WIDGET (ephy_header_bar_get_title_widget (self->header_bar));
-  g_assert (EPHY_IS_LOCATION_ENTRY (location_entry));
-  bookmark = ephy_location_entry_get_bookmark_widget (EPHY_LOCATION_ENTRY (location_entry));
-
-  gtk_popover_set_relative_to (GTK_POPOVER (self), bookmark);
+  gtk_popover_set_relative_to (GTK_POPOVER (self), self->relative_to);
 }
 
 static void
@@ -101,14 +107,34 @@ ephy_add_bookmark_popover_class_init (EphyAddBookmarkPopoverClass *klass)
   object_class->finalize = ephy_add_bookmark_popover_finalize;
   object_class->constructed = ephy_add_bookmark_popover_constructed;
 
-  obj_properties[PROP_HEADER_BAR] =
-    g_param_spec_object ("header-bar",
-                         "An EphyHeaderBar object",
-                         "The popover's parent EphyHeaderBar",
-                         EPHY_TYPE_HEADER_BAR,
+  obj_properties[PROP_RELATIVE_TO] =
+    g_param_spec_object ("relative-to",
+                         "A GtkWidget object",
+                         "The popover's parent widget",
+                         GTK_TYPE_WIDGET,
+                         G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+  obj_properties[PROP_WINDOW] =
+    g_param_spec_object ("window",
+                         "A GtkWidget object",
+                         "The popover's parent window",
+                         GTK_TYPE_WIDGET,
                          G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
 
   g_object_class_install_properties (object_class, LAST_PROP, obj_properties);
+
+  /**
+   * EphAddBookmarkPopover::update-state:
+   * @entry: the object on which the signal is emitted
+   *
+   * Emitted when the bookmark state changes
+   *
+   */
+  signals[UPDATE_STATE] = g_signal_new ("update-state", G_OBJECT_CLASS_TYPE (klass),
+                                        G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+                                        0, NULL, NULL, NULL,
+                                        G_TYPE_NONE,
+                                        1,
+                                        G_TYPE_INT);
 }
 
 static void
@@ -145,12 +171,12 @@ ephy_add_bookmark_popover_init (EphyAddBookmarkPopover *self)
 }
 
 GtkWidget *
-ephy_add_bookmark_popover_new (EphyHeaderBar *header_bar)
+ephy_add_bookmark_popover_new (GtkWidget *relative_to,
+                               GtkWidget *window)
 {
-  g_assert (EPHY_IS_HEADER_BAR (header_bar));
-
   return g_object_new (EPHY_TYPE_ADD_BOOKMARK_POPOVER,
-                       "header-bar", header_bar,
+                       "relative-to", relative_to,
+                       "window", window,
                        NULL);
 }
 
@@ -167,8 +193,6 @@ ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *s
                                                        EphyBookmark           *bookmark,
                                                        EphyBookmarksManager   *manager)
 {
-  GtkWidget *location_entry;
-  EphyWindow *window;
   EphyEmbed *embed;
   EphyWebView *view;
   const char *address;
@@ -177,17 +201,13 @@ ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *s
   g_assert (EPHY_IS_BOOKMARK (bookmark));
   g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
 
-  location_entry = GTK_WIDGET (ephy_header_bar_get_title_widget (self->header_bar));
-  window = ephy_header_bar_get_window (self->header_bar);
-  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (self->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_bookmark_icon_state (EPHY_LOCATION_ENTRY (location_entry),
-                                                 EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY);
-  }
+  if (g_strcmp0 (ephy_bookmark_get_url (bookmark), address) == 0)
+    g_signal_emit (self, signals[UPDATE_STATE], 0, EPHY_BOOKMARK_ICON_EMPTY);
 
   ephy_bookmarks_manager_save (manager,
                                ephy_bookmarks_manager_save_warn_on_error_cancellable (manager),
@@ -202,15 +222,11 @@ ephy_add_bookmark_popover_show (EphyAddBookmarkPopover *self)
 {
   EphyBookmarksManager *manager;
   EphyBookmark *bookmark;
-  EphyWindow *window;
-  EphyLocationEntry *location_entry;
   EphyEmbed *embed;
   const char *address;
 
   manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
-  location_entry = EPHY_LOCATION_ENTRY (ephy_header_bar_get_title_widget (self->header_bar));
-  window = ephy_header_bar_get_window (self->header_bar);
-  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (self->window));
 
   address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
 
@@ -226,8 +242,7 @@ ephy_add_bookmark_popover_show (EphyAddBookmarkPopover *self)
                                       id);
 
     ephy_bookmarks_manager_add_bookmark (manager, new_bookmark);
-    ephy_location_entry_set_bookmark_icon_state (location_entry,
-                                                 EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED);
+    g_signal_emit (self, signals[UPDATE_STATE], 0, EPHY_BOOKMARK_ICON_BOOKMARKED);
 
     bookmark = new_bookmark;
   }
diff --git a/src/bookmarks/ephy-add-bookmark-popover.h b/src/bookmarks/ephy-add-bookmark-popover.h
index 41d19dee8..3dc5066ca 100644
--- a/src/bookmarks/ephy-add-bookmark-popover.h
+++ b/src/bookmarks/ephy-add-bookmark-popover.h
@@ -30,7 +30,8 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyAddBookmarkPopover, ephy_add_bookmark_popover, EPHY, ADD_BOOKMARK_POPOVER, 
GtkPopover)
 
-GtkWidget       *ephy_add_bookmark_popover_new      (EphyHeaderBar *header_bar);
+GtkWidget       *ephy_add_bookmark_popover_new      (GtkWidget *relative_to,
+                                                     GtkWidget *window);
 
 void             ephy_add_bookmark_popover_show     (EphyAddBookmarkPopover *self);
 
diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c
index 4f56c7248..ef118565c 100644
--- a/src/ephy-action-bar-end.c
+++ b/src/ephy-action-bar-end.c
@@ -20,9 +20,11 @@
  */
 
 #include "ephy-action-bar-end.h"
+#include "ephy-add-bookmark-popover.h"
 #include "ephy-desktop-utils.h"
 #include "ephy-downloads-popover.h"
 #include "ephy-downloads-progress-icon.h"
+#include "ephy-location-entry.h"
 #include "ephy-shell.h"
 #include "ephy-window.h"
 
@@ -33,6 +35,8 @@
 struct _EphyActionBarEnd {
   GtkBox parent_instance;
 
+  GtkWidget *bookmark_button;
+  GtkWidget *bookmark_image;
   GtkWidget *bookmarks_button;
   GtkWidget *downloads_revealer;
   GtkWidget *downloads_button;
@@ -228,6 +232,12 @@ ephy_action_bar_end_class_init (EphyActionBarEndClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/org/gnome/epiphany/gtk/action-bar-end.ui");
 
+  gtk_widget_class_bind_template_child (widget_class,
+                                        EphyActionBarEnd,
+                                        bookmark_button);
+  gtk_widget_class_bind_template_child (widget_class,
+                                        EphyActionBarEnd,
+                                        bookmark_image);
   gtk_widget_class_bind_template_child (widget_class,
                                         EphyActionBarEnd,
                                         bookmarks_button);
@@ -248,6 +258,17 @@ ephy_action_bar_end_class_init (EphyActionBarEndClass *klass)
                                         browser_action_box);
 }
 
+static void
+add_bookmark_button_clicked_cb (EphyActionBarEnd *action_bar_end)
+{
+  GtkWidget *window = gtk_widget_get_toplevel (GTK_WIDGET (action_bar_end->bookmark_button));
+  GtkWidget *popover = ephy_add_bookmark_popover_new (GTK_WIDGET (action_bar_end->bookmark_button), window);
+
+  g_signal_connect_object (popover, "update-state", G_CALLBACK (ephy_window_sync_bookmark_state), 
action_bar_end, G_CONNECT_SWAPPED);
+
+  ephy_add_bookmark_popover_show (EPHY_ADD_BOOKMARK_POPOVER (popover));
+}
+
 static void
 ephy_action_bar_end_init (EphyActionBarEnd *action_bar_end)
 {
@@ -296,6 +317,10 @@ ephy_action_bar_end_init (EphyActionBarEnd *action_bar_end)
   g_signal_connect_object (downloads_manager, "show-downloads",
                            G_CALLBACK (show_downloads_cb),
                            object, 0);
+
+  g_signal_connect_object (action_bar_end->bookmark_button, "clicked",
+                           G_CALLBACK (add_bookmark_button_clicked_cb), action_bar_end,
+                           G_CONNECT_SWAPPED);
 }
 
 EphyActionBarEnd *
@@ -342,3 +367,38 @@ ephy_action_bar_end_add_browser_action (EphyActionBarEnd *action_bar_end,
 {
   gtk_container_add (GTK_CONTAINER (action_bar_end->browser_action_box), action);
 }
+
+void
+ephy_action_bar_end_set_show_bookmark_button (EphyActionBarEnd *action_bar_end,
+                                              gboolean          show)
+{
+  gtk_widget_set_visible (action_bar_end->bookmark_button, show);
+}
+
+
+void
+ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd      *action_bar_end,
+                                             EphyBookmarkIconState  state)
+{
+  g_assert (EPHY_IS_ACTION_BAR_END (action_bar_end));
+
+  switch (state) {
+    case EPHY_BOOKMARK_ICON_HIDDEN:
+      gtk_widget_set_visible (action_bar_end->bookmark_button, FALSE);
+      break;
+    case EPHY_BOOKMARK_ICON_EMPTY:
+      gtk_widget_set_visible (action_bar_end->bookmark_button, TRUE);
+      gtk_image_set_from_icon_name (GTK_IMAGE (action_bar_end->bookmark_image),
+                                    "non-starred-symbolic",
+                                    GTK_ICON_SIZE_BUTTON);
+      break;
+    case EPHY_BOOKMARK_ICON_BOOKMARKED:
+      gtk_widget_set_visible (action_bar_end->bookmark_button, TRUE);
+      gtk_image_set_from_icon_name (GTK_IMAGE (action_bar_end->bookmark_image),
+                                    "starred-symbolic",
+                                    GTK_ICON_SIZE_BUTTON);
+      break;
+    default:
+      g_assert_not_reached ();
+  }
+}
diff --git a/src/ephy-action-bar-end.h b/src/ephy-action-bar-end.h
index 4be334df7..ffecf9596 100644
--- a/src/ephy-action-bar-end.h
+++ b/src/ephy-action-bar-end.h
@@ -21,6 +21,8 @@
 
 #pragma once
 
+#include "ephy-bookmark-states.h"
+
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
@@ -39,4 +41,10 @@ GtkWidget        *ephy_action_bar_end_get_downloads_revealer    (EphyActionBarEn
 void              ephy_action_bar_end_add_browser_action        (EphyActionBarEnd *action_bar_end,
                                                                  GtkWidget        *action);
 
+void              ephy_action_bar_end_set_show_bookmark_button (EphyActionBarEnd *action_bar_end,
+                                                                gboolean          show);
+
+void              ephy_action_bar_end_set_bookmark_icon_state (EphyActionBarEnd       *action_bar_end,
+                                                               EphyBookmarkIconState  state);
+
 G_END_DECLS
diff --git a/src/ephy-action-bar.c b/src/ephy-action-bar.c
index 17fbfa481..123d6001b 100644
--- a/src/ephy-action-bar.c
+++ b/src/ephy-action-bar.c
@@ -20,6 +20,8 @@
  */
 
 #include "ephy-action-bar.h"
+#include "ephy-add-bookmark-popover.h"
+#include "ephy-location-entry.h"
 #include "ephy-pages-button.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
@@ -228,6 +230,8 @@ ephy_action_bar_set_adaptive_mode (EphyActionBar    *action_bar,
                                    EphyAdaptiveMode  adaptive_mode)
 {
   action_bar->adaptive_mode = adaptive_mode;
+  ephy_action_bar_end_set_show_bookmark_button (action_bar->action_bar_end,
+                                                adaptive_mode == EPHY_ADAPTIVE_MODE_NARROW);
 
   update_revealer (action_bar);
 }
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 6f509b200..2590b5acd 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -255,8 +255,11 @@ ephy_header_bar_constructed (GObject *object)
   gtk_widget_show (GTK_WIDGET (header_bar->title_widget));
 
   if (EPHY_IS_LOCATION_ENTRY (header_bar->title_widget)) {
-    ephy_location_entry_set_add_bookmark_popover (EPHY_LOCATION_ENTRY (header_bar->title_widget),
-                                                  GTK_POPOVER (ephy_add_bookmark_popover_new (header_bar)));
+    EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (header_bar->title_widget);
+    GtkWidget *popover = ephy_add_bookmark_popover_new (ephy_location_entry_get_bookmark_widget (lentry), 
GTK_WIDGET (header_bar->window));
+
+    g_signal_connect_object (popover, "update-state", G_CALLBACK (ephy_window_sync_bookmark_state), 
header_bar, G_CONNECT_SWAPPED);
+    ephy_location_entry_set_add_bookmark_popover (lentry, GTK_POPOVER (popover));
 
     g_signal_connect_object (header_bar->title_widget,
                              "bookmark-clicked",
@@ -443,6 +446,9 @@ void
 ephy_header_bar_set_adaptive_mode (EphyHeaderBar    *header_bar,
                                    EphyAdaptiveMode  adaptive_mode)
 {
+  ephy_action_bar_end_set_show_bookmark_button (header_bar->action_bar_end,
+                                                adaptive_mode == EPHY_ADAPTIVE_MODE_NARROW);
+
   switch (adaptive_mode) {
     case EPHY_ADAPTIVE_MODE_NORMAL:
       gtk_revealer_set_reveal_child (GTK_REVEALER (header_bar->start_revealer), TRUE);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 695dd5a84..b74e98f31 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -26,6 +26,7 @@
 
 #include "ephy-action-bar.h"
 #include "ephy-action-helper.h"
+#include "ephy-bookmark-states.h"
 #include "ephy-bookmarks-manager.h"
 #include "ephy-debug.h"
 #include "ephy-desktop-utils.h"
@@ -1226,15 +1227,34 @@ sync_tab_is_blank (EphyWebView *view,
                                               ephy_web_view_get_is_blank (view));
 }
 
+void
+ephy_window_sync_bookmark_state (GtkWidget             *widget,
+                                 EphyBookmarkIconState  state)
+{
+  GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (widget));
+  EphyWindow *window = EPHY_WINDOW (toplevel);
+  EphyActionBarEnd *action_bar_end = ephy_action_bar_get_action_bar_end (EPHY_ACTION_BAR 
(window->action_bar));
+  GtkWidget *lentry;
+
+  if (action_bar_end)
+    ephy_action_bar_end_set_bookmark_icon_state (EPHY_ACTION_BAR_END (action_bar_end), state);
+
+  lentry = GTK_WIDGET (ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (window->header_bar)));
+
+  if (EPHY_IS_LOCATION_ENTRY (lentry))
+    ephy_location_entry_set_bookmark_icon_state (EPHY_LOCATION_ENTRY (lentry), state);
+}
+
 static void
 sync_tab_bookmarked_status (EphyWebView *view,
                             GParamSpec  *pspec,
                             EphyWindow  *window)
 {
+  EphyActionBarEnd *action_bar_end = ephy_action_bar_get_action_bar_end (EPHY_ACTION_BAR 
(window->action_bar));
   EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
   EphyEmbedShell *shell = ephy_embed_shell_get_default ();
   EphyEmbedShellMode mode;
-  EphyLocationEntryBookmarkIconState state;
+  EphyBookmarkIconState state;
   GtkWidget *widget;
   EphyBookmark *bookmark;
   const char *address;
@@ -1251,13 +1271,14 @@ sync_tab_bookmarked_status (EphyWebView *view,
       ephy_embed_utils_is_no_show_address (address) ||
       mode == EPHY_EMBED_SHELL_MODE_INCOGNITO ||
       mode == EPHY_EMBED_SHELL_MODE_AUTOMATION) {
-    state = EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN;
+    state = EPHY_BOOKMARK_ICON_HIDDEN;
   } else {
     bookmark = ephy_bookmarks_manager_get_bookmark_by_url (manager, address);
-    state = bookmark ? EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED
-                     : EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY;
+    state = bookmark ? EPHY_BOOKMARK_ICON_BOOKMARKED
+                     : EPHY_BOOKMARK_ICON_EMPTY;
   }
 
+  ephy_action_bar_end_set_bookmark_icon_state (EPHY_ACTION_BAR_END (action_bar_end), state);
   ephy_location_entry_set_bookmark_icon_state (EPHY_LOCATION_ENTRY (widget), state);
 }
 
diff --git a/src/ephy-window.h b/src/ephy-window.h
index cdd40fd6f..1c7a1459d 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include "ephy-bookmark-states.h"
 #include "ephy-bookmarks-manager.h"
 #include "ephy-embed.h"
 #include "ephy-embed-event.h"
@@ -95,4 +96,7 @@ gboolean          ephy_window_is_fullscreen              (EphyWindow *window);
 void              ephy_window_get_geometry               (EphyWindow   *window,
                                                           GdkRectangle *rectangle);
 
+void ephy_window_sync_bookmark_state (GtkWidget             *widget,
+                                      EphyBookmarkIconState  state);
+
 G_END_DECLS
diff --git a/src/resources/ephy-library-symbolic.svg b/src/resources/ephy-library-symbolic.svg
new file mode 100644
index 000000000..cb8f5abfb
--- /dev/null
+++ b/src/resources/ephy-library-symbolic.svg
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb";
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   inkscape:version="1.0 (4035a4fb49, 2020-05-01)"
+   sodipodi:docname="library-symbolic.svg"
+   height="16"
+   id="svg7384"
+   version="1.1"
+   width="16">
+  <sodipodi:namedview
+     inkscape:snap-nodes="false"
+     inkscape:snap-bbox-edge-midpoints="true"
+     inkscape:bbox-nodes="true"
+     inkscape:bbox-paths="true"
+     inkscape:snap-bbox="true"
+     inkscape:document-rotation="0"
+     inkscape:current-layer="svg7384"
+     inkscape:window-maximized="1"
+     inkscape:window-y="0"
+     inkscape:window-x="0"
+     inkscape:cy="17.615062"
+     inkscape:cx="20.519029"
+     inkscape:zoom="9.0553378"
+     inkscape:snap-page="true"
+     inkscape:snap-text-baseline="true"
+     inkscape:snap-center="true"
+     inkscape:snap-object-midpoints="true"
+     inkscape:snap-intersection-paths="true"
+     inkscape:object-paths="true"
+     inkscape:snap-midpoints="true"
+     inkscape:snap-smooth-nodes="true"
+     showgrid="false"
+     id="namedview16"
+     inkscape:window-height="1016"
+     inkscape:window-width="1920"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0"
+     guidetolerance="10"
+     gridtolerance="10"
+     objecttolerance="10"
+     borderopacity="1"
+     bordercolor="#666666"
+     pagecolor="#ffffff">
+    <inkscape:grid
+       id="grid835"
+       type="xygrid" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata90">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title>Gnome Symbolic Icon Theme</dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <title
+     id="title9167">Gnome Symbolic Icon Theme</title>
+  <defs
+     id="defs7386">
+    <linearGradient
+       id="linearGradient7212"
+       osb:paint="solid">
+      <stop
+         id="stop7214"
+         offset="0"
+         style="stop-color:#000000;stop-opacity:1;" />
+    </linearGradient>
+  </defs>
+  <rect
+     ry="0.5"
+     rx="0.5"
+     y="2"
+     x="1"
+     height="13"
+     width="3"
+     id="rect837"
+     style="fill:#241f31;fill-opacity:1;stroke-width:0.917791;stroke-linecap:round;stroke-linejoin:round" />
+  <rect
+     ry="0.5"
+     rx="0.5"
+     style="fill:#241f31;fill-opacity:1;stroke-width:0.844245;stroke-linecap:round;stroke-linejoin:round"
+     id="rect839"
+     width="2"
+     height="11"
+     x="5"
+     y="4" />
+  <rect
+     ry="0.5"
+     rx="0.5"
+     y="3"
+     x="8"
+     height="12"
+     width="2"
+     id="rect841"
+     style="fill:#241f31;fill-opacity:1;stroke-width:0.881785;stroke-linecap:round;stroke-linejoin:round" />
+  <rect
+     ry="0.5"
+     rx="0.5"
+     transform="rotate(-15)"
+     style="fill:#241f31;fill-opacity:1;stroke-width:0.952437;stroke-linecap:round;stroke-linejoin:round"
+     id="rect843"
+     width="2"
+     height="14"
+     x="9.462719"
+     y="4.1807427" />
+</svg>
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index 835d3efee..a1b1a1885 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -46,7 +46,6 @@
   </gresource>
   <gresource prefix="/org/gnome/Epiphany/icons">
     <file compressed="true" alias="scalable/actions/ephy-download-symbolic.svg" 
preprocess="xml-stripblanks">ephy-download-symbolic.svg</file>
-    <file compressed="true" 
alias="scalable/actions/ephy-bookmarks-symbolic.svg">ephy-bookmarks-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/actions/ephy-bookmark-tag-symbolic.svg">ephy-bookmark-tag-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/actions/ephy-reader-mode-symbolic.svg">ephy-reader-mode-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-audio-muted-symbolic.svg">ephy-audio-muted-symbolic.svg</file>
@@ -54,6 +53,7 @@
     <file compressed="true" 
alias="scalable/status/ephy-open-link-symbolic.svg">ephy-open-link-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-tab-counter-symbolic.svg">ephy-tab-counter-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/status/ephy-tab-overflow-symbolic.svg">ephy-tab-overflow-symbolic.svg</file>
+    <file compressed="true" 
alias="scalable/status/ephy-library-symbolic.svg">ephy-library-symbolic.svg</file>
   </gresource>
   <gresource prefix="/org/gnome/Epiphany">
     <file compressed="true">themes/shared.css</file>
diff --git a/src/resources/gtk/action-bar-end.ui b/src/resources/gtk/action-bar-end.ui
index a1b68bf7c..902ea47c4 100644
--- a/src/resources/gtk/action-bar-end.ui
+++ b/src/resources/gtk/action-bar-end.ui
@@ -27,7 +27,7 @@
         <child>
           <object class="GtkImage" id="bookmarks_image">
             <property name="visible">True</property>
-            <property name="icon-name">ephy-bookmarks-symbolic</property>
+            <property name="icon-name">ephy-library-symbolic</property>
             <property name="icon-size">1</property>
           </object>
         </child>
@@ -36,6 +36,27 @@
         <property name="pack-type">end</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkButton" id="bookmark_button">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <!-- Translators: tooltip for the bookmark button -->
+        <property name="tooltip_text" translatable="yes">Bookmark page</property>
+        <child>
+          <object class="GtkImage" id="bookmark_image">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="icon_name">non-starred-symbolic</property>
+          </object>
+        </child>
+        <style>
+          <class name="image-button"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkRevealer" id="downloads_revealer">
         <property name="visible">True</property>


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