[evolution] Bug 755730 - Focus message list after start in the Mail view ][



commit 4978623f5d6b8b78d2b52e8097947ed7c3dcac14
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 27 12:40:34 2019 +0200

    Bug 755730 - Focus message list after start in the Mail view ][
    
    Closes https://bugzilla.gnome.org/show_bug.cgi?id=755730#c13

 src/modules/mail/e-mail-shell-content.c | 16 ++++++++--------
 src/shell/e-shell-window.c              | 25 ++++++++++++++++---------
 2 files changed, 24 insertions(+), 17 deletions(-)
---
diff --git a/src/modules/mail/e-mail-shell-content.c b/src/modules/mail/e-mail-shell-content.c
index dd507c0794..7e3dc553d7 100644
--- a/src/modules/mail/e-mail-shell-content.c
+++ b/src/modules/mail/e-mail-shell-content.c
@@ -261,7 +261,6 @@ mail_shell_content_constructed (GObject *object)
        EAttachmentStore *attachment_store;
        EMailDisplay *display;
        GtkPaned *paned;
-       GtkWindow *window;
        GtkWidget *widget;
        GtkBox *vbox;
        GSettings *settings;
@@ -350,12 +349,6 @@ mail_shell_content_constructed (GObject *object)
                G_SETTINGS_BIND_DEFAULT);
 
        g_object_unref (settings);
-
-       window = e_mail_reader_get_window (E_MAIL_READER (object));
-       widget = e_mail_reader_get_message_list (E_MAIL_READER (object));
-
-       if (window && widget)
-               gtk_window_set_focus (window, widget);
 }
 
 static guint32
@@ -380,6 +373,7 @@ static void
 mail_shell_content_focus_search_results (EShellContent *shell_content)
 {
        EMailShellContent *mail_shell_content;
+       EShellWindow *shell_window;
        GtkWidget *message_list;
        EMailReader *reader;
 
@@ -391,7 +385,13 @@ mail_shell_content_focus_search_results (EShellContent *shell_content)
        reader = E_MAIL_READER (mail_shell_content->priv->mail_view);
        message_list = e_mail_reader_get_message_list (reader);
 
-       if (!message_list || MESSAGE_LIST (message_list)->just_set_folder)
+       shell_window = e_shell_view_get_shell_window (e_shell_content_get_shell_view (shell_content));
+
+       /* This can be called also when the window is showing, to focus default
+          widget, in which case do not skip the gtk_widget_grab_focus() call. */
+       if (!message_list || (MESSAGE_LIST (message_list)->just_set_folder &&
+           gtk_widget_get_mapped (GTK_WIDGET (shell_window)) &&
+           gtk_window_get_focus (GTK_WINDOW (shell_window))))
                return;
 
        gtk_widget_grab_focus (message_list);
diff --git a/src/shell/e-shell-window.c b/src/shell/e-shell-window.c
index 3e23f75c0f..7bc4cf2f34 100644
--- a/src/shell/e-shell-window.c
+++ b/src/shell/e-shell-window.c
@@ -832,26 +832,33 @@ shell_window_submit_postponed_alerts_idle_cb (gpointer user_data)
        return FALSE;
 }
 
-static gboolean
-shell_window_map_event (GtkWidget *widget,
-                       GdkEventAny *event)
+static void
+shell_window_map (GtkWidget *widget)
 {
        EShellWindow *shell_window;
-       gboolean res;
+       EShellView *shell_view;
 
-       g_return_val_if_fail (E_IS_SHELL_WINDOW (widget), FALSE);
+       g_return_if_fail (E_IS_SHELL_WINDOW (widget));
 
        shell_window = E_SHELL_WINDOW (widget);
 
+       /* Do this before the parent's map() is called, to distinguish from search and from window open */
+       shell_view = e_shell_window_peek_shell_view (shell_window, e_shell_window_get_active_view 
(shell_window));
+       if (shell_view) {
+               EShellContent *shell_content;
+
+               shell_content = e_shell_view_get_shell_content (shell_view);
+               if (shell_content)
+                       e_shell_content_focus_search_results (shell_content);
+       }
+
        /* Chain up to parent's method */
-       res = GTK_WIDGET_CLASS (e_shell_window_parent_class)->map_event (widget, event);
+       GTK_WIDGET_CLASS (e_shell_window_parent_class)->map (widget);
 
        g_idle_add_full (
                G_PRIORITY_LOW,
                shell_window_submit_postponed_alerts_idle_cb,
                g_object_ref (shell_window), g_object_unref);
-
-       return res;
 }
 
 static gboolean
@@ -882,7 +889,7 @@ e_shell_window_class_init (EShellWindowClass *class)
        object_class->constructed = shell_window_constructed;
 
        widget_class = GTK_WIDGET_CLASS (class);
-       widget_class->map_event = shell_window_map_event;
+       widget_class->map = shell_window_map;
 
        class->close_alert = shell_window_close_alert;
        class->construct_menubar = shell_window_construct_menubar;


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