[gedit] Let Ctrl+W close the window if there are no tabs



commit 3c222f2621be58d920704c9b40b4fb43cf01edc0
Author: Paolo Bonzini <bonzini gnu org>
Date:   Thu Aug 28 12:23:45 2014 +0200

    Let Ctrl+W close the window if there are no tabs
    
    gedit is one of very few apps where Ctrl+W, Ctrl+Q and Alt+F4 are all necessary
    to use the app.  In particular, Alt+F4 is the only way to get rid of a window
    if i press Ctrl+N instead of Ctrl+T.
    
    An extra Ctrl+W press could close the window after closing the last tab.  It is
    easy for the user to understand what happened, and once you know it you don't
    have to learn another shortcut.
    
    It turns out that this feature was actually already supported, but only on OS
    X.  In _gedit_cmd_file_close the #ifdef is useless, since it will never be
    reached when tab != NULL disables the action.  The patch then only has to
    remove that condition from update_actions_sensitivity.
    
    It makes sense now to remove the #ifdef from update_actions_sensitivity
    too, but which branch to take?  As requested by jessevdk, I kept the
    non-OS X branch; the remaining conditions where Ctrl+W is disabled are:
    
    - closing/saving/print-previewing, where I'm not really sure how to test
    it and they should be rare anyway.  Perhaps for saving it should set a
    close-after-save flag?
    
    - for print preview, I'd find it confusing that you'll close the entire
    document instead of just the preview
    
    - for saving error, it's better to get the user's attention
    
    Signed-off-by: Paolo Bonzini <pbonzini redhat com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735514

 gedit/gedit-commands-file.c |    3 ---
 gedit/gedit-window.c        |    6 ------
 2 files changed, 0 insertions(+), 9 deletions(-)
---
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index 85e5063..f4057d0 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -1886,10 +1886,7 @@ _gedit_cmd_file_close (GSimpleAction *action,
 
        if (active_tab == NULL)
        {
-#ifdef OS_OSX
-               /* Close the window on OS X */
                gtk_widget_destroy (GTK_WIDGET (window));
-#endif
                return;
        }
 
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index edf23d8..749ba2e 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -628,19 +628,13 @@ update_actions_sensitivity (GeditWindow *window)
                                     !(lockdown & GEDIT_LOCKDOWN_PRINTING));
 
        action = g_action_map_lookup_action (G_ACTION_MAP (window), "close");
-#ifdef OS_OSX
-       /* On OS X, File Close is always sensitive */
-       g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
-#else
        g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
-                                    (tab != NULL) &&
                                     (state != GEDIT_TAB_STATE_CLOSING) &&
                                     (state != GEDIT_TAB_STATE_SAVING) &&
                                     (state != GEDIT_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
                                     (state != GEDIT_TAB_STATE_PRINTING) &&
                                     (state != GEDIT_TAB_STATE_PRINT_PREVIEWING) &&
                                     (state != GEDIT_TAB_STATE_SAVING_ERROR));
-#endif
 
        action = g_action_map_lookup_action (G_ACTION_MAP (window), "undo");
        g_simple_action_set_enabled (G_SIMPLE_ACTION (action),


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