[PATCH] Pressing F12 should do the same thing as clicking "Done" (#840998).

Chris Lumens clumens at redhat.com
Thu Feb 28 18:25:19 UTC 2013


You could do this in the old UI, so let's bring it forward to the new UI.
---
 widgets/src/SpokeWindow.c      | 15 ++++++++++++++-
 widgets/src/StandaloneWindow.c | 23 ++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/widgets/src/SpokeWindow.c b/widgets/src/SpokeWindow.c
index 2db0efe..9c1ae47 100644
--- a/widgets/src/SpokeWindow.c
+++ b/widgets/src/SpokeWindow.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011  Red Hat, Inc.
+ * Copyright (C) 2011-2013  Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +21,8 @@
 #include "SpokeWindow.h"
 #include "intl.h"
 
+#include <gdk/gdkkeysyms.h>
+
 /**
  * SECTION: SpokeWindow
  * @title: AnacondaSpokeWindow
@@ -155,6 +157,7 @@ static void anaconda_spoke_window_init(AnacondaSpokeWindow *win) {
 }
 
 static void anaconda_spoke_window_realize(GtkWidget *widget, gpointer user_data) {
+    GtkAccelGroup *accel_group;
     GError *error;
     GdkPixbuf *pixbuf;
     cairo_pattern_t *pattern;
@@ -189,6 +192,16 @@ static void anaconda_spoke_window_realize(GtkWidget *widget, gpointer user_data)
         cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
         gdk_window_set_background_pattern(gtk_widget_get_window(nav_box), pattern);
     }
+
+    /* Pressing F12 should send you back to the hub, similar to how the old UI worked. */
+    accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
+    gtk_widget_add_accelerator(window->priv->button,
+                               "clicked",
+                               accel_group,
+                               GDK_KEY_F12,
+                               0,
+                               0);
 }
 
 static void anaconda_spoke_window_button_clicked(GtkButton *button,
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c
index d7e86a8..28b25e2 100644
--- a/widgets/src/StandaloneWindow.c
+++ b/widgets/src/StandaloneWindow.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2012  Red Hat, Inc.
+ * Copyright (C) 2011-2013  Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +21,8 @@
 #include "StandaloneWindow.h"
 #include "intl.h"
 
+#include <gdk/gdkkeysyms.h>
+
 /**
  * SECTION: StandaloneWindow
  * @title: AnacondaStandaloneWindow
@@ -63,6 +65,8 @@ static void anaconda_standalone_window_quit_clicked(GtkButton *button,
                                                     AnacondaStandaloneWindow *win);
 static void anaconda_standalone_window_continue_clicked(GtkButton *button,
                                                         AnacondaStandaloneWindow *win);
+static void anaconda_standalone_window_realize(GtkWidget *widget,
+                                               AnacondaStandaloneWindow *win);
 
 G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
 
@@ -149,6 +153,23 @@ static void anaconda_standalone_window_init(AnacondaStandaloneWindow *win) {
     gtk_container_add(GTK_CONTAINER(win->priv->button_box), win->priv->continue_button);
 
     gtk_box_pack_start(GTK_BOX(main_box), win->priv->button_box, FALSE, TRUE, 0);
+
+    /* It would be handy for F12 to continue to work like it did in the old
+     * UI, by skipping you to the next screen.
+     */
+    g_signal_connect(win, "realize", G_CALLBACK(anaconda_standalone_window_realize), win);
+}
+
+static void anaconda_standalone_window_realize(GtkWidget *widget,
+                                               AnacondaStandaloneWindow *win) {
+    GtkAccelGroup *accel_group = gtk_accel_group_new();
+    gtk_window_add_accel_group(GTK_WINDOW(win), accel_group);
+    gtk_widget_add_accelerator(win->priv->continue_button,
+                               "clicked",
+                               accel_group,
+                               GDK_KEY_F12,
+                               0,
+                               0);
 }
 
 static void anaconda_standalone_window_quit_clicked(GtkButton *button,
-- 
1.8.1.2



More information about the anaconda-patches mailing list