From 0a6d8c81926cd1f0f0a63db9f23152ccec52c754 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 22 Oct 2021 03:26:45 +0300 Subject: [PATCH 47/47] gtk3x: Avoid gtk_button_set_relief() calls Replace them with gtk_button_set_has_frame() See osdn #43096 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/citydlg.c | 4 ++-- client/gui-gtk-4.0/editgui.c | 6 +++--- client/gui-gtk-4.0/gtkcompat.c | 12 ++++++++++++ client/gui-gtk-4.0/gtkcompat.h | 1 + client/gui-gtk-4.0/gui_stuff.c | 2 +- client/gui-gtk-4.0/helpdlg.c | 2 +- client/gui-gtk-4.0/voteinfo_bar.c | 3 ++- client/gui-gtk-4.0/wldlg.c | 10 +++++----- 8 files changed, 27 insertions(+), 13 deletions(-) diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c index 5e4e673ee6..eb4bbc0d54 100644 --- a/client/gui-gtk-4.0/citydlg.c +++ b/client/gui-gtk-4.0/citydlg.c @@ -2135,7 +2135,7 @@ static void city_dialog_update_supported_units(struct city_dialog *pdialog) cmd = gtk_button_new(); node.cmd = cmd; - gtk_button_set_relief(GTK_BUTTON(cmd), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(cmd), FALSE); pix = gtk_image_new(); node.pix = pix; @@ -2238,7 +2238,7 @@ static void city_dialog_update_present_units(struct city_dialog *pdialog) cmd = gtk_button_new(); node.cmd = cmd; - gtk_button_set_relief(GTK_BUTTON(cmd), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(cmd), FALSE); pix = gtk_image_new(); node.pix = pix; diff --git a/client/gui-gtk-4.0/editgui.c b/client/gui-gtk-4.0/editgui.c index 353ee1ca09..7caf1b3226 100644 --- a/client/gui-gtk-4.0/editgui.c +++ b/client/gui-gtk-4.0/editgui.c @@ -442,7 +442,7 @@ static void editbar_add_tool_button(struct editbar *eb, gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE); gtk_widget_set_tooltip_text(button, editor_tool_get_tooltip(ett)); gtk_size_group_add_widget(eb->size_group, button); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); g_signal_connect(button, "toggled", @@ -504,7 +504,7 @@ static void editbar_add_mode_button(struct editbar *eb, gtk_widget_set_tooltip_text(button, tooltip); } gtk_size_group_add_widget(eb->size_group, button); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); g_signal_connect(button, "toggled", @@ -598,7 +598,7 @@ static struct editbar *editbar_create(void) gtk_container_add(GTK_CONTAINER(button), image); gtk_widget_set_tooltip_text(button, _("Show the property editor.")); gtk_size_group_add_widget(eb->size_group, button); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); g_signal_connect(button, "clicked", G_CALLBACK(editbar_player_properties_button_clicked), eb); diff --git a/client/gui-gtk-4.0/gtkcompat.c b/client/gui-gtk-4.0/gtkcompat.c index 2ff935f02f..c9c4f82045 100644 --- a/client/gui-gtk-4.0/gtkcompat.c +++ b/client/gui-gtk-4.0/gtkcompat.c @@ -35,6 +35,18 @@ void gtk_scrolled_window_set_has_frame(GtkScrolledWindow *wnd, bool shadow) } } +/************************************************************************//** + Version of gtk_button_set_has_frame() for gtk < 3.98.3 +****************************************************************************/ +void gtk_button_set_has_frame(GtkButton *btn, bool shadow) +{ + if (shadow) { + gtk_button_set_relief(btn, GTK_RELIEF_NORMAL); + } else { + gtk_button_set_relief(btn, GTK_RELIEF_NONE); + } +} + #endif /* GTK version < 3.98.3 */ diff --git a/client/gui-gtk-4.0/gtkcompat.h b/client/gui-gtk-4.0/gtkcompat.h index 9855f7db7f..a7a42ca6b3 100644 --- a/client/gui-gtk-4.0/gtkcompat.h +++ b/client/gui-gtk-4.0/gtkcompat.h @@ -24,6 +24,7 @@ #define GDK_ALT_MASK GDK_MOD1_MASK void gtk_scrolled_window_set_has_frame(GtkScrolledWindow *wnd, bool shadow); +void gtk_button_set_has_frame(GtkButton *btn, bool shadow); #endif /* GTK version < 3.98.3 */ diff --git a/client/gui-gtk-4.0/gui_stuff.c b/client/gui-gtk-4.0/gui_stuff.c index 7b011fb413..0f6b17f182 100644 --- a/client/gui-gtk-4.0/gui_stuff.c +++ b/client/gui-gtk-4.0/gui_stuff.c @@ -602,7 +602,7 @@ void gui_dialog_new(struct gui_dialog **pdlg, GtkNotebook *notebook, gtk_container_add(GTK_CONTAINER(hbox), label); button = gtk_button_new(); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); g_signal_connect_swapped(button, "clicked", G_CALLBACK(gui_dialog_delete_tab_handler), dlg); diff --git a/client/gui-gtk-4.0/helpdlg.c b/client/gui-gtk-4.0/helpdlg.c index cf0d204130..65e8c32803 100644 --- a/client/gui-gtk-4.0/helpdlg.c +++ b/client/gui-gtk-4.0/helpdlg.c @@ -331,7 +331,7 @@ static GtkWidget *help_hyperlink_new(GtkWidget *label, enum help_page_type type) GtkWidget *button; button = gtk_button_new(); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_halign(label, GTK_ALIGN_CENTER); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_widget_set_name(label, "help_link"); diff --git a/client/gui-gtk-4.0/voteinfo_bar.c b/client/gui-gtk-4.0/voteinfo_bar.c index 5d50ccbebb..10b590695f 100644 --- a/client/gui-gtk-4.0/voteinfo_bar.c +++ b/client/gui-gtk-4.0/voteinfo_bar.c @@ -28,6 +28,7 @@ /* client/gui-gtk-4.0 */ #include "chatline.h" +#include "gtkcompat.h" #include "pages.h" #include "voteinfo_bar.h" @@ -143,7 +144,7 @@ GtkWidget *voteinfo_bar_new(bool split_bar) G_CALLBACK(voteinfo_bar_next_callback), NULL); gtk_button_set_icon_name(GTK_BUTTON(button), "media-seek-backward"); gtk_widget_set_size_request(button, -1, BUTTON_HEIGHT); - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_widget_set_focus_on_click(button, FALSE); gtk_container_add(GTK_CONTAINER(hbox), button); vib->next_button = button; diff --git a/client/gui-gtk-4.0/wldlg.c b/client/gui-gtk-4.0/wldlg.c index 94a66fb40a..acc40ea8f1 100644 --- a/client/gui-gtk-4.0/wldlg.c +++ b/client/gui-gtk-4.0/wldlg.c @@ -1138,7 +1138,7 @@ GtkWidget *create_worklist(void) gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->prepend_cmd = button; - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_grid_attach(GTK_GRID(table2), button, 0, 0, 1, 1); arrow = gtk_image_new_from_icon_name("pan-start-symbolic"); @@ -1149,7 +1149,7 @@ GtkWidget *create_worklist(void) button = gtk_button_new(); ptr->up_cmd = button; - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_grid_attach(GTK_GRID(table2), button, 0, 1, 1, 1); arrow = gtk_image_new_from_icon_name("pan-up-symbolic"); @@ -1160,7 +1160,7 @@ GtkWidget *create_worklist(void) button = gtk_button_new(); ptr->down_cmd = button; - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_grid_attach(GTK_GRID(table2), button, 0, 2, 1, 1); arrow = gtk_image_new_from_icon_name("pan-down-symbolic"); @@ -1173,7 +1173,7 @@ GtkWidget *create_worklist(void) gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->append_cmd = button; - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_grid_attach(GTK_GRID(table2), button, 0, 3, 1, 1); arrow = gtk_image_new_from_icon_name("pan-start-symbolic"); @@ -1186,7 +1186,7 @@ GtkWidget *create_worklist(void) gtk_widget_set_margin_top(button, 24); gtk_widget_set_margin_bottom(button, 24); ptr->remove_cmd = button; - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + gtk_button_set_has_frame(GTK_BUTTON(button), FALSE); gtk_grid_attach(GTK_GRID(table2), button, 0, 4, 1, 1); arrow = gtk_image_new_from_icon_name("pan-end-symbolic"); -- 2.33.0