]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Make sure Escape terminates the About box.
authorSimon Tatham <anakin@pobox.com>
Sat, 26 Sep 2015 13:09:27 +0000 (14:09 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 26 Sep 2015 13:09:27 +0000 (14:09 +0100)
I think it only did so in GTK2 by virtue of the About box being a
GtkDialog. But in GTK3 I've abandoned GtkDialog for not being flexible
enough, so I have to process the Escape key myself.

unix/gtkdlg.c

index 9c16235095f0c089bc9667e36bbbceaeeed2e7ed..a1d72a842bda8e35ffcc4a5c559aa6ea56dbde21 100644 (file)
@@ -3585,6 +3585,15 @@ static void about_close_clicked(GtkButton *button, gpointer data)
     aboutbox = NULL;
 }
 
+static void about_key_press(GtkWidget *widget, GdkEventKey *event,
+                            gpointer data)
+{
+    if (event->keyval == GDK_KEY_Escape && aboutbox) {
+        gtk_widget_destroy(aboutbox);
+        aboutbox = NULL;
+    }
+}
+
 static void licence_clicked(GtkButton *button, gpointer data)
 {
     char *title;
@@ -3673,6 +3682,9 @@ void about_box(void *window)
     our_dialog_add_to_content_area(GTK_WINDOW(aboutbox), w, FALSE, FALSE, 5);
     gtk_widget_show(w);
 
+    g_signal_connect(G_OBJECT(aboutbox), "key_press_event",
+                     G_CALLBACK(about_key_press), NULL);
+
     set_transient_window_pos(GTK_WIDGET(window), aboutbox);
     gtk_window_set_transient_for(GTK_WINDOW(aboutbox),
                                 GTK_WINDOW(window));