[epiphany/wip/exalm/cleanups-again] Simplify bookmark opening




commit ed38b99dc9576ff82f6dcf642fd8d31e35fc100f
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Feb 25 19:01:17 2022 +0500

    Simplify bookmark opening
    
    Remove the win.bookmark-open action as it's only used from one place.
    Instead, just inline that code.
    
    Since this is the last use of ephy_link_flags_from_current_event(), inline
    it as well. While it means we're still using ephy_gui_get_current_event(),
    at this point it's very close to the actual event handling and can be
    replaced relatively easily in GTK4 - unlike when it's in a GAction.

 src/bookmarks/ephy-bookmarks-popover.c | 18 +++++++++++-------
 src/ephy-link.c                        | 13 -------------
 src/ephy-link.h                        |  2 --
 src/ephy-location-controller.c         |  4 ++--
 src/ephy-window.c                      |  1 -
 src/window-commands.c                  | 14 --------------
 6 files changed, 13 insertions(+), 39 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-popover.c b/src/bookmarks/ephy-bookmarks-popover.c
index 779b9b58f..9f6cdede1 100644
--- a/src/bookmarks/ephy-bookmarks-popover.c
+++ b/src/bookmarks/ephy-bookmarks-popover.c
@@ -26,6 +26,8 @@
 #include "ephy-bookmark-row.h"
 #include "ephy-bookmarks-manager.h"
 #include "ephy-debug.h"
+#include "ephy-gui.h"
+#include "ephy-link.h"
 #include "ephy-shell.h"
 #include "ephy-window.h"
 
@@ -411,19 +413,21 @@ ephy_bookmarks_popover_open_bookmark (EphyBookmarksPopover *self,
                                       GtkListBoxRow        *row)
 {
   GtkWidget *window;
-  GActionGroup *action_group;
-  GAction *action;
   const char *url;
+  GdkEventType type = GDK_NOTHING;
+  guint state = 0, button = (guint) - 1;
+  EphyLinkFlags flags;
 
   window = gtk_widget_get_ancestor (GTK_WIDGET (self), EPHY_TYPE_WINDOW);
   g_assert (EPHY_IS_WINDOW (window));
-  action_group = gtk_widget_get_action_group (window, "win");
-  g_assert (action_group != NULL);
-  action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "open-bookmark");
-  g_assert (action != NULL);
   url = ephy_bookmark_row_get_bookmark_url (EPHY_BOOKMARK_ROW (row));
 
-  g_action_activate (action, g_variant_new_string (url));
+  ephy_gui_get_current_event (&type, &state, &button, NULL);
+  flags = ephy_link_flags_from_modifiers (state, button == GDK_BUTTON_MIDDLE &&
+                                                 (type == GDK_BUTTON_PRESS ||
+                                                  type == GDK_BUTTON_RELEASE));
+
+  ephy_link_open (EPHY_LINK (window), url, NULL, flags | EPHY_LINK_BOOKMARK);
 }
 
 static void
diff --git a/src/ephy-link.c b/src/ephy-link.c
index 61dbb3735..07ca9a26f 100644
--- a/src/ephy-link.c
+++ b/src/ephy-link.c
@@ -115,16 +115,3 @@ ephy_link_flags_from_modifiers (GdkModifierType modifiers,
 
   return 0;
 }
-
-EphyLinkFlags
-ephy_link_flags_from_current_event (void)
-{
-  GdkEventType type = GDK_NOTHING;
-  guint state = 0, button = (guint) - 1;
-
-  ephy_gui_get_current_event (&type, &state, &button, NULL);
-
-  return ephy_link_flags_from_modifiers (state, button == GDK_BUTTON_MIDDLE &&
-                                                (type == GDK_BUTTON_PRESS ||
-                                                 type == GDK_BUTTON_RELEASE));
-}
diff --git a/src/ephy-link.h b/src/ephy-link.h
index ab3667538..7ec3c9ae8 100644
--- a/src/ephy-link.h
+++ b/src/ephy-link.h
@@ -61,6 +61,4 @@ EphyEmbed *ephy_link_open (EphyLink *link,
 EphyLinkFlags ephy_link_flags_from_modifiers (GdkModifierType modifiers,
                                               gboolean        middle_click);
 
-EphyLinkFlags ephy_link_flags_from_current_event (void);
-
 G_END_DECLS
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 7d39a16b4..3f0db081d 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -86,7 +86,7 @@ entry_activate_cb (EphyLocationEntry      *entry,
   const char *content;
   char *address;
   char *effective_address;
-  GtkEntry *inner_entry;
+  GtkWidget *inner_entry;
 
   if (controller->sync_address_is_blocked) {
     controller->sync_address_is_blocked = FALSE;
@@ -94,7 +94,7 @@ entry_activate_cb (EphyLocationEntry      *entry,
   }
 
   inner_entry = ephy_location_entry_get_entry (entry);
-  content = gtk_entry_get_text (inner_entry);
+  content = gtk_entry_get_text (GTK_ENTRY (inner_entry));
   if (content == NULL || content[0] == '\0')
     return;
 
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 18ebca4e6..fef509336 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -835,7 +835,6 @@ static const GActionEntry window_entries [] = {
   { "find", window_cmd_find },
   { "find-prev", window_cmd_find_prev },
   { "find-next", window_cmd_find_next },
-  { "open-bookmark", window_cmd_open_bookmark, "s" },
   { "bookmark-page", window_cmd_bookmark_page },
   { "bookmarks", window_cmd_bookmarks },
   { "show-downloads", window_cmd_show_downloads },
diff --git a/src/window-commands.c b/src/window-commands.c
index d75b2e070..2ebc302aa 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2398,20 +2398,6 @@ window_cmd_find_next (GSimpleAction *action,
   ephy_find_toolbar_find_next (toolbar);
 }
 
-void
-window_cmd_open_bookmark (GSimpleAction *action,
-                          GVariant      *parameter,
-                          gpointer       user_data)
-{
-  const gchar *address;
-  EphyLinkFlags flags;
-
-  address = g_variant_get_string (parameter, NULL);
-  flags = ephy_link_flags_from_current_event () | EPHY_LINK_BOOKMARK;
-
-  ephy_link_open (EPHY_LINK (user_data), address, NULL, flags);
-}
-
 void
 window_cmd_bookmark_page (GSimpleAction *action,
                           GVariant      *parameter,


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