42 #include <glib/gi18n.h> 43 #include "swig-runtime.h" 44 #include "guile-mappings.h" 47 #include "gnc-plugin-register.h" 50 #include "gnc-plugin-business.h" 53 #include "dialog-dup-trans.h" 54 #include "dialog-find-account.h" 55 #include "dialog-find-transactions.h" 56 #include "dialog-print-check.h" 57 #include "dialog-invoice.h" 58 #include "dialog-transfer.h" 59 #include "dialog-utils.h" 60 #include "assistant-stock-split.h" 61 #include "assistant-stock-transaction.h" 62 #include "gnc-component-manager.h" 64 #include "gnc-date-edit.h" 71 #include "gnc-gui-query.h" 72 #include "gnc-icons.h" 73 #include "gnc-split-reg.h" 79 #include "gnc-session.h" 81 #include "gnc-warnings.h" 83 #include "dialog-lot-viewer.h" 87 #include "window-reconcile.h" 88 #include "window-autoclear.h" 89 #include "window-report.h" 90 #include "engine-helpers.h" 91 #include "qofbookslots.h" 98 JUMP_LARGEST_VALUE_FIRST_SPLIT = 1,
99 JUMP_SMALLEST_VALUE_FIRST_SPLIT = 2,
100 } GncPrefJumpMultSplits;
103 static QofLogModule log_module = GNC_MOD_GUI;
105 #define DEFAULT_LINES_AMOUNT 50 107 static void gnc_plugin_page_register_finalize (GObject*
object);
111 static GtkWidget* gnc_plugin_page_register_create_widget (
GncPluginPage*
113 static void gnc_plugin_page_register_destroy_widget (
GncPluginPage*
115 static void gnc_plugin_page_register_window_changed (
GncPluginPage*
116 plugin_page, GtkWidget* window);
117 static gboolean gnc_plugin_page_register_focus_widget (
GncPluginPage*
119 static void gnc_plugin_page_register_focus (
GncPluginPage* plugin_page,
120 gboolean current_page);
121 static void gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
122 GKeyFile* file,
const gchar* group);
123 static GncPluginPage* gnc_plugin_page_register_recreate_page (GtkWidget* window,
126 static void gnc_plugin_page_register_update_edit_menu (
GncPluginPage* plugin_page,
128 static gboolean gnc_plugin_page_register_finish_pending (
GncPluginPage* plugin_page);
130 static gchar* gnc_plugin_page_register_get_tab_name (
GncPluginPage*
132 static gchar* gnc_plugin_page_register_get_tab_color (
GncPluginPage*
134 static gchar* gnc_plugin_page_register_get_long_name (
GncPluginPage*
137 static void gnc_plugin_page_register_summarybar_position_changed (gpointer prefs,
142 static void gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
143 static void gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
144 static void gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
145 static void gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
146 static void gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
147 static void gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
148 static void gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
149 static void gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
150 static void gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
151 static void gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
152 static void gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
153 static void gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
154 static void gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
155 static void gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
156 static void gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
157 static void gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
159 static void gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
160 static void gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
161 static void gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
163 static void gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
164 static void gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
165 static void gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
166 static void gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
167 static void gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
168 static void gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
169 static void gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
170 static void gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
171 static void gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
172 static void gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
173 static void gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
174 static void gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
175 static void gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
176 static void gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
177 static void gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
178 static void gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
179 static void gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
180 static void gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
181 static void gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
182 static void gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
183 static void gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
184 static void gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
185 static void gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
186 static void gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
188 static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
190 static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
192 static void gnc_plugin_page_register_refresh_cb (GHashTable* changes,
194 static void gnc_plugin_page_register_close_cb (gpointer user_data);
196 static void gnc_plugin_page_register_ui_update (gpointer various,
198 static void gppr_account_destroy_cb (
Account* account);
199 static void gnc_plugin_page_register_event_handler (
QofInstance* entity,
204 static GncInvoice* invoice_from_split (Split* split);
210 #define CUT_TRANSACTION_LABEL N_("Cu_t Transaction") 211 #define COPY_TRANSACTION_LABEL N_("_Copy Transaction") 212 #define PASTE_TRANSACTION_LABEL N_("_Paste Transaction") 213 #define DUPLICATE_TRANSACTION_LABEL N_("Dup_licate Transaction") 214 #define DELETE_TRANSACTION_LABEL N_("_Delete Transaction") 218 #define LINK_TRANSACTION_LABEL N_("_Manage Document Linkā¦") 222 #define LINK_TRANSACTION_OPEN_LABEL N_("_Open Linked Document") 225 #define JUMP_LINKED_INVOICE_LABEL N_("Jump to Business item") 226 #define CUT_SPLIT_LABEL N_("Cu_t Split") 227 #define COPY_SPLIT_LABEL N_("_Copy Split") 228 #define PASTE_SPLIT_LABEL N_("_Paste Split") 229 #define DUPLICATE_SPLIT_LABEL N_("Dup_licate Split") 230 #define DELETE_SPLIT_LABEL N_("_Delete Split") 231 #define CUT_TRANSACTION_TIP N_("Cut the selected transaction into clipboard") 232 #define COPY_TRANSACTION_TIP N_("Copy the selected transaction into clipboard") 233 #define PASTE_TRANSACTION_TIP N_("Paste the transaction from the clipboard") 234 #define DUPLICATE_TRANSACTION_TIP N_("Make a copy of the current transaction") 235 #define DELETE_TRANSACTION_TIP N_("Delete the current transaction") 236 #define LINK_TRANSACTION_TIP N_("Add, change, or unlink the document linked with the current transaction") 237 #define LINK_TRANSACTION_OPEN_TIP N_("Open the linked document for the current transaction") 238 #define JUMP_LINKED_INVOICE_TIP N_("Jump to the linked invoice, bill, expense or credit note") 239 #define CUT_SPLIT_TIP N_("Cut the selected split into clipboard") 240 #define COPY_SPLIT_TIP N_("Copy the selected split into clipboard") 241 #define PASTE_SPLIT_TIP N_("Paste the split from the clipboard") 242 #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split") 243 #define DELETE_SPLIT_TIP N_("Delete the current split") 245 static GActionEntry gnc_plugin_page_register_actions [] =
247 {
"FilePrintAction", gnc_plugin_page_register_cmd_print_check, NULL, NULL, NULL },
248 {
"EditCutAction", gnc_plugin_page_register_cmd_cut, NULL, NULL, NULL },
249 {
"EditCopyAction", gnc_plugin_page_register_cmd_copy, NULL, NULL, NULL },
250 {
"EditPasteAction", gnc_plugin_page_register_cmd_paste, NULL, NULL, NULL },
251 {
"EditEditAccountAction", gnc_plugin_page_register_cmd_edit_account, NULL, NULL, NULL },
252 {
"EditFindAccountAction", gnc_plugin_page_register_cmd_find_account, NULL, NULL, NULL },
253 {
"EditFindTransactionsAction", gnc_plugin_page_register_cmd_find_transactions, NULL, NULL, NULL },
254 {
"EditTaxOptionsAction", gnc_plugin_page_register_cmd_edit_tax_options, NULL, NULL, NULL },
255 {
"CutTransactionAction", gnc_plugin_page_register_cmd_cut_transaction, NULL, NULL, NULL },
256 {
"CopyTransactionAction", gnc_plugin_page_register_cmd_copy_transaction, NULL, NULL, NULL },
257 {
"PasteTransactionAction", gnc_plugin_page_register_cmd_paste_transaction, NULL, NULL, NULL },
258 {
"DuplicateTransactionAction", gnc_plugin_page_register_cmd_duplicate_transaction, NULL, NULL, NULL },
259 {
"DeleteTransactionAction", gnc_plugin_page_register_cmd_delete_transaction, NULL, NULL, NULL },
260 {
"RemoveTransactionSplitsAction", gnc_plugin_page_register_cmd_reinitialize_transaction, NULL, NULL, NULL },
261 {
"RecordTransactionAction", gnc_plugin_page_register_cmd_enter_transaction, NULL, NULL, NULL },
262 {
"CancelTransactionAction", gnc_plugin_page_register_cmd_cancel_transaction, NULL, NULL, NULL },
263 {
"VoidTransactionAction", gnc_plugin_page_register_cmd_void_transaction, NULL, NULL, NULL },
264 {
"UnvoidTransactionAction", gnc_plugin_page_register_cmd_unvoid_transaction, NULL, NULL, NULL },
265 {
"ReverseTransactionAction", gnc_plugin_page_register_cmd_reverse_transaction, NULL, NULL, NULL },
266 {
"LinkTransactionAction", gnc_plugin_page_register_cmd_linked_transaction, NULL, NULL, NULL },
267 {
"LinkedTransactionOpenAction", gnc_plugin_page_register_cmd_linked_transaction_open, NULL, NULL, NULL },
268 {
"JumpLinkedInvoiceAction", gnc_plugin_page_register_cmd_jump_linked_invoice, NULL, NULL, NULL },
269 {
"ViewSortByAction", gnc_plugin_page_register_cmd_view_sort_by, NULL, NULL, NULL },
270 {
"ViewFilterByAction", gnc_plugin_page_register_cmd_view_filter_by, NULL, NULL, NULL },
271 {
"ViewRefreshAction", gnc_plugin_page_register_cmd_reload, NULL, NULL, NULL },
272 {
"ActionsTransferAction", gnc_plugin_page_register_cmd_transfer, NULL, NULL, NULL },
273 {
"ActionsReconcileAction", gnc_plugin_page_register_cmd_reconcile, NULL, NULL, NULL },
274 {
"ActionsAutoClearAction", gnc_plugin_page_register_cmd_autoclear, NULL, NULL, NULL },
275 {
"ActionsStockAssistantAction", gnc_plugin_page_register_cmd_stock_assistant, NULL, NULL, NULL },
276 {
"ActionsStockSplitAction", gnc_plugin_page_register_cmd_stock_split, NULL, NULL, NULL },
277 {
"ActionsLotsAction", gnc_plugin_page_register_cmd_lots, NULL, NULL, NULL },
278 {
"BlankTransactionAction", gnc_plugin_page_register_cmd_blank_transaction, NULL, NULL, NULL },
279 {
"GotoDateAction", gnc_plugin_page_register_cmd_goto_date, NULL, NULL, NULL },
280 {
"EditExchangeRateAction", gnc_plugin_page_register_cmd_exchange_rate, NULL, NULL, NULL },
281 {
"JumpTransactionAction", gnc_plugin_page_register_cmd_jump, NULL, NULL, NULL },
282 {
"ScheduleTransactionAction", gnc_plugin_page_register_cmd_schedule, NULL, NULL, NULL },
283 {
"ScrubAllAction", gnc_plugin_page_register_cmd_scrub_all, NULL, NULL, NULL },
284 {
"ScrubCurrentAction", gnc_plugin_page_register_cmd_scrub_current, NULL, NULL, NULL },
285 {
"ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL },
286 {
"ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL },
288 {
"ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL,
"false", NULL },
289 {
"SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL,
"false", NULL },
290 {
"ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed,
"i",
"@i 0", NULL },
292 static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions);
295 static const gchar *gnc_plugin_load_ui_items [] =
311 "ActionsPlaceholder4",
312 "ActionsPlaceholder5",
313 "ActionsPlaceholder6",
314 "ReportsPlaceholder1",
320 static const gchar* actions_requiring_account[] =
322 "EditEditAccountAction",
323 "ActionsReconcileAction",
324 "ActionsAutoClearAction",
329 static const gchar* actions_requiring_priced_account[] =
331 "ActionsStockAssistantAction",
338 {
"ActionsTransferAction", N_ (
"Transfer") },
339 {
"RecordTransactionAction", N_ (
"Enter") },
340 {
"CancelTransactionAction", N_ (
"Cancel") },
341 {
"DeleteTransactionAction", N_ (
"Delete") },
342 {
"DuplicateTransactionAction", N_ (
"Duplicate") },
343 {
"SplitTransactionAction",
345 N_ (
"Show Splits") },
346 {
"JumpTransactionAction", N_ (
"Jump") },
347 {
"ScheduleTransactionAction", N_ (
"Schedule") },
348 {
"BlankTransactionAction", N_ (
"Blank") },
349 {
"ActionsReconcileAction", N_ (
"Reconcile") },
350 {
"ActionsStockAssistantAction", N_ (
"Stock Assistant") },
360 GNCLedgerDisplay* ledger;
365 gint event_handler_id;
366 gint component_manager_id;
372 gboolean enable_refresh;
382 GNC_TYPE_PLUGIN_PAGE)
384 #define GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(o) \ 385 ((GncPluginPageRegisterPrivate*)gnc_plugin_page_register_get_instance_private((GncPluginPageRegister*)o)) 392 gnc_plugin_page_register_new_common (GNCLedgerDisplay* ledger)
405 if (!gnc_features_check_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER))
409 if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book()))
410 gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book());
413 gsr = GNC_SPLIT_REG(gnc_ledger_display_get_user_data (ledger));
417 for (; item; item = g_list_next (item))
420 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
421 if (priv->gsr == gsr)
422 return GNC_PLUGIN_PAGE (page);
426 page = GNC_PLUGIN_PAGE_REGISTER(g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER,
nullptr));
427 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
428 priv->ledger = ledger;
431 plugin_page = GNC_PLUGIN_PAGE (page);
432 label = gnc_plugin_page_register_get_tab_name (plugin_page);
436 label_color = gnc_plugin_page_register_get_tab_color (plugin_page);
438 g_free (label_color);
440 label = gnc_plugin_page_register_get_long_name (plugin_page);
446 for (item = book_list; item; item = g_list_next (item))
450 priv->component_manager_id = 0;
455 gnc_plug_page_register_check_commodity (
Account* account,
void* usr_data)
458 gnc_commodity* com0 = (gnc_commodity*) usr_data;
466 GNCLedgerDisplay* ledger;
472 ENTER (
"account=%p, subaccounts=%s", account,
473 subaccounts ?
"TRUE" :
"FALSE");
477 gnc_plug_page_register_check_commodity,
478 static_cast<gpointer>(com0)));
485 plugin_page = gnc_plugin_page_register_new_common (ledger);
486 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
489 LEAVE (
"%p", plugin_page);
496 GNCLedgerDisplay* ledger;
499 return gnc_plugin_page_register_new_common (ledger);
505 return gnc_plugin_page_register_new_common (ledger);
511 GObjectClass* object_class = G_OBJECT_CLASS (klass);
514 object_class->finalize = gnc_plugin_page_register_finalize;
516 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
517 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_REGISTER_NAME;
518 gnc_plugin_class->
create_widget = gnc_plugin_page_register_create_widget;
519 gnc_plugin_class->
destroy_widget = gnc_plugin_page_register_destroy_widget;
520 gnc_plugin_class->
window_changed = gnc_plugin_page_register_window_changed;
521 gnc_plugin_class->
focus_page = gnc_plugin_page_register_focus;
522 gnc_plugin_class->
save_page = gnc_plugin_page_register_save_page;
523 gnc_plugin_class->
recreate_page = gnc_plugin_page_register_recreate_page;
525 gnc_plugin_class->
finish_pending = gnc_plugin_page_register_finish_pending;
528 gnc_ui_register_account_destroy_callback (gppr_account_destroy_cb);
536 GSimpleActionGroup *simple_action_group;
539 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
542 plugin_page = GNC_PLUGIN_PAGE (page);
545 g_object_set (G_OBJECT (page),
546 "page-name", _ (
"General Journal"),
547 "ui-description",
"gnc-plugin-page-register.ui",
548 "use-new-window", use_new,
553 "GncPluginPageRegisterActions");
554 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
555 gnc_plugin_page_register_actions,
556 gnc_plugin_page_register_n_actions,
559 priv->lines_default = DEFAULT_LINES_AMOUNT;
560 priv->read_only = FALSE;
561 priv->fd.cleared_match = CLEARED_ALL;
563 priv->enable_refresh = TRUE;
564 priv->search_query = NULL;
565 priv->filter_query = NULL;
569 gnc_plugin_page_register_finalize (GObject*
object)
571 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (
object));
573 ENTER (
"object %p",
object);
575 G_OBJECT_CLASS (gnc_plugin_page_register_parent_class)->finalize (
object);
583 GNCLedgerDisplayType ledger_type;
586 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
587 ledger_type = gnc_ledger_display_type (priv->ledger);
590 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
601 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
611 gnc_plugin_page_register_focus_widget (
GncPluginPage* plugin_page)
613 if (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page))
615 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
618 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window))
622 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
625 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
629 gnc_plugin_load_ui_items);
633 GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window);
634 GtkWidget *menubar = gnc_window_get_menubar (gnc_window);
635 GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window);
636 GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window);
646 gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(plugin_page));
648 gnc_split_reg_focus_on_sheet (gsr);
654 static const char* readonly_inactive_actions[] =
658 "CutTransactionAction",
659 "PasteTransactionAction",
660 "DuplicateTransactionAction",
661 "DeleteTransactionAction",
662 "RemoveTransactionSplitsAction",
663 "RecordTransactionAction",
664 "CancelTransactionAction",
665 "UnvoidTransactionAction",
666 "VoidTransactionAction",
667 "ReverseTransactionAction",
668 "ActionsTransferAction",
669 "ActionsReconcileAction",
670 "ActionsStockSplitAction",
671 "ScheduleTransactionAction",
673 "ScrubCurrentAction",
674 "LinkTransactionAction",
680 static const char* tran_vs_split_actions[] =
682 "CutTransactionAction",
683 "CopyTransactionAction",
684 "PasteTransactionAction",
685 "DuplicateTransactionAction",
686 "DeleteTransactionAction",
691 static const char* tran_action_labels[] =
693 CUT_TRANSACTION_LABEL,
694 COPY_TRANSACTION_LABEL,
695 PASTE_TRANSACTION_LABEL,
696 DUPLICATE_TRANSACTION_LABEL,
697 DELETE_TRANSACTION_LABEL,
702 static const char* tran_action_tips[] =
705 COPY_TRANSACTION_TIP,
706 PASTE_TRANSACTION_TIP,
707 DUPLICATE_TRANSACTION_TIP,
708 DELETE_TRANSACTION_TIP,
713 static const char* split_action_labels[] =
718 DUPLICATE_SPLIT_LABEL,
724 static const char* split_action_tips[] =
734 static std::vector<GncInvoice*>
735 invoices_from_transaction (
const Transaction* trans)
737 std::vector<GncInvoice*> rv;
739 g_return_val_if_fail (GNC_IS_TRANSACTION (trans), rv);
743 auto split = GNC_SPLIT(node->data);
747 auto inv = invoice_from_split (split);
755 gnc_plugin_page_register_ui_update (gpointer various,
761 GNCLedgerDisplayType ledger_type;
762 gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE;
767 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
770 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
776 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
779 ledger_type = gnc_ledger_display_type (priv->ledger);
782 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type != LD_GL);
783 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
787 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
791 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
793 g_signal_handlers_block_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
794 g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded));
795 g_signal_handlers_unblock_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
800 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
804 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
808 actions_requiring_priced_account,
816 gnc_split_reg_get_read_only (priv->gsr))
817 read_only_reg = TRUE;
820 actions_requiring_account,
821 !read_only_reg && account != NULL);
824 actions_requiring_priced_account,
830 if (cursor_class == CURSOR_CLASS_SPLIT)
832 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
839 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
850 for (iter = readonly_inactive_actions; *iter; ++iter)
854 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
864 "CutTransactionAction");
865 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
868 "PasteTransactionAction");
869 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
872 "DeleteTransactionAction");
873 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
875 if (cursor_class == CURSOR_CLASS_SPLIT)
878 "DuplicateTransactionAction");
879 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
883 "RemoveTransactionSplitsAction");
884 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
891 "VoidTransactionAction");
892 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided);
898 "UnvoidTransactionAction");
899 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided);
904 "LinkedTransactionOpenAction");
908 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (uri ? TRUE:FALSE));
916 "JumpLinkedInvoiceAction");
919 auto invoices = invoices_from_transaction (trans);
920 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !invoices.empty());
923 gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page));
927 "PasteTransactionAction");
928 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
935 for (iter = readonly_inactive_actions; *iter; ++iter)
939 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
946 GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
947 gboolean found = FALSE;
948 const char** iter, **label_iter, **tooltip_iter;
949 gboolean curr_label_trans = FALSE;
950 iter = tran_vs_split_actions;
951 label_iter = tran_action_labels;
953 gsm->search_action_label = NULL;
954 gsm->search_action_name = *iter;
955 gsm->search_action_target = NULL;
959 PINFO(
"Test for action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter));
967 if (g_strcmp0 (gsm->search_action_label, _(*label_iter)) == 0)
968 curr_label_trans = TRUE;
972 if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans)
974 gboolean found = FALSE;
975 label_iter = split_action_labels;
976 tooltip_iter = split_action_tips;
977 for (iter = tran_vs_split_actions; *iter; ++iter)
981 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
983 PINFO(
"split model_item action '%s', found is %d, iter label is '%s'",
984 *iter, found, _(*label_iter));
990 else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans)
992 gboolean found = FALSE;
993 label_iter = tran_action_labels;
994 tooltip_iter = tran_action_tips;
995 for (iter = tran_vs_split_actions; *iter; ++iter)
999 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
1001 PINFO(
"trans model_item action '%s', found is %d, iter label is '%s'",
1002 *iter, found, _(*label_iter));
1010 gnc_window_get_menubar_model (gnc_window),
1011 gnc_window_get_statusbar (gnc_window));
1015 gnc_window_get_menubar_model (gnc_window),
1016 gnc_window_get_accel_group (gnc_window));
1024 GSimpleActionGroup *simple_action_group;
1028 GNCLedgerDisplayType ledger_type;
1031 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1036 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
1039 is_readwrite && account != NULL);
1042 ledger_type = gnc_ledger_display_type (priv->ledger);
1044 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type == LD_SINGLE);
1048 g_signal_handlers_block_by_func (action,
1049 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1050 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
1051 g_signal_handlers_unblock_by_func (action,
1052 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1056 g_signal_handlers_block_by_func (action,
1057 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1058 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
1059 g_signal_handlers_unblock_by_func (action,
1060 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1070 gboolean on_current_page)
1075 gboolean main_window_is_quitting = FALSE;
1077 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1079 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1080 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1084 if (GNC_IS_MAIN_WINDOW(plugin_page->
window))
1087 if (on_current_page)
1089 priv->page_focus = TRUE;
1093 GNC_PLUGIN_PAGE_CLASS (gnc_plugin_page_register_parent_class)->focus_page (plugin_page, TRUE);
1096 priv->page_focus = FALSE;
1099 gnc_split_reg_set_sheet_focus (gsr, priv->page_focus);
1102 if (on_current_page && !main_window_is_quitting)
1112 ENTER(
"page %p", plugin_page);
1114 priv->enable_refresh = FALSE;
1120 priv->enable_refresh = TRUE;
1127 gnc_plugin_page_register_create_widget (
GncPluginPage* plugin_page)
1131 GncWindow* gnc_window;
1137 ENTER (
"page %p", plugin_page);
1138 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1139 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1141 if (priv->widget != NULL)
1143 LEAVE (
"existing widget %p", priv->widget);
1144 return priv->widget;
1147 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1148 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
1149 gtk_widget_show (priv->widget);
1152 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-register-page");
1154 numRows = priv->lines_default;
1155 numRows = MIN (numRows, DEFAULT_LINES_AMOUNT);
1157 gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
1158 gsr = gnc_split_reg_new (priv->ledger,
1159 gnc_window_get_gtk_window (gnc_window),
1160 numRows, priv->read_only);
1161 priv->gsr = (GNCSplitReg *)gsr;
1164 gtk_widget_show (gsr);
1165 gtk_box_pack_start (GTK_BOX (priv->widget), gsr, TRUE, TRUE, 0);
1167 g_signal_connect (G_OBJECT (gsr),
"help-changed",
1168 G_CALLBACK (gnc_plugin_page_help_changed_cb),
1171 g_signal_connect (G_OBJECT (gsr),
"show-popup-menu",
1172 G_CALLBACK (gnc_plugin_page_popup_menu_cb),
1177 reg->use_double_line);
1179 gnc_plugin_page_register_ui_initial_state (page);
1180 gnc_plugin_page_register_ui_update (NULL, page);
1183 gnc_ppr_update_filter_and_sort (plugin_page);
1185 plugin_page->
summarybar = gsr_create_summary_bar (priv->gsr);
1188 gtk_widget_show_all (plugin_page->
summarybar);
1189 gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->
summarybar,
1192 gnc_plugin_page_register_summarybar_position_changed (NULL, NULL, page);
1194 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1195 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1198 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1199 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1205 priv->component_manager_id =
1206 gnc_register_gui_component (GNC_PLUGIN_PAGE_REGISTER_NAME,
1207 gnc_plugin_page_register_refresh_cb,
1208 gnc_plugin_page_register_close_cb,
1210 gnc_gui_component_set_session (priv->component_manager_id,
1211 gnc_get_current_session());
1214 gnc_gui_component_watch_entity (
1216 QOF_EVENT_DESTROY | QOF_EVENT_MODIFY);
1218 gnc_split_reg_set_moved_cb
1219 (priv->gsr, (GFunc)gnc_plugin_page_register_ui_update, page);
1221 g_signal_connect (G_OBJECT (plugin_page),
"inserted",
1227 return priv->widget;
1231 gnc_plugin_page_register_destroy_widget (
GncPluginPage* plugin_page)
1236 ENTER (
"page %p", plugin_page);
1237 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1238 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1241 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1242 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1245 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1246 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1253 g_idle_remove_by_data (GNC_PLUGIN_PAGE_REGISTER (plugin_page));
1255 if (priv->widget == NULL)
1258 if (priv->component_manager_id)
1260 gnc_unregister_gui_component (priv->component_manager_id);
1261 priv->component_manager_id = 0;
1264 if (priv->event_handler_id)
1267 priv->event_handler_id = 0;
1270 if (priv->sd.dialog)
1272 gtk_widget_destroy (priv->sd.dialog);
1273 memset (&priv->sd, 0, sizeof (priv->sd));
1276 if (priv->fd.dialog)
1278 gtk_widget_destroy (priv->fd.dialog);
1279 memset (&priv->fd, 0, sizeof (priv->fd));
1285 gtk_widget_hide (priv->widget);
1287 g_object_unref(priv->widget);
1288 priv->widget = NULL;
1291 priv->ledger = NULL;
1297 gnc_plugin_page_register_window_changed (
GncPluginPage* plugin_page,
1303 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1305 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1306 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1308 GTK_WIDGET (gnc_window_get_gtk_window (GNC_WINDOW (window)));
1311 static const gchar* style_names[] =
1319 #define KEY_REGISTER_TYPE "RegisterType" 1320 #define KEY_ACCOUNT_NAME "AccountName" 1321 #define KEY_ACCOUNT_GUID "AccountGuid" 1322 #define KEY_REGISTER_STYLE "RegisterStyle" 1323 #define KEY_DOUBLE_LINE "DoubleLineMode" 1325 #define LABEL_ACCOUNT "Account" 1326 #define LABEL_SUBACCOUNT "SubAccount" 1327 #define LABEL_GL "GL" 1328 #define LABEL_SEARCH "Search" 1341 gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
1343 const gchar* group_name)
1347 GNCLedgerDisplayType ledger_type;
1351 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1352 g_return_if_fail (key_file != NULL);
1353 g_return_if_fail (group_name != NULL);
1355 ENTER (
"page %p, key_file %p, group_name %s", plugin_page, key_file,
1358 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1359 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1362 ledger_type = gnc_ledger_display_type (priv->ledger);
1363 if (ledger_type > LD_GL)
1365 LEAVE (
"Unsupported ledger type");
1368 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1373 label = (ledger_type == LD_SINGLE) ? LABEL_ACCOUNT : LABEL_SUBACCOUNT;
1375 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE, label);
1377 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_NAME, name);
1380 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_GUID, acct_guid);
1382 else if (reg->type == GENERAL_JOURNAL)
1384 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1387 else if (reg->type == SEARCH_LEDGER)
1389 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1394 LEAVE (
"Unsupported register type");
1398 g_key_file_set_string (key_file, group_name, KEY_REGISTER_STYLE,
1399 style_names[reg->style]);
1400 g_key_file_set_boolean (key_file, group_name, KEY_DOUBLE_LINE,
1401 reg->use_double_line);
1420 gnc_plugin_page_register_restore_edit_menu (
GncPluginPage* plugin_page,
1422 const gchar* group_name)
1426 GError* error = NULL;
1429 gboolean use_double_line;
1434 style_name = g_key_file_get_string (key_file, group_name,
1435 KEY_REGISTER_STYLE, &error);
1436 for (i = 0 ; style_names[i]; i++)
1438 if (g_ascii_strcasecmp (style_name, style_names[i]) == 0)
1440 DEBUG (
"Found match for style name: %s", style_name);
1444 g_free (style_name);
1447 if (i <= REG_STYLE_JOURNAL)
1449 DEBUG (
"Setting style: %d", i);
1451 g_action_activate (G_ACTION(action), g_variant_new_int32 (i));
1455 use_double_line = g_key_file_get_boolean (key_file, group_name,
1456 KEY_DOUBLE_LINE, &error);
1457 DEBUG (
"Setting double_line_mode: %d", use_double_line);
1460 state = g_action_get_state (G_ACTION(action));
1462 if (use_double_line != g_variant_get_boolean (state))
1463 g_action_activate (G_ACTION(action), NULL);
1465 g_variant_unref (state);
1481 gnc_plugin_page_register_recreate_page (GtkWidget* window,
1483 const gchar* group_name)
1487 GError* error = NULL;
1488 gchar* reg_type, *acct_guid;
1492 gboolean include_subs;
1494 g_return_val_if_fail (key_file, NULL);
1495 g_return_val_if_fail (group_name, NULL);
1496 ENTER (
"key_file %p, group_name %s", key_file, group_name);
1499 reg_type = g_key_file_get_string (key_file, group_name,
1500 KEY_REGISTER_TYPE, &error);
1501 DEBUG (
"Page type: %s", reg_type);
1502 if ((g_ascii_strcasecmp (reg_type, LABEL_ACCOUNT) == 0) ||
1503 (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0))
1505 include_subs = (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0);
1506 DEBUG (
"Include subs: %d", include_subs);
1510 LEAVE(
"Session has no book");
1513 acct_guid = g_key_file_get_string (key_file, group_name,
1514 KEY_ACCOUNT_GUID, &error);
1520 if (account == NULL)
1522 gchar* acct_name = g_key_file_get_string (key_file, group_name,
1523 KEY_ACCOUNT_NAME, &error);
1528 if (account == NULL)
1530 LEAVE (
"Bad account name");
1536 else if (g_ascii_strcasecmp (reg_type, LABEL_GL) == 0)
1542 LEAVE (
"Bad ledger type");
1550 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1551 priv->enable_refresh = FALSE;
1560 gnc_plugin_page_register_restore_edit_menu (plugin_page, key_file, group_name);
1563 priv->enable_refresh = TRUE;
1573 gnc_plugin_page_register_update_edit_menu (
GncPluginPage* plugin_page, gboolean hide)
1578 gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
1579 gboolean has_selection;
1582 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1583 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1584 has_selection = gnucash_register_has_selection (priv->gsr->reg);
1586 can_copy = has_selection;
1587 can_cut = is_readwrite && has_selection;
1588 can_paste = is_readwrite;
1591 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy);
1593 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut);
1595 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste);
1598 static gboolean is_scrubbing = FALSE;
1599 static gboolean show_abort_verify = TRUE;
1602 check_repair_abort_YN = N_(
"'Check & Repair' is currently running, do you want to abort it?");
1607 gboolean ret = FALSE;
1612 false,
"%s", _(check_repair_abort_YN));
1614 show_abort_verify = FALSE;
1623 gnc_plugin_page_register_finish_pending (
GncPluginPage* plugin_page)
1628 GtkWidget* dialog, *window;
1632 if (is_scrubbing && show_abort_verify)
1634 if (!finish_scrub (plugin_page))
1638 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1639 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1645 name = gnc_plugin_page_register_get_tab_name (plugin_page);
1647 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1648 GTK_DIALOG_DESTROY_WITH_PARENT,
1649 GTK_MESSAGE_WARNING,
1653 _ (
"Save changes to %s?"), name);
1655 gtk_message_dialog_format_secondary_text
1656 (GTK_MESSAGE_DIALOG (dialog),
1658 _ (
"This register has pending changes to a transaction. " 1659 "Would you like to save the changes to this transaction, " 1660 "discard the transaction, or cancel the operation?"));
1661 gnc_gtk_dialog_add_button (dialog, _ (
"_Discard Transaction"),
1662 "edit-delete", GTK_RESPONSE_REJECT);
1663 gtk_dialog_add_button (GTK_DIALOG (dialog),
1664 _ (
"_Cancel"), GTK_RESPONSE_CANCEL);
1665 gnc_gtk_dialog_add_button (dialog, _ (
"_Save Transaction"),
1666 "document-save", GTK_RESPONSE_ACCEPT);
1668 response = gtk_dialog_run (GTK_DIALOG (dialog));
1669 gtk_widget_destroy (dialog);
1673 case GTK_RESPONSE_ACCEPT:
1677 case GTK_RESPONSE_REJECT:
1689 gnc_plugin_page_register_get_tab_name (
GncPluginPage* plugin_page)
1692 GNCLedgerDisplayType ledger_type;
1693 GNCLedgerDisplay* ld;
1697 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1698 g_strdup (_(
"unknown")));
1700 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1703 ledger_type = gnc_ledger_display_type (ld);
1706 switch (ledger_type)
1717 case GENERAL_JOURNAL:
1719 return g_strdup (_ (
"General Journal"));
1720 case PORTFOLIO_LEDGER:
1721 return g_strdup (_ (
"Portfolio"));
1723 return g_strdup (_ (
"Search Results"));
1733 return g_strdup (_ (
"unknown"));
1737 gnc_plugin_page_register_get_tab_color (
GncPluginPage* plugin_page)
1740 GNCLedgerDisplayType ledger_type;
1741 GNCLedgerDisplay* ld;
1745 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1746 g_strdup (_(
"unknown")));
1748 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1750 ledger_type = gnc_ledger_display_type (ld);
1754 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1757 return g_strdup (color ? color :
"Not Set");
1761 gnc_plugin_page_register_get_long_name (
GncPluginPage* plugin_page)
1764 GNCLedgerDisplayType ledger_type;
1765 GNCLedgerDisplay* ld;
1768 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1771 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1773 ledger_type = gnc_ledger_display_type (ld);
1776 switch (ledger_type)
1784 gchar* return_string = g_strdup_printf (
"%s+", account_full_name);
1785 g_free ((gpointer*) account_full_name);
1786 return return_string;
1797 gnc_plugin_page_register_summarybar_position_changed (gpointer prefs,
1804 GtkPositionType position = GTK_POS_BOTTOM;
1806 g_return_if_fail (user_data != NULL);
1808 if (!GNC_IS_PLUGIN_PAGE (user_data))
1811 plugin_page = GNC_PLUGIN_PAGE (user_data);
1812 page = GNC_PLUGIN_PAGE_REGISTER (user_data);
1813 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1819 GNC_PREF_SUMMARYBAR_POSITION_TOP))
1820 position = GTK_POS_TOP;
1822 gtk_box_reorder_child (GTK_BOX (priv->widget),
1824 (position == GTK_POS_TOP ? 0 : -1));
1828 gnc_plugin_page_register_update_page_icon (
GncPluginPage* plugin_page)
1833 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1835 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1838 gnc_split_reg_get_read_only (priv->gsr))
1858 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
1860 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1861 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1871 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
1877 if (priv->enable_refresh)
1888 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1891 if (reg->type == SEARCH_LEDGER)
1898 if ((priv->filter_query == NULL) ||
1910 gboolean enable_refresh)
1914 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
1916 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
1918 priv->enable_refresh = enable_refresh;
1924 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page));
1934 gnc_reg_get_name (GNCLedgerDisplay* ledger, gboolean for_window)
1938 gchar* account_name;
1941 GNCLedgerDisplayType ledger_type;
1947 ledger_type = gnc_ledger_display_type (ledger);
1951 case GENERAL_JOURNAL:
1954 reg_name = _ (
"General Journal");
1956 reg_name = _ (
"Transaction Report");
1958 case PORTFOLIO_LEDGER:
1960 reg_name = _ (
"Portfolio");
1962 reg_name = _ (
"Portfolio Report");
1966 reg_name = _ (
"Search Results");
1968 reg_name = _ (
"Search Results Report");
1972 reg_name = _ (
"Register");
1974 reg_name = _ (
"Transaction Report");
1980 if ((leader != NULL) && (ledger_type != LD_GL))
1984 if (ledger_type == LD_SINGLE)
1986 name = g_strconcat (account_name,
" - ", reg_name, NULL);
1990 name = g_strconcat (account_name,
" ", _ (
"and subaccounts"),
" - ", reg_name,
1993 g_free (account_name);
1996 name = g_strdup (reg_name);
2002 report_helper (GNCLedgerDisplay* ledger, Split* split,
Query* query)
2008 swig_type_info* qtype;
2015 func = scm_c_eval_string (
"gnc:register-report-create");
2016 g_return_val_if_fail (scm_is_procedure (func), -1);
2019 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Credit"));
2020 args = scm_cons (arg, args);
2023 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Debit"));
2024 args = scm_cons (arg, args);
2026 str = gnc_reg_get_name (ledger, FALSE);
2027 arg = scm_from_utf8_string (str ? str :
"");
2028 args = scm_cons (arg, args);
2031 arg = SCM_BOOL (reg->use_double_line);
2032 args = scm_cons (arg, args);
2034 arg = SCM_BOOL (reg->type == GENERAL_JOURNAL || reg->type == INCOME_LEDGER
2035 || reg->type == SEARCH_LEDGER);
2036 args = scm_cons (arg, args);
2038 arg = SCM_BOOL (reg->style == REG_STYLE_JOURNAL);
2039 args = scm_cons (arg, args);
2044 g_return_val_if_fail (query != NULL, -1);
2047 qtype = SWIG_TypeQuery (
"_p__QofQuery");
2048 g_return_val_if_fail (qtype, -1);
2050 arg = SWIG_NewPointerObj (query, qtype, 0);
2051 args = scm_cons (arg, args);
2052 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2057 qtype = SWIG_TypeQuery (
"_p_Split");
2058 g_return_val_if_fail (qtype, -1);
2059 arg = SWIG_NewPointerObj (split, qtype, 0);
2065 args = scm_cons (arg, args);
2066 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2069 qtype = SWIG_TypeQuery (
"_p_Account");
2070 g_return_val_if_fail (qtype, -1);
2073 arg = SWIG_NewPointerObj (account, qtype, 0);
2074 args = scm_cons (arg, args);
2075 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2079 arg = scm_apply (func, args, SCM_EOL);
2080 g_return_val_if_fail (scm_is_exact (arg), -1);
2082 return scm_to_int (arg);
2090 gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple,
2094 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2099 GList* splits = NULL, *item;
2100 GNCLedgerDisplayType ledger_type;
2101 Account* account, *subaccount = NULL;
2104 ENTER (
"(action %p, page %p)", simple, page);
2106 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2108 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2110 ledger_type = gnc_ledger_display_type (priv->ledger);
2112 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
2117 if (ledger_type == LD_SUBACCOUNT)
2121 subaccount = account;
2128 splits = g_list_prepend (splits, split);
2129 gnc_ui_print_check_dialog_create (window, splits, subaccount);
2130 g_list_free (splits);
2139 splits = g_list_prepend (splits, split);
2140 gnc_ui_print_check_dialog_create (window, splits, subaccount);
2141 g_list_free (splits);
2146 else if (ledger_type == LD_GL && reg->type == SEARCH_LEDGER)
2154 for (item = splits; item; item = g_list_next (item))
2156 split = (Split*) item->data;
2157 if (common_acct == NULL)
2167 const gchar* title = _ (
"Print checks from multiple accounts?");
2168 const gchar* message =
2169 _ (
"This search result contains splits from more than one account. " 2170 "Do you want to print the checks even though they are not all " 2171 "from the same account?");
2172 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
2173 GTK_DIALOG_DESTROY_WITH_PARENT,
2174 GTK_MESSAGE_WARNING,
2177 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
2179 gtk_dialog_add_button (GTK_DIALOG (dialog), _ (
"_Print checks"),
2181 response = gnc_dialog_run (GTK_DIALOG (dialog),
2182 GNC_PREF_WARN_CHECKPRINTING_MULTI_ACCT);
2183 gtk_widget_destroy (dialog);
2184 if (response != GTK_RESPONSE_YES)
2186 LEAVE (
"Multiple accounts");
2193 gnc_ui_print_check_dialog_create (window, splits, NULL);
2197 gnc_error_dialog (GTK_WINDOW (window),
"%s",
2198 _ (
"You can only print checks from a bank account register or search results."));
2199 LEAVE (
"Unsupported ledger type");
2207 gnc_plugin_page_register_cmd_cut (GSimpleAction *simple,
2211 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2214 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2216 ENTER (
"(action %p, page %p)", simple, page);
2217 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2219 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
2220 const char *name = gtk_widget_get_name(widget);
2221 if (strcmp(name,
"GnucashSheet") != 0)
2223 gtk_editable_cut_clipboard( GTK_EDITABLE(widget));
2224 LEAVE(
"Not cut from GnucashSheet");
2229 gnucash_register_cut_clipboard (priv->gsr->reg);
2235 gnc_plugin_page_register_cmd_copy (GSimpleAction *simple,
2239 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2242 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2244 ENTER (
"(action %p, page %p)", simple, page);
2245 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2247 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
2248 const char *name = gtk_widget_get_name(widget);
2249 if (strcmp(name,
"GnucashSheet") != 0)
2251 gtk_editable_copy_clipboard( GTK_EDITABLE(widget));
2252 LEAVE(
"Not copied from GnucashSheet");
2257 gnucash_register_copy_clipboard (priv->gsr->reg);
2263 gnc_plugin_page_register_cmd_paste (GSimpleAction *simple,
2267 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2270 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2272 ENTER (
"(action %p, page %p)", simple, page);
2273 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2275 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
2276 const char *name = gtk_widget_get_name(widget);
2277 if (strcmp(name,
"GnucashSheet") != 0)
2279 gtk_editable_paste_clipboard( GTK_EDITABLE(widget));
2280 LEAVE(
"Not pasted to GnucashSheet");
2285 gnucash_register_paste_clipboard (priv->gsr->reg);
2291 gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple,
2295 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2298 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2300 ENTER (
"(action %p, page %p)", simple, page);
2309 gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple,
2313 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2316 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2319 gnc_find_account_dialog (window, NULL);
2324 gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple,
2328 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2332 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2334 ENTER (
"(action %p, page %p)", simple, page);
2335 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2337 gnc_ui_find_transactions_dialog_create (window, priv->ledger);
2343 gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple,
2347 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2351 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2353 ENTER (
"(action %p, page %p)", simple, page);
2356 gnc_tax_info_dialog (window, account);
2361 gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple,
2365 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2368 ENTER (
"(action %p, page %p)", simple, page);
2370 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2372 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2373 gsr_default_cut_txn_handler (priv->gsr, NULL);
2377 "PasteTransactionAction");
2378 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
2385 gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple,
2389 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2393 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2395 ENTER (
"(action %p, page %p)", simple, page);
2396 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2402 "PasteTransactionAction");
2403 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
2410 gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple,
2414 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2418 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2420 ENTER (
"(action %p, page %p)", simple, page);
2421 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2429 gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple,
2433 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2435 GtkWidget* dialog, *entry;
2438 GtkBuilder* builder;
2443 ENTER (
"(action %p, page %p)", simple, page);
2445 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2448 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2458 gnc_error_dialog (window,
"%s",
2459 _ (
"You cannot void a transaction with reconciled or cleared splits."));
2465 gnc_error_dialog (window,
2466 _ (
"This transaction is marked read-only with the comment: '%s'"), reason);
2470 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
2473 builder = gtk_builder_new();
2474 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
2475 "void_transaction_dialog");
2476 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
2477 "void_transaction_dialog"));
2478 entry = GTK_WIDGET (gtk_builder_get_object (builder,
"reason"));
2480 gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
2482 result = gtk_dialog_run (GTK_DIALOG (dialog));
2483 if (result == GTK_RESPONSE_OK)
2485 reason = gtk_entry_get_text (GTK_ENTRY (entry));
2492 gtk_widget_destroy (dialog);
2493 g_object_unref (G_OBJECT (builder));
2498 gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple,
2502 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2507 ENTER (
"(action %p, page %p)", simple, page);
2509 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2511 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2520 static std::optional<time64>
2521 input_date (GtkWidget * parent,
const char *window_title,
const char* title)
2524 if (!gnc_dup_time64_dialog (parent, window_title, title, &rv))
2531 gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
2535 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2539 Transaction* trans, *new_trans;
2544 ENTER (
"(action %p, page %p)", simple, page);
2546 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2548 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2560 LEAVE (
"shouldn't try to reverse the blank transaction...");
2567 const char *rev = _(
"A reversing entry has already been created for this transaction.");
2568 const char *jump = _(
"Jump to the transaction?");
2569 if (!gnc_verify_dialog (GTK_WINDOW (window), TRUE,
"%s\n\n%s", rev, jump))
2571 LEAVE (
"reverse cancelled");
2577 auto date = input_date (window, _(
"Reverse Transaction"), _(
"New Transaction Information"));
2580 LEAVE (
"reverse cancelled");
2584 gnc_suspend_gui_refresh ();
2591 gnc_resume_gui_refresh();
2596 split = xaccTransFindSplitByAccount(new_trans, account);
2599 if (gnc_split_reg_clear_filter_for_split (gsr, split))
2602 gnc_split_reg_jump_to_split (gsr, split);
2610 GNCLedgerDisplayType ledger_type = gnc_ledger_display_type (priv->ledger);
2613 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
2619 case GENERAL_JOURNAL:
2624 case PORTFOLIO_LEDGER:
2634 gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple,
2638 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2641 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
2642 ENTER (
"(action %p, page %p)", simple, page);
2644 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
2645 if (priv->sd.dialog)
2647 gtk_window_present (GTK_WINDOW (priv->sd.dialog));
2648 LEAVE(
"existing dialog");
2653 bool show_save_button = gnc_plugin_page_register_show_fs_save (page);
2656 &priv->sd, show_save_button);
2660 gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple,
2664 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2667 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
2668 ENTER (
"(action %p, page %p)", simple, page);
2670 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(page);
2671 if (priv->fd.dialog)
2673 gtk_window_present (GTK_WINDOW(priv->fd.dialog));
2674 LEAVE (
"existing dialog");
2679 bool show_save_button = gnc_plugin_page_register_show_fs_save (page);
2682 &priv->fd, show_save_button);
2688 gnc_plugin_page_register_cmd_reload (GSimpleAction *simple,
2692 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2696 ENTER (
"(action %p, page %p)", simple, page);
2698 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2700 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2706 LEAVE (
"register has pending edits");
2714 gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple,
2715 GVariant *parameter,
2718 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2722 ENTER (
"(action %p, page %p)", simple, page);
2724 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2726 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2730 g_action_change_state (G_ACTION(simple), parameter);
2732 gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh);
2734 gnc_plugin_page_register_ui_update (NULL, page);
2739 gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple,
2740 GVariant *parameter,
2743 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2746 gboolean use_double_line;
2749 ENTER (
"(action %p, page %p)", simple, page);
2751 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
2753 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2756 state = g_action_get_state (G_ACTION(simple));
2758 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
2760 use_double_line = !g_variant_get_boolean (state);
2762 if (use_double_line != reg->use_double_line)
2765 if (priv->enable_refresh)
2768 g_variant_unref (state);
2773 gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple,
2777 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2779 GncWindow* gnc_window;
2782 ENTER (
"(action %p, page %p)", simple, page);
2784 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2787 gnc_window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
2788 window = GTK_WIDGET (gnc_window_get_gtk_window (gnc_window));
2789 gnc_xfer_dialog (window, account);
2794 gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple,
2798 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2801 RecnWindow* recnData;
2803 ENTER (
"(action %p, page %p)", simple, page);
2805 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2815 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
2820 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
2822 recnData = recnWindow (GTK_WIDGET (window), account);
2823 gnc_ui_reconcile_window_raise (recnData);
2828 gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple,
2832 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2836 ENTER (
"(action %p, page %p)", simple, page);
2838 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2839 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
2841 gnc_stock_transaction_assistant (GTK_WIDGET (window), account);
2847 gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple,
2851 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2854 AutoClearWindow* autoClearData;
2856 ENTER (
"(action %p, page %p)", simple, page);
2858 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2862 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
2864 autoClearData = autoClearWindow (GTK_WIDGET (window), account);
2865 gnc_ui_autoclear_window_raise (autoClearData);
2870 gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple,
2874 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2878 ENTER (
"(action %p, page %p)", simple, page);
2880 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2883 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
2884 gnc_stock_split_dialog (GTK_WIDGET (window), account);
2889 gnc_plugin_page_register_cmd_lots (GSimpleAction *simple,
2893 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2897 ENTER (
"(action %p, page %p)", simple, page);
2899 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2901 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
2904 gnc_lot_viewer_dialog (window, account);
2909 gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple,
2913 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2916 ENTER (
"(action %p, page %p)", simple, page);
2918 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2920 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2921 gnc_split_reg_enter (priv->gsr, FALSE);
2926 gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple,
2930 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2933 ENTER (
"(action %p, page %p)", simple, page);
2935 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2937 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2944 gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple,
2948 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2951 ENTER (
"(action %p, page %p)", simple, page);
2953 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2955 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2956 gsr_default_delete_handler (priv->gsr, NULL);
2962 gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple,
2966 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2969 ENTER (
"(action %p, page %p)", simple, page);
2971 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2973 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2974 gsr_default_doclink_handler (priv->gsr);
2975 gnc_plugin_page_register_ui_update (NULL, page);
2980 gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple,
2984 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2987 ENTER (
"(action %p, page %p)", simple, page);
2989 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2991 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2992 gsr_default_doclink_open_handler (priv->gsr);
2997 invoice_from_split (Split* split)
2999 GncInvoice* invoice;
3018 gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple,
3022 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3025 GncInvoice* invoice;
3029 ENTER (
"(action %p, page %p)", simple, page);
3031 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3032 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3036 window = GNC_PLUGIN_PAGE(page)->window;
3040 auto invoices = invoices_from_transaction (txn);
3041 if (invoices.empty())
3042 PERR (
"shouldn't happen: if no invoices, function is never called");
3043 else if (invoices.size() == 1)
3044 invoice = invoices[0];
3047 GList *details = NULL;
3050 for (
const auto& inv : invoices)
3055 gnc_account_print_info (gncInvoiceGetPostedAcc (inv), TRUE));
3056 details = g_list_prepend
3061 g_strdup_printf (_(
"%s %s from %s, posted %s, amount %s"),
3062 gncInvoiceGetTypeString (inv),
3063 gncInvoiceGetID (inv),
3064 gncOwnerGetName (gncInvoiceGetOwner (inv)),
3068 details = g_list_reverse (details);
3069 choice = gnc_choose_radio_option_dialog
3070 (window, _(
"Select Business Item"),
3071 _(
"Several business items are linked with this transaction. \ 3072 Please choose one:"), _(
"Select"), 0, details);
3073 if ((choice >= 0) && ((
size_t)choice < invoices.size()))
3074 invoice = invoices[choice];
3075 g_list_free_full (details, g_free);
3081 GtkWindow *gtk_window = gnc_window_get_gtk_window (GNC_WINDOW (window));
3082 gnc_ui_invoice_edit (gtk_window, invoice);
3089 gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple,
3093 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3097 ENTER (
"(action %p, page %p)", simple, page);
3099 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3101 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3107 gnc_split_reg_jump_to_blank (priv->gsr);
3112 find_after_date (Split *split,
time64* find_date)
3121 gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
3125 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3131 ENTER (
"(action %p, page %p)", simple, page);
3132 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3134 auto date = input_date (window, _(
"Go to Date"), _(
"Go to Date"));
3138 LEAVE (
"goto_date cancelled");
3149 auto it = g_list_find_custom (splits, &date.value(), (GCompareFunc)find_after_date);
3152 gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(it->data));
3154 gnc_split_reg_jump_to_blank (gsr);
3156 g_list_free (splits);
3161 gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple,
3165 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3168 ENTER (
"(action %p, page %p)", simple, page);
3170 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3172 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3179 gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple,
3183 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3186 ENTER (
"(action %p, page %p)", simple, page);
3188 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3190 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3191 gsr_default_reinit_handler (priv->gsr, NULL);
3196 gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple,
3197 GVariant *parameter,
3200 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3206 ENTER (
"(action %p, page %p)", simple, page);
3208 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3210 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3213 state = g_action_get_state (G_ACTION(simple));
3215 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
3217 expand = !g_variant_get_boolean (state);
3220 g_variant_unref (state);
3227 gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple,
3231 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3235 ENTER (
"(action %p, page %p)", simple, page);
3237 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3239 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3248 jump_multiple_splits_by_single_account (
Account *account, Split *split)
3252 Account *other_account = NULL;
3253 Split *other_split = NULL;
3261 Split *s = (Split*)splits->data;
3264 if (!xaccTransStillHasSplit(trans, s))
3272 if (other_account != a)
3284 other_split = split;
3290 jump_multiple_splits_by_value (
Account *account, Split *split, gboolean largest)
3294 Split *other_split = NULL;
3296 int cmp = largest ? 1 : -1;
3304 Split *s = (Split*)splits->data;
3307 if (!xaccTransStillHasSplit(trans, s))
3329 other_split = split;
3335 jump_multiple_splits (
Account* account, Split *split)
3337 GncPrefJumpMultSplits mode = (GncPrefJumpMultSplits)
gnc_prefs_get_enum(GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_JUMP_MULT_SPLITS);
3341 case JUMP_LARGEST_VALUE_FIRST_SPLIT:
3342 return jump_multiple_splits_by_value (account, split, TRUE);
3344 case JUMP_SMALLEST_VALUE_FIRST_SPLIT:
3345 return jump_multiple_splits_by_value (account, split, FALSE);
3353 return jump_multiple_splits_by_single_account (account, split);
3357 gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
3361 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3371 gboolean multiple_splits;
3373 ENTER (
"(action %p, page %p)", simple, page);
3375 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3377 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3378 window = GNC_PLUGIN_PAGE (page)->window;
3381 LEAVE (
"no window");
3389 LEAVE (
"no split (1)");
3394 if (account == NULL)
3396 LEAVE (
"no account");
3401 multiple_splits = other_split == NULL;
3404 if (account == leader)
3407 if (cursor_class == CURSOR_CLASS_SPLIT)
3426 LEAVE (
"split for this account");
3430 if (multiple_splits)
3432 other_split = jump_multiple_splits (account, split);
3434 if (other_split == NULL)
3436 GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window),
3437 (GtkDialogFlags)(GTK_DIALOG_MODAL
3438 | GTK_DIALOG_DESTROY_WITH_PARENT),
3442 _(
"Unable to jump to other account"));
3444 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
3445 "%s", _(
"This transaction involves more than one other account. Select a specific split to jump to that account."));
3446 gtk_dialog_add_button (GTK_DIALOG(dialog), _(
"_OK"), GTK_RESPONSE_OK);
3447 gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_MULTIPLE_SPLITS);
3448 gtk_widget_destroy (dialog);
3450 LEAVE (
"no split (2)");
3454 split = other_split;
3457 if (account == NULL)
3459 LEAVE (
"no account (2)");
3463 if (account == leader)
3465 GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window),
3466 (GtkDialogFlags)(GTK_DIALOG_MODAL
3467 | GTK_DIALOG_DESTROY_WITH_PARENT),
3471 _(
"Unable to jump to other account"));
3473 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
3474 "%s", _(
"This transaction only involves the current account so there is no other account to jump to."));
3475 gtk_dialog_add_button (GTK_DIALOG(dialog), _(
"_OK"), GTK_RESPONSE_OK);
3476 gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_SINGLE_ACCOUNT);
3477 gtk_widget_destroy (dialog);
3479 LEAVE (
"register open for account");
3485 if (new_plugin_page == NULL)
3487 LEAVE (
"couldn't create new page");
3495 gboolean jump_twice = FALSE;
3501 if (new_page_reg->style != REG_STYLE_JOURNAL)
3505 if (gnc_split_reg_clear_filter_for_split (gsr, split))
3508 gnc_split_reg_jump_to_split (gsr, split);
3510 if (multiple_splits && jump_twice)
3516 gnc_split_reg_jump_to_split (gsr, split);
3522 gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple,
3526 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3530 ENTER (
"(action %p, page %p)", simple, page);
3532 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3536 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3537 gsr_default_schedule_handler (priv->gsr, window);
3542 scrub_split (Split *split)
3548 g_return_if_fail (split);
3552 g_return_if_fail (trans);
3564 gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple,
3568 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3573 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3575 ENTER (
"(action %p, page %p)", simple, page);
3577 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3581 LEAVE (
"no query found");
3587 gnc_suspend_gui_refresh();
3589 gnc_resume_gui_refresh();
3594 scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data)
3596 if (event->length == 0)
return FALSE;
3598 switch (event->keyval)
3600 case GDK_KEY_Escape:
3602 auto abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget),
false,
3603 "%s", _(check_repair_abort_YN));
3617 gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple,
3621 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3625 GList* node, *splits;
3626 gint split_count = 0, curr_split_no = 0;
3627 gulong scrub_kp_handler_ID;
3628 const char* message = _ (
"Checking splits in current register: %u of %u");
3630 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3632 ENTER (
"(action %p, page %p)", simple, page);
3634 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3638 LEAVE (
"no query found");
3642 gnc_suspend_gui_refresh();
3643 is_scrubbing = TRUE;
3645 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3646 scrub_kp_handler_ID = g_signal_connect (G_OBJECT (window),
"key-press-event",
3647 G_CALLBACK (scrub_kp_handler), NULL);
3648 gnc_window_set_progressbar_window (window);
3651 split_count = g_list_length (splits);
3652 for (node = splits; node && !gnc_get_abort_scrub (); node = node->next, curr_split_no++)
3654 auto split = GNC_SPLIT(node->data);
3656 if (!split)
continue;
3658 PINFO (
"Start processing split %d of %d",
3659 curr_split_no + 1, split_count);
3661 scrub_split (split);
3663 PINFO (
"Finished processing split %d of %d",
3664 curr_split_no + 1, split_count);
3666 if (curr_split_no % 10 == 0)
3668 char* progress_msg = g_strdup_printf (message, curr_split_no, split_count);
3669 gnc_window_show_progress (progress_msg, (100 * curr_split_no) / split_count);
3670 g_free (progress_msg);
3674 g_signal_handler_disconnect (G_OBJECT(window), scrub_kp_handler_ID);
3675 gnc_window_show_progress (NULL, -1.0);
3676 is_scrubbing = FALSE;
3677 show_abort_verify = TRUE;
3680 gnc_resume_gui_refresh();
3685 gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple,
3689 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3691 GncMainWindow* window;
3694 ENTER (
"(action %p, page %p)", simple, page);
3696 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3698 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3699 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3700 id = report_helper (priv->ledger, NULL, NULL);
3702 gnc_main_window_open_report (
id, window);
3707 gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple,
3711 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3713 GncMainWindow* window;
3720 ENTER (
"(action %p, page %p)", simple, page);
3722 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3724 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3731 query = qof_query_create_for (GNC_ID_SPLIT);
3736 GNC_ID_SPLIT, QOF_QUERY_AND);
3738 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3739 id = report_helper (priv->ledger, split, query);
3741 gnc_main_window_open_report (
id, window);
3757 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
3759 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
3760 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3761 priv->lines_default = lines_default;
3762 priv->read_only = read_only;
3771 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
3773 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
3774 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3782 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page), NULL);
3793 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(plugin_page), NULL);
3802 gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
3810 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3812 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3822 (GNC_MAIN_WINDOW(window)) != GNC_PLUGIN_PAGE(page)))
3826 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3828 help = gnc_table_get_help (reg->table);
3829 gnc_window_set_status (window, GNC_PLUGIN_PAGE (page), help);
3834 gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
3839 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3841 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3849 GNC_PLUGIN_PAGE (page));
3853 gnc_plugin_page_register_refresh_cb (GHashTable* changes, gpointer user_data)
3855 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3858 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3859 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3864 ei = gnc_gui_get_entity_events (changes, &priv->key);
3867 if (ei->event_mask & QOF_EVENT_DESTROY)
3872 if (ei->event_mask & QOF_EVENT_MODIFY)
3880 gnucash_register_refresh_from_prefs (priv->gsr->reg);
3881 gtk_widget_queue_draw (priv->widget);
3884 gnc_plugin_page_register_ui_update (NULL, page);
3888 gnc_plugin_page_register_close_cb (gpointer user_data)
3903 gppr_account_destroy_cb (
Account* account)
3907 GNCLedgerDisplayType ledger_type;
3910 GList* item, *kill = NULL;
3917 for (; citem; citem = g_list_next (citem))
3920 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3921 ledger_type = gnc_ledger_display_type (priv->ledger);
3922 if (ledger_type == LD_GL)
3924 kill = g_list_prepend (kill, page);
3927 else if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
3929 if (guid_compare (acct_guid, &priv->key) == 0)
3931 kill = g_list_prepend (kill, page);
3936 kill = g_list_reverse (kill);
3938 for (item = kill; item; item = g_list_next (item))
3961 gnc_plugin_page_register_event_handler (
QofInstance* entity,
3971 g_return_if_fail (page);
3972 if (!GNC_IS_TRANS (entity) && !GNC_IS_ACCOUNT (entity))
3975 ENTER (
"entity %p of type %d, page %p, event data %p",
3976 entity, event_type, page, ed);
3980 if (GNC_IS_ACCOUNT (entity))
3982 if (GNC_IS_MAIN_WINDOW (window))
3988 LEAVE (
"account is NULL");
3992 gchar *name = gnc_plugin_page_register_get_tab_name (GNC_PLUGIN_PAGE (page));
3995 gchar *long_name = gnc_plugin_page_register_get_long_name (GNC_PLUGIN_PAGE (page));
3998 gchar *color = gnc_plugin_page_register_get_tab_color (GNC_PLUGIN_PAGE (page));
4001 gnc_plugin_page_register_update_page_icon (GNC_PLUGIN_PAGE (page));
4007 LEAVE (
"tab contents updated");
4011 if (! (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
4013 LEAVE (
"not a modify");
4016 trans = GNC_TRANS (entity);
4020 LEAVE (
"not in this book");
4024 if (GNC_IS_MAIN_WINDOW (window))
4027 if (visable_plugin_page != GNC_PLUGIN_PAGE (page))
4029 LEAVE (
"page not visible");
4034 gnc_plugin_page_register_ui_update (NULL, page);
CursorClass gnc_split_register_get_current_cursor_class(SplitRegister *reg)
Returns the class of a register's current cursor.
Split * gnc_split_register_get_current_trans_split(SplitRegister *reg, VirtualCellLocation *trans_split_loc)
Gets the anchoring split of the transaction at the current cursor location, which may be on the trans...
void gnc_ledger_display_close(GNCLedgerDisplay *ld)
close the window
GncPluginPage * gnc_plugin_page_register_new(Account *account, gboolean subaccounts)
Create a new "register" plugin page, given a pointer to an account.
void gnc_ledger_display_set_focus(GNCLedgerDisplay *ld, gboolean focus)
Mark the ledger as being in focus (refresh immediately) or not.
Functions to load, save and get gui state.
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
Retrieve a pointer to the GncMainWindow (GtkWindow) containing this page.
gboolean xaccTransHasReconciledSplits(const Transaction *trans)
FIXME: document me.
void gnc_ledger_display_refresh(GNCLedgerDisplay *ld)
redisplay/redraw only the indicated window.
const gchar * tab_icon
The relative name of the icon that should be shown on the tab for this page.
const char * gnc_split_register_get_credit_string(SplitRegister *reg)
Return the credit string used in the register.
gboolean(* focus_page_function)(GncPluginPage *plugin_page)
This function performs specific actions to set the focus on a specific widget.
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
void gnc_plugin_register_set_enable_refresh(GncPluginPageRegister *page, gboolean enable_refresh)
This allows controlling when refreshes happen, used to reduce refreshes when different aspects of the...
void gnc_main_window_update_menu_and_toolbar(GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates)
Update the main window menu with the placeholders listed in ui_updates and load the page specific too...
void(* focus_page)(GncPluginPage *plugin_page, gboolean on_current_page)
Perform plugin specific actions to set the focus.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
The instance data structure for a content plugin.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
Returns TRUE if this Transaction is read-only because its posted-date is older than the "auto-readonl...
Date and Time handling routines.
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Register a callback that gets triggered when the given preference changes.
gboolean gnc_split_register_save(SplitRegister *reg, gboolean do_commit)
Copy the contents of the current cursor to a split.
This file contains the functions to present a gui to the user for creating a new account or editing a...
void gnc_split_register_unvoid_current_trans(SplitRegister *reg)
Unvoids the transaction associated with the current cursor, if non-NULL.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
gboolean xaccAccountIsPriced(const Account *acc)
Returns true if the account is a stock, mutual fund or currency, otherwise false. ...
void(* QofEventHandler)(QofInstance *ent, QofEventId event_type, gpointer handler_data, gpointer event_data)
Handler invoked when an event is generated.
void gnc_split_register_expand_current_trans(SplitRegister *reg, gboolean expand)
Expand the current transaction if it is collapsed.
utility functions for the GnuCash UI
#define PINFO(format, args...)
Print an informational note.
void gnc_main_window_set_vis_of_items_by_action(GncMainWindow *window, const gchar **action_names, gboolean vis)
Show or hide menu and toolbar items based on a NULL terminated list of action names.
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Transaction * gnc_split_register_get_current_trans(SplitRegister *reg)
Gets the transaction at the current cursor location, which may be on the transaction itself or on any...
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
Create a new page based on the information saved during a previous instantiation of gnucash...
FilterData * gnc_plugin_page_register_get_filter_data(GncPluginPage *plugin_page)
Get the FilterData data structure associated with this register page.
gboolean gnc_menubar_model_find_item(GMenuModel *menu_model, GncMenuModelSearch *gsm)
Find a GtkMenu item from the action name.
const char * xaccTransGetReadOnly(Transaction *trans)
Returns a non-NULL value if this Transaction was marked as read-only with some specific "reason" text...
#define DEBUG(format, args...)
Print a debugging message.
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Given a string, replace the given guid with the parsed one unless the given value is null...
Functions that are supported by all types of windows.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
gpointer gnc_account_foreach_descendant_until(const Account *acc, AccountCb2 thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling 'func' on each...
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
QofQuery * qof_query_copy(QofQuery *q)
Make a copy of the indicated query.
gboolean qof_query_equal(const QofQuery *q1, const QofQuery *q2)
Compare two queries for equality.
GtkWidget * window
The window that contains the display widget for this plugin.
Account * gnc_ledger_display_leader(GNCLedgerDisplay *ld)
Implementations.
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
Set the long name of this page.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
GSimpleActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
Create the GSimpleActionGroup object associated with this page.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
void gnc_ledger_display_set_query(GNCLedgerDisplay *ledger_display, Query *q)
Set the query used for a register.
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b.
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
Cleanup functions for business objects.
gnc_numeric gncInvoiceGetTotal(GncInvoice *invoice)
Return the "total" amount of the invoice as seen on the document (and shown to the user in the report...
void gnc_ui_edit_account_window(GtkWindow *parent, Account *account)
Display a window for editing the attributes of an existing account.
gboolean gnc_split_register_current_trans_expanded(SplitRegister *reg)
Return TRUE if current trans is expanded and style is REG_STYLE_LEDGER.
GncPluginPage * gnc_main_window_get_current_page(GncMainWindow *window)
Retrieve a pointer to the page that is currently at the front of the specified window.
const char * xaccTransGetDocLink(const Transaction *trans)
Gets the transaction Document Link.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Query * gnc_ledger_display_get_query(GNCLedgerDisplay *ld)
return the query associated with a ledger
Functions for adding content to a window.
GncPluginPage * gnc_plugin_page_register_new_ledger(GNCLedgerDisplay *ledger)
Create a new "register" plugin page, given a pointer to an already created ledger.
void(* update_edit_menu_actions)(GncPluginPage *plugin_page, gboolean hide)
This function vector allows page specific actions to override the generic code for setting the sensit...
#define VREC
split is void
void(* destroy_widget)(GncPluginPage *plugin_page)
Function called to destroy the display widget for a particular type of plugin.
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
void main_window_update_page_long_name(GncPluginPage *page, const gchar *long_name_in)
Update the long name of the page in the main window.
const char * xaccAccountGetColor(const Account *acc)
Get the account's color.
int xaccTransCountSplits(const Transaction *trans)
Returns the number of splits in this transaction.
GNCLedgerDisplay * gnc_ledger_display_subaccounts(Account *account, gboolean mismatched_commodities)
opens up a register window to display the parent account and all of its children. ...
#define xaccAccountGetGUID(X)
void gnc_set_abort_scrub(gboolean abort)
The gnc_set_abort_scrub () method causes a currently running scrub operation to stop, if abort is TRUE; gnc_set_abort_scrub(FALSE) must be called before any scrubbing operation.
convert single-entry accounts to clean double-entry
char * qof_print_date(time64 secs)
Convenience; calls through to qof_print_date_dmy_buff().
gboolean gnc_main_window_is_quitting(GncMainWindow *window)
Check if the main window is quitting.
GList SplitList
GList of Split.
gboolean xaccTransHasSplitsInState(const Transaction *trans, const char state)
FIXME: document me.
gboolean gnc_split_register_has_copied_item(void)
Return TRUE if copied_item holds a transaction or split.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
void gnc_split_register_redraw(SplitRegister *reg)
Causes a redraw of the register window associated with reg.
Functions providing a register page for the GnuCash UI.
const char * gnc_split_register_get_debit_string(SplitRegister *reg)
Return the debit string used in the register.
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
Update the color on the page tabs in the main window.
The class data structure for a content plugin.
void qof_query_destroy(QofQuery *query)
Frees the resources associate with a Query object.
gint QofEventId
Define the type of events allowed.
void gnc_plugin_page_set_use_new_window(GncPluginPage *page, gboolean use_new)
Set the "use new window" setting associated with this page.
CursorClass
Types of cursors.
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Transaction * gnc_plugin_page_register_get_current_txn(GncPluginPageRegister *page)
Get the currently selected transaction in this register page.
gboolean gnc_split_register_changed(SplitRegister *reg)
Returns TRUE if the register has changed cells.
void xaccTransScrubImbalance(Transaction *trans, Account *root, Account *account)
Correct transaction imbalances.
void gnc_plugin_page_disconnect_page_changed(GncPluginPage *page)
Disconnect the page_changed_id signal callback.
gint gnc_prefs_get_enum(const gchar *group, const gchar *pref_name)
Get an enum value from the preferences backend.
gboolean gncScrubBusinessSplit(Split *split)
The gncScrubBusinessSplit() function will fix all issues found with the given split.
void qof_query_set_book(QofQuery *query, QofBook *book)
Set the book to be searched.
gboolean gnc_plugin_page_has_book(GncPluginPage *page, QofBook *book)
Query a page to see if it has a reference to a given book.
void(* window_changed)(GncPluginPage *plugin_page, GtkWidget *window)
Perform plugin specific actions when a page is added to a window (or has been removed from one window...
gboolean gnc_main_window_popup_menu_cb(GtkWidget *widget, GncPluginPage *page)
Callback function invoked when the user requests that Gnucash popup the contextual menu via the keybo...
const gchar * plugin_name
The textual name of this plugin.
void gnc_ppr_filter_set_tooltip(GncPluginPage *plugin_page, FilterData *fd)
This function is used to update the tooltip shown in the register which shows a summary of the curren...
void gnc_split_register_config(SplitRegister *reg, SplitRegisterType newtype, SplitRegisterStyle newstyle, gboolean use_double_line)
Sets a split register's type, style or line use.
void qof_event_unregister_handler(gint handler_id)
Unregister an event handler.
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Function called to create the display widget for a particular type of plugin.
void gnc_ppr_filter_update_register(GncPluginPage *plugin_page)
This function is called to update the register.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
The gnc_account_lookup_full_name() subroutine works like gnc_account_lookup_by_name, but uses fully-qualified names using the given separator.
void gnc_split_register_void_current_trans(SplitRegister *reg, const char *reason)
Voids the transaction associated with the current cursor, if non-NULL.
void gnc_ppr_filter_by(GncPluginPage *plugin_page, Query *query, FilterData *fd, bool show_save_button)
This function is called for the filter dialog.
void xaccTransScrubOrphans(Transaction *trans)
The xaccTransScrubOrphans() method scrubs only the splits in the given transaction.
Gnome specific utility functions.
Public declarations of GnucashRegister class.
gboolean xaccAccountIsAPARType(GNCAccountType t)
Convenience function to check if the account is a valid business account type (meaning an Accounts Pa...
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
SortData * gnc_plugin_page_register_get_sort_data(GncPluginPage *plugin_page)
Get the SortData data structure associated with this register page.
Additional event handling code.
#define xaccSplitGetGUID(X)
gboolean(* finish_pending)(GncPluginPage *plugin_page)
This function vector is called to finish any outstanding activities.
All type declarations for the whole Gnucash engine.
#define CREC
The Split has been cleared.
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
Save enough information about this page so that it can be recreated next time the user starts gnucash...
gnc_commodity * gnc_account_get_currency_or_parent(const Account *account)
Returns a gnc_commodity that is a currency, suitable for being a Transaction's currency.
Generic api to store and retrieve preferences.
Split * gnc_split_register_duplicate_current(SplitRegister *reg)
Duplicates either the current transaction or the current split depending on the register mode and cur...
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
Query * gnc_plugin_page_register_get_query(GncPluginPage *plugin_page)
This function is called to get the query associated with this plugin page.
void gnc_split_register_cancel_cursor_trans_changes(SplitRegister *reg)
Cancels any changes made to the current pending transaction, reloads the table from the engine...
GncInvoice * gncInvoiceGetInvoiceFromLot(GNCLot *lot)
Given a LOT, find and return the Invoice attached to the lot.
void gnc_split_register_paste_current(SplitRegister *reg)
Pastes a previous copied entity onto the current entity, but only if the copied and current entity ha...
Transaction * xaccTransReverse(Transaction *orig)
xaccTransReverse creates a Transaction that reverses the given transaction by inverting all the numer...
GList * qof_query_run(QofQuery *query)
Perform the query, return the results.
void main_window_update_page_set_read_only_icon(GncPluginPage *page, gboolean read_only)
Update the icon on the page tabs in the main window.
gboolean qof_book_is_readonly(const QofBook *book)
Return whether the book is read only.
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
Set the color of this page.
GncPluginPage * gnc_plugin_page_register_new_gl(void)
Create a new "register" plugin page containing a general journal.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
GNCLedgerDisplay * gnc_ledger_display_simple(Account *account)
opens up a register window to display a single account
gboolean gncScrubBusinessLot(GNCLot *lot)
The gncScrubBusinessLot() function makes sure that the indicated lot has all the correct properties r...
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
void gnc_ppr_sort_dialog(GncPluginPage *plugin_page, SplitRegister *reg, SortData *sd, bool show_save_button)
This function is called for the sort dialog.
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
void gnc_plugin_page_set_menu_popup_qualifier(GncPluginPage *page, const char *menu_qualifier)
Set a qualifier string for this page.
void gnc_plugin_page_inserted_cb(GncPluginPage *page, gpointer user_data)
Set up the page_changed callback for when the current page is changed.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
Transaction * xaccTransGetReversedBy(const Transaction *trans)
Returns the transaction that reversed the given transaction.
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits...
#define LEAVE(format, args...)
Print a function exit debugging message.
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
Set the name of this page.
time64 gnc_time(time64 *tbuf)
get the current time
Account * gnc_plugin_page_register_get_account(GncPluginPageRegister *page)
Get the Account associated with this register page.
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
Add a book reference to the specified page.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a)
Check for error signal in value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void gnc_plugin_page_register_query_update(GncPluginPageRegister *page, Query *query)
This updates the query after the filters have been applied.
gboolean gnc_split_register_handle_exchange(SplitRegister *reg, gboolean force_dialog)
If needed display the transfer dialog to get a price/exchange rate and adjust the price cell accordin...
void gnc_plugin_page_register_clear_current_filter(GncPluginPage *plugin_page)
This function clears the registers current filter.
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Modify the date of when the transaction was entered.
GNCLedgerDisplay * gnc_ledger_display_gl(void)
opens up a general ledger window
SplitRegister * gnc_ledger_display_get_split_register(GNCLedgerDisplay *ld)
return the split register associated with a ledger display
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
void gnc_plugin_page_register_update_for_search_query(GncPluginPageRegister *page)
This checks if the register is a search register and if so saves the query.
The type used to store guids in C.
GNCSplitReg * gnc_plugin_page_register_get_gsr(GncPluginPage *plugin_page)
Get the GNCSplitReg data structure associated with this register page.
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.
gboolean gnc_menubar_model_update_item(GMenuModel *menu_model, const gchar *action_name, const gchar *target, const gchar *label, const gchar *accel_name, const gchar *tooltip)
Update the GMenuModel item based on the action name by copying existing item, removing it and inserti...
GAction * gnc_plugin_page_get_action(GncPluginPage *page, const gchar *name)
Retrieve a GAction object associated with this page.
void gnc_ppr_sort_update_register(GncPluginPage *plugin_page)
This function is called to update the register.
Split * gnc_split_register_get_current_split(SplitRegister *reg)
Returns the split at which the cursor is currently located.
void gnc_plugin_page_register_set_options(GncPluginPage *plugin_page, gint lines_default, gboolean read_only)
Set various register options on a newly created "register" plugin page.
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
GtkWidget * summarybar
The summary bar widget (if any) that is associated with this plugin.
SplitRegisterStyle
Register styles.
GNCLot * xaccSplitGetLot(const Split *split)
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't be...
GList * qof_query_get_books(QofQuery *q)
Return the list of books we're using.
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)
Remove a function that was registered for a callback when the given preference changed.
void gnc_split_register_copy_current(SplitRegister *reg)
Makes a copy of the current entity, either a split or a transaction, so that it can be pasted later...
Utility functions for file access.
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...
void gnc_ppr_filter_clear_current_filter(GncPluginPage *plugin_page)
This function is used to clear the current filter so that a specific split can be shown in the regist...