[epiphany] Add "Reload Tab" and "Reopen Closed Tab" option to tab contextual menu



commit fd4a463bb6903ead13b4e3f3820bbcd24afeb62c
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Mon Dec 17 15:34:46 2018 +0100

    Add "Reload Tab" and "Reopen Closed Tab" option to tab contextual menu
    
    Add a reload option / reopen closed tab option to tab context menu and move close tab to the bottom.
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/226
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/199

 src/ephy-window.c                          |  4 +++-
 src/resources/gtk/notebook-context-menu.ui | 12 ++++++++++--
 src/window-commands.c                      | 29 +++++++++++++++++++++++++++++
 src/window-commands.h                      |  6 ++++++
 4 files changed, 48 insertions(+), 3 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 8211673de..57cda1a79 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -771,7 +771,9 @@ static const GActionEntry tab_entries [] = {
   { "close", window_cmd_tabs_close },
   { "close-left", window_cmd_tabs_close_left },
   { "close-right", window_cmd_tabs_close_right },
-  { "close-others", window_cmd_tabs_close_others }
+  { "close-others", window_cmd_tabs_close_others },
+  { "reload", window_cmd_tabs_reload },
+  { "reopen", window_cmd_tabs_reopen_closed_tab },
 };
 
 static const GActionEntry toolbar_entries [] = {
diff --git a/src/resources/gtk/notebook-context-menu.ui b/src/resources/gtk/notebook-context-menu.ui
index 3c79791bd..aaaf8c878 100644
--- a/src/resources/gtk/notebook-context-menu.ui
+++ b/src/resources/gtk/notebook-context-menu.ui
@@ -3,13 +3,17 @@
   <!-- interface-requires gtk+ 3.0 -->
   <menu id="notebook-menu">
     <section>
+      <item>
+        <attribute name="label" translatable="yes">R_eload</attribute>
+        <attribute name="action">tab.reload</attribute>
+      </item>
       <item>
         <attribute name="label" translatable="yes">Du_plicate</attribute>
         <attribute name="action">tab.duplicate</attribute>
       </item>
       <item>
-        <attribute name="label" translatable="yes">_Close</attribute>
-        <attribute name="action">tab.close</attribute>
+        <attribute name="label" translatable="yes">Reo_pen Closed Tab</attribute>
+        <attribute name="action">tab.reopen</attribute>
       </item>
       <item>
         <attribute name="label" translatable="yes">Close Tabs to the _Left</attribute>
@@ -23,6 +27,10 @@
         <attribute name="label" translatable="yes">Close _Other Tabs</attribute>
         <attribute name="action">tab.close-others</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">_Close</attribute>
+        <attribute name="action">tab.close</attribute>
+      </item>
     </section>
   </menu>
 </interface>
diff --git a/src/window-commands.c b/src/window-commands.c
index ea0fddcea..a0706a086 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -2443,6 +2443,35 @@ window_cmd_tabs_close_others (GSimpleAction *action,
   g_slist_free (pages_to_close);
 }
 
+void
+window_cmd_tabs_reload (GSimpleAction *action,
+                        GVariant      *parameter,
+                        gpointer       user_data)
+{
+  EphyWindow *window = user_data;
+  EphyEmbed *embed;
+  WebKitWebView *view;
+
+  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
+  g_assert (embed != NULL);
+
+  gtk_widget_grab_focus (GTK_WIDGET (embed));
+
+  view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
+  webkit_web_view_reload (view);
+}
+
+void
+window_cmd_tabs_reopen_closed_tab (GSimpleAction *action,
+                                   GVariant      *parameter,
+                                   gpointer       user_data)
+{
+  EphySession *session = ephy_shell_get_session (ephy_shell_get_default ());
+
+  g_assert (session != NULL);
+  ephy_session_undo_close_tab (session);
+}
+
 void
 window_cmd_show_tab (GSimpleAction *action,
                      GVariant      *parameter,
diff --git a/src/window-commands.h b/src/window-commands.h
index f02183787..a961d7418 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -188,6 +188,12 @@ void window_cmd_tabs_close_left                 (GSimpleAction *action,
 void window_cmd_tabs_close_right                (GSimpleAction *action,
                                                  GVariant      *parameter,
                                                  gpointer       user_data);
+void window_cmd_tabs_reload                     (GSimpleAction *action,
+                                                 GVariant      *parameter,
+                                                 gpointer       user_data);
+void window_cmd_tabs_reopen_closed_tab          (GSimpleAction *action,
+                                                 GVariant      *parameter,
+                                                 gpointer       user_data);
 void window_cmd_tabs_close_others               (GSimpleAction *action,
                                                  GVariant      *parameter,
                                                  gpointer       user_data);


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