Skip to content

Commit

Permalink
Changes for budget plugin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-IT committed Oct 30, 2022
1 parent 5bcb73a commit 161dad7
Show file tree
Hide file tree
Showing 3 changed files with 345 additions and 0 deletions.
56 changes: 56 additions & 0 deletions gnucash/gnome/gnc-plugin-page-budget.c
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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 */
/******************************/
Expand Down
1 change: 1 addition & 0 deletions gnucash/gnucash-gresources.xml
Expand Up @@ -19,6 +19,7 @@
<file>ui/gnc-plugin-report-system.ui</file>

<file>ui/gnc-plugin-page-account-tree.ui</file>
<file>ui/gnc-plugin-page-budget.ui</file>
<file>ui/gnc-plugin-page-register.ui</file>

<file>ui/gnc-plugin-ofx.ui</file>
Expand Down
288 changes: 288 additions & 0 deletions gnucash/ui/gnc-plugin-page-budget.ui
@@ -0,0 +1,288 @@
<?xml version="1.0"?>
<interface>

<menu id="EditPlaceholder1">
<item>
<attribute name="label" translatable="yes">Esti_mate Budget...</attribute>
<attribute name="action">GncPluginPageBudgetActions.EstimateBudgetAction</attribute>
<attribute name="tooltip" translatable="yes">Edit the selected account</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_All Periods...</attribute>
<attribute name="action">GncPluginPageBudgetActions.AllPeriodsBudgetAction</attribute>
<attribute name="tooltip" translatable="yes">Estimate a budget value for the selected accounts from past transactions</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Delete Budget...</attribute>
<attribute name="action">GncPluginPageBudgetActions.DeleteBudgetAction</attribute>
<attribute name="tooltip" translatable="yes">Select this or another budget and delete it</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Edit Note</attribute>
<attribute name="action">GncPluginPageBudgetActions.BudgetNoteAction</attribute>
<attribute name="tooltip" translatable="yes">Edit note for the selected account and period</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Budget Report</attribute>
<attribute name="action">GncPluginPageBudgetActions.BudgetReportAction</attribute>
<attribute name="tooltip" translatable="yes">Run the budget report</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="EditPlaceholder3">
<item>
<attribute name="label" translatable="yes">_Find...</attribute>
<attribute name="action">gnc-plugin-basic-commands-actions.EditFindTransactionsAction</attribute>
<attribute name="accel">&lt;Primary&gt;f</attribute>
<attribute name="tooltip" translatable="yes">Find transactions with a search</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="EditPlaceholder5">
<item>
<!-- Translators: remember to reuse this translation in dialog-account.glade -->
<attribute name="label" translatable="yes">Ta_x Report Options</attribute>
<attribute name="action">GncPluginPageBudgetActions.EditTaxOptionsAction</attribute>
<!-- Translators: currently implemented are, US: income tax and DE: VAT, So adjust this string -->
<attribute name="tooltip" translatable="yes">Setup relevant accounts for tax reports, e.g. US income tax</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="EditPlaceholder6">
<item>
<attribute name="label" translatable="yes">Budget _Options...</attribute>
<attribute name="action">GncPluginPageBudgetActions.OptionsBudgetAction</attribute>
<attribute name="tooltip" translatable="yes">Edit this budget's options</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="ViewPlaceholder1">
<item>
<attribute name="label" translatable="yes">_Filter By...</attribute>
<attribute name="action">GncPluginPageBudgetActions.ViewFilterByAction</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="ViewPlaceholder4">
<item>
<attribute name="label" translatable="yes">_Refresh</attribute>
<attribute name="action">GncPluginPageBudgetActions.ViewRefreshAction</attribute>
<attribute name="accel">&lt;Primary&gt;r</attribute>
<attribute name="tooltip" translatable="yes">Refresh this window</attribute>
<attribute name="temp" translatable="no">yes</attribute>
</item>
</menu>

<menu id="mainwin-popup">
<item>
<attribute name="label" translatable="no">_Test</attribute>
<attribute name="action">mainwin.TestAction</attribute>
</item>
</menu>


<object class="GtkToolbar" id="mainwin-toolbar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkToolButton" id="but1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Save</property>
<property name="action-name">gnc-plugin-basic-commands-actions.FileSaveAction</property>
<property name="tooltip-text" translatable="yes">Save the current file</property>
<property name="use-underline">True</property>
<property name="icon-name">document-save</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Close</property>
<property name="action-name">mainwin.FileCloseAction</property>
<property name="tooltip-text" translatable="yes">Close the currently active page</property>
<property name="use-underline">True</property>
<property name="icon-name">window-close</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but2a">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">New _Invoice...</property>
<property name="action-name">gnc-plugin-business-actions.ToolbarNewInvoiceAction</property>
<property name="tooltip-text" translatable="yes">Open the New Invoice dialog</property>
<property name="use-underline">True</property>
<property name="icon-name">gnc-invoice-new</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem" id="extra_separator">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but3">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Open _Account</property>
<property name="action-name">GncPluginPageBudgetActions.EditOpenAccountAction</property>
<property name="tooltip-text" translatable="yes">Open the selected account</property>
<property name="use-underline">True</property>
<property name="icon-name">gnc-account-open</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but4">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Budget _Options...</property>
<property name="action-name">GncPluginPageBudgetActions.OptionsBudgetAction</property>
<property name="tooltip-text" translatable="yes">Edit this budget's options</property>
<property name="use-underline">True</property>
<property name="icon-name">document-properties</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkSeparatorToolItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but5">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Esti_mate Budget...</property>
<property name="action-name">GncPluginPageBudgetActions.EstimateBudgetAction</property>
<property name="tooltip-text" translatable="yes">Estimate a budget value for the selected accounts from past transactions</property>
<property name="use-underline">True</property>
<property name="icon-name">system-run</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but6">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_All Periods...</property>
<property name="action-name">GncPluginPageBudgetActions.AllPeriodsBudgetAction</property>
<property name="tooltip-text" translatable="yes">Edit budget for all periods for the selected accounts</property>
<property name="use-underline">True</property>
<property name="icon-name">system-run</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but7">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Delete Budget...</property>
<property name="action-name">GncPluginPageBudgetActions.DeleteBudgetAction</property>
<property name="tooltip-text" translatable="yes">Select this or another budget and delete it</property>
<property name="use-underline">True</property>
<property name="icon-name">gnc-account-delete</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but8">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Edit Note</property>
<property name="action-name">GncPluginPageBudgetActions.BudgetNoteAction</property>
<property name="tooltip-text" translatable="yes">Edit note for the selected account and period</property>
<property name="use-underline">True</property>
<property name="icon-name">text-x-generic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkToolButton" id="but9">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Budget Report</property>
<property name="action-name">GncPluginPageBudgetActions.BudgetReportAction</property>
<property name="tooltip-text" translatable="yes">Run the budget report</property>
<property name="use-underline">True</property>
<property name="icon-name">system-run</property>
</object>
<packing>
<property name="expand">False</property>
<property name="homogeneous">True</property>
</packing>
</child>
</object>

</interface>

0 comments on commit 161dad7

Please sign in to comment.