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" 95 static QofLogModule log_module = GNC_MOD_GUI;
97 #define DEFAULT_LINES_AMOUNT 50 98 #define DEFAULT_FILTER_NUM_DAYS_GL "30" 100 static void gnc_plugin_page_register_finalize (GObject*
object);
104 static GtkWidget* gnc_plugin_page_register_create_widget (
106 static void gnc_plugin_page_register_destroy_widget (
GncPluginPage*
108 static void gnc_plugin_page_register_window_changed (
GncPluginPage*
109 plugin_page, GtkWidget* window);
110 static gboolean gnc_plugin_page_register_focus_widget (
GncPluginPage*
112 static void gnc_plugin_page_register_focus (
GncPluginPage* plugin_page,
113 gboolean current_page);
114 static void gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
115 GKeyFile* file,
const gchar* group);
116 static GncPluginPage* gnc_plugin_page_register_recreate_page (
117 GtkWidget* window, GKeyFile* file,
const gchar* group);
118 static void gnc_plugin_page_register_update_edit_menu (
GncPluginPage* page,
120 static gboolean gnc_plugin_page_register_finish_pending (
GncPluginPage* page);
122 static gchar* gnc_plugin_page_register_get_tab_name (
GncPluginPage*
124 static gchar* gnc_plugin_page_register_get_tab_color (
GncPluginPage*
126 static gchar* gnc_plugin_page_register_get_long_name (
GncPluginPage*
129 static void gnc_plugin_page_register_summarybar_position_changed (
130 gpointer prefs, gchar* pref, gpointer user_data);
145 static gchar* gnc_plugin_page_register_get_sort_order (
GncPluginPage*
147 void gnc_plugin_page_register_set_sort_order (
GncPluginPage* plugin_page,
148 const gchar* sort_order);
149 static gboolean gnc_plugin_page_register_get_sort_reversed (
151 void gnc_plugin_page_register_set_sort_reversed (
GncPluginPage* plugin_page,
152 gboolean reverse_order);
177 static time64 gnc_plugin_page_register_filter_dmy2time (
char* date_string);
178 static gchar* gnc_plugin_page_register_filter_time2dmy (
time64 raw_time);
179 static gchar* gnc_plugin_page_register_get_filter (
GncPluginPage* plugin_page);
180 void gnc_plugin_page_register_set_filter (
GncPluginPage* plugin_page,
181 const gchar* filter);
188 static void gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
189 static void gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
190 static void gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
191 static void gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
192 static void gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
193 static void gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
194 static void gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
195 static void gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
196 static void gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
197 static void gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
198 static void gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
199 static void gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
200 static void gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
201 static void gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
202 static void gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
203 static void gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
205 static void gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
206 static void gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
207 static void gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
209 static void gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
210 static void gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
211 static void gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
212 static void gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
213 static void gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
214 static void gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
215 static void gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
216 static void gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
217 static void gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
218 static void gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
219 static void gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
220 static void gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
221 static void gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
222 static void gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
223 static void gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
224 static void gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
225 static void gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
226 static void gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
227 static void gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
228 static void gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
229 static void gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
230 static void gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
231 static void gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
232 static void gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
234 static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
236 static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
238 static void gnc_plugin_page_register_refresh_cb (GHashTable* changes,
240 static void gnc_plugin_page_register_close_cb (gpointer user_data);
242 static void gnc_plugin_page_register_ui_update (gpointer various,
244 static void gppr_account_destroy_cb (
Account* account);
245 static void gnc_plugin_page_register_event_handler (
QofInstance* entity,
250 static GncInvoice* invoice_from_split (Split* split);
256 #define CUT_TRANSACTION_LABEL N_("Cu_t Transaction") 257 #define COPY_TRANSACTION_LABEL N_("_Copy Transaction") 258 #define PASTE_TRANSACTION_LABEL N_("_Paste Transaction") 259 #define DUPLICATE_TRANSACTION_LABEL N_("Dup_licate Transaction") 260 #define DELETE_TRANSACTION_LABEL N_("_Delete Transaction") 264 #define LINK_TRANSACTION_LABEL N_("_Manage Document Link…") 268 #define LINK_TRANSACTION_OPEN_LABEL N_("_Open Linked Document") 271 #define JUMP_LINKED_INVOICE_LABEL N_("Jump to Invoice") 272 #define CUT_SPLIT_LABEL N_("Cu_t Split") 273 #define COPY_SPLIT_LABEL N_("_Copy Split") 274 #define PASTE_SPLIT_LABEL N_("_Paste Split") 275 #define DUPLICATE_SPLIT_LABEL N_("Dup_licate Split") 276 #define DELETE_SPLIT_LABEL N_("_Delete Split") 277 #define CUT_TRANSACTION_TIP N_("Cut the selected transaction into clipboard") 278 #define COPY_TRANSACTION_TIP N_("Copy the selected transaction into clipboard") 279 #define PASTE_TRANSACTION_TIP N_("Paste the transaction from the clipboard") 280 #define DUPLICATE_TRANSACTION_TIP N_("Make a copy of the current transaction") 281 #define DELETE_TRANSACTION_TIP N_("Delete the current transaction") 282 #define LINK_TRANSACTION_TIP N_("Add, change, or unlink the document linked with the current transaction") 283 #define LINK_TRANSACTION_OPEN_TIP N_("Open the linked document for the current transaction") 284 #define JUMP_LINKED_INVOICE_TIP N_("Jump to the linked bill, invoice, or voucher") 285 #define CUT_SPLIT_TIP N_("Cut the selected split into clipboard") 286 #define COPY_SPLIT_TIP N_("Copy the selected split into clipboard") 287 #define PASTE_SPLIT_TIP N_("Paste the split from the clipboard") 288 #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split") 289 #define DELETE_SPLIT_TIP N_("Delete the current split") 291 static GActionEntry gnc_plugin_page_register_actions [] =
293 {
"FilePrintAction", gnc_plugin_page_register_cmd_print_check, NULL, NULL, NULL },
294 {
"EditCutAction", gnc_plugin_page_register_cmd_cut, NULL, NULL, NULL },
295 {
"EditCopyAction", gnc_plugin_page_register_cmd_copy, NULL, NULL, NULL },
296 {
"EditPasteAction", gnc_plugin_page_register_cmd_paste, NULL, NULL, NULL },
297 {
"EditEditAccountAction", gnc_plugin_page_register_cmd_edit_account, NULL, NULL, NULL },
298 {
"EditFindAccountAction", gnc_plugin_page_register_cmd_find_account, NULL, NULL, NULL },
299 {
"EditFindTransactionsAction", gnc_plugin_page_register_cmd_find_transactions, NULL, NULL, NULL },
300 {
"EditTaxOptionsAction", gnc_plugin_page_register_cmd_edit_tax_options, NULL, NULL, NULL },
301 {
"CutTransactionAction", gnc_plugin_page_register_cmd_cut_transaction, NULL, NULL, NULL },
302 {
"CopyTransactionAction", gnc_plugin_page_register_cmd_copy_transaction, NULL, NULL, NULL },
303 {
"PasteTransactionAction", gnc_plugin_page_register_cmd_paste_transaction, NULL, NULL, NULL },
304 {
"DuplicateTransactionAction", gnc_plugin_page_register_cmd_duplicate_transaction, NULL, NULL, NULL },
305 {
"DeleteTransactionAction", gnc_plugin_page_register_cmd_delete_transaction, NULL, NULL, NULL },
306 {
"RemoveTransactionSplitsAction", gnc_plugin_page_register_cmd_reinitialize_transaction, NULL, NULL, NULL },
307 {
"RecordTransactionAction", gnc_plugin_page_register_cmd_enter_transaction, NULL, NULL, NULL },
308 {
"CancelTransactionAction", gnc_plugin_page_register_cmd_cancel_transaction, NULL, NULL, NULL },
309 {
"VoidTransactionAction", gnc_plugin_page_register_cmd_void_transaction, NULL, NULL, NULL },
310 {
"UnvoidTransactionAction", gnc_plugin_page_register_cmd_unvoid_transaction, NULL, NULL, NULL },
311 {
"ReverseTransactionAction", gnc_plugin_page_register_cmd_reverse_transaction, NULL, NULL, NULL },
312 {
"LinkTransactionAction", gnc_plugin_page_register_cmd_linked_transaction, NULL, NULL, NULL },
313 {
"LinkedTransactionOpenAction", gnc_plugin_page_register_cmd_linked_transaction_open, NULL, NULL, NULL },
314 {
"JumpLinkedInvoiceAction", gnc_plugin_page_register_cmd_jump_linked_invoice, NULL, NULL, NULL },
315 {
"ViewSortByAction", gnc_plugin_page_register_cmd_view_sort_by, NULL, NULL, NULL },
316 {
"ViewFilterByAction", gnc_plugin_page_register_cmd_view_filter_by, NULL, NULL, NULL },
317 {
"ViewRefreshAction", gnc_plugin_page_register_cmd_reload, NULL, NULL, NULL },
318 {
"ActionsTransferAction", gnc_plugin_page_register_cmd_transfer, NULL, NULL, NULL },
319 {
"ActionsReconcileAction", gnc_plugin_page_register_cmd_reconcile, NULL, NULL, NULL },
320 {
"ActionsAutoClearAction", gnc_plugin_page_register_cmd_autoclear, NULL, NULL, NULL },
321 {
"ActionsStockAssistantAction", gnc_plugin_page_register_cmd_stock_assistant, NULL, NULL, NULL },
322 {
"ActionsStockSplitAction", gnc_plugin_page_register_cmd_stock_split, NULL, NULL, NULL },
323 {
"ActionsLotsAction", gnc_plugin_page_register_cmd_lots, NULL, NULL, NULL },
324 {
"BlankTransactionAction", gnc_plugin_page_register_cmd_blank_transaction, NULL, NULL, NULL },
325 {
"GotoDateAction", gnc_plugin_page_register_cmd_goto_date, NULL, NULL, NULL },
326 {
"EditExchangeRateAction", gnc_plugin_page_register_cmd_exchange_rate, NULL, NULL, NULL },
327 {
"JumpTransactionAction", gnc_plugin_page_register_cmd_jump, NULL, NULL, NULL },
328 {
"ScheduleTransactionAction", gnc_plugin_page_register_cmd_schedule, NULL, NULL, NULL },
329 {
"ScrubAllAction", gnc_plugin_page_register_cmd_scrub_all, NULL, NULL, NULL },
330 {
"ScrubCurrentAction", gnc_plugin_page_register_cmd_scrub_current, NULL, NULL, NULL },
331 {
"ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL },
332 {
"ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL },
334 {
"ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL,
"false", NULL },
335 {
"SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL,
"false", NULL },
336 {
"ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed,
"i",
"@i 0", NULL },
338 static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions);
341 static const gchar *gnc_plugin_load_ui_items [] =
357 "ActionsPlaceholder4",
358 "ActionsPlaceholder5",
359 "ActionsPlaceholder6",
360 "ReportsPlaceholder1",
366 static const gchar* actions_requiring_account[] =
368 "EditEditAccountAction",
369 "ActionsReconcileAction",
370 "ActionsAutoClearAction",
375 static const gchar* actions_requiring_priced_account[] =
377 "ActionsStockAssistantAction",
384 {
"ActionsTransferAction", N_ (
"Transfer") },
385 {
"RecordTransactionAction", N_ (
"Enter") },
386 {
"CancelTransactionAction", N_ (
"Cancel") },
387 {
"DeleteTransactionAction", N_ (
"Delete") },
388 {
"DuplicateTransactionAction", N_ (
"Duplicate") },
389 {
"SplitTransactionAction",
391 N_ (
"Show Splits") },
392 {
"JumpTransactionAction", N_ (
"Jump") },
393 {
"ScheduleTransactionAction", N_ (
"Schedule") },
394 {
"BlankTransactionAction", N_ (
"Blank") },
395 {
"ActionsReconcileAction", N_ (
"Reconcile") },
396 {
"ActionsAutoClearAction", N_ (
"Auto-clear") },
397 {
"LinkTransactionAction", N_ (
"Manage Document Link") },
398 {
"LinkedTransactionOpenAction", N_ (
"Open Linked Document") },
399 {
"JumpLinkedInvoiceAction", N_ (
"Invoice") },
400 {
"ActionsStockAssistantAction", N_ (
"Stock Assistant") },
406 const char* action_name;
413 {
"filter_status_reconciled", CLEARED_RECONCILED, NULL },
414 {
"filter_status_cleared", CLEARED_CLEARED, NULL },
415 {
"filter_status_voided", CLEARED_VOIDED, NULL },
416 {
"filter_status_frozen", CLEARED_FROZEN, NULL },
417 {
"filter_status_unreconciled", CLEARED_NO, NULL },
421 #define CLEARED_VALUE "cleared_value" 422 #define DEFAULT_FILTER "0x001f" 423 #define DEFAULT_SORT_ORDER "BY_STANDARD" 431 GNCLedgerDisplay* ledger;
436 gint event_handler_id;
437 gint component_manager_id;
443 gboolean enable_refresh;
450 GtkWidget* num_radio;
451 GtkWidget* act_radio;
452 SortType original_sort_type;
453 gboolean original_save_order;
455 gboolean reverse_order;
456 gboolean original_reverse_order;
463 GtkWidget* start_date_choose;
464 GtkWidget* start_date_today;
465 GtkWidget* start_date;
466 GtkWidget* end_date_choose;
467 GtkWidget* end_date_today;
470 cleared_match_t original_cleared_match;
471 cleared_match_t cleared_match;
472 time64 original_start_time;
478 gboolean original_save_filter;
479 gboolean save_filter;
484 GNC_TYPE_PLUGIN_PAGE)
486 #define GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(o) \ 487 ((GncPluginPageRegisterPrivate*)gnc_plugin_page_register_get_instance_private((GncPluginPageRegister*)o)) 494 gnc_plugin_page_register_new_common (GNCLedgerDisplay* ledger)
507 if (!gnc_features_check_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER))
511 if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book()))
512 gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book());
515 gsr = GNC_SPLIT_REG(gnc_ledger_display_get_user_data (ledger));
519 for (; item; item = g_list_next (item))
522 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
523 if (priv->gsr == gsr)
524 return GNC_PLUGIN_PAGE (register_page);
528 register_page = GNC_PLUGIN_PAGE_REGISTER(g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER,
nullptr));
529 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
530 priv->ledger = ledger;
533 plugin_page = GNC_PLUGIN_PAGE (register_page);
534 label = gnc_plugin_page_register_get_tab_name (plugin_page);
538 label_color = gnc_plugin_page_register_get_tab_color (plugin_page);
540 g_free (label_color);
542 label = gnc_plugin_page_register_get_long_name (plugin_page);
548 for (item = book_list; item; item = g_list_next (item))
552 priv->component_manager_id = 0;
557 gnc_plug_page_register_check_commodity (
Account* account,
void* usr_data)
560 gnc_commodity* com0 = (gnc_commodity*) usr_data;
568 GNCLedgerDisplay* ledger;
574 ENTER (
"account=%p, subaccounts=%s", account,
575 subaccounts ?
"TRUE" :
"FALSE");
579 gnc_plug_page_register_check_commodity,
580 static_cast<gpointer>(com0)));
587 page = gnc_plugin_page_register_new_common (ledger);
588 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
598 GNCLedgerDisplay* ledger;
601 return gnc_plugin_page_register_new_common (ledger);
607 return gnc_plugin_page_register_new_common (ledger);
613 GObjectClass* object_class = G_OBJECT_CLASS (klass);
616 object_class->finalize = gnc_plugin_page_register_finalize;
618 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
619 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_REGISTER_NAME;
620 gnc_plugin_class->
create_widget = gnc_plugin_page_register_create_widget;
621 gnc_plugin_class->
destroy_widget = gnc_plugin_page_register_destroy_widget;
622 gnc_plugin_class->
window_changed = gnc_plugin_page_register_window_changed;
623 gnc_plugin_class->
focus_page = gnc_plugin_page_register_focus;
624 gnc_plugin_class->
save_page = gnc_plugin_page_register_save_page;
625 gnc_plugin_class->
recreate_page = gnc_plugin_page_register_recreate_page;
627 gnc_plugin_page_register_update_edit_menu;
628 gnc_plugin_class->
finish_pending = gnc_plugin_page_register_finish_pending;
631 gnc_ui_register_account_destroy_callback (gppr_account_destroy_cb);
639 GSimpleActionGroup *simple_action_group;
642 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
645 parent = GNC_PLUGIN_PAGE (plugin_page);
648 g_object_set (G_OBJECT (plugin_page),
649 "page-name", _ (
"General Journal"),
650 "ui-description",
"gnc-plugin-page-register.ui",
651 "use-new-window", use_new,
656 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
657 gnc_plugin_page_register_actions,
658 gnc_plugin_page_register_n_actions,
661 priv->lines_default = DEFAULT_LINES_AMOUNT;
662 priv->read_only = FALSE;
663 priv->fd.cleared_match = CLEARED_ALL;
665 priv->enable_refresh = TRUE;
666 priv->search_query = NULL;
667 priv->filter_query = NULL;
671 gnc_plugin_page_register_finalize (GObject*
object)
673 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (
object));
675 ENTER (
"object %p",
object);
677 G_OBJECT_CLASS (gnc_plugin_page_register_parent_class)->finalize (
object);
685 GNCLedgerDisplayType ledger_type;
688 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
689 ledger_type = gnc_ledger_display_type (priv->ledger);
692 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
703 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
713 gnc_plugin_page_register_focus_widget (
GncPluginPage* register_plugin_page)
715 if (GNC_IS_PLUGIN_PAGE_REGISTER (register_plugin_page))
717 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window);
720 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window))
724 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
727 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
730 register_plugin_page,
731 gnc_plugin_load_ui_items);
735 GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window);
736 GtkWidget *menubar = gnc_window_get_menubar (gnc_window);
737 GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window);
738 GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window);
748 gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page));
750 gnc_split_reg_focus_on_sheet (gsr);
756 static const char* readonly_inactive_actions[] =
760 "CutTransactionAction",
761 "PasteTransactionAction",
762 "DuplicateTransactionAction",
763 "DeleteTransactionAction",
764 "RemoveTransactionSplitsAction",
765 "RecordTransactionAction",
766 "CancelTransactionAction",
767 "UnvoidTransactionAction",
768 "VoidTransactionAction",
769 "ReverseTransactionAction",
770 "ActionsTransferAction",
771 "ActionsReconcileAction",
772 "ActionsStockSplitAction",
773 "ScheduleTransactionAction",
775 "ScrubCurrentAction",
776 "LinkTransactionAction",
782 static const char* tran_vs_split_actions[] =
784 "CutTransactionAction",
785 "CopyTransactionAction",
786 "PasteTransactionAction",
787 "DuplicateTransactionAction",
788 "DeleteTransactionAction",
793 static const char* tran_action_labels[] =
795 CUT_TRANSACTION_LABEL,
796 COPY_TRANSACTION_LABEL,
797 PASTE_TRANSACTION_LABEL,
798 DUPLICATE_TRANSACTION_LABEL,
799 DELETE_TRANSACTION_LABEL,
800 LINK_TRANSACTION_LABEL,
801 LINK_TRANSACTION_OPEN_LABEL,
802 JUMP_LINKED_INVOICE_LABEL,
807 static const char* tran_action_tips[] =
810 COPY_TRANSACTION_TIP,
811 PASTE_TRANSACTION_TIP,
812 DUPLICATE_TRANSACTION_TIP,
813 DELETE_TRANSACTION_TIP,
814 LINK_TRANSACTION_TIP,
815 LINK_TRANSACTION_OPEN_TIP,
816 JUMP_LINKED_INVOICE_TIP,
821 static const char* split_action_labels[] =
826 DUPLICATE_SPLIT_LABEL,
832 static const char* split_action_tips[] =
842 static std::vector<GncInvoice*>
843 invoices_from_transaction (
const Transaction* trans)
845 std::vector<GncInvoice*> rv;
847 g_return_val_if_fail (GNC_IS_TRANSACTION (trans), rv);
851 auto split = GNC_SPLIT(node->data);
855 auto inv = invoice_from_split (split);
863 gnc_plugin_page_register_ui_update (gpointer various,
869 GNCLedgerDisplayType ledger_type;
870 gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE;
875 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
878 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
884 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
887 ledger_type = gnc_ledger_display_type (priv->ledger);
890 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type != LD_GL);
891 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
895 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
899 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
901 g_signal_handlers_block_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
902 g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded));
903 g_signal_handlers_unblock_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
908 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
912 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
916 actions_requiring_priced_account,
924 gnc_split_reg_get_read_only (priv->gsr))
925 read_only_reg = TRUE;
928 actions_requiring_account,
929 !read_only_reg && account != NULL);
932 actions_requiring_priced_account,
938 if (cursor_class == CURSOR_CLASS_SPLIT)
940 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
947 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
958 for (iter = readonly_inactive_actions; *iter; ++iter)
962 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
972 "CutTransactionAction");
973 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
976 "PasteTransactionAction");
977 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
980 "DeleteTransactionAction");
981 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
983 if (cursor_class == CURSOR_CLASS_SPLIT)
986 "DuplicateTransactionAction");
987 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
991 "RemoveTransactionSplitsAction");
992 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
999 "VoidTransactionAction");
1000 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided);
1006 "UnvoidTransactionAction");
1007 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided);
1012 "LinkedTransactionOpenAction");
1016 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (uri ? TRUE:FALSE));
1024 "JumpLinkedInvoiceAction");
1027 auto invoices = invoices_from_transaction (trans);
1028 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !invoices.empty());
1031 gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page));
1037 for (iter = readonly_inactive_actions; *iter; ++iter)
1041 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
1048 GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
1049 gboolean found = FALSE;
1050 const char** iter, **label_iter, **tooltip_iter;
1051 gboolean curr_label_trans = FALSE;
1052 iter = tran_vs_split_actions;
1053 label_iter = tran_action_labels;
1055 gsm->search_action_label = NULL;
1056 gsm->search_action_name = *iter;
1057 gsm->search_action_target = NULL;
1061 PINFO(
"Test for action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter));
1069 if (g_strcmp0 (gsm->search_action_label, _(*label_iter)) == 0)
1070 curr_label_trans = TRUE;
1074 if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans)
1076 gboolean found = FALSE;
1077 label_iter = split_action_labels;
1078 tooltip_iter = split_action_tips;
1079 for (iter = tran_vs_split_actions; *iter; ++iter)
1083 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
1085 PINFO(
"split model_item action '%s', found is %d, iter label is '%s'",
1086 *iter, found, _(*label_iter));
1092 else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans)
1094 gboolean found = FALSE;
1095 label_iter = tran_action_labels;
1096 tooltip_iter = tran_action_tips;
1097 for (iter = tran_vs_split_actions; *iter; ++iter)
1101 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
1103 PINFO(
"trans model_item action '%s', found is %d, iter label is '%s'",
1104 *iter, found, _(*label_iter));
1112 gnc_window_get_menubar_model (gnc_window),
1113 gnc_window_get_statusbar (gnc_window));
1117 gnc_window_get_menubar_model (gnc_window),
1118 gnc_window_get_accel_group (gnc_window));
1126 GSimpleActionGroup *simple_action_group;
1130 GNCLedgerDisplayType ledger_type;
1133 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1138 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
1141 is_readwrite && account != NULL);
1144 ledger_type = gnc_ledger_display_type (priv->ledger);
1146 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type == LD_SINGLE);
1150 g_signal_handlers_block_by_func (action,
1151 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1152 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
1153 g_signal_handlers_unblock_by_func (action,
1154 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1158 g_signal_handlers_block_by_func (action,
1159 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1160 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
1161 g_signal_handlers_unblock_by_func (action,
1162 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1168 get_filter_default_num_of_days (GNCLedgerDisplayType ledger_type)
1170 if (ledger_type == LD_GL)
1171 return DEFAULT_FILTER_NUM_DAYS_GL;
1183 gboolean on_current_page)
1189 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1191 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1192 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1196 if (on_current_page)
1198 priv->page_focus = TRUE;
1202 GNC_PLUGIN_PAGE_CLASS (gnc_plugin_page_register_parent_class)->focus_page (plugin_page, TRUE);
1205 priv->page_focus = FALSE;
1208 gnc_split_reg_set_sheet_focus (gsr, priv->page_focus);
1214 gnc_plugin_page_register_create_widget (
GncPluginPage* plugin_page)
1218 GNCLedgerDisplayType ledger_type;
1219 GncWindow* gnc_window;
1225 int filter_changed = 0;
1226 gboolean create_new_page = FALSE;
1228 ENTER (
"page %p", plugin_page);
1229 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1230 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1232 if (priv->widget != NULL)
1234 LEAVE (
"existing widget %p", priv->widget);
1235 return priv->widget;
1238 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1239 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
1240 gtk_widget_show (priv->widget);
1243 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-register-page");
1245 numRows = priv->lines_default;
1246 numRows = MIN (numRows, DEFAULT_LINES_AMOUNT);
1248 gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
1249 gsr = gnc_split_reg_new (priv->ledger,
1250 gnc_window_get_gtk_window (gnc_window),
1251 numRows, priv->read_only);
1252 priv->gsr = (GNCSplitReg *)gsr;
1254 gtk_widget_show (gsr);
1255 gtk_box_pack_start (GTK_BOX (priv->widget), gsr, TRUE, TRUE, 0);
1257 g_signal_connect (G_OBJECT (gsr),
"help-changed",
1258 G_CALLBACK (gnc_plugin_page_help_changed_cb),
1261 g_signal_connect (G_OBJECT (gsr),
"show-popup-menu",
1262 G_CALLBACK (gnc_plugin_page_popup_menu_cb),
1267 reg->use_double_line);
1269 gnc_plugin_page_register_ui_initial_state (page);
1270 gnc_plugin_page_register_ui_update (NULL, page);
1272 ledger_type = gnc_ledger_display_type (priv->ledger);
1277 guint filtersize = 0;
1279 priv->sd.save_order = FALSE;
1280 order = gnc_plugin_page_register_get_sort_order (plugin_page);
1282 PINFO (
"Loaded Sort order is %s", order);
1284 gnc_split_reg_set_sort_type (priv->gsr, SortTypefromString (order));
1286 if (order && (g_strcmp0 (order, DEFAULT_SORT_ORDER) != 0))
1287 priv->sd.save_order = TRUE;
1289 priv->sd.original_save_order = priv->sd.save_order;
1292 priv->sd.reverse_order = gnc_plugin_page_register_get_sort_reversed (
1294 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.reverse_order, FALSE);
1295 if (priv->sd.reverse_order)
1296 priv->sd.save_order = TRUE;
1298 priv->sd.original_reverse_order = priv->sd.reverse_order;
1301 priv->fd.save_filter = FALSE;
1303 filter_str = gnc_plugin_page_register_get_filter (plugin_page);
1304 filter = g_strsplit (filter_str,
",", -1);
1305 filtersize = g_strv_length (filter);
1306 g_free (filter_str);
1308 PINFO (
"Loaded Filter Status is %s", filter[0]);
1310 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (filter[0], NULL, 16);
1312 if (filtersize > 0 && (g_strcmp0 (filter[0], DEFAULT_FILTER) != 0))
1313 filter_changed = filter_changed + 1;
1315 if (filtersize > 1 && (g_strcmp0 (filter[1],
"0") != 0))
1317 PINFO (
"Loaded Filter Start Date is %s", filter[1]);
1319 priv->fd.start_time = gnc_plugin_page_register_filter_dmy2time (filter[1]);
1321 filter_changed = filter_changed + 1;
1324 if (filtersize > 2 && (g_strcmp0 (filter[2],
"0") != 0))
1326 PINFO (
"Loaded Filter End Date is %s", filter[2]);
1328 priv->fd.end_time = gnc_plugin_page_register_filter_dmy2time (filter[2]);
1330 filter_changed = filter_changed + 1;
1334 priv->fd.days = (gint)g_ascii_strtoll (
1335 get_filter_default_num_of_days (ledger_type), NULL, 10);
1337 if (filtersize > 3 &&
1338 (g_strcmp0 (filter[3], get_filter_default_num_of_days (ledger_type)) != 0))
1340 PINFO (
"Loaded Filter Days is %s", filter[3]);
1342 priv->fd.days = (gint)g_ascii_strtoll (filter[3], NULL, 10);
1343 filter_changed = filter_changed + 1;
1346 if (filter_changed != 0)
1347 priv->fd.save_filter = TRUE;
1349 priv->fd.original_save_filter = priv->fd.save_filter;
1350 g_strfreev (filter);
1353 if (ledger_type == LD_GL)
1355 time64 start_time = 0, end_time = 0;
1357 if (reg->type == GENERAL_JOURNAL)
1359 start_time = priv->fd.start_time;
1360 end_time = priv->fd.end_time;
1365 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (DEFAULT_FILTER, NULL, 16);
1366 gnc_split_reg_set_sort_type (priv->gsr,
1367 SortTypefromString (DEFAULT_SORT_ORDER));
1368 priv->sd.reverse_order = FALSE;
1369 priv->fd.save_filter = FALSE;
1370 priv->sd.save_order = FALSE;
1373 priv->fd.original_days = priv->fd.days;
1375 priv->fd.original_start_time = start_time;
1376 priv->fd.start_time = start_time;
1377 priv->fd.original_end_time = end_time;
1378 priv->fd.end_time = end_time;
1383 if (priv->enable_refresh == TRUE)
1385 create_new_page = TRUE;
1386 priv->enable_refresh = FALSE;
1390 gnc_ppr_update_status_query (page);
1391 gnc_ppr_update_date_query (page);
1394 if (create_new_page)
1396 priv->enable_refresh = TRUE;
1401 gnc_plugin_page_register_set_filter_tooltip (page);
1403 plugin_page->
summarybar = gsr_create_summary_bar (priv->gsr);
1406 gtk_widget_show_all (plugin_page->
summarybar);
1407 gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->
summarybar,
1410 gnc_plugin_page_register_summarybar_position_changed (NULL, NULL, page);
1412 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1413 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1416 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1417 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1423 priv->component_manager_id =
1424 gnc_register_gui_component (GNC_PLUGIN_PAGE_REGISTER_NAME,
1425 gnc_plugin_page_register_refresh_cb,
1426 gnc_plugin_page_register_close_cb,
1428 gnc_gui_component_set_session (priv->component_manager_id,
1429 gnc_get_current_session());
1432 gnc_gui_component_watch_entity (
1434 QOF_EVENT_DESTROY | QOF_EVENT_MODIFY);
1436 gnc_split_reg_set_moved_cb
1437 (priv->gsr, (GFunc)gnc_plugin_page_register_ui_update, page);
1439 g_signal_connect (G_OBJECT (plugin_page),
"inserted",
1445 return priv->widget;
1449 gnc_plugin_page_register_destroy_widget (
GncPluginPage* plugin_page)
1454 ENTER (
"page %p", plugin_page);
1455 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1456 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1459 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1460 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1463 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1464 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1471 g_idle_remove_by_data (GNC_PLUGIN_PAGE_REGISTER (plugin_page));
1473 if (priv->widget == NULL)
1476 if (priv->component_manager_id)
1478 gnc_unregister_gui_component (priv->component_manager_id);
1479 priv->component_manager_id = 0;
1482 if (priv->event_handler_id)
1485 priv->event_handler_id = 0;
1488 if (priv->sd.dialog)
1490 gtk_widget_destroy (priv->sd.dialog);
1491 memset (&priv->sd, 0, sizeof (priv->sd));
1494 if (priv->fd.dialog)
1496 gtk_widget_destroy (priv->fd.dialog);
1497 memset (&priv->fd, 0, sizeof (priv->fd));
1503 gtk_widget_hide (priv->widget);
1505 priv->ledger = NULL;
1510 gnc_plugin_page_register_window_changed (
GncPluginPage* plugin_page,
1516 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1518 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1519 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1521 GTK_WIDGET (gnc_window_get_gtk_window (GNC_WINDOW (window)));
1524 static const gchar* style_names[] =
1532 #define KEY_REGISTER_TYPE "RegisterType" 1533 #define KEY_ACCOUNT_NAME "AccountName" 1534 #define KEY_ACCOUNT_GUID "AccountGuid" 1535 #define KEY_REGISTER_STYLE "RegisterStyle" 1536 #define KEY_DOUBLE_LINE "DoubleLineMode" 1538 #define LABEL_ACCOUNT "Account" 1539 #define LABEL_SUBACCOUNT "SubAccount" 1540 #define LABEL_GL "GL" 1541 #define LABEL_SEARCH "Search" 1554 gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
1556 const gchar* group_name)
1560 GNCLedgerDisplayType ledger_type;
1564 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1565 g_return_if_fail (key_file != NULL);
1566 g_return_if_fail (group_name != NULL);
1568 ENTER (
"page %p, key_file %p, group_name %s", plugin_page, key_file,
1571 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1572 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1575 ledger_type = gnc_ledger_display_type (priv->ledger);
1576 if (ledger_type > LD_GL)
1578 LEAVE (
"Unsupported ledger type");
1581 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1586 label = (ledger_type == LD_SINGLE) ? LABEL_ACCOUNT : LABEL_SUBACCOUNT;
1588 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE, label);
1590 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_NAME, name);
1593 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_GUID, acct_guid);
1595 else if (reg->type == GENERAL_JOURNAL)
1597 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1600 else if (reg->type == SEARCH_LEDGER)
1602 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1607 LEAVE (
"Unsupported register type");
1611 g_key_file_set_string (key_file, group_name, KEY_REGISTER_STYLE,
1612 style_names[reg->style]);
1613 g_key_file_set_boolean (key_file, group_name, KEY_DOUBLE_LINE,
1614 reg->use_double_line);
1633 gnc_plugin_page_register_restore_edit_menu (
GncPluginPage* page,
1635 const gchar* group_name)
1639 GError* error = NULL;
1642 gboolean use_double_line;
1647 style_name = g_key_file_get_string (key_file, group_name,
1648 KEY_REGISTER_STYLE, &error);
1649 for (i = 0 ; style_names[i]; i++)
1651 if (g_ascii_strcasecmp (style_name, style_names[i]) == 0)
1653 DEBUG (
"Found match for style name: %s", style_name);
1657 g_free (style_name);
1660 if (i <= REG_STYLE_JOURNAL)
1662 DEBUG (
"Setting style: %d", i);
1664 g_action_activate (G_ACTION(action), g_variant_new_int32 (i));
1668 use_double_line = g_key_file_get_boolean (key_file, group_name,
1669 KEY_DOUBLE_LINE, &error);
1670 DEBUG (
"Setting double_line_mode: %d", use_double_line);
1673 state = g_action_get_state (G_ACTION(action));
1675 if (use_double_line != g_variant_get_boolean (state))
1676 g_action_activate (G_ACTION(action), NULL);
1678 g_variant_unref (state);
1694 gnc_plugin_page_register_recreate_page (GtkWidget* window,
1696 const gchar* group_name)
1700 GError* error = NULL;
1701 gchar* reg_type, *acct_guid;
1705 gboolean include_subs;
1707 g_return_val_if_fail (key_file, NULL);
1708 g_return_val_if_fail (group_name, NULL);
1709 ENTER (
"key_file %p, group_name %s", key_file, group_name);
1712 reg_type = g_key_file_get_string (key_file, group_name,
1713 KEY_REGISTER_TYPE, &error);
1714 DEBUG (
"Page type: %s", reg_type);
1715 if ((g_ascii_strcasecmp (reg_type, LABEL_ACCOUNT) == 0) ||
1716 (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0))
1718 include_subs = (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0);
1719 DEBUG (
"Include subs: %d", include_subs);
1723 LEAVE(
"Session has no book");
1726 acct_guid = g_key_file_get_string (key_file, group_name,
1727 KEY_ACCOUNT_GUID, &error);
1733 if (account == NULL)
1735 gchar* acct_name = g_key_file_get_string (key_file, group_name,
1736 KEY_ACCOUNT_NAME, &error);
1741 if (account == NULL)
1743 LEAVE (
"Bad account name");
1749 else if (g_ascii_strcasecmp (reg_type, LABEL_GL) == 0)
1755 LEAVE (
"Bad ledger type");
1763 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1764 priv->enable_refresh = FALSE;
1773 gnc_plugin_page_register_restore_edit_menu (page, key_file, group_name);
1776 priv->enable_refresh = TRUE;
1786 gnc_plugin_page_register_update_edit_menu (
GncPluginPage* page, gboolean hide)
1791 gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
1792 gboolean has_selection;
1795 reg_page = GNC_PLUGIN_PAGE_REGISTER (page);
1796 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (reg_page);
1797 has_selection = gnucash_register_has_selection (priv->gsr->reg);
1799 can_copy = has_selection;
1800 can_cut = is_readwrite && has_selection;
1801 can_paste = is_readwrite;
1804 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy);
1806 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut);
1808 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste);
1811 static gboolean is_scrubbing = FALSE;
1812 static gboolean show_abort_verify = TRUE;
1815 check_repair_abort_YN = N_(
"'Check & Repair' is currently running, do you want to abort it?");
1820 gboolean ret = FALSE;
1825 false,
"%s", _(check_repair_abort_YN));
1827 show_abort_verify = FALSE;
1836 gnc_plugin_page_register_finish_pending (
GncPluginPage* page)
1841 GtkWidget* dialog, *window;
1845 if (is_scrubbing && show_abort_verify)
1847 if (!finish_scrub (page))
1851 reg_page = GNC_PLUGIN_PAGE_REGISTER (page);
1852 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (reg_page);
1858 name = gnc_plugin_page_register_get_tab_name (page);
1860 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1861 GTK_DIALOG_DESTROY_WITH_PARENT,
1862 GTK_MESSAGE_WARNING,
1866 _ (
"Save changes to %s?"), name);
1868 gtk_message_dialog_format_secondary_text
1869 (GTK_MESSAGE_DIALOG (dialog),
1871 _ (
"This register has pending changes to a transaction. " 1872 "Would you like to save the changes to this transaction, " 1873 "discard the transaction, or cancel the operation?"));
1874 gnc_gtk_dialog_add_button (dialog, _ (
"_Discard Transaction"),
1875 "edit-delete", GTK_RESPONSE_REJECT);
1876 gtk_dialog_add_button (GTK_DIALOG (dialog),
1877 _ (
"_Cancel"), GTK_RESPONSE_CANCEL);
1878 gnc_gtk_dialog_add_button (dialog, _ (
"_Save Transaction"),
1879 "document-save", GTK_RESPONSE_ACCEPT);
1881 response = gtk_dialog_run (GTK_DIALOG (dialog));
1882 gtk_widget_destroy (dialog);
1886 case GTK_RESPONSE_ACCEPT:
1890 case GTK_RESPONSE_REJECT:
1902 gnc_plugin_page_register_get_tab_name (
GncPluginPage* plugin_page)
1905 GNCLedgerDisplayType ledger_type;
1906 GNCLedgerDisplay* ld;
1910 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1911 g_strdup (_(
"unknown")));
1913 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1916 ledger_type = gnc_ledger_display_type (ld);
1919 switch (ledger_type)
1930 case GENERAL_JOURNAL:
1932 return g_strdup (_ (
"General Journal"));
1933 case PORTFOLIO_LEDGER:
1934 return g_strdup (_ (
"Portfolio"));
1936 return g_strdup (_ (
"Search Results"));
1946 return g_strdup (_ (
"unknown"));
1950 gnc_plugin_page_register_get_tab_color (
GncPluginPage* plugin_page)
1953 GNCLedgerDisplayType ledger_type;
1954 GNCLedgerDisplay* ld;
1958 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1959 g_strdup (_(
"unknown")));
1961 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1963 ledger_type = gnc_ledger_display_type (ld);
1967 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1970 return g_strdup (color ? color :
"Not Set");
1974 gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file,
1975 const gchar *state_section)
1978 gchar **keys = g_key_file_get_keys (state_file, state_section, &num_keys, NULL);
1987 gnc_plugin_page_register_get_filter_gcm (GNCSplitReg *gsr)
1990 gchar* state_section;
1991 GError* error = NULL;
1992 char* filter = NULL;
1995 state_section = gsr_get_register_state_section (gsr);
1996 filter = g_key_file_get_string (state_file, state_section,
1997 KEY_PAGE_FILTER, &error);
2000 g_clear_error (&error);
2002 g_strdelimit (filter,
";",
',');
2004 g_free (state_section);
2009 gnc_plugin_page_register_get_filter (
GncPluginPage* plugin_page)
2012 GNCLedgerDisplayType ledger_type;
2013 char* filter = NULL;
2015 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2016 g_strdup (_(
"unknown")));
2018 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2020 ledger_type = gnc_ledger_display_type (priv->ledger);
2023 filter = gnc_plugin_page_register_get_filter_gcm (priv->gsr);
2028 return g_strdup_printf (
"%s,%s,%s,%s", DEFAULT_FILTER,
2029 "0",
"0", get_filter_default_num_of_days (ledger_type));
2033 gnc_plugin_page_register_set_filter_gcm (GNCSplitReg *gsr,
const gchar* filter,
2034 gchar* default_filter)
2037 gchar* state_section;
2041 state_section = gsr_get_register_state_section (gsr);
2042 if (!filter || (g_strcmp0 (filter, default_filter) == 0))
2044 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_FILTER, NULL))
2045 g_key_file_remove_key (state_file, state_section, KEY_PAGE_FILTER, NULL);
2047 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2051 filter_text = g_strdup (filter);
2052 g_strdelimit (filter_text,
",",
';');
2053 g_key_file_set_string (state_file, state_section, KEY_PAGE_FILTER,
2055 g_free (filter_text);
2057 g_free (state_section);
2061 gnc_plugin_page_register_set_filter (
GncPluginPage* plugin_page,
2062 const gchar* filter)
2065 GNCLedgerDisplayType ledger_type;
2066 gchar* default_filter;
2068 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2070 ledger_type = gnc_ledger_display_type (priv->ledger);
2072 default_filter = g_strdup_printf (
"%s,%s,%s,%s", DEFAULT_FILTER,
2073 "0",
"0", get_filter_default_num_of_days (ledger_type));
2076 gnc_plugin_page_register_set_filter_gcm (priv->gsr, filter, default_filter);
2078 g_free (default_filter);
2083 gnc_plugin_page_register_get_sort_order_gcm (GNCSplitReg *gsr)
2086 gchar* state_section;
2088 GError* error = NULL;
2089 char* sort_order = NULL;
2092 state_section = gsr_get_register_state_section (gsr);
2093 sort_text = g_key_file_get_string (state_file, state_section, KEY_PAGE_SORT,
2097 g_clear_error (&error);
2100 sort_order = g_strdup (sort_text);
2103 g_free (state_section);
2108 gnc_plugin_page_register_get_sort_order (
GncPluginPage* plugin_page)
2111 char* sort_order = NULL;
2113 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2116 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2119 sort_order = gnc_plugin_page_register_get_sort_order_gcm (priv->gsr);
2121 return sort_order ? sort_order : g_strdup (DEFAULT_SORT_ORDER);
2125 gnc_plugin_page_register_set_sort_order_gcm (GNCSplitReg *gsr,
2126 const gchar* sort_order)
2129 gchar* state_section;
2132 state_section = gsr_get_register_state_section (gsr);
2133 if (!sort_order || (g_strcmp0 (sort_order, DEFAULT_SORT_ORDER) == 0))
2135 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_SORT, NULL))
2136 g_key_file_remove_key (state_file, state_section, KEY_PAGE_SORT, NULL);
2138 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2141 g_key_file_set_string (state_file, state_section, KEY_PAGE_SORT, sort_order);
2143 g_free (state_section);
2146 gnc_plugin_page_register_set_sort_order (
GncPluginPage* plugin_page,
2147 const gchar* sort_order)
2151 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2154 gnc_plugin_page_register_set_sort_order_gcm (priv->gsr, sort_order);
2158 gnc_plugin_page_register_get_sort_reversed_gcm (GNCSplitReg *gsr)
2161 gchar* state_section;
2162 GError* error = NULL;
2163 gboolean sort_reversed = FALSE;
2166 state_section = gsr_get_register_state_section (gsr);
2167 sort_reversed = g_key_file_get_boolean (state_file, state_section,
2168 KEY_PAGE_SORT_REV, &error);
2171 g_clear_error (&error);
2173 g_free (state_section);
2174 return sort_reversed;
2178 gnc_plugin_page_register_get_sort_reversed (
GncPluginPage* plugin_page)
2181 gboolean sort_reversed = FALSE;
2183 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), FALSE);
2185 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2188 sort_reversed = gnc_plugin_page_register_get_sort_reversed_gcm (priv->gsr);
2189 return sort_reversed;
2193 gnc_plugin_page_register_set_sort_reversed_gcm (GNCSplitReg *gsr,
2194 gboolean reverse_order)
2197 gchar* state_section;
2200 state_section = gsr_get_register_state_section (gsr);
2204 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_SORT_REV, NULL))
2205 g_key_file_remove_key (state_file, state_section, KEY_PAGE_SORT_REV, NULL);
2207 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2210 g_key_file_set_boolean (state_file, state_section, KEY_PAGE_SORT_REV,
2213 g_free (state_section);
2217 gnc_plugin_page_register_set_sort_reversed (
GncPluginPage* plugin_page,
2218 gboolean reverse_order)
2222 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2225 gnc_plugin_page_register_set_sort_reversed_gcm (priv->gsr, reverse_order);
2229 gnc_plugin_page_register_get_long_name (
GncPluginPage* plugin_page)
2232 GNCLedgerDisplayType ledger_type;
2233 GNCLedgerDisplay* ld;
2236 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2239 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2241 ledger_type = gnc_ledger_display_type (ld);
2244 switch (ledger_type)
2252 gchar* return_string = g_strdup_printf (
"%s+", account_full_name);
2253 g_free ((gpointer*) account_full_name);
2254 return return_string;
2265 gnc_plugin_page_register_summarybar_position_changed (gpointer prefs,
2272 GtkPositionType position = GTK_POS_BOTTOM;
2274 g_return_if_fail (user_data != NULL);
2276 if (!GNC_IS_PLUGIN_PAGE (user_data))
2279 plugin_page = GNC_PLUGIN_PAGE (user_data);
2280 page = GNC_PLUGIN_PAGE_REGISTER (user_data);
2281 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2287 GNC_PREF_SUMMARYBAR_POSITION_TOP))
2288 position = GTK_POS_TOP;
2290 gtk_box_reorder_child (GTK_BOX (priv->widget),
2292 (position == GTK_POS_TOP ? 0 : -1));
2306 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
2308 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
2309 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2328 gnc_plugin_page_register_sort_book_option_changed (gpointer new_val,
2332 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2333 gboolean* new_data = (gboolean*)new_val;
2335 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2337 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2340 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio),
2341 _ (
"Transaction Number"));
2342 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Number/Action"));
2346 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio), _ (
"Number"));
2347 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Action"));
2349 gnc_split_reg_set_sort_type_force (priv->gsr, (SortType)priv->gsr->sort_type, TRUE);
2373 g_return_if_fail (GTK_IS_DIALOG (dialog));
2374 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2377 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2378 plugin_page = GNC_PLUGIN_PAGE (page);
2380 if (response != GTK_RESPONSE_OK)
2383 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.original_reverse_order,
2385 priv->sd.reverse_order = priv->sd.original_reverse_order;
2386 gnc_split_reg_set_sort_type (priv->gsr, priv->sd.original_sort_type);
2387 priv->sd.save_order = priv->sd.original_save_order;
2392 if ((!priv->sd.save_order) && ((priv->sd.original_save_order) || (priv->sd.original_reverse_order)))
2394 gnc_plugin_page_register_set_sort_order (plugin_page, DEFAULT_SORT_ORDER);
2395 gnc_plugin_page_register_set_sort_reversed (plugin_page, FALSE);
2397 priv->sd.original_save_order = priv->sd.save_order;
2399 if (priv->sd.save_order)
2401 type = gnc_split_reg_get_sort_type (priv->gsr);
2402 order = SortTypeasString (type);
2403 gnc_plugin_page_register_set_sort_order (plugin_page, order);
2404 gnc_plugin_page_register_set_sort_reversed (plugin_page,
2405 priv->sd.reverse_order);
2408 gnc_book_option_remove_cb (OPTION_NAME_NUM_FIELD_SOURCE,
2409 gnc_plugin_page_register_sort_book_option_changed,
2411 priv->sd.dialog = NULL;
2412 priv->sd.num_radio = NULL;
2413 priv->sd.act_radio = NULL;
2414 gtk_widget_destroy (GTK_WIDGET (dialog));
2435 g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
2436 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2438 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2439 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2440 ENTER (
"button %s(%p), page %p", name, button, page);
2441 type = SortTypefromString (name);
2442 gnc_split_reg_set_sort_type (priv->gsr, type);
2461 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2462 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2464 ENTER (
"Save toggle button (%p), plugin_page %p", button, page);
2467 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2469 if (gtk_toggle_button_get_active (button))
2470 priv->sd.save_order = TRUE;
2472 priv->sd.save_order = FALSE;
2491 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2492 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2494 ENTER (
"Reverse toggle button (%p), plugin_page %p", button, page);
2497 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2499 priv->sd.reverse_order = gtk_toggle_button_get_active (button);
2500 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.reverse_order, TRUE);
2514 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2517 if (reg->type == SEARCH_LEDGER)
2524 if ((priv->filter_query == NULL) ||
2555 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2558 LEAVE (
"no ledger");
2562 gnc_ppr_update_for_search_query (page);
2567 LEAVE (
"no query found");
2574 if (reg->type != SEARCH_LEDGER)
2576 GSList *param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
2578 g_slist_free (param_list);
2582 if (priv->fd.cleared_match != CLEARED_ALL)
2583 xaccQueryAddClearedMatch (query, priv->fd.cleared_match, QOF_QUERY_AND);
2586 gnc_plugin_page_register_set_filter_tooltip (page);
2592 if (priv->enable_refresh)
2618 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2621 LEAVE (
"no ledger");
2625 gnc_ppr_update_for_search_query (page);
2638 if (reg->type != SEARCH_LEDGER)
2640 GSList *param_list = qof_query_build_param_list (SPLIT_TRANS,
2641 TRANS_DATE_POSTED, NULL);
2643 g_slist_free (param_list);
2646 if (priv->fd.start_time || priv->fd.end_time)
2649 xaccQueryAddDateMatchTT (query,
2650 priv->fd.start_time != 0, priv->fd.start_time,
2651 priv->fd.end_time != 0, priv->fd.end_time,
2655 if (priv->fd.days > 0)
2662 tm.tm_mday = tm.tm_mday - priv->fd.days;
2664 xaccQueryAddDateMatchTT (query, TRUE, start, FALSE, 0, QOF_QUERY_AND);
2668 gnc_plugin_page_register_set_filter_tooltip (page);
2674 if (priv->enable_refresh)
2682 gnc_plugin_page_register_filter_time2dmy (
time64 raw_time)
2684 struct tm* timeinfo;
2685 gchar date_string[11];
2688 strftime (date_string, 11,
"%d-%m-%Y", timeinfo);
2689 PINFO (
"Date string is %s", date_string);
2692 return g_strdup (date_string);
2698 gnc_plugin_page_register_filter_dmy2time (
char* date_string)
2702 PINFO (
"Date string is %s", date_string);
2703 memset (&when, 0,
sizeof (when));
2705 sscanf (date_string,
"%d-%d-%d", &when.tm_mday,
2706 &when.tm_mon, &when.tm_year);
2709 when.tm_year -= 1900;
2733 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2734 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2736 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2737 ENTER (
"toggle button %s (%p), plugin_page %p", name, button, page);
2740 value = CLEARED_NONE;
2741 for (i = 0; status_actions[i].action_name; i++)
2743 if (g_strcmp0 (name, status_actions[i].action_name) == 0)
2745 value = status_actions[i].value;
2751 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2752 if (gtk_toggle_button_get_active (button))
2753 priv->fd.cleared_match = (cleared_match_t)(priv->fd.cleared_match | value);
2755 priv->fd.cleared_match = (cleared_match_t)(priv->fd.cleared_match & ~value);
2756 gnc_ppr_update_status_query (page);
2778 g_return_if_fail (GTK_IS_BUTTON (button));
2779 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2781 ENTER (
"(button %p, page %p)", button, page);
2784 for (i = 0; status_actions[i].action_name; i++)
2786 widget = status_actions[i].widget;
2787 g_signal_handlers_block_by_func (widget,
2789 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
2790 g_signal_handlers_unblock_by_func (widget,
2795 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2796 priv->fd.cleared_match = CLEARED_ALL;
2797 gnc_ppr_update_status_query (page);
2820 g_return_if_fail (GTK_IS_BUTTON (button));
2821 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2823 ENTER (
"(button %p, page %p)", button, page);
2826 for (i = 0; status_actions[i].action_name; i++)
2828 widget = status_actions[i].widget;
2829 g_signal_handlers_block_by_func (widget,
2831 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
2832 g_signal_handlers_unblock_by_func (widget,
2837 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2838 priv->fd.cleared_match = CLEARED_NONE;
2839 gnc_ppr_update_status_query (page);
2861 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2862 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2863 priv->fd.start_date_choose)))
2865 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.start_date));
2867 priv->fd.start_time = time_val;
2871 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2872 priv->fd.start_date_today)))
2878 priv->fd.start_time = 0;
2882 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2883 priv->fd.end_date_choose)))
2885 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.end_date));
2887 priv->fd.end_time = time_val;
2891 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2892 priv->fd.end_date_today)))
2898 priv->fd.end_time = 0;
2923 g_return_if_fail (GTK_IS_RADIO_BUTTON (button));
2924 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2926 ENTER (
"(button %p, page %p)", button, page);
2927 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2928 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2929 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
2931 if (active && g_strcmp0 (name,
"filter_show_range") == 0)
2933 gtk_widget_set_sensitive (priv->fd.table, active);
2934 gtk_widget_set_sensitive (priv->fd.num_days, !active);
2935 get_filter_times (page);
2937 else if (active && g_strcmp0 (name,
"filter_show_days") == 0)
2939 gtk_widget_set_sensitive (priv->fd.table, !active);
2940 gtk_widget_set_sensitive (priv->fd.num_days, active);
2941 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->fd.num_days), priv->fd.days);
2945 gtk_widget_set_sensitive (priv->fd.table, FALSE);
2946 gtk_widget_set_sensitive (priv->fd.num_days, FALSE);
2948 priv->fd.start_time = 0;
2949 priv->fd.end_time = 0;
2951 gnc_ppr_update_date_query (page);
2960 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
2962 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2965 priv->fd.start_time = 0;
2966 priv->fd.end_time = 0;
2967 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (DEFAULT_FILTER, NULL, 16);
2969 gnc_ppr_update_date_query (GNC_PLUGIN_PAGE_REGISTER(plugin_page));
2988 g_return_if_fail (GTK_IS_SPIN_BUTTON (button));
2989 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2991 ENTER (
"(button %p, page %p)", button, page);
2992 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2994 priv->fd.days = gtk_spin_button_get_value (GTK_SPIN_BUTTON (button));
2995 gnc_ppr_update_date_query (page);
3011 gnc_plugin_page_register_filter_gde_changed_cb (GtkWidget* unused,
3014 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3016 ENTER (
"(widget %s(%p), page %p)",
3017 gtk_buildable_get_name (GTK_BUILDABLE (unused)), unused, page);
3018 get_filter_times (page);
3019 gnc_ppr_update_date_query (page);
3051 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
3052 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3054 ENTER (
"(radio %s(%p), page %p)",
3055 gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
3056 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3057 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
3059 LEAVE (
"1st callback of pair. Defer to 2nd callback.");
3063 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
3064 active = !g_strcmp0 (name,
"start_date_choose");
3065 gtk_widget_set_sensitive (priv->fd.start_date, active);
3066 get_filter_times (page);
3067 gnc_ppr_update_date_query (page);
3099 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
3100 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3102 ENTER (
"(radio %s(%p), page %p)",
3103 gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
3104 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3105 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
3107 LEAVE (
"1st callback of pair. Defer to 2nd callback.");
3111 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
3112 active = !g_strcmp0 (name,
"end_date_choose");
3113 gtk_widget_set_sensitive (priv->fd.end_date, active);
3114 get_filter_times (page);
3115 gnc_ppr_update_date_query (page);
3134 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
3135 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3137 ENTER (
"Save toggle button (%p), plugin_page %p", button, page);
3140 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3141 if (gtk_toggle_button_get_active (button))
3142 priv->fd.save_filter = TRUE;
3144 priv->fd.save_filter = FALSE;
3168 g_return_if_fail (GTK_IS_DIALOG (dialog));
3169 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3172 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3173 plugin_page = GNC_PLUGIN_PAGE (page);
3175 if (response != GTK_RESPONSE_OK)
3178 priv->fd.cleared_match = priv->fd.original_cleared_match;
3179 priv->enable_refresh = FALSE;
3180 gnc_ppr_update_status_query (page);
3181 priv->enable_refresh = TRUE;
3182 priv->fd.start_time = priv->fd.original_start_time;
3183 priv->fd.end_time = priv->fd.original_end_time;
3184 priv->fd.days = priv->fd.original_days;
3185 priv->fd.save_filter = priv->fd.original_save_filter;
3186 gnc_ppr_update_date_query (page);
3191 if ((priv->fd.save_filter == FALSE) && (priv->fd.original_save_filter == TRUE))
3192 gnc_plugin_page_register_set_filter (plugin_page, NULL);
3194 priv->fd.original_save_filter = priv->fd.save_filter;
3196 if (priv->fd.save_filter)
3199 GList *flist = NULL;
3202 flist = g_list_prepend
3203 (flist, g_strdup_printf (
"0x%04x", priv->fd.cleared_match));
3206 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)) && priv->fd.start_time != 0)
3207 flist = g_list_prepend (flist, gnc_plugin_page_register_filter_time2dmy (priv->fd.start_time));
3209 flist = g_list_prepend (flist, g_strdup (
"0"));
3212 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose))
3213 && priv->fd.end_time != 0)
3214 flist = g_list_prepend (flist, gnc_plugin_page_register_filter_time2dmy (priv->fd.end_time));
3216 flist = g_list_prepend (flist, g_strdup (
"0"));
3219 if (priv->fd.days > 0)
3220 flist = g_list_prepend (flist, g_strdup_printf (
"%d", priv->fd.days));
3222 flist = g_list_prepend (flist, g_strdup (
"0"));
3224 flist = g_list_reverse (flist);
3226 PINFO (
"The filter to save is %s", filter);
3227 gnc_plugin_page_register_set_filter (plugin_page, filter);
3229 g_list_free_full (flist, g_free);
3232 priv->fd.dialog = NULL;
3233 gtk_widget_destroy (GTK_WIDGET (dialog));
3238 gpp_update_match_filter_text (cleared_match_t match,
const guint mask,
3239 const gchar* filter_name, GList **show, GList **hide)
3241 if ((match & mask) == mask)
3242 *show = g_list_prepend (*show, g_strdup (filter_name));
3244 *hide = g_list_prepend (*hide, g_strdup (filter_name));
3251 GList *t_list = NULL;
3253 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3256 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3259 if (priv->fd.start_time != 0)
3262 t_list = g_list_prepend
3263 (t_list, g_strdup_printf (
"%s %s", _(
"Start Date:"), sdate));
3268 if (priv->fd.days > 0)
3269 t_list = g_list_prepend
3270 (t_list, g_strdup_printf (
"%s %d", _(
"Show previous number of days:"),
3274 if (priv->fd.end_time != 0)
3277 t_list = g_list_prepend
3278 (t_list, g_strdup_printf (
"%s %s", _(
"End Date:"), edate));
3283 if (priv->fd.cleared_match != CLEARED_ALL)
3288 gpp_update_match_filter_text (priv->fd.cleared_match, 0x01, _ (
"Unreconciled"),
3290 gpp_update_match_filter_text (priv->fd.cleared_match, 0x02, _ (
"Cleared"),
3292 gpp_update_match_filter_text (priv->fd.cleared_match, 0x04, _ (
"Reconciled"),
3294 gpp_update_match_filter_text (priv->fd.cleared_match, 0x08, _ (
"Frozen"),
3296 gpp_update_match_filter_text (priv->fd.cleared_match, 0x10, _ (
"Voided"),
3299 show = g_list_reverse (show);
3300 hide = g_list_reverse (hide);
3305 t_list = g_list_prepend
3306 (t_list, g_strdup_printf (
"%s %s", _(
"Show:"), str));
3313 t_list = g_list_prepend
3314 (t_list, g_strdup_printf (
"%s %s", _(
"Hide:"), str));
3318 g_list_free_full (show, g_free);
3319 g_list_free_full (hide, g_free);
3322 t_list = g_list_reverse (t_list);
3325 t_list = g_list_prepend (t_list, g_strdup (_(
"Filter By:")));
3328 if (priv->gsr->filter_text != NULL)
3329 g_free (priv->gsr->filter_text);
3334 g_list_free_full (t_list, g_free);
3341 gnc_plugin_page_register_update_page_icon (
GncPluginPage* plugin_page)
3346 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
3348 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
3351 gnc_split_reg_get_read_only (priv->gsr))
3365 gnc_reg_get_name (GNCLedgerDisplay* ledger, gboolean for_window)
3369 gchar* account_name;
3372 GNCLedgerDisplayType ledger_type;
3378 ledger_type = gnc_ledger_display_type (ledger);
3382 case GENERAL_JOURNAL:
3385 reg_name = _ (
"General Journal");
3387 reg_name = _ (
"Transaction Report");
3389 case PORTFOLIO_LEDGER:
3391 reg_name = _ (
"Portfolio");
3393 reg_name = _ (
"Portfolio Report");
3397 reg_name = _ (
"Search Results");
3399 reg_name = _ (
"Search Results Report");
3403 reg_name = _ (
"Register");
3405 reg_name = _ (
"Transaction Report");
3411 if ((leader != NULL) && (ledger_type != LD_GL))
3415 if (ledger_type == LD_SINGLE)
3417 name = g_strconcat (account_name,
" - ", reg_name, NULL);
3421 name = g_strconcat (account_name,
" ", _ (
"and subaccounts"),
" - ", reg_name,
3424 g_free (account_name);
3427 name = g_strdup (reg_name);
3433 report_helper (GNCLedgerDisplay* ledger, Split* split,
Query* query)
3439 swig_type_info* qtype;
3446 func = scm_c_eval_string (
"gnc:register-report-create");
3447 g_return_val_if_fail (scm_is_procedure (func), -1);
3450 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Credit"));
3451 args = scm_cons (arg, args);
3454 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Debit"));
3455 args = scm_cons (arg, args);
3457 str = gnc_reg_get_name (ledger, FALSE);
3458 arg = scm_from_utf8_string (str ? str :
"");
3459 args = scm_cons (arg, args);
3462 arg = SCM_BOOL (reg->use_double_line);
3463 args = scm_cons (arg, args);
3465 arg = SCM_BOOL (reg->type == GENERAL_JOURNAL || reg->type == INCOME_LEDGER
3466 || reg->type == SEARCH_LEDGER);
3467 args = scm_cons (arg, args);
3469 arg = SCM_BOOL (reg->style == REG_STYLE_JOURNAL);
3470 args = scm_cons (arg, args);
3475 g_return_val_if_fail (query != NULL, -1);
3478 qtype = SWIG_TypeQuery (
"_p__QofQuery");
3479 g_return_val_if_fail (qtype, -1);
3481 arg = SWIG_NewPointerObj (query, qtype, 0);
3482 args = scm_cons (arg, args);
3483 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3488 qtype = SWIG_TypeQuery (
"_p_Split");
3489 g_return_val_if_fail (qtype, -1);
3490 arg = SWIG_NewPointerObj (split, qtype, 0);
3496 args = scm_cons (arg, args);
3497 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3500 qtype = SWIG_TypeQuery (
"_p_Account");
3501 g_return_val_if_fail (qtype, -1);
3504 arg = SWIG_NewPointerObj (account, qtype, 0);
3505 args = scm_cons (arg, args);
3506 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3510 arg = scm_apply (func, args, SCM_EOL);
3511 g_return_val_if_fail (scm_is_exact (arg), -1);
3513 return scm_to_int (arg);
3521 gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple,
3525 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3530 GList* splits = NULL, *item;
3531 GNCLedgerDisplayType ledger_type;
3532 Account* account, *subaccount = NULL;
3535 ENTER (
"(action %p, page %p)", simple, page);
3537 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3539 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3541 ledger_type = gnc_ledger_display_type (priv->ledger);
3543 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
3548 if (ledger_type == LD_SUBACCOUNT)
3552 subaccount = account;
3559 splits = g_list_prepend (splits, split);
3560 gnc_ui_print_check_dialog_create (window, splits, subaccount);
3561 g_list_free (splits);
3570 splits = g_list_prepend (splits, split);
3571 gnc_ui_print_check_dialog_create (window, splits, subaccount);
3572 g_list_free (splits);
3577 else if (ledger_type == LD_GL && reg->type == SEARCH_LEDGER)
3585 for (item = splits; item; item = g_list_next (item))
3587 split = (Split*) item->data;
3588 if (common_acct == NULL)
3598 const gchar* title = _ (
"Print checks from multiple accounts?");
3599 const gchar* message =
3600 _ (
"This search result contains splits from more than one account. " 3601 "Do you want to print the checks even though they are not all " 3602 "from the same account?");
3603 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
3604 GTK_DIALOG_DESTROY_WITH_PARENT,
3605 GTK_MESSAGE_WARNING,
3608 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
3610 gtk_dialog_add_button (GTK_DIALOG (dialog), _ (
"_Print checks"),
3612 response = gnc_dialog_run (GTK_DIALOG (dialog),
3613 GNC_PREF_WARN_CHECKPRINTING_MULTI_ACCT);
3614 gtk_widget_destroy (dialog);
3615 if (response != GTK_RESPONSE_YES)
3617 LEAVE (
"Multiple accounts");
3624 gnc_ui_print_check_dialog_create (window, splits, NULL);
3628 gnc_error_dialog (GTK_WINDOW (window),
"%s",
3629 _ (
"You can only print checks from a bank account register or search results."));
3630 LEAVE (
"Unsupported ledger type");
3638 gnc_plugin_page_register_cmd_cut (GSimpleAction *simple,
3642 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3645 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3647 ENTER (
"(action %p, page %p)", simple, page);
3648 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3649 gnucash_register_cut_clipboard (priv->gsr->reg);
3655 gnc_plugin_page_register_cmd_copy (GSimpleAction *simple,
3659 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3662 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3664 ENTER (
"(action %p, page %p)", simple, page);
3665 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3666 gnucash_register_copy_clipboard (priv->gsr->reg);
3672 gnc_plugin_page_register_cmd_paste (GSimpleAction *simple,
3676 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3679 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3681 ENTER (
"(action %p, page %p)", simple, page);
3682 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3683 gnucash_register_paste_clipboard (priv->gsr->reg);
3689 gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple,
3693 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3696 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3698 ENTER (
"(action %p, page %p)", simple, page);
3707 gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple,
3711 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3714 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3717 gnc_find_account_dialog (window, NULL);
3722 gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple,
3726 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3730 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3732 ENTER (
"(action %p, page %p)", simple, page);
3733 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3735 gnc_ui_find_transactions_dialog_create (window, priv->ledger);
3741 gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple,
3745 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3749 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3751 ENTER (
"(action %p, page %p)", simple, page);
3754 gnc_tax_info_dialog (window, account);
3759 gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple,
3763 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3766 ENTER (
"(action %p, page %p)", simple, page);
3768 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3770 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3771 gsr_default_cut_txn_handler (priv->gsr, NULL);
3777 gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple,
3781 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3785 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3787 ENTER (
"(action %p, page %p)", simple, page);
3788 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3796 gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple,
3800 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3804 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3806 ENTER (
"(action %p, page %p)", simple, page);
3807 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3815 gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple,
3819 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3821 GtkWidget* dialog, *entry;
3824 GtkBuilder* builder;
3829 ENTER (
"(action %p, page %p)", simple, page);
3831 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3834 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3844 gnc_error_dialog (window,
"%s",
3845 _ (
"You cannot void a transaction with reconciled or cleared splits."));
3851 gnc_error_dialog (window,
3852 _ (
"This transaction is marked read-only with the comment: '%s'"), reason);
3856 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
3859 builder = gtk_builder_new();
3860 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
3861 "void_transaction_dialog");
3862 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
3863 "void_transaction_dialog"));
3864 entry = GTK_WIDGET (gtk_builder_get_object (builder,
"reason"));
3866 gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
3868 result = gtk_dialog_run (GTK_DIALOG (dialog));
3869 if (result == GTK_RESPONSE_OK)
3871 reason = gtk_entry_get_text (GTK_ENTRY (entry));
3878 gtk_widget_destroy (dialog);
3879 g_object_unref (G_OBJECT (builder));
3884 gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple,
3888 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3893 ENTER (
"(action %p, page %p)", simple, page);
3895 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3897 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3906 static std::optional<time64>
3907 input_date (GtkWidget * parent,
const char *window_title,
const char* title)
3910 if (!gnc_dup_time64_dialog (parent, window_title, title, &rv))
3917 gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
3921 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3925 Transaction* trans, *new_trans;
3930 ENTER (
"(action %p, page %p)", simple, page);
3932 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3934 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3946 LEAVE (
"shouldn't try to reverse the blank transaction...");
3953 const char *rev = _(
"A reversing entry has already been created for this transaction.");
3954 const char *jump = _(
"Jump to the transaction?");
3955 if (!gnc_verify_dialog (GTK_WINDOW (window), TRUE,
"%s\n\n%s", rev, jump))
3957 LEAVE (
"reverse cancelled");
3963 auto date = input_date (window, _(
"Reverse Transaction"), _(
"New Transaction Information"));
3966 LEAVE (
"reverse cancelled");
3970 gnc_suspend_gui_refresh ();
3977 gnc_resume_gui_refresh();
3982 split = xaccTransFindSplitByAccount(new_trans, account);
3985 if (gnc_split_reg_clear_filter_for_split (gsr, split))
3988 gnc_split_reg_jump_to_split (gsr, split);
3996 GNCLedgerDisplayType ledger_type = gnc_ledger_display_type (priv->ledger);
3999 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
4005 case GENERAL_JOURNAL:
4010 case PORTFOLIO_LEDGER:
4020 gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple,
4024 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4027 GtkWidget* dialog, *button;
4028 GtkBuilder* builder;
4033 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4034 ENTER (
"(action %p, page %p)", simple, page);
4036 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4037 if (priv->sd.dialog)
4039 gtk_window_present (GTK_WINDOW (priv->sd.dialog));
4040 LEAVE (
"existing dialog");
4046 builder = gtk_builder_new();
4047 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4049 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_by_dialog"));
4050 priv->sd.dialog = dialog;
4051 gtk_window_set_transient_for (GTK_WINDOW (dialog),
4052 gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)));
4054 title = g_strdup_printf (_ (
"Sort %s by…"),
4056 gtk_window_set_title (GTK_WINDOW (dialog), title);
4060 sort = gnc_split_reg_get_sort_type (priv->gsr);
4061 name = SortTypeasString (sort);
4062 button = GTK_WIDGET (gtk_builder_get_object (builder, name));
4063 DEBUG (
"current sort %d, button %s(%p)", sort, name, button);
4064 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4065 priv->sd.original_sort_type = sort;
4067 button = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_save"));
4068 if (priv->sd.save_order == TRUE)
4069 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4072 gtk_widget_set_visible (GTK_WIDGET (button),
4073 gnc_plugin_page_register_show_fs_save (page));
4076 button = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_reverse"));
4077 if (priv->sd.reverse_order == TRUE)
4078 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4079 priv->sd.original_reverse_order = priv->sd.reverse_order;
4081 priv->sd.num_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"BY_NUM"));
4082 priv->sd.act_radio = GTK_WIDGET (gtk_builder_get_object (builder,
4086 if (reg && !reg->use_tran_num_for_num_field)
4088 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio),
4089 _ (
"Transaction Number"));
4090 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Number/Action"));
4092 gnc_book_option_register_cb (OPTION_NAME_NUM_FIELD_SOURCE,
4093 (GncBOCb)gnc_plugin_page_register_sort_book_option_changed,
4097 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func,
4101 gtk_widget_show (dialog);
4102 g_object_unref (G_OBJECT (builder));
4107 gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple,
4111 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4113 GtkWidget* dialog, *toggle, *button, *
table, *hbox;
4114 time64 start_time, end_time, time_val;
4115 GtkBuilder* builder;
4116 gboolean sensitive, value;
4121 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4122 ENTER (
"(action %p, page %p)", simple, page);
4124 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4125 if (priv->fd.dialog)
4127 gtk_window_present (GTK_WINDOW (priv->fd.dialog));
4128 LEAVE (
"existing dialog");
4133 builder = gtk_builder_new();
4134 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4136 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4137 "filter_by_dialog");
4138 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_by_dialog"));
4139 priv->fd.dialog = dialog;
4140 gtk_window_set_transient_for (GTK_WINDOW (dialog),
4141 gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)));
4144 title = g_strdup_printf (_ (
"Filter %s by…"),
4146 gtk_window_set_title (GTK_WINDOW (dialog), title);
4150 for (i = 0; status_actions[i].action_name; i++)
4152 toggle = GTK_WIDGET (gtk_builder_get_object (builder,
4153 status_actions[i].action_name));
4154 value = priv->fd.cleared_match & status_actions[i].value;
4155 status_actions[i].widget = toggle;
4156 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), value);
4158 priv->fd.original_cleared_match = priv->fd.cleared_match;
4160 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_save"));
4161 if (priv->fd.save_filter == TRUE)
4162 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4165 gtk_widget_set_visible (GTK_WIDGET (button),
4166 gnc_plugin_page_register_show_fs_save (page));
4169 priv->fd.num_days = GTK_WIDGET (gtk_builder_get_object (builder,
4170 "filter_show_num_days"));
4171 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_show_days"));
4175 if (priv->fd.days > 0)
4177 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4178 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.num_days), TRUE);
4179 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->fd.num_days), priv->fd.days);
4180 priv->fd.original_days = priv->fd.days;
4188 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.num_days), FALSE);
4189 priv->fd.original_days = 0;
4193 xaccQueryGetDateMatchTT (query, &start_time, &end_time);
4197 priv->fd.original_start_time = start_time;
4198 priv->fd.start_time = start_time;
4199 priv->fd.original_end_time = end_time;
4200 priv->fd.end_time = end_time;
4202 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_show_range"));
4203 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), start_time ||
4205 table = GTK_WIDGET (gtk_builder_get_object (builder,
"select_range_table"));
4206 priv->fd.table =
table;
4207 gtk_widget_set_sensitive (GTK_WIDGET (
table), start_time || end_time);
4209 priv->fd.start_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
4210 "start_date_choose"));
4211 priv->fd.start_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
4212 "start_date_today"));
4213 priv->fd.end_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
4214 "end_date_choose"));
4215 priv->fd.end_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
4220 if (start_time == 0)
4222 button = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_earliest"));
4223 time_val = xaccQueryGetEarliestDateFound (query);
4228 time_val = start_time;
4232 button = priv->fd.start_date_today;
4237 button = priv->fd.start_date_choose;
4241 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4242 priv->fd.start_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
4243 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_hbox"));
4244 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.start_date, TRUE, TRUE, 0);
4245 gtk_widget_show (priv->fd.start_date);
4246 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.start_date), sensitive);
4247 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.start_date), time_val);
4248 g_signal_connect (G_OBJECT (priv->fd.start_date),
"date-changed",
4249 G_CALLBACK (gnc_plugin_page_register_filter_gde_changed_cb),
4257 button = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_latest"));
4258 time_val = xaccQueryGetLatestDateFound (query);
4263 time_val = end_time;
4267 button = priv->fd.end_date_today;
4272 button = priv->fd.end_date_choose;
4276 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4277 priv->fd.end_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
4278 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_hbox"));
4279 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.end_date, TRUE, TRUE, 0);
4280 gtk_widget_show (priv->fd.end_date);
4281 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.end_date), sensitive);
4282 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.end_date), time_val);
4283 g_signal_connect (G_OBJECT (priv->fd.end_date),
"date-changed",
4284 G_CALLBACK (gnc_plugin_page_register_filter_gde_changed_cb),
4289 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func,
4293 gtk_widget_show (dialog);
4294 g_object_unref (G_OBJECT (builder));
4299 gnc_plugin_page_register_cmd_reload (GSimpleAction *simple,
4303 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4307 ENTER (
"(action %p, page %p)", simple, page);
4309 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4311 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4317 LEAVE (
"register has pending edits");
4325 gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple,
4326 GVariant *parameter,
4329 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4333 ENTER (
"(action %p, page %p)", simple, page);
4335 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4337 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4341 g_action_change_state (G_ACTION(simple), parameter);
4343 gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh);
4345 gnc_plugin_page_register_ui_update (NULL, page);
4350 gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple,
4351 GVariant *parameter,
4354 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4357 gboolean use_double_line;
4360 ENTER (
"(action %p, page %p)", simple, page);
4362 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
4364 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4367 state = g_action_get_state (G_ACTION(simple));
4369 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
4371 use_double_line = !g_variant_get_boolean (state);
4373 if (use_double_line != reg->use_double_line)
4376 if (priv->enable_refresh)
4379 g_variant_unref (state);
4384 gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple,
4388 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4390 GncWindow* gnc_window;
4393 ENTER (
"(action %p, page %p)", simple, page);
4395 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4398 gnc_window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
4399 window = GTK_WIDGET (gnc_window_get_gtk_window (gnc_window));
4400 gnc_xfer_dialog (window, account);
4405 gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple,
4409 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4412 RecnWindow* recnData;
4414 ENTER (
"(action %p, page %p)", simple, page);
4416 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4426 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
4431 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4433 recnData = recnWindow (GTK_WIDGET (window), account);
4434 gnc_ui_reconcile_window_raise (recnData);
4439 gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple,
4443 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4447 ENTER (
"(action %p, page %p)", simple, page);
4449 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4450 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
4452 gnc_stock_transaction_assistant (GTK_WIDGET (window), account);
4458 gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple,
4462 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4465 AutoClearWindow* autoClearData;
4467 ENTER (
"(action %p, page %p)", simple, page);
4469 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4473 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4475 autoClearData = autoClearWindow (GTK_WIDGET (window), account);
4476 gnc_ui_autoclear_window_raise (autoClearData);
4481 gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple,
4485 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4489 ENTER (
"(action %p, page %p)", simple, page);
4491 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4494 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
4495 gnc_stock_split_dialog (GTK_WIDGET (window), account);
4500 gnc_plugin_page_register_cmd_lots (GSimpleAction *simple,
4504 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4508 ENTER (
"(action %p, page %p)", simple, page);
4510 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4512 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4515 gnc_lot_viewer_dialog (window, account);
4520 gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple,
4524 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4527 ENTER (
"(action %p, page %p)", simple, page);
4529 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4531 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4532 gnc_split_reg_enter (priv->gsr, FALSE);
4537 gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple,
4541 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4544 ENTER (
"(action %p, page %p)", simple, page);
4546 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4548 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4555 gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple,
4559 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4562 ENTER (
"(action %p, page %p)", simple, page);
4564 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4566 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4567 gsr_default_delete_handler (priv->gsr, NULL);
4573 gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple,
4577 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4580 ENTER (
"(action %p, page %p)", simple, page);
4582 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4584 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4585 gsr_default_doclink_handler (priv->gsr);
4586 gnc_plugin_page_register_ui_update (NULL, page);
4591 gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple,
4595 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4598 ENTER (
"(action %p, page %p)", simple, page);
4600 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4602 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4603 gsr_default_doclink_open_handler (priv->gsr);
4607 static GncInvoice* invoice_from_split (Split* split)
4609 GncInvoice* invoice;
4628 gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple,
4632 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4635 GncInvoice* invoice;
4639 ENTER (
"(action %p, page %p)", simple, page);
4641 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4642 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4646 window = GNC_PLUGIN_PAGE(page)->window;
4650 auto invoices = invoices_from_transaction (txn);
4651 if (invoices.empty())
4652 PERR (
"shouldn't happen: if no invoices, function is never called");
4653 else if (invoices.size() == 1)
4654 invoice = invoices[0];
4657 GList *details = NULL;
4660 for (
const auto& inv : invoices)
4665 gnc_account_print_info (gncInvoiceGetPostedAcc (inv), TRUE));
4666 details = g_list_prepend
4671 g_strdup_printf (_(
"%s %s from %s, posted %s, amount %s"),
4672 gncInvoiceGetTypeString (inv),
4673 gncInvoiceGetID (inv),
4674 gncOwnerGetName (gncInvoiceGetOwner (inv)),
4678 details = g_list_reverse (details);
4679 choice = gnc_choose_radio_option_dialog
4680 (window, _(
"Select document"),
4681 _(
"Several documents are linked with this transaction. \ 4682 Please choose one:"), _(
"Select"), 0, details);
4683 if ((choice >= 0) && ((
size_t)choice < invoices.size()))
4684 invoice = invoices[choice];
4685 g_list_free_full (details, g_free);
4691 GtkWindow *gtk_window = gnc_window_get_gtk_window (GNC_WINDOW (window));
4692 gnc_ui_invoice_edit (gtk_window, invoice);
4699 gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple,
4703 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4707 ENTER (
"(action %p, page %p)", simple, page);
4709 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4711 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4717 gnc_split_reg_jump_to_blank (priv->gsr);
4722 find_after_date (Split *split,
time64* find_date)
4731 gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
4735 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4741 ENTER (
"(action %p, page %p)", simple, page);
4742 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4744 auto date = input_date (window, _(
"Go to Date"), _(
"Go to Date"));
4748 LEAVE (
"goto_date cancelled");
4759 auto it = g_list_find_custom (splits, &date.value(), (GCompareFunc)find_after_date);
4762 gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(it->data));
4764 gnc_split_reg_jump_to_blank (gsr);
4766 g_list_free (splits);
4771 gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple,
4775 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4778 ENTER (
"(action %p, page %p)", simple, page);
4780 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4782 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4789 gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple,
4793 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4796 ENTER (
"(action %p, page %p)", simple, page);
4798 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4800 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4801 gsr_default_reinit_handler (priv->gsr, NULL);
4806 gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple,
4807 GVariant *parameter,
4810 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4816 ENTER (
"(action %p, page %p)", simple, page);
4818 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4820 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4823 state = g_action_get_state (G_ACTION(simple));
4825 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
4827 expand = !g_variant_get_boolean (state);
4830 g_variant_unref (state);
4837 gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple,
4841 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4845 ENTER (
"(action %p, page %p)", simple, page);
4847 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4849 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4858 gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
4862 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4872 ENTER (
"(action %p, page %p)", simple, page);
4874 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4876 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4877 window = GNC_PLUGIN_PAGE (page)->window;
4880 LEAVE (
"no window");
4888 LEAVE (
"no split (1)");
4893 if (account == NULL)
4895 LEAVE (
"no account");
4900 if (account == leader)
4905 LEAVE (
"no split (2)");
4910 if (account == NULL)
4912 LEAVE (
"no account (2)");
4916 if (account == leader)
4918 LEAVE (
"register open for account");
4924 if (new_page == NULL)
4926 LEAVE (
"couldn't create new page");
4934 if (gnc_split_reg_clear_filter_for_split (gsr, split))
4937 gnc_split_reg_jump_to_split (gsr, split);
4942 gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple,
4946 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4950 ENTER (
"(action %p, page %p)", simple, page);
4952 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4956 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4957 gsr_default_schedule_handler (priv->gsr, window);
4962 scrub_split (Split *split)
4968 g_return_if_fail (split);
4972 g_return_if_fail (trans);
4984 gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple,
4988 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4993 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4995 ENTER (
"(action %p, page %p)", simple, page);
4997 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5001 LEAVE (
"no query found");
5007 gnc_suspend_gui_refresh();
5009 gnc_resume_gui_refresh();
5014 scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data)
5016 if (event->length == 0)
return FALSE;
5018 switch (event->keyval)
5020 case GDK_KEY_Escape:
5022 auto abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget),
false,
5023 "%s", _(check_repair_abort_YN));
5037 gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple,
5041 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5045 GList* node, *splits;
5046 gint split_count = 0, curr_split_no = 0;
5047 gulong scrub_kp_handler_ID;
5048 const char* message = _ (
"Checking splits in current register: %u of %u");
5050 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5052 ENTER (
"(action %p, page %p)", simple, page);
5054 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5058 LEAVE (
"no query found");
5062 gnc_suspend_gui_refresh();
5063 is_scrubbing = TRUE;
5065 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5066 scrub_kp_handler_ID = g_signal_connect (G_OBJECT (window),
"key-press-event",
5067 G_CALLBACK (scrub_kp_handler), NULL);
5068 gnc_window_set_progressbar_window (window);
5071 split_count = g_list_length (splits);
5072 for (node = splits; node && !gnc_get_abort_scrub (); node = node->next, curr_split_no++)
5074 auto split = GNC_SPLIT(node->data);
5076 if (!split)
continue;
5078 PINFO (
"Start processing split %d of %d",
5079 curr_split_no + 1, split_count);
5081 scrub_split (split);
5083 PINFO (
"Finished processing split %d of %d",
5084 curr_split_no + 1, split_count);
5086 if (curr_split_no % 10 == 0)
5088 char* progress_msg = g_strdup_printf (message, curr_split_no, split_count);
5089 gnc_window_show_progress (progress_msg, (100 * curr_split_no) / split_count);
5090 g_free (progress_msg);
5094 g_signal_handler_disconnect (G_OBJECT(window), scrub_kp_handler_ID);
5095 gnc_window_show_progress (NULL, -1.0);
5096 is_scrubbing = FALSE;
5097 show_abort_verify = TRUE;
5100 gnc_resume_gui_refresh();
5105 gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple,
5109 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5111 GncMainWindow* window;
5114 ENTER (
"(action %p, page %p)", simple, page);
5116 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5118 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5119 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5120 id = report_helper (priv->ledger, NULL, NULL);
5122 gnc_main_window_open_report (
id, window);
5127 gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple,
5131 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5133 GncMainWindow* window;
5140 ENTER (
"(action %p, page %p)", simple, page);
5142 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5144 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5151 query = qof_query_create_for (GNC_ID_SPLIT);
5156 GNC_ID_SPLIT, QOF_QUERY_AND);
5158 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5159 id = report_helper (priv->ledger, split, query);
5161 gnc_main_window_open_report (
id, window);
5177 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
5179 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
5180 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5181 priv->lines_default = lines_default;
5182 priv->read_only = read_only;
5191 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
5193 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
5194 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5200 gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
5208 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page));
5210 window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window);
5220 (GNC_MAIN_WINDOW(window)) != GNC_PLUGIN_PAGE(register_page)))
5224 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
5226 help = gnc_table_get_help (reg->table);
5227 gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help);
5232 gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
5237 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5239 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5247 GNC_PLUGIN_PAGE (page));
5251 gnc_plugin_page_register_refresh_cb (GHashTable* changes, gpointer user_data)
5253 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5256 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5257 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5262 ei = gnc_gui_get_entity_events (changes, &priv->key);
5265 if (ei->event_mask & QOF_EVENT_DESTROY)
5270 if (ei->event_mask & QOF_EVENT_MODIFY)
5278 gnucash_register_refresh_from_prefs (priv->gsr->reg);
5279 gtk_widget_queue_draw (priv->widget);
5282 gnc_plugin_page_register_ui_update (NULL, page);
5286 gnc_plugin_page_register_close_cb (gpointer user_data)
5301 gppr_account_destroy_cb (
Account* account)
5305 GNCLedgerDisplayType ledger_type;
5308 GList* item, *kill = NULL;
5315 for (; citem; citem = g_list_next (citem))
5318 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5319 ledger_type = gnc_ledger_display_type (priv->ledger);
5320 if (ledger_type == LD_GL)
5322 kill = g_list_prepend (kill, page);
5325 else if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
5327 if (guid_compare (acct_guid, &priv->key) == 0)
5329 kill = g_list_prepend (kill, page);
5334 kill = g_list_reverse (kill);
5336 for (item = kill; item; item = g_list_next (item))
5359 gnc_plugin_page_register_event_handler (
QofInstance* entity,
5369 g_return_if_fail (page);
5370 if (!GNC_IS_TRANS (entity) && !GNC_IS_ACCOUNT (entity))
5373 ENTER (
"entity %p of type %d, page %p, event data %p",
5374 entity, event_type, page, ed);
5378 if (GNC_IS_ACCOUNT (entity))
5380 if (GNC_IS_MAIN_WINDOW (window))
5386 LEAVE (
"account is NULL");
5390 gchar *name = gnc_plugin_page_register_get_tab_name (GNC_PLUGIN_PAGE (page));
5393 gchar *long_name = gnc_plugin_page_register_get_long_name (GNC_PLUGIN_PAGE (page));
5396 gchar *color = gnc_plugin_page_register_get_tab_color (GNC_PLUGIN_PAGE (page));
5399 gnc_plugin_page_register_update_page_icon (GNC_PLUGIN_PAGE (page));
5405 LEAVE (
"tab contents updated");
5409 if (! (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
5411 LEAVE (
"not a modify");
5414 trans = GNC_TRANS (entity);
5418 LEAVE (
"not in this book");
5422 if (GNC_IS_MAIN_WINDOW (window))
5425 if (visible_page != GNC_PLUGIN_PAGE (page))
5427 LEAVE (
"page not visible");
5432 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_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.
void gnc_plugin_page_register_filter_save_cb(GtkToggleButton *button, GncPluginPageRegister *page)
This function is called whenever the save status is checked or unchecked.
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.
void gnc_plugin_page_register_filter_days_changed_cb(GtkSpinButton *button, GncPluginPageRegister *page)
This function is called when the "number of days" spin button is changed which is then saved and upda...
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...
gchar * gnc_g_list_stringjoin(GList *list_of_strings, const gchar *sep)
Return a string joining a GList whose elements are gchar* strings.
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.
void qof_query_purge_terms(QofQuery *q, QofQueryParamList *param_list)
Remove query terms of a particular type from q.
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...
gboolean gnc_menubar_model_find_item(GMenuModel *menu_model, GncMenuModelSearch *gsm)
Find a GtkMenu item from the action name.
gint gnc_state_drop_sections_for(const gchar *partial_name)
Drop all sections from the state file whose name contains partial_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.
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
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.
void gnc_plugin_page_register_sort_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister *plugin_page)
This function is called when the "Sort By…" dialog is closed.
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.
void gnc_tm_get_today_start(struct tm *tm)
The gnc_tm_get_today_start() routine takes a pointer to a struct tm and fills it in with the first se...
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.
#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...
GKeyFile * gnc_state_get_current(void)
Returns a pointer to the most recently loaded state.
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.
void gnc_tm_free(struct tm *time)
free a struct tm* created with gnc_localtime() or gnc_gmtime()
const char * xaccAccountGetColor(const Account *acc)
Get the account's color.
void gnc_plugin_page_register_filter_select_range_cb(GtkRadioButton *button, GncPluginPageRegister *page)
This function is called when the radio buttons changes state.
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.
void gnc_plugin_page_register_sort_button_cb(GtkToggleButton *button, GncPluginPageRegister *page)
This function is called when a radio button in the "Sort By…" dialog is clicked. ...
convert single-entry accounts to clean double-entry
char * qof_print_date(time64 secs)
Convenience; calls through to qof_print_date_dmy_buff().
gboolean xaccTransHasSplitsInState(const Transaction *trans, const char state)
FIXME: document me.
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_register_filter_end_cb(GtkWidget *radio, GncPluginPageRegister *page)
This function is called when one of the end date radio buttons is selected.
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.
gboolean gncScrubBusinessSplit(Split *split)
The gncScrubBusinessSplit() function will fix all issues found with the given split.
void gnc_plugin_page_register_filter_start_cb(GtkWidget *radio, GncPluginPageRegister *page)
This function is called when one of the start date radio buttons is selected.
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...
time64 gnc_time64_get_day_start(time64 time_val)
The gnc_time64_get_day_start() routine will take the given time in seconds and adjust it to the first...
void gnc_plugin_page_register_filter_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister *plugin_page)
This function is called when the "Filter By…" dialog is closed.
const gchar * plugin_name
The textual name of this plugin.
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.
gchar * gnc_list_formatter(GList *strings)
This function takes a GList of char*, and uses locale-sensitive list formatter.
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.
time64 gnc_time64_get_today_start(void)
The gnc_time64_get_today_start() routine returns a time64 value corresponding to the first second of ...
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.
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
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...
Additional event handling code.
#define xaccSplitGetGUID(X)
struct tm * gnc_localtime(const time64 *secs)
fill out a time struct from a 64-bit time value.
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.
void gnc_plugin_page_register_filter_status_one_cb(GtkToggleButton *button, GncPluginPageRegister *page)
This function is called whenever one of the status entries is checked or unchecked.
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_plugin_page_register_filter_status_clear_all_cb(GtkButton *button, GncPluginPageRegister *plugin_page)
This function is called whenever the "clear all" status button is clicked.
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.
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().
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.
void gnc_plugin_page_register_filter_status_select_all_cb(GtkButton *button, GncPluginPageRegister *plugin_page)
This function is called whenever the "select all" status button is clicked.
time64 gnc_time64_get_today_end(void)
The gnc_time64_get_today_end() routine returns a time64 value corresponding to the last second of tod...
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.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void gnc_plugin_page_register_sort_order_save_cb(GtkToggleButton *button, GncPluginPageRegister *page)
This function is called whenever the save sort order is checked or unchecked which allows saving of t...
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
time64 gnc_time64_get_day_end(time64 time_val)
The gnc_time64_get_day_end() routine will take the given time in seconds and adjust it to the last se...
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.
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 gnc_plugin_page_register_sort_order_reverse_cb(GtkToggleButton *button, GncPluginPageRegister *page)
This function is called whenever the reverse sort order is checked or unchecked which allows reversin...
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.
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...