From 1fc4e97c2a7955d0807591da699745030be87186 Mon Sep 17 00:00:00 2001 From: Dino Date: Sat, 12 Apr 2025 16:07:44 -0400 Subject: [PATCH] #1288, gtk3.22 & gtk4 clients, save options dlog size during one runtime. --- client/gui-gtk-3.22/optiondlg.c | 15 ++++++++++++++- client/gui-gtk-4.0/optiondlg.c | 10 +++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/client/gui-gtk-3.22/optiondlg.c b/client/gui-gtk-3.22/optiondlg.c index 34099bc1eb..cb9d0b17b6 100644 --- a/client/gui-gtk-3.22/optiondlg.c +++ b/client/gui-gtk-3.22/optiondlg.c @@ -36,6 +36,7 @@ #include "optiondlg.h" +static int opt_dlog_width = 576, opt_dlog_height = 480; /* The option dialog data. */ struct option_dialog { @@ -129,6 +130,16 @@ static void option_dialog_reponse_callback(GtkDialog *dialog, static void option_dialog_destroy_callback(GtkWidget *object, gpointer data) { struct option_dialog *pdialog = (struct option_dialog *) data; + GtkWidget* cont_area; + GtkAllocation allocation; + int baseline; + + /* Save size of the dialog. */ + cont_area = gtk_dialog_get_content_area (GTK_DIALOG(pdialog->shell)); + gtk_widget_get_allocated_size(GTK_WIDGET(cont_area), + &allocation, &baseline); + opt_dlog_width = allocation.width; + opt_dlog_height = allocation.height; if (NULL != pdialog->shell) { /* Mark as destroyed, see also option_dialog_destroy(). */ @@ -377,7 +388,9 @@ option_dialog_new(const char *name, const struct option_set *poptset) /* Shell */ setup_dialog(pdialog->shell, toplevel); gtk_window_set_position(GTK_WINDOW(pdialog->shell), GTK_WIN_POS_MOUSE); - gtk_window_set_default_size(GTK_WINDOW(pdialog->shell), -1, 480); + gtk_window_set_default_size(GTK_WINDOW(pdialog->shell), + opt_dlog_width, + opt_dlog_height); g_signal_connect(pdialog->shell, "response", G_CALLBACK(option_dialog_reponse_callback), pdialog); g_signal_connect(pdialog->shell, "destroy", diff --git a/client/gui-gtk-4.0/optiondlg.c b/client/gui-gtk-4.0/optiondlg.c index a85f2d24af..6e9fda36b3 100644 --- a/client/gui-gtk-4.0/optiondlg.c +++ b/client/gui-gtk-4.0/optiondlg.c @@ -36,6 +36,7 @@ #include "optiondlg.h" +static int opt_dlog_width = 576, opt_dlog_height = 480; /* The option dialog data. */ struct option_dialog { @@ -132,6 +133,11 @@ static void option_dialog_destroy_callback(GtkWidget *object, gpointer data) { struct option_dialog *pdialog = (struct option_dialog *) data; + /* Save size of the dialog. */ + gtk_window_get_default_size (GTK_WINDOW(object), + &opt_dlog_width, + &opt_dlog_height); + if (NULL != pdialog->shell) { /* Mark as destroyed, see also option_dialog_destroy(). */ pdialog->shell = NULL; @@ -402,7 +408,9 @@ option_dialog_new(const char *name, const struct option_set *poptset) /* Shell */ setup_dialog(pdialog->shell, toplevel); - gtk_window_set_default_size(GTK_WINDOW(pdialog->shell), -1, 480); + gtk_window_set_default_size(GTK_WINDOW(pdialog->shell), + opt_dlog_width, + opt_dlog_height); g_signal_connect(pdialog->shell, "response", G_CALLBACK(option_dialog_reponse_callback), pdialog); g_signal_connect(pdialog->shell, "destroy", -- 2.31.0