From 161dad7a4c4d000b27621ffaf6bd13c84a3e82f7 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Fri, 28 Oct 2022 16:26:24 +0100 Subject: [PATCH] Changes for budget plugin pages --- gnucash/gnome/gnc-plugin-page-budget.c | 56 +++++ gnucash/gnucash-gresources.xml | 1 + gnucash/ui/gnc-plugin-page-budget.ui | 288 +++++++++++++++++++++++++ 3 files changed, 345 insertions(+) create mode 100644 gnucash/ui/gnc-plugin-page-budget.ui diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c index 054493574b8..afbfd4c8e3b 100644 --- a/gnucash/gnome/gnc-plugin-page-budget.c +++ b/gnucash/gnome/gnc-plugin-page-budget.c @@ -120,6 +120,7 @@ static void gnc_plugin_page_budget_cmd_allperiods_budget (GSimpleAction *simple, static void gnc_plugin_page_budget_cmd_refresh (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_budget_cmd_budget_note (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void gnc_plugin_page_budget_cmd_budget_report (GSimpleAction *simple, GVariant *parameter, gpointer user_data); +static void gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data); static void allperiods_budget_helper (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); @@ -137,6 +138,7 @@ static GActionEntry gnc_plugin_page_budget_actions [] = { "BudgetReportAction", gnc_plugin_page_budget_cmd_budget_report, NULL, NULL, NULL }, { "ViewFilterByAction", gnc_plugin_page_budget_cmd_view_filter_by, NULL, NULL, NULL }, { "ViewRefreshAction", gnc_plugin_page_budget_cmd_refresh, NULL, NULL, NULL }, + { "EditTaxOptionsAction", gnc_plugin_page_budget_cmd_edit_tax_options, NULL, NULL, NULL }, }; static guint gnc_plugin_page_budget_n_actions = G_N_ELEMENTS(gnc_plugin_page_budget_actions); @@ -193,6 +195,18 @@ static GncDisplayItem gnc_plugin_page_budget_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_budget_n_display_items = G_N_ELEMENTS(gnc_plugin_page_budget_display_items); +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder3", + "EditPlaceholder5", + "EditPlaceholder6", + "ViewPlaceholder1", + "ViewPlaceholder4", + NULL, +}; + static const gchar *writeable_actions[] = { /* actions which must be disabled on a readonly book. */ @@ -419,6 +433,16 @@ gnc_plugin_page_budget_focus_widget (GncPluginPage *budget_plugin_page) GncBudgetView *budget_view = priv->budget_view; GtkWidget *account_view = gnc_budget_view_get_account_tree_view (budget_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "TransactionAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + /* Disable the Schedule menu */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(budget_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(budget_plugin_page->window), budget_plugin_page, + gnc_plugin_load_ui_items); + if (!gtk_widget_is_focus (GTK_WIDGET(account_view))) gtk_widget_grab_focus (GTK_WIDGET(account_view)); } @@ -811,6 +835,38 @@ gnc_plugin_page_budget_cmd_delete_budget (GSimpleAction *simple, } +static void +gnc_plugin_page_budget_cmd_edit_tax_options (GSimpleAction *simple, + GVariant *parameter, + gpointer user_data) +{ + GncPluginPageBudget *page = user_data; + GncPluginPageBudgetPrivate *priv; + GtkTreeSelection *selection; + Account *account = NULL; + GtkWidget *window; + + page = GNC_PLUGIN_PAGE_BUDGET(page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_BUDGET(page)); + + ENTER ("(action %p, page %p)", simple, page); + priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page); + + selection = gnc_budget_view_get_selection (priv->budget_view); + window = GNC_PLUGIN_PAGE(page)->window; + + if (gtk_tree_selection_count_selected_rows (selection) == 1) + { + GList *acc_list = gnc_budget_view_get_selected_accounts (priv->budget_view); + GList *node = g_list_first (acc_list); + account = acc_list->data; + g_list_free (acc_list); + } + gnc_tax_info_dialog (window, account); + LEAVE (" "); +} + /******************************/ /* Options Dialog */ /******************************/ diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 224de420b99..e3320694d3f 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -19,6 +19,7 @@ ui/gnc-plugin-report-system.ui ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-page-budget.ui ui/gnc-plugin-page-register.ui ui/gnc-plugin-ofx.ui diff --git a/gnucash/ui/gnc-plugin-page-budget.ui b/gnucash/ui/gnc-plugin-page-budget.ui new file mode 100644 index 00000000000..a187e2f2d6f --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-budget.ui @@ -0,0 +1,288 @@ + + + + + + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Edit the selected account + yes + + + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Estimate a budget value for the selected accounts from past transactions + yes + + + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + yes + + + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + yes + + + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageBudgetActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + yes + + + + + + _Filter By... + GncPluginPageBudgetActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageBudgetActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + _Test + mainwin.TestAction + + + + + + True + False + + + True + False + _Save + gnc-plugin-basic-commands-actions.FileSaveAction + Save the current file + True + document-save + + + False + True + + + + + True + False + _Close + mainwin.FileCloseAction + Close the currently active page + True + window-close + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Invoice... + gnc-plugin-business-actions.ToolbarNewInvoiceAction + Open the New Invoice dialog + True + gnc-invoice-new + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Open _Account + GncPluginPageBudgetActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Budget _Options... + GncPluginPageBudgetActions.OptionsBudgetAction + Edit this budget's options + True + document-properties + + + False + True + + + + + True + False + + + False + True + + + + + True + False + Esti_mate Budget... + GncPluginPageBudgetActions.EstimateBudgetAction + Estimate a budget value for the selected accounts from past transactions + True + system-run + + + False + True + + + + + True + False + _All Periods... + GncPluginPageBudgetActions.AllPeriodsBudgetAction + Edit budget for all periods for the selected accounts + True + system-run + + + False + True + + + + + True + False + _Delete Budget... + GncPluginPageBudgetActions.DeleteBudgetAction + Select this or another budget and delete it + True + gnc-account-delete + + + False + True + + + + + True + False + Edit Note + GncPluginPageBudgetActions.BudgetNoteAction + Edit note for the selected account and period + True + text-x-generic + + + False + True + + + + + True + False + Budget Report + GncPluginPageBudgetActions.BudgetReportAction + Run the budget report + True + system-run + + + False + True + + + + +