39 #include "guile-mappings.h"
41 #include <glib/gi18n.h>
42 #include "swig-runtime.h"
44 #include "gnc-plugin-page-register2.h"
48 #include "gnc-plugin-register2.h"
53 #include "gnc-tree-view-split-reg.h"
54 #include "gnc-tree-model-split-reg.h"
55 #include "gnc-tree-control-split-reg.h"
58 #include "dialog-find-transactions2.h"
59 #include "dialog-print-check2.h"
60 #include "dialog-transfer.h"
61 #include "dialog-utils.h"
63 #include "dialog-sx-editor.h"
65 #include "dialog-sx-editor2.h"
67 #include "dialog-sx-from-trans.h"
68 #include "assistant-stock-split.h"
69 #include "gnc-component-manager.h"
71 #include "gnc-date-edit.h"
76 #include "gnc-gui-query.h"
77 #include "gnc-icons.h"
79 #include "gnc-split-reg2.h"
83 #include "gnc-session.h"
84 #include "gnome-utils/gnc-warnings.h"
85 #include "dialog-lot-viewer.h"
88 #include "window-reconcile2.h"
89 #include "window-autoclear.h"
90 #include "window-report.h"
95 #define DEFAULT_LINES_AMOUNT 50
99 static void gnc_plugin_page_register2_finalize (GObject *
object);
101 static GtkWidget *gnc_plugin_page_register2_create_widget (
GncPluginPage *plugin_page);
102 static void gnc_plugin_page_register2_destroy_widget (
GncPluginPage *plugin_page);
103 static void gnc_plugin_page_register2_window_changed (
GncPluginPage *plugin_page, GtkWidget *window);
104 static void gnc_plugin_page_register2_save_page (
GncPluginPage *plugin_page, GKeyFile *file,
const gchar *group);
105 static GncPluginPage *gnc_plugin_page_register2_recreate_page (GtkWidget *window, GKeyFile *file,
const gchar *group);
106 static void gnc_plugin_page_register2_update_edit_menu (
GncPluginPage *page, gboolean hide);
107 static gboolean gnc_plugin_page_register2_finish_pending (
GncPluginPage *page);
109 static gboolean gnc_plugin_page_register2_button_press_cb (GtkWidget *widget, GdkEventButton *event,
GncPluginPage *page);
111 static gchar *gnc_plugin_page_register2_get_tab_name (
GncPluginPage *plugin_page);
112 static gchar *gnc_plugin_page_register2_get_tab_color (
GncPluginPage *plugin_page);
113 static gchar *gnc_plugin_page_register2_get_long_name (
GncPluginPage *plugin_page);
115 static void gnc_plugin_page_register2_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data);
126 static time64 gnc_plugin_page_register2_filter_dmy2time (
char *date_string);
127 static gchar *gnc_plugin_page_register2_filter_time2dmy (
time64 raw_time);
128 static gchar *gnc_plugin_page_register2_get_filter (
GncPluginPage *plugin_page);
129 void gnc_plugin_page_register2_set_filter (
GncPluginPage *plugin_page,
const gchar *filter);
135 static void gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
139 static void gnc_plugin_page_register2_cmd_edit_account (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
140 static void gnc_plugin_page_register2_cmd_find_transactions (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
141 static void gnc_plugin_page_register2_cmd_cut_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
142 static void gnc_plugin_page_register2_cmd_copy_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
143 static void gnc_plugin_page_register2_cmd_paste_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
144 static void gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
145 static void gnc_plugin_page_register2_cmd_unvoid_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
146 static void gnc_plugin_page_register2_cmd_reverse_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
147 static void gnc_plugin_page_register2_cmd_reload (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
148 static void gnc_plugin_page_register2_cmd_view_filter_by (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
149 static void gnc_plugin_page_register2_cmd_style_changed (GtkAction *action, GtkRadioAction *current,
GncPluginPageRegister2 *plugin_page);
150 static void gnc_plugin_page_register2_cmd_style_double_line (GtkToggleAction *action,
GncPluginPageRegister2 *plugin_page);
151 static void gnc_plugin_page_register2_cmd_style_extra_dates (GtkToggleAction *action,
GncPluginPageRegister2 *plugin_page);
153 static void gnc_plugin_page_register2_cmd_reconcile (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
154 static void gnc_plugin_page_register2_cmd_autoclear (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
155 static void gnc_plugin_page_register2_cmd_transfer (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
156 static void gnc_plugin_page_register2_cmd_stock_split (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
158 static void gnc_plugin_page_register2_cmd_enter_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
159 static void gnc_plugin_page_register2_cmd_cancel_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
160 static void gnc_plugin_page_register2_cmd_delete_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
161 static void gnc_plugin_page_register2_cmd_blank_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
162 static void gnc_plugin_page_register2_cmd_duplicate_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
163 static void gnc_plugin_page_register2_cmd_reinitialize_transaction (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
164 static void gnc_plugin_page_register2_cmd_expand_transaction (GtkToggleAction *action,
GncPluginPageRegister2 *plugin_page);
165 static void gnc_plugin_page_register2_cmd_exchange_rate (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
167 static void gnc_plugin_page_register2_cmd_schedule (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
168 static void gnc_plugin_page_register2_cmd_scrub_all (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
169 static void gnc_plugin_page_register2_cmd_scrub_current (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
170 static void gnc_plugin_page_register2_cmd_account_report (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
171 static void gnc_plugin_page_register2_cmd_transaction_report (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
172 static void gnc_plugin_page_register2_cmd_entryUp (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
173 static void gnc_plugin_page_register2_cmd_entryDown (GtkAction *action,
GncPluginPageRegister2 *plugin_page);
176 static void gnc_plugin_page_register2_refresh_cb (GHashTable *changes, gpointer user_data);
177 static void gnc_plugin_page_register2_close_cb (gpointer user_data);
180 static void gppr_account_destroy_cb (
Account *account);
181 static void gnc_plugin_page_register2_event_handler (
QofInstance *entity,
190 #define CUT_TRANSACTION_LABEL N_("Cu_t Transaction")
191 #define COPY_TRANSACTION_LABEL N_("_Copy Transaction")
192 #define PASTE_TRANSACTION_LABEL N_("_Paste Transaction")
193 #define DUPLICATE_TRANSACTION_LABEL N_("Dup_licate Transaction")
194 #define DELETE_TRANSACTION_LABEL N_("_Delete Transaction")
195 #define CUT_SPLIT_LABEL N_("Cu_t Split")
196 #define COPY_SPLIT_LABEL N_("_Copy Split")
197 #define PASTE_SPLIT_LABEL N_("_Paste Split")
198 #define DUPLICATE_SPLIT_LABEL N_("Dup_licate Split")
199 #define DELETE_SPLIT_LABEL N_("_Delete Split")
200 #define CUT_TRANSACTION_TIP N_("Cut the selected transaction into clipboard")
201 #define COPY_TRANSACTION_TIP N_("Copy the selected transaction into clipboard")
202 #define PASTE_TRANSACTION_TIP N_("Paste the transaction from the clipboard")
203 #define DUPLICATE_TRANSACTION_TIP N_("Make a copy of the current transaction")
204 #define DELETE_TRANSACTION_TIP N_("Delete the current transaction")
205 #define CUT_SPLIT_TIP N_("Cut the selected split into clipboard")
206 #define COPY_SPLIT_TIP N_("Copy the selected split into clipboard")
207 #define PASTE_SPLIT_TIP N_("Paste the split from the clipboard")
208 #define DUPLICATE_SPLIT_TIP N_("Make a copy of the current split")
209 #define DELETE_SPLIT_TIP N_("Delete the current split")
211 #define TRANSACTION_UP_ACTION "TransactionUpAction"
212 #define TRANSACTION_DOWN_ACTION "TransactionDownAction"
214 static GtkActionEntry gnc_plugin_page_register2_actions [] =
219 "FilePrintAction", GTK_STOCK_PRINT, N_(
"_Print Checks..."),
"<control>p", NULL,
220 G_CALLBACK (gnc_plugin_page_register2_cmd_print_check)
226 "EditCutAction", GTK_STOCK_CUT, N_(
"Cu_t"), NULL,
227 N_(
"Cut the current selection and copy it to clipboard"),
228 G_CALLBACK (gnc_plugin_page_register2_cmd_cut)
231 "EditCopyAction", GTK_STOCK_COPY, N_(
"_Copy"), NULL,
232 N_(
"Copy the current selection to clipboard"),
233 G_CALLBACK (gnc_plugin_page_register2_cmd_copy)
236 "EditPasteAction", GTK_STOCK_PASTE, N_(
"_Paste"), NULL,
237 N_(
"Paste the clipboard content at the cursor position"),
238 G_CALLBACK (gnc_plugin_page_register2_cmd_paste)
241 "EditEditAccountAction", GNC_STOCK_EDIT_ACCOUNT, N_(
"Edit _Account"),
"<control>e",
242 N_(
"Edit the selected account"),
243 G_CALLBACK (gnc_plugin_page_register2_cmd_edit_account)
246 "EditFindTransactionsAction", GTK_STOCK_FIND, N_(
"_Find..."),
"<control>f",
247 N_(
"Find transactions with a search"),
248 G_CALLBACK (gnc_plugin_page_register2_cmd_find_transactions)
254 "CutTransactionAction", GTK_STOCK_CUT, CUT_TRANSACTION_LABEL,
"",
256 G_CALLBACK (gnc_plugin_page_register2_cmd_cut_transaction)
259 "CopyTransactionAction", GTK_STOCK_COPY, COPY_TRANSACTION_LABEL,
"",
260 COPY_TRANSACTION_TIP,
261 G_CALLBACK (gnc_plugin_page_register2_cmd_copy_transaction)
264 "PasteTransactionAction", GTK_STOCK_PASTE, PASTE_TRANSACTION_LABEL,
"",
265 PASTE_TRANSACTION_TIP,
266 G_CALLBACK (gnc_plugin_page_register2_cmd_paste_transaction)
269 "DuplicateTransactionAction", GTK_STOCK_COPY, DUPLICATE_TRANSACTION_LABEL,
"",
270 DUPLICATE_TRANSACTION_TIP,
271 G_CALLBACK (gnc_plugin_page_register2_cmd_duplicate_transaction)
274 "DeleteTransactionAction", GTK_STOCK_DELETE, DELETE_TRANSACTION_LABEL, NULL,
275 DELETE_TRANSACTION_TIP,
276 G_CALLBACK (gnc_plugin_page_register2_cmd_delete_transaction)
279 "RemoveTransactionSplitsAction", GTK_STOCK_CLEAR, N_(
"Remo_ve All Splits"), NULL,
280 N_(
"Remove all splits in the current transaction"),
281 G_CALLBACK (gnc_plugin_page_register2_cmd_reinitialize_transaction)
284 "RecordTransactionAction", GTK_STOCK_ADD, N_(
"_Enter Transaction"), NULL,
285 N_(
"Record the current transaction"),
286 G_CALLBACK (gnc_plugin_page_register2_cmd_enter_transaction)
289 "CancelTransactionAction", GTK_STOCK_CANCEL, N_(
"Ca_ncel Transaction"), NULL,
290 N_(
"Cancel the current transaction"),
291 G_CALLBACK (gnc_plugin_page_register2_cmd_cancel_transaction)
294 "VoidTransactionAction", NULL, N_(
"_Void Transaction"), NULL, NULL,
295 G_CALLBACK (gnc_plugin_page_register2_cmd_void_transaction)
298 "UnvoidTransactionAction", NULL, N_(
"_Unvoid Transaction"), NULL, NULL,
299 G_CALLBACK (gnc_plugin_page_register2_cmd_unvoid_transaction)
302 "ReverseTransactionAction", NULL, N_(
"Add _Reversing Transaction"), NULL, NULL,
303 G_CALLBACK (gnc_plugin_page_register2_cmd_reverse_transaction)
306 TRANSACTION_UP_ACTION, GTK_STOCK_GO_UP, N_(
"Move Transaction _Up"), NULL,
307 N_(
"Move the current transaction one row upwards. Only available if the date and number of both rows are identical and the register window is sorted by date."),
308 G_CALLBACK (gnc_plugin_page_register2_cmd_entryUp)
311 TRANSACTION_DOWN_ACTION, GTK_STOCK_GO_DOWN, N_(
"Move Transaction Do_wn"), NULL,
312 N_(
"Move the current transaction one row downwards. Only available if the date and number of both rows are identical and the register window is sorted by date."),
313 G_CALLBACK (gnc_plugin_page_register2_cmd_entryDown)
319 "ViewFilterByAction", NULL, N_(
"_Filter By..."), NULL, NULL,
320 G_CALLBACK (gnc_plugin_page_register2_cmd_view_filter_by)
323 "ViewRefreshAction", GTK_STOCK_REFRESH, N_(
"_Refresh"),
"<control>r",
324 N_(
"Refresh this window"),
325 G_CALLBACK (gnc_plugin_page_register2_cmd_reload)
331 "ActionsTransferAction", GNC_STOCK_TRANSFER, N_(
"_Transfer..."),
"<control>t",
332 N_(
"Transfer funds from one account to another"),
333 G_CALLBACK (gnc_plugin_page_register2_cmd_transfer)
336 "ActionsReconcileAction", GTK_STOCK_INDEX, N_(
"_Reconcile..."), NULL,
337 N_(
"Reconcile the selected account"),
338 G_CALLBACK (gnc_plugin_page_register2_cmd_reconcile)
341 "ActionsAutoClearAction", GTK_STOCK_INDEX, N_(
"_Auto-clear..."), NULL,
342 N_(
"Automatically clear individual transactions, so as to reach a certain cleared amount"),
343 G_CALLBACK (gnc_plugin_page_register2_cmd_autoclear)
346 "ActionsStockSplitAction", NULL, N_(
"Stoc_k Split..."), NULL,
347 N_(
"Record a stock split or a stock merger"),
348 G_CALLBACK (gnc_plugin_page_register2_cmd_stock_split)
351 "ActionsLotsAction", NULL, N_(
"View _Lots..."), NULL,
352 N_(
"Bring up the lot viewer/editor window"),
353 G_CALLBACK (gnc_plugin_page_register2_cmd_lots)
356 "BlankTransactionAction", GTK_STOCK_GOTO_BOTTOM, N_(
"_Blank Transaction"),
"<control>Page_Down",
357 N_(
"Move to the blank transaction at the bottom of the register"),
358 G_CALLBACK (gnc_plugin_page_register2_cmd_blank_transaction)
361 "EditExchangeRateAction", NULL, N_(
"Edit E_xchange Rate"), NULL,
362 N_(
"Edit the exchange rate for the current transaction"),
363 G_CALLBACK (gnc_plugin_page_register2_cmd_exchange_rate)
366 "JumpTransactionAction", GNC_STOCK_JUMP_TO, N_(
"_Jump"), NULL,
367 N_(
"Jump to the corresponding transaction in the other account"),
368 G_CALLBACK (gnc_plugin_page_register2_cmd_jump)
371 "ScheduleTransactionAction", GNC_STOCK_SCHEDULE, N_(
"Sche_dule..."), NULL,
372 N_(
"Create a Scheduled Transaction with the current transaction as a template"),
373 G_CALLBACK (gnc_plugin_page_register2_cmd_schedule)
376 "ScrubAllAction", NULL, N_(
"_All transactions"), NULL, NULL,
377 G_CALLBACK (gnc_plugin_page_register2_cmd_scrub_all)
380 "ScrubCurrentAction", NULL, N_(
"_This transaction"), NULL, NULL,
381 G_CALLBACK (gnc_plugin_page_register2_cmd_scrub_current)
387 "ReportsAccountReportAction", NULL, N_(
"Account Report"), NULL,
388 N_(
"Open a register report for this Account"),
389 G_CALLBACK (gnc_plugin_page_register2_cmd_account_report)
392 "ReportsAcctTransReportAction", NULL, N_(
"Account Report - Single Transaction"), NULL,
393 N_(
"Open a register report for the selected Transaction"),
394 G_CALLBACK (gnc_plugin_page_register2_cmd_transaction_report)
398 static guint gnc_plugin_page_register2_n_actions = G_N_ELEMENTS (gnc_plugin_page_register2_actions);
400 static GtkToggleActionEntry toggle_entries[] =
403 "ViewStyleDoubleLineAction", NULL, N_(
"_Double Line"), NULL,
404 N_(
"Show two lines of information for each transaction"),
405 G_CALLBACK (gnc_plugin_page_register2_cmd_style_double_line), FALSE
409 "ViewStyleExtraDatesAction", NULL, N_(
"Show _Extra Dates"), NULL,
410 N_(
"Show entered and reconciled dates"),
411 G_CALLBACK (gnc_plugin_page_register2_cmd_style_extra_dates), FALSE
415 "SplitTransactionAction", GNC_STOCK_SPLIT_TRANS, N_(
"S_plit Transaction"), NULL,
416 N_(
"Show all splits in the current transaction"),
417 G_CALLBACK (gnc_plugin_page_register2_cmd_expand_transaction), FALSE
421 static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
423 static GtkRadioActionEntry radio_entries_2 [] =
427 "ViewStyleBasicAction", NULL, N_(
"_Basic Ledger"), NULL,
428 N_(
"Show transactions on one or two lines"), REG2_STYLE_LEDGER
432 "ViewStyleAutoSplitAction", NULL, N_(
"_Auto-Split Ledger"), NULL,
433 N_(
"Show transactions on one or two lines and expand the current transaction"), REG2_STYLE_AUTO_LEDGER
437 "ViewStyleJournalAction", NULL, N_(
"Transaction _Journal"), NULL,
438 N_(
"Show expanded transactions with all splits"), REG2_STYLE_JOURNAL
442 static guint n_radio_entries_2 = G_N_ELEMENTS (radio_entries_2);
447 static const gchar *important_actions[] =
449 "SplitTransactionAction",
455 static const gchar *actions_requiring_account[] =
457 "EditEditAccountAction",
458 "ActionsReconcileAction",
459 "ActionsAutoClearAction",
465 static const gchar *view_style_actions[] =
467 "ViewStyleBasicAction",
468 "ViewStyleAutoSplitAction",
469 "ViewStyleJournalAction",
476 {
"ActionsTransferAction", N_(
"Transfer") },
477 {
"RecordTransactionAction", N_(
"Enter") },
478 {
"CancelTransactionAction", N_(
"Cancel") },
479 {
"DeleteTransactionAction", N_(
"Delete") },
480 {
"DuplicateTransactionAction", N_(
"Duplicate") },
481 {
"SplitTransactionAction", N_(
"Split") },
482 {
"ScheduleTransactionAction", N_(
"Schedule") },
483 {
"BlankTransactionAction", N_(
"Blank") },
484 {
"ActionsReconcileAction", N_(
"Reconcile") },
485 {
"ActionsAutoClearAction", N_(
"Auto-clear") },
486 { TRANSACTION_UP_ACTION, N_(
"Up") },
487 { TRANSACTION_DOWN_ACTION, N_(
"Down") },
493 const char *action_name;
500 {
"filter_status_reconciled", CLEARED_RECONCILED, NULL },
501 {
"filter_status_cleared", CLEARED_CLEARED, NULL },
502 {
"filter_status_voided", CLEARED_VOIDED, NULL },
503 {
"filter_status_frozen", CLEARED_FROZEN, NULL },
504 {
"filter_status_unreconciled", CLEARED_NO, NULL },
508 #define CLEARED_VALUE "cleared_value"
509 #define DEFAULT_FILTER "0x001f"
522 gint event_handler_id;
523 gint component_manager_id;
533 GtkWidget *start_date_choose;
534 GtkWidget *start_date_today;
535 GtkWidget *start_date;
536 GtkWidget *end_date_choose;
537 GtkWidget *end_date_today;
539 cleared_match_t original_cleared_match;
540 cleared_match_t cleared_match;
541 time64 original_start_time;
545 gboolean original_save_filter;
546 gboolean save_filter;
550 #define GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(o) \
551 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE_REGISTER2, GncPluginPageRegister2Private))
553 static GObjectClass *parent_class = NULL;
562 static GType gnc_plugin_page_register2_type = 0;
564 if (gnc_plugin_page_register2_type == 0)
566 static const GTypeInfo our_info =
571 (GClassInitFunc) gnc_plugin_page_register2_class_init,
576 (GInstanceInitFunc) gnc_plugin_page_register2_init
579 gnc_plugin_page_register2_type = g_type_register_static (GNC_TYPE_PLUGIN_PAGE,
580 GNC_PLUGIN_PAGE_REGISTER2_NAME,
584 return gnc_plugin_page_register2_type;
609 gsr = gnc_ledger_display2_get_user_data (ledger);
613 for ( ; item; item = g_list_next (item))
616 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (register_page);
617 if (priv->gsr == gsr)
618 return GNC_PLUGIN_PAGE (register_page);
622 register_page = g_object_new (GNC_TYPE_PLUGIN_PAGE_REGISTER2, NULL);
623 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (register_page);
624 priv->ledger = ledger;
627 plugin_page = GNC_PLUGIN_PAGE (register_page);
628 label = gnc_plugin_page_register2_get_tab_name (plugin_page);
632 label_color = gnc_plugin_page_register2_get_tab_color (plugin_page);
634 g_free (label_color);
636 label = gnc_plugin_page_register2_get_long_name (plugin_page);
640 q = gnc_ledger_display2_get_query (ledger);
642 for (item = book_list; item; item = g_list_next (item))
646 priv->component_manager_id = 0;
664 ENTER(
"account=%p, subaccounts=%s", account,
665 subaccounts ?
"TRUE" :
"FALSE");
670 for ( ; item; item = g_list_next (item))
678 gnc_error_dialog (NULL,
"%s",
679 _(
"You have tried to open an account in the new register while it is open in the old register."));
686 ledger = gnc_ledger_display2_subaccounts (account);
688 ledger = gnc_ledger_display2_simple (account);
690 page = gnc_plugin_page_register2_new_common (ledger);
691 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
703 ledger = gnc_ledger_display2_gl ();
704 return gnc_plugin_page_register2_new_common (ledger);
710 return gnc_plugin_page_register2_new_common (ledger);
716 GObjectClass *object_class = G_OBJECT_CLASS (klass);
719 parent_class = g_type_class_peek_parent (klass);
721 object_class->finalize = gnc_plugin_page_register2_finalize;
723 gnc_plugin_class->
tab_icon = GNC_STOCK_ACCOUNT;
724 gnc_plugin_class->
plugin_name = GNC_PLUGIN_PAGE_REGISTER2_NAME;
725 gnc_plugin_class->
create_widget = gnc_plugin_page_register2_create_widget;
726 gnc_plugin_class->
destroy_widget = gnc_plugin_page_register2_destroy_widget;
727 gnc_plugin_class->
window_changed = gnc_plugin_page_register2_window_changed;
728 gnc_plugin_class->
save_page = gnc_plugin_page_register2_save_page;
729 gnc_plugin_class->
recreate_page = gnc_plugin_page_register2_recreate_page;
731 gnc_plugin_class->
finish_pending = gnc_plugin_page_register2_finish_pending;
735 gnc_ui_register_account_destroy_callback (gppr_account_destroy_cb);
743 GtkActionGroup *action_group;
746 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
749 parent = GNC_PLUGIN_PAGE(plugin_page);
751 g_object_set(G_OBJECT(plugin_page),
752 "page-name", _(
"General Ledger2"),
753 "page-uri",
"default:",
754 "ui-description",
"gnc-plugin-page-register2-ui.xml",
755 "use-new-window", use_new,
761 "GncPluginPageRegister2Actions");
762 gtk_action_group_add_actions (action_group, gnc_plugin_page_register2_actions,
763 gnc_plugin_page_register2_n_actions, plugin_page);
764 gtk_action_group_add_toggle_actions (action_group,
765 toggle_entries, n_toggle_entries,
767 gtk_action_group_add_radio_actions (action_group,
768 radio_entries_2, n_radio_entries_2,
770 G_CALLBACK(gnc_plugin_page_register2_cmd_style_changed),
776 priv->lines_default = DEFAULT_LINES_AMOUNT;
777 priv->read_only = FALSE;
778 priv->fd.cleared_match = CLEARED_ALL;
782 gnc_plugin_page_register2_finalize (GObject *
object)
787 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (
object));
789 ENTER(
"object %p",
object);
790 page = GNC_PLUGIN_PAGE_REGISTER2 (
object);
791 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
793 G_OBJECT_CLASS (parent_class)->finalize (
object);
801 GNCLedgerDisplay2Type ledger_type;
804 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
805 ledger_type = gnc_ledger_display2_type (priv->ledger);
806 leader = gnc_ledger_display2_leader (priv->ledger);
808 if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
814 static const char* readonly_inactive_actions[] =
818 "CutTransactionAction",
819 "PasteTransactionAction",
820 TRANSACTION_UP_ACTION,
821 TRANSACTION_DOWN_ACTION,
822 "DuplicateTransactionAction",
823 "DeleteTransactionAction",
824 "RemoveTransactionSplitsAction",
825 "RecordTransactionAction",
826 "CancelTransactionAction",
827 "UnvoidTransactionAction",
828 "VoidTransactionAction",
829 "ReverseTransactionAction",
830 "ActionsTransferAction",
831 "ActionsReconcileAction",
832 "ActionsStockSplitAction",
833 "ScheduleTransactionAction",
835 "ScrubCurrentAction",
841 static const char* tran_vs_split_actions[] =
843 "CutTransactionAction",
844 "CopyTransactionAction",
845 "PasteTransactionAction",
846 "DuplicateTransactionAction",
847 "DeleteTransactionAction",
852 static const char* tran_action_labels[] =
854 CUT_TRANSACTION_LABEL,
855 COPY_TRANSACTION_LABEL,
856 PASTE_TRANSACTION_LABEL,
857 DUPLICATE_TRANSACTION_LABEL,
858 DELETE_TRANSACTION_LABEL,
863 static const char* tran_action_tips[] =
866 COPY_TRANSACTION_TIP,
867 PASTE_TRANSACTION_TIP,
868 DUPLICATE_TRANSACTION_TIP,
869 DELETE_TRANSACTION_TIP,
874 static const char* split_action_labels[] =
879 DUPLICATE_SPLIT_LABEL,
885 static const char* split_action_tips[] =
902 gboolean expanded, voided;
906 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
907 g_return_if_fail(priv);
908 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
909 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
910 g_return_if_fail(model);
911 g_return_if_fail(view);
913 expanded = gnc_tree_view_split_reg_trans_expanded (view, NULL);
915 "SplitTransactionAction");
916 gtk_action_set_sensitive (action, model->
style == REG2_STYLE_LEDGER);
917 g_signal_handlers_block_by_func
918 (action, gnc_plugin_page_register2_cmd_expand_transaction, page);
919 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), expanded);
920 g_signal_handlers_unblock_by_func
921 (action, gnc_plugin_page_register2_cmd_expand_transaction, page);
924 trans = gnc_tree_view_split_reg_get_current_trans (view);
928 "VoidTransactionAction");
929 gtk_action_set_sensitive (GTK_ACTION (action), !voided);
932 "UnvoidTransactionAction");
933 gtk_action_set_sensitive (GTK_ACTION (action), voided);
938 gtk_action_set_sensitive(action,
939 gnc_tree_control_split_reg_is_current_movable_updown(view, TRUE));
941 gtk_action_set_sensitive(action,
942 gnc_tree_control_split_reg_is_current_movable_updown(view, FALSE));
949 for (iter = readonly_inactive_actions; *iter; ++iter)
953 gtk_action_set_sensitive (action, FALSE);
960 const char **iter, **label_iter, **tooltip_iter;
961 gboolean curr_label_trans = FALSE;
962 depth = gnc_tree_view_reg_get_selected_row_depth (view);
963 iter = tran_vs_split_actions;
965 label_iter = tran_action_labels;
966 if (g_strcmp0 (gtk_action_get_label (action), _(*label_iter)) == 0)
967 curr_label_trans = TRUE;
968 if ((depth == SPLIT3) && curr_label_trans)
970 label_iter = split_action_labels;
971 tooltip_iter = split_action_tips;
972 for (iter = tran_vs_split_actions; *iter; ++iter)
976 gtk_action_set_label (action, _(*label_iter));
977 gtk_action_set_tooltip (action, _(*tooltip_iter));
982 else if ((depth == TRANS1 || depth == TRANS2) && !curr_label_trans)
984 label_iter = tran_action_labels;
985 tooltip_iter = tran_action_tips;
986 for (iter = tran_vs_split_actions; *iter; ++iter)
990 gtk_action_set_label (action, _(*label_iter));
991 gtk_action_set_tooltip (action, _(*tooltip_iter));
1003 GtkActionGroup *action_group;
1008 GNCLedgerDisplay2Type ledger_type;
1012 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1016 "sensitive", is_readwrite && account != NULL);
1019 ledger_type = gnc_ledger_display2_type (priv->ledger);
1021 "sensitive", ledger_type == LD2_SINGLE);
1023 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
1024 for (i = n_radio_entries_2 - 1; i > 0; i--)
1026 DEBUG(
" index %d: comparing %x to %x", i, radio_entries_2[i].value,
1028 if (radio_entries_2[i].value == model->
style)
1036 action = gtk_action_group_get_action (action_group, radio_entries_2[i].name);
1037 g_signal_handlers_block_by_func (action, gnc_plugin_page_register2_cmd_style_changed, page);
1038 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
1039 g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register2_cmd_style_changed, page);
1041 view = gnc_split_reg2_get_register (priv->gsr);
1044 action = gtk_action_group_get_action (action_group,
"ViewStyleDoubleLineAction");
1045 g_signal_handlers_block_by_func (action, gnc_plugin_page_register2_cmd_style_double_line, page);
1046 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), model->
use_double_line);
1047 g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register2_cmd_style_double_line, page);
1050 action = gtk_action_group_get_action (action_group,
"ViewStyleExtraDatesAction");
1051 g_signal_handlers_block_by_func (action, gnc_plugin_page_register2_cmd_style_extra_dates, page);
1052 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), view->show_extra_dates);
1053 g_signal_handlers_unblock_by_func (action, gnc_plugin_page_register2_cmd_style_extra_dates, page);
1062 gnc_plugin_page_register2_create_widget (
GncPluginPage *plugin_page)
1066 GNCLedgerDisplay2Type ledger_type;
1067 GncWindow *gnc_window;
1076 int filter_changed = 0;
1078 ENTER(
"page %p", plugin_page);
1079 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
1080 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1081 if (priv->widget != NULL)
1083 LEAVE(
"existing widget %p", priv->widget);
1084 return priv->widget;
1087 priv->widget = gtk_vbox_new (FALSE, 0);
1088 gtk_widget_show (priv->widget);
1090 numRows = priv->lines_default;
1091 numRows = MIN (numRows, DEFAULT_LINES_AMOUNT);
1093 gnc_window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
1095 gsr = gnc_split_reg2_new (priv->ledger,
1096 gnc_window_get_gtk_window (gnc_window),
1097 numRows, priv->read_only);
1099 gtk_widget_show (gsr);
1101 gtk_box_pack_start (GTK_BOX (priv->widget), gsr, TRUE, TRUE, 0);
1103 g_signal_connect (G_OBJECT (gsr),
"help-changed",
1104 G_CALLBACK (gnc_plugin_page_help_changed_cb),
1107 view = gnc_split_reg2_get_register (priv->gsr);
1110 g_signal_connect (G_OBJECT (GTK_TREE_VIEW (view)),
"button-press-event",
1111 G_CALLBACK (gnc_plugin_page_register2_button_press_cb), page);
1113 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
1117 gnc_plugin_page_register2_ui_initial_state (page);
1118 gnc_plugin_page_register2_ui_update (NULL, page);
1120 ledger_type = gnc_ledger_display2_type (priv->ledger);
1122 if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT || ledger_type == LD2_GL)
1125 priv->fd.save_filter = FALSE;
1127 filter = g_strsplit(gnc_plugin_page_register2_get_filter (plugin_page),
",", -1);
1129 PINFO(
"Loaded Filter Status is %s", filter[0]);
1131 priv->fd.cleared_match = (gint)g_ascii_strtoll (filter[0], NULL, 16 );
1133 if (filter[0] && (g_strcmp0 (filter[0], DEFAULT_FILTER) != 0))
1134 filter_changed = filter_changed + 1;
1136 if (filter[1] && (g_strcmp0 (filter[1],
"0") != 0 ))
1138 PINFO(
"Loaded Filter Start Date is %s", filter[1]);
1140 priv->fd.start_time = gnc_plugin_page_register2_filter_dmy2time (filter[1]);
1142 filter_changed = filter_changed + 1;
1144 if (filter[2] && (g_strcmp0 (filter[2],
"0") != 0 ))
1146 PINFO(
"Loaded Filter End Date is %s", filter[2]);
1148 priv->fd.end_time = gnc_plugin_page_register2_filter_dmy2time (filter[2]);
1150 filter_changed = filter_changed + 1;
1154 if (filter_changed != 0)
1155 priv->fd.save_filter = TRUE;
1157 priv->fd.original_save_filter = priv->fd.save_filter;
1158 g_strfreev (filter);
1161 gnc_ppr_update_status_query (page, FALSE);
1162 gnc_ppr_update_date_query (page, FALSE);
1166 gnc_ledger_display2_refresh (priv->ledger);
1169 if (!gnc_tree_model_split_reg_get_template (model))
1170 gnc_tree_view_split_reg_default_selection (view);
1172 plugin_page->
summarybar = gnc_split_reg2_create_summary_bar (priv->gsr);
1175 gtk_widget_show_all (plugin_page->
summarybar);
1176 gtk_box_pack_start (GTK_BOX (priv->widget), plugin_page->
summarybar,
1178 gnc_plugin_page_register2_summarybar_position_changed (NULL, NULL, page);
1180 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1181 gnc_plugin_page_register2_summarybar_position_changed,
1184 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1185 gnc_plugin_page_register2_summarybar_position_changed,
1191 priv->component_manager_id =
1192 gnc_register_gui_component (GNC_PLUGIN_PAGE_REGISTER2_NAME,
1193 gnc_plugin_page_register2_refresh_cb,
1194 gnc_plugin_page_register2_close_cb,
1196 gnc_gui_component_set_session (priv->component_manager_id,
1197 gnc_get_current_session());
1200 gnc_gui_component_watch_entity (
1202 QOF_EVENT_DESTROY | QOF_EVENT_MODIFY);
1205 gnc_split_reg2_set_moved_cb
1206 (priv->gsr, (GFunc)gnc_plugin_page_register2_ui_update, page);
1209 return priv->widget;
1222 gnc_plugin_page_register2_button_press_cb (GtkWidget *widget,
1223 GdkEventButton *event,
1227 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
1229 ENTER(
"widget %p, event %p, page %p", widget, event, page);
1241 gnc_plugin_page_register2_destroy_widget (
GncPluginPage *plugin_page)
1246 ENTER(
"page %p", plugin_page);
1247 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
1248 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
1251 GNC_PREF_SUMMARYBAR_POSITION_TOP,
1252 gnc_plugin_page_register2_summarybar_position_changed,
1255 GNC_PREF_SUMMARYBAR_POSITION_BOTTOM,
1256 gnc_plugin_page_register2_summarybar_position_changed,
1259 if (priv->widget == NULL)
1265 if (priv->component_manager_id)
1267 gnc_unregister_gui_component (priv->component_manager_id);
1268 priv->component_manager_id = 0;
1271 if (priv->event_handler_id)
1274 priv->event_handler_id = 0;
1277 if (priv->fd.dialog)
1279 gtk_widget_destroy (priv->fd.dialog);
1280 memset(&priv->fd, 0,
sizeof(priv->fd));
1283 gtk_widget_hide (priv->widget);
1287 gnc_ledger_display2_close (priv->ledger);
1288 priv->ledger = NULL;
1293 g_object_unref (G_OBJECT(priv->widget));
1294 priv->widget = NULL;
1300 gnc_plugin_page_register2_window_changed (
GncPluginPage *plugin_page,
1306 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
1308 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
1309 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1312 GTK_WIDGET(gnc_window_get_gtk_window (GNC_WINDOW (window)));
1315 static const gchar *style_names[] =
1323 #define KEY_REGISTER_TYPE "RegisterType"
1324 #define KEY_ACCOUNT_NAME "AccountName"
1325 #define KEY_REGISTER_STYLE "RegisterStyle"
1326 #define KEY_DOUBLE_LINE "DoubleLineMode"
1327 #define KEY_EXTRA_DATES "ExtraDatesMode"
1329 #define LABEL_ACCOUNT "Account"
1330 #define LABEL_SUBACCOUNT "SubAccount"
1331 #define LABEL_GL "GL"
1332 #define LABEL_SEARCH "Search"
1334 #define SPLIT_REGISTER_GUID "SplitRegister GUID"
1346 gnc_plugin_page_register2_save_page (
GncPluginPage *plugin_page,
1348 const gchar *group_name)
1352 GNCLedgerDisplay2Type ledger_type;
1357 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
1358 g_return_if_fail (key_file != NULL);
1359 g_return_if_fail (group_name != NULL);
1361 ENTER(
"page %p, key_file %p, group_name %s", plugin_page, key_file,
1364 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
1365 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1367 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
1368 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
1369 ledger_type = gnc_ledger_display2_type (priv->ledger);
1370 if (ledger_type > LD2_GL)
1372 LEAVE(
"Unsupported ledger type");
1375 if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
1379 label = (ledger_type == LD2_SINGLE) ? LABEL_ACCOUNT : LABEL_SUBACCOUNT;
1380 leader = gnc_ledger_display2_leader (priv->ledger);
1381 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE, label);
1383 g_key_file_set_string (key_file, group_name, KEY_ACCOUNT_NAME, name);
1386 else if (model->
type == GENERAL_LEDGER2)
1388 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1391 else if (model->
type == SEARCH_LEDGER2)
1393 g_key_file_set_string (key_file, group_name, KEY_REGISTER_TYPE,
1398 LEAVE(
"Unsupported register type");
1402 g_key_file_set_string (key_file, group_name, KEY_REGISTER_STYLE, style_names[model->
style]);
1403 g_key_file_set_boolean (key_file, group_name, KEY_DOUBLE_LINE, model->
use_double_line);
1404 g_key_file_set_boolean (key_file, group_name, KEY_EXTRA_DATES, view->show_extra_dates);
1422 gnc_plugin_page_register2_restore_edit_menu (
GncPluginPage *page,
1424 const gchar *group_name)
1428 GError *error = NULL;
1431 gboolean use_double_line;
1432 gboolean show_extra_dates;
1435 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1438 style_name = g_key_file_get_string (key_file, group_name,
1439 KEY_REGISTER_STYLE, &error);
1440 for (i = 0 ; style_names[i]; i++)
1442 if (g_ascii_strcasecmp (style_name, style_names[i]) == 0)
1444 DEBUG(
"Found match for style name: %s", style_name);
1448 g_free (style_name);
1451 if (i <= REG2_STYLE_JOURNAL)
1453 DEBUG(
"Setting style: %d", i);
1455 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
1460 g_key_file_get_boolean (key_file, group_name, KEY_DOUBLE_LINE, &error);
1461 DEBUG(
"Setting double_line_mode: %d", use_double_line);
1463 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), use_double_line);
1467 g_key_file_get_boolean (key_file, group_name, KEY_EXTRA_DATES, &error);
1468 DEBUG(
"Setting extra_dates_mode: %d", show_extra_dates);
1470 gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_extra_dates);
1484 gnc_plugin_page_register2_recreate_page (GtkWidget *window,
1486 const gchar *group_name)
1489 GError *error = NULL;
1490 gchar *reg_type, *acct_name;
1493 gboolean include_subs;
1495 g_return_val_if_fail (key_file, NULL);
1496 g_return_val_if_fail (group_name, NULL);
1497 ENTER(
"key_file %p, group_name %s", key_file, group_name);
1500 reg_type = g_key_file_get_string (key_file, group_name,
1501 KEY_REGISTER_TYPE, &error);
1502 DEBUG(
"Page type: %s", reg_type);
1503 if ((g_ascii_strcasecmp (reg_type, LABEL_ACCOUNT) == 0) ||
1504 (g_ascii_strcasecmp (reg_type, LABEL_SUBACCOUNT) == 0))
1506 include_subs = (g_ascii_strcasecmp(reg_type, LABEL_SUBACCOUNT) == 0);
1507 DEBUG(
"Include subs: %d", include_subs);
1508 acct_name = g_key_file_get_string (key_file, group_name,
1509 KEY_ACCOUNT_NAME, &error);
1514 if (account == NULL)
1516 LEAVE(
"Bad account name");
1522 else if (g_ascii_strcasecmp (reg_type, LABEL_GL) == 0)
1528 LEAVE(
"Bad ledger type");
1541 gnc_plugin_page_register2_restore_edit_menu (page, key_file, group_name);
1551 gnc_plugin_page_register2_update_edit_menu (
GncPluginPage *page, gboolean hide)
1557 gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
1558 gboolean has_selection;
1560 reg_page = GNC_PLUGIN_PAGE_REGISTER2 (page);
1561 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (reg_page);
1562 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
1565 if (view->editing_now)
1566 has_selection = TRUE;
1568 has_selection = FALSE;
1570 can_copy = has_selection;
1571 can_cut = is_readwrite && has_selection;
1572 can_paste = is_readwrite;
1575 gtk_action_set_sensitive (action, can_copy);
1576 gtk_action_set_visible (action, !hide || can_copy);
1578 gtk_action_set_sensitive (action, can_cut);
1579 gtk_action_set_visible (action, !hide || can_cut);
1581 gtk_action_set_sensitive (action, can_paste);
1582 gtk_action_set_visible (action, !hide || can_paste);
1586 gnc_plugin_page_register2_finish_pending (
GncPluginPage *page)
1591 GtkWidget *dialog, *window;
1595 reg_page = GNC_PLUGIN_PAGE_REGISTER2 (page);
1596 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (reg_page);
1597 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
1600 gnc_tree_view_split_reg_finish_edit (view);
1602 if (!view || (gnc_tree_view_split_reg_get_dirty_trans (view) == NULL))
1605 name = gnc_plugin_page_register2_get_tab_name (page);
1607 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
1608 GTK_DIALOG_DESTROY_WITH_PARENT,
1609 GTK_MESSAGE_WARNING,
1613 _(
"Save changes to %s?"), name);
1614 gtk_message_dialog_format_secondary_text
1615 (GTK_MESSAGE_DIALOG (dialog),
1617 _(
"This register has pending changes to a transaction. "
1618 "Would you like to save the changes to this transaction, "
1619 "discard the transaction, or cancel the operation?"));
1620 gnc_gtk_dialog_add_button (dialog, _(
"_Discard Transaction"),
1621 GTK_STOCK_DELETE, GTK_RESPONSE_REJECT);
1622 gtk_dialog_add_button (GTK_DIALOG (dialog),
1623 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
1624 gnc_gtk_dialog_add_button (dialog, _(
"_Save Transaction"),
1625 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT);
1627 response = gtk_dialog_run (GTK_DIALOG (dialog));
1628 gtk_widget_destroy (dialog);
1632 case GTK_RESPONSE_ACCEPT:
1633 return (gnc_tree_control_split_reg_save (view, TRUE));
1635 case GTK_RESPONSE_REJECT:
1636 gnc_tree_control_split_reg_cancel_edit (view, TRUE);
1645 gnc_plugin_page_register2_get_tab_name (
GncPluginPage *plugin_page)
1648 GNCLedgerDisplay2Type ledger_type;
1653 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page), _(
"unknown"));
1655 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
1657 model = gnc_ledger_display2_get_split_model_register(ld);
1658 ledger_type = gnc_ledger_display2_type (ld);
1659 leader = gnc_ledger_display2_leader (ld);
1661 switch (ledger_type)
1666 case LD2_SUBACCOUNT:
1670 switch (model->
type)
1672 case GENERAL_LEDGER:
1674 return g_strdup(_(
"General Ledger"));
1675 case PORTFOLIO_LEDGER:
1676 return g_strdup(_(
"Portfolio"));
1678 return g_strdup(_(
"Search Results"));
1688 return g_strdup(_(
"unknown"));
1692 gnc_plugin_page_register2_get_tab_color (
GncPluginPage *plugin_page)
1695 GNCLedgerDisplay2Type ledger_type;
1700 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page), _(
"unknown"));
1702 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
1704 ledger_type = gnc_ledger_display2_type (ld);
1705 leader = gnc_ledger_display2_leader (ld);
1708 if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
1711 return g_strdup(color ? color :
"Not Set");
1715 gnc_plugin_page_register2_get_filter (
GncPluginPage *plugin_page)
1718 GNCLedgerDisplay2Type ledger_type;
1723 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page), _(
"unknown"));
1725 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
1727 ledger_type = gnc_ledger_display2_type (ld);
1728 leader = gnc_ledger_display2_leader (ld);
1731 if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
1734 return filter ? g_strdup(filter) : g_strdup_printf(
"%s,%s,%s", DEFAULT_FILTER,
"0",
"0");
1738 gnc_plugin_page_register2_set_filter (
GncPluginPage *plugin_page,
const gchar *filter )
1741 GNCLedgerDisplay2Type ledger_type;
1744 gchar *default_filter;
1746 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
1748 ledger_type = gnc_ledger_display2_type (ld);
1749 leader = gnc_ledger_display2_leader (ld);
1753 default_filter = g_strdup_printf(
"%s,%s,%s", DEFAULT_FILTER,
"0",
"0");
1755 if (!filter || (g_strcmp0 (filter, default_filter) == 0))
1760 g_free (default_filter);
1766 gnc_plugin_page_register2_get_long_name (
GncPluginPage *plugin_page)
1769 GNCLedgerDisplay2Type ledger_type;
1773 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page), _(
"unknown"));
1775 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
1777 ledger_type = gnc_ledger_display2_type (ld);
1778 leader = gnc_ledger_display2_leader (ld);
1780 switch (ledger_type)
1785 case LD2_SUBACCOUNT:
1788 gchar *return_string = g_strdup_printf (
"%s+", account_full_name);
1789 g_free ((gpointer *) account_full_name);
1790 return return_string;
1801 gnc_plugin_page_register2_summarybar_position_changed (gpointer prefs, gchar* pref, gpointer user_data)
1806 GtkPositionType position = GTK_POS_BOTTOM;
1808 g_return_if_fail (user_data != NULL);
1810 if (!GNC_IS_PLUGIN_PAGE (user_data))
1813 plugin_page = GNC_PLUGIN_PAGE (user_data);
1814 page = GNC_PLUGIN_PAGE_REGISTER2 (user_data);
1815 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1821 position = GTK_POS_TOP;
1823 gtk_box_reorder_child (GTK_BOX (priv->widget),
1825 (position == GTK_POS_TOP ? 0 : -1) );
1855 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1856 query = gnc_ledger_display2_get_query (priv->ledger );
1859 LEAVE(
"no query found");
1864 param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
1868 g_slist_free(param_list);
1872 if (priv->fd.cleared_match != CLEARED_ALL)
1873 xaccQueryAddClearedMatch(query, priv->fd.cleared_match, QOF_QUERY_AND);
1876 gnc_ledger_display2_refresh (priv->ledger);
1900 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
1907 query = gnc_ledger_display2_get_query (priv->ledger);
1915 param_list = qof_query_build_param_list (SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
1919 g_slist_free(param_list);
1922 if (priv->fd.start_time || priv->fd.end_time)
1925 xaccQueryAddDateMatchTT (query,
1926 priv->fd.start_time != 0, priv->fd.start_time,
1927 priv->fd.end_time != 0, priv->fd.end_time,
1932 gnc_ledger_display2_refresh (priv->ledger);
1938 gnc_plugin_page_register2_filter_time2dmy (
time64 raw_time)
1940 struct tm * timeinfo;
1941 gchar date_string[11];
1945 i = strftime (date_string, 11,
"%d-%m-%Y", timeinfo);
1946 PINFO(
"Date string is %s", date_string);
1949 return g_strdup (date_string);
1954 gnc_plugin_page_register2_filter_dmy2time (
char *date_string)
1958 PINFO(
"Date string is %s", date_string);
1959 memset (&when, 0,
sizeof (when));
1960 sscanf (date_string,
"%d-%d-%d", &when.tm_mday,
1961 &when.tm_mon, &when.tm_year);
1963 when.tm_year -= 1900;
1987 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
1988 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
1990 name = gtk_buildable_get_name (GTK_BUILDABLE (button));
1991 ENTER(
"toggle button %s (%p), plugin_page %p", name, button, page);
1994 value = CLEARED_NONE;
1995 for (i = 0; status_actions[i].action_name; i++)
1997 if (g_strcmp0 (name, status_actions[i].action_name) == 0)
1999 value = status_actions[i].value;
2005 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2006 if (gtk_toggle_button_get_active (button))
2007 priv->fd.cleared_match |= value;
2009 priv->fd.cleared_match &= ~value;
2010 gnc_ppr_update_status_query (page, TRUE);
2031 g_return_if_fail (GTK_IS_BUTTON (button));
2032 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2034 ENTER(
"(button %p, page %p)", button, page);
2037 for (i = 0; status_actions[i].action_name; i++)
2039 widget = status_actions[i].widget;
2041 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
2046 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2047 priv->fd.cleared_match = CLEARED_ALL;
2048 gnc_ppr_update_status_query (page, TRUE);
2067 GtkWidget *button, *today, *gde;
2070 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2071 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)))
2073 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.start_date));
2075 priv->fd.start_time = time_val;
2079 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_today)))
2085 priv->fd.start_time = 0;
2089 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose)))
2091 time_val = gnc_date_edit_get_date (GNC_DATE_EDIT (priv->fd.end_date));
2093 priv->fd.end_time = time_val;
2097 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_today)))
2103 priv->fd.end_time = 0;
2130 g_return_if_fail (GTK_IS_RADIO_BUTTON (button));
2131 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2133 ENTER(
"(button %p, page %p)", button, page);
2134 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2135 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
2136 gtk_widget_set_sensitive (priv->fd.table, active);
2139 get_filter_times (page);
2143 priv->fd.start_time = 0;
2144 priv->fd.end_time = 0;
2146 gnc_ppr_update_date_query (page, TRUE);
2161 gnc_plugin_page_register2_filter_gde_changed_cb (GtkWidget *unused,
2164 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2166 ENTER(
"(widget %s(%p), page %p)", gtk_buildable_get_name (GTK_BUILDABLE (unused)), unused, page);
2167 get_filter_times (page);
2168 gnc_ppr_update_date_query (page, TRUE);
2199 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
2200 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2202 ENTER(
"(radio %s(%p), page %p)", gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
2203 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2204 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
2206 LEAVE(
"1st callback of pair. Defer to 2nd callback.");
2210 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
2211 active = (g_strcmp0 (name, g_strdup (
"start_date_choose")) == 0 ? 1 : 0 );
2212 gtk_widget_set_sensitive (priv->fd.start_date, active);
2213 get_filter_times (page);
2214 gnc_ppr_update_date_query (page, TRUE);
2245 g_return_if_fail (GTK_IS_RADIO_BUTTON (radio));
2246 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2248 ENTER(
"(radio %s(%p), page %p)", gtk_buildable_get_name (GTK_BUILDABLE (radio)), radio, page);
2249 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2250 if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)))
2252 LEAVE(
"1st callback of pair. Defer to 2nd callback.");
2256 name = gtk_buildable_get_name (GTK_BUILDABLE (radio));
2257 active = (g_strcmp0 (name, g_strdup (
"end_date_choose")) == 0 ? 1 : 0 );
2258 gtk_widget_set_sensitive (priv->fd.end_date, active);
2259 get_filter_times (page);
2260 gnc_ppr_update_date_query (page, TRUE);
2278 g_return_if_fail (GTK_IS_CHECK_BUTTON (button));
2279 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2281 ENTER(
"Save toggle button (%p), plugin_page %p", button, page);
2284 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2285 if (gtk_toggle_button_get_active (button))
2286 priv->fd.save_filter = TRUE;
2288 priv->fd.save_filter = FALSE;
2311 g_return_if_fail (GTK_IS_DIALOG (dialog));
2312 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2315 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2316 plugin_page = GNC_PLUGIN_PAGE (page);
2318 if (response != GTK_RESPONSE_OK)
2321 priv->fd.cleared_match = priv->fd.original_cleared_match;
2322 gnc_ppr_update_status_query (page, FALSE);
2323 priv->fd.start_time = priv->fd.original_start_time;
2324 priv->fd.end_time = priv->fd.original_end_time;
2325 priv->fd.save_filter = priv->fd.original_save_filter;
2326 gnc_ppr_update_date_query (page, FALSE);
2327 gnc_ledger_display2_refresh (priv->ledger);
2331 priv->fd.original_save_filter = priv->fd.save_filter;
2333 if (priv->fd.save_filter)
2336 filter = g_strdup_printf (
"0x%04x", priv->fd.cleared_match);
2338 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)) && priv->fd.start_time != 0 )
2340 gchar *
timeval = gnc_plugin_page_register2_filter_time2dmy (priv->fd.start_time);
2341 filter = g_strconcat (filter,
",", timeval, NULL);
2345 filter = g_strconcat (filter,
",0", NULL);
2347 if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose)) && priv->fd.end_time != 0 )
2349 gchar *
timeval = gnc_plugin_page_register2_filter_time2dmy (priv->fd.end_time);
2350 filter = g_strconcat (filter,
",", timeval, NULL);
2354 filter = g_strconcat (filter,
",0", NULL);
2356 PINFO(
"The filter to save is %s", filter);
2358 gnc_plugin_page_register2_set_filter (plugin_page, filter);
2362 priv->fd.dialog = NULL;
2363 gtk_widget_destroy (GTK_WIDGET (dialog));
2379 gchar *account_name;
2382 GNCLedgerDisplay2Type ledger_type;
2387 model = gnc_ledger_display2_get_split_model_register (ledger);
2388 ledger_type = gnc_ledger_display2_type (ledger);
2390 switch (model->
type)
2392 case GENERAL_LEDGER:
2395 reg_name = _(
"General Ledger");
2397 reg_name = _(
"General Ledger Report");
2399 case PORTFOLIO_LEDGER:
2401 reg_name = _(
"Portfolio");
2403 reg_name = _(
"Portfolio Report");
2407 reg_name = _(
"Search Results");
2409 reg_name = _(
"Search Results Report");
2413 reg_name = _(
"Register");
2415 reg_name = _(
"Register Report");
2419 leader = gnc_ledger_display2_leader (ledger);
2421 if ((leader != NULL) && (ledger_type != LD2_GL))
2425 if (ledger_type == LD2_SINGLE)
2427 name = g_strconcat (account_name,
" - ", reg_name, NULL);
2431 name = g_strconcat (account_name,
" ", _(
"and subaccounts"),
" - ", reg_name, NULL);
2433 g_free (account_name);
2436 name = g_strdup (reg_name);
2449 swig_type_info * qtype;
2456 view = gnc_ledger_display2_get_split_view_register (ledger);
2457 model = gnc_ledger_display2_get_split_model_register (ledger);
2459 func = scm_c_eval_string (
"gnc:register-report-create");
2460 g_return_val_if_fail (scm_is_procedure (func), -1);
2461 tmp = gnc_tree_view_split_reg_get_credit_debit_string (view, TRUE);
2463 arg = scm_from_utf8_string (tmp ? tmp : _(
"Credit"));
2464 args = scm_cons (arg, args);
2465 tmp = gnc_tree_view_split_reg_get_credit_debit_string (view, FALSE);
2466 arg = scm_from_utf8_string (tmp ? tmp : _(
"Debit"));
2467 args = scm_cons (arg, args);
2469 str = gnc_reg_get_name (ledger, FALSE);
2470 arg = scm_from_utf8_string (str ? str :
"");
2471 args = scm_cons (arg, args);
2475 args = scm_cons (arg, args);
2477 arg = SCM_BOOL (model->
type == GENERAL_LEDGER2 || model->
type == INCOME_LEDGER2
2478 || model->
type == SEARCH_LEDGER2);
2479 args = scm_cons (arg, args);
2481 arg = SCM_BOOL (model->
style == REG2_STYLE_JOURNAL);
2482 args = scm_cons (arg, args);
2486 query = gnc_ledger_display2_get_query (ledger);
2487 g_return_val_if_fail (query != NULL, -1);
2490 qtype = SWIG_TypeQuery (
"_p__QofQuery");
2491 g_return_val_if_fail (qtype, -1);
2493 arg = SWIG_NewPointerObj (query, qtype, 0);
2494 args = scm_cons (arg, args);
2495 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2500 qtype = SWIG_TypeQuery (
"_p_Split");
2501 g_return_val_if_fail (qtype, -1);
2502 arg = SWIG_NewPointerObj (split, qtype, 0);
2508 args = scm_cons (arg, args);
2509 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2512 qtype = SWIG_TypeQuery (
"_p_Account");
2513 g_return_val_if_fail (qtype, -1);
2515 account = gnc_ledger_display2_leader (ledger);
2516 arg = SWIG_NewPointerObj (account, qtype, 0);
2517 args = scm_cons (arg, args);
2518 g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
2522 arg = scm_apply (func, args, SCM_EOL);
2523 g_return_val_if_fail (scm_is_exact (arg), -1);
2525 return scm_to_int (arg);
2536 gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
2544 GList * splits = NULL, *item;
2545 GNCLedgerDisplay2Type ledger_type;
2548 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
2550 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
2552 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
2553 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2554 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
2555 ledger_type = gnc_ledger_display2_type (priv->ledger);
2557 if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
2560 split = gnc_tree_view_split_reg_get_current_split (view);
2565 LEAVE(
"trans is NULL");
2570 if (trans == gnc_tree_control_split_reg_get_blank_trans (view))
2572 LEAVE(
"Asked to print a blank trans");
2577 if (gnc_tree_control_split_reg_trans_test_for_edit (view, trans))
2579 LEAVE(
"trans being edited in another register");
2584 if (gnc_tree_control_split_reg_trans_open_and_warn (view, trans))
2586 LEAVE(
"trans being edited");
2594 splits = g_list_append(splits, split);
2595 gnc_ui_print_check_dialog_create2 (plugin_page, splits);
2596 g_list_free(splits);
2602 split = gnc_tree_model_split_reg_trans_get_split_equal_to_ancestor(trans, account);
2605 splits = g_list_append(splits, split);
2606 gnc_ui_print_check_dialog_create2 (plugin_page, splits);
2607 g_list_free(splits);
2612 else if (ledger_type == LD2_GL && model->
type == SEARCH_LEDGER2)
2614 Account *common_acct = NULL, *account;
2615 splits =
qof_query_run (gnc_ledger_display2_get_query (priv->ledger));
2617 for (item = splits; item; item = g_list_next (item))
2619 split = (
Split *) item->data;
2620 if (common_acct == NULL)
2628 GtkWidget *dialog, *window;
2630 const gchar *title = _(
"Print checks from multiple accounts?");
2631 const gchar *message =
2632 _(
"This search result contains splits from more than one account. "
2633 "Do you want to print the checks even though they are not all "
2634 "from the same account?");
2636 dialog = gtk_message_dialog_new (GTK_WINDOW (window),
2637 GTK_DIALOG_DESTROY_WITH_PARENT,
2638 GTK_MESSAGE_WARNING,
2641 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
2643 gtk_dialog_add_button (GTK_DIALOG (dialog), _(
"_Print checks"),
2645 response = gnc_dialog_run (GTK_DIALOG (dialog),
2646 GNC_PREF_WARN_CHECKPRINTING_MULTI_ACCT);
2647 gtk_widget_destroy (dialog);
2648 if (response != GTK_RESPONSE_YES)
2650 LEAVE(
"Multiple accounts");
2657 gnc_ui_print_check_dialog_create2 (plugin_page, splits);
2662 _(
"You can only print checks from a bank account register or search results."));
2663 LEAVE(
"Unsupported ledger type");
2670 gnc_plugin_page_register2_cmd_cut (GtkAction *action,
2675 GtkWidget *window, *widget;
2677 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2679 ENTER(
"(action %p, page %p)", action, page);
2680 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2681 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2684 widget = gtk_window_get_focus (GTK_WINDOW (window));
2686 DEBUG(
"(widget name is %s)", gtk_widget_get_name (widget));
2688 if (GTK_IS_ENTRY(widget))
2689 g_signal_emit_by_name(widget,
"cut-clipboard", NULL);
2695 gnc_plugin_page_register2_cmd_copy (GtkAction *action,
2700 GtkWidget *window, *widget;
2702 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2704 ENTER(
"(action %p, page %p)", action, page);
2705 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2706 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2709 widget = gtk_window_get_focus (GTK_WINDOW (window));
2711 DEBUG(
"(widget name is %s)", gtk_widget_get_name (widget));
2713 if (GTK_IS_ENTRY(widget))
2714 g_signal_emit_by_name (widget,
"copy-clipboard", NULL);
2720 gnc_plugin_page_register2_cmd_paste (GtkAction *action,
2725 GtkWidget *window, *widget;
2727 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2729 ENTER(
"(action %p, page %p)", action, page);
2730 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2731 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2734 widget = gtk_window_get_focus (GTK_WINDOW (window));
2736 DEBUG(
"(widget name is %s)", gtk_widget_get_name (widget));
2738 if (GTK_IS_ENTRY(widget))
2739 g_signal_emit_by_name (widget,
"paste-clipboard", NULL);
2745 gnc_plugin_page_register2_cmd_edit_account (GtkAction *action,
2750 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
2752 ENTER(
"(action %p, page %p)", action, page);
2760 gnc_plugin_page_register2_cmd_find_transactions (GtkAction *action,
2765 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
2767 ENTER(
"(action %p, page %p)", action, page);
2768 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
2770 gnc_ui_find_transactions_dialog_create2 (priv->ledger);
2775 gnc_plugin_page_register2_cmd_cut_transaction (GtkAction *action,
2781 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
2783 ENTER(
"(action %p, page %p)", action, page);
2784 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
2785 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2786 gnc_tree_control_split_reg_cut_trans (view);
2792 gnc_plugin_page_register2_cmd_copy_transaction (GtkAction *action,
2798 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
2800 ENTER(
"(action %p, page %p)", action, page);
2801 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
2802 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2803 gnc_tree_control_split_reg_copy_trans (view);
2808 gnc_plugin_page_register2_cmd_paste_transaction (GtkAction *action,
2814 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
2816 ENTER(
"(action %p, page %p)", action, page);
2817 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
2818 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2819 gnc_tree_control_split_reg_paste_trans (view);
2824 gnc_plugin_page_register2_cmd_void_transaction (GtkAction *action,
2828 GtkWidget *dialog, *entry;
2831 GtkBuilder *builder;
2835 ENTER(
"(action %p, page %p)", action, page);
2837 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2839 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2840 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2841 trans = gnc_tree_view_split_reg_get_current_trans (view);
2844 LEAVE(
"trans is NULL");
2849 LEAVE(
"trans has split in VREC state");
2854 gnc_error_dialog (NULL,
"%s", _(
"You cannot void a transaction with reconciled or cleared splits."));
2855 LEAVE(
"trans with reconciled splits");
2859 if (!gnc_plugin_page_register2_finish_pending (GNC_PLUGIN_PAGE (page)))
2861 LEAVE(
"finish pending");
2865 builder = gtk_builder_new();
2866 gnc_builder_add_from_file (builder ,
"gnc-plugin-page-register2.glade",
"Void Transaction");
2867 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"Void Transaction"));
2868 entry = GTK_WIDGET (gtk_builder_get_object (builder,
"reason"));
2870 result = gtk_dialog_run (GTK_DIALOG (dialog));
2871 if (result == GTK_RESPONSE_OK)
2873 reason = gtk_entry_get_text (GTK_ENTRY (entry));
2876 gnc_tree_control_split_reg_void_current_trans (view, reason);
2880 gtk_widget_destroy (dialog);
2881 g_object_unref (G_OBJECT(builder));
2886 gnc_plugin_page_register2_cmd_unvoid_transaction (GtkAction *action,
2893 ENTER(
"(action %p, page %p)", action, page);
2895 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2897 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2898 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2899 trans = gnc_tree_view_split_reg_get_current_trans (view);
2902 LEAVE(
"trans has split in VREC state");
2905 gnc_tree_control_split_reg_unvoid_current_trans (view);
2910 gnc_plugin_page_register2_cmd_reverse_transaction (GtkAction *action,
2916 ENTER(
"(action %p, page %p)", action, page);
2918 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2920 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2921 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2923 gnc_tree_control_split_reg_reverse_current (view);
2928 gnc_plugin_page_register2_cmd_entryUp (GtkAction *action,
2933 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
2935 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
2936 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
2937 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2938 g_return_if_fail(view);
2939 gnc_tree_control_split_reg_move_current_entry_updown(view, TRUE);
2944 gnc_plugin_page_register2_cmd_entryDown (GtkAction *action,
2949 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
2951 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
2952 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
2953 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
2954 g_return_if_fail(view);
2955 gnc_tree_control_split_reg_move_current_entry_updown(view, FALSE);
2964 gnc_plugin_page_register2_cmd_view_filter_by (GtkAction *action,
2968 GNCLedgerDisplay2Type ledger_type;
2969 GtkWidget *dialog, *toggle, *button, *start_date, *end_date, *
table, *hbox;
2970 time64 start_time, end_time, time_val;
2971 GtkBuilder *builder;
2972 gboolean sensitive, value;
2978 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
2979 ENTER(
"(action %p, page %p)", action, page);
2981 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
2982 if (priv->fd.dialog)
2984 gtk_window_present (GTK_WINDOW (priv->fd.dialog));
2985 LEAVE(
"existing dialog");
2990 builder = gtk_builder_new();
2991 gnc_builder_add_from_file (builder,
"gnc-plugin-page-register2.glade",
"Filter By");
2992 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"Filter By"));
2993 priv->fd.dialog = dialog;
2994 gtk_window_set_transient_for (GTK_WINDOW (dialog),
2995 gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window)));
2998 title = g_strdup_printf (_(
"Filter %s by..."),
3000 gtk_window_set_title (GTK_WINDOW (dialog), title);
3004 for (i = 0; status_actions[i].action_name; i++)
3006 toggle = GTK_WIDGET (gtk_builder_get_object (builder, status_actions[i].action_name));
3007 value = priv->fd.cleared_match & status_actions[i].value;
3008 status_actions[i].widget = toggle;
3009 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), value);
3011 priv->fd.original_cleared_match = priv->fd.cleared_match;
3013 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_save"));
3014 if (priv->fd.save_filter == TRUE)
3015 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
3018 ledger_type = gnc_ledger_display2_type (priv->ledger);
3019 if (ledger_type == LD2_GL)
3020 gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
3023 button = GTK_WIDGET (gtk_builder_get_object (builder,
"filter_show_range"));
3024 query = gnc_ledger_display2_get_query (priv->ledger);
3025 xaccQueryGetDateMatchTT (query, &start_time, &end_time);
3026 priv->fd.original_start_time = start_time;
3027 priv->fd.start_time = start_time;
3028 priv->fd.original_end_time = end_time;
3029 priv->fd.end_time = end_time;
3031 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), start_time || end_time);
3032 table = GTK_WIDGET (gtk_builder_get_object (builder,
"select_range_table"));
3033 priv->fd.table = table;
3034 gtk_widget_set_sensitive (GTK_WIDGET (table), start_time || end_time);
3036 priv->fd.start_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_choose"));
3037 priv->fd.start_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_today"));
3038 priv->fd.end_date_choose = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_choose"));
3039 priv->fd.end_date_today = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_today"));
3043 if (start_time == 0)
3045 button = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_earliest"));
3046 time_val = xaccQueryGetEarliestDateFound (query);
3051 time_val = start_time;
3055 button = priv->fd.start_date_today;
3060 button = priv->fd.start_date_choose;
3064 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
3065 priv->fd.start_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
3066 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"start_date_hbox"));
3067 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.start_date, TRUE, TRUE, 0);
3068 gtk_widget_show (priv->fd.start_date);
3069 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.start_date), sensitive);
3070 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.start_date), time_val);
3071 g_signal_connect (G_OBJECT (priv->fd.start_date),
"date-changed",
3072 G_CALLBACK (gnc_plugin_page_register2_filter_gde_changed_cb),
3080 button = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_latest"));
3081 time_val = xaccQueryGetLatestDateFound (query);
3086 time_val = end_time;
3090 button = priv->fd.end_date_today;
3095 button = priv->fd.end_date_choose;
3099 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
3100 priv->fd.end_date = gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE);
3101 hbox = GTK_WIDGET (gtk_builder_get_object (builder,
"end_date_hbox"));
3102 gtk_box_pack_start (GTK_BOX (hbox), priv->fd.end_date, TRUE, TRUE, 0);
3103 gtk_widget_show (priv->fd.end_date);
3104 gtk_widget_set_sensitive (GTK_WIDGET (priv->fd.end_date), sensitive);
3105 gnc_date_edit_set_time (GNC_DATE_EDIT (priv->fd.end_date), time_val);
3106 g_signal_connect (G_OBJECT (priv->fd.end_date),
"date-changed",
3107 G_CALLBACK (gnc_plugin_page_register2_filter_gde_changed_cb),
3112 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, page);
3115 gtk_widget_show_all (dialog);
3116 g_object_unref (G_OBJECT (builder));
3129 ENTER(
"(action %p, page %p)", action, plugin_page);
3131 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3133 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3135 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3137 trans = gnc_tree_view_split_reg_get_current_trans (view);
3140 if (gnc_tree_control_split_reg_trans_open_and_warn (view, trans))
3142 LEAVE(
"trans being edited");
3147 while (gtk_events_pending ())
3148 gtk_main_iteration ();
3150 gnc_ledger_display2_refresh (priv->ledger);
3159 gnc_plugin_page_register2_cmd_style_changed (GtkAction *action,
3160 GtkRadioAction *current,
3164 SplitRegisterStyle2 value;
3166 ENTER(
"(action %p, radio action %p, plugin_page %p)",
3167 action, current, plugin_page);
3169 g_return_if_fail (GTK_IS_ACTION (action));
3170 g_return_if_fail (GTK_IS_RADIO_ACTION (current));
3171 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3173 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3174 value = gtk_radio_action_get_current_value (current);
3175 gnc_split_reg2_change_style (priv->gsr, value);
3177 gnc_plugin_page_register2_ui_update (NULL, plugin_page);
3182 gnc_plugin_page_register2_cmd_style_double_line (GtkToggleAction *action,
3188 gboolean use_double_line;
3190 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3192 g_return_if_fail (GTK_IS_ACTION (action));
3193 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3195 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3196 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
3198 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3200 use_double_line = gtk_toggle_action_get_active (action);
3203 gnc_tree_model_split_reg_config (model, model->
type, model->
style, use_double_line);
3206 gnc_tree_view_split_reg_set_format (view);
3207 gnc_ledger_display2_refresh (priv->ledger);
3213 gnc_plugin_page_register2_cmd_style_extra_dates (GtkToggleAction *action,
3219 gboolean show_extra_dates;
3221 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3223 g_return_if_fail (GTK_IS_ACTION (action));
3224 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3226 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3227 model = gnc_ledger_display2_get_split_model_register (priv->ledger);
3229 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3231 show_extra_dates = gtk_toggle_action_get_active (action);
3232 if (show_extra_dates != view->show_extra_dates)
3234 view->show_extra_dates = show_extra_dates;
3235 gnc_ledger_display2_refresh (priv->ledger);
3241 gnc_plugin_page_register2_cmd_transfer (GtkAction *action,
3245 GncWindow *gnc_window;
3248 ENTER(
"(action %p, plugin_page %p)", action, page);
3250 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
3253 gnc_window = GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window);
3254 window = GTK_WIDGET (gnc_window_get_gtk_window (gnc_window));
3255 gnc_xfer_dialog (window, account);
3260 gnc_plugin_page_register2_cmd_reconcile (GtkAction *action,
3270 ENTER(
"(action %p, plugin_page %p)", action, page);
3272 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
3274 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
3275 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3279 trans = gnc_tree_view_split_reg_get_current_trans (view);
3282 if (gnc_tree_control_split_reg_trans_open_and_warn (view, trans))
3284 LEAVE(
"trans being edited");
3288 window = gnc_window_get_gtk_window (GNC_WINDOW (GNC_PLUGIN_PAGE (page)->window));
3289 recnData = recnWindow2 (GTK_WIDGET (window), account);
3290 gnc_ui_reconcile_window2_raise (recnData);
3295 gnc_plugin_page_register2_cmd_autoclear (GtkAction *action,
3302 ENTER(
"(action %p, plugin_page %p)", action, page);
3304 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
3308 window = gnc_window_get_gtk_window(GNC_WINDOW(GNC_PLUGIN_PAGE (page)->window));
3309 autoClearData = autoClearWindow (GTK_WIDGET(window), account);
3310 gnc_ui_autoclear_window_raise (autoClearData);
3315 gnc_plugin_page_register2_cmd_stock_split (GtkAction *action,
3320 ENTER(
"(action %p, plugin_page %p)", action, page);
3322 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
3325 gnc_stock_split_dialog (NULL, account);
3330 gnc_plugin_page_register2_cmd_lots (GtkAction *action,
3335 ENTER(
"(action %p, plugin_page %p)", action, page);
3337 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
3340 gnc_lot_viewer_dialog (account);
3345 gnc_plugin_page_register2_cmd_enter_transaction (GtkAction *action,
3351 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3353 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3355 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3356 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3357 gnc_tree_control_split_reg_enter (view);
3362 gnc_plugin_page_register2_cmd_cancel_transaction (GtkAction *action,
3368 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3370 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3372 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3373 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3374 gnc_tree_control_split_reg_cancel_edit (view, FALSE);
3379 gnc_plugin_page_register2_cmd_delete_transaction (GtkAction *action,
3385 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3387 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3389 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3390 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3391 gnc_tree_control_split_reg_delete (view, NULL);
3397 gnc_plugin_page_register2_cmd_blank_transaction (GtkAction *action,
3403 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3405 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3407 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3408 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3409 gnc_tree_control_split_reg_jump_to_blank (view);
3414 gnc_plugin_page_register2_cmd_duplicate_transaction (GtkAction *action,
3420 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3422 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3424 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3425 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3426 gnc_tree_control_split_reg_duplicate_current (view);
3431 gnc_plugin_page_register2_cmd_reinitialize_transaction (GtkAction *action,
3437 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3439 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3441 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3442 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3443 gnc_tree_control_split_reg_reinit (view, NULL);
3448 gnc_plugin_page_register2_cmd_expand_transaction (GtkToggleAction *action,
3455 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3457 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3459 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3460 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3461 expand = gtk_toggle_action_get_active (action);
3463 gnc_tree_view_split_reg_expand_trans (view, NULL);
3465 gnc_tree_view_split_reg_collapse_trans (view, NULL);
3470 gnc_plugin_page_register2_cmd_exchange_rate (GtkAction *action,
3476 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3478 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3480 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3481 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3482 gnc_tree_control_split_reg_exchange_rate (view);
3487 gnc_plugin_page_register2_cmd_jump (GtkAction *action,
3502 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3504 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3506 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3507 window = GNC_PLUGIN_PAGE (plugin_page)->window;
3514 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3515 split = gnc_tree_view_split_reg_get_current_split (view);
3518 split = gnc_tree_control_split_reg_get_current_trans_split (view);
3521 LEAVE(
"split is NULL");
3526 if (!gnc_tree_view_split_reg_trans_expanded (view, NULL))
3531 LEAVE(
"more than 2 splits");
3536 depth = gnc_tree_view_reg_get_selected_row_depth (view);
3537 if (gnc_tree_view_split_reg_trans_expanded (view, NULL) && depth != SPLIT3)
3539 LEAVE(
"expanded but no split selected");
3544 if (account == NULL)
3546 LEAVE(
"account is NULL");
3550 leader = gnc_ledger_display2_leader (priv->ledger);
3551 if (account == leader)
3556 LEAVE(
"no other split");
3561 if (account == NULL)
3563 LEAVE(
"no other account");
3567 if (account == leader)
3569 LEAVE(
"register open for account");
3575 if (new_page == NULL)
3577 LEAVE(
"couldn't create new page");
3584 new_view = gnc_ledger_display2_get_split_view_register (ld);
3585 new_model = gnc_ledger_display2_get_split_model_register (ld);
3589 if (!gnc_tree_model_split_reg_trans_is_in_view (new_model,
xaccSplitGetParent (split)))
3590 g_signal_emit_by_name (new_model,
"refresh_trans");
3592 gnc_tree_control_split_reg_jump_to (new_view, NULL, split, FALSE);
3603 gnc_plugin_page_register2_cmd_schedule (GtkAction *action,
3610 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3612 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
3614 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
3615 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3617 trans = gnc_tree_view_split_reg_get_current_trans (view);
3621 LEAVE(
"trans is NULL");
3626 if (trans == gnc_tree_control_split_reg_get_blank_trans (view))
3628 LEAVE(
"Asked to schedule a blank trans");
3633 if (gnc_tree_control_split_reg_trans_test_for_edit (view, trans))
3635 LEAVE(
"trans being edited in another register");
3640 if (gnc_tree_control_split_reg_trans_open_and_warn (view, trans))
3642 LEAVE(
"trans being edited");
3653 "from-sched-xaction", &fromSXId,
3657 for ( sxElts = gnc_book_get_schedxactions (gnc_get_current_book())->sx_list;
3659 sxElts = sxElts->next )
3669 gnc_ui_scheduled_xaction_editor_dialog_create2 (theSX, FALSE);
3674 gnc_sx_create_from_trans (trans);
3679 gnc_plugin_page_register2_cmd_scrub_current (GtkAction *action,
3688 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3690 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3692 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3693 query = gnc_ledger_display2_get_query (priv->ledger);
3696 LEAVE(
"no query found");
3700 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3701 trans = gnc_tree_view_split_reg_get_current_trans (view);
3704 LEAVE(
"no trans found");
3708 gnc_suspend_gui_refresh();
3709 root = gnc_get_current_root_account ();
3712 gnc_resume_gui_refresh ();
3717 gnc_plugin_page_register2_cmd_scrub_all (GtkAction *action,
3727 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
3729 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3731 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
3732 query = gnc_ledger_display2_get_query( priv->ledger );
3735 LEAVE(
"no query found");
3739 gnc_suspend_gui_refresh();
3740 root = gnc_get_current_root_account();
3751 gnc_resume_gui_refresh();
3756 gnc_plugin_page_register2_cmd_account_report (GtkAction *action,
3763 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3765 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
3767 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
3768 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
3769 id = report_helper (priv->ledger, NULL, NULL);
3771 gnc_main_window_open_report(
id, window);
3776 gnc_plugin_page_register2_cmd_transaction_report (GtkAction *action,
3786 ENTER(
"(action %p, plugin_page %p)", action, plugin_page);
3788 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
3790 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
3791 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3793 split = gnc_tree_view_split_reg_get_current_split (view);
3796 LEAVE(
"split is NULL");
3800 query = qof_query_create_for(GNC_ID_SPLIT);
3805 GNC_ID_SPLIT, QOF_QUERY_AND);
3807 window = GNC_MAIN_WINDOW(GNC_PLUGIN_PAGE(plugin_page)->window);
3808 id = report_helper (priv->ledger, split, query);
3810 gnc_main_window_open_report(
id, window);
3829 g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
3831 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
3832 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
3833 priv->lines_default = lines_default;
3834 priv->read_only = read_only;
3843 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page), NULL);
3845 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
3846 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
3858 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page), NULL);
3860 page = GNC_PLUGIN_PAGE_REGISTER2 (plugin_page);
3861 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
3863 return priv->ledger;
3873 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (register_page));
3875 window = GNC_WINDOW (GNC_PLUGIN_PAGE (register_page)->window);
3883 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (register_page);
3884 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3885 help = g_strdup (view->help_text);
3886 gnc_window_set_status (window, GNC_PLUGIN_PAGE (register_page), help);
3891 gnc_plugin_page_register2_refresh_cb (GHashTable *changes, gpointer user_data)
3897 g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
3898 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (page);
3899 view = gnc_ledger_display2_get_split_view_register (priv->ledger);
3905 ei = gnc_gui_get_entity_events (changes, &priv->key);
3908 if (ei->event_mask & QOF_EVENT_DESTROY)
3914 g_object_set (G_OBJECT (view),
"state-section", NULL, NULL);
3918 if (ei->event_mask & QOF_EVENT_MODIFY)
3926 gnc_tree_view_split_reg_refresh_from_prefs (view);
3928 gnc_plugin_page_register2_ui_update (NULL, page);
3932 gnc_plugin_page_register2_close_cb (gpointer user_data)
3947 gppr_account_destroy_cb (
Account *account)
3951 GNCLedgerDisplay2Type ledger_type;
3954 GList *item, *kill = NULL;
3961 for ( ; citem; citem = g_list_next(citem))
3964 priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
3965 ledger_type = gnc_ledger_display2_type (priv->ledger);
3966 if (ledger_type == LD2_GL)
3968 kill = g_list_append(kill, page);
3971 else if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
3973 if (guid_compare(acct_guid, &priv->key) == 0)
3975 kill = g_list_append(kill, page);
3981 for (item = kill; item; item = g_list_next(item))
4003 gnc_plugin_page_register2_event_handler (
QofInstance *entity,
4012 gchar *label, *color;
4014 g_return_if_fail(page);
4015 if (!GNC_IS_TRANS(entity) && !GNC_IS_ACCOUNT(entity))
4018 ENTER(
"entity %p of type %d, page %p, event data %p",
4019 entity, event_type, page, ed);
4023 if (GNC_IS_ACCOUNT(entity))
4025 if (GNC_IS_MAIN_WINDOW(window))
4027 label = gnc_plugin_page_register2_get_tab_name(GNC_PLUGIN_PAGE(page));
4029 color = gnc_plugin_page_register2_get_tab_color(GNC_PLUGIN_PAGE(page));
4034 LEAVE(
"tab name updated");
4038 if (!(event_type & (QOF_EVENT_MODIFY | QOF_EVENT_DESTROY)))
4040 LEAVE(
"not a modify");
4043 trans = GNC_TRANS(entity);
4047 LEAVE(
"not in this book");
4051 if (GNC_IS_MAIN_WINDOW(window))
4054 if (visible_page != GNC_PLUGIN_PAGE(page))
4056 LEAVE(
"page not visible");
4061 gnc_plugin_page_register2_ui_update(NULL, page);
void gnc_plugin_page_register2_filter_status_one_cb(GtkToggleButton *button, GncPluginPageRegister2 *page)
GNCLedgerDisplay2 * gnc_plugin_page_register2_get_ledger(GncPluginPage *plugin_page)
void xaccAccountSetFilter(Account *acc, const char *str)
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
gboolean xaccTransHasReconciledSplits(const Transaction *trans)
time64 gnc_time64_get_today_start(void)
void gnc_plugin_page_register2_set_options(GncPluginPage *plugin_page, gint lines_default, gboolean read_only)
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
gboolean gnc_main_window_button_press_cb(GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
Date and Time handling routines.
GType gnc_plugin_page_register2_get_type(void)
gulong gnc_prefs_register_cb(const char *group, const gchar *pref_name, gpointer func, gpointer user_data)
Dialog for create/edit an account.
QofBook * qof_instance_get_book(gconstpointer)
void(* update_edit_menu_actions)(GncPluginPage *plugin_page, gboolean hide)
time64 gnc_time64_get_today_end(void)
utility functions for the GnuCash UI
#define PINFO(format, args...)
const char * xaccAccountGetFilter(const Account *acc)
void qof_query_purge_terms(QofQuery *q, QofQueryParamList *param_list)
common utilities for manipulating a GtkTreeView within gnucash
#define DEBUG(format, args...)
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Functions that are supported by all types of windows.
void(* QofEventHandler)(QofInstance *ent, QofEventId event_type, gpointer handler_data, gpointer event_data)
Handler invoked when an event is generated.
void gnc_plugin_page_register2_filter_start_cb(GtkWidget *radio, GncPluginPageRegister2 *page)
void gnc_plugin_page_register2_filter_save_cb(GtkToggleButton *button, GncPluginPageRegister2 *page)
GncPluginPage * gnc_plugin_page_register2_new(Account *account, gboolean subaccounts)
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
Transaction * xaccSplitGetParent(const Split *split)
GncPluginPage * gnc_plugin_page_register2_new_gl(void)
void gnc_plugin_page_register2_filter_end_cb(GtkWidget *radio, GncPluginPageRegister2 *page)
GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
#define ENTER(format, args...)
struct _QofQuery QofQuery
GncPluginPage * gnc_main_window_get_current_page(GncMainWindow *window)
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
void gnc_ui_edit_account_window(Account *account)
Functions for adding content to a window.
gboolean(* finish_pending)(GncPluginPage *plugin_page)
gint qof_event_register_handler(QofEventHandler handler, gpointer handler_data)
Register a handler for events.
Transaction * current_trans
void gnc_tm_free(struct tm *time)
free a struct tm* created with gnc_localtime() or gnc_gmtime()
void gnc_plugin_page_register2_filter_status_all_cb(GtkButton *button, GncPluginPageRegister2 *plugin_page)
const char * xaccAccountGetColor(const Account *acc)
GNCSplitReg2 * gnc_plugin_page_register2_get_gsr(GncPluginPage *plugin_page)
int xaccTransCountSplits(const Transaction *trans)
#define xaccAccountGetGUID(X)
convert single-entry accounts to clean double-entry
gboolean xaccTransHasSplitsInState(const Transaction *trans, const char state)
QofBook * qof_session_get_book(const QofSession *session)
gchar * gnc_account_get_full_name(const Account *account)
Functions providing a register page for the GnuCash UI.
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
void gnc_plugin_page_set_use_new_window(GncPluginPage *page, gboolean use_new)
GncPluginPage * gnc_plugin_page_register2_new_ledger(GNCLedgerDisplay2 *ledger)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Account * gnc_plugin_page_register2_get_account(GncPluginPageRegister2 *page)
void(* destroy_widget)(GncPluginPage *plugin_page)
void xaccTransScrubImbalance(Transaction *trans, Account *root, Account *account)
time64 gnc_time64_get_day_end(time64 time_val)
void qof_query_set_book(QofQuery *q, QofBook *book)
gboolean gnc_plugin_page_has_book(GncPluginPage *page, QofBook *book)
SplitRegisterStyle2 style
Anchor Scheduled Transaction info in a book. See src/doc/books.txt for design overview.
const gchar * plugin_name
void qof_event_unregister_handler(gint handler_id)
Unregister an event handler.
Account * gnc_account_lookup_by_full_name(const Account *any_acc, const gchar *name)
time64 gnc_mktime(struct tm *time)
calculate seconds from the epoch given a time struct
void xaccTransScrubOrphans(Transaction *trans)
Gnome specific utility functions.
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.
#define xaccSchedXactionGetGUID(X)
All type declarations for the whole Gnucash engine.
void(* window_changed)(GncPluginPage *plugin_page, GtkWidget *window)
Generic api to store and retrieve preferences.
void gnc_plugin_page_register2_filter_select_range_cb(GtkRadioButton *button, GncPluginPageRegister2 *page)
time64 gnc_time64_get_day_start(time64 time_val)
GList * qof_query_run(QofQuery *query)
gboolean qof_book_is_readonly(const QofBook *book)
GtkAction * gnc_plugin_page_get_action(GncPluginPage *page, const gchar *name)
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
Account * xaccSplitGetAccount(const Split *s)
const GncGUID * guid_null(void)
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
void gnc_main_window_close_page(GncPluginPage *page)
Split * xaccSplitGetOtherSplit(const Split *split)
#define LEAVE(format, args...)
void gnc_plugin_page_register2_filter_response_cb(GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page)
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
time64 gnc_time(time64 *tbuf)
get the current local time
Account * gnc_plugin_page_register_get_account(GncPluginPageRegister *page)
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
GtkActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
const char * xaccAccountGetName(const Account *acc)
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
GList * qof_query_get_books(QofQuery *q)
const gchar * QofLogModule
void gnc_prefs_remove_cb_by_func(const gchar *group, const gchar *pref_name, gpointer func, gpointer user_data)