[evolution] Label shortcuts prevent typing numbers



commit 0b6a4a707279d63c389bff691da4519d51f468a6
Author: Milan Crha <mcrha redhat com>
Date:   Wed Oct 4 18:49:06 2017 +0200

    Label shortcuts prevent typing numbers
    
    Since change for bug 787002 typing numbers into for example search
    entry was not possible, due to the shortcuts for labels "consuming"
    the key presses. The fix is to allow labels only if the message
    list is focused, when also the context menu contains the Labels.
    
    This had been reported downstream:
    https://bugzilla.redhat.com/show_bug.cgi?id=1498484

 src/modules/mail/e-mail-shell-view-private.c |   40 ++++++++++++++++++++++++++
 src/modules/mail/e-mail-shell-view-private.h |    3 ++
 src/modules/mail/e-mail-shell-view.c         |    2 +
 3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/src/modules/mail/e-mail-shell-view-private.c b/src/modules/mail/e-mail-shell-view-private.c
index 6a73cfa..a964dbc 100644
--- a/src/modules/mail/e-mail-shell-view-private.c
+++ b/src/modules/mail/e-mail-shell-view-private.c
@@ -559,6 +559,10 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
        e_shell_window_add_action_group (shell_window, "mail-label");
        e_shell_window_add_action_group (shell_window, "search-folders");
 
+       g_signal_connect (
+               shell_window, "set-focus",
+               G_CALLBACK (e_mail_shell_view_update_labels_sensitivity), shell_view);
+
        merge_id = gtk_ui_manager_new_merge_id (ui_manager);
        priv->label_merge_id = merge_id;
 
@@ -1545,3 +1549,39 @@ e_mail_shell_view_update_send_receive_menus (EMailShellView *mail_shell_view)
                        GTK_MENU_TOOL_BUTTON (priv->send_receive_tool_item),
                        create_send_receive_submenu (mail_shell_view));
 }
+
+void
+e_mail_shell_view_update_labels_sensitivity (EShellWindow *shell_window,
+                                            GtkWidget *focused_widget)
+{
+       GtkActionGroup *action_group;
+       GtkAction *action;
+       GtkWidget *widget;
+       gboolean sensitive = FALSE;
+
+       g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
+
+       /* It can be called also during the dispose of the GtkWindow,
+          when the UI manager is already freed */
+       if (!e_shell_window_get_ui_manager (shell_window))
+               return;
+
+       widget = focused_widget ? focused_widget : gtk_window_get_focus (GTK_WINDOW (shell_window));
+
+       while (widget) {
+               if (IS_MESSAGE_LIST (widget)) {
+                       sensitive = TRUE;
+                       break;
+               }
+
+               widget = gtk_widget_get_parent (widget);
+       }
+
+       action_group = ACTION_GROUP (MAIL_LABEL);
+       if (action_group)
+               gtk_action_group_set_sensitive (action_group, sensitive);
+
+       action = ACTION (MAIL_LABEL_NONE);
+       if (action)
+               gtk_action_set_sensitive (action, sensitive);
+}
diff --git a/src/modules/mail/e-mail-shell-view-private.h b/src/modules/mail/e-mail-shell-view-private.h
index c2eb113..b9aac71 100644
--- a/src/modules/mail/e-mail-shell-view-private.h
+++ b/src/modules/mail/e-mail-shell-view-private.h
@@ -169,6 +169,9 @@ void                e_mail_shell_view_update_send_receive_menus
                                        (EMailShellView *mail_shell_view);
 GDBusProxy *   e_mail_shell_view_get_web_extension_proxy
                                        (EMailShellView *mail_shell_view);
+void           e_mail_shell_view_update_labels_sensitivity
+                                       (EShellWindow *shell_window,
+                                        GtkWidget *focused_widget);
 
 G_END_DECLS
 
diff --git a/src/modules/mail/e-mail-shell-view.c b/src/modules/mail/e-mail-shell-view.c
index 53ae0f9..57ac524 100644
--- a/src/modules/mail/e-mail-shell-view.c
+++ b/src/modules/mail/e-mail-shell-view.c
@@ -1225,6 +1225,8 @@ mail_shell_view_update_actions (EShellView *shell_view)
        action = ACTION (MAIL_VFOLDER_UNMATCHED_ENABLE);
        gtk_action_set_visible (action, folder_is_store && folder_is_virtual);
 
+       e_mail_shell_view_update_labels_sensitivity (shell_window, NULL);
+
        e_mail_shell_view_update_popup_labels (mail_shell_view);
 }
 


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