diff --git a/gnucash/gnome/gnc-plugin-page-account-tree.c b/gnucash/gnome/gnc-plugin-page-account-tree.c index 80b465fc7c..35fe19dbc8 100644 --- a/gnucash/gnome/gnc-plugin-page-account-tree.c +++ b/gnucash/gnome/gnc-plugin-page-account-tree.c @@ -47,6 +47,7 @@ #include "dialog-transfer.h" #include "dialog-utils.h" #include "assistant-hierarchy.h" +#include "assistant-stock-transaction.h" #include "gnc-account-sel.h" #include "gnc-component-manager.h" #include "gnc-engine.h" @@ -136,16 +137,14 @@ static GncPluginPage *gnc_plugin_page_account_tree_recreate_page (GtkWidget *win /* Callbacks */ static void gnc_plugin_page_account_tree_summarybar_position_changed(gpointer prefs, gchar* pref, gpointer user_data); -static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - GncPluginPage *page); -static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *col, - GncPluginPageAccountTree *page); +static gboolean gnc_plugin_page_account_tree_button_press_cb (GtkWidget *widget, GdkEventButton *event, GncPluginPage *page); +static void gnc_plugin_page_account_tree_double_click_cb (GtkTreeView *treeview, + GtkTreePath *path, + GtkTreeViewColumn *col, + GncPluginPageAccountTree *page); static void gnc_plugin_page_account_tree_selection_changed_cb (GtkTreeSelection *selection, - GncPluginPageAccountTree *page); + GncPluginPageAccountTree *page); void gppat_populate_trans_mas_list(GtkToggleButton *sa_mrb, GtkWidget *dialog); void gppat_set_insensitive_iff_rb_active(GtkWidget *widget, GtkToggleButton *b); @@ -165,6 +164,7 @@ static void gnc_plugin_page_account_tree_cmd_refresh (GSimpleAction *simple, GVa static void gnc_plugin_page_account_tree_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data); +static void gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data); static void gnc_plugin_page_account_tree_cmd_scrub (GSimpleAction *simple, GVariant *paramter, gpointer user_data); @@ -189,8 +189,8 @@ static GActionEntry gnc_plugin_page_account_tree_actions [] = { { "FileNewAccountAction", gnc_plugin_page_account_tree_cmd_new_account, NULL, NULL, NULL }, { "FileAddAccountHierarchyAssistantAction", gnc_plugin_page_account_tree_cmd_file_new_hierarchy, NULL, NULL, NULL }, - { "FileOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, - { "FileOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, + { "EditOpenAccountAction", gnc_plugin_page_account_tree_cmd_open_account, NULL, NULL, NULL }, + { "EditOpenSubaccountsAction", gnc_plugin_page_account_tree_cmd_open_subaccounts, NULL, NULL, NULL }, { "EditEditAccountAction", gnc_plugin_page_account_tree_cmd_edit_account, NULL, NULL, NULL }, { "EditDeleteAccountAction", gnc_plugin_page_account_tree_cmd_delete_account, NULL, NULL, NULL }, { "EditCascadeAccountAction", gnc_plugin_page_account_tree_cmd_cascade_account_properties, NULL, NULL, NULL }, @@ -204,6 +204,7 @@ static GActionEntry gnc_plugin_page_account_tree_actions [] = { "ActionsAutoClearAction", gnc_plugin_page_account_tree_cmd_autoclear, NULL, NULL, NULL }, { "ActionsTransferAction", gnc_plugin_page_account_tree_cmd_transfer, NULL, NULL, NULL }, { "ActionsStockSplitAction", gnc_plugin_page_account_tree_cmd_stock_split, NULL, NULL, NULL }, + { "ActionsStockAssistantAction", gnc_plugin_page_account_tree_cmd_stock_assistant, NULL, NULL, NULL }, { "ActionsLotsAction", gnc_plugin_page_account_tree_cmd_lots, NULL, NULL, NULL }, { "ScrubAction", gnc_plugin_page_account_tree_cmd_scrub, NULL, NULL, NULL }, { "ScrubSubAction", gnc_plugin_page_account_tree_cmd_scrub_sub, NULL, NULL, NULL }, @@ -224,11 +225,11 @@ static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = N_("Extend the current book by merging with new account type categories") }, { - "FileOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, + "EditOpenAccountAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _Account"), NULL, N_("Open the selected account") }, { - "FileOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, + "EditOpenSubaccountsAction", GNC_ICON_OPEN_ACCOUNT, N_("Open _SubAccounts"), NULL, N_("Open the selected account and all its subaccounts") }, /* Edit menu */ @@ -313,6 +314,25 @@ static GncDisplayItem gnc_plugin_page_account_tree_display_items [] = /** The number of display items provided by this plugin. */ static guint gnc_plugin_page_account_tree_n_display_items = G_N_ELEMENTS(gnc_plugin_page_account_tree_display_items); + +/** The default menu items that need to be add to the menu */ +static const gchar *gnc_plugin_load_ui_items [] = +{ + "EditPlaceholder1", + "EditPlaceholder2", + "EditPlaceholder3", + "EditPlaceholder5", + "ViewPlaceholder1", + "ViewPlaceholder4", + "ActionsPlaceholder4", + "ActionsPlaceholder5", + "ActionsPlaceholder6", + NULL, +}; + + + + /** Actions that require an account to be selected before they are * enabled, and the book is in read-write mode. */ static const gchar *actions_requiring_account_rw[] = @@ -337,12 +357,18 @@ static const gchar *actions_requiring_subaccounts_rw[] = * enabled. Those actions can be selected even if the book is in readonly mode. */ static const gchar *actions_requiring_account_always[] = { - "FileOpenAccountAction", - "FileOpenSubaccountsAction", + "EditOpenAccountAction", + "EditOpenSubaccountsAction", "ActionsLotsAction", NULL }; +static const gchar* actions_requiring_priced_account[] = +{ + "ActionsStockAssistantAction", + NULL +}; + /* This is the list of actions which are switched inactive in a read-only book. */ static const gchar* readonly_inactive_actions[] = { @@ -363,8 +389,8 @@ static const gchar* readonly_inactive_actions[] = /** Short labels for use on the toolbar buttons. */ static action_toolbar_labels toolbar_labels[] = { - { "FileOpenAccountAction", N_("Open") }, - { "EditEditAccountAction", N_("Edit") }, + { "FileOpenAccountAction", N_("Open") }, + { "EditEditAccountAction", N_("Edit") }, { "FileNewAccountAction", N_("New") }, { "EditDeleteAccountAction", N_("Delete") }, { NULL, NULL }, @@ -465,7 +491,7 @@ gnc_plugin_page_account_tree_class_init (GncPluginPageAccountTreeClass *klass) static void gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) { - GSimpleActionGroup *simple_action_group; + GSimpleActionGroup *simple_action_group = NULL; GncPluginPageAccountTreePrivate *priv; GncPluginPage *parent; const GList *page_list; @@ -475,24 +501,24 @@ gnc_plugin_page_account_tree_init (GncPluginPageAccountTree *plugin_page) /* Init parent declared variables */ parent = GNC_PLUGIN_PAGE(plugin_page); - g_object_set(G_OBJECT(plugin_page), - "page-name", _("Accounts"), - "page-uri", "default:", - "ui-description", "gnc-plugin-page-account-tree.ui", - NULL); + g_object_set (G_OBJECT(plugin_page), + "page-name", _("Accounts"), + "page-uri", "default:", + "ui-description", "gnc-plugin-page-account-tree.ui", + NULL); g_signal_connect (G_OBJECT (plugin_page), "selected", G_CALLBACK (gnc_plugin_page_account_tree_selected), plugin_page); /* change me when the system supports multiple books */ - gnc_plugin_page_add_book(parent, gnc_get_current_book()); + gnc_plugin_page_add_book (parent, gnc_get_current_book()); /* Is this the first accounts page? */ page_list = - gnc_gobject_tracking_get_list(GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); + gnc_gobject_tracking_get_list (GNC_PLUGIN_PAGE_ACCOUNT_TREE_NAME); if (!page_list || plugin_page == page_list->data) { - g_object_set_data(G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, - GINT_TO_POINTER(1)); + g_object_set_data (G_OBJECT(plugin_page), PLUGIN_PAGE_IMMUTABLE, + GINT_TO_POINTER(1)); } /* Create menu and toolbar information */ @@ -620,6 +646,20 @@ gnc_plugin_page_account_tree_focus_widget (GncPluginPage *account_plugin_page) GncPluginPageAccountTreePrivate *priv = GNC_PLUGIN_PAGE_ACCOUNT_TREE_GET_PRIVATE(account_plugin_page); GtkTreeView *view = GTK_TREE_VIEW(priv->tree_view); + /* Disable the Transaction Menu */ + GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_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(account_plugin_page->window), "ScheduledAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + + gnc_main_window_update_menu (GNC_MAIN_WINDOW(account_plugin_page->window), account_plugin_page, + gnc_plugin_load_ui_items); + + /* Disable the FilePrintAction */ + action = gnc_main_window_find_action (GNC_MAIN_WINDOW(account_plugin_page->window), "FilePrintAction"); + g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); + if (!gtk_widget_is_focus (GTK_WIDGET(view))) gtk_widget_grab_focus (GTK_WIDGET(view)); } @@ -658,7 +698,7 @@ gnc_plugin_page_account_editing_started_cd (gpointer various, GncPluginPageRegis { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + "EditDeleteAccountAction"); if (action != NULL) g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE); @@ -669,7 +709,7 @@ gnc_plugin_page_account_editing_finished_cb (gpointer various, GncPluginPageRegi { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE(page); GAction *action = gnc_main_window_find_action (GNC_MAIN_WINDOW(plugin_page->window), - "EditDeleteAccountAction"); + "EditDeleteAccountAction"); if (action != NULL) g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE); @@ -836,12 +876,13 @@ gnc_plugin_page_account_tree_destroy_widget (GncPluginPage *plugin_page) LEAVE("widget destroyed"); } -static void update_inactive_actions(GncPluginPage *plugin_page) +static void +update_inactive_actions (GncPluginPage *plugin_page) { GncPluginPageAccountTreePrivate *priv; - GSimpleActionGroup *simple_action_group; + GSimpleActionGroup *simple_action_group = NULL; Account *account = NULL; - gboolean allow_write = !qof_book_is_readonly(gnc_get_current_book()); + gboolean allow_write = !qof_book_is_readonly (gnc_get_current_book()); gboolean has_account = FALSE; gboolean subaccounts = FALSE; @@ -870,6 +911,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) "sensitive", has_account); gnc_plugin_update_actionsb (simple_action_group, actions_requiring_subaccounts_rw, "sensitive", allow_write && subaccounts); + gnc_plugin_update_actionsb (simple_action_group, actions_requiring_priced_account, + "sensitive", account && xaccAccountIsPriced (account)); g_signal_emit (plugin_page, plugin_page_signals[ACCOUNT_SELECTED], 0, account); } @@ -877,7 +920,8 @@ static void update_inactive_actions(GncPluginPage *plugin_page) * Called when this page is selected. * * Update the toolbar button sensitivity. */ -static void gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) +static void +gnc_plugin_page_account_tree_selected (GObject *object, gpointer user_data) { GncPluginPage *plugin_page = GNC_PLUGIN_PAGE (object); g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); @@ -1601,7 +1645,7 @@ gnc_plugin_page_account_tree_cmd_delete_account (GSimpleAction *simple, adopter_match (&adopt.subtrans, GTK_WINDOW (window))) break; } - filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); + filter = g_object_get_data (G_OBJECT (dialog), DELETE_DIALOG_FILTER); gtk_widget_destroy(dialog); g_list_free(filter); if (confirm_delete_account (simple, page, adopt.trans.new_account, @@ -1700,7 +1744,8 @@ confirm_delete_account (GSimpleAction *simple, GncPluginPageAccountTree *page, return response; } -void do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) +void +do_delete_account (Account* account, Account* saa, Account* sta, Account* ta) { GList *acct_list, *ptr; const GncGUID *guid; @@ -1877,6 +1922,25 @@ gnc_plugin_page_account_tree_cmd_stock_split (GSimpleAction *simple, gnc_stock_split_dialog (window, account); } +static void +gnc_plugin_page_account_tree_cmd_stock_assistant (GSimpleAction *simple, + GVariant *paramter, + gpointer user_data) +{ + GncPluginPageAccountTree *page = user_data; + Account *account; + GtkWidget *window; + + ENTER ("(action %p, page %p)", simple, page); + + g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page)); + account = gnc_plugin_page_account_tree_get_current_account (page); + window = GNC_PLUGIN_PAGE(page)->window; + gnc_stock_transaction_assistant (window, account); + + LEAVE (" "); +} + static void gnc_plugin_page_account_tree_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, diff --git a/gnucash/gnucash-gresources.xml b/gnucash/gnucash-gresources.xml index 283b60d557..9e4094b101 100644 --- a/gnucash/gnucash-gresources.xml +++ b/gnucash/gnucash-gresources.xml @@ -18,6 +18,8 @@ ui/gnc-plugin-register.ui ui/gnc-plugin-report-system.ui + ui/gnc-plugin-page-account-tree.ui + ui/gnc-plugin-ofx.ui ui/gnc-plugin-aqbanking.ui diff --git a/gnucash/ui/gnc-plugin-page-account-tree.ui b/gnucash/ui/gnc-plugin-page-account-tree.ui new file mode 100644 index 0000000000..b449ce79d8 --- /dev/null +++ b/gnucash/ui/gnc-plugin-page-account-tree.ui @@ -0,0 +1,434 @@ + + + + + + _Edit Account + GncPluginPageAccountTreeActions.EditEditAccountAction + <Primary>e + Edit the selected account + yes + + + _Delete Account + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete + Edit the selected account + yes + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountAction + <Primary>i + Find an account + yes + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + yes + + + _Renumber Subaccounts... + GncPluginPageAccountTreeActions.EditRenumberSubaccountsAction + Renumber the children of the selected account + yes + + + + + + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + yes + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + yes + + + + + + _Find... + gnc-plugin-basic-commands-actions.EditFindTransactionsAction + <Primary>f + Find transactions with a search + yes + + + + + + + Ta_x Report Options + GncPluginPageAccountTreeActions.EditTaxOptionsAction + + Setup relevant accounts for tax reports, e.g. US income tax + yes + + + + + + + + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + yes + + + + + + _Refresh + GncPluginPageAccountTreeActions.ViewRefreshAction + <Primary>r + Refresh this window + yes + + + + + + + + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + yes + + + New Account _Hierarchy... + GncPluginPageAccountTreeActions.FileAddAccountHierarchyAssistantAction + Extend the current book by merging with new account type categories + yes + + + + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + <Primary>t + Transfer funds from one account to another + yes + + + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + yes + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, so as to reach a certain cleared amount + yes + + + Stock Ass_istant + GncPluginPageAccountTreeActions.ActionsStockAssistantAction + Stock Assistant + yes + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + yes + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + yes + + + + + + _Check & Repair + mainwin.ScrubMenuAction + yes + + Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + yes + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + yes + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + yes + + + + + + + + +
+ + _Filter By... + GncPluginPageAccountTreeActions.ViewFilterByAction + Filter accounts + + + Re_name Page + mainwin.ActionsRenamePageAction + Rename this page + +
+
+ + Open _Account + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + + + Open _SubAccounts + GncPluginPageAccountTreeActions.EditOpenSubaccountsAction + Open the selected account and all its subaccounts + + + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + + + _Cascade Account Properties... + GncPluginPageAccountTreeActions.EditCascadeAccountAction + Cascade selected properties for account + + + F_ind Account + GncPluginPageAccountTreeActions.EditFindAccountPopupAction + Find an account + +
+
+ + _Reconcile... + GncPluginPageAccountTreeActions.ActionsReconcileAction + Reconcile the selected account + + + _Auto-clear... + GncPluginPageAccountTreeActions.ActionsAutoClearAction + Automatically clear individual transactions, given a cleared amount + + + _Transfer... + GncPluginPageAccountTreeActions.ActionsTransferAction + Transfer funds from one account to another + + + Stoc_k Split... + GncPluginPageAccountTreeActions.ActionsStockSplitAction + Record a stock split or a stock merger + + + View _Lots... + GncPluginPageAccountTreeActions.ActionsLotsAction + Bring up the lot viewer/editor window + +
+
+ + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + + + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + +
+
+ + _Check & Repair + GncPluginPageAccountTreeActions.ScrubMenuAction + + _Check & Repair A_ccount + GncPluginPageAccountTreeActions.ScrubAction + Check for and repair unbalanced transactions and orphan splits in this account + + + Check & Repair Su_baccounts + GncPluginPageAccountTreeActions.ScrubSubAction + Check for and repair unbalanced transactions and orphan splits in this account and its subaccounts + + + Check & Repair A_ll + GncPluginPageAccountTreeActions.ScrubAllAction + Check for and repair unbalanced transactions and orphan splits in all accounts + + +
+
+ + + + 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 + GncPluginPageAccountTreeActions.EditOpenAccountAction + Open the selected account + True + gnc-account-open + + + False + True + + + + + True + False + Edit _Account + GncPluginPageAccountTreeActions.EditEditAccountAction + Edit the selected account + True + gnc-account-edit + + + False + True + + + + + True + False + + + False + True + + + + + True + False + New _Account... + GncPluginPageAccountTreeActions.FileNewAccountAction + Create a new Account + True + gnc-account-new + + + False + True + + + + + True + False + _Delete Account... + GncPluginPageAccountTreeActions.EditDeleteAccountAction + Delete selected account + True + gnc-account-delete + + + False + True + + + + + + + + + + + + + +