42 #include <glib/gi18n.h> 43 #include "swig-runtime.h" 44 #include "guile-mappings.h" 47 #include "gnc-plugin-register.h" 50 #include "gnc-plugin-business.h" 53 #include "dialog-dup-trans.h" 54 #include "dialog-find-account.h" 55 #include "dialog-find-transactions.h" 56 #include "dialog-print-check.h" 57 #include "dialog-invoice.h" 58 #include "dialog-transfer.h" 59 #include "dialog-utils.h" 60 #include "assistant-stock-split.h" 61 #include "assistant-stock-transaction.h" 62 #include "gnc-component-manager.h" 64 #include "gnc-date-edit.h" 71 #include "gnc-gui-query.h" 72 #include "gnc-icons.h" 73 #include "gnc-split-reg.h" 79 #include "gnc-session.h" 81 #include "gnc-warnings.h" 83 #include "dialog-lot-viewer.h" 87 #include "window-reconcile.h" 88 #include "window-autoclear.h" 89 #include "window-report.h" 90 #include "engine-helpers.h" 91 #include "qofbookslots.h" 98 JUMP_LARGEST_VALUE_FIRST_SPLIT = 1,
99 JUMP_SMALLEST_VALUE_FIRST_SPLIT = 2,
100 } GncPrefJumpMultSplits;
103 static QofLogModule log_module = GNC_MOD_GUI;
105 #define DEFAULT_LINES_AMOUNT 50 106 #define DEFAULT_FILTER_NUM_DAYS_GL "30" 108 static void gnc_plugin_page_register_finalize (GObject*
object);
112 static GtkWidget* gnc_plugin_page_register_create_widget (
114 static void gnc_plugin_page_register_destroy_widget (
GncPluginPage*
116 static void gnc_plugin_page_register_window_changed (
GncPluginPage*
117 plugin_page, GtkWidget* window);
118 static gboolean gnc_plugin_page_register_focus_widget (
GncPluginPage*
120 static void gnc_plugin_page_register_focus (
GncPluginPage* plugin_page,
121 gboolean current_page);
122 static void gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
123 GKeyFile* file,
const gchar* group);
124 static GncPluginPage* gnc_plugin_page_register_recreate_page (
125 GtkWidget* window, GKeyFile* file,
const gchar* group);
126 static void gnc_plugin_page_register_update_edit_menu (
GncPluginPage* page,
128 static gboolean gnc_plugin_page_register_finish_pending (
GncPluginPage* page);
130 static gchar* gnc_plugin_page_register_get_tab_name (
GncPluginPage*
132 static gchar* gnc_plugin_page_register_get_tab_color (
GncPluginPage*
134 static gchar* gnc_plugin_page_register_get_long_name (
GncPluginPage*
137 static void gnc_plugin_page_register_summarybar_position_changed (
138 gpointer prefs, gchar* pref, gpointer user_data);
153 static gchar* gnc_plugin_page_register_get_sort_order (
GncPluginPage*
155 void gnc_plugin_page_register_set_sort_order (
GncPluginPage* plugin_page,
156 const gchar* sort_order);
157 static gboolean gnc_plugin_page_register_get_sort_reversed (
159 void gnc_plugin_page_register_set_sort_reversed (
GncPluginPage* plugin_page,
160 gboolean reverse_order);
185 static time64 gnc_plugin_page_register_filter_dmy2time (
char* date_string);
186 static gchar* gnc_plugin_page_register_filter_time2dmy (
time64 raw_time);
187 static gchar* gnc_plugin_page_register_get_filter (
GncPluginPage* plugin_page);
188 void gnc_plugin_page_register_set_filter (
GncPluginPage* plugin_page,
189 const gchar* filter);
196 static void gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
197 static void gnc_plugin_page_register_cmd_cut (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
198 static void gnc_plugin_page_register_cmd_copy (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
199 static void gnc_plugin_page_register_cmd_paste (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
200 static void gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
201 static void gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
202 static void gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
203 static void gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
204 static void gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
205 static void gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
206 static void gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
207 static void gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
208 static void gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
209 static void gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
210 static void gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
211 static void gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
213 static void gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
214 static void gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
215 static void gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple, GVariant *parameter, gpointer user_data);
217 static void gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
218 static void gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
219 static void gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
220 static void gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
221 static void gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
222 static void gnc_plugin_page_register_cmd_lots (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
223 static void gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
224 static void gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
225 static void gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
226 static void gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
227 static void gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
228 static void gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
229 static void gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
230 static void gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
231 static void gnc_plugin_page_register_cmd_jump (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
232 static void gnc_plugin_page_register_cmd_reload (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
233 static void gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
234 static void gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
235 static void gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
236 static void gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
237 static void gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
238 static void gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
239 static void gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
240 static void gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple, GVariant *paramter, gpointer user_data);
242 static void gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
244 static void gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
246 static void gnc_plugin_page_register_refresh_cb (GHashTable* changes,
248 static void gnc_plugin_page_register_close_cb (gpointer user_data);
250 static void gnc_plugin_page_register_ui_update (gpointer various,
252 static void gppr_account_destroy_cb (
Account* account);
253 static void gnc_plugin_page_register_event_handler (
QofInstance* entity,
258 static GncInvoice* invoice_from_split (Split* split);
264 #define CUT_TRANSACTION_LABEL N_("Cu_t Transaction") 265 #define COPY_TRANSACTION_LABEL N_("_Copy Transaction") 266 #define PASTE_TRANSACTION_LABEL N_("_Paste Transaction") 267 #define DUPLICATE_TRANSACTION_LABEL N_("Dup_licate Transaction") 268 #define DELETE_TRANSACTION_LABEL N_("_Delete Transaction") 272 #define LINK_TRANSACTION_LABEL N_("_Manage Document Link…") 276 #define LINK_TRANSACTION_OPEN_LABEL N_("_Open Linked Document") 279 #define JUMP_LINKED_INVOICE_LABEL N_("Jump to Business item") 280 #define CUT_SPLIT_LABEL N_("Cu_t Split") 281 #define COPY_SPLIT_LABEL N_("_Copy Split") 282 #define PASTE_SPLIT_LABEL N_("_Paste Split") 283 #define DUPLICATE_SPLIT_LABEL N_("Dup_licate Split") 284 #define DELETE_SPLIT_LABEL N_("_Delete Split") 285 #define CUT_TRANSACTION_TIP N_("Cut the selected transaction into clipboard") 286 #define COPY_TRANSACTION_TIP N_("Copy the selected transaction into clipboard") 287 #define PASTE_TRANSACTION_TIP N_("Paste the transaction from the clipboard") 288 #define DUPLICATE_TRANSACTION_TIP N_("Make a copy of the current transaction") 289 #define DELETE_TRANSACTION_TIP N_("Delete the current transaction") 290 #define LINK_TRANSACTION_TIP N_("Add, change, or unlink the document linked with the current transaction") 291 #define LINK_TRANSACTION_OPEN_TIP N_("Open the linked document for the current transaction") 292 #define JUMP_LINKED_INVOICE_TIP N_("Jump to the linked invoice, bill, expense or credit note") 293 #define CUT_SPLIT_TIP N_("Cut the selected split into clipboard") 294 #define COPY_SPLIT_TIP N_("Copy the selected split into clipboard") 295 #define PASTE_SPLIT_TIP N_("Paste the split from the clipboard") 296 #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split") 297 #define DELETE_SPLIT_TIP N_("Delete the current split") 299 static GActionEntry gnc_plugin_page_register_actions [] =
301 {
"FilePrintAction", gnc_plugin_page_register_cmd_print_check, NULL, NULL, NULL },
302 {
"EditCutAction", gnc_plugin_page_register_cmd_cut, NULL, NULL, NULL },
303 {
"EditCopyAction", gnc_plugin_page_register_cmd_copy, NULL, NULL, NULL },
304 {
"EditPasteAction", gnc_plugin_page_register_cmd_paste, NULL, NULL, NULL },
305 {
"EditEditAccountAction", gnc_plugin_page_register_cmd_edit_account, NULL, NULL, NULL },
306 {
"EditFindAccountAction", gnc_plugin_page_register_cmd_find_account, NULL, NULL, NULL },
307 {
"EditFindTransactionsAction", gnc_plugin_page_register_cmd_find_transactions, NULL, NULL, NULL },
308 {
"EditTaxOptionsAction", gnc_plugin_page_register_cmd_edit_tax_options, NULL, NULL, NULL },
309 {
"CutTransactionAction", gnc_plugin_page_register_cmd_cut_transaction, NULL, NULL, NULL },
310 {
"CopyTransactionAction", gnc_plugin_page_register_cmd_copy_transaction, NULL, NULL, NULL },
311 {
"PasteTransactionAction", gnc_plugin_page_register_cmd_paste_transaction, NULL, NULL, NULL },
312 {
"DuplicateTransactionAction", gnc_plugin_page_register_cmd_duplicate_transaction, NULL, NULL, NULL },
313 {
"DeleteTransactionAction", gnc_plugin_page_register_cmd_delete_transaction, NULL, NULL, NULL },
314 {
"RemoveTransactionSplitsAction", gnc_plugin_page_register_cmd_reinitialize_transaction, NULL, NULL, NULL },
315 {
"RecordTransactionAction", gnc_plugin_page_register_cmd_enter_transaction, NULL, NULL, NULL },
316 {
"CancelTransactionAction", gnc_plugin_page_register_cmd_cancel_transaction, NULL, NULL, NULL },
317 {
"VoidTransactionAction", gnc_plugin_page_register_cmd_void_transaction, NULL, NULL, NULL },
318 {
"UnvoidTransactionAction", gnc_plugin_page_register_cmd_unvoid_transaction, NULL, NULL, NULL },
319 {
"ReverseTransactionAction", gnc_plugin_page_register_cmd_reverse_transaction, NULL, NULL, NULL },
320 {
"LinkTransactionAction", gnc_plugin_page_register_cmd_linked_transaction, NULL, NULL, NULL },
321 {
"LinkedTransactionOpenAction", gnc_plugin_page_register_cmd_linked_transaction_open, NULL, NULL, NULL },
322 {
"JumpLinkedInvoiceAction", gnc_plugin_page_register_cmd_jump_linked_invoice, NULL, NULL, NULL },
323 {
"ViewSortByAction", gnc_plugin_page_register_cmd_view_sort_by, NULL, NULL, NULL },
324 {
"ViewFilterByAction", gnc_plugin_page_register_cmd_view_filter_by, NULL, NULL, NULL },
325 {
"ViewRefreshAction", gnc_plugin_page_register_cmd_reload, NULL, NULL, NULL },
326 {
"ActionsTransferAction", gnc_plugin_page_register_cmd_transfer, NULL, NULL, NULL },
327 {
"ActionsReconcileAction", gnc_plugin_page_register_cmd_reconcile, NULL, NULL, NULL },
328 {
"ActionsAutoClearAction", gnc_plugin_page_register_cmd_autoclear, NULL, NULL, NULL },
329 {
"ActionsStockAssistantAction", gnc_plugin_page_register_cmd_stock_assistant, NULL, NULL, NULL },
330 {
"ActionsStockSplitAction", gnc_plugin_page_register_cmd_stock_split, NULL, NULL, NULL },
331 {
"ActionsLotsAction", gnc_plugin_page_register_cmd_lots, NULL, NULL, NULL },
332 {
"BlankTransactionAction", gnc_plugin_page_register_cmd_blank_transaction, NULL, NULL, NULL },
333 {
"GotoDateAction", gnc_plugin_page_register_cmd_goto_date, NULL, NULL, NULL },
334 {
"EditExchangeRateAction", gnc_plugin_page_register_cmd_exchange_rate, NULL, NULL, NULL },
335 {
"JumpTransactionAction", gnc_plugin_page_register_cmd_jump, NULL, NULL, NULL },
336 {
"ScheduleTransactionAction", gnc_plugin_page_register_cmd_schedule, NULL, NULL, NULL },
337 {
"ScrubAllAction", gnc_plugin_page_register_cmd_scrub_all, NULL, NULL, NULL },
338 {
"ScrubCurrentAction", gnc_plugin_page_register_cmd_scrub_current, NULL, NULL, NULL },
339 {
"ReportsAccountReportAction", gnc_plugin_page_register_cmd_account_report, NULL, NULL, NULL },
340 {
"ReportsAcctTransReportAction", gnc_plugin_page_register_cmd_transaction_report, NULL, NULL, NULL },
342 {
"ViewStyleDoubleLineAction", gnc_plugin_page_register_cmd_style_double_line, NULL,
"false", NULL },
343 {
"SplitTransactionAction", gnc_plugin_page_register_cmd_expand_transaction, NULL,
"false", NULL },
344 {
"ViewStyleRadioAction", gnc_plugin_page_register_cmd_style_changed,
"i",
"@i 0", NULL },
346 static guint gnc_plugin_page_register_n_actions = G_N_ELEMENTS(gnc_plugin_page_register_actions);
349 static const gchar *gnc_plugin_load_ui_items [] =
365 "ActionsPlaceholder4",
366 "ActionsPlaceholder5",
367 "ActionsPlaceholder6",
368 "ReportsPlaceholder1",
374 static const gchar* actions_requiring_account[] =
376 "EditEditAccountAction",
377 "ActionsReconcileAction",
378 "ActionsAutoClearAction",
383 static const gchar* actions_requiring_priced_account[] =
385 "ActionsStockAssistantAction",
392 {
"ActionsTransferAction", N_ (
"Transfer") },
393 {
"RecordTransactionAction", N_ (
"Enter") },
394 {
"CancelTransactionAction", N_ (
"Cancel") },
395 {
"DeleteTransactionAction", N_ (
"Delete") },
396 {
"DuplicateTransactionAction", N_ (
"Duplicate") },
397 {
"SplitTransactionAction",
399 N_ (
"Show Splits") },
400 {
"JumpTransactionAction", N_ (
"Jump") },
401 {
"ScheduleTransactionAction", N_ (
"Schedule") },
402 {
"BlankTransactionAction", N_ (
"Blank") },
403 {
"ActionsReconcileAction", N_ (
"Reconcile") },
404 {
"ActionsStockAssistantAction", N_ (
"Stock Assistant") },
410 const char* action_name;
417 {
"filter_status_reconciled", CLEARED_RECONCILED, NULL },
418 {
"filter_status_cleared", CLEARED_CLEARED, NULL },
419 {
"filter_status_voided", CLEARED_VOIDED, NULL },
420 {
"filter_status_frozen", CLEARED_FROZEN, NULL },
421 {
"filter_status_unreconciled", CLEARED_NO, NULL },
425 #define CLEARED_VALUE "cleared_value" 426 #define DEFAULT_FILTER "0x001f" 427 #define DEFAULT_SORT_ORDER "BY_STANDARD" 435 GNCLedgerDisplay* ledger;
440 gint event_handler_id;
441 gint component_manager_id;
447 gboolean enable_refresh;
454 GtkWidget* num_radio;
455 GtkWidget* act_radio;
456 SortType original_sort_type;
457 gboolean original_save_order;
459 gboolean reverse_order;
460 gboolean original_reverse_order;
467 GtkWidget* start_date_choose;
468 GtkWidget* start_date_today;
469 GtkWidget* start_date;
470 GtkWidget* end_date_choose;
471 GtkWidget* end_date_today;
474 cleared_match_t original_cleared_match;
475 cleared_match_t cleared_match;
476 time64 original_start_time;
482 gboolean original_save_filter;
483 gboolean save_filter;
488 GNC_TYPE_PLUGIN_PAGE)
490 #define GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(o) \ 491 ((GncPluginPageRegisterPrivate*)gnc_plugin_page_register_get_instance_private((GncPluginPageRegister*)o)) 498 gnc_plugin_page_register_new_common (GNCLedgerDisplay* ledger)
511 if (!gnc_features_check_used (gnc_get_current_book(), GNC_FEATURE_REG_SORT_FILTER))
515 if (!gnc_using_equity_type_opening_balance_account (gnc_get_current_book()))
516 gnc_set_use_equity_type_opening_balance_account (gnc_get_current_book());
519 gsr = GNC_SPLIT_REG(gnc_ledger_display_get_user_data (ledger));
523 for (; item; item = g_list_next (item))
526 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
527 if (priv->gsr == gsr)
528 return GNC_PLUGIN_PAGE (register_page);
532 register_page = GNC_PLUGIN_PAGE_REGISTER(g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER,
nullptr));
533 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
534 priv->ledger = ledger;
537 plugin_page = GNC_PLUGIN_PAGE (register_page);
538 label = gnc_plugin_page_register_get_tab_name (plugin_page);
542 label_color = gnc_plugin_page_register_get_tab_color (plugin_page);
544 g_free (label_color);
546 label = gnc_plugin_page_register_get_long_name (plugin_page);
552 for (item = book_list; item; item = g_list_next (item))
556 priv->component_manager_id = 0;
561 gnc_plug_page_register_check_commodity (
Account* account,
void* usr_data)
564 gnc_commodity* com0 = (gnc_commodity*) usr_data;
572 GNCLedgerDisplay* ledger;
578 ENTER (
"account=%p, subaccounts=%s", account,
579 subaccounts ?
"TRUE" :
"FALSE");
583 gnc_plug_page_register_check_commodity,
584 static_cast<gpointer>(com0)));
591 page = gnc_plugin_page_register_new_common (ledger);
592 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
602 GNCLedgerDisplay* ledger;
605 return gnc_plugin_page_register_new_common (ledger);
611 return gnc_plugin_page_register_new_common (ledger);
617 GObjectClass* object_class = G_OBJECT_CLASS (klass);
620 object_class->finalize = gnc_plugin_page_register_finalize;
622 gnc_plugin_class->
tab_icon = GNC_ICON_ACCOUNT;
623 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_REGISTER_NAME;
624 gnc_plugin_class->
create_widget = gnc_plugin_page_register_create_widget;
625 gnc_plugin_class->
destroy_widget = gnc_plugin_page_register_destroy_widget;
626 gnc_plugin_class->
window_changed = gnc_plugin_page_register_window_changed;
627 gnc_plugin_class->
focus_page = gnc_plugin_page_register_focus;
628 gnc_plugin_class->
save_page = gnc_plugin_page_register_save_page;
629 gnc_plugin_class->
recreate_page = gnc_plugin_page_register_recreate_page;
631 gnc_plugin_page_register_update_edit_menu;
632 gnc_plugin_class->
finish_pending = gnc_plugin_page_register_finish_pending;
635 gnc_ui_register_account_destroy_callback (gppr_account_destroy_cb);
643 GSimpleActionGroup *simple_action_group;
646 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
649 parent = GNC_PLUGIN_PAGE (plugin_page);
652 g_object_set (G_OBJECT (plugin_page),
653 "page-name", _ (
"General Journal"),
654 "ui-description",
"gnc-plugin-page-register.ui",
655 "use-new-window", use_new,
660 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
661 gnc_plugin_page_register_actions,
662 gnc_plugin_page_register_n_actions,
665 priv->lines_default = DEFAULT_LINES_AMOUNT;
666 priv->read_only = FALSE;
667 priv->fd.cleared_match = CLEARED_ALL;
669 priv->enable_refresh = TRUE;
670 priv->search_query = NULL;
671 priv->filter_query = NULL;
675 gnc_plugin_page_register_finalize (GObject*
object)
677 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (
object));
679 ENTER (
"object %p",
object);
681 G_OBJECT_CLASS (gnc_plugin_page_register_parent_class)->finalize (
object);
689 GNCLedgerDisplayType ledger_type;
692 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
693 ledger_type = gnc_ledger_display_type (priv->ledger);
696 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
707 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
717 gnc_plugin_page_register_focus_widget (
GncPluginPage* register_plugin_page)
719 if (GNC_IS_PLUGIN_PAGE_REGISTER (register_plugin_page))
721 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window);
724 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(register_plugin_page)->window))
728 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
731 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
734 register_plugin_page,
735 gnc_plugin_load_ui_items);
739 GtkWidget *toolbar = gnc_window_get_toolbar (gnc_window);
740 GtkWidget *menubar = gnc_window_get_menubar (gnc_window);
741 GMenuModel *menubar_model = gnc_window_get_menubar_model (gnc_window);
742 GtkWidget *statusbar = gnc_window_get_statusbar (gnc_window);
752 gnc_plugin_page_register_ui_update (NULL, GNC_PLUGIN_PAGE_REGISTER(register_plugin_page));
754 gnc_split_reg_focus_on_sheet (gsr);
760 static const char* readonly_inactive_actions[] =
764 "CutTransactionAction",
765 "PasteTransactionAction",
766 "DuplicateTransactionAction",
767 "DeleteTransactionAction",
768 "RemoveTransactionSplitsAction",
769 "RecordTransactionAction",
770 "CancelTransactionAction",
771 "UnvoidTransactionAction",
772 "VoidTransactionAction",
773 "ReverseTransactionAction",
774 "ActionsTransferAction",
775 "ActionsReconcileAction",
776 "ActionsStockSplitAction",
777 "ScheduleTransactionAction",
779 "ScrubCurrentAction",
780 "LinkTransactionAction",
786 static const char* tran_vs_split_actions[] =
788 "CutTransactionAction",
789 "CopyTransactionAction",
790 "PasteTransactionAction",
791 "DuplicateTransactionAction",
792 "DeleteTransactionAction",
797 static const char* tran_action_labels[] =
799 CUT_TRANSACTION_LABEL,
800 COPY_TRANSACTION_LABEL,
801 PASTE_TRANSACTION_LABEL,
802 DUPLICATE_TRANSACTION_LABEL,
803 DELETE_TRANSACTION_LABEL,
808 static const char* tran_action_tips[] =
811 COPY_TRANSACTION_TIP,
812 PASTE_TRANSACTION_TIP,
813 DUPLICATE_TRANSACTION_TIP,
814 DELETE_TRANSACTION_TIP,
819 static const char* split_action_labels[] =
824 DUPLICATE_SPLIT_LABEL,
830 static const char* split_action_tips[] =
840 static std::vector<GncInvoice*>
841 invoices_from_transaction (
const Transaction* trans)
843 std::vector<GncInvoice*> rv;
845 g_return_val_if_fail (GNC_IS_TRANSACTION (trans), rv);
849 auto split = GNC_SPLIT(node->data);
853 auto inv = invoice_from_split (split);
861 gnc_plugin_page_register_ui_update (gpointer various,
867 GNCLedgerDisplayType ledger_type;
868 gboolean expanded, voided, read_only = FALSE, read_only_reg = FALSE;
873 GncWindow* gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
876 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
882 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
885 ledger_type = gnc_ledger_display_type (priv->ledger);
888 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type != LD_GL);
889 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
893 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
897 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), reg->style == REG_STYLE_LEDGER);
899 g_signal_handlers_block_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
900 g_action_change_state (G_ACTION(action), g_variant_new_boolean (expanded));
901 g_signal_handlers_unblock_by_func (action, (gpointer)gnc_plugin_page_register_cmd_expand_transaction, page);
906 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
910 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
914 actions_requiring_priced_account,
922 gnc_split_reg_get_read_only (priv->gsr))
923 read_only_reg = TRUE;
926 actions_requiring_account,
927 !read_only_reg && account != NULL);
930 actions_requiring_priced_account,
936 if (cursor_class == CURSOR_CLASS_SPLIT)
938 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
945 if (GNC_IS_MAIN_WINDOW(GNC_PLUGIN_PAGE(page)->window))
956 for (iter = readonly_inactive_actions; *iter; ++iter)
960 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), TRUE);
970 "CutTransactionAction");
971 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
974 "PasteTransactionAction");
975 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
978 "DeleteTransactionAction");
979 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
981 if (cursor_class == CURSOR_CLASS_SPLIT)
984 "DuplicateTransactionAction");
985 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
989 "RemoveTransactionSplitsAction");
990 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !read_only & !voided);
997 "VoidTransactionAction");
998 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !voided);
1004 "UnvoidTransactionAction");
1005 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), voided);
1010 "LinkedTransactionOpenAction");
1014 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), (uri ? TRUE:FALSE));
1022 "JumpLinkedInvoiceAction");
1025 auto invoices = invoices_from_transaction (trans);
1026 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), !invoices.empty());
1029 gnc_plugin_business_split_reg_ui_update (GNC_PLUGIN_PAGE(page));
1033 "PasteTransactionAction");
1034 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
1041 for (iter = readonly_inactive_actions; *iter; ++iter)
1045 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), FALSE);
1052 GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
1053 gboolean found = FALSE;
1054 const char** iter, **label_iter, **tooltip_iter;
1055 gboolean curr_label_trans = FALSE;
1056 iter = tran_vs_split_actions;
1057 label_iter = tran_action_labels;
1059 gsm->search_action_label = NULL;
1060 gsm->search_action_name = *iter;
1061 gsm->search_action_target = NULL;
1065 PINFO(
"Test for action '%s', found is %d, iter label is '%s'", *iter, found, _(*label_iter));
1073 if (g_strcmp0 (gsm->search_action_label, _(*label_iter)) == 0)
1074 curr_label_trans = TRUE;
1078 if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans)
1080 gboolean found = FALSE;
1081 label_iter = split_action_labels;
1082 tooltip_iter = split_action_tips;
1083 for (iter = tran_vs_split_actions; *iter; ++iter)
1087 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
1089 PINFO(
"split model_item action '%s', found is %d, iter label is '%s'",
1090 *iter, found, _(*label_iter));
1096 else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans)
1098 gboolean found = FALSE;
1099 label_iter = tran_action_labels;
1100 tooltip_iter = tran_action_tips;
1101 for (iter = tran_vs_split_actions; *iter; ++iter)
1105 *iter, NULL, _(*label_iter), NULL, _(*tooltip_iter));
1107 PINFO(
"trans model_item action '%s', found is %d, iter label is '%s'",
1108 *iter, found, _(*label_iter));
1116 gnc_window_get_menubar_model (gnc_window),
1117 gnc_window_get_statusbar (gnc_window));
1121 gnc_window_get_menubar_model (gnc_window),
1122 gnc_window_get_accel_group (gnc_window));
1130 GSimpleActionGroup *simple_action_group;
1134 GNCLedgerDisplayType ledger_type;
1137 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1142 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(simple_action_group));
1145 is_readwrite && account != NULL);
1148 ledger_type = gnc_ledger_display_type (priv->ledger);
1150 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), ledger_type == LD_SINGLE);
1154 g_signal_handlers_block_by_func (action,
1155 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1156 g_action_change_state (G_ACTION(action), g_variant_new_int32 (reg->style));
1157 g_signal_handlers_unblock_by_func (action,
1158 (gpointer)gnc_plugin_page_register_cmd_style_changed, page);
1162 g_signal_handlers_block_by_func (action,
1163 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1164 g_action_change_state (G_ACTION(action), g_variant_new_boolean (reg->use_double_line));
1165 g_signal_handlers_unblock_by_func (action,
1166 (gpointer)gnc_plugin_page_register_cmd_style_double_line, page);
1172 get_filter_default_num_of_days (GNCLedgerDisplayType ledger_type)
1174 if (ledger_type == LD_GL)
1175 return DEFAULT_FILTER_NUM_DAYS_GL;
1187 gboolean on_current_page)
1193 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1195 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1196 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1200 if (on_current_page)
1202 priv->page_focus = TRUE;
1206 GNC_PLUGIN_PAGE_CLASS (gnc_plugin_page_register_parent_class)->focus_page (plugin_page, TRUE);
1209 priv->page_focus = FALSE;
1212 gnc_split_reg_set_sheet_focus (gsr, priv->page_focus);
1218 gnc_plugin_page_register_create_widget (
GncPluginPage* plugin_page)
1222 GNCLedgerDisplayType ledger_type;
1223 GncWindow* gnc_window;
1229 int filter_changed = 0;
1230 gboolean create_new_page = FALSE;
1232 ENTER (
"page %p", plugin_page);
1233 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1234 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1236 if (priv->widget != NULL)
1238 LEAVE (
"existing widget %p", priv->widget);
1239 return priv->widget;
1242 priv->widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
1243 gtk_box_set_homogeneous (GTK_BOX (priv->widget), FALSE);
1244 gtk_widget_show (priv->widget);
1247 gtk_widget_set_name (GTK_WIDGET(priv->widget),
"gnc-id-register-page");
1249 numRows = priv->lines_default;
1250 numRows = MIN (numRows, DEFAULT_LINES_AMOUNT);
1252 gnc_window = GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window);
1253 gsr = gnc_split_reg_new (priv->ledger,
1254 gnc_window_get_gtk_window (gnc_window),
1255 numRows, priv->read_only);
1256 priv->gsr = (GNCSplitReg *)gsr;
1259 gtk_widget_show (gsr);
1260 gtk_box_pack_start (GTK_BOX (priv->widget), gsr, TRUE, TRUE, 0);
1262 g_signal_connect (G_OBJECT (gsr),
"help-changed",
1263 G_CALLBACK (gnc_plugin_page_help_changed_cb),
1266 g_signal_connect (G_OBJECT (gsr),
"show-popup-menu",
1267 G_CALLBACK (gnc_plugin_page_popup_menu_cb),
1272 reg->use_double_line);
1274 gnc_plugin_page_register_ui_initial_state (page);
1275 gnc_plugin_page_register_ui_update (NULL, page);
1277 ledger_type = gnc_ledger_display_type (priv->ledger);
1282 guint filtersize = 0;
1284 priv->sd.save_order = FALSE;
1285 order = gnc_plugin_page_register_get_sort_order (plugin_page);
1287 PINFO (
"Loaded Sort order is %s", order);
1289 gnc_split_reg_set_sort_type (priv->gsr, SortTypefromString (order));
1291 if (order && (g_strcmp0 (order, DEFAULT_SORT_ORDER) != 0))
1292 priv->sd.save_order = TRUE;
1294 priv->sd.original_save_order = priv->sd.save_order;
1297 priv->sd.reverse_order = gnc_plugin_page_register_get_sort_reversed (
1299 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.reverse_order, FALSE);
1300 if (priv->sd.reverse_order)
1301 priv->sd.save_order = TRUE;
1303 priv->sd.original_reverse_order = priv->sd.reverse_order;
1306 priv->fd.save_filter = FALSE;
1308 filter_str = gnc_plugin_page_register_get_filter (plugin_page);
1309 filter = g_strsplit (filter_str,
",", -1);
1310 filtersize = g_strv_length (filter);
1311 g_free (filter_str);
1313 PINFO (
"Loaded Filter Status is %s", filter[0]);
1315 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (filter[0], NULL, 16);
1317 if (filtersize > 0 && (g_strcmp0 (filter[0], DEFAULT_FILTER) != 0))
1318 filter_changed = filter_changed + 1;
1320 if (filtersize > 1 && (g_strcmp0 (filter[1],
"0") != 0))
1322 PINFO (
"Loaded Filter Start Date is %s", filter[1]);
1324 priv->fd.start_time = gnc_plugin_page_register_filter_dmy2time (filter[1]);
1326 filter_changed = filter_changed + 1;
1329 if (filtersize > 2 && (g_strcmp0 (filter[2],
"0") != 0))
1331 PINFO (
"Loaded Filter End Date is %s", filter[2]);
1333 priv->fd.end_time = gnc_plugin_page_register_filter_dmy2time (filter[2]);
1335 filter_changed = filter_changed + 1;
1339 priv->fd.days = (gint)g_ascii_strtoll (
1340 get_filter_default_num_of_days (ledger_type), NULL, 10);
1342 if (filtersize > 3 &&
1343 (g_strcmp0 (filter[3], get_filter_default_num_of_days (ledger_type)) != 0))
1345 PINFO (
"Loaded Filter Days is %s", filter[3]);
1347 priv->fd.days = (gint)g_ascii_strtoll (filter[3], NULL, 10);
1348 filter_changed = filter_changed + 1;
1351 if (filter_changed != 0)
1352 priv->fd.save_filter = TRUE;
1354 priv->fd.original_save_filter = priv->fd.save_filter;
1355 g_strfreev (filter);
1358 if (ledger_type == LD_GL)
1360 time64 start_time = 0, end_time = 0;
1362 if (reg->type == GENERAL_JOURNAL)
1364 start_time = priv->fd.start_time;
1365 end_time = priv->fd.end_time;
1370 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (DEFAULT_FILTER, NULL, 16);
1371 gnc_split_reg_set_sort_type (priv->gsr,
1372 SortTypefromString (DEFAULT_SORT_ORDER));
1373 priv->sd.reverse_order = FALSE;
1374 priv->fd.save_filter = FALSE;
1375 priv->sd.save_order = FALSE;
1378 priv->fd.original_days = priv->fd.days;
1380 priv->fd.original_start_time = start_time;
1381 priv->fd.start_time = start_time;
1382 priv->fd.original_end_time = end_time;
1383 priv->fd.end_time = end_time;
1388 if (priv->enable_refresh == TRUE)
1390 create_new_page = TRUE;
1391 priv->enable_refresh = FALSE;
1395 gnc_ppr_update_status_query (page);
1396 gnc_ppr_update_date_query (page);
1399 if (create_new_page)
1401 priv->enable_refresh = TRUE;
1406 gnc_plugin_page_register_set_filter_tooltip (page);
1408 plugin_page->
summarybar = gsr_create_summary_bar (priv->gsr);
1411 gtk_widget_show_all (plugin_page->
summarybar);
1412 gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->
summarybar,
1415 gnc_plugin_page_register_summarybar_position_changed (NULL, NULL, page);
1417 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1418 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1421 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1422 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1428 priv->component_manager_id =
1429 gnc_register_gui_component (GNC_PLUGIN_PAGE_REGISTER_NAME,
1430 gnc_plugin_page_register_refresh_cb,
1431 gnc_plugin_page_register_close_cb,
1433 gnc_gui_component_set_session (priv->component_manager_id,
1434 gnc_get_current_session());
1437 gnc_gui_component_watch_entity (
1439 QOF_EVENT_DESTROY | QOF_EVENT_MODIFY);
1441 gnc_split_reg_set_moved_cb
1442 (priv->gsr, (GFunc)gnc_plugin_page_register_ui_update, page);
1444 g_signal_connect (G_OBJECT (plugin_page),
"inserted",
1450 return priv->widget;
1454 gnc_plugin_page_register_destroy_widget (
GncPluginPage* plugin_page)
1459 ENTER (
"page %p", plugin_page);
1460 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1461 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1464 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1465 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1468 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1469 (gpointer)gnc_plugin_page_register_summarybar_position_changed,
1476 g_idle_remove_by_data (GNC_PLUGIN_PAGE_REGISTER (plugin_page));
1478 if (priv->widget == NULL)
1481 if (priv->component_manager_id)
1483 gnc_unregister_gui_component (priv->component_manager_id);
1484 priv->component_manager_id = 0;
1487 if (priv->event_handler_id)
1490 priv->event_handler_id = 0;
1493 if (priv->sd.dialog)
1495 gtk_widget_destroy (priv->sd.dialog);
1496 memset (&priv->sd, 0, sizeof (priv->sd));
1499 if (priv->fd.dialog)
1501 gtk_widget_destroy (priv->fd.dialog);
1502 memset (&priv->fd, 0, sizeof (priv->fd));
1508 gtk_widget_hide (priv->widget);
1510 g_object_unref(priv->widget);
1511 priv->widget = NULL;
1514 priv->ledger = NULL;
1520 gnc_plugin_page_register_window_changed (
GncPluginPage* plugin_page,
1526 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1528 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1529 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1531 GTK_WIDGET (gnc_window_get_gtk_window (GNC_WINDOW (window)));
1534 static const gchar* style_names[] =
1542 #define KEY_REGISTER_TYPE "RegisterType" 1543 #define KEY_ACCOUNT_NAME "AccountName" 1544 #define KEY_ACCOUNT_GUID "AccountGuid" 1545 #define KEY_REGISTER_STYLE "RegisterStyle" 1546 #define KEY_DOUBLE_LINE "DoubleLineMode" 1548 #define LABEL_ACCOUNT "Account" 1549 #define LABEL_SUBACCOUNT "SubAccount" 1550 #define LABEL_GL "GL" 1551 #define LABEL_SEARCH "Search" 1564 gnc_plugin_page_register_save_page (
GncPluginPage* plugin_page,
1566 const gchar* group_name)
1570 GNCLedgerDisplayType ledger_type;
1574 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
1575 g_return_if_fail (key_file != NULL);
1576 g_return_if_fail (group_name != NULL);
1578 ENTER (
"page %p, key_file %p, group_name %s", plugin_page, key_file,
1581 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
1582 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1585 ledger_type = gnc_ledger_display_type (priv->ledger);
1586 if (ledger_type > LD_GL)
1588 LEAVE (
"Unsupported ledger type");
1591 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1596 label = (ledger_type == LD_SINGLE) ? LABEL_ACCOUNT : LABEL_SUBACCOUNT;
1598 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE, label);
1600 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_NAME, name);
1603 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_GUID, acct_guid);
1605 else if (reg->type == GENERAL_JOURNAL)
1607 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1610 else if (reg->type == SEARCH_LEDGER)
1612 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1617 LEAVE (
"Unsupported register type");
1621 g_key_file_set_string (key_file, group_name, KEY_REGISTER_STYLE,
1622 style_names[reg->style]);
1623 g_key_file_set_boolean (key_file, group_name, KEY_DOUBLE_LINE,
1624 reg->use_double_line);
1643 gnc_plugin_page_register_restore_edit_menu (
GncPluginPage* page,
1645 const gchar* group_name)
1649 GError* error = NULL;
1652 gboolean use_double_line;
1657 style_name = g_key_file_get_string (key_file, group_name,
1658 KEY_REGISTER_STYLE, &error);
1659 for (i = 0 ; style_names[i]; i++)
1661 if (g_ascii_strcasecmp (style_name, style_names[i]) == 0)
1663 DEBUG (
"Found match for style name: %s", style_name);
1667 g_free (style_name);
1670 if (i <= REG_STYLE_JOURNAL)
1672 DEBUG (
"Setting style: %d", i);
1674 g_action_activate (G_ACTION(action), g_variant_new_int32 (i));
1678 use_double_line = g_key_file_get_boolean (key_file, group_name,
1679 KEY_DOUBLE_LINE, &error);
1680 DEBUG (
"Setting double_line_mode: %d", use_double_line);
1683 state = g_action_get_state (G_ACTION(action));
1685 if (use_double_line != g_variant_get_boolean (state))
1686 g_action_activate (G_ACTION(action), NULL);
1688 g_variant_unref (state);
1704 gnc_plugin_page_register_recreate_page (GtkWidget* window,
1706 const gchar* group_name)
1710 GError* error = NULL;
1711 gchar* reg_type, *acct_guid;
1715 gboolean include_subs;
1717 g_return_val_if_fail (key_file, NULL);
1718 g_return_val_if_fail (group_name, NULL);
1719 ENTER (
"key_file %p, group_name %s", key_file, group_name);
1722 reg_type = g_key_file_get_string (key_file, group_name,
1723 KEY_REGISTER_TYPE, &error);
1724 DEBUG (
"Page type: %s", reg_type);
1725 if ((g_ascii_strcasecmp (reg_type, LABEL_ACCOUNT) == 0) ||
1726 (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0))
1728 include_subs = (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0);
1729 DEBUG (
"Include subs: %d", include_subs);
1733 LEAVE(
"Session has no book");
1736 acct_guid = g_key_file_get_string (key_file, group_name,
1737 KEY_ACCOUNT_GUID, &error);
1743 if (account == NULL)
1745 gchar* acct_name = g_key_file_get_string (key_file, group_name,
1746 KEY_ACCOUNT_NAME, &error);
1751 if (account == NULL)
1753 LEAVE (
"Bad account name");
1759 else if (g_ascii_strcasecmp (reg_type, LABEL_GL) == 0)
1765 LEAVE (
"Bad ledger type");
1773 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
1774 priv->enable_refresh = FALSE;
1783 gnc_plugin_page_register_restore_edit_menu (page, key_file, group_name);
1786 priv->enable_refresh = TRUE;
1796 gnc_plugin_page_register_update_edit_menu (
GncPluginPage* page, gboolean hide)
1801 gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
1802 gboolean has_selection;
1805 reg_page = GNC_PLUGIN_PAGE_REGISTER (page);
1806 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (reg_page);
1807 has_selection = gnucash_register_has_selection (priv->gsr->reg);
1809 can_copy = has_selection;
1810 can_cut = is_readwrite && has_selection;
1811 can_paste = is_readwrite;
1814 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_copy);
1816 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_cut);
1818 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), can_paste);
1821 static gboolean is_scrubbing = FALSE;
1822 static gboolean show_abort_verify = TRUE;
1825 check_repair_abort_YN = N_(
"'Check & Repair' is currently running, do you want to abort it?");
1830 gboolean ret = FALSE;
1835 false,
"%s", _(check_repair_abort_YN));
1837 show_abort_verify = FALSE;
1846 gnc_plugin_page_register_finish_pending (
GncPluginPage* page)
1851 GtkWidget* dialog, *window;
1855 if (is_scrubbing && show_abort_verify)
1857 if (!finish_scrub (page))
1861 reg_page = GNC_PLUGIN_PAGE_REGISTER (page);
1862 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (reg_page);
1868 name = gnc_plugin_page_register_get_tab_name (page);
1870 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1871 GTK_DIALOG_DESTROY_WITH_PARENT,
1872 GTK_MESSAGE_WARNING,
1876 _ (
"Save changes to %s?"), name);
1878 gtk_message_dialog_format_secondary_text
1879 (GTK_MESSAGE_DIALOG (dialog),
1881 _ (
"This register has pending changes to a transaction. " 1882 "Would you like to save the changes to this transaction, " 1883 "discard the transaction, or cancel the operation?"));
1884 gnc_gtk_dialog_add_button (dialog, _ (
"_Discard Transaction"),
1885 "edit-delete", GTK_RESPONSE_REJECT);
1886 gtk_dialog_add_button (GTK_DIALOG (dialog),
1887 _ (
"_Cancel"), GTK_RESPONSE_CANCEL);
1888 gnc_gtk_dialog_add_button (dialog, _ (
"_Save Transaction"),
1889 "document-save", GTK_RESPONSE_ACCEPT);
1891 response = gtk_dialog_run (GTK_DIALOG (dialog));
1892 gtk_widget_destroy (dialog);
1896 case GTK_RESPONSE_ACCEPT:
1900 case GTK_RESPONSE_REJECT:
1912 gnc_plugin_page_register_get_tab_name (
GncPluginPage* plugin_page)
1915 GNCLedgerDisplayType ledger_type;
1916 GNCLedgerDisplay* ld;
1920 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1921 g_strdup (_(
"unknown")));
1923 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1926 ledger_type = gnc_ledger_display_type (ld);
1929 switch (ledger_type)
1940 case GENERAL_JOURNAL:
1942 return g_strdup (_ (
"General Journal"));
1943 case PORTFOLIO_LEDGER:
1944 return g_strdup (_ (
"Portfolio"));
1946 return g_strdup (_ (
"Search Results"));
1956 return g_strdup (_ (
"unknown"));
1960 gnc_plugin_page_register_get_tab_color (
GncPluginPage* plugin_page)
1963 GNCLedgerDisplayType ledger_type;
1964 GNCLedgerDisplay* ld;
1968 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
1969 g_strdup (_(
"unknown")));
1971 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
1973 ledger_type = gnc_ledger_display_type (ld);
1977 if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
1980 return g_strdup (color ? color :
"Not Set");
1984 gnc_plugin_page_register_check_for_empty_group (GKeyFile *state_file,
1985 const gchar *state_section)
1988 gchar **keys = g_key_file_get_keys (state_file, state_section, &num_keys, NULL);
1997 gnc_plugin_page_register_get_filter_gcm (GNCSplitReg *gsr)
2000 gchar* state_section;
2001 GError* error = NULL;
2002 char* filter = NULL;
2005 state_section = gsr_get_register_state_section (gsr);
2006 filter = g_key_file_get_string (state_file, state_section,
2007 KEY_PAGE_FILTER, &error);
2010 g_clear_error (&error);
2012 g_strdelimit (filter,
";",
',');
2014 g_free (state_section);
2019 gnc_plugin_page_register_get_filter (
GncPluginPage* plugin_page)
2022 GNCLedgerDisplayType ledger_type;
2023 char* filter = NULL;
2025 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2026 g_strdup (_(
"unknown")));
2028 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2030 ledger_type = gnc_ledger_display_type (priv->ledger);
2033 filter = gnc_plugin_page_register_get_filter_gcm (priv->gsr);
2038 return g_strdup_printf (
"%s,%s,%s,%s", DEFAULT_FILTER,
2039 "0",
"0", get_filter_default_num_of_days (ledger_type));
2043 gnc_plugin_page_register_set_filter_gcm (GNCSplitReg *gsr,
const gchar* filter,
2044 gchar* default_filter)
2047 gchar* state_section;
2051 state_section = gsr_get_register_state_section (gsr);
2052 if (!filter || (g_strcmp0 (filter, default_filter) == 0))
2054 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_FILTER, NULL))
2055 g_key_file_remove_key (state_file, state_section, KEY_PAGE_FILTER, NULL);
2057 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2061 filter_text = g_strdup (filter);
2062 g_strdelimit (filter_text,
",",
';');
2063 g_key_file_set_string (state_file, state_section, KEY_PAGE_FILTER,
2065 g_free (filter_text);
2067 g_free (state_section);
2071 gnc_plugin_page_register_set_filter (
GncPluginPage* plugin_page,
2072 const gchar* filter)
2075 GNCLedgerDisplayType ledger_type;
2076 gchar* default_filter;
2078 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2080 ledger_type = gnc_ledger_display_type (priv->ledger);
2082 default_filter = g_strdup_printf (
"%s,%s,%s,%s", DEFAULT_FILTER,
2083 "0",
"0", get_filter_default_num_of_days (ledger_type));
2086 gnc_plugin_page_register_set_filter_gcm (priv->gsr, filter, default_filter);
2088 g_free (default_filter);
2093 gnc_plugin_page_register_get_sort_order_gcm (GNCSplitReg *gsr)
2096 gchar* state_section;
2098 GError* error = NULL;
2099 char* sort_order = NULL;
2102 state_section = gsr_get_register_state_section (gsr);
2103 sort_text = g_key_file_get_string (state_file, state_section, KEY_PAGE_SORT,
2107 g_clear_error (&error);
2110 sort_order = g_strdup (sort_text);
2113 g_free (state_section);
2118 gnc_plugin_page_register_get_sort_order (
GncPluginPage* plugin_page)
2121 char* sort_order = NULL;
2123 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2126 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2129 sort_order = gnc_plugin_page_register_get_sort_order_gcm (priv->gsr);
2131 return sort_order ? sort_order : g_strdup (DEFAULT_SORT_ORDER);
2135 gnc_plugin_page_register_set_sort_order_gcm (GNCSplitReg *gsr,
2136 const gchar* sort_order)
2139 gchar* state_section;
2142 state_section = gsr_get_register_state_section (gsr);
2143 if (!sort_order || (g_strcmp0 (sort_order, DEFAULT_SORT_ORDER) == 0))
2145 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_SORT, NULL))
2146 g_key_file_remove_key (state_file, state_section, KEY_PAGE_SORT, NULL);
2148 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2151 g_key_file_set_string (state_file, state_section, KEY_PAGE_SORT, sort_order);
2153 g_free (state_section);
2156 gnc_plugin_page_register_set_sort_order (
GncPluginPage* plugin_page,
2157 const gchar* sort_order)
2161 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2164 gnc_plugin_page_register_set_sort_order_gcm (priv->gsr, sort_order);
2168 gnc_plugin_page_register_get_sort_reversed_gcm (GNCSplitReg *gsr)
2171 gchar* state_section;
2172 GError* error = NULL;
2173 gboolean sort_reversed = FALSE;
2176 state_section = gsr_get_register_state_section (gsr);
2177 sort_reversed = g_key_file_get_boolean (state_file, state_section,
2178 KEY_PAGE_SORT_REV, &error);
2181 g_clear_error (&error);
2183 g_free (state_section);
2184 return sort_reversed;
2188 gnc_plugin_page_register_get_sort_reversed (
GncPluginPage* plugin_page)
2191 gboolean sort_reversed = FALSE;
2193 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), FALSE);
2195 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2198 sort_reversed = gnc_plugin_page_register_get_sort_reversed_gcm (priv->gsr);
2199 return sort_reversed;
2203 gnc_plugin_page_register_set_sort_reversed_gcm (GNCSplitReg *gsr,
2204 gboolean reverse_order)
2207 gchar* state_section;
2210 state_section = gsr_get_register_state_section (gsr);
2214 if (g_key_file_has_key (state_file, state_section, KEY_PAGE_SORT_REV, NULL))
2215 g_key_file_remove_key (state_file, state_section, KEY_PAGE_SORT_REV, NULL);
2217 gnc_plugin_page_register_check_for_empty_group (state_file, state_section);
2220 g_key_file_set_boolean (state_file, state_section, KEY_PAGE_SORT_REV,
2223 g_free (state_section);
2227 gnc_plugin_page_register_set_sort_reversed (
GncPluginPage* plugin_page,
2228 gboolean reverse_order)
2232 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2235 gnc_plugin_page_register_set_sort_reversed_gcm (priv->gsr, reverse_order);
2239 gnc_plugin_page_register_get_long_name (
GncPluginPage* plugin_page)
2242 GNCLedgerDisplayType ledger_type;
2243 GNCLedgerDisplay* ld;
2246 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page),
2249 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2251 ledger_type = gnc_ledger_display_type (ld);
2254 switch (ledger_type)
2262 gchar* return_string = g_strdup_printf (
"%s+", account_full_name);
2263 g_free ((gpointer*) account_full_name);
2264 return return_string;
2275 gnc_plugin_page_register_summarybar_position_changed (gpointer prefs,
2282 GtkPositionType position = GTK_POS_BOTTOM;
2284 g_return_if_fail (user_data != NULL);
2286 if (!GNC_IS_PLUGIN_PAGE (user_data))
2289 plugin_page = GNC_PLUGIN_PAGE (user_data);
2290 page = GNC_PLUGIN_PAGE_REGISTER (user_data);
2291 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2297 GNC_PREF_SUMMARYBAR_POSITION_TOP))
2298 position = GTK_POS_TOP;
2300 gtk_box_reorder_child (GTK_BOX (priv->widget),
2302 (position == GTK_POS_TOP ? 0 : -1));
2316 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
2318 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
2319 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2338 gnc_plugin_page_register_sort_book_option_changed (gpointer new_val,
2342 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
2343 gboolean* new_data = (gboolean*)new_val;
2345 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2347 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2350 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio),
2351 _ (
"Transaction Number"));
2352 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Number/Action"));
2356 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio), _ (
"Number"));
2357 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Action"));
2359 gnc_split_reg_set_sort_type_force (priv->gsr, (SortType)priv->gsr->sort_type, TRUE);
2383 g_return_if_fail (GTK_IS_DIALOG (dialog));
2384 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2387 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2388 plugin_page = GNC_PLUGIN_PAGE (page);
2390 if (response != GTK_RESPONSE_OK)
2393 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.original_reverse_order,
2395 priv->sd.reverse_order = priv->sd.original_reverse_order;
2396 gnc_split_reg_set_sort_type (priv->gsr, priv->sd.original_sort_type);
2397 priv->sd.save_order = priv->sd.original_save_order;
2402 if ((!priv->sd.save_order) && ((priv->sd.original_save_order) || (priv->sd.original_reverse_order)))
2404 gnc_plugin_page_register_set_sort_order (plugin_page, DEFAULT_SORT_ORDER);
2405 gnc_plugin_page_register_set_sort_reversed (plugin_page, FALSE);
2407 priv->sd.original_save_order = priv->sd.save_order;
2409 if (priv->sd.save_order)
2411 type = gnc_split_reg_get_sort_type (priv->gsr);
2412 order = SortTypeasString (type);
2413 gnc_plugin_page_register_set_sort_order (plugin_page, order);
2414 gnc_plugin_page_register_set_sort_reversed (plugin_page,
2415 priv->sd.reverse_order);
2418 gnc_book_option_remove_cb (OPTION_NAME_NUM_FIELD_SOURCE,
2419 gnc_plugin_page_register_sort_book_option_changed,
2421 priv->sd.dialog = NULL;
2422 priv->sd.num_radio = NULL;
2423 priv->sd.act_radio = NULL;
2424 gtk_widget_destroy (GTK_WIDGET (dialog));
2445 g_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
2446 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2448 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2449 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2450 ENTER (
"button %s(%p), page %p", name, button, page);
2451 type = SortTypefromString (name);
2452 gnc_split_reg_set_sort_type (priv->gsr, type);
2471 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2472 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2474 ENTER (
"Save toggle button (%p), plugin_page %p", button, page);
2477 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2479 if (gtk_toggle_button_get_active (button))
2480 priv->sd.save_order = TRUE;
2482 priv->sd.save_order = FALSE;
2501 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2502 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2504 ENTER (
"Reverse toggle button (%p), plugin_page %p", button, page);
2507 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2509 priv->sd.reverse_order = gtk_toggle_button_get_active (button);
2510 gnc_split_reg_set_sort_reversed (priv->gsr, priv->sd.reverse_order, TRUE);
2524 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2527 if (reg->type == SEARCH_LEDGER)
2534 if ((priv->filter_query == NULL) ||
2565 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2568 LEAVE (
"no ledger");
2572 gnc_ppr_update_for_search_query (page);
2577 LEAVE (
"no query found");
2584 if (reg->type != SEARCH_LEDGER)
2586 GSList *param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
2588 g_slist_free (param_list);
2592 if (priv->fd.cleared_match != CLEARED_ALL)
2593 xaccQueryAddClearedMatch (query, priv->fd.cleared_match, QOF_QUERY_AND);
2596 gnc_plugin_page_register_set_filter_tooltip (page);
2602 if (priv->enable_refresh)
2628 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2631 LEAVE (
"no ledger");
2635 gnc_ppr_update_for_search_query (page);
2648 if (reg->type != SEARCH_LEDGER)
2650 GSList *param_list = qof_query_build_param_list (SPLIT_TRANS,
2651 TRANS_DATE_POSTED, NULL);
2653 g_slist_free (param_list);
2656 if (priv->fd.start_time || priv->fd.end_time)
2659 xaccQueryAddDateMatchTT (query,
2660 priv->fd.start_time != 0, priv->fd.start_time,
2661 priv->fd.end_time != 0, priv->fd.end_time,
2665 if (priv->fd.days > 0)
2672 tm.tm_mday = tm.tm_mday - priv->fd.days;
2674 xaccQueryAddDateMatchTT (query, TRUE, start, FALSE, 0, QOF_QUERY_AND);
2678 gnc_plugin_page_register_set_filter_tooltip (page);
2684 if (priv->enable_refresh)
2692 gnc_plugin_page_register_filter_time2dmy (
time64 raw_time)
2694 struct tm* timeinfo;
2695 gchar date_string[11];
2698 strftime (date_string, 11,
"%d-%m-%Y", timeinfo);
2699 PINFO (
"Date string is %s", date_string);
2702 return g_strdup (date_string);
2708 gnc_plugin_page_register_filter_dmy2time (
char* date_string)
2712 PINFO (
"Date string is %s", date_string);
2713 memset (&when, 0,
sizeof (when));
2715 sscanf (date_string,
"%d-%d-%d", &when.tm_mday,
2716 &when.tm_mon, &when.tm_year);
2719 when.tm_year -= 1900;
2743 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2744 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2746 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2747 ENTER (
"toggle button %s (%p), plugin_page %p", name, button, page);
2750 value = CLEARED_NONE;
2751 for (i = 0; status_actions[i].action_name; i++)
2753 if (g_strcmp0 (name, status_actions[i].action_name) == 0)
2755 value = status_actions[i].value;
2761 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2762 if (gtk_toggle_button_get_active (button))
2763 priv->fd.cleared_match = (cleared_match_t)(priv->fd.cleared_match | value);
2765 priv->fd.cleared_match = (cleared_match_t)(priv->fd.cleared_match & ~value);
2766 gnc_ppr_update_status_query (page);
2788 g_return_if_fail (GTK_IS_BUTTON (button));
2789 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2791 ENTER (
"(button %p, page %p)", button, page);
2794 for (i = 0; status_actions[i].action_name; i++)
2796 widget = status_actions[i].widget;
2797 g_signal_handlers_block_by_func (widget,
2799 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
2800 g_signal_handlers_unblock_by_func (widget,
2805 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2806 priv->fd.cleared_match = CLEARED_ALL;
2807 gnc_ppr_update_status_query (page);
2830 g_return_if_fail (GTK_IS_BUTTON (button));
2831 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2833 ENTER (
"(button %p, page %p)", button, page);
2836 for (i = 0; status_actions[i].action_name; i++)
2838 widget = status_actions[i].widget;
2839 g_signal_handlers_block_by_func (widget,
2841 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
2842 g_signal_handlers_unblock_by_func (widget,
2847 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2848 priv->fd.cleared_match = CLEARED_NONE;
2849 gnc_ppr_update_status_query (page);
2871 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2872 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2873 priv->fd.start_date_choose)))
2875 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.start_date));
2877 priv->fd.start_time = time_val;
2881 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2882 priv->fd.start_date_today)))
2888 priv->fd.start_time = 0;
2892 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2893 priv->fd.end_date_choose)))
2895 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.end_date));
2897 priv->fd.end_time = time_val;
2901 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
2902 priv->fd.end_date_today)))
2908 priv->fd.end_time = 0;
2933 g_return_if_fail (GTK_IS_RADIO_BUTTON (button));
2934 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
2936 ENTER (
"(button %p, page %p)", button, page);
2937 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
2938 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
2939 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
2941 if (active && g_strcmp0 (name,
"filter_show_range") == 0)
2943 gtk_widget_set_sensitive (priv->fd.table, active);
2944 gtk_widget_set_sensitive (priv->fd.num_days, !active);
2945 get_filter_times (page);
2947 else if (active && g_strcmp0 (name,
"filter_show_days") == 0)
2949 gtk_widget_set_sensitive (priv->fd.table, !active);
2950 gtk_widget_set_sensitive (priv->fd.num_days, active);
2951 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->fd.num_days), priv->fd.days);
2955 gtk_widget_set_sensitive (priv->fd.table, FALSE);
2956 gtk_widget_set_sensitive (priv->fd.num_days, FALSE);
2958 priv->fd.start_time = 0;
2959 priv->fd.end_time = 0;
2961 gnc_ppr_update_date_query (page);
2970 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
2972 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
2975 priv->fd.start_time = 0;
2976 priv->fd.end_time = 0;
2977 priv->fd.cleared_match = (cleared_match_t)g_ascii_strtoll (DEFAULT_FILTER, NULL, 16);
2979 gnc_ppr_update_date_query (GNC_PLUGIN_PAGE_REGISTER(plugin_page));
2998 g_return_if_fail (GTK_IS_SPIN_BUTTON (button));
2999 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3001 ENTER (
"(button %p, page %p)", button, page);
3002 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3004 priv->fd.days = gtk_spin_button_get_value (GTK_SPIN_BUTTON (button));
3005 gnc_ppr_update_date_query (page);
3021 gnc_plugin_page_register_filter_gde_changed_cb (GtkWidget* unused,
3024 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3026 ENTER (
"(widget %s(%p), page %p)",
3027 gtk_buildable_get_name (GTK_BUILDABLE (unused)), unused, page);
3028 get_filter_times (page);
3029 gnc_ppr_update_date_query (page);
3061 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
3062 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3064 ENTER (
"(radio %s(%p), page %p)",
3065 gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
3066 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3067 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
3069 LEAVE (
"1st callback of pair. Defer to 2nd callback.");
3073 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
3074 active = !g_strcmp0 (name,
"start_date_choose");
3075 gtk_widget_set_sensitive (priv->fd.start_date, active);
3076 get_filter_times (page);
3077 gnc_ppr_update_date_query (page);
3109 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
3110 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3112 ENTER (
"(radio %s(%p), page %p)",
3113 gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
3114 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3115 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
3117 LEAVE (
"1st callback of pair. Defer to 2nd callback.");
3121 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
3122 active = !g_strcmp0 (name,
"end_date_choose");
3123 gtk_widget_set_sensitive (priv->fd.end_date, active);
3124 get_filter_times (page);
3125 gnc_ppr_update_date_query (page);
3144 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
3145 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3147 ENTER (
"Save toggle button (%p), plugin_page %p", button, page);
3150 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3151 if (gtk_toggle_button_get_active (button))
3152 priv->fd.save_filter = TRUE;
3154 priv->fd.save_filter = FALSE;
3178 g_return_if_fail (GTK_IS_DIALOG (dialog));
3179 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3182 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3183 plugin_page = GNC_PLUGIN_PAGE (page);
3185 if (response != GTK_RESPONSE_OK)
3188 priv->fd.cleared_match = priv->fd.original_cleared_match;
3189 priv->enable_refresh = FALSE;
3190 gnc_ppr_update_status_query (page);
3191 priv->enable_refresh = TRUE;
3192 priv->fd.start_time = priv->fd.original_start_time;
3193 priv->fd.end_time = priv->fd.original_end_time;
3194 priv->fd.days = priv->fd.original_days;
3195 priv->fd.save_filter = priv->fd.original_save_filter;
3196 gnc_ppr_update_date_query (page);
3201 if ((priv->fd.save_filter == FALSE) && (priv->fd.original_save_filter == TRUE))
3202 gnc_plugin_page_register_set_filter (plugin_page, NULL);
3204 priv->fd.original_save_filter = priv->fd.save_filter;
3206 if (priv->fd.save_filter)
3209 GList *flist = NULL;
3212 flist = g_list_prepend
3213 (flist, g_strdup_printf (
"0x%04x", priv->fd.cleared_match));
3216 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)) && priv->fd.start_time != 0)
3217 flist = g_list_prepend (flist, gnc_plugin_page_register_filter_time2dmy (priv->fd.start_time));
3219 flist = g_list_prepend (flist, g_strdup (
"0"));
3222 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose))
3223 && priv->fd.end_time != 0)
3224 flist = g_list_prepend (flist, gnc_plugin_page_register_filter_time2dmy (priv->fd.end_time));
3226 flist = g_list_prepend (flist, g_strdup (
"0"));
3229 if (priv->fd.days > 0)
3230 flist = g_list_prepend (flist, g_strdup_printf (
"%d", priv->fd.days));
3232 flist = g_list_prepend (flist, g_strdup (
"0"));
3234 flist = g_list_reverse (flist);
3236 PINFO (
"The filter to save is %s", filter);
3237 gnc_plugin_page_register_set_filter (plugin_page, filter);
3239 g_list_free_full (flist, g_free);
3242 priv->fd.dialog = NULL;
3243 gtk_widget_destroy (GTK_WIDGET (dialog));
3248 gpp_update_match_filter_text (cleared_match_t match,
const guint mask,
3249 const gchar* filter_name, GList **show, GList **hide)
3251 if ((match & mask) == mask)
3252 *show = g_list_prepend (*show, g_strdup (filter_name));
3254 *hide = g_list_prepend (*hide, g_strdup (filter_name));
3261 GList *t_list = NULL;
3263 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3266 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3269 if (priv->fd.start_time != 0)
3272 t_list = g_list_prepend
3273 (t_list, g_strdup_printf (
"%s %s", _(
"Start Date:"), sdate));
3278 if (priv->fd.days > 0)
3279 t_list = g_list_prepend
3280 (t_list, g_strdup_printf (
"%s %d", _(
"Show previous number of days:"),
3284 if (priv->fd.end_time != 0)
3287 t_list = g_list_prepend
3288 (t_list, g_strdup_printf (
"%s %s", _(
"End Date:"), edate));
3293 if (priv->fd.cleared_match != CLEARED_ALL)
3298 gpp_update_match_filter_text (priv->fd.cleared_match, 0x01, _ (
"Unreconciled"),
3300 gpp_update_match_filter_text (priv->fd.cleared_match, 0x02, _ (
"Cleared"),
3302 gpp_update_match_filter_text (priv->fd.cleared_match, 0x04, _ (
"Reconciled"),
3304 gpp_update_match_filter_text (priv->fd.cleared_match, 0x08, _ (
"Frozen"),
3306 gpp_update_match_filter_text (priv->fd.cleared_match, 0x10, _ (
"Voided"),
3309 show = g_list_reverse (show);
3310 hide = g_list_reverse (hide);
3315 t_list = g_list_prepend
3316 (t_list, g_strdup_printf (
"%s %s", _(
"Show:"), str));
3323 t_list = g_list_prepend
3324 (t_list, g_strdup_printf (
"%s %s", _(
"Hide:"), str));
3328 g_list_free_full (show, g_free);
3329 g_list_free_full (hide, g_free);
3332 t_list = g_list_reverse (t_list);
3335 t_list = g_list_prepend (t_list, g_strdup (_(
"Filter By:")));
3338 if (priv->gsr->filter_text != NULL)
3339 g_free (priv->gsr->filter_text);
3344 g_list_free_full (t_list, g_free);
3351 gnc_plugin_page_register_update_page_icon (
GncPluginPage* plugin_page)
3356 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
3358 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (plugin_page);
3361 gnc_split_reg_get_read_only (priv->gsr))
3375 gnc_reg_get_name (GNCLedgerDisplay* ledger, gboolean for_window)
3379 gchar* account_name;
3382 GNCLedgerDisplayType ledger_type;
3388 ledger_type = gnc_ledger_display_type (ledger);
3392 case GENERAL_JOURNAL:
3395 reg_name = _ (
"General Journal");
3397 reg_name = _ (
"Transaction Report");
3399 case PORTFOLIO_LEDGER:
3401 reg_name = _ (
"Portfolio");
3403 reg_name = _ (
"Portfolio Report");
3407 reg_name = _ (
"Search Results");
3409 reg_name = _ (
"Search Results Report");
3413 reg_name = _ (
"Register");
3415 reg_name = _ (
"Transaction Report");
3421 if ((leader != NULL) && (ledger_type != LD_GL))
3425 if (ledger_type == LD_SINGLE)
3427 name = g_strconcat (account_name,
" - ", reg_name, NULL);
3431 name = g_strconcat (account_name,
" ", _ (
"and subaccounts"),
" - ", reg_name,
3434 g_free (account_name);
3437 name = g_strdup (reg_name);
3443 report_helper (GNCLedgerDisplay* ledger, Split* split,
Query* query)
3449 swig_type_info* qtype;
3456 func = scm_c_eval_string (
"gnc:register-report-create");
3457 g_return_val_if_fail (scm_is_procedure (func), -1);
3460 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Credit"));
3461 args = scm_cons (arg, args);
3464 arg = scm_from_utf8_string (tmp ? tmp : _ (
"Debit"));
3465 args = scm_cons (arg, args);
3467 str = gnc_reg_get_name (ledger, FALSE);
3468 arg = scm_from_utf8_string (str ? str :
"");
3469 args = scm_cons (arg, args);
3472 arg = SCM_BOOL (reg->use_double_line);
3473 args = scm_cons (arg, args);
3475 arg = SCM_BOOL (reg->type == GENERAL_JOURNAL || reg->type == INCOME_LEDGER
3476 || reg->type == SEARCH_LEDGER);
3477 args = scm_cons (arg, args);
3479 arg = SCM_BOOL (reg->style == REG_STYLE_JOURNAL);
3480 args = scm_cons (arg, args);
3485 g_return_val_if_fail (query != NULL, -1);
3488 qtype = SWIG_TypeQuery (
"_p__QofQuery");
3489 g_return_val_if_fail (qtype, -1);
3491 arg = SWIG_NewPointerObj (query, qtype, 0);
3492 args = scm_cons (arg, args);
3493 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3498 qtype = SWIG_TypeQuery (
"_p_Split");
3499 g_return_val_if_fail (qtype, -1);
3500 arg = SWIG_NewPointerObj (split, qtype, 0);
3506 args = scm_cons (arg, args);
3507 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3510 qtype = SWIG_TypeQuery (
"_p_Account");
3511 g_return_val_if_fail (qtype, -1);
3514 arg = SWIG_NewPointerObj (account, qtype, 0);
3515 args = scm_cons (arg, args);
3516 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
3520 arg = scm_apply (func, args, SCM_EOL);
3521 g_return_val_if_fail (scm_is_exact (arg), -1);
3523 return scm_to_int (arg);
3531 gnc_plugin_page_register_cmd_print_check (GSimpleAction *simple,
3535 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3540 GList* splits = NULL, *item;
3541 GNCLedgerDisplayType ledger_type;
3542 Account* account, *subaccount = NULL;
3545 ENTER (
"(action %p, page %p)", simple, page);
3547 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3549 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3551 ledger_type = gnc_ledger_display_type (priv->ledger);
3553 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
3558 if (ledger_type == LD_SUBACCOUNT)
3562 subaccount = account;
3569 splits = g_list_prepend (splits, split);
3570 gnc_ui_print_check_dialog_create (window, splits, subaccount);
3571 g_list_free (splits);
3580 splits = g_list_prepend (splits, split);
3581 gnc_ui_print_check_dialog_create (window, splits, subaccount);
3582 g_list_free (splits);
3587 else if (ledger_type == LD_GL && reg->type == SEARCH_LEDGER)
3595 for (item = splits; item; item = g_list_next (item))
3597 split = (Split*) item->data;
3598 if (common_acct == NULL)
3608 const gchar* title = _ (
"Print checks from multiple accounts?");
3609 const gchar* message =
3610 _ (
"This search result contains splits from more than one account. " 3611 "Do you want to print the checks even though they are not all " 3612 "from the same account?");
3613 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
3614 GTK_DIALOG_DESTROY_WITH_PARENT,
3615 GTK_MESSAGE_WARNING,
3618 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
3620 gtk_dialog_add_button (GTK_DIALOG (dialog), _ (
"_Print checks"),
3622 response = gnc_dialog_run (GTK_DIALOG (dialog),
3623 GNC_PREF_WARN_CHECKPRINTING_MULTI_ACCT);
3624 gtk_widget_destroy (dialog);
3625 if (response != GTK_RESPONSE_YES)
3627 LEAVE (
"Multiple accounts");
3634 gnc_ui_print_check_dialog_create (window, splits, NULL);
3638 gnc_error_dialog (GTK_WINDOW (window),
"%s",
3639 _ (
"You can only print checks from a bank account register or search results."));
3640 LEAVE (
"Unsupported ledger type");
3648 gnc_plugin_page_register_cmd_cut (GSimpleAction *simple,
3652 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3655 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3657 ENTER (
"(action %p, page %p)", simple, page);
3658 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3660 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
3661 const char *name = gtk_widget_get_name(widget);
3662 if (strcmp(name,
"GnucashSheet") != 0)
3664 gtk_editable_cut_clipboard( GTK_EDITABLE(widget));
3665 LEAVE(
"Not cut from GnucashSheet");
3670 gnucash_register_cut_clipboard (priv->gsr->reg);
3676 gnc_plugin_page_register_cmd_copy (GSimpleAction *simple,
3680 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3683 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3685 ENTER (
"(action %p, page %p)", simple, page);
3686 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3688 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
3689 const char *name = gtk_widget_get_name(widget);
3690 if (strcmp(name,
"GnucashSheet") != 0)
3692 gtk_editable_copy_clipboard( GTK_EDITABLE(widget));
3693 LEAVE(
"Not copied from GnucashSheet");
3698 gnucash_register_copy_clipboard (priv->gsr->reg);
3704 gnc_plugin_page_register_cmd_paste (GSimpleAction *simple,
3708 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3711 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3713 ENTER (
"(action %p, page %p)", simple, page);
3714 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3716 GtkWidget *widget = gtk_window_get_focus(GTK_WINDOW (priv->gsr->window));
3717 const char *name = gtk_widget_get_name(widget);
3718 if (strcmp(name,
"GnucashSheet") != 0)
3720 gtk_editable_paste_clipboard( GTK_EDITABLE(widget));
3721 LEAVE(
"Not pasted to GnucashSheet");
3726 gnucash_register_paste_clipboard (priv->gsr->reg);
3732 gnc_plugin_page_register_cmd_edit_account (GSimpleAction *simple,
3736 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3739 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3741 ENTER (
"(action %p, page %p)", simple, page);
3750 gnc_plugin_page_register_cmd_find_account (GSimpleAction *simple,
3754 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3757 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3760 gnc_find_account_dialog (window, NULL);
3765 gnc_plugin_page_register_cmd_find_transactions (GSimpleAction *simple,
3769 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3773 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3775 ENTER (
"(action %p, page %p)", simple, page);
3776 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3778 gnc_ui_find_transactions_dialog_create (window, priv->ledger);
3784 gnc_plugin_page_register_cmd_edit_tax_options (GSimpleAction *simple,
3788 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3792 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3794 ENTER (
"(action %p, page %p)", simple, page);
3797 gnc_tax_info_dialog (window, account);
3802 gnc_plugin_page_register_cmd_cut_transaction (GSimpleAction *simple,
3806 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3809 ENTER (
"(action %p, page %p)", simple, page);
3811 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3813 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3814 gsr_default_cut_txn_handler (priv->gsr, NULL);
3818 "PasteTransactionAction");
3819 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
3826 gnc_plugin_page_register_cmd_copy_transaction (GSimpleAction *simple,
3830 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3834 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3836 ENTER (
"(action %p, page %p)", simple, page);
3837 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3843 "PasteTransactionAction");
3844 g_simple_action_set_enabled (G_SIMPLE_ACTION(action),
3851 gnc_plugin_page_register_cmd_paste_transaction (GSimpleAction *simple,
3855 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3859 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3861 ENTER (
"(action %p, page %p)", simple, page);
3862 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3870 gnc_plugin_page_register_cmd_void_transaction (GSimpleAction *simple,
3874 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3876 GtkWidget* dialog, *entry;
3879 GtkBuilder* builder;
3884 ENTER (
"(action %p, page %p)", simple, page);
3886 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3889 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3899 gnc_error_dialog (window,
"%s",
3900 _ (
"You cannot void a transaction with reconciled or cleared splits."));
3906 gnc_error_dialog (window,
3907 _ (
"This transaction is marked read-only with the comment: '%s'"), reason);
3911 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
3914 builder = gtk_builder_new();
3915 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
3916 "void_transaction_dialog");
3917 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
3918 "void_transaction_dialog"));
3919 entry = GTK_WIDGET (gtk_builder_get_object (builder,
"reason"));
3921 gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
3923 result = gtk_dialog_run (GTK_DIALOG (dialog));
3924 if (result == GTK_RESPONSE_OK)
3926 reason = gtk_entry_get_text (GTK_ENTRY (entry));
3933 gtk_widget_destroy (dialog);
3934 g_object_unref (G_OBJECT (builder));
3939 gnc_plugin_page_register_cmd_unvoid_transaction (GSimpleAction *simple,
3943 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3948 ENTER (
"(action %p, page %p)", simple, page);
3950 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3952 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
3961 static std::optional<time64>
3962 input_date (GtkWidget * parent,
const char *window_title,
const char* title)
3965 if (!gnc_dup_time64_dialog (parent, window_title, title, &rv))
3972 gnc_plugin_page_register_cmd_reverse_transaction (GSimpleAction *simple,
3976 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
3980 Transaction* trans, *new_trans;
3985 ENTER (
"(action %p, page %p)", simple, page);
3987 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
3989 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4001 LEAVE (
"shouldn't try to reverse the blank transaction...");
4008 const char *rev = _(
"A reversing entry has already been created for this transaction.");
4009 const char *jump = _(
"Jump to the transaction?");
4010 if (!gnc_verify_dialog (GTK_WINDOW (window), TRUE,
"%s\n\n%s", rev, jump))
4012 LEAVE (
"reverse cancelled");
4018 auto date = input_date (window, _(
"Reverse Transaction"), _(
"New Transaction Information"));
4021 LEAVE (
"reverse cancelled");
4025 gnc_suspend_gui_refresh ();
4032 gnc_resume_gui_refresh();
4037 split = xaccTransFindSplitByAccount(new_trans, account);
4040 if (gnc_split_reg_clear_filter_for_split (gsr, split))
4043 gnc_split_reg_jump_to_split (gsr, split);
4051 GNCLedgerDisplayType ledger_type = gnc_ledger_display_type (priv->ledger);
4054 if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
4060 case GENERAL_JOURNAL:
4065 case PORTFOLIO_LEDGER:
4075 gnc_plugin_page_register_cmd_view_sort_by (GSimpleAction *simple,
4079 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4082 GtkWidget* dialog, *button;
4083 GtkBuilder* builder;
4088 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4089 ENTER (
"(action %p, page %p)", simple, page);
4091 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4092 if (priv->sd.dialog)
4094 gtk_window_present (GTK_WINDOW (priv->sd.dialog));
4095 LEAVE (
"existing dialog");
4101 builder = gtk_builder_new();
4102 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4104 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_by_dialog"));
4105 priv->sd.dialog = dialog;
4106 gtk_window_set_transient_for (GTK_WINDOW (dialog),
4107 gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)));
4109 title = g_strdup_printf (_ (
"Sort %s by…"),
4111 gtk_window_set_title (GTK_WINDOW (dialog), title);
4115 sort = gnc_split_reg_get_sort_type (priv->gsr);
4116 name = SortTypeasString (sort);
4117 button = GTK_WIDGET (gtk_builder_get_object (builder, name));
4118 DEBUG (
"current sort %d, button %s(%p)", sort, name, button);
4119 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4120 priv->sd.original_sort_type = sort;
4122 button = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_save"));
4123 if (priv->sd.save_order == TRUE)
4124 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4127 gtk_widget_set_visible (GTK_WIDGET (button),
4128 gnc_plugin_page_register_show_fs_save (page));
4131 button = GTK_WIDGET (gtk_builder_get_object (builder,
"sort_reverse"));
4132 if (priv->sd.reverse_order == TRUE)
4133 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4134 priv->sd.original_reverse_order = priv->sd.reverse_order;
4136 priv->sd.num_radio = GTK_WIDGET (gtk_builder_get_object (builder,
"BY_NUM"));
4137 priv->sd.act_radio = GTK_WIDGET (gtk_builder_get_object (builder,
4141 if (reg && !reg->use_tran_num_for_num_field)
4143 gtk_button_set_label (GTK_BUTTON (priv->sd.num_radio),
4144 _ (
"Transaction Number"));
4145 gtk_button_set_label (GTK_BUTTON (priv->sd.act_radio), _ (
"Number/Action"));
4147 gnc_book_option_register_cb (OPTION_NAME_NUM_FIELD_SOURCE,
4148 (GncBOCb)gnc_plugin_page_register_sort_book_option_changed,
4152 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func,
4156 gtk_widget_show (dialog);
4157 g_object_unref (G_OBJECT (builder));
4162 gnc_plugin_page_register_cmd_view_filter_by (GSimpleAction *simple,
4166 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4168 GtkWidget* dialog, *toggle, *button, *
table, *hbox;
4169 time64 start_time, end_time, time_val;
4170 GtkBuilder* builder;
4171 gboolean sensitive, value;
4176 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4177 ENTER (
"(action %p, page %p)", simple, page);
4179 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4180 if (priv->fd.dialog)
4182 gtk_window_present (GTK_WINDOW (priv->fd.dialog));
4183 LEAVE (
"existing dialog");
4188 builder = gtk_builder_new();
4189 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4191 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register.glade",
4192 "filter_by_dialog");
4193 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_by_dialog"));
4194 priv->fd.dialog = dialog;
4195 gtk_window_set_transient_for (GTK_WINDOW (dialog),
4196 gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)));
4199 title = g_strdup_printf (_ (
"Filter %s by…"),
4201 gtk_window_set_title (GTK_WINDOW (dialog), title);
4205 for (i = 0; status_actions[i].action_name; i++)
4207 toggle = GTK_WIDGET (gtk_builder_get_object (builder,
4208 status_actions[i].action_name));
4209 value = priv->fd.cleared_match & status_actions[i].value;
4210 status_actions[i].widget = toggle;
4211 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), value);
4213 priv->fd.original_cleared_match = priv->fd.cleared_match;
4215 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_save"));
4216 if (priv->fd.save_filter == TRUE)
4217 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4220 gtk_widget_set_visible (GTK_WIDGET (button),
4221 gnc_plugin_page_register_show_fs_save (page));
4224 priv->fd.num_days = GTK_WIDGET (gtk_builder_get_object (builder,
4225 "filter_show_num_days"));
4226 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_show_days"));
4230 if (priv->fd.days > 0)
4232 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4233 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.num_days), TRUE);
4234 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->fd.num_days), priv->fd.days);
4235 priv->fd.original_days = priv->fd.days;
4243 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.num_days), FALSE);
4244 priv->fd.original_days = 0;
4248 xaccQueryGetDateMatchTT (query, &start_time, &end_time);
4252 priv->fd.original_start_time = start_time;
4253 priv->fd.start_time = start_time;
4254 priv->fd.original_end_time = end_time;
4255 priv->fd.end_time = end_time;
4257 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_show_range"));
4258 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), start_time ||
4260 table = GTK_WIDGET (gtk_builder_get_object (builder,
"select_range_table"));
4261 priv->fd.table =
table;
4262 gtk_widget_set_sensitive (GTK_WIDGET (
table), start_time || end_time);
4264 priv->fd.start_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
4265 "start_date_choose"));
4266 priv->fd.start_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
4267 "start_date_today"));
4268 priv->fd.end_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
4269 "end_date_choose"));
4270 priv->fd.end_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
4275 if (start_time == 0)
4277 button = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_earliest"));
4278 time_val = xaccQueryGetEarliestDateFound (query);
4283 time_val = start_time;
4287 button = priv->fd.start_date_today;
4292 button = priv->fd.start_date_choose;
4296 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4297 priv->fd.start_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
4298 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_hbox"));
4299 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.start_date, TRUE, TRUE, 0);
4300 gtk_widget_show (priv->fd.start_date);
4301 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.start_date), sensitive);
4302 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.start_date), time_val);
4303 g_signal_connect (G_OBJECT (priv->fd.start_date),
"date-changed",
4304 G_CALLBACK (gnc_plugin_page_register_filter_gde_changed_cb),
4312 button = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_latest"));
4313 time_val = xaccQueryGetLatestDateFound (query);
4318 time_val = end_time;
4322 button = priv->fd.end_date_today;
4327 button = priv->fd.end_date_choose;
4331 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
4332 priv->fd.end_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
4333 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_hbox"));
4334 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.end_date, TRUE, TRUE, 0);
4335 gtk_widget_show (priv->fd.end_date);
4336 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.end_date), sensitive);
4337 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.end_date), time_val);
4338 g_signal_connect (G_OBJECT (priv->fd.end_date),
"date-changed",
4339 G_CALLBACK (gnc_plugin_page_register_filter_gde_changed_cb),
4344 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func,
4348 gtk_widget_show (dialog);
4349 g_object_unref (G_OBJECT (builder));
4354 gnc_plugin_page_register_cmd_reload (GSimpleAction *simple,
4358 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4362 ENTER (
"(action %p, page %p)", simple, page);
4364 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4366 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4372 LEAVE (
"register has pending edits");
4380 gnc_plugin_page_register_cmd_style_changed (GSimpleAction *simple,
4381 GVariant *parameter,
4384 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4388 ENTER (
"(action %p, page %p)", simple, page);
4390 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4392 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4396 g_action_change_state (G_ACTION(simple), parameter);
4398 gnc_split_reg_change_style (priv->gsr, value, priv->enable_refresh);
4400 gnc_plugin_page_register_ui_update (NULL, page);
4405 gnc_plugin_page_register_cmd_style_double_line (GSimpleAction *simple,
4406 GVariant *parameter,
4409 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4412 gboolean use_double_line;
4415 ENTER (
"(action %p, page %p)", simple, page);
4417 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER(page));
4419 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4422 state = g_action_get_state (G_ACTION(simple));
4424 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
4426 use_double_line = !g_variant_get_boolean (state);
4428 if (use_double_line != reg->use_double_line)
4431 if (priv->enable_refresh)
4434 g_variant_unref (state);
4439 gnc_plugin_page_register_cmd_transfer (GSimpleAction *simple,
4443 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4445 GncWindow* gnc_window;
4448 ENTER (
"(action %p, page %p)", simple, page);
4450 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4453 gnc_window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
4454 window = GTK_WIDGET (gnc_window_get_gtk_window (gnc_window));
4455 gnc_xfer_dialog (window, account);
4460 gnc_plugin_page_register_cmd_reconcile (GSimpleAction *simple,
4464 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4467 RecnWindow* recnData;
4469 ENTER (
"(action %p, page %p)", simple, page);
4471 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4481 if (!gnc_plugin_page_register_finish_pending (GNC_PLUGIN_PAGE (page)))
4486 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4488 recnData = recnWindow (GTK_WIDGET (window), account);
4489 gnc_ui_reconcile_window_raise (recnData);
4494 gnc_plugin_page_register_cmd_stock_assistant (GSimpleAction *simple,
4498 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4502 ENTER (
"(action %p, page %p)", simple, page);
4504 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4505 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
4507 gnc_stock_transaction_assistant (GTK_WIDGET (window), account);
4513 gnc_plugin_page_register_cmd_autoclear (GSimpleAction *simple,
4517 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4520 AutoClearWindow* autoClearData;
4522 ENTER (
"(action %p, page %p)", simple, page);
4524 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4528 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4530 autoClearData = autoClearWindow (GTK_WIDGET (window), account);
4531 gnc_ui_autoclear_window_raise (autoClearData);
4536 gnc_plugin_page_register_cmd_stock_split (GSimpleAction *simple,
4540 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));
4549 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
4550 gnc_stock_split_dialog (GTK_WIDGET (window), account);
4555 gnc_plugin_page_register_cmd_lots (GSimpleAction *simple,
4559 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4563 ENTER (
"(action %p, page %p)", simple, page);
4565 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4567 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (
4570 gnc_lot_viewer_dialog (window, account);
4575 gnc_plugin_page_register_cmd_enter_transaction (GSimpleAction *simple,
4579 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4582 ENTER (
"(action %p, page %p)", simple, page);
4584 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4586 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4587 gnc_split_reg_enter (priv->gsr, FALSE);
4592 gnc_plugin_page_register_cmd_cancel_transaction (GSimpleAction *simple,
4596 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4599 ENTER (
"(action %p, page %p)", simple, page);
4601 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4603 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4610 gnc_plugin_page_register_cmd_delete_transaction (GSimpleAction *simple,
4614 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4617 ENTER (
"(action %p, page %p)", simple, page);
4619 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4621 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4622 gsr_default_delete_handler (priv->gsr, NULL);
4628 gnc_plugin_page_register_cmd_linked_transaction (GSimpleAction *simple,
4632 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4635 ENTER (
"(action %p, page %p)", simple, page);
4637 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4639 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4640 gsr_default_doclink_handler (priv->gsr);
4641 gnc_plugin_page_register_ui_update (NULL, page);
4646 gnc_plugin_page_register_cmd_linked_transaction_open (GSimpleAction *simple,
4650 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4653 ENTER (
"(action %p, page %p)", simple, page);
4655 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4657 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4658 gsr_default_doclink_open_handler (priv->gsr);
4662 static GncInvoice* invoice_from_split (Split* split)
4664 GncInvoice* invoice;
4683 gnc_plugin_page_register_cmd_jump_linked_invoice (GSimpleAction *simple,
4687 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4690 GncInvoice* invoice;
4694 ENTER (
"(action %p, page %p)", simple, page);
4696 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4697 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4701 window = GNC_PLUGIN_PAGE(page)->window;
4705 auto invoices = invoices_from_transaction (txn);
4706 if (invoices.empty())
4707 PERR (
"shouldn't happen: if no invoices, function is never called");
4708 else if (invoices.size() == 1)
4709 invoice = invoices[0];
4712 GList *details = NULL;
4715 for (
const auto& inv : invoices)
4720 gnc_account_print_info (gncInvoiceGetPostedAcc (inv), TRUE));
4721 details = g_list_prepend
4726 g_strdup_printf (_(
"%s %s from %s, posted %s, amount %s"),
4727 gncInvoiceGetTypeString (inv),
4728 gncInvoiceGetID (inv),
4729 gncOwnerGetName (gncInvoiceGetOwner (inv)),
4733 details = g_list_reverse (details);
4734 choice = gnc_choose_radio_option_dialog
4735 (window, _(
"Select Business Item"),
4736 _(
"Several business items are linked with this transaction. \ 4737 Please choose one:"), _(
"Select"), 0, details);
4738 if ((choice >= 0) && ((
size_t)choice < invoices.size()))
4739 invoice = invoices[choice];
4740 g_list_free_full (details, g_free);
4746 GtkWindow *gtk_window = gnc_window_get_gtk_window (GNC_WINDOW (window));
4747 gnc_ui_invoice_edit (gtk_window, invoice);
4754 gnc_plugin_page_register_cmd_blank_transaction (GSimpleAction *simple,
4758 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4762 ENTER (
"(action %p, page %p)", simple, page);
4764 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4766 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4772 gnc_split_reg_jump_to_blank (priv->gsr);
4777 find_after_date (Split *split,
time64* find_date)
4786 gnc_plugin_page_register_cmd_goto_date (GSimpleAction *simple,
4790 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4796 ENTER (
"(action %p, page %p)", simple, page);
4797 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4799 auto date = input_date (window, _(
"Go to Date"), _(
"Go to Date"));
4803 LEAVE (
"goto_date cancelled");
4814 auto it = g_list_find_custom (splits, &date.value(), (GCompareFunc)find_after_date);
4817 gnc_split_reg_jump_to_split (gsr, GNC_SPLIT(it->data));
4819 gnc_split_reg_jump_to_blank (gsr);
4821 g_list_free (splits);
4826 gnc_plugin_page_register_cmd_duplicate_transaction (GSimpleAction *simple,
4830 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4833 ENTER (
"(action %p, page %p)", simple, page);
4835 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4837 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4844 gnc_plugin_page_register_cmd_reinitialize_transaction (GSimpleAction *simple,
4848 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4851 ENTER (
"(action %p, page %p)", simple, page);
4853 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4855 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4856 gsr_default_reinit_handler (priv->gsr, NULL);
4861 gnc_plugin_page_register_cmd_expand_transaction (GSimpleAction *simple,
4862 GVariant *parameter,
4865 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4871 ENTER (
"(action %p, page %p)", simple, page);
4873 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4875 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4878 state = g_action_get_state (G_ACTION(simple));
4880 g_action_change_state (G_ACTION(simple), g_variant_new_boolean (!g_variant_get_boolean (state)));
4882 expand = !g_variant_get_boolean (state);
4885 g_variant_unref (state);
4892 gnc_plugin_page_register_cmd_exchange_rate (GSimpleAction *simple,
4896 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
4900 ENTER (
"(action %p, page %p)", simple, page);
4902 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
4904 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
4913 jump_multiple_splits_by_single_account (
Account *account, Split *split)
4917 Account *other_account = NULL;
4918 Split *other_split = NULL;
4926 Split *s = (Split*)splits->data;
4929 if (!xaccTransStillHasSplit(trans, s))
4937 if (other_account != a)
4949 other_split = split;
4955 jump_multiple_splits_by_value (
Account *account, Split *split, gboolean largest)
4959 Split *other_split = NULL;
4961 int cmp = largest ? 1 : -1;
4969 Split *s = (Split*)splits->data;
4972 if (!xaccTransStillHasSplit(trans, s))
4994 other_split = split;
5000 jump_multiple_splits (
Account* account, Split *split)
5002 GncPrefJumpMultSplits mode = (GncPrefJumpMultSplits)
gnc_prefs_get_enum(GNC_PREFS_GROUP_GENERAL_REGISTER, GNC_PREF_JUMP_MULT_SPLITS);
5006 case JUMP_LARGEST_VALUE_FIRST_SPLIT:
5007 return jump_multiple_splits_by_value (account, split, TRUE);
5009 case JUMP_SMALLEST_VALUE_FIRST_SPLIT:
5010 return jump_multiple_splits_by_value (account, split, FALSE);
5018 return jump_multiple_splits_by_single_account (account, split);
5022 gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
5026 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5036 gboolean multiple_splits;
5038 ENTER (
"(action %p, page %p)", simple, page);
5040 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5042 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5043 window = GNC_PLUGIN_PAGE (page)->window;
5046 LEAVE (
"no window");
5054 LEAVE (
"no split (1)");
5059 if (account == NULL)
5061 LEAVE (
"no account");
5066 multiple_splits = other_split == NULL;
5069 if (account == leader)
5072 if (cursor_class == CURSOR_CLASS_SPLIT)
5091 LEAVE (
"split for this account");
5095 if (multiple_splits)
5097 other_split = jump_multiple_splits (account, split);
5099 if (other_split == NULL)
5101 GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window),
5102 (GtkDialogFlags)(GTK_DIALOG_MODAL
5103 | GTK_DIALOG_DESTROY_WITH_PARENT),
5107 _(
"Unable to jump to other account"));
5109 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
5110 "%s", _(
"This transaction involves more than one other account. Select a specific split to jump to that account."));
5111 gtk_dialog_add_button (GTK_DIALOG(dialog), _(
"_OK"), GTK_RESPONSE_OK);
5112 gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_MULTIPLE_SPLITS);
5113 gtk_widget_destroy (dialog);
5115 LEAVE (
"no split (2)");
5119 split = other_split;
5122 if (account == NULL)
5124 LEAVE (
"no account (2)");
5128 if (account == leader)
5130 GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW(window),
5131 (GtkDialogFlags)(GTK_DIALOG_MODAL
5132 | GTK_DIALOG_DESTROY_WITH_PARENT),
5136 _(
"Unable to jump to other account"));
5138 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG(dialog),
5139 "%s", _(
"This transaction only involves the current account so there is no other account to jump to."));
5140 gtk_dialog_add_button (GTK_DIALOG(dialog), _(
"_OK"), GTK_RESPONSE_OK);
5141 gnc_dialog_run (GTK_DIALOG(dialog), GNC_PREF_WARN_REG_TRANS_JUMP_SINGLE_ACCOUNT);
5142 gtk_widget_destroy (dialog);
5144 LEAVE (
"register open for account");
5150 if (new_page == NULL)
5152 LEAVE (
"couldn't create new page");
5160 gboolean jump_twice = FALSE;
5166 if (new_page_reg->style != REG_STYLE_JOURNAL)
5170 if (gnc_split_reg_clear_filter_for_split (gsr, split))
5173 gnc_split_reg_jump_to_split (gsr, split);
5175 if (multiple_splits && jump_twice)
5181 gnc_split_reg_jump_to_split (gsr, split);
5187 gnc_plugin_page_register_cmd_schedule (GSimpleAction *simple,
5191 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5195 ENTER (
"(action %p, page %p)", simple, page);
5197 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5201 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5202 gsr_default_schedule_handler (priv->gsr, window);
5207 scrub_split (Split *split)
5213 g_return_if_fail (split);
5217 g_return_if_fail (trans);
5229 gnc_plugin_page_register_cmd_scrub_current (GSimpleAction *simple,
5233 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5238 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5240 ENTER (
"(action %p, page %p)", simple, page);
5242 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5246 LEAVE (
"no query found");
5252 gnc_suspend_gui_refresh();
5254 gnc_resume_gui_refresh();
5259 scrub_kp_handler (GtkWidget *widget, GdkEventKey *event, gpointer data)
5261 if (event->length == 0)
return FALSE;
5263 switch (event->keyval)
5265 case GDK_KEY_Escape:
5267 auto abort_scrub = gnc_verify_dialog (GTK_WINDOW(widget),
false,
5268 "%s", _(check_repair_abort_YN));
5282 gnc_plugin_page_register_cmd_scrub_all (GSimpleAction *simple,
5286 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5290 GList* node, *splits;
5291 gint split_count = 0, curr_split_no = 0;
5292 gulong scrub_kp_handler_ID;
5293 const char* message = _ (
"Checking splits in current register: %u of %u");
5295 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5297 ENTER (
"(action %p, page %p)", simple, page);
5299 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5303 LEAVE (
"no query found");
5307 gnc_suspend_gui_refresh();
5308 is_scrubbing = TRUE;
5310 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5311 scrub_kp_handler_ID = g_signal_connect (G_OBJECT (window),
"key-press-event",
5312 G_CALLBACK (scrub_kp_handler), NULL);
5313 gnc_window_set_progressbar_window (window);
5316 split_count = g_list_length (splits);
5317 for (node = splits; node && !gnc_get_abort_scrub (); node = node->next, curr_split_no++)
5319 auto split = GNC_SPLIT(node->data);
5321 if (!split)
continue;
5323 PINFO (
"Start processing split %d of %d",
5324 curr_split_no + 1, split_count);
5326 scrub_split (split);
5328 PINFO (
"Finished processing split %d of %d",
5329 curr_split_no + 1, split_count);
5331 if (curr_split_no % 10 == 0)
5333 char* progress_msg = g_strdup_printf (message, curr_split_no, split_count);
5334 gnc_window_show_progress (progress_msg, (100 * curr_split_no) / split_count);
5335 g_free (progress_msg);
5339 g_signal_handler_disconnect (G_OBJECT(window), scrub_kp_handler_ID);
5340 gnc_window_show_progress (NULL, -1.0);
5341 is_scrubbing = FALSE;
5342 show_abort_verify = TRUE;
5345 gnc_resume_gui_refresh();
5350 gnc_plugin_page_register_cmd_account_report (GSimpleAction *simple,
5354 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5356 GncMainWindow* window;
5359 ENTER (
"(action %p, page %p)", simple, page);
5361 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5363 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5364 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5365 id = report_helper (priv->ledger, NULL, NULL);
5367 gnc_main_window_open_report (
id, window);
5372 gnc_plugin_page_register_cmd_transaction_report (GSimpleAction *simple,
5376 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5378 GncMainWindow* window;
5385 ENTER (
"(action %p, page %p)", simple, page);
5387 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5389 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5396 query = qof_query_create_for (GNC_ID_SPLIT);
5401 GNC_ID_SPLIT, QOF_QUERY_AND);
5403 window = GNC_MAIN_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5404 id = report_helper (priv->ledger, split, query);
5406 gnc_main_window_open_report (
id, window);
5422 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page));
5424 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
5425 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5426 priv->lines_default = lines_default;
5427 priv->read_only = read_only;
5436 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (plugin_page), NULL);
5438 page = GNC_PLUGIN_PAGE_REGISTER (plugin_page);
5439 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5445 gnc_plugin_page_help_changed_cb (GNCSplitReg* gsr,
5453 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (register_page));
5455 window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window);
5465 (GNC_MAIN_WINDOW(window)) != GNC_PLUGIN_PAGE(register_page)))
5469 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (register_page);
5471 help = gnc_table_get_help (reg->table);
5472 gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help);
5477 gnc_plugin_page_popup_menu_cb (GNCSplitReg* gsr,
5482 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5484 window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
5492 GNC_PLUGIN_PAGE (page));
5496 gnc_plugin_page_register_refresh_cb (GHashTable* changes, gpointer user_data)
5498 auto page = GNC_PLUGIN_PAGE_REGISTER(user_data);
5501 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER (page));
5502 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5507 ei = gnc_gui_get_entity_events (changes, &priv->key);
5510 if (ei->event_mask & QOF_EVENT_DESTROY)
5515 if (ei->event_mask & QOF_EVENT_MODIFY)
5523 gnucash_register_refresh_from_prefs (priv->gsr->reg);
5524 gtk_widget_queue_draw (priv->widget);
5527 gnc_plugin_page_register_ui_update (NULL, page);
5531 gnc_plugin_page_register_close_cb (gpointer user_data)
5546 gppr_account_destroy_cb (
Account* account)
5550 GNCLedgerDisplayType ledger_type;
5553 GList* item, *kill = NULL;
5560 for (; citem; citem = g_list_next (citem))
5563 priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE (page);
5564 ledger_type = gnc_ledger_display_type (priv->ledger);
5565 if (ledger_type == LD_GL)
5567 kill = g_list_prepend (kill, page);
5570 else if ((ledger_type == LD_SINGLE) || (ledger_type == LD_SUBACCOUNT))
5572 if (guid_compare (acct_guid, &priv->key) == 0)
5574 kill = g_list_prepend (kill, page);
5579 kill = g_list_reverse (kill);
5581 for (item = kill; item; item = g_list_next (item))
5604 gnc_plugin_page_register_event_handler (
QofInstance* entity,
5614 g_return_if_fail (page);
5615 if (!GNC_IS_TRANS (entity) && !GNC_IS_ACCOUNT (entity))
5618 ENTER (
"entity %p of type %d, page %p, event data %p",
5619 entity, event_type, page, ed);
5623 if (GNC_IS_ACCOUNT (entity))
5625 if (GNC_IS_MAIN_WINDOW (window))
5631 LEAVE (
"account is NULL");
5635 gchar *name = gnc_plugin_page_register_get_tab_name (GNC_PLUGIN_PAGE (page));
5638 gchar *long_name = gnc_plugin_page_register_get_long_name (GNC_PLUGIN_PAGE (page));
5641 gchar *color = gnc_plugin_page_register_get_tab_color (GNC_PLUGIN_PAGE (page));
5644 gnc_plugin_page_register_update_page_icon (GNC_PLUGIN_PAGE (page));
5650 LEAVE (
"tab contents updated");
5654 if (! (event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
5656 LEAVE (
"not a modify");
5659 trans = GNC_TRANS (entity);
5663 LEAVE (
"not in this book");
5667 if (GNC_IS_MAIN_WINDOW (window))
5670 if (visible_page != GNC_PLUGIN_PAGE (page))
5672 LEAVE (
"page not visible");
5677 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.
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b.
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
Cleanup functions for business objects.
gnc_numeric gncInvoiceGetTotal(GncInvoice *invoice)
Return the "total" amount of the invoice as seen on the document (and shown to the user in the report...
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().
GList SplitList
GList of Split.
gboolean xaccTransHasSplitsInState(const Transaction *trans, const char state)
FIXME: document me.
gboolean gnc_split_register_has_copied_item(void)
Return TRUE if copied_item holds a transaction or split.
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
void gnc_split_register_redraw(SplitRegister *reg)
Causes a redraw of the register window associated with reg.
Functions providing a register page for the GnuCash UI.
const char * gnc_split_register_get_debit_string(SplitRegister *reg)
Return the debit string used in the register.
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
Update the color on the page tabs in the main window.
The class data structure for a content plugin.
void qof_query_destroy(QofQuery *query)
Frees the resources associate with a Query object.
gint QofEventId
Define the type of events allowed.
void gnc_plugin_page_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.
gint gnc_prefs_get_enum(const gchar *group, const gchar *pref_name)
Get an enum value from the preferences backend.
gboolean gncScrubBusinessSplit(Split *split)
The gncScrubBusinessSplit() function will fix all issues found with the given split.
void 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...
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
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.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
GNCLedgerDisplay * gnc_ledger_display_simple(Account *account)
opens up a register window to display a single account
gboolean gncScrubBusinessLot(GNCLot *lot)
The gncScrubBusinessLot() function makes sure that the indicated lot has all the correct properties r...
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
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.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a)
Check for error signal in value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void gnc_plugin_page_register_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...