X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fgtkdlg.c;h=573111aeede967676f5f2d6c4a86c87c43226046;hb=af1460d6e5044a3344aaacd15c91cfdcb58578e7;hp=e48c51b59e5d8fd45e79f4ed96e193f8133e9d44;hpb=49ff9f480e973060c0c7215868fae53db096ce2d;p=PuTTY.git diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index e48c51b5..573111ae 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -2294,6 +2294,9 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs, */ g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(droplist_selchange), dp); + + g_signal_connect(G_OBJECT(w), "focus_in_event", + G_CALLBACK(widget_focus), dp); #endif } else { #if !GTK_CHECK_VERSION(2,0,0) @@ -2400,6 +2403,8 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs, uc->treeview = w; g_signal_connect(G_OBJECT(w), "row-activated", G_CALLBACK(listbox_doubleclick), dp); + g_signal_connect(G_OBJECT(w), "focus_in_event", + G_CALLBACK(widget_focus), dp); g_signal_connect(G_OBJECT(sel), "changed", G_CALLBACK(listbox_selchange), dp); @@ -2468,7 +2473,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs, #endif shortcut_add(scs, label, ctrl->listbox.shortcut, - SHORTCUT_FOCUS, w); + SHORTCUT_UCTRL, uc); container = columns_new(4); if (ctrl->listbox.percentwidth == 100) { @@ -2880,7 +2885,7 @@ void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw, scs->sc[chr].action = action; - if (action == SHORTCUT_FOCUS) { + if (action == SHORTCUT_FOCUS || action == SHORTCUT_TREE) { scs->sc[chr].uc = NULL; scs->sc[chr].widget = (GtkWidget *)ptr; } else { @@ -3315,7 +3320,7 @@ int messagebox(GtkWidget *parentwin, const char *title, const char *msg, union control *c; struct dlgparam dp; struct Shortcuts scs; - int index, ncols; + int index, ncols, min_type; va_list ap; dlg_init(&dp); @@ -3326,13 +3331,23 @@ int messagebox(GtkWidget *parentwin, const char *title, const char *msg, 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); @@ -3357,7 +3372,17 @@ int messagebox(GtkWidget *parentwin, const char *title, const char *msg, 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); @@ -3495,7 +3520,8 @@ int askalg(void *frontend, const char *algtype, const char *algname, 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); @@ -3560,6 +3586,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; @@ -3648,6 +3683,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));