From eb8451febf428ff4ad2e0489e600387c3c61c5b7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Mon, 6 May 2024 11:06:52 +0100 Subject: [PATCH] Bug 669035 - Save the Scheduled Transaction divider position The position of the divider is saved when the Scheduled Transaction page is left open and reverts to the default when closed. This commit adds a menu option 'Save layout as default' which will save the position as a preference setting so it will be remembered. --- gnucash/gnome/gnc-plugin-page-sx-list.cpp | 33 +++++++++++++++---- ...gnucash.GnuCash.dialogs.sxs.gschema.xml.in | 5 +++ gnucash/ui/gnc-plugin-page-sx-list.ui | 6 ++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/gnucash/gnome/gnc-plugin-page-sx-list.cpp b/gnucash/gnome/gnc-plugin-page-sx-list.cpp index 6719c14900..30dd267872 100644 --- a/gnucash/gnome/gnc-plugin-page-sx-list.cpp +++ b/gnucash/gnome/gnc-plugin-page-sx-list.cpp @@ -64,6 +64,7 @@ #include "gnc-main-window.h" #include "gnc-plugin.h" #include "gnc-plugin-page-sx-list.h" +#include "gnc-prefs.h" #include "gnc-session.h" #include "gnc-sx-instance-dense-cal-adapter.h" #include "gnc-sx-instance-model.h" @@ -80,6 +81,7 @@ G_GNUC_UNUSED static QofLogModule log_module = GNC_MOD_GUI_SX; #define PLUGIN_PAGE_SX_LIST_CM_CLASS "plugin-page-sx-list" #define STATE_SECTION "SX Transaction List" +#define GNC_PREF_DIVIDER_POS "divider-position" typedef struct GncPluginPageSxListPrivate { @@ -120,6 +122,7 @@ static void gnc_plugin_page_sx_list_cmd_new (GSimpleAction *simple, GVariant *pa static void gnc_plugin_page_sx_list_cmd_edit (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_sx_list_cmd_delete (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_sx_list_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); /* Command callbacks */ @@ -130,6 +133,7 @@ static GActionEntry gnc_plugin_page_sx_list_actions [] = { "SxListEditAction", gnc_plugin_page_sx_list_cmd_edit, NULL, NULL, NULL }, { "SxListDeleteAction", gnc_plugin_page_sx_list_cmd_delete, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_sx_list_cmd_refresh, NULL, NULL, NULL }, + { "ViewSaveLayoutAction", gnc_plugin_page_sx_list_cmd_save_layout, NULL, NULL, NULL }, { "EditTaxOptionsAction", gnc_plugin_page_sx_list_cmd_edit_tax_options, NULL, NULL, NULL }, }; /** The number of actions provided by this plugin. */ @@ -500,12 +504,10 @@ gnc_plugin_page_sx_list_create_widget (GncPluginPage *plugin_page) gtk_box_pack_start (GTK_BOX(vbox), swin, TRUE, TRUE, 5); gtk_widget_show (swin); - { - // gint half_way; - // half_way = plugin_page->notebook_page->allocation.height * 0.5; - // fixme; get a real value: - gtk_paned_set_position (GTK_PANED(priv->widget), 160); - } + /* Set the paned position from the preferences, default 160 */ + gtk_paned_set_position (GTK_PANED(priv->widget), + gnc_prefs_get_float (GNC_PREFS_GROUP_SXED, + GNC_PREF_DIVIDER_POS)); { GDate end; @@ -751,6 +753,25 @@ gnc_plugin_page_sx_list_cmd_refresh (GSimpleAction *simple, gtk_widget_queue_draw (priv->widget); } +static void +gnc_plugin_page_sx_list_cmd_save_layout (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + auto plugin_page = GNC_PLUGIN_PAGE_SX_LIST(user_data); + GncPluginPageSxListPrivate *priv; + gint paned_position; + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_SX_LIST(plugin_page)); + + priv = GNC_PLUGIN_PAGE_SX_LIST_GET_PRIVATE(plugin_page); + + paned_position = gtk_paned_get_position (GTK_PANED(priv->widget)); + + gnc_prefs_set_float (GNC_PREFS_GROUP_SXED, GNC_PREF_DIVIDER_POS, + paned_position); +} + static void _edit_sx(gpointer data, gpointer user_data) { diff --git a/gnucash/gschemas/org.gnucash.GnuCash.dialogs.sxs.gschema.xml.in b/gnucash/gschemas/org.gnucash.GnuCash.dialogs.sxs.gschema.xml.in index b1ebf3d55c..0409834843 100644 --- a/gnucash/gschemas/org.gnucash.GnuCash.dialogs.sxs.gschema.xml.in +++ b/gnucash/gschemas/org.gnucash.GnuCash.dialogs.sxs.gschema.xml.in @@ -54,6 +54,11 @@ How many days in advance to notify the user. How many days in advance to notify the user. + + 160 + The horizontal position of the editor divider. + The horizontal position of the editor divider. + (-1,-1,-1,-1) Last window position and size diff --git a/gnucash/ui/gnc-plugin-page-sx-list.ui b/gnucash/ui/gnc-plugin-page-sx-list.ui index 3ddab428b5..af845fd429 100644 --- a/gnucash/ui/gnc-plugin-page-sx-list.ui +++ b/gnucash/ui/gnc-plugin-page-sx-list.ui @@ -33,6 +33,12 @@ + + _Save layout as default + GncPluginPageSxListActions.ViewSaveLayoutAction + Save current layout as default + yes + _Refresh GncPluginPageSxListActions.ViewRefreshAction