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



commit f79108840b9ff2434032a6412634c966680ea42f
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Tue Jul 28 19:49:51 2020 +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 https://gitlab.gnome.org/GNOME/epiphany/-/issues/1172

 lib/ephy-bookmark-states.h                |  28 +++++++
 lib/widgets/ephy-location-entry.c         |  27 +++++--
 lib/widgets/ephy-location-entry.h         |  14 ++--
 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                     |   5 ++
 src/ephy-header-bar.c                     |  12 ++-
 src/ephy-window.c                         |  28 ++++++-
 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       |  22 +++++-
 15 files changed, 354 insertions(+), 146 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 4c8ea0a36..416575603 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -69,6 +69,7 @@ struct _EphyLocationEntry {
 
   gboolean reader_mode_active;
   gboolean button_release_is_blocked;
+  gboolean mobile_mode;
 
   char *saved_text;
   char *jump_tab;
@@ -87,6 +88,7 @@ struct _EphyLocationEntry {
   guint original_address : 1;
 
   EphySecurityLevel security_level;
+  EphyBookmarkIconState icon_state;
 };
 
 static gboolean ephy_location_entry_reset_internal (EphyLocationEntry *,
@@ -1320,8 +1322,8 @@ ephy_location_entry_focus (EphyLocationEntry *entry)
 }
 
 void
-ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry                  *entry,
-                                             EphyLocationEntryBookmarkIconState  state)
+ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry     *entry,
+                                             EphyBookmarkIconState  state)
 {
   GtkStyleContext *context;
 
@@ -1329,13 +1331,18 @@ ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry
 
   context = gtk_widget_get_style_context (GTK_WIDGET (entry->bookmark));
 
+  entry->icon_state = state;
+
+  if (entry->mobile_mode)
+    state = EPHY_BOOKMARK_ICON_HIDDEN;
+
   switch (state) {
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_HIDDEN:
+    case EPHY_BOOKMARK_ICON_HIDDEN:
       gtk_widget_set_visible (entry->bookmark_event_box, FALSE);
       gtk_style_context_remove_class (context, "starred");
       gtk_style_context_remove_class (context, "non-starred");
       break;
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_EMPTY:
+    case EPHY_BOOKMARK_ICON_EMPTY:
       gtk_widget_set_visible (entry->bookmark_event_box, TRUE);
       gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark),
                                     "non-starred-symbolic",
@@ -1343,7 +1350,7 @@ ephy_location_entry_set_bookmark_icon_state (EphyLocationEntry
       gtk_style_context_remove_class (context, "starred");
       gtk_style_context_add_class (context, "non-starred");
       break;
-    case EPHY_LOCATION_ENTRY_BOOKMARK_ICON_BOOKMARKED:
+    case EPHY_BOOKMARK_ICON_BOOKMARKED:
       gtk_widget_set_visible (entry->bookmark_event_box, TRUE);
       gtk_image_set_from_icon_name (GTK_IMAGE (entry->bookmark),
                                     "starred-symbolic",
@@ -1497,11 +1504,15 @@ ephy_location_entry_set_progress (EphyLocationEntry *entry,
 }
 
 void
-ephy_location_entry_set_mobile_popdown (EphyLocationEntry *entry,
-                                        gboolean           mobile_popdown)
+ephy_location_entry_set_mobile_mode (EphyLocationEntry *entry,
+                                     gboolean           mobile)
 {
-  if (mobile_popdown)
+  if (mobile)
     dzl_suggestion_entry_set_position_func (DZL_SUGGESTION_ENTRY (entry->url_entry), 
dzl_suggestion_entry_window_position_func, NULL, NULL);
   else
     dzl_suggestion_entry_set_position_func (DZL_SUGGESTION_ENTRY (entry->url_entry), position_func, NULL, 
NULL);
+
+
+  entry->mobile_mode = mobile;
+  ephy_location_entry_set_bookmark_icon_state (entry, entry->icon_state);
 }
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index fb8074b83..96c2de273 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -25,6 +25,7 @@
 
 #include <gtk/gtk.h>
 
+#include "ephy-bookmark-states.h"
 #include "ephy-security-levels.h"
 
 G_BEGIN_DECLS
@@ -33,11 +34,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);
 
@@ -51,8 +47,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);
@@ -80,7 +76,7 @@ void            ephy_location_entry_set_progress               (EphyLocationEntr
                                                                 gdouble            progress,
                                                                 gboolean           loading);
 
-void            ephy_location_entry_set_mobile_popdown         (EphyLocationEntry *entry,
-                                                                gboolean           mobile_popdown);
+void            ephy_location_entry_set_mobile_mode            (EphyLocationEntry *entry,
+                                                                gboolean           mobile);
 
 G_END_DECLS
diff --git a/src/bookmarks/ephy-add-bookmark-popover.c b/src/bookmarks/ephy-add-bookmark-popover.c
index 1fd476c83..3977f486c 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 7775e0ce2..8fee25dec 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;
@@ -227,6 +231,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);
@@ -244,6 +254,17 @@ ephy_action_bar_end_class_init (EphyActionBarEndClass *klass)
                                         downloads_progress);
 }
 
+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)
 {
@@ -292,6 +313,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 *
@@ -319,3 +344,38 @@ ephy_action_bar_end_get_downloads_revealer (EphyActionBarEnd *action_bar_end)
 {
   return action_bar_end->downloads_revealer;
 }
+
+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 a0d397bc9..81bab0b0d 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
@@ -34,4 +36,10 @@ void              ephy_action_bar_end_set_show_bookmarks_button (EphyActionBarEn
                                                                  gboolean          show);
 GtkWidget        *ephy_action_bar_end_get_downloads_revealer    (EphyActionBarEnd *action_bar_end);
 
+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 c28ce6bac..a1d89fb56 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-pages-popover.h"
 #include "ephy-settings.h"
@@ -224,6 +226,9 @@ void
 ephy_action_bar_set_adaptive_mode (EphyActionBar    *action_bar,
                                    EphyAdaptiveMode  adaptive_mode)
 {
+  ephy_action_bar_end_set_show_bookmark_button (action_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 (action_bar), FALSE);
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index a248b0ef9..c2c9f22bf 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -236,8 +236,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",
@@ -417,6 +420,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);
@@ -433,7 +439,7 @@ ephy_header_bar_set_adaptive_mode (EphyHeaderBar    *header_bar,
   }
 
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION)
-    ephy_location_entry_set_mobile_popdown (EPHY_LOCATION_ENTRY (header_bar->title_widget), adaptive_mode == 
EPHY_ADAPTIVE_MODE_NARROW);
+    ephy_location_entry_set_mobile_mode (EPHY_LOCATION_ENTRY (header_bar->title_widget), adaptive_mode == 
EPHY_ADAPTIVE_MODE_NARROW);
 }
 
 void
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 7f4cefa8a..a12057048 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"
@@ -1221,15 +1222,33 @@ 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;
@@ -1246,13 +1265,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 01c272846..6f7a2587d 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"
@@ -97,4 +98,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 861486aec..b335d6001 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -45,7 +45,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-missing-favicon-symbolic.svg">ephy-missing-favicon-symbolic.svg</file>
     <file compressed="true" 
alias="scalable/actions/ephy-reader-mode-symbolic.svg">ephy-reader-mode-symbolic.svg</file>
@@ -53,6 +52,7 @@
     <file compressed="true" 
alias="scalable/status/ephy-audio-playing-symbolic.svg">ephy-audio-playing-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 6e03dbfc6..cd56c34ea 100644
--- a/src/resources/gtk/action-bar-end.ui
+++ b/src/resources/gtk/action-bar-end.ui
@@ -1,5 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
+  <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>
   <template class="EphyActionBarEnd" parent="GtkBox">
     <property name="spacing">6</property>
     <child>
@@ -15,7 +20,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>
@@ -24,6 +29,21 @@
         <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>
+        <property name="image">bookmark_image</property>
+        <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]