From 333dbaaa49d98fe23ea46b99caf9e4409ca52c36 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 10 May 2023 05:00:10 +0300 Subject: [PATCH 27/27] gtk4: Use GtkControllerFocus instead of "focus" signal Signal does not exist in gtk4 See osdn #47442 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/gui_main.c | 3 ++- client/gui-gtk-4.0/gui_main.h | 3 ++- client/gui-gtk-4.0/pages.c | 49 ++++++++++++++++++----------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/client/gui-gtk-4.0/gui_main.c b/client/gui-gtk-4.0/gui_main.c index e5891e93bf..4b8b3ba915 100644 --- a/client/gui-gtk-4.0/gui_main.c +++ b/client/gui-gtk-4.0/gui_main.c @@ -1035,7 +1035,8 @@ static void setup_canvas_color_for_state(GtkStateFlags state) /**********************************************************************//** Callback that just returns TRUE. **************************************************************************/ -bool terminate_signal_processing(void) +gboolean terminate_signal_processing(GtkEventControllerFocus *controller, + gpointer data) { return TRUE; } diff --git a/client/gui-gtk-4.0/gui_main.h b/client/gui-gtk-4.0/gui_main.h index 1e557b4b27..8effb44db1 100644 --- a/client/gui-gtk-4.0/gui_main.h +++ b/client/gui-gtk-4.0/gui_main.h @@ -78,7 +78,8 @@ struct video_mode *resolution_request_get(void); GtkApplication *gui_app(void); bool is_gui_up(void); -bool terminate_signal_processing(void); +gboolean terminate_signal_processing(GtkEventControllerFocus *controller, + gpointer data); gboolean fc_lost_focus(GtkEventControllerFocus *controller, gpointer data); diff --git a/client/gui-gtk-4.0/pages.c b/client/gui-gtk-4.0/pages.c index 4563d17b67..09c7f9c502 100644 --- a/client/gui-gtk-4.0/pages.c +++ b/client/gui-gtk-4.0/pages.c @@ -1200,24 +1200,20 @@ static void update_network_page(void) **************************************************************************/ GtkWidget *create_network_page(void) { - GtkWidget *box, *sbox, *bbox, *hgrid, *notebook; + GtkWidget *box, *sbox, *bbox, *hbox, *notebook; GtkWidget *button, *label, *view, *sw, *table; GtkTreeSelection *selection; GtkListStore *store; - int box_row = 0; - int sbox_row = 0; - int grid_col = 0; + GtkEventController *controller; - box = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(box), - GTK_ORIENTATION_VERTICAL); + box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); gtk_widget_set_margin_start(box, 4); gtk_widget_set_margin_end(box, 4); gtk_widget_set_margin_top(box, 4); gtk_widget_set_margin_bottom(box, 4); notebook = gtk_notebook_new(); - gtk_grid_attach(GTK_GRID(box), notebook, 0, box_row++, 1, 1); + gtk_box_append(GTK_BOX(box), notebook); /* LAN pane. */ lan_store = gtk_list_store_new(7, G_TYPE_STRING, /* host */ @@ -1237,8 +1233,12 @@ GtkWidget *create_network_page(void) selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); lan_selection = selection; gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); - g_signal_connect(view, "focus", + + controller = gtk_event_controller_focus_new(); + g_signal_connect(controller, "enter", G_CALLBACK(terminate_signal_processing), NULL); + gtk_widget_add_controller(view, controller); + g_signal_connect(view, "row-activated", G_CALLBACK(network_activate_callback), NULL); g_signal_connect(selection, "changed", @@ -1284,8 +1284,12 @@ GtkWidget *create_network_page(void) selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); meta_selection = selection; gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE); - g_signal_connect(view, "focus", + + controller = gtk_event_controller_focus_new(); + g_signal_connect(controller, "enter", G_CALLBACK(terminate_signal_processing), NULL); + gtk_widget_add_controller(view, controller); + g_signal_connect(view, "row-activated", G_CALLBACK(network_activate_callback), NULL); g_signal_connect(selection, "changed", @@ -1317,23 +1321,20 @@ GtkWidget *create_network_page(void) } /* Bottom part of the page, outside the inner notebook. */ - sbox = gtk_grid_new(); - gtk_orientable_set_orientation(GTK_ORIENTABLE(sbox), - GTK_ORIENTATION_VERTICAL); - gtk_grid_attach(GTK_GRID(box), sbox, 0, box_row++, 1, 1); + sbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 2); + gtk_box_append(GTK_BOX(box), sbox); - hgrid = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(hgrid), 12); - gtk_widget_set_margin_bottom(hgrid, 8); - gtk_widget_set_margin_end(hgrid, 8); - gtk_widget_set_margin_start(hgrid, 8); - gtk_widget_set_margin_top(hgrid, 8); - gtk_grid_attach(GTK_GRID(sbox), hgrid, 0, sbox_row++, 1, 1); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); + gtk_widget_set_margin_bottom(hbox, 8); + gtk_widget_set_margin_end(hbox, 8); + gtk_widget_set_margin_start(hbox, 8); + gtk_widget_set_margin_top(hbox, 8); + gtk_box_append(GTK_BOX(sbox), hbox); table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 2); gtk_grid_set_column_spacing(GTK_GRID(table), 12); - gtk_grid_attach(GTK_GRID(hgrid), table, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), table); network_host = gtk_entry_new(); g_signal_connect(network_host, "activate", @@ -1434,7 +1435,7 @@ GtkWidget *create_network_page(void) gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(sw), view); - gtk_grid_attach(GTK_GRID(hgrid), sw, grid_col++, 0, 1, 1); + gtk_box_append(GTK_BOX(hbox), sw); bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_widget_set_margin_bottom(bbox, 2); @@ -1442,7 +1443,7 @@ GtkWidget *create_network_page(void) gtk_widget_set_margin_start(bbox, 2); gtk_widget_set_margin_top(bbox, 2); gtk_box_set_spacing(GTK_BOX(bbox), 12); - gtk_grid_attach(GTK_GRID(sbox), bbox, 0, sbox_row++, 1, 1); + gtk_box_append(GTK_BOX(sbox), bbox); button = gtk_button_new_from_icon_name("view-refresh"); gtk_box_append(GTK_BOX(bbox), button); -- 2.39.2