[epiphany/wip/exalm/gtk4: 13/14] Clean up EphyAddBookmarkPopover




commit 096e0505fe48ada9aa3740902d9696ca2749ba26
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Feb 21 16:15:43 2022 +0500

    Clean up EphyAddBookmarkPopover
    
    - Don't reimplement :relative-to, it already exists on GtkPopover
    - Make buttons handling the popover GtkMenuButtons
    - Remove dead code handling GtkEntry icon clicking from location entry
    - Remove ephy_location_entry_get_bookmark_widget() and
      ephy_location_entry_get_add_bookmark_popover(), add
      ephy_location_entry_show_add_bookmark_popover() instead so we don't
      expose widgetry
    - Make ephy_window_sync_bookmark_state() first param an EphyWindow instead
      of an arbitrary widget inside a window
    - That function only existed to be EphyAddBookmarkPopover::update-state
      callback, just call it directly instead
    - Remove ephy_add_bookmark_popover_show(), make it happen automatically
    - Don't pass a window into EphyAddBookmarkPopover, it can get it itself

 lib/widgets/ephy-location-entry.c         |  57 ++-----
 lib/widgets/ephy-location-entry.h         |   4 +-
 src/bookmarks/ephy-add-bookmark-popover.c | 250 +++++++++++-------------------
 src/bookmarks/ephy-add-bookmark-popover.h |   5 +-
 src/ephy-action-bar-end.c                 |  18 +--
 src/ephy-header-bar.c                     |  23 +--
 src/ephy-window.c                         |   4 +-
 src/ephy-window.h                         |   4 +-
 src/resources/gtk/action-bar-end.ui       |   2 +-
 src/window-commands.c                     |   5 +-
 10 files changed, 119 insertions(+), 253 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index cb626f351..ccb85da0f 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -104,7 +104,6 @@ enum {
 
 enum signalsEnum {
   USER_CHANGED,
-  BOOKMARK_CLICKED,
   GET_LOCATION,
   GET_TITLE,
   LAST_SIGNAL
@@ -527,20 +526,6 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
                                         0,
                                         G_TYPE_NONE);
 
-  /**
-   * EphyLocationEntry::bookmark-clicked:
-   * @entry: the object on which the signal is emitted
-   *
-   * Emitted when the user clicks the bookmark icon inside the
-   * #EphyLocationEntry.
-   *
-   */
-  signals[BOOKMARK_CLICKED] = g_signal_new ("bookmark-clicked", G_OBJECT_CLASS_TYPE (klass),
-                                            G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
-                                            0, NULL, NULL, NULL,
-                                            G_TYPE_NONE,
-                                            0);
-
   /**
    * EphyLocationEntry::get-location:
    * @entry: the object on which the signal is emitted
@@ -813,8 +798,6 @@ icon_button_icon_press_event_cb (GtkWidget            *widget,
       GdkRectangle lock_position;
       gtk_entry_get_icon_area (GTK_ENTRY (entry->url_entry), GTK_ENTRY_ICON_PRIMARY, &lock_position);
       g_signal_emit_by_name (entry, "lock-clicked", &lock_position);
-    } else {
-      g_signal_emit (entry, signals[BOOKMARK_CLICKED], 0);
     }
     return TRUE;
   }
@@ -822,13 +805,6 @@ icon_button_icon_press_event_cb (GtkWidget            *widget,
   return FALSE;
 }
 
-static void
-bookmark_icon_button_clicked_cb (GtkButton         *button,
-                                 EphyLocationEntry *lentry)
-{
-  g_signal_emit (lentry, signals[BOOKMARK_CLICKED], 0);
-}
-
 static GtkBorder
 get_progress_margin (EphyLocationEntry *entry)
 {
@@ -1130,14 +1106,18 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
                            G_CALLBACK (update_reader_icon), entry, G_CONNECT_SWAPPED);
 
   /* Bookmark */
-  entry->bookmark_button = gtk_button_new_from_icon_name ("non-starred-symbolic", GTK_ICON_SIZE_MENU);
-  gtk_widget_set_tooltip_text (entry->bookmark_button, _("Bookmark this page"));
-  entry->bookmark_icon = gtk_button_get_image (GTK_BUTTON (entry->bookmark_button));
-  g_signal_connect (G_OBJECT (entry->bookmark_button), "clicked", G_CALLBACK 
(bookmark_icon_button_clicked_cb), entry);
-  gtk_box_pack_start (GTK_BOX (box), entry->bookmark_button, FALSE, TRUE, 0);
-
+  entry->bookmark_icon = gtk_image_new_from_icon_name ("non-starred-symbolic", GTK_ICON_SIZE_MENU);
   context = gtk_widget_get_style_context (entry->bookmark_icon);
   gtk_style_context_add_class (context, "entry_icon");
+  gtk_widget_show (entry->bookmark_icon);
+
+  entry->bookmark_button = gtk_menu_button_new ();
+  gtk_container_add (GTK_CONTAINER (entry->bookmark_button), entry->bookmark_icon);
+  context = gtk_widget_get_style_context (entry->bookmark_button);
+  gtk_style_context_add_class (context, "image-button");
+
+  gtk_widget_set_tooltip_text (entry->bookmark_button, _("Bookmark this page"));
+  gtk_box_pack_start (GTK_BOX (box), entry->bookmark_button, FALSE, TRUE, 0);
 
   g_settings_bind (EPHY_SETTINGS_LOCKDOWN,
                    EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING,
@@ -1454,13 +1434,16 @@ ephy_location_entry_set_add_bookmark_popover (EphyLocationEntry *entry,
   g_assert (EPHY_IS_LOCATION_ENTRY (entry));
   g_assert (GTK_IS_POPOVER (popover));
 
-  entry->add_bookmark_popover = popover;
+  gtk_menu_button_set_popover (GTK_MENU_BUTTON (entry->bookmark_button),
+                               GTK_WIDGET (popover));
 }
 
-GtkPopover *
-ephy_location_entry_get_add_bookmark_popover (EphyLocationEntry *entry)
+void
+ephy_location_entry_show_add_bookmark_popover (EphyLocationEntry *entry)
 {
-  return entry->add_bookmark_popover;
+  GtkPopover *popover = gtk_menu_button_get_popover (GTK_MENU_BUTTON (entry->bookmark_button));
+
+  gtk_popover_popup (popover);
 }
 
 GtkWidget *
@@ -1469,12 +1452,6 @@ ephy_location_entry_get_entry (EphyLocationEntry *entry)
   return GTK_WIDGET (entry->url_entry);
 }
 
-GtkWidget *
-ephy_location_entry_get_bookmark_widget (EphyLocationEntry *entry)
-{
-  return entry->bookmark_button;
-}
-
 GtkWidget *
 ephy_location_entry_get_reader_mode_widget (EphyLocationEntry *entry)
 {
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index a344128c7..8d8178d2e 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -57,12 +57,10 @@ void            ephy_location_entry_set_lock_tooltip           (EphyLocationEntr
 void            ephy_location_entry_set_add_bookmark_popover   (EphyLocationEntry *entry,
                                                                 GtkPopover        *popover);
 
-GtkPopover     *ephy_location_entry_get_add_bookmark_popover   (EphyLocationEntry *entry);
+void            ephy_location_entry_show_add_bookmark_popover  (EphyLocationEntry *entry);
 
 GtkWidget      *ephy_location_entry_get_entry                  (EphyLocationEntry *entry);
 
-GtkWidget      *ephy_location_entry_get_bookmark_widget        (EphyLocationEntry *entry);
-
 GtkWidget      *ephy_location_entry_get_reader_mode_widget     (EphyLocationEntry *entry);
 
 void            ephy_location_entry_set_reader_mode_visible    (EphyLocationEntry *entry,
diff --git a/src/bookmarks/ephy-add-bookmark-popover.c b/src/bookmarks/ephy-add-bookmark-popover.c
index 71bb3fd50..af6fc205d 100644
--- a/src/bookmarks/ephy-add-bookmark-popover.c
+++ b/src/bookmarks/ephy-add-bookmark-popover.c
@@ -35,164 +35,17 @@ struct _EphyAddBookmarkPopover {
   char *address;
 
   GtkWidget *grid;
-  GtkWidget *relative_to;
-  GtkWindow *window;
 };
 
 G_DEFINE_TYPE (EphyAddBookmarkPopover, ephy_add_bookmark_popover, GTK_TYPE_POPOVER)
 
-enum {
-  PROP_0,
-  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
-ephy_bookmarks_popover_set_property (GObject      *object,
-                                     guint         prop_id,
-                                     const GValue *value,
-                                     GParamSpec   *pspec)
-{
-  EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
-
-  switch (prop_id) {
-    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);
-  }
-}
-
-static void
-ephy_add_bookmark_popover_finalize (GObject *object)
-{
-  EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
-
-  if (self->address)
-    g_free (self->address);
-
-  G_OBJECT_CLASS (ephy_add_bookmark_popover_parent_class)->finalize (object);
-}
-
-static void
-ephy_add_bookmark_popover_constructed (GObject *object)
-{
-  EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
-
-  G_OBJECT_CLASS (ephy_add_bookmark_popover_parent_class)->constructed (object);
-
-  gtk_popover_set_relative_to (GTK_POPOVER (self), self->relative_to);
-}
-
-static void
-ephy_add_bookmark_popover_class_init (EphyAddBookmarkPopoverClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->set_property = ephy_bookmarks_popover_set_property;
-  object_class->finalize = ephy_add_bookmark_popover_finalize;
-  object_class->constructed = ephy_add_bookmark_popover_constructed;
-
-  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
-ephy_add_bookmark_popover_notify_visible_cb (GtkPopover *popover,
-                                             GParamSpec *param,
-                                             gpointer    user_data)
-{
-  EphyAddBookmarkPopover *self;
-  EphyBookmarksManager *manager;
-
-  g_assert (EPHY_IS_ADD_BOOKMARK_POPOVER (popover));
-
-  if (gtk_widget_get_visible (GTK_WIDGET (popover)))
-    return;
-
-  self = EPHY_ADD_BOOKMARK_POPOVER (popover);
-  manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
-
-  ephy_bookmarks_manager_save (manager,
-                               ephy_bookmarks_manager_save_warn_on_error_cancellable (manager),
-                               ephy_bookmarks_manager_save_warn_on_error_cb,
-                               NULL);
-
-  g_clear_pointer (&self->address, g_free);
-  g_clear_pointer (&self->grid, gtk_widget_destroy);
-}
-
-static void
-ephy_add_bookmark_popover_init (EphyAddBookmarkPopover *self)
-{
-  g_signal_connect (self, "notify::visible",
-                    G_CALLBACK (ephy_add_bookmark_popover_notify_visible_cb),
-                    NULL);
-}
-
-GtkWidget *
-ephy_add_bookmark_popover_new (GtkWidget *relative_to,
-                               GtkWidget *window)
-{
-  return g_object_new (EPHY_TYPE_ADD_BOOKMARK_POPOVER,
-                       "relative-to", relative_to,
-                       "window", window,
-                       NULL);
-}
-
-/**
- * update_bookmarked_status_cb:
- * @bookmark: an #EphyBookmark object
- * @header_bar: an #EphyHeaderBar widget
- *
- * Remove bookmarked status if the @bookmark was removed.
- *
- **/
 static void
-ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *self,
-                                                       EphyBookmark           *bookmark,
-                                                       EphyBookmarksManager   *manager)
+bookmark_removed_cb (EphyAddBookmarkPopover *self,
+                     EphyBookmark           *bookmark,
+                     EphyBookmarksManager   *manager)
 {
+  GtkWidget *relative_to;
+  GtkWidget *window;
   EphyEmbed *embed;
   EphyWebView *view;
   const char *address;
@@ -201,13 +54,19 @@ ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *s
   g_assert (EPHY_IS_BOOKMARK (bookmark));
   g_assert (EPHY_IS_BOOKMARKS_MANAGER (manager));
 
-  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (self->window));
+  relative_to = gtk_popover_get_relative_to (GTK_POPOVER (self));
+
+  if (!relative_to)
+    return;
+
+  window = gtk_widget_get_toplevel (relative_to);
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (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)
-    g_signal_emit (self, signals[UPDATE_STATE], 0, EPHY_BOOKMARK_ICON_EMPTY);
+    ephy_window_sync_bookmark_state (EPHY_WINDOW (window), EPHY_BOOKMARK_ICON_EMPTY);
 
   ephy_bookmarks_manager_save (manager,
                                ephy_bookmarks_manager_save_warn_on_error_cancellable (manager),
@@ -217,16 +76,24 @@ ephy_add_bookmark_popover_update_bookmarked_status_cb (EphyAddBookmarkPopover *s
   gtk_popover_popdown (GTK_POPOVER (self));
 }
 
-void
-ephy_add_bookmark_popover_show (EphyAddBookmarkPopover *self)
+static void
+popover_shown (EphyAddBookmarkPopover *self)
 {
+  GtkWidget *relative_to;
+  GtkWidget *window;
   EphyBookmarksManager *manager;
   EphyBookmark *bookmark;
   EphyEmbed *embed;
   const char *address;
 
+  relative_to = gtk_popover_get_relative_to (GTK_POPOVER (self));
+
+  if (!relative_to)
+    return;
+
+  window = gtk_widget_get_toplevel (relative_to);
   manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
-  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (self->window));
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
 
   address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
 
@@ -242,13 +109,13 @@ ephy_add_bookmark_popover_show (EphyAddBookmarkPopover *self)
                                       id);
 
     ephy_bookmarks_manager_add_bookmark (manager, new_bookmark);
-    g_signal_emit (self, signals[UPDATE_STATE], 0, EPHY_BOOKMARK_ICON_BOOKMARKED);
+    ephy_window_sync_bookmark_state (EPHY_WINDOW (window), EPHY_BOOKMARK_ICON_BOOKMARKED);
 
     bookmark = new_bookmark;
   }
 
   g_signal_connect_object (manager, "bookmark-removed",
-                           G_CALLBACK (ephy_add_bookmark_popover_update_bookmarked_status_cb),
+                           G_CALLBACK (bookmark_removed_cb),
                            self,
                            G_CONNECT_SWAPPED);
 
@@ -261,6 +128,69 @@ ephy_add_bookmark_popover_show (EphyAddBookmarkPopover *self)
 
   g_free (self->address);
   self->address = g_strdup (address);
+}
+
+static void
+popover_hidden (EphyAddBookmarkPopover *self)
+{
+  EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
+
+  ephy_bookmarks_manager_save (manager,
+                               ephy_bookmarks_manager_save_warn_on_error_cancellable (manager),
+                               ephy_bookmarks_manager_save_warn_on_error_cb,
+                               NULL);
+
+  g_clear_pointer (&self->address, g_free);
+
+  if (self->grid) {
+    gtk_popover_set_default_widget (GTK_POPOVER (self), NULL);
+    gtk_container_remove (GTK_CONTAINER (self), self->grid);
+    self->grid = NULL;
+  }
+}
+
+static void
+ephy_add_bookmark_popover_finalize (GObject *object)
+{
+  EphyAddBookmarkPopover *self = EPHY_ADD_BOOKMARK_POPOVER (object);
 
-  gtk_popover_popup (GTK_POPOVER (self));
+  if (self->address)
+    g_free (self->address);
+
+  G_OBJECT_CLASS (ephy_add_bookmark_popover_parent_class)->finalize (object);
+}
+
+static void
+ephy_add_bookmark_popover_class_init (EphyAddBookmarkPopoverClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = ephy_add_bookmark_popover_finalize;
+}
+
+static void
+ephy_add_bookmark_popover_notify_visible_cb (GtkPopover *popover,
+                                             GParamSpec *param,
+                                             gpointer    user_data)
+{
+  g_assert (EPHY_IS_ADD_BOOKMARK_POPOVER (popover));
+
+  if (gtk_widget_get_visible (GTK_WIDGET (popover)))
+    popover_shown (EPHY_ADD_BOOKMARK_POPOVER (popover));
+  else
+    popover_hidden (EPHY_ADD_BOOKMARK_POPOVER (popover));
+}
+
+static void
+ephy_add_bookmark_popover_init (EphyAddBookmarkPopover *self)
+{
+  g_signal_connect (self, "notify::visible",
+                    G_CALLBACK (ephy_add_bookmark_popover_notify_visible_cb),
+                    NULL);
+}
+
+GtkWidget *
+ephy_add_bookmark_popover_new (void)
+{
+  return g_object_new (EPHY_TYPE_ADD_BOOKMARK_POPOVER, NULL);
 }
diff --git a/src/bookmarks/ephy-add-bookmark-popover.h b/src/bookmarks/ephy-add-bookmark-popover.h
index 3dc5066ca..00d4541c0 100644
--- a/src/bookmarks/ephy-add-bookmark-popover.h
+++ b/src/bookmarks/ephy-add-bookmark-popover.h
@@ -30,9 +30,6 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyAddBookmarkPopover, ephy_add_bookmark_popover, EPHY, ADD_BOOKMARK_POPOVER, 
GtkPopover)
 
-GtkWidget       *ephy_add_bookmark_popover_new      (GtkWidget *relative_to,
-                                                     GtkWidget *window);
-
-void             ephy_add_bookmark_popover_show     (EphyAddBookmarkPopover *self);
+GtkWidget       *ephy_add_bookmark_popover_new      (void);
 
 G_END_DECLS
diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c
index 0104fb336..04ae42090 100644
--- a/src/ephy-action-bar-end.c
+++ b/src/ephy-action-bar-end.c
@@ -258,22 +258,12 @@ 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)
 {
   GObject *object = G_OBJECT (action_bar_end);
   EphyDownloadsManager *downloads_manager;
+  GtkWidget *popover;
 
   /* Ensure the types used by the template have been initialized. */
   EPHY_TYPE_DOWNLOADS_PROGRESS_ICON;
@@ -318,9 +308,9 @@ ephy_action_bar_end_init (EphyActionBarEnd *action_bar_end)
                            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);
+  popover = ephy_add_bookmark_popover_new ();
+
+  gtk_menu_button_set_popover (GTK_MENU_BUTTON (action_bar_end->bookmark_button), popover);
 }
 
 EphyActionBarEnd *
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 0850f2411..f50912828 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -150,20 +150,6 @@ fullscreen_changed_cb (EphyHeaderBar *header_bar)
   }
 }
 
-static void
-add_bookmark_button_clicked_cb (EphyLocationEntry *entry,
-                                gpointer          *user_data)
-{
-  EphyHeaderBar *header_bar = EPHY_HEADER_BAR (user_data);
-  GActionGroup *action_group;
-  GAction *action;
-
-  action_group = gtk_widget_get_action_group (GTK_WIDGET (header_bar->window), "win");
-  action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "bookmark-page");
-
-  g_action_activate (action, NULL);
-}
-
 static void
 update_revealer_visibility (GtkRevealer *revealer)
 {
@@ -250,16 +236,9 @@ ephy_header_bar_constructed (GObject *object)
 
   if (EPHY_IS_LOCATION_ENTRY (header_bar->title_widget)) {
     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));
+    GtkWidget *popover = ephy_add_bookmark_popover_new ();
 
-    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",
-                             G_CALLBACK (add_bookmark_button_clicked_cb),
-                             header_bar,
-                             0);
   }
 
   /* Fullscreen restore button */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0bc8be18d..18ebca4e6 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1195,11 +1195,9 @@ sync_tab_is_blank (EphyWebView *view,
 }
 
 void
-ephy_window_sync_bookmark_state (GtkWidget             *widget,
+ephy_window_sync_bookmark_state (EphyWindow            *window,
                                  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;
 
diff --git a/src/ephy-window.h b/src/ephy-window.h
index 35997a3d9..ec2f2a2de 100644
--- a/src/ephy-window.h
+++ b/src/ephy-window.h
@@ -95,7 +95,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);
+void              ephy_window_sync_bookmark_state        (EphyWindow            *window,
+                                                          EphyBookmarkIconState  state);
 
 G_END_DECLS
diff --git a/src/resources/gtk/action-bar-end.ui b/src/resources/gtk/action-bar-end.ui
index 2c74b14bd..c11e194b3 100644
--- a/src/resources/gtk/action-bar-end.ui
+++ b/src/resources/gtk/action-bar-end.ui
@@ -50,7 +50,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkButton" id="bookmark_button">
+      <object class="GtkMenuButton" id="bookmark_button">
         <property name="visible">True</property>
         <!-- Translators: tooltip for the bookmark button -->
         <property name="tooltip_text" translatable="yes">Bookmark page</property>
diff --git a/src/window-commands.c b/src/window-commands.c
index f69f3c21c..d75b2e070 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -25,7 +25,6 @@
 
 #include "window-commands.h"
 
-#include "ephy-add-bookmark-popover.h"
 #include "ephy-bookmarks-export.h"
 #include "ephy-bookmarks-import.h"
 #include "ephy-bookmarks-manager.h"
@@ -2421,14 +2420,12 @@ window_cmd_bookmark_page (GSimpleAction *action,
   EphyWindow *window = EPHY_WINDOW (user_data);
   EphyHeaderBar *header_bar;
   EphyTitleWidget *title_widget;
-  GtkPopover *popover;
 
   header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
   title_widget = ephy_header_bar_get_title_widget (header_bar);
   g_assert (EPHY_IS_LOCATION_ENTRY (title_widget));
-  popover = ephy_location_entry_get_add_bookmark_popover (EPHY_LOCATION_ENTRY (title_widget));
 
-  ephy_add_bookmark_popover_show (EPHY_ADD_BOOKMARK_POPOVER (popover));
+  ephy_location_entry_show_add_bookmark_popover (EPHY_LOCATION_ENTRY (title_widget));
 }
 
 void


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