[epiphany] Add reader mode keyboard short cut



commit 1714a0d9931385ffebacbe203c03cbd84f52c023
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Mon Sep 10 21:52:53 2018 +0200

    Add reader mode keyboard short cut
    
    Use Primary + Shift + r to toggle reader mode.
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/526

 src/ephy-window.c                     |  2 ++
 src/resources/gtk/shortcuts-dialog.ui |  7 +++++++
 src/window-commands.c                 | 23 +++++++++++++++++++++++
 src/window-commands.h                 |  3 +++
 4 files changed, 35 insertions(+)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 8464b661b..d86c59d07 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -101,6 +101,7 @@ const struct {
   { "win.encoding", { NULL } },
   { "win.page-source", { "<Primary>U", NULL } },
   { "win.toggle-inspector", { "<shift><Primary>I", "F12", NULL } },
+  { "win.toggle-reader-mode", { "<shift><Primary>r", NULL } },
 
   { "win.select-all", { "<Primary>A", NULL } },
 
@@ -748,6 +749,7 @@ static const GActionEntry window_entries [] =
   { "encoding", window_cmd_encoding },
   { "page-source", window_cmd_page_source },
   { "toggle-inspector", window_cmd_toggle_inspector },
+  { "toggle-reader-mode", window_cmd_toggle_reader_mode },
 
   { "select-all", window_cmd_select_all },
 
diff --git a/src/resources/gtk/shortcuts-dialog.ui b/src/resources/gtk/shortcuts-dialog.ui
index 8ca99271e..1dfce785b 100644
--- a/src/resources/gtk/shortcuts-dialog.ui
+++ b/src/resources/gtk/shortcuts-dialog.ui
@@ -255,6 +255,13 @@
                 <property name="accelerator">&lt;shift&gt;&lt;Primary&gt;I</property>
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes" context="shortcut window">Toggle reader 
moder</property>
+                <property name="accelerator">&lt;shift&gt;&lt;Primary&gt;R</property>
+              </object>
+            </child>
           </object>
         </child>
 
diff --git a/src/window-commands.c b/src/window-commands.c
index 0d483808c..bcc7dad76 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2430,3 +2430,26 @@ window_cmd_change_show_tab_state (GSimpleAction *action,
 {
   /* This page intentionally left blank. */
 }
+
+void
+window_cmd_toggle_reader_mode (GSimpleAction *action,
+                               GVariant      *parameter,
+                               gpointer       user_data)
+{
+  EphyWindow *window = EPHY_WINDOW (user_data);
+  EphyEmbed *embed;
+  EphyWebView *web_view;
+  gboolean active;
+
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+  g_assert (embed != NULL);
+
+  web_view = ephy_embed_get_web_view (embed);
+
+  if (!ephy_web_view_is_reader_mode_available (web_view))
+    return;
+
+  active = ephy_web_view_get_reader_mode_state (web_view);
+
+  ephy_web_view_toggle_reader_mode (web_view, !active);
+}
diff --git a/src/window-commands.h b/src/window-commands.h
index 5d1b75a9a..9da083357 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -188,5 +188,8 @@ void window_cmd_show_tab                        (GSimpleAction *action,
 void window_cmd_change_show_tab_state           (GSimpleAction *action,
                                                  GVariant      *state,
                                                  gpointer       user_data);
+void window_cmd_toggle_reader_mode              (GSimpleAction *action,
+                                                 GVariant      *parameter,
+                                                 gpointer       user_data);
 
 G_END_DECLS


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