Bug 799343 - Dialog boxes won't remain sized and positioned - part1

This commit allows saving the position and size of the Billing Term
Editor and the Process Payment dialogs.
This commit is contained in:
Robert Fewell 2025-01-24 12:02:34 +00:00
parent 71583f60b2
commit 4fc3a0cb83
3 changed files with 67 additions and 3 deletions

View File

@ -39,6 +39,7 @@
#include "dialog-billterms.h"
#define DIALOG_BILLTERMS_CM_CLASS "billterms-dialog"
#define GNC_PREFS_GROUP "dialogs.bill-terms"
enum term_cols
{
@ -709,8 +710,10 @@ static void
billterms_window_close_handler (gpointer data)
{
BillTermsWindow *btw = data;
g_return_if_fail (btw);
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(btw->window));
gtk_widget_destroy (btw->window);
}
@ -718,9 +721,24 @@ void
billterms_window_close (GtkWidget *widget, gpointer data)
{
BillTermsWindow *btw = data;
gnc_close_gui_component (btw->component_id);
}
static gboolean
billterms_window_delete_event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer data)
{
BillTermsWindow *btw = data;
if (!btw) return FALSE;
// this cb allows the window size to be saved on closing with the X
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(btw->window));
return FALSE;
}
void
billterms_window_destroy_cb (GtkWidget *widget, gpointer data)
{
@ -809,7 +827,7 @@ gnc_ui_billterms_window_new (GtkWindow *parent, QofBook *book)
gnc_widget_style_context_add_class (GTK_WIDGET(btw->window), "gnc-class-bill-terms");
g_signal_connect (btw->window, "key_press_event",
G_CALLBACK (billterms_window_key_press_cb), btw);
G_CALLBACK(billterms_window_key_press_cb), btw);
/* Initialize the view */
view = GTK_TREE_VIEW(btw->terms_view);
@ -850,6 +868,11 @@ gnc_ui_billterms_window_new (GtkWindow *parent, QofBook *book)
gnc_gui_component_set_session (btw->component_id, btw->session);
g_signal_connect (G_OBJECT(btw->window), "delete-event",
G_CALLBACK(billterms_window_delete_event_cb), btw);
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(btw->window), GTK_WINDOW(parent));
gtk_widget_show_all (btw->window);
billterms_window_refresh (btw);

View File

@ -59,6 +59,7 @@
static const QofLogModule log_module = G_LOG_DOMAIN;
#define DIALOG_PAYMENT_CM_CLASS "payment-dialog"
#define GNC_PREFS_GROUP "dialogs.process-payment"
typedef enum
{
@ -327,8 +328,9 @@ gnc_payment_window_close_handler (gpointer data)
{
PaymentWindow *pw = data;
if (pw)
gtk_widget_destroy (pw->dialog);
if (!pw) return;
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog));
gtk_widget_destroy (pw->dialog);
}
static void
@ -1203,6 +1205,19 @@ doc_sort_func (GtkTreeModel *model,
return ret;
}
static gboolean
payment_dialog_delete_event_cb (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
PaymentWindow *pw = user_data;
// this cb allows the window size to be saved on closing with the X
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog));
return FALSE;
}
static PaymentWindow *
new_payment_window (GtkWindow *parent, QofBook *book, InitialPaymentInfo *tx_info)
{
@ -1404,6 +1419,8 @@ new_payment_window (GtkWindow *parent, QofBook *book, InitialPaymentInfo *tx_inf
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (gnc_payment_dialog_xfer_acct_changed_cb), pw);
g_signal_connect (G_OBJECT(pw->dialog), "delete-event",
G_CALLBACK(payment_dialog_delete_event_cb), pw);
/* Register with the component manager */
pw->component_id =
@ -1418,6 +1435,8 @@ new_payment_window (GtkWindow *parent, QofBook *book, InitialPaymentInfo *tx_inf
QOF_EVENT_CREATE | QOF_EVENT_MODIFY |
QOF_EVENT_DESTROY);
gnc_restore_window_size (GNC_PREFS_GROUP, GTK_WINDOW(pw->dialog), GTK_WINDOW(parent));
/* Show it all */
gtk_widget_show_all (pw->dialog);
g_object_unref(G_OBJECT(builder));

View File

@ -1,10 +1,12 @@
<schemalist gettext-domain="@PROJECT_NAME@">
<schema id="org.gnucash.GnuCash.dialogs" path="/org/gnucash/GnuCash/dialogs/">
<child name="account" schema="org.gnucash.GnuCash.dialogs.account"/>
<child name="bill-terms" schema="org.gnucash.GnuCash.dialogs.bill-terms"/>
<child name="imap-editor" schema="org.gnucash.GnuCash.dialogs.imap-editor"/>
<child name="preferences" schema="org.gnucash.GnuCash.dialogs.preferences"/>
<child name="price-editor" schema="org.gnucash.GnuCash.dialogs.price-editor"/>
<child name="pricedb-editor" schema="org.gnucash.GnuCash.dialogs.pricedb-editor"/>
<child name="process-payment" schema="org.gnucash.GnuCash.dialogs.process-payment"/>
<child name="reset-warnings" schema="org.gnucash.GnuCash.dialogs.reset-warnings"/>
<child name="tax-info" schema="org.gnucash.GnuCash.dialogs.tax-info"/>
<child name="fincalc" schema="org.gnucash.GnuCash.dialogs.fincalc"/>
@ -37,6 +39,16 @@
</key>
</schema>
<schema id="org.gnucash.GnuCash.dialogs.bill-terms" path="/org/gnucash/GnuCash/dialogs/bill-terms/">
<key type="(iiii)" name="last-geometry">
<default>(-1,-1,-1,-1)</default>
<summary>Last window position and size</summary>
<description>This setting describes the size and position of the window when it was last closed.
The numbers are the X and Y coordinates of the top left corner of the window
followed by the width and height of the window.</description>
</key>
</schema>
<schema id="org.gnucash.GnuCash.dialogs.imap-editor" path="/org/gnucash/GnuCash/dialogs/imap-editor/">
<key type="(iiii)" name="last-geometry">
<default>(-1,-1,-1,-1)</default>
@ -87,6 +99,16 @@
</key>
</schema>
<schema id="org.gnucash.GnuCash.dialogs.process-payment" path="/org/gnucash/GnuCash/dialogs/process-payment/">
<key type="(iiii)" name="last-geometry">
<default>(-1,-1,-1,-1)</default>
<summary>Last window position and size</summary>
<description>This setting describes the size and position of the window when it was last closed.
The numbers are the X and Y coordinates of the top left corner of the window
followed by the width and height of the window.</description>
</key>
</schema>
<schema id="org.gnucash.GnuCash.dialogs.reset-warnings" path="/org/gnucash/GnuCash/dialogs/reset-warnings/">
<key name="last-geometry" type="(iiii)">
<default>(-1,-1,-1,-1)</default>