X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fgtkdlg.c;h=573111aeede967676f5f2d6c4a86c87c43226046;hb=5471539a6738484b48fb938c88dce547a3e4b299;hp=47a8fae12edc7d219c7cde84b117bd755103ff85;hpb=dc11417aeeec0735071cf98347af6f9616ba6a2e;p=PuTTY.git diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index 47a8fae1..573111ae 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -1077,15 +1077,6 @@ static void set_transient_window_pos(GtkWidget *parent, GtkWidget *child) #endif } -void align_label_left(GtkLabel *label) -{ -#if GTK_CHECK_VERSION(3,16,0) - gtk_label_set_xalign(label, 0.0); -#else - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0); -#endif -} - void dlg_error_msg(void *dlg, const char *msg) { struct dlgparam *dp = (struct dlgparam *)dlg; @@ -2303,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) @@ -2409,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); @@ -2477,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) { @@ -2889,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 { @@ -3324,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); @@ -3335,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); @@ -3366,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); @@ -3413,13 +3429,6 @@ int messagebox(GtkWidget *parentwin, const char *title, const char *msg, return dp.retval; } -int string_width(const char *text) -{ - int ret; - get_label_text_dimensions(text, &ret, NULL); - return ret; -} - int reallyclose(void *frontend) { char *title = dupcat(appname, " Exit Confirmation", NULL); @@ -3511,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); @@ -3576,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; @@ -3664,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));