[evolution] I#279 - [EMailBrowser] Enable Space/Backspace keys to scroll within message



commit b49a88334ba641ec74658cdaef766aab7f6bfec2
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 14 14:04:14 2019 +0100

    I#279 - [EMailBrowser] Enable Space/Backspace keys to scroll within message
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/279

 src/mail/e-mail-browser.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/src/mail/e-mail-browser.c b/src/mail/e-mail-browser.c
index a054990c0d..e476759f38 100644
--- a/src/mail/e-mail-browser.c
+++ b/src/mail/e-mail-browser.c
@@ -392,6 +392,34 @@ mail_browser_close_on_reply_response_cb (EAlert *alert,
        }
 }
 
+static gboolean
+mail_browser_key_press_event_cb (GtkWindow *mail_browser,
+                                GdkEventKey *event)
+{
+       GtkWidget *focused;
+       EMailDisplay *mail_display;
+
+       if (!event || (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)) != 0 ||
+           (event->keyval != GDK_KEY_space && event->keyval != GDK_KEY_BackSpace))
+               return FALSE;
+
+       focused = gtk_window_get_focus (mail_browser);
+
+       if (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)))
+               return FALSE;
+
+       mail_display = e_mail_reader_get_mail_display (E_MAIL_READER (mail_browser));
+
+       if (e_web_view_get_need_input (E_WEB_VIEW (mail_display)) &&
+           gtk_widget_has_focus (GTK_WIDGET (mail_display))) {
+               gtk_widget_event (GTK_WIDGET (mail_display), (GdkEvent *) event);
+               return TRUE;
+       }
+
+       return e_mail_display_process_magic_spacebar (mail_display, event->keyval == GDK_KEY_space);
+}
+
 static void
 mail_browser_set_backend (EMailBrowser *browser,
                           EMailBackend *backend)
@@ -818,6 +846,10 @@ mail_browser_constructed (GObject *object)
                action, "sensitive",
                G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
 
+       g_signal_connect (
+               browser, "key-press-event",
+               G_CALLBACK (mail_browser_key_press_event_cb), NULL);
+
        e_extensible_load_extensions (E_EXTENSIBLE (object));
 }
 


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