36 #include <glib/gi18n.h> 41 #include "gnc-component-manager.h" 43 #include "dialog-doclink.h" 46 #include "dialog-fincalc.h" 47 #include "dialog-find-transactions.h" 48 #include "dialog-imap-editor.h" 49 #include "dialog-sx-since-last-run.h" 50 #include "dialog-totd.h" 51 #include "assistant-acct-period.h" 52 #include "assistant-loan.h" 55 #include "gnc-gui-query.h" 59 #include "gnc-session.h" 60 #include "gnc-plugin-page-sx-list.h" 64 G_GNUC_UNUSED
static QofLogModule log_module = GNC_MOD_GUI;
66 static void gnc_plugin_basic_commands_finalize (GObject *
object);
68 static void gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin, GncMainWindow *window, GQuark type);
69 static void gnc_plugin_basic_commands_main_window_page_changed(GncMainWindow *window,
GncPluginPage *page, gpointer user_data);
72 static void gnc_main_window_cmd_file_new (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
73 static void gnc_main_window_cmd_file_open (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
74 static void gnc_main_window_cmd_file_save (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
75 static void gnc_main_window_cmd_file_save_as (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
76 static void gnc_main_window_cmd_file_revert (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
77 static void gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
78 static void gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
79 static void gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
80 static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
81 static void gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
83 #if CLOSE_BOOKS_ACTUALLY_WORKS 84 static void gnc_main_window_cmd_actions_close_books (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
87 static void gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
88 static void gnc_main_window_cmd_tools_close_book (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
89 static void gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
90 static void gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
91 static void gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
92 static void gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
93 static void gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
94 static void gnc_main_window_cmd_help_totd (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
98 #define PLUGIN_ACTIONS_NAME "gnc-plugin-basic-commands-actions" 99 #define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands.ui" 103 static GActionEntry gnc_plugin_actions [] =
105 {
"FileNewAction", gnc_main_window_cmd_file_new, NULL, NULL, NULL },
106 {
"FileOpenAction", gnc_main_window_cmd_file_open, NULL, NULL, NULL },
107 {
"FileSaveAction", gnc_main_window_cmd_file_save, NULL, NULL, NULL },
108 {
"FileSaveAsAction", gnc_main_window_cmd_file_save_as, NULL, NULL, NULL },
109 {
"FileRevertAction", gnc_main_window_cmd_file_revert, NULL, NULL, NULL },
110 {
"FileExportAccountsAction", gnc_main_window_cmd_file_export_accounts, NULL, NULL, NULL },
111 {
"EditFindTransactionsAction", gnc_main_window_cmd_tools_find_transactions, NULL, NULL, NULL },
112 {
"EditTaxOptionsAction", gnc_main_window_cmd_edit_tax_options, NULL, NULL, NULL },
113 {
"ActionsScheduledTransactionsAction", NULL, NULL, NULL, NULL },
114 {
"ActionsScheduledTransactionEditorAction", gnc_main_window_cmd_actions_scheduled_transaction_editor, NULL, NULL, NULL },
115 {
"ActionsSinceLastRunAction", gnc_main_window_cmd_actions_since_last_run, NULL, NULL, NULL },
116 {
"ActionsMortgageLoanAction", gnc_main_window_cmd_actions_mortgage_loan, NULL, NULL, NULL },
117 {
"ActionsBudgetAction", NULL, NULL, NULL, NULL },
118 #ifdef CLOSE_BOOKS_ACTUALLY_WORKS 119 {
"ActionsCloseBooksAction", gnc_main_window_cmd_actions_close_books, NULL, NULL, NULL },
120 #endif // CLOSE_BOOKS_ACTUALLY_WORKS 121 {
"ToolsPriceEditorAction", gnc_main_window_cmd_tools_price_editor, NULL, NULL, NULL },
122 {
"ToolsCommodityEditorAction", gnc_main_window_cmd_tools_commodity_editor, NULL, NULL, NULL },
123 {
"ToolsFinancialCalculatorAction", gnc_main_window_cmd_tools_financial_calculator, NULL, NULL, NULL },
124 {
"ToolsBookCloseAction", gnc_main_window_cmd_tools_close_book, NULL, NULL, NULL },
125 {
"ToolsImapEditorAction", gnc_main_window_cmd_tools_imap_editor, NULL, NULL, NULL },
126 {
"ToolsTransLinkedDocsAction", gnc_main_window_cmd_tools_trans_doclink, NULL, NULL, NULL },
127 {
"HelpTipsOfTheDayAction", gnc_main_window_cmd_help_totd, NULL, NULL, NULL },
130 static guint gnc_plugin_n_actions = G_N_ELEMENTS(gnc_plugin_actions);
133 static const gchar *gnc_plugin_load_ui_items [] =
141 "ActionsPlaceholder2",
149 static const gchar *gnc_plugin_initially_insensitive_actions[] =
159 static const gchar *readwrite_only_active_actions[] =
161 "ToolsBookCloseAction",
171 static const gchar *dirty_only_active_actions[] =
189 GncPluginBasicCommands *plugin;
195 plugin = g_object_new (GNC_TYPE_PLUGIN_BASIC_COMMANDS, NULL);
197 return GNC_PLUGIN (plugin);
215 gnc_plugin_basic_commands_add_to_window (GncPlugin *plugin,
216 GncMainWindow *window,
219 GSimpleActionGroup *simple_action_group =
223 gnc_plugin_initially_insensitive_actions,
226 g_signal_connect (window,
"page_changed",
227 G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed),
233 static void update_inactive_actions (
GncPluginPage *plugin_page)
235 GncMainWindow *window;
236 GSimpleActionGroup *simple_action_group;
243 if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
246 window = GNC_MAIN_WINDOW(plugin_page->
window);
247 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
249 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
259 gnc_plugin_basic_commands_main_window_page_changed (GncMainWindow *window,
267 update_inactive_actions (plugin_page);
271 G_DEFINE_TYPE(GncPluginBasicCommands, gnc_plugin_basic_commands, GNC_TYPE_PLUGIN)
281 gnc_plugin_basic_commands_class_init (GncPluginBasicCommandsClass *klass)
283 GObjectClass *object_class = G_OBJECT_CLASS (klass);
284 GncPluginClass *plugin_class = GNC_PLUGIN_CLASS (klass);
286 object_class->finalize = gnc_plugin_basic_commands_finalize;
289 plugin_class->plugin_name = GNC_PLUGIN_BASIC_COMMANDS_NAME;
292 plugin_class->add_to_window = gnc_plugin_basic_commands_add_to_window;
296 plugin_class->actions = gnc_plugin_actions;
297 plugin_class->n_actions = gnc_plugin_n_actions;
299 plugin_class->ui_updates = gnc_plugin_load_ui_items;
309 gnc_plugin_basic_commands_init (GncPluginBasicCommands *plugin)
323 gnc_plugin_basic_commands_finalize (GObject *
object)
325 g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS(
object));
327 G_OBJECT_CLASS(gnc_plugin_basic_commands_parent_class)->finalize (
object);
335 gnc_main_window_cmd_file_new (GSimpleAction *simple,
344 gnc_file_new (GTK_WINDOW(data->window));
348 gnc_main_window_cmd_file_open (GSimpleAction *simple,
354 g_return_if_fail (data != NULL);
363 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
364 #ifdef HAVE_DBI_DBI_H 365 gnc_ui_file_access_for_open (GTK_WINDOW(data->window));
367 gnc_file_open (GTK_WINDOW(data->window));
369 gnc_window_set_progressbar_window (NULL);
373 gnc_main_window_cmd_file_save (GSimpleAction *simple,
379 g_return_if_fail (data != NULL);
382 gnc_file_save_in_progress())
385 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
386 gnc_file_save (GTK_WINDOW(data->window));
387 gnc_window_set_progressbar_window (NULL);
391 gnc_main_window_cmd_file_save_as (GSimpleAction *simple,
397 g_return_if_fail (data != NULL);
400 gnc_file_save_in_progress())
403 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
404 #ifdef HAVE_DBI_DBI_H 405 gnc_ui_file_access_for_save_as (GTK_WINDOW(data->window));
407 gnc_file_save_as (GTK_WINDOW(data->window));
409 gnc_window_set_progressbar_window (NULL);
413 gnc_main_window_cmd_file_revert (GSimpleAction *simple,
419 g_return_if_fail (data != NULL);
424 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
425 gnc_file_revert (GTK_WINDOW(data->window));
426 gnc_window_set_progressbar_window (NULL);
430 gnc_main_window_cmd_file_export_accounts (GSimpleAction *simple,
436 g_return_if_fail (data != NULL);
438 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
439 #ifdef HAVE_DBI_DBI_H 440 gnc_ui_file_access_for_export (GTK_WINDOW(data->window));
442 gnc_file_export (GTK_WINDOW(data->window));
444 gnc_window_set_progressbar_window (NULL);
448 gnc_main_window_cmd_edit_tax_options (GSimpleAction *simple,
454 g_return_if_fail (data != NULL);
456 gnc_tax_info_dialog (GTK_WIDGET(data->window), NULL);
460 gnc_main_window_cmd_actions_scheduled_transaction_editor (GSimpleAction *simple,
469 gnc_main_window_cmd_actions_since_last_run (GSimpleAction *simple,
475 GncSxInstanceModel *sx_instances;
477 GList *auto_created_txns = NULL;
478 GList *creation_errors = NULL;
479 const char *nothing_to_do_msg =
480 _(
"There are no Scheduled Transactions to be entered at this time." );
482 g_return_if_fail (data != NULL);
484 window = GTK_WINDOW(data->window);
497 if (auto_created_txns)
498 gnc_gui_refresh_all();
502 gnc_ui_sx_since_last_run_dialog (window, sx_instances, auto_created_txns);
503 auto_created_txns = NULL;
509 gnc_info_dialog (window,
"%s", nothing_to_do_msg);
513 gnc_info_dialog (window, ngettext
516 (
"There are no Scheduled Transactions to be entered at this time. " 517 "(%d transaction automatically created)",
518 "There are no Scheduled Transactions to be entered at this time. " 519 "(%d transactions automatically created)",
524 g_list_free (auto_created_txns);
525 g_object_unref (G_OBJECT(sx_instances));
528 gnc_ui_sx_creation_error_dialog (&creation_errors);
532 gnc_main_window_cmd_actions_mortgage_loan (GSimpleAction *simple,
536 gnc_ui_sx_loan_assistant_create ();
538 #ifdef CLOSE_BOOKS_ACTUALLY_WORKS 540 gnc_main_window_cmd_actions_close_books (GSimpleAction *simple,
545 gnc_acct_period_dialog ();
550 gnc_main_window_cmd_tools_imap_editor (GSimpleAction *simple,
555 gnc_set_busy_cursor (NULL, TRUE);
556 gnc_imap_dialog (GTK_WIDGET(data->window));
557 gnc_unset_busy_cursor (NULL);
561 gnc_main_window_cmd_tools_trans_doclink (GSimpleAction *simple,
566 gnc_set_busy_cursor (NULL, TRUE);
567 gnc_doclink_trans_dialog (GTK_WINDOW(data->window));
568 gnc_unset_busy_cursor (NULL);
572 gnc_main_window_cmd_tools_price_editor (GSimpleAction *simple,
577 gnc_set_busy_cursor (NULL, TRUE);
578 gnc_prices_dialog (GTK_WIDGET(data->window));
579 gnc_unset_busy_cursor (NULL);
583 gnc_main_window_cmd_tools_commodity_editor (GSimpleAction *simple,
588 gnc_set_busy_cursor (NULL, TRUE);
589 gnc_commodities_dialog (GTK_WIDGET(data->window));
590 gnc_unset_busy_cursor (NULL);
594 gnc_main_window_cmd_tools_financial_calculator (GSimpleAction *simple,
599 gnc_ui_fincalc_dialog_create (GTK_WINDOW(data->window));
603 gnc_main_window_cmd_tools_close_book (GSimpleAction *simple,
612 gnc_main_window_cmd_tools_find_transactions (GSimpleAction *simple,
618 gnc_ui_find_transactions_dialog_create (GTK_WINDOW(data->window), NULL);
622 gnc_main_window_cmd_help_totd (GSimpleAction *simple,
628 g_return_if_fail (data != NULL);
630 gnc_totd_dialog (GTK_WINDOW(data->window), FALSE);
The instance data structure for a content plugin.
utility functions for the GnuCash UI
gint num_auto_create_no_notify_instances
The number of automatically-created instances that do no request notification.
This file contains the functions to present a GUI to select a book closing date and accounts into whi...
Functions that are supported by all types of windows.
The instance data structure for an basic commands menu plugin.
GtkWidget * window
The window that contains the display widget for this plugin.
void gnc_sx_instance_model_summarize(GncSxInstanceModel *model, GncSxSummary *summary)
void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, gboolean auto_create_only, GList **created_transaction_guids, GList **creation_errors)
Really ("effectively") create the transactions from the SX instances in the given model...
void gnc_ui_close_book(QofBook *book, GtkWindow *parent)
Create and run the dialog to close the book.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Functions for adding content to a window.
Functions providing the file history menu.
void gnc_account_reset_convert_bayes_to_flat(void)
Reset the flag that indicates the function imap_convert_bayes_to_flat has been run.
GncPlugin * gnc_plugin_basic_commands_new(void)
Create a new basic commands menu plugin.
gboolean qof_book_session_not_saved(const QofBook *book)
qof_book_not_saved() returns the value of the session_dirty flag, set when changes to any object in t...
All type declarations for the whole Gnucash engine.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
#define PLUGIN_ACTIONS_NAME
The label given to the main window for this plugin.
GncSxInstanceModel * gnc_sx_get_current_instances(void)
Shorthand for get_instances(now, FALSE);.
#define GNC_TYPE_PLUGIN_PAGE_SX_LIST
Functions providing a list of scheduled transactions as a plugin page.
GncPluginPage * gnc_plugin_page_sx_list_new(void)
This file contains the functions to present a GUI to select a file or a database connection.
GncPlugin gnc_plugin
The parent object for this widget.
GSimpleActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
Retrieve a specific set of user interface actions from a window.
gboolean gnc_main_window_all_finish_pending(void)
Tell all pages in all windows to finish any outstanding activities.
gboolean need_dialog
If the dialog needs to be displayed.
Functions providing a basic set of menu items.
#define PLUGIN_UI_FILENAME
The name of the UI description file for this plugin.