[evolution/gnome-3-30] I#140 - Single key accelerator triggered in search box ]I[



commit 64a48ea51afc2174d53e9ec570563634f9770cb3
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 8 12:29:24 2018 +0200

    I#140 - Single key accelerator triggered in search box ]I[
    
    Related to https://gitlab.gnome.org/GNOME/evolution/issues/140

 src/modules/mail/e-mail-shell-view-private.c |  3 ++-
 src/shell/e-shell-window-private.c           | 17 +++++++---------
 src/shell/e-shell-window.c                   | 30 ++++++++++++++++++++++++++++
 src/shell/e-shell-window.h                   |  3 +++
 4 files changed, 42 insertions(+), 11 deletions(-)
---
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index 0b5ef35444..04a47c4bbd 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -263,7 +263,8 @@ mail_shell_view_process_key_press_event (EMailShellView *mail_shell_view,
        shell_view = E_SHELL_VIEW (mail_shell_view);
        shell_window = e_shell_view_get_shell_window (shell_view);
 
-       if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0)
+       if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0 ||
+           e_shell_window_get_need_input (shell_window, event))
                return FALSE;
 
        shell_content = e_shell_view_get_shell_content (shell_view);
diff --git a/src/shell/e-shell-window-private.c b/src/shell/e-shell-window-private.c
index 3c59e97da5..8558fe8b5e 100644
--- a/src/shell/e-shell-window-private.c
+++ b/src/shell/e-shell-window-private.c
@@ -349,14 +349,8 @@ static gboolean
 e_shell_window_key_press_event_cb (GtkWidget *widget,
                                   GdkEventKey *event)
 {
-       GtkWindow *window;
-       GtkWidget *focused;
-
        g_return_val_if_fail (E_IS_SHELL_WINDOW (widget), FALSE);
 
-       window = GTK_WINDOW (widget);
-       focused = gtk_window_get_focus (window);
-
        if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0 ||
            event->keyval == GDK_KEY_Tab ||
            event->keyval == GDK_KEY_Return ||
@@ -366,10 +360,13 @@ e_shell_window_key_press_event_cb (GtkWidget *widget,
            event->keyval == GDK_KEY_BackSpace)
                return FALSE;
 
-       if (GTK_IS_ENTRY (focused) ||
-           GTK_IS_EDITABLE (focused) ||
-           (GTK_IS_TREE_VIEW (focused) && gtk_tree_view_get_search_column (GTK_TREE_VIEW (focused)) >= 0)) {
-               gtk_widget_event (focused, (GdkEvent *) event);
+       if (e_shell_window_get_need_input (E_SHELL_WINDOW (widget), event)) {
+               GtkWidget *focused;
+
+               focused = gtk_window_get_focus (GTK_WINDOW (widget));
+               if (focused)
+                       gtk_widget_event (focused, (GdkEvent *) event);
+
                return TRUE;
        }
 
diff --git a/src/shell/e-shell-window.c b/src/shell/e-shell-window.c
index d5e584cbf6..9df7595d63 100644
--- a/src/shell/e-shell-window.c
+++ b/src/shell/e-shell-window.c
@@ -2146,3 +2146,33 @@ e_shell_window_register_new_source_actions (EShellWindow *shell_window,
                        "backend-name", (gpointer) backend_name);
        }
 }
+
+/**
+ * e_shell_window_get_need_input:
+ * @shell_window: an #EShellWindow
+ * @event: a #GdkEventKey
+ *
+ * Returns: Whether the key @event should be processed by currently
+ *    focused widget in the @window, instead of being processed
+ *    bu usual means including accelerators.
+ *
+ * Since: 3.30.2
+ **/
+gboolean
+e_shell_window_get_need_input (EShellWindow *shell_window,
+                              GdkEventKey *event)
+{
+       GtkWidget *focused;
+
+       g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), FALSE);
+       g_return_val_if_fail (event != NULL, FALSE);
+
+       if ((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0)
+               return FALSE;
+
+       focused = gtk_window_get_focus (GTK_WINDOW (shell_window));
+
+       return focused && (GTK_IS_ENTRY (focused) ||
+               GTK_IS_EDITABLE (focused) ||
+               (GTK_IS_TREE_VIEW (focused) && gtk_tree_view_get_search_column (GTK_TREE_VIEW (focused)) >= 
0));
+}
diff --git a/src/shell/e-shell-window.h b/src/shell/e-shell-window.h
index 1c6c9a5f9c..b678f37803 100644
--- a/src/shell/e-shell-window.h
+++ b/src/shell/e-shell-window.h
@@ -155,6 +155,9 @@ void                e_shell_window_connect_client   (EShellWindow *shell_window,
                                                 gpointer user_data,
                                                 GDestroyNotify destroy_user_data);
 
+gboolean       e_shell_window_get_need_input   (EShellWindow *shell_window,
+                                                GdkEventKey *event);
+
 /* These should be called from the shell backend's window_created() handler. */
 
 void           e_shell_window_register_new_item_actions


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