[epiphany] ephy-shell: add application menu item for reopening closed tabs



commit be7b9d45477bd6762979f2046f41b713b2eefffe
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Mon Jan 28 13:18:41 2013 +0200

    ephy-shell: add application menu item for reopening closed tabs
    
    https://bugzilla.gnome.org/show_bug.cgi?id=128184

 src/ephy-shell.c                           |   24 ++++++++++++++++++++++++
 src/resources/epiphany-application-menu.ui |    5 +++++
 src/window-commands.c                      |    7 +++++++
 src/window-commands.h                      |    2 ++
 4 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index f080974..6da0900 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -152,6 +152,14 @@ new_incognito_window (GSimpleAction *action,
 }
 
 static void
+reopen_closed_tab (GSimpleAction *action,
+                   GVariant *parameter,
+                   gpointer user_data)
+{
+  window_cmd_undo_close_tab (NULL, NULL);
+}
+
+static void
 show_bookmarks (GSimpleAction *action,
                 GVariant *parameter,
                 gpointer user_data)
@@ -214,6 +222,10 @@ static GActionEntry app_entries[] = {
   { "quit", quit_application, NULL, NULL, NULL },
 };
 
+static GActionEntry app_normal_mode_entries[] = {
+  { "reopen-closed-tab", reopen_closed_tab, NULL, NULL, NULL },
+};
+
 static void
 ephy_shell_startup (GApplication* application)
 {
@@ -231,6 +243,18 @@ ephy_shell_startup (GApplication* application)
                                      app_entries, G_N_ELEMENTS (app_entries),
                                      application);
 
+    if (mode != EPHY_EMBED_SHELL_MODE_INCOGNITO) {
+      g_action_map_add_action_entries (G_ACTION_MAP (application),
+                                       app_normal_mode_entries, G_N_ELEMENTS (app_normal_mode_entries),
+                                       application);
+      g_object_bind_property (G_OBJECT (ephy_shell_get_session (EPHY_SHELL (application))),
+                              "can-undo-tab-closed",
+                              g_action_map_lookup_action (G_ACTION_MAP (application),
+                                                          "reopen-closed-tab"),
+                              "enabled",
+                              G_BINDING_SYNC_CREATE);
+    }
+
     builder = gtk_builder_new ();
     gtk_builder_add_from_resource (builder,
                                    "/org/gnome/epiphany/epiphany-application-menu.ui",
diff --git a/src/resources/epiphany-application-menu.ui b/src/resources/epiphany-application-menu.ui
index 6b4523b..a77ae51 100644
--- a/src/resources/epiphany-application-menu.ui
+++ b/src/resources/epiphany-application-menu.ui
@@ -12,6 +12,11 @@
         <attribute name="action">app.new-incognito</attribute>
         <attribute name="accel">&lt;Primary&gt;i</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">Reopen Closed _Tab</attribute>
+        <attribute name="action">app.reopen-closed-tab</attribute>
+        <attribute name="accel">&lt;Primary&gt;&lt;Shift&gt;t</attribute>
+      </item>
     </section>
     <section>
       <item>
diff --git a/src/window-commands.c b/src/window-commands.c
index abf2950..df1274a 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -82,6 +82,13 @@ window_cmd_file_print (GtkAction *action,
 }
 
 void
+window_cmd_undo_close_tab (GtkAction *action,
+			   EphyWindow *window)
+{
+	ephy_session_undo_close_tab (ephy_shell_get_session (ephy_shell_get_default ()));
+}
+
+void
 window_cmd_file_send_to	(GtkAction *action,
 			 EphyWindow *window)
 {
diff --git a/src/window-commands.h b/src/window-commands.h
index 4d8582f..8000c70 100644
--- a/src/window-commands.h
+++ b/src/window-commands.h
@@ -50,6 +50,8 @@ void window_cmd_file_save_as_application  (GtkAction  *action,
                                            EphyWindow *window);
 void window_cmd_file_print                (GtkAction  *action,
                                            EphyWindow *window);
+void window_cmd_undo_close_tab            (GtkAction *action,
+                                           EphyWindow *window);
 void window_cmd_file_send_to              (GtkAction  *action,
                                            EphyWindow *window);
 void window_cmd_file_work_offline         (GtkAction  *action,


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