[epiphany] window: Add shortcut to show bookmarks list



commit b41370469dc408c802889058af072468e5b025dc
Author: vanadiae <vanadiae35 gmail com>
Date:   Tue Jun 1 15:59:13 2021 +0200

    window: Add shortcut to show bookmarks list
    
    Most buttons in the headerbar have a shortcut to activate them, which
    is nice given that using Tab to reach them is long because of all the UI
    elements in the web page that take precedence.
    
    But the bookmarks list popover doesn't have one, so let's add one :)

 src/ephy-action-bar-end.c             |  6 ++++++
 src/ephy-action-bar-end.h             |  1 +
 src/ephy-window.c                     |  2 ++
 src/resources/gtk/shortcuts-dialog.ui |  7 +++++++
 src/window-commands.c                 | 14 ++++++++++++++
 src/window-commands.h                 |  3 +++
 6 files changed, 33 insertions(+)
---
diff --git a/src/ephy-action-bar-end.c b/src/ephy-action-bar-end.c
index c979ffa41..ca3519b49 100644
--- a/src/ephy-action-bar-end.c
+++ b/src/ephy-action-bar-end.c
@@ -312,6 +312,12 @@ ephy_action_bar_end_set_show_bookmarks_button (EphyActionBarEnd *action_bar_end,
   gtk_widget_set_visible (action_bar_end->bookmarks_button, show);
 }
 
+void
+ephy_action_bar_end_show_bookmarks (EphyActionBarEnd *action_bar_end)
+{
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (action_bar_end->bookmarks_button), TRUE);
+}
+
 GtkWidget *
 ephy_action_bar_end_get_bookmarks_button (EphyActionBarEnd *action_bar_end)
 {
diff --git a/src/ephy-action-bar-end.h b/src/ephy-action-bar-end.h
index 2d4f540c0..a199f6c4f 100644
--- a/src/ephy-action-bar-end.h
+++ b/src/ephy-action-bar-end.h
@@ -32,6 +32,7 @@ G_DECLARE_FINAL_TYPE (EphyActionBarEnd, ephy_action_bar_end, EPHY, ACTION_BAR_EN
 EphyActionBarEnd *ephy_action_bar_end_new                       (void);
 void              ephy_action_bar_end_set_show_bookmarks_button (EphyActionBarEnd *action_bar_end,
                                                                  gboolean          show);
+void              ephy_action_bar_end_show_bookmarks            (EphyActionBarEnd *action_bar_end);
 GtkWidget        *ephy_action_bar_end_get_downloads_revealer    (EphyActionBarEnd *action_bar_end);
 
 void              ephy_action_bar_end_add_browser_action        (EphyActionBarEnd *action_bar_end,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 94f38604b..d6455b432 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -104,6 +104,7 @@ const struct {
   { "win.find-prev", { "<shift><Primary>G", NULL } },
   { "win.find-next", { "<Primary>G", NULL } },
   { "win.bookmark-page", { "<Primary>D", "AddFavorite", NULL } },
+  { "win.bookmarks", { "<alt><Primary>D", NULL } },
   { "win.encoding", { NULL } },
   { "win.page-source", { "<Primary>U", NULL } },
   { "win.toggle-inspector", { "<shift><Primary>I", "F12", NULL } },
@@ -860,6 +861,7 @@ static const GActionEntry window_entries [] = {
   { "find-next", window_cmd_find_next },
   { "open-bookmark", window_cmd_open_bookmark, "s" },
   { "bookmark-page", window_cmd_bookmark_page },
+  { "bookmarks", window_cmd_bookmarks },
   { "encoding", window_cmd_encoding },
   { "page-source", window_cmd_page_source },
   { "toggle-inspector", window_cmd_toggle_inspector },
diff --git a/src/resources/gtk/shortcuts-dialog.ui b/src/resources/gtk/shortcuts-dialog.ui
index 947d79d13..1a94fadf1 100644
--- a/src/resources/gtk/shortcuts-dialog.ui
+++ b/src/resources/gtk/shortcuts-dialog.ui
@@ -233,6 +233,13 @@
                 <property name="accelerator">&lt;Primary&gt;D</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Show bookmarks 
list</property>
+                <property name="accelerator">&lt;alt&gt;&lt;Primary&gt;D</property>
+              </object>
+            </child>
             <child>
               <object class="GtkShortcutsShortcut">
                 <property name="visible">True</property>
diff --git a/src/window-commands.c b/src/window-commands.c
index d9c83b7be..6d1da63e5 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2369,6 +2369,20 @@ window_cmd_bookmark_page (GSimpleAction *action,
   ephy_add_bookmark_popover_show (EPHY_ADD_BOOKMARK_POPOVER (popover));
 }
 
+void
+window_cmd_bookmarks (GSimpleAction *action,
+                      GVariant      *parameter,
+                      gpointer       user_data)
+{
+  EphyWindow *window = EPHY_WINDOW (user_data);
+  EphyHeaderBar *header_bar;
+  EphyActionBarEnd *action_bar_end;
+
+  header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
+  action_bar_end = EPHY_ACTION_BAR_END (ephy_header_bar_get_action_bar_end (header_bar));
+  ephy_action_bar_end_show_bookmarks (action_bar_end);
+}
+
 void
 window_cmd_zoom_in (GSimpleAction *action,
                     GVariant      *parameter,
diff --git a/src/window-commands.h b/src/window-commands.h
index 2c56d9288..ef0cc82c0 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -134,6 +134,9 @@ void window_cmd_open_bookmark                   (GSimpleAction *action,
 void window_cmd_bookmark_page                   (GSimpleAction *action,
                                                  GVariant      *parameter,
                                                  gpointer       user_data);
+void window_cmd_bookmarks                       (GSimpleAction *action,
+                                                 GVariant      *parameter,
+                                                 gpointer       user_data);
 void window_cmd_zoom_in                         (GSimpleAction *action,
                                                  GVariant      *parameter,
                                                  gpointer       user_data);


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