[devhelp] Window: fix/improve code for Ctrl+W action



commit ad8498639cbdd471424edff85c3f33d67430005b
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Tue May 15 13:33:06 2018 +0200

    Window: fix/improve code for Ctrl+W action
    
    In gedit Ctrl+W is to close the current tab.
    
    - Rename GAction to have a better name.
    - Fix documentation for the shortcuts window.

 src/dh-app.c    |    2 +-
 src/dh-window.c |   15 +++++----------
 2 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index 7ca8b13..eaa3e16 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -109,7 +109,7 @@ add_other_action_infos (DhApp *app)
         const AmtkActionInfoEntry entries[] = {
                 /* action, icon, label, accel, tooltip */
                 { "win.new-tab", NULL, NULL, "<Control>t", N_("Open a new tab") },
-                { "win.close", NULL, NULL, "<Control>w", N_("Close the current window") },
+                { "win.close-tab", NULL, NULL, "<Control>w", N_("Close the current tab") },
                 { "win.go-back", NULL, NULL, NULL, N_("Go back") },
                 { "win.go-forward", NULL, NULL, NULL, N_("Go forward") },
                 { "win.focus-search", NULL, NULL, NULL, N_("Focus global search") },
diff --git a/src/dh-window.c b/src/dh-window.c
index 3011349..47124d4 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -271,19 +271,14 @@ print_cb (GSimpleAction *action,
 }
 
 static void
-close_cb (GSimpleAction *action,
-          GVariant      *parameter,
-          gpointer       user_data)
+close_tab_cb (GSimpleAction *action,
+              GVariant      *parameter,
+              gpointer       user_data)
 {
         DhWindow *window = DH_WINDOW (user_data);
         DhWindowPrivate *priv = dh_window_get_instance_private (window);
         gint page_num;
 
-        /* FIXME: the code here closes the current *tab*, but in the
-         * AmtkActionInfo it is documented as "Close the current window". Look
-         * for example at what gedit does, or other GNOME apps with a
-         * GtkNotebook plus Ctrl+W shortcut, and do the same.
-         */
         page_num = gtk_notebook_get_current_page (priv->notebook);
         gtk_notebook_remove_page (priv->notebook, page_num);
 }
@@ -440,7 +435,7 @@ shortcuts_window_cb (GSimpleAction *action,
         gtk_container_add (group, amtk_factory_create_shortcut (factory, "win.go-back"));
         gtk_container_add (group, amtk_factory_create_shortcut (factory, "win.go-forward"));
         gtk_container_add (group, amtk_factory_create_shortcut (factory, "win.print"));
-        gtk_container_add (group, amtk_factory_create_shortcut (factory, "win.close"));
+        gtk_container_add (group, amtk_factory_create_shortcut (factory, "win.close-tab"));
         gtk_container_add (group, amtk_factory_create_shortcut (factory, "app.quit"));
         gtk_container_add (section, GTK_WIDGET (group));
 
@@ -470,7 +465,7 @@ add_actions (DhWindow *window)
                 { "prev-tab", prev_tab_cb },
                 { "go-to-tab", go_to_tab_cb, "q" },
                 { "print", print_cb },
-                { "close", close_cb },
+                { "close-tab", close_tab_cb },
 
                 /* Edit */
                 { "copy", copy_cb },


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