#endif
shortcut_add(scs, label, ctrl->listbox.shortcut,
- SHORTCUT_FOCUS, w);
+ SHORTCUT_UCTRL, uc);
container = columns_new(4);
if (ctrl->listbox.percentwidth == 100) {
union control *c;
struct dlgparam dp;
struct Shortcuts scs;
- int index, ncols;
+ int index, ncols, min_type;
va_list ap;
dlg_init(&dp);
ctrlbox = ctrl_new_box();
+ /*
+ * Preliminary pass over the va_list, to count up the number of
+ * buttons and find out what kinds there are.
+ */
ncols = 0;
va_start(ap, minwid);
+ min_type = +1;
while (va_arg(ap, char *) != NULL) {
- ncols++;
+ int type;
+
(void) va_arg(ap, int); /* shortcut */
- (void) va_arg(ap, int); /* normal/default/cancel */
+ type = va_arg(ap, int); /* normal/default/cancel */
(void) va_arg(ap, int); /* end value */
+
+ ncols++;
+ if (min_type > type)
+ min_type = type;
}
va_end(ap);
c->generic.column = index++;
if (type > 0)
c->button.isdefault = TRUE;
- else if (type < 0)
+
+ /* We always arrange that _some_ button is labelled as
+ * 'iscancel', so that pressing Escape will always cause
+ * win_key_press to do something. The button we choose is
+ * whichever has the smallest type value: this means that real
+ * cancel buttons (labelled -1) will be picked if one is
+ * there, or in cases where the options are yes/no (1,0) then
+ * no will be picked, and if there's only one option (a box
+ * that really is just showing a _message_ and not even asking
+ * a question) then that will be picked. */
+ if (type == min_type)
c->button.iscancel = TRUE;
}
va_end(ap);
text = dupprintf(msg, algtype, algname);
ret = messagebox(GTK_WIDGET(get_window(frontend)),
"PuTTY Security Alert", text,
- string_width("Continue with connection?"),
+ string_width("Reasonably long line of text as a width"
+ " template"),
"Yes", 'y', 0, 1,
"No", 'n', 0, 0,
NULL);
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;
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));