Skip to content

Commit

Permalink
Budgets are sensitive to readonly status
Browse files Browse the repository at this point in the history
Disable some budget features if book is readonly
  • Loading branch information
christopherlam committed Jan 11, 2022
1 parent 47f2e82 commit f96585b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gnucash/gnome/gnc-budget-view.c
Expand Up @@ -1265,6 +1265,9 @@ budget_col_edited (Account *account, GtkTreeViewColumn *col,
guint period_num;
gnc_numeric numeric = gnc_numeric_error (GNC_ERROR_ARG);

if (qof_book_is_readonly (gnc_get_current_book ()))
return;

if (!xaccParseAmount (new_text, TRUE, &numeric, NULL) &&
!(new_text && *new_text == '\0'))
return;
Expand Down
15 changes: 15 additions & 0 deletions gnucash/gnome/gnc-plugin-page-budget.c
Expand Up @@ -202,6 +202,17 @@ static GtkActionEntry gnc_plugin_page_budget_actions [] =

};

static const gchar *writeable_actions[] =
{
/* actions which must be disabled on a readonly book. */
"DeleteBudgetAction",
"OptionsBudgetAction",
"EstimateBudgetAction",
"AllPeriodsBudgetAction",
"BudgetNoteAction",
NULL
};

static guint gnc_plugin_page_budget_n_actions =
G_N_ELEMENTS(gnc_plugin_page_budget_actions);

Expand Down Expand Up @@ -366,6 +377,10 @@ gnc_plugin_page_budget_init (GncPluginPageBudget *plugin_page)
plugin_page);
gnc_plugin_init_short_names (action_group, toolbar_labels);

if (qof_book_is_readonly (gnc_get_current_book()))
gnc_plugin_update_actions (action_group, writeable_actions,
"sensitive", FALSE);

/* Visible types */
priv->fd.visible_types = -1; /* Start with all types */
priv->fd.show_hidden = FALSE;
Expand Down

0 comments on commit f96585b

Please sign in to comment.