36 #include <glib/gi18n.h>
44 #include "dialog-fincalc.h"
45 #include "dialog-find-transactions.h"
46 #include "dialog-find-transactions2.h"
47 #include "dialog-sx-since-last-run.h"
48 #include "dialog-totd.h"
49 #include "assistant-acct-period.h"
50 #include "assistant-loan.h"
53 #include "gnc-gui-query.h"
57 #include "gnc-session.h"
58 #include "gnc-plugin-page-sx-list.h"
62 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);
80 static void gnc_main_window_cmd_actions_scheduled_transaction_editor (GtkAction *action,
GncMainWindowActionData *data);
83 #if CLOSE_BOOKS_ACTUALLY_WORKS
96 #define PLUGIN_ACTIONS_NAME "gnc-plugin-basic-commands-actions"
97 #define PLUGIN_UI_FILENAME "gnc-plugin-basic-commands-ui.xml"
101 static GtkActionEntry gnc_plugin_actions [] =
107 "FileNewAction", GTK_STOCK_NEW, N_(
"New _File"),
"<control>n",
108 N_(
"Create a new file"),
109 G_CALLBACK (gnc_main_window_cmd_file_new)
112 "FileOpenAction", GTK_STOCK_OPEN, N_(
"_Open..."),
"<control>o",
113 N_(
"Open an existing GnuCash file"),
114 G_CALLBACK (gnc_main_window_cmd_file_open)
117 "FileSaveAction", GTK_STOCK_SAVE, N_(
"_Save"),
"<control>s",
118 N_(
"Save the current file"),
119 G_CALLBACK (gnc_main_window_cmd_file_save)
122 "FileSaveAsAction", GTK_STOCK_SAVE_AS, N_(
"Save _As..."),
"<shift><control>s",
123 N_(
"Save this file with a different name"),
124 G_CALLBACK (gnc_main_window_cmd_file_save_as)
127 "FileRevertAction", GTK_STOCK_REVERT_TO_SAVED, N_(
"Re_vert"), NULL,
128 N_(
"Reload the current database, reverting all unsaved changes"),
129 G_CALLBACK (gnc_main_window_cmd_file_revert)
132 "FileExportAccountsAction", GTK_STOCK_CONVERT,
133 N_(
"Export _Accounts"), NULL,
134 N_(
"Export the account hierarchy to a new GnuCash datafile"),
135 G_CALLBACK (gnc_main_window_cmd_file_export_accounts)
141 "EditFindTransactionsAction", GTK_STOCK_FIND, N_(
"_Find..."),
"<control>f",
142 N_(
"Find transactions with a search"),
143 G_CALLBACK (gnc_main_window_cmd_tools_find_transactions)
146 "EditTaxOptionsAction", NULL,
147 N_(
"Ta_x Report Options"), NULL,
152 N_(
"Setup relevant accounts for tax reports, e.g. US income tax"),
153 G_CALLBACK (gnc_main_window_cmd_edit_tax_options)
158 {
"ActionsScheduledTransactionsAction", NULL, N_(
"_Scheduled Transactions"), NULL, NULL, NULL },
160 "ActionsScheduledTransactionEditorAction", NULL, N_(
"_Scheduled Transaction Editor"), NULL,
161 N_(
"The list of Scheduled Transactions"),
162 G_CALLBACK (gnc_main_window_cmd_actions_scheduled_transaction_editor)
165 "ActionsSinceLastRunAction", NULL, N_(
"Since _Last Run..."), NULL,
166 N_(
"Create Scheduled Transactions since the last time run"),
167 G_CALLBACK (gnc_main_window_cmd_actions_since_last_run)
170 "ActionsMortgageLoanAction", NULL, N_(
"_Mortgage & Loan Repayment..."), NULL,
171 N_(
"Setup scheduled transactions for repayment of a loan"),
172 G_CALLBACK (gnc_main_window_cmd_actions_mortgage_loan)
174 {
"ActionsBudgetAction", NULL, N_(
"B_udget"), NULL, NULL, NULL },
175 #ifdef CLOSE_BOOKS_ACTUALLY_WORKS
177 "ActionsCloseBooksAction", NULL, N_(
"Close _Books"), NULL,
178 N_(
"Archive old data using accounting periods"),
179 G_CALLBACK (gnc_main_window_cmd_actions_close_books)
181 #endif // CLOSE_BOOKS_ACTUALLY_WORKS
186 "ToolsPriceEditorAction", NULL, N_(
"_Price Editor"), NULL,
187 N_(
"View and edit the prices for stocks and mutual funds"),
188 G_CALLBACK (gnc_main_window_cmd_tools_price_editor)
191 "ToolsCommodityEditorAction", NULL, N_(
"_Security Editor"), NULL,
192 N_(
"View and edit the commodities for stocks and mutual funds"),
193 G_CALLBACK (gnc_main_window_cmd_tools_commodity_editor)
196 "ToolsFinancialCalculatorAction", NULL, N_(
"_Loan Repayment Calculator"), NULL,
197 N_(
"Use the loan/mortgage repayment calculator"),
198 G_CALLBACK (gnc_main_window_cmd_tools_financial_calculator)
201 "ToolsBookCloseAction", NULL, N_(
"_Close Book"), NULL,
202 N_(
"Close the Book at the end of the Period"),
203 G_CALLBACK (gnc_main_window_cmd_tools_close_book)
209 "HelpTipsOfTheDayAction", NULL, N_(
"_Tips Of The Day"), NULL,
210 N_(
"View the Tips of the Day"),
211 G_CALLBACK (gnc_main_window_cmd_help_totd)
215 static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
221 static const gchar *gnc_plugin_important_actions[] =
231 static const gchar *readonly_inactive_actions[] =
233 "ToolsBookCloseAction",
244 #define GNC_PLUGIN_BASIC_COMMANDS_GET_PRIVATE(o) \
245 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_BASIC_COMMANDS, GncPluginBasicCommandsPrivate))
248 static GObjectClass *parent_class = NULL;
255 static GType gnc_plugin_basic_commands_type = 0;
257 if (gnc_plugin_basic_commands_type == 0)
259 static const GTypeInfo our_info =
264 (GClassInitFunc) gnc_plugin_basic_commands_class_init,
269 (GInstanceInitFunc) gnc_plugin_basic_commands_init
272 gnc_plugin_basic_commands_type = g_type_register_static (GNC_TYPE_PLUGIN,
273 "GncPluginBasicCommands",
277 return gnc_plugin_basic_commands_type;
291 plugin = g_object_new (GNC_TYPE_PLUGIN_BASIC_COMMANDS, NULL);
293 return GNC_PLUGIN (plugin);
311 gnc_plugin_basic_commands_add_to_window (
GncPlugin *plugin,
315 g_signal_connect(window,
"page_changed",
316 G_CALLBACK(gnc_plugin_basic_commands_main_window_page_changed),
322 static void update_inactive_actions(
GncPluginPage *plugin_page)
325 GtkActionGroup *action_group;
326 GtkAction *file_save_action;
333 if (!plugin_page || !GNC_IS_PLUGIN_PAGE(plugin_page))
336 window = GNC_MAIN_WINDOW(plugin_page->
window);
337 g_return_if_fail(GNC_IS_MAIN_WINDOW(window));
339 g_return_if_fail(GTK_IS_ACTION_GROUP(action_group));
343 "sensitive", is_readwrite);
345 file_save_action = gtk_action_group_get_action (action_group,
347 gtk_action_set_sensitive (file_save_action, is_readwrite && is_dirty);
351 gnc_plugin_basic_commands_main_window_page_changed(
GncMainWindow *window,
359 update_inactive_actions(page);
373 GObjectClass *object_class = G_OBJECT_CLASS (klass);
376 parent_class = g_type_class_peek_parent (klass);
378 object_class->finalize = gnc_plugin_basic_commands_finalize;
381 plugin_class->
plugin_name = GNC_PLUGIN_BASIC_COMMANDS_NAME;
384 plugin_class->
add_to_window = gnc_plugin_basic_commands_add_to_window;
388 plugin_class->
actions = gnc_plugin_actions;
389 plugin_class->
n_actions = gnc_plugin_n_actions;
417 gnc_plugin_basic_commands_finalize (GObject *
object)
419 g_return_if_fail (GNC_IS_PLUGIN_BASIC_COMMANDS (
object));
421 G_OBJECT_CLASS (parent_class)->finalize (
object);
441 g_return_if_fail (data != NULL);
446 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
447 #ifdef HAVE_DBI_DBI_H
448 gnc_ui_file_access_for_open();
452 gnc_window_set_progressbar_window (NULL);
458 g_return_if_fail (data != NULL);
463 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
465 gnc_window_set_progressbar_window (NULL);
472 g_return_if_fail (data != NULL);
477 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
478 #ifdef HAVE_DBI_DBI_H
479 gnc_ui_file_access_for_save_as();
483 gnc_window_set_progressbar_window (NULL);
490 g_return_if_fail (data != NULL);
495 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
504 gnc_window_set_progressbar_window (NULL);
510 g_return_if_fail (data != NULL);
512 gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
513 #ifdef HAVE_DBI_DBI_H
514 gnc_ui_file_access_for_export();
518 gnc_window_set_progressbar_window (NULL);
526 g_return_if_fail (data != NULL);
528 gnc_tax_info_dialog (GTK_WIDGET (data->window));
544 GList *auto_created_txns = NULL;
545 const char *nothing_to_do_msg =
546 _(
"There are no Scheduled Transactions to be entered at this time." );
548 g_return_if_fail (data != NULL);
550 window = data->window;
563 gnc_ui_sx_since_last_run_dialog(sx_instances, auto_created_txns);
564 auto_created_txns = NULL;
570 gnc_info_dialog(GTK_WIDGET(&window->
gtk_window),
"%s", nothing_to_do_msg);
574 gnc_info_dialog(GTK_WIDGET(&window->
gtk_window), ngettext
577 (
"There are no Scheduled Transactions to be entered at this time. "
578 "(%d transaction automatically created)",
579 "There are no Scheduled Transactions to be entered at this time. "
580 "(%d transactions automatically created)",
585 g_list_free(auto_created_txns);
586 g_object_unref(G_OBJECT(sx_instances));
592 gnc_ui_sx_loan_assistant_create ();
594 #ifdef CLOSE_BOOKS_ACTUALLY_WORKS
598 gnc_acct_period_dialog();
605 gnc_set_busy_cursor(NULL, TRUE);
606 gnc_prices_dialog (NULL);
607 gnc_unset_busy_cursor(NULL);
613 gnc_set_busy_cursor(NULL, TRUE);
614 gnc_commodities_dialog (NULL);
615 gnc_unset_busy_cursor(NULL);
621 gnc_ui_fincalc_dialog_create();
634 #ifdef REGISTER2_ENABLED
636 gnc_ui_find_transactions_dialog_create2 (NULL);
639 gnc_ui_find_transactions_dialog_create (NULL);
646 g_return_if_fail (data != NULL);
648 gnc_totd_dialog(GTK_WINDOW(data->window), FALSE);
gint num_auto_create_no_notify_instances
utility functions for the GnuCash UI
Functions that are supported by all types of windows.
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)
const gchar * ui_filename
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Functions for adding content to a window.
GType gnc_plugin_basic_commands_get_type(void)
char * gnc_history_get_last(void)
Functions providing the file history menu.
const gchar ** important_actions
GncPlugin * gnc_plugin_basic_commands_new(void)
gboolean qof_book_session_not_saved(const QofBook *book)
All type declarations for the whole Gnucash engine.
const gchar * actions_name
GtkActionGroup * gnc_main_window_get_action_group(GncMainWindow *window, const gchar *group_name)
gboolean qof_book_is_readonly(const QofBook *book)
const gchar * plugin_name
#define PLUGIN_ACTIONS_NAME
GncSxInstanceModel * gnc_sx_get_current_instances(void)
#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)
void(* add_to_window)(GncPlugin *plugin, GncMainWindow *window, GQuark type)
struct GncPluginBasicCommandsPrivate GncPluginBasicCommandsPrivate
gboolean gnc_main_window_all_finish_pending(void)
void gnc_ui_close_book(QofBook *book)
Functions providing a basic set of menu items.
#define PLUGIN_UI_FILENAME
const gchar * QofLogModule