[gnome-logs/wip/latest-mockup: 5/6] Add accelerator for closing a window



commit 88b8a60a84696843dd3ef38c0011cae94ffb23a0
Author: David King <davidk gnome org>
Date:   Tue Oct 8 15:39:23 2013 +0100

    Add accelerator for closing a window

 src/gl-application.c |    2 ++
 src/gl-window.c      |   15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/gl-application.c b/src/gl-application.c
index f6bbed5..99544cf 100644
--- a/src/gl-application.c
+++ b/src/gl-application.c
@@ -127,6 +127,8 @@ gl_application_activate (GApplication *application)
     window = gl_window_new (GTK_APPLICATION (application));
     gtk_widget_show (window);
     gtk_application_add_accelerator (GTK_APPLICATION (application),
+                                     "<Primary>w", "win.close", NULL);
+    gtk_application_add_accelerator (GTK_APPLICATION (application),
                                      "<Primary>f", "win.search", NULL);
 }
 
diff --git a/src/gl-window.c b/src/gl-window.c
index 49f5c9a..cee2813 100644
--- a/src/gl-window.c
+++ b/src/gl-window.c
@@ -82,6 +82,18 @@ on_category (GSimpleAction *action,
 }
 
 static void
+on_close (GSimpleAction *action, 
+          GVariant *variant,
+          gpointer user_data)
+{
+    GtkWindow *window;
+
+    window = GTK_WINDOW (user_data);
+
+    gtk_window_close (window);
+}
+
+static void
 on_toolbar_mode (GSimpleAction *action,
                  GVariant *variant,
                  gpointer user_data)
@@ -243,7 +255,8 @@ static GActionEntry actions[] = {
     { "category", on_action_radio, "s", "'important'", on_category },
     { "view-mode", on_action_radio, "s", "'list'", on_view_mode },
     { "toolbar-mode", on_action_radio, "s", "'list'", on_toolbar_mode },
-    { "search", on_action_toggle, NULL, "false", on_search }
+    { "search", on_action_toggle, NULL, "false", on_search },
+    { "close", on_close }
 };
 
 static void


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