From 0e0958f09542d3d8f09b4065f02256b20d801302 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 18 Dec 2021 14:27:31 +0200 Subject: [PATCH 39/40] gtk3x: Replace GtkRadioButtons They go away in gtk-3.99.1. See osdn #43416 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/citydlg.c | 14 +++++++++----- client/gui-gtk-4.0/dialogs.c | 9 ++++++--- client/gui-gtk-4.0/editgui.c | 10 ++++++---- client/gui-gtk-4.0/unitselextradlg.c | 13 +++---------- client/gui-gtk-4.0/unitselunitdlg.c | 13 +++---------- 5 files changed, 27 insertions(+), 32 deletions(-) diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 71aa0194a2..e06a30ab64 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -1390,7 +1390,7 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) int i; GtkWidget *vgrid, *page, *frame, *label, *button; GtkSizeGroup *size; - GSList *group; + GtkWidget *group; const char *tab_title = _("_Settings"); int grid_row = 0; @@ -1447,12 +1447,14 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) group = NULL; for (i = 0; i < ARRAY_SIZE(new_citizens_output_label); i++) { - button = gtk_radio_button_new_with_mnemonic(group, new_citizens_output_label[i]); + button = gtk_check_button_new_with_mnemonic(new_citizens_output_label[i]); + gtk_check_button_set_group(GTK_CHECK_BUTTON(button), + GTK_CHECK_BUTTON(group)); pdialog->misc.new_citizens_radio[i] = button; gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "toggled", G_CALLBACK(cityopt_callback), pdialog); - group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + group = button; } /* next is the next-time-open radio group in the right column */ @@ -1471,12 +1473,14 @@ static void create_and_append_settings_page(struct city_dialog *pdialog) group = NULL; for (i = 0; i < ARRAY_SIZE(misc_whichtab_label); i++) { - button = gtk_radio_button_new_with_mnemonic(group, misc_whichtab_label[i]); + button = gtk_check_button_new_with_mnemonic(misc_whichtab_label[i]); + gtk_check_button_set_group(GTK_CHECK_BUTTON(button), + GTK_CHECK_BUTTON(group)); pdialog->misc.whichtab_radio[i] = button; gtk_grid_attach(GTK_GRID(vgrid), button, 0, grid_row++, 1, 1); g_signal_connect(button, "toggled", G_CALLBACK(misc_whichtab_callback), GINT_TO_POINTER(i)); - group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button)); + group = button; } /* now we go back and fill the hbox rename */ diff --git a/client/gui-gtk-4.0/dialogs.c b/client/gui-gtk-4.0/dialogs.c index 0f9b5d8cea..c536b41e06 100644 --- a/client/gui-gtk-4.0/dialogs.c +++ b/client/gui-gtk-4.0/dialogs.c @@ -842,6 +842,7 @@ static void create_races_dialog(struct player *pplayer) { GtkWidget *shell; GtkWidget *cmd; + GtkWidget *group; GtkWidget *hgrid, *table; GtkWidget *frame, *label, *combo; GtkWidget *text; @@ -1086,13 +1087,15 @@ static void create_races_dialog(struct player *pplayer) gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 2); gtk_grid_attach(GTK_GRID(table), combo, 1, 0, 2, 1); - cmd = gtk_radio_button_new_with_mnemonic(NULL, _("_Female")); + cmd = gtk_check_button_new_with_mnemonic(_("_Female")); gtk_widget_set_margin_bottom(cmd, 6); races_sex[0] = cmd; gtk_grid_attach(GTK_GRID(table), cmd, 1, 1, 1, 1); + group = cmd; - cmd = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(cmd), - _("_Male")); + cmd = gtk_check_button_new_with_mnemonic(_("_Male")); + gtk_check_button_set_group(GTK_CHECK_BUTTON(cmd), + GTK_CHECK_BUTTON(group)); gtk_widget_set_margin_bottom(cmd, 6); races_sex[1] = cmd; gtk_grid_attach(GTK_GRID(table), cmd, 2, 1, 1, 1); diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 1b7d22f83c..233849e4ef 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -412,7 +412,7 @@ static void editbar_add_tool_button(struct editbar *eb, { GdkPixbuf *pixbuf; GtkWidget *image, *button, *hbox; - GtkRadioButton *parent = NULL; + GtkCheckButton *parent = NULL; struct sprite *sprite; int i; @@ -422,15 +422,17 @@ static void editbar_add_tool_button(struct editbar *eb, for (i = 0; i < NUM_EDITOR_TOOL_TYPES; i++) { if (eb->tool_buttons[i] != NULL) { - parent = GTK_RADIO_BUTTON(eb->tool_buttons[i]); + parent = GTK_CHECK_BUTTON(eb->tool_buttons[i]); break; } } if (parent == NULL) { - button = gtk_radio_button_new(NULL); + button = gtk_check_button_new(); } else { - button = gtk_radio_button_new_from_widget(parent); + button = gtk_check_button_new(); + gtk_check_button_set_group(GTK_CHECK_BUTTON(button), + GTK_CHECK_BUTTON(parent)); } sprite = editor_tool_get_sprite(ett); diff --git a/client/gui-gtk-4.0/unitselextradlg.c b/client/gui-gtk-4.0/unitselextradlg.c index c15adaf59b..abce9dbcbd 100644 --- a/client/gui-gtk-4.0/unitselextradlg.c +++ b/client/gui-gtk-4.0/unitselextradlg.c @@ -180,21 +180,14 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, cbdata->tp_id = ptgt->id; cbdata->dlg = dlg; - radio = gtk_radio_button_new_from_widget( - GTK_RADIO_BUTTON(first_option)); + radio = gtk_check_button_new(); + gtk_check_button_set_group(GTK_CHECK_BUTTON(radio), + GTK_CHECK_BUTTON(first_option)); if (first_option == NULL) { first_option = radio; default_option = first_option; default_extra = ptgt; } - /* The lists must be the same length if they contain the same - * elements. */ - fc_assert_msg(g_slist_length(gtk_radio_button_get_group( - GTK_RADIO_BUTTON(radio))) - == g_slist_length(gtk_radio_button_get_group( - GTK_RADIO_BUTTON(first_option))), - "The radio button for '%s' is broken.", - extra_rule_name(ptgt)); g_signal_connect(radio, "toggled", G_CALLBACK(unit_sel_extra_toggled), cbdata); g_signal_connect(radio, "destroy", diff --git a/client/gui-gtk-4.0/unitselunitdlg.c b/client/gui-gtk-4.0/unitselunitdlg.c index 5f71d483d2..b561b0de30 100644 --- a/client/gui-gtk-4.0/unitselunitdlg.c +++ b/client/gui-gtk-4.0/unitselunitdlg.c @@ -140,21 +140,14 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, cbdata->tp_id = ptgt->id; cbdata->dlg = dlg; - radio = gtk_radio_button_new_from_widget( - GTK_RADIO_BUTTON(first_option)); + radio = gtk_check_button_new(); + gtk_check_button_set_group(GTK_CHECK_BUTTON(radio), + GTK_CHECK_BUTTON(first_option)); if (first_option == NULL) { first_option = radio; default_option = first_option; default_unit = ptgt; } - /* The lists must be the same length if they contain the same - * elements. */ - fc_assert_msg(g_slist_length(gtk_radio_button_get_group( - GTK_RADIO_BUTTON(radio))) - == g_slist_length(gtk_radio_button_get_group( - GTK_RADIO_BUTTON(first_option))), - "The radio button for '%s' is broken.", - unit_rule_name(ptgt)); g_signal_connect(radio, "toggled", G_CALLBACK(unit_sel_unit_toggled), cbdata); g_signal_connect(radio, "destroy", -- 2.34.1