From 22a80a234dcff892aece29042029f52b65f44292 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 2 May 2022 15:40:44 +0100 Subject: [PATCH] GTK: change implementation of 100%-width editboxes. Previously, in the code that instantiated the dialog.h portable control spec, an edit control with width=100 would be implemented as a small Columns object containing the label and the edit control atop each other. Now, instead, the two controls are placed separately into the containing Columns. Combined with the changes just made to the align_next_to system, this means that you can put buttons to the right of such an edit box and have them line up with the actual edit box, instead of trying to line up with the combination of the box and its label. (The Windows alignment system already identified the specific edit box control as the relevant one, so this was already working there.) --- unix/dialog.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/unix/dialog.c b/unix/dialog.c index 5b205201..8038a2e5 100644 --- a/unix/dialog.c +++ b/unix/dialog.c @@ -2089,19 +2089,20 @@ GtkWidget *layout_ctrls( #endif if (ctrl->label) { - GtkWidget *label, *container; + GtkWidget *label; label = gtk_label_new(ctrl->label); shortcut_add(scs, label, ctrl->editbox.shortcut, SHORTCUT_FOCUS, uc->entry); - container = columns_new(4); if (ctrl->editbox.percentwidth == 100) { - columns_add(COLUMNS(container), label, 0, 1); - columns_force_left_align(COLUMNS(container), label); - columns_add(COLUMNS(container), w, 0, 1); + columns_add(cols, label, + COLUMN_START(ctrl->column), + COLUMN_SPAN(ctrl->column)); + columns_force_left_align(cols, label); } else { + GtkWidget *container = columns_new(4); gint percentages[2]; percentages[1] = ctrl->editbox.percentwidth; percentages[0] = 100 - ctrl->editbox.percentwidth; @@ -2110,11 +2111,11 @@ GtkWidget *layout_ctrls( columns_force_left_align(COLUMNS(container), label); columns_add(COLUMNS(container), w, 1, 1); columns_align_next_to(COLUMNS(container), label, w); + gtk_widget_show(w); + w = container; } - gtk_widget_show(label); - gtk_widget_show(w); - w = container; + gtk_widget_show(label); uc->label = label; } break;