[evolution/gnome-3-8] Bug 704440 - Close shell window alerts with Escape key



commit f856b4d66c2229760eb840c2c080852cbfcac621
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Aug 10 17:18:44 2013 -0400

    Bug 704440 - Close shell window alerts with Escape key
    
    This adds a "close-alert" signal to EShellWindow, which is bound to
    GDK_KEY_Escape.  The default handler closes view-specific alerts first,
    then global alerts.
    
    (cherry picked from commit 161df81dd99ddfe090b12f73d5b8dd3701d63f44)

 shell/e-shell-window.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 shell/e-shell-window.h |    1 +
 2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 3ed79b4..6702cf1 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -47,6 +47,7 @@ enum {
 };
 
 enum {
+       CLOSE_ALERT,
        SHELL_VIEW_CREATED,
        LAST_SIGNAL
 };
@@ -379,6 +380,27 @@ shell_window_constructed (GObject *object)
        G_OBJECT_CLASS (e_shell_window_parent_class)->constructed (object);
 }
 
+static void
+shell_window_close_alert (EShellWindow *shell_window)
+{
+       EShellView *shell_view;
+       EShellContent *shell_content;
+       GtkWidget *alert_bar;
+       const gchar *view_name;
+
+       /* Close view-specific alerts first, followed by global alerts. */
+
+       view_name = e_shell_window_get_active_view (shell_window);
+       shell_view = e_shell_window_get_shell_view (shell_window, view_name);
+       shell_content = e_shell_view_get_shell_content (shell_view);
+       alert_bar = e_shell_content_get_alert_bar (shell_content);
+
+       if (!e_alert_bar_close_alert (E_ALERT_BAR (alert_bar))) {
+               alert_bar = e_shell_window_get_alert_bar (shell_window);
+               e_alert_bar_close_alert (E_ALERT_BAR (alert_bar));
+       }
+}
+
 static GtkWidget *
 shell_window_construct_menubar (EShellWindow *shell_window)
 {
@@ -783,6 +805,7 @@ e_shell_window_class_init (EShellWindowClass *class)
 {
        GObjectClass *object_class;
        GtkWidgetClass *widget_class;
+       GtkBindingSet *binding_set;
 
        g_type_class_add_private (class, sizeof (EShellWindowPrivate));
 
@@ -796,6 +819,7 @@ e_shell_window_class_init (EShellWindowClass *class)
        widget_class = GTK_WIDGET_CLASS (class);
        widget_class->realize = shell_window_realize;
 
+       class->close_alert = shell_window_close_alert;
        class->construct_menubar = shell_window_construct_menubar;
        class->construct_toolbar = shell_window_construct_toolbar;
        class->construct_sidebar = shell_window_construct_sidebar;
@@ -973,6 +997,22 @@ e_shell_window_class_init (EShellWindowClass *class)
                        G_PARAM_READABLE));
 
        /**
+        * EShellWindow::close-alert
+        * @shell_window: the #EShellWindow which emitted the signal
+        *
+        * Closes either one #EShellView-specific #EAlert or else one
+        * global #EAlert.  This signal is bound to the Escape key.
+        **/
+       signals[CLOSE_ALERT] = g_signal_new (
+               "close-alert",
+               G_OBJECT_CLASS_TYPE (object_class),
+               G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+               G_STRUCT_OFFSET (EShellWindowClass, close_alert),
+               NULL, NULL,
+               g_cclosure_marshal_VOID__VOID,
+               G_TYPE_NONE, 0);
+
+       /**
         * EShellWindow::shell-view-created
         * @shell_window: the #EShellWindow which emitted the signal
         * @shell_view: the new #EShellView
@@ -991,6 +1031,10 @@ e_shell_window_class_init (EShellWindowClass *class)
                g_cclosure_marshal_VOID__OBJECT,
                G_TYPE_NONE, 1,
                E_TYPE_SHELL_VIEW);
+
+       binding_set = gtk_binding_set_by_class (class);
+       gtk_binding_entry_add_signal (
+               binding_set, GDK_KEY_Escape, 0, "close-alert", 0);
 }
 
 static void
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index b96d2f6..4e4bdba 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -67,6 +67,7 @@ struct _EShellWindowClass {
        GtkWindowClass parent_class;
 
        /* Signals */
+       void            (*close_alert)          (EShellWindow *shell_window);
        void            (*shell_view_created)   (EShellWindow *shell_window,
                                                 struct _EShellView *shell_view);
 


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