From 19a45192f8d52f592b6fd8a989f4a6ab1a7d7c2e Mon Sep 17 00:00:00 2001 From: David Hampton Date: Tue, 26 Dec 2006 00:07:58 +0000 Subject: [PATCH] Save and restore the visibility of the toolbar, statusbar, and summarybar. Fixes #106259. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15258 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-main-window.c | 63 ++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c index 8f9cb66e34..34dfd78569 100644 --- a/src/gnome-utils/gnc-main-window.c +++ b/src/gnome-utils/gnc-main-window.c @@ -403,6 +403,9 @@ static const gchar *multiple_page_actions[] = { #define WINDOW_GEOMETRY "Window Geometry" #define WINDOW_POSITION "Window Position" #define WINDOW_MAXIMIZED "Window Maximized" +#define TOOLBAR_VISIBLE "Toolbar Visible" +#define STATUSBAR_VISIBLE "Statusbar Visible" +#define SUMMARYBAR_VISIBLE "Summarybar Visible" #define WINDOW_FIRSTPAGE "First Page" #define WINDOW_PAGECOUNT "Page Count" #define WINDOW_PAGEORDER "Page Order" @@ -511,9 +514,10 @@ static void gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; + GtkAction *action; gint *pos, *geom, *order; gsize length; - gboolean max; + gboolean max, visible, desired_visibility; gchar *window_group; gint page_start, page_count, i; GError *error = NULL; @@ -612,6 +616,46 @@ gnc_main_window_restore_window (GncMainWindow *window, GncMainWindowSaveData *da gtk_window_maximize(GTK_WINDOW(window)); } + /* Common view menu items */ + action = gnc_main_window_find_action(window, "ViewToolbarAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean(data->key_file, window_group, + TOOLBAR_VISIBLE, &error); + if (error) { + g_warning("error reading group %s key %s: %s", + window_group, TOOLBAR_VISIBLE, error->message); + g_error_free(error); + error = NULL; + } else if (visible != desired_visibility) { + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),desired_visibility); + } + + action = gnc_main_window_find_action(window, "ViewSummaryAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean(data->key_file, window_group, + SUMMARYBAR_VISIBLE, &error); + if (error) { + g_warning("error reading group %s key %s: %s", + window_group, TOOLBAR_VISIBLE, error->message); + g_error_free(error); + error = NULL; + } else if (visible != desired_visibility) { + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),desired_visibility); + } + + action = gnc_main_window_find_action(window, "ViewStatusbarAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + desired_visibility = g_key_file_get_boolean(data->key_file, window_group, + STATUSBAR_VISIBLE, &error); + if (error) { + g_warning("error reading group %s key %s: %s", + window_group, TOOLBAR_VISIBLE, error->message); + g_error_free(error); + error = NULL; + } else if (visible != desired_visibility) { + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action),desired_visibility); + } + /* Now populate the window with pages. */ for (i = 0; i < page_count; i++) { data->page_offset = page_start; @@ -752,8 +796,9 @@ static void gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) { GncMainWindowPrivate *priv; + GtkAction *action; gint i, num_pages, coords[4], *order; - gboolean maximized; + gboolean maximized, visible; gchar *window_group; /* Setup */ @@ -802,6 +847,20 @@ gnc_main_window_save_window (GncMainWindow *window, GncMainWindowSaveData *data) coords[2], coords[3], maximized ? "maximized" : "not maximized"); + /* Common view menu items */ + action = gnc_main_window_find_action(window, "ViewToolbarAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + g_key_file_set_boolean(data->key_file, window_group, + TOOLBAR_VISIBLE, visible); + action = gnc_main_window_find_action(window, "ViewSummaryAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + g_key_file_set_boolean(data->key_file, window_group, + SUMMARYBAR_VISIBLE, visible); + action = gnc_main_window_find_action(window, "ViewStatusbarAction"); + visible = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)); + g_key_file_set_boolean(data->key_file, window_group, + STATUSBAR_VISIBLE, visible); + /* Save individual pages in this window */ g_list_foreach(priv->installed_pages, (GFunc)gnc_main_window_save_page, data);