mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'Bug796965' of https://github.com/Bob-IT/gnucash into maint
This commit is contained in:
commit
aab9bb59cd
@ -2286,6 +2286,7 @@ account_filter_dialog_create(AccountFilterDialog *fd, GncPluginPage *page)
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
// page state section
|
||||
#define ACCT_COUNT "NumberOfOpenAccounts"
|
||||
#define ACCT_OPEN "OpenAccount%d"
|
||||
#define ACCT_SELECTED "SelectedAccount"
|
||||
@ -2294,6 +2295,14 @@ account_filter_dialog_create(AccountFilterDialog *fd, GncPluginPage *page)
|
||||
#define SHOW_UNUSED "ShowUnused"
|
||||
#define ACCT_TYPES "AccountTypes"
|
||||
|
||||
// account/budget state section
|
||||
// versions less than 3.2 would crash if key did not have an "_"
|
||||
#define SHOW_HIDDEN_ACCOUNTS "Show_Hidden"
|
||||
#define SHOW_ZERO_TOTALS "Show_ZeroTotal"
|
||||
#define SHOW_UNUSED_ACCOUNTS "Show_Unused"
|
||||
#define ACCOUNT_TYPES "Account_Types"
|
||||
|
||||
|
||||
typedef struct foo
|
||||
{
|
||||
GKeyFile *key_file;
|
||||
@ -2402,6 +2411,33 @@ gnc_tree_view_account_save(GncTreeViewAccount *view,
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gnc_tree_view_account_save_filter (GncTreeViewAccount *view,
|
||||
AccountFilterDialog *fd,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name)
|
||||
{
|
||||
g_return_if_fail (key_file != NULL);
|
||||
g_return_if_fail (group_name != NULL);
|
||||
|
||||
ENTER("view %p, key_file %p, group_name %s", view, key_file,
|
||||
group_name);
|
||||
|
||||
g_key_file_set_integer (key_file, group_name, ACCOUNT_TYPES,
|
||||
fd->visible_types);
|
||||
g_key_file_set_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS,
|
||||
fd->show_hidden);
|
||||
g_key_file_set_boolean (key_file, group_name, SHOW_ZERO_TOTALS,
|
||||
fd->show_zero_total);
|
||||
g_key_file_set_boolean (key_file, group_name, SHOW_UNUSED_ACCOUNTS,
|
||||
fd->show_unused);
|
||||
|
||||
g_key_file_set_comment (key_file, group_name, ACCOUNT_TYPES,
|
||||
"Account Filter Section below, four lines", NULL);
|
||||
|
||||
LEAVE("");
|
||||
}
|
||||
|
||||
/** Expand a row in the tree that was expanded when the user last quit
|
||||
* gnucash. Its job is to map from account name to tree row and
|
||||
* expand the row.
|
||||
@ -2542,6 +2578,59 @@ gnc_tree_view_account_restore(GncTreeViewAccount *view,
|
||||
gnc_tree_view_account_refilter(view);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
|
||||
AccountFilterDialog *fd,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gint i;
|
||||
gboolean show;
|
||||
|
||||
g_return_if_fail (key_file != NULL);
|
||||
g_return_if_fail (group_name != NULL);
|
||||
|
||||
/* if entry not found, filter will use the default setting */
|
||||
|
||||
/* Filter information. Ignore missing keys. */
|
||||
show = g_key_file_get_boolean (key_file, group_name, SHOW_HIDDEN_ACCOUNTS, &error);
|
||||
if (error)
|
||||
{
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
}
|
||||
else
|
||||
fd->show_hidden = show;
|
||||
|
||||
show = g_key_file_get_boolean(key_file, group_name, SHOW_ZERO_TOTALS, &error);
|
||||
if (error)
|
||||
{
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
}
|
||||
else
|
||||
fd->show_zero_total = show;
|
||||
|
||||
show = g_key_file_get_boolean(key_file, group_name, SHOW_UNUSED_ACCOUNTS, &error);
|
||||
if (error)
|
||||
{
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
}
|
||||
else
|
||||
fd->show_unused = show;
|
||||
|
||||
i = g_key_file_get_integer(key_file, group_name, ACCOUNT_TYPES, &error);
|
||||
if (error)
|
||||
{
|
||||
g_error_free (error);
|
||||
error = NULL;
|
||||
}
|
||||
else
|
||||
fd->visible_types = i;
|
||||
}
|
||||
|
||||
// @@fixme -- factor this app-not-gui-specific-logic out.
|
||||
void
|
||||
gnc_tree_view_account_name_edited_cb(Account *account, GtkTreeViewColumn *col, const gchar *new_name)
|
||||
|
@ -118,6 +118,15 @@ void gnc_tree_view_account_restore(GncTreeViewAccount *view,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name);
|
||||
|
||||
void gnc_tree_view_account_save_filter (GncTreeViewAccount *tree_view,
|
||||
AccountFilterDialog *fd,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name);
|
||||
void gnc_tree_view_account_restore_filter (GncTreeViewAccount *view,
|
||||
AccountFilterDialog *fd,
|
||||
GKeyFile *key_file,
|
||||
const gchar *group_name);
|
||||
|
||||
|
||||
/* Get the GType for an GncTreeViewAccount object. */
|
||||
GType gnc_tree_view_account_get_type (void);
|
||||
|
@ -496,6 +496,10 @@ gbv_create_widget(GncBudgetView *view)
|
||||
g_signal_connect(G_OBJECT(tree_view), "size-allocate",
|
||||
G_CALLBACK(gbv_treeview_resized_cb), view);
|
||||
|
||||
// Read account filter state information from budget section
|
||||
gnc_tree_view_account_restore_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), priv->fd,
|
||||
gnc_state_get_current(), gnc_tree_view_get_state_section (GNC_TREE_VIEW(priv->tree_view)));
|
||||
|
||||
gnc_budget_view_refresh(view);
|
||||
}
|
||||
|
||||
@ -526,7 +530,7 @@ gnc_budget_view_save(GncBudgetView *view, GKeyFile *key_file, const gchar *group
|
||||
|
||||
priv = GNC_BUDGET_VIEW_GET_PRIVATE(view);
|
||||
|
||||
//FIXME
|
||||
// Save the account filter and page state information to page section
|
||||
gnc_tree_view_account_save(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
priv->fd, key_file, group_name);
|
||||
LEAVE(" ");
|
||||
@ -586,7 +590,7 @@ gnc_budget_view_restore(GncBudgetView* view, GKeyFile *key_file, const gchar *gr
|
||||
/* Create the new view */
|
||||
priv = GNC_BUDGET_VIEW_GET_PRIVATE(view);
|
||||
|
||||
//FIXME
|
||||
// Restore the account filter and page state information from page section
|
||||
gnc_tree_view_account_restore(GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
priv->fd, key_file, group_name);
|
||||
LEAVE(" ");
|
||||
@ -619,7 +623,28 @@ gnc_budget_view_delete_budget(GncBudgetView *view)
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Save the Account filter information for this budget *
|
||||
* *
|
||||
* @param view The view to which the budget is associated. *
|
||||
**********************************************************************/
|
||||
void
|
||||
gnc_budget_view_save_account_filter (GncBudgetView *view)
|
||||
{
|
||||
GncBudgetViewPrivate *priv;
|
||||
|
||||
g_return_if_fail(view != NULL);
|
||||
|
||||
ENTER("view %p", view);
|
||||
|
||||
priv = GNC_BUDGET_VIEW_GET_PRIVATE (view);
|
||||
|
||||
// Save account filter state information to budget section
|
||||
gnc_tree_view_account_save_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
|
||||
priv->fd, gnc_state_get_current(), gnc_tree_view_get_state_section (GNC_TREE_VIEW(priv->tree_view)));
|
||||
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/***********************************************************************
|
||||
|
@ -64,6 +64,7 @@ GncBudgetView *gnc_budget_view_new(GncBudget *budget, AccountFilterDialog* fd);
|
||||
void gnc_budget_view_save(GncBudgetView* view, GKeyFile *key_file, const gchar* group_name);
|
||||
void gnc_budget_view_refresh(GncBudgetView* view);
|
||||
void gnc_budget_view_delete_budget(GncBudgetView* view);
|
||||
void gnc_budget_view_save_account_filter(GncBudgetView *view);
|
||||
gboolean gnc_budget_view_restore(GncBudgetView* view, GKeyFile *key_file, const gchar* group_name);
|
||||
GtkTreeSelection* gnc_budget_view_get_selection(GncBudgetView* view);
|
||||
Account* gnc_budget_view_get_account_from_path(GncBudgetView* view, GtkTreePath* path);
|
||||
|
@ -759,6 +759,10 @@ gnc_plugin_page_account_tree_create_widget (GncPluginPage *plugin_page)
|
||||
gnc_plugin_page_account_tree_summarybar_position_changed,
|
||||
page);
|
||||
|
||||
// Read account filter state information from account section
|
||||
gnc_tree_view_account_restore_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), &priv->fd,
|
||||
gnc_state_get_current(), gnc_tree_view_get_state_section (GNC_TREE_VIEW(priv->tree_view)));
|
||||
|
||||
LEAVE("widget = %p", priv->widget);
|
||||
return priv->widget;
|
||||
}
|
||||
@ -782,6 +786,10 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page)
|
||||
gnc_plugin_page_account_tree_summarybar_position_changed,
|
||||
page);
|
||||
|
||||
// Save account filter state information to account section
|
||||
gnc_tree_view_account_save_filter (GNC_TREE_VIEW_ACCOUNT(priv->tree_view), &priv->fd,
|
||||
gnc_state_get_current(), gnc_tree_view_get_state_section (GNC_TREE_VIEW(priv->tree_view)));
|
||||
|
||||
// Destroy the filter override hash table
|
||||
g_hash_table_destroy(priv->fd.filter_override);
|
||||
|
||||
|
@ -334,6 +334,7 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page)
|
||||
/* Visible types */
|
||||
priv->fd.visible_types = -1; /* Start with all types */
|
||||
priv->fd.show_hidden = FALSE;
|
||||
priv->fd.show_unused = TRUE;
|
||||
priv->fd.show_zero_total = TRUE;
|
||||
priv->fd.filter_override = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
@ -479,6 +480,9 @@ gnc_plugin_page_budget_destroy_widget (GncPluginPage *plugin_page)
|
||||
|
||||
if (priv->budget_view)
|
||||
{
|
||||
// save the account filter state information to budget section
|
||||
gnc_budget_view_save_account_filter (priv->budget_view);
|
||||
|
||||
if (priv->delete_budget)
|
||||
{
|
||||
gnc_budget_view_delete_budget (priv->budget_view);
|
||||
@ -537,7 +541,7 @@ gnc_plugin_page_budget_save_page (GncPluginPage *plugin_page,
|
||||
guid_to_string_buff(gnc_budget_get_guid(priv->budget), guid_str);
|
||||
g_key_file_set_string(key_file, group_name, BUDGET_GUID, guid_str);
|
||||
|
||||
//FIXME
|
||||
// Save the Budget page information to state file
|
||||
gnc_budget_view_save(priv->budget_view, key_file, group_name);
|
||||
|
||||
LEAVE(" ");
|
||||
|
Loading…
Reference in New Issue
Block a user