From 5fde1b9e891179bccb554d847e0172e488a07b71 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 15 Nov 2025 02:50:17 +0000 Subject: [PATCH] libgimpwidgets, theme: Group radio buttons together This patch swaps out the GtkBox in gimp_enum_icon_box_new_with_toggle () with a GtkButtonBox and sets it to EXPAND so that the buttons are pressed together. It also adds some CSS style to complete the effect. --- app/tools/gimptextoptions.c | 1 + app/widgets/gimpstrokeeditor.c | 2 ++ libgimpwidgets/gimpenumwidgets.c | 3 +- themes/Default/common-dark.css | 4 +++ themes/Default/common-light.css | 4 +++ themes/Default/common.css | 25 +++++++++++++++ themes/System/gimp.css | 52 ++++++++++++++++++++++++++++++++ 7 files changed, 90 insertions(+), 1 deletion(-) diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index d0c25717f9..7562edf209 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -907,6 +907,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options) box = gimp_prop_enum_icon_box_new (config, "justify", "format-justify", 0, 0); gtk_widget_set_halign (box, GTK_ALIGN_START); + gtk_box_set_homogeneous (GTK_BOX (box), FALSE); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("Justify:"), 0.0, 0.5, box, 2); diff --git a/app/widgets/gimpstrokeeditor.c b/app/widgets/gimpstrokeeditor.c index ed2e0dcda4..1a4d9f90f2 100644 --- a/app/widgets/gimpstrokeeditor.c +++ b/app/widgets/gimpstrokeeditor.c @@ -146,12 +146,14 @@ gimp_stroke_editor_constructed (GObject *object) box = gimp_prop_enum_icon_box_new (G_OBJECT (options), "cap-style", "gimp-cap", 0, 0); + gtk_widget_set_halign (box, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("_Cap style:"), 0.0, 0.5, box, 2); box = gimp_prop_enum_icon_box_new (G_OBJECT (options), "join-style", "gimp-join", 0, 0); + gtk_widget_set_halign (box, GTK_ALIGN_START); gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++, _("_Join style:"), 0.0, 0.5, box, 2); diff --git a/libgimpwidgets/gimpenumwidgets.c b/libgimpwidgets/gimpenumwidgets.c index ee9adde2fa..246e3e6bf8 100644 --- a/libgimpwidgets/gimpenumwidgets.c +++ b/libgimpwidgets/gimpenumwidgets.c @@ -372,7 +372,8 @@ gimp_enum_icon_box_new_with_range (GType enum_type, enum_class = g_type_class_ref (enum_type); - hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_EXPAND); g_object_weak_ref (G_OBJECT (hbox), (GWeakNotify) g_type_class_unref, enum_class); diff --git a/themes/Default/common-dark.css b/themes/Default/common-dark.css index 886534aba2..a84343837b 100644 --- a/themes/Default/common-dark.css +++ b/themes/Default/common-dark.css @@ -42,3 +42,7 @@ GimpSpinScale entry progress { progressbar trough progress { background-color: @hover-color; } + +buttonbox button.radio:not(:checked) { + background-color: @stronger-border-color; +} diff --git a/themes/Default/common-light.css b/themes/Default/common-light.css index 25e1785e62..abed63fc41 100644 --- a/themes/Default/common-light.css +++ b/themes/Default/common-light.css @@ -25,3 +25,7 @@ paned.vertical > separator { button:not(.flat) { box-shadow: 0 1px @extreme-bg-color inset; } + +buttonbox button.radio:not(:checked) { + box-shadow: 0 1px @extreme-bg-color inset; +} diff --git a/themes/Default/common.css b/themes/Default/common.css index f3efa15d90..038231ddc8 100644 --- a/themes/Default/common.css +++ b/themes/Default/common.css @@ -657,6 +657,31 @@ button.radio image { padding: 4px; } +/* Create appearance of toggle group for enum radio buttons */ +buttonbox.horizontal button.radio +{ + border-top: 1px solid @edge-border-color; + border-bottom: 1px solid @edge-border-color; + border-left: 1px solid @edge-border-color; +} + +buttonbox.horizontal button.radio:last-child +{ + border-right: 1px solid @edge-border-color; +} + +buttonbox.vertical button.radio +{ + border-top: 1px solid @edge-border-color; + border-left: 1px solid @edge-border-color; + border-right: 1px solid @edge-border-color; +} + +buttonbox.vertical button.radio:last-child +{ + border-bottom: 1px solid @edge-border-color; +} + /* Removes "blurred" effect from tooltip label */ tooltip { background-color: @bg-color; diff --git a/themes/System/gimp.css b/themes/System/gimp.css index 6324c12201..2f89ec829f 100644 --- a/themes/System/gimp.css +++ b/themes/System/gimp.css @@ -126,6 +126,58 @@ GimpSpinScale button { padding: 0 1px 0 1px; } + +/* Create appearance of toggle group for enum radio buttons */ +buttonbox button.radio +{ + min-height: 24px; + min-width: 16px; + outline-width: 0px; +} + +buttonbox button.radio image +{ + padding: 4px; +} + +buttonbox.horizontal button.radio +{ + border-top: 1px solid @borders; + border-bottom: 1px solid @borders; + border-left: 1px solid @borders; +} + +buttonbox.horizontal button.radio:last-child +{ + border-right: 1px solid @borders; +} + +buttonbox.vertical button.radio +{ + border-top: 1px solid @borders; + border-left: 1px solid @borders; + border-right: 1px solid @borders; +} + +buttonbox.vertical button.radio:last-child +{ + border-bottom: 1px solid @borders; +} + +buttonbox.horizontal button.radio:not(:first-child) +{ + margin-right: -1px; +} + +buttonbox.vertical button.radio:not(:first-child) +{ + margin-bottom: -1px; +} + +combobox button { + outline-width: 0px; +} + entry.italic { font-style: italic; }