39 #include <glib/gi18n.h> 47 #include "dialog-sx-editor.h" 48 #include "dialog-utils.h" 49 #include "gnc-component-manager.h" 51 #include "gnc-date-edit.h" 52 #include "gnc-dense-cal.h" 53 #include "gnc-dense-cal-store.h" 56 #include "gnc-frequency.h" 57 #include "gnc-gui-query.h" 58 #include "gnc-hooks.h" 66 #include "gnc-session.h" 69 #include "gnc-split-reg.h" 72 #include "dialog-sx-since-last-run.h" 75 #define G_LOG_DOMAIN "gnc.gui.sx.editor" 77 static QofLogModule log_module = GNC_MOD_GUI_SX;
79 static gint _sx_engine_event_handler_id = -1;
81 #define END_NEVER_OPTION 0 82 #define END_DATE_OPTION 1 83 #define NUM_OCCUR_OPTION 2 85 #define NUM_LEDGER_LINES_DEFAULT 6 87 #define EX_CAL_NUM_MONTHS 12 88 #define EX_CAL_MO_PER_COL 3 90 #define GNC_D_WIDTH 25 91 #define GNC_D_BUF_WIDTH 26 95 typedef enum _EndTypeEnum
106 GtkNotebook *notebook;
112 GNCLedgerDisplay *ledger;
115 GncDenseCalStore *dense_cal_model;
116 GncDenseCal *example_cal;
120 GtkLabel *lastOccurLabel;
122 GtkToggleButton *enabledOpt;
123 GtkToggleButton *autocreateOpt;
124 GtkToggleButton *notifyOpt;
125 GtkToggleButton *advanceOpt;
126 GtkSpinButton *advanceSpin;
127 GtkToggleButton *remindOpt;
128 GtkSpinButton *remindSpin;
130 GtkToggleButton *optEndDate;
131 GtkToggleButton *optEndNone;
132 GtkToggleButton *optEndCount;
134 GtkEntry *endCountSpin;
135 GtkEntry *endRemainSpin;
140 GncEmbeddedWindow *embed_window;
146 static void schedXact_editor_create_freq_sel (GncSxEditorDialog *sxed);
147 static void schedXact_editor_create_ledger (GncSxEditorDialog *sxed);
148 static void schedXact_editor_populate (GncSxEditorDialog *);
149 static void endgroup_rb_toggled_cb (GtkButton *b, gpointer d);
150 static void set_endgroup_toggle_states (GncSxEditorDialog *sxed, EndType t);
151 static void advance_toggled_cb (GtkButton *b, GncSxEditorDialog *sxed);
152 static void remind_toggled_cb (GtkButton *b, GncSxEditorDialog *sxed);
153 static gboolean gnc_sxed_check_consistent (GncSxEditorDialog *sxed);
154 static gboolean gnc_sxed_check_changed (GncSxEditorDialog *sxed);
155 static void gnc_sxed_save_sx (GncSxEditorDialog *sxed);
156 static void gnc_sxed_freq_changed (
GncFrequency *gf, gpointer ud);
157 static void sxed_excal_update_adapt_cb (GtkWidget *o, gpointer ud);
158 static void gnc_sxed_update_cal (GncSxEditorDialog *sxed);
159 void on_sx_check_toggled_cb (GtkWidget *togglebutton, gpointer user_data);
160 static void gnc_sxed_reg_check_close (GncSxEditorDialog *sxed);
161 static gboolean sxed_delete_event (GtkWidget *widget, GdkEvent *event, gpointer ud);
162 static gboolean sxed_confirmed_cancel (GncSxEditorDialog *sxed);
163 static gboolean editor_component_sx_equality (gpointer
find_data,
166 static GActionEntry gnc_sxed_menu_entries [] =
168 {
"EditAction", NULL, NULL, NULL, NULL },
169 {
"TransactionAction", NULL, NULL, NULL, NULL },
170 {
"ViewAction", NULL, NULL, NULL, NULL },
171 {
"ActionsAction", NULL, NULL, NULL, NULL },
173 static guint gnc_sxed_menu_n_entries = G_N_ELEMENTS(gnc_sxed_menu_entries);
178 sxed_close_handler (gpointer user_data)
180 GncSxEditorDialog *sxed = user_data;
182 gnc_sxed_reg_check_close (sxed);
183 gnc_save_window_size (GNC_PREFS_GROUP_SXED, GTK_WINDOW (sxed->dialog));
184 gtk_widget_destroy (sxed->dialog);
194 sxed_confirmed_cancel (GncSxEditorDialog *sxed)
200 if (gnc_sxed_check_changed (sxed))
202 const char *sx_changed_msg =
203 _(
"This Scheduled Transaction has changed; are you " 204 "sure you want to cancel?");
205 if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE,
"%s", sx_changed_msg))
220 editor_cancel_button_clicked_cb (GtkButton *b, GncSxEditorDialog *sxed)
223 if (!sxed_confirmed_cancel (sxed))
226 gnc_close_gui_component_by_data (DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
232 editor_help_button_clicked_cb (GtkButton *b, GncSxEditorDialog *sxed)
234 gnc_gnome_help (GTK_WINDOW (sxed->dialog), DF_MANUAL, DL_SXEDITOR);
239 editor_ok_button_clicked_cb (GtkButton *b, GncSxEditorDialog *sxed)
244 if (!gnc_sxed_check_consistent (sxed))
247 gnc_sxed_save_sx (sxed);
253 book = gnc_get_current_book ();
254 sxes = gnc_book_get_schedxactions (book);
255 gnc_sxes_add_sx (sxes, sxed->sx);
256 sxed->newsxP = FALSE;
260 gnc_close_gui_component_by_data (DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
266 gnc_sxed_check_name_changed (GncSxEditorDialog *sxed)
268 const char *name = gtk_entry_get_text (sxed->nameEntry);
270 if (!name || !name[0])
273 if (xaccSchedXactionGetName (sxed->sx) == NULL ||
274 strcmp (xaccSchedXactionGetName (sxed->sx), name) != 0)
281 gnc_sxed_check_end_date_changed (GncSxEditorDialog *sxed)
283 GDate sxEndDate, dlgEndDate;
285 if (!xaccSchedXactionHasEndDate (sxed->sx))
290 gnc_date_edit_get_date (sxed-> endDateEntry));
292 if (g_date_compare (&sxEndDate, &dlgEndDate) != 0)
299 gnc_sxed_check_num_occurs_changed (GncSxEditorDialog *sxed)
301 gint sxNumOccur, sxNumRem, dlgNumOccur, dlgNumRem;
303 if (!xaccSchedXactionGetNumOccur (sxed->sx))
306 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endCountSpin));
308 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endRemainSpin));
309 sxNumOccur = xaccSchedXactionGetNumOccur (sxed->sx);
310 sxNumRem = xaccSchedXactionGetRemOccur (sxed->sx);
312 if (dlgNumOccur != sxNumOccur || dlgNumRem != sxNumRem)
319 gnc_sxed_check_creation_changed (GncSxEditorDialog *sxed)
321 gboolean sxAutoCreate, sxNotify;
325 gboolean dlgEnabled =
326 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sxed->enabledOpt));
327 gboolean dlgAutoCreate =
328 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sxed->autocreateOpt));
330 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sxed->notifyOpt));
332 if (dlgEnabled != xaccSchedXactionGetEnabled (sxed->sx))
335 xaccSchedXactionGetAutoCreate (sxed->sx, &sxAutoCreate, &sxNotify);
336 if (dlgAutoCreate != sxAutoCreate || dlgNotify != sxNotify)
339 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sxed->advanceOpt)))
340 dlgAdvance = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->advanceSpin));
341 if (dlgAdvance != xaccSchedXactionGetAdvanceCreation (sxed->sx))
344 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sxed->remindOpt)))
345 dlgRemind = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->remindSpin));
346 if (dlgRemind != xaccSchedXactionGetAdvanceReminder (sxed->sx))
353 gnc_sxed_check_dates_changed (GncSxEditorDialog *sxed)
355 GList *dialog_schedule = NULL;
356 GDate dialog_start_date, sx_start_date;
357 gchar *dialog_schedule_str, *sx_schedule_str;
358 gboolean schedules_are_the_same, start_dates_are_the_same;
360 g_date_clear (&dialog_start_date, 1);
361 gnc_frequency_save_to_recurrence (sxed->gncfreq, &dialog_schedule,
363 dialog_schedule_str = recurrenceListToString (dialog_schedule);
364 recurrenceListFree (&dialog_schedule);
366 sx_start_date = *xaccSchedXactionGetStartDate (sxed->sx);
369 DEBUG (
"dialog schedule [%s], sx schedule [%s]",
370 dialog_schedule_str, sx_schedule_str);
372 schedules_are_the_same = (strcmp (dialog_schedule_str,
373 sx_schedule_str) == 0);
374 g_free (dialog_schedule_str);
375 g_free (sx_schedule_str);
377 start_dates_are_the_same = (g_date_compare (&dialog_start_date,
378 &sx_start_date) == 0);
380 if (schedules_are_the_same && start_dates_are_the_same)
392 gnc_sxed_check_changed (GncSxEditorDialog *sxed)
394 SplitRegister *sr = NULL;
399 if (gnc_sxed_check_name_changed (sxed))
403 if (gtk_toggle_button_get_active (sxed->optEndNone) &&
404 (xaccSchedXactionHasEndDate (sxed->sx) ||
409 if (gtk_toggle_button_get_active (sxed->optEndDate) &&
410 gnc_sxed_check_end_date_changed (sxed))
414 if (gtk_toggle_button_get_active (sxed->optEndCount) &&
415 gnc_sxed_check_num_occurs_changed (sxed))
418 if (gnc_sxed_check_creation_changed (sxed))
421 if (gnc_sxed_check_dates_changed (sxed))
437 typedef struct _txnCreditDebitSums
439 gnc_numeric creditSum;
440 gnc_numeric debitSum;
447 tcds->creditSum = tcds->debitSum = gnc_numeric_zero ();
452 set_sums_to_zero (gpointer key,
457 tcds->creditSum = gnc_numeric_zero ();
458 tcds->debitSum = gnc_numeric_zero ();
461 inline static gnc_numeric
464 return gnc_numeric_sub_fixed (tcds->debitSum, tcds->creditSum);
468 check_credit_debit_balance (gpointer key, gpointer val, gpointer ud)
471 gboolean *unbalanced = (gboolean*)ud;
472 gnc_numeric diff = tcds_difference (tcds);
476 DEBUG (
"%p | %s [%s - %s = %s]", key, result,
483 gnc_sxed_check_names (GncSxEditorDialog *sxed)
485 const gchar *name = gtk_entry_get_text (sxed->nameEntry);
486 if (!name || !name[0])
488 const char *sx_has_no_name_msg =
489 _(
"Please name the Scheduled Transaction.");
490 gnc_error_dialog (GTK_WINDOW (sxed->dialog),
"%s", sx_has_no_name_msg);
495 bool nameExists = FALSE;
496 gchar *nameKey = g_utf8_collate_key (name, -1);
497 bool nameHasChanged =
498 (xaccSchedXactionGetName (sxed->sx) == NULL)
499 || (strcmp (xaccSchedXactionGetName (sxed->sx), name) != 0);
500 for (GList *sxList = gnc_book_get_schedxactions (gnc_get_current_book ())->sx_list;
501 nameHasChanged && !nameExists && sxList;
502 sxList = sxList->next)
504 const char *existingName = xaccSchedXactionGetName ((SchedXaction*)sxList->data);
505 char *existingNameKey = g_utf8_collate_key (existingName, -1);
506 nameExists |= (strcmp (nameKey, existingNameKey) == 0);
507 g_free (existingNameKey);
510 if (nameHasChanged && nameExists)
512 const char *sx_has_existing_name_msg =
513 _(
"A Scheduled Transaction with the name \"%s\" already exists. " 514 "Are you sure you want to name this one the same?");
515 if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE,
516 sx_has_existing_name_msg, name))
523 gnc_sxed_check_endpoint (GncSxEditorDialog *sxed)
525 GDate startDate, endDate, nextDate;
526 GList *schedule = NULL;
528 if (!gtk_toggle_button_get_active (sxed->optEndDate)
529 && !gtk_toggle_button_get_active (sxed->optEndCount)
530 && !gtk_toggle_button_get_active (sxed->optEndNone))
532 const char *sx_end_spec_msg =
533 _(
"Please provide a valid end selection.");
534 gnc_error_dialog (GTK_WINDOW (sxed->dialog),
"%s", sx_end_spec_msg);
538 if (gtk_toggle_button_get_active (sxed->optEndCount))
541 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endCountSpin));
543 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endRemainSpin));
547 const char *sx_occur_count_zero_msg =
548 _(
"There must be some number of occurrences.");
549 gnc_error_dialog (GTK_WINDOW (sxed->dialog),
"%s", sx_occur_count_zero_msg);
555 const char *sx_occur_counts_wrong_msg =
556 _(
"The number of remaining occurrences (%d) is greater than " 557 "the number of total occurrences (%d).");
558 gnc_error_dialog (GTK_WINDOW (sxed->dialog), sx_occur_counts_wrong_msg,
565 g_date_clear (&endDate, 1);
566 if (gtk_toggle_button_get_active (sxed->optEndDate))
569 gnc_date_edit_get_date (sxed-> endDateEntry));
572 g_date_clear (&nextDate, 1);
573 gnc_frequency_save_to_recurrence (sxed->gncfreq, &schedule, &startDate);
576 g_date_subtract_days (&startDate, 1);
577 recurrenceListNextInstance (schedule, &startDate, &nextDate);
579 recurrenceListFree (&schedule);
581 if (!g_date_valid (&nextDate) ||
582 (g_date_valid (&endDate) && (g_date_compare (&nextDate, &endDate) > 0)))
584 const char *invalid_sx_check_msg =
585 _(
"You have attempted to create a Scheduled Transaction which " 586 "will never run. Do you really want to do this?");
587 if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE,
588 "%s", invalid_sx_check_msg))
595 gnc_sxed_check_autocreate (GncSxEditorDialog *sxed,
int ttVarCount,
596 int splitCount, gboolean multi_commodity)
598 gboolean autocreateState;
601 gtk_toggle_button_get_active (
602 GTK_TOGGLE_BUTTON (sxed->autocreateOpt));
604 if (((ttVarCount > 0) || multi_commodity) && autocreateState)
606 gnc_warning_dialog (GTK_WINDOW (sxed->dialog),
"%s",
607 _(
"Scheduled Transactions with variables " 608 "or involving more than one commodity " 609 "cannot be automatically created."));
615 if (autocreateState && splitCount == 0)
617 gnc_warning_dialog (GTK_WINDOW (sxed->dialog),
"%s",
618 _(
"Scheduled Transactions without a template " 619 "transaction cannot be automatically created."));
626 gnc_sxed_split_check_account (GncSxEditorDialog *sxed, Split *s,
627 gnc_commodity *base_cmdty, gboolean *multi_cmdty)
629 gnc_commodity *split_cmdty = NULL;
630 gnc_numeric split_amount;
634 "sx-account", &acct_guid,
637 guid_free (acct_guid);
645 base_cmdty = split_cmdty;
653 gnc_sxed_split_calculate_formula (GncSxEditorDialog *sxed, Split *s,
654 GHashTable *vars,
const char *key,
657 gnc_numeric tmp = gnc_numeric_zero ();
668 if (gnc_sx_parse_vars_from_formula (str, vars, &tmp) < 0)
670 gchar *err = g_strdup_printf (_(
"Couldn't parse %s for split \"%s\"."),
672 gnc_error_dialog (GTK_WINDOW (sxed->dialog),
"%s", err);
678 if (g_strcmp0 (key,
"sx-credit-formula") == 0)
690 GncSxEditorDialog *sxed;
694 gboolean multi_commodity;
699 split_error_warning_dialog (GtkWidget *parent,
const gchar *title,
702 GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 0,
706 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
708 gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
709 g_signal_connect_swapped (dialog,
"response",
710 G_CALLBACK (gtk_widget_destroy), dialog);
711 gtk_dialog_run (GTK_DIALOG (dialog));
716 check_transaction_splits (Transaction *txn, gpointer data)
721 for (; splitList; splitList = splitList->next)
723 gnc_commodity *base_cmdty = NULL;
724 Split *s = (Split*)splitList->data;
726 if (sd->tcds == NULL)
728 sd->tcds = tcds_new ();
729 g_hash_table_insert (sd->txns, (gpointer)txn, (gpointer)(sd->tcds));
732 if (!gnc_sxed_split_check_account (sd->sxed, s, base_cmdty,
733 &sd->multi_commodity))
735 gchar *message = g_strdup_printf
736 (_(
"Split with memo %s has an invalid account."),
738 split_error_warning_dialog (sd->sxed->dialog,
739 _(
"Invalid Account in Split"),
746 if (!gnc_sxed_split_calculate_formula (sd->sxed, s, sd->vars,
750 gchar *message = g_strdup_printf
751 (_(
"Split with memo %s has an unparsable Credit Formula."),
753 split_error_warning_dialog (sd->sxed->dialog,
754 _(
"Unparsable Formula in Split"),
761 if (!gnc_sxed_split_calculate_formula (sd->sxed, s, sd->vars,
766 gchar *message = g_strdup_printf
767 (_(
"Split with memo %s has an unparsable Debit Formula."),
769 split_error_warning_dialog (sd->sxed->dialog,
770 _(
"Unparsable Formula in Split"),
785 gnc_sxed_check_consistent (GncSxEditorDialog *sxed)
807 gint ttVarCount = 0, splitCount = 0;
808 static const int NUM_ITERS_WITH_VARS = 5;
809 static const int NUM_ITERS_NO_VARS = 1;
810 int numIters = NUM_ITERS_NO_VARS, i;
811 gboolean unbalanceable = FALSE;
812 gpointer unusedKey, unusedValue;
814 GHashTable *vars = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
815 (GDestroyNotify)gnc_sx_variable_free);
816 GHashTable *txns = g_hash_table_new_full (g_direct_hash, g_direct_equal,
829 gnc_sxed_reg_check_close (sxed);
831 gnc_sx_get_variables (sxed->sx, vars);
833 ttVarCount = g_hash_table_size (vars);
839 numIters = NUM_ITERS_WITH_VARS;
842 for (i = 0; i < numIters && !unbalanceable; i++)
844 GList *splitList = xaccSchedXactionGetSplits (sxed->sx);
845 Account *tmpl_acct = gnc_sx_get_template_transaction_account (sxed->sx);
846 gnc_sx_randomize_variables (vars);
847 g_hash_table_foreach (txns, set_sums_to_zero, NULL);
849 splitCount += g_list_length (splitList);
850 g_list_free (splitList);
856 g_hash_table_destroy (vars);
857 g_hash_table_destroy (txns);
861 g_hash_table_foreach (txns, check_credit_debit_balance, &unbalanceable);
865 if (g_hash_table_lookup_extended (vars,
"i", &unusedKey, &unusedValue))
868 g_hash_table_destroy (vars);
869 g_hash_table_destroy (txns);
874 _(
"The Scheduled Transaction Editor cannot automatically " 875 "balance this transaction. Should it still be entered?");
876 if (!gnc_verify_dialog (GTK_WINDOW (sxed->dialog), FALSE,
"%s", msg))
880 if (!gnc_sxed_check_names (sxed))
883 if (!gnc_sxed_check_autocreate (sxed, ttVarCount,
884 splitCount, sd.multi_commodity))
887 if (!gnc_sxed_check_endpoint (sxed))
898 gnc_sxed_save_sx (GncSxEditorDialog *sxed)
900 gnc_sx_begin_edit (sxed->sx);
903 const gchar *name = gtk_entry_get_text (sxed->nameEntry);
911 if (gtk_toggle_button_get_active (sxed->optEndDate))
915 gnc_date_edit_get_date (
916 sxed->endDateEntry));
921 else if (gtk_toggle_button_get_active (sxed->optEndCount))
927 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endCountSpin));
931 gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endRemainSpin));
932 xaccSchedXactionSetRemOccur (sxed->sx, num);
934 g_date_clear (&gdate, 1);
937 else if (gtk_toggle_button_get_active (sxed->optEndNone))
940 g_date_clear (&gdate, 1);
945 g_critical (
"no valid end specified\n");
951 gboolean enabledState;
953 enabledState = gtk_toggle_button_get_active (sxed->enabledOpt);
954 xaccSchedXactionSetEnabled (sxed->sx, enabledState);
959 gboolean autocreateState, notifyState;
961 autocreateState = gtk_toggle_button_get_active (sxed->autocreateOpt);
962 notifyState = gtk_toggle_button_get_active (sxed->notifyOpt);
965 xaccSchedXactionSetAutoCreate (sxed->sx,
967 (autocreateState & notifyState));
975 if (gtk_toggle_button_get_active (sxed->advanceOpt))
978 gtk_spin_button_get_value_as_int (sxed->advanceSpin);
980 xaccSchedXactionSetAdvanceCreation (sxed->sx, daysInAdvance);
983 if (gtk_toggle_button_get_active (sxed->remindOpt))
986 gtk_spin_button_get_value_as_int (sxed->remindSpin);
988 xaccSchedXactionSetAdvanceReminder (sxed->sx, daysInAdvance);
994 GList *schedule = NULL;
996 gnc_frequency_save_to_recurrence (sxed->gncfreq, &schedule, &gdate);
999 gchar *recurrence_str = recurrenceListToCompactString (schedule);
1000 DEBUG (
"recurrences parsed [%s]", recurrence_str);
1001 g_free (recurrence_str);
1005 xaccSchedXactionSetStartDate (sxed->sx, &gdate);
1008 gnc_sx_commit_edit (sxed->sx);
1012 update_sensitivity (GncSxEditorDialog *sxed)
1014 gboolean enabled = gtk_toggle_button_get_active (sxed->enabledOpt);
1015 gboolean autocreate = gtk_toggle_button_get_active (sxed->autocreateOpt);
1016 gboolean advance = gtk_toggle_button_get_active (sxed->advanceOpt);
1017 gboolean remind = gtk_toggle_button_get_active (sxed->remindOpt);
1018 gboolean type_date = (sxed->end_type == END_DATE);
1019 gboolean type_occur = (sxed->end_type == END_OCCUR);
1021 gnc_suspend_gui_refresh ();
1023 gtk_widget_set_sensitive (GTK_WIDGET (sxed->autocreateOpt), enabled);
1024 gtk_widget_set_sensitive (GTK_WIDGET (sxed->notifyOpt), enabled && autocreate);
1026 gtk_widget_set_sensitive (GTK_WIDGET (sxed->advanceOpt), enabled);
1027 gtk_widget_set_sensitive (GTK_WIDGET (sxed->advanceSpin), enabled && advance);
1029 gtk_widget_set_sensitive (GTK_WIDGET (sxed->remindOpt), enabled);
1030 gtk_widget_set_sensitive (GTK_WIDGET (sxed->remindSpin), enabled && remind);
1032 gtk_widget_set_sensitive (GTK_WIDGET (sxed->optEndNone), enabled);
1033 gtk_widget_set_sensitive (GTK_WIDGET (sxed->optEndDate), enabled);
1034 gtk_widget_set_sensitive (GTK_WIDGET (sxed->optEndCount), enabled);
1036 gtk_widget_set_sensitive (GTK_WIDGET (sxed->endDateEntry), enabled && type_date);
1037 gtk_widget_set_sensitive (GTK_WIDGET (sxed->endCountSpin), enabled && type_occur);
1038 gtk_widget_set_sensitive (GTK_WIDGET (sxed->endRemainSpin), enabled && type_occur);
1040 gtk_widget_set_sensitive (gtk_notebook_get_nth_page (sxed->notebook, 1), enabled);
1041 gtk_widget_set_sensitive (gtk_notebook_get_nth_page (sxed->notebook, 2), enabled);
1043 gnc_resume_gui_refresh ();
1047 enabled_toggled_cb (GtkToggleButton *o, GncSxEditorDialog *sxed)
1049 update_sensitivity (sxed);
1053 autocreate_toggled_cb (GtkToggleButton *o, GncSxEditorDialog *sxed)
1055 update_sensitivity (sxed);
1059 advance_toggled_cb (GtkButton *o, GncSxEditorDialog *sxed)
1061 update_sensitivity (sxed);
1065 remind_toggled_cb (GtkButton *o, GncSxEditorDialog *sxed)
1067 update_sensitivity (sxed);
1073 scheduledxaction_editor_dialog_destroy (GtkWidget *
object, gpointer data)
1075 GncSxEditorDialog *sxed = data;
1080 gnc_unregister_gui_component_by_data
1081 (DIALOG_SCHEDXACTION_EDITOR_CM_CLASS, sxed);
1084 gtk_widget_destroy (GTK_WIDGET (sxed->embed_window));
1085 sxed->embed_window = NULL;
1086 sxed->plugin_page = NULL;
1087 sxed->ledger = NULL;
1089 g_free (sxed->sxGUIDstr);
1090 sxed->sxGUIDstr = NULL;
1102 gnc_sx_begin_edit (sxed->sx);
1113 sxed_delete_event (GtkWidget *widget, GdkEvent *event, gpointer ud)
1115 GncSxEditorDialog *sxed = (GncSxEditorDialog*)ud;
1119 if (sxed->sx == NULL)
1124 if (!sxed_confirmed_cancel (sxed))
1136 gnc_ui_scheduled_xaction_editor_dialog_create (GtkWindow *parent,
1137 SchedXaction *sx, gboolean newSX)
1139 GncSxEditorDialog *sxed;
1140 GtkBuilder *builder;
1144 GList *dlgExists = NULL;
1146 static struct widgetSignalCallback
1151 gpointer objectData;
1154 {
"ok_button",
"clicked", editor_ok_button_clicked_cb, NULL },
1155 {
"cancel_button",
"clicked", editor_cancel_button_clicked_cb, NULL },
1156 {
"help_button",
"clicked", editor_help_button_clicked_cb, NULL },
1157 {
"rb_noend",
"toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER (END_NEVER_OPTION) },
1158 {
"rb_enddate",
"toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER (END_DATE_OPTION) },
1159 {
"rb_num_occur",
"toggled", endgroup_rb_toggled_cb, GINT_TO_POINTER (NUM_OCCUR_OPTION) },
1160 {
"remain_spin" ,
"value-changed", sxed_excal_update_adapt_cb, NULL },
1161 {
"enabled_opt",
"toggled", enabled_toggled_cb, NULL },
1162 {
"autocreate_opt",
"toggled", autocreate_toggled_cb, NULL },
1163 {
"advance_opt",
"toggled", advance_toggled_cb, NULL },
1164 {
"remind_opt",
"toggled", remind_toggled_cb, NULL },
1165 { NULL, NULL, NULL, NULL }
1168 dlgExists = gnc_find_gui_components (DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
1169 editor_component_sx_equality,
1173 DEBUG (
"dialog already exists; using that one.");
1174 sxed = (GncSxEditorDialog*)dlgExists->data;
1175 gtk_window_present (GTK_WINDOW (sxed->dialog));
1176 g_list_free (dlgExists);
1180 sxed = g_new0(GncSxEditorDialog, 1);
1183 sxed->newsxP = newSX;
1186 builder = gtk_builder_new ();
1187 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"advance_days_adj");
1188 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"remind_days_adj");
1189 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"end_spin_adj");
1190 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"remain_spin_adj");
1191 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"scheduled_transaction_editor_dialog");
1193 sxed->builder = builder;
1196 sxed->dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"scheduled_transaction_editor_dialog"));
1197 sxed->notebook = GTK_NOTEBOOK (gtk_builder_get_object (builder,
"editor_notebook"));
1198 sxed->nameEntry = GTK_ENTRY (gtk_builder_get_object (builder,
"sxe_name"));
1199 sxed->enabledOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"enabled_opt"));
1200 sxed->autocreateOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"autocreate_opt"));
1201 sxed->notifyOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"notify_opt"));
1202 sxed->advanceOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"advance_opt"));
1203 sxed->advanceSpin = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
"advance_days"));
1204 sxed->remindOpt = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"remind_opt"));
1205 sxed->remindSpin = GTK_SPIN_BUTTON (gtk_builder_get_object (builder,
"remind_days"));
1206 sxed->lastOccurLabel = GTK_LABEL (gtk_builder_get_object (builder,
"last_occur_label"));
1207 sxed->optEndNone = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"rb_noend"));
1208 sxed->optEndDate = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"rb_enddate"));
1209 sxed->optEndCount = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder,
"rb_num_occur"));
1210 sxed->endCountSpin = GTK_ENTRY (gtk_builder_get_object (builder,
"end_spin"));
1211 sxed->endRemainSpin = GTK_ENTRY (gtk_builder_get_object (builder,
"remain_spin"));
1214 gtk_widget_set_name (GTK_WIDGET (sxed->dialog),
"gnc-id-sx-editor");
1215 gnc_widget_style_context_add_class (GTK_WIDGET (sxed->dialog),
"gnc-class-sx");
1217 gtk_window_set_transient_for (GTK_WINDOW (sxed->dialog), parent);
1221 GtkWidget *endDateBox = GTK_WIDGET (gtk_builder_get_object (builder,
"editor_end_date_box"));
1222 sxed->endDateEntry = GNC_DATE_EDIT (gnc_date_edit_new (
gnc_time (NULL), FALSE, FALSE));
1223 gtk_widget_show (GTK_WIDGET (sxed->endDateEntry));
1224 g_signal_connect (sxed->endDateEntry,
"date-changed",
1225 G_CALLBACK (sxed_excal_update_adapt_cb), sxed);
1226 gtk_box_pack_start (GTK_BOX (endDateBox), GTK_WIDGET (sxed->endDateEntry),
1230 id = gnc_register_gui_component (DIALOG_SCHEDXACTION_EDITOR_CM_CLASS,
1235 gnc_gui_component_set_session (
id, gnc_get_current_session ());
1237 g_signal_connect (sxed->dialog,
"delete_event",
1238 G_CALLBACK (sxed_delete_event), sxed);
1239 g_signal_connect (sxed->dialog,
"destroy",
1240 G_CALLBACK (scheduledxaction_editor_dialog_destroy),
1243 for (i = 0; widgets[i].name; i++)
1245 button = GTK_WIDGET (gtk_builder_get_object (builder, widgets[i].name));
1246 if (widgets[i].objectData)
1248 g_object_set_data (G_OBJECT (button),
"whichOneAmI",
1249 widgets[i].objectData);
1251 g_signal_connect (button, widgets[i].signal,
1252 G_CALLBACK (widgets[i].fn), sxed);
1256 gtk_widget_set_sensitive (GTK_WIDGET (sxed->notifyOpt), FALSE);
1257 gtk_widget_set_sensitive (GTK_WIDGET (sxed->advanceSpin), FALSE);
1258 gtk_widget_set_sensitive (GTK_WIDGET (sxed->remindSpin), FALSE);
1259 gtk_widget_set_sensitive (GTK_WIDGET (sxed->endCountSpin), FALSE);
1260 gtk_widget_set_sensitive (GTK_WIDGET (sxed->endRemainSpin), FALSE);
1261 gtk_editable_set_editable (GTK_EDITABLE (sxed->advanceSpin), TRUE);
1262 gtk_editable_set_editable (GTK_EDITABLE (sxed->remindSpin), TRUE);
1265 gtk_window_set_resizable (GTK_WINDOW (sxed->dialog), TRUE);
1266 gnc_restore_window_size (GNC_PREFS_GROUP_SXED, GTK_WINDOW (sxed->dialog), parent);
1269 schedXact_editor_create_freq_sel (sxed);
1272 schedXact_editor_create_ledger (sxed);
1275 schedXact_editor_populate (sxed);
1278 gtk_widget_show (sxed->dialog);
1279 gtk_notebook_set_current_page (GTK_NOTEBOOK (sxed->notebook), 0);
1282 gtk_widget_queue_resize (GTK_WIDGET (sxed->example_cal));
1287 gtk_widget_grab_focus (GTK_WIDGET (sxed->nameEntry));
1289 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, sxed);
1290 g_object_unref (G_OBJECT (builder));
1297 schedXact_editor_create_freq_sel (GncSxEditorDialog *sxed)
1300 GtkWidget *example_cal_scrolled_win = NULL;
1302 b = GTK_BOX (gtk_builder_get_object (sxed->builder,
"gncfreq_hbox"));
1306 xaccSchedXactionGetStartDate (sxed->sx)));
1307 g_assert (sxed->gncfreq);
1308 g_signal_connect (sxed->gncfreq,
"changed",
1309 G_CALLBACK (gnc_sxed_freq_changed),
1312 gtk_box_pack_start (GTK_BOX (b), GTK_WIDGET (sxed->gncfreq), TRUE, TRUE, 0);
1314 b = GTK_BOX (gtk_builder_get_object (sxed->builder,
"example_cal_hbox"));
1316 example_cal_scrolled_win = gtk_scrolled_window_new (NULL, NULL);
1317 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (example_cal_scrolled_win),
1318 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1319 gtk_box_pack_start (GTK_BOX (b), example_cal_scrolled_win, TRUE, TRUE, 0);
1321 sxed->dense_cal_model = gnc_dense_cal_store_new (EX_CAL_NUM_MONTHS * 31);
1322 sxed->example_cal = GNC_DENSE_CAL(gnc_dense_cal_new_with_model (GTK_WINDOW(sxed->dialog),
1323 GNC_DENSE_CAL_MODEL(sxed->dense_cal_model)));
1324 g_assert (sxed->example_cal);
1325 gnc_dense_cal_set_num_months (sxed->example_cal, EX_CAL_NUM_MONTHS);
1326 gnc_dense_cal_set_months_per_col (sxed->example_cal, EX_CAL_MO_PER_COL);
1327 gtk_container_add (GTK_CONTAINER (example_cal_scrolled_win), GTK_WIDGET (sxed->example_cal));
1330 gtk_widget_show_all (example_cal_scrolled_win);
1335 schedXact_editor_create_ledger (GncSxEditorDialog *sxed)
1337 SplitRegister *splitreg;
1338 GtkWidget *main_vbox;
1346 main_vbox = GTK_WIDGET (gtk_builder_get_object (sxed->builder,
"register_vbox"));
1347 sxed->embed_window =
1349 gnc_sxed_menu_entries,
1350 gnc_sxed_menu_n_entries,
1351 "gnc-embedded-register-window.ui",
1355 gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (sxed->embed_window),
1363 gtk_widget_insert_action_group (GTK_WIDGET(sxed->embed_window),
1368 NUM_LEDGER_LINES_DEFAULT, FALSE);
1374 splitreg->type, splitreg->style,
1384 schedXact_editor_populate (GncSxEditorDialog *sxed)
1388 SplitRegister *splitReg;
1391 gboolean enabledState, autoCreateState, notifyState;
1393 name = xaccSchedXactionGetName (sxed->sx);
1396 gtk_entry_set_text (sxed->nameEntry, name);
1399 gd = xaccSchedXactionGetLastOccurDate (sxed->sx);
1400 if (g_date_valid (gd))
1404 gtk_label_set_text (sxed->lastOccurLabel, dateBuf);
1408 gtk_label_set_text (sxed->lastOccurLabel, _(
"(never)"));
1414 if (g_date_valid (gd))
1416 gtk_toggle_button_set_active (sxed->optEndDate, TRUE);
1418 gnc_date_edit_set_time (sxed->endDateEntry, tmpDate);
1420 set_endgroup_toggle_states (sxed, END_DATE);
1424 gint numOccur = xaccSchedXactionGetNumOccur (sxed->sx);
1425 gint numRemain = xaccSchedXactionGetRemOccur (sxed->sx);
1427 gtk_toggle_button_set_active (sxed->optEndCount, TRUE);
1429 gtk_spin_button_set_value (GTK_SPIN_BUTTON (sxed->endCountSpin), numOccur);
1430 gtk_spin_button_set_value (GTK_SPIN_BUTTON (sxed->endRemainSpin), numRemain);
1432 set_endgroup_toggle_states (sxed, END_OCCUR);
1436 gtk_toggle_button_set_active (sxed->optEndNone, TRUE);
1437 set_endgroup_toggle_states (sxed, END_NEVER);
1440 enabledState = xaccSchedXactionGetEnabled (sxed->sx);
1441 gtk_toggle_button_set_active (sxed->enabledOpt, enabledState);
1453 xaccSchedXactionGetAutoCreate (sxed->sx,
1457 gtk_toggle_button_set_active (sxed->autocreateOpt, autoCreateState);
1458 if (!autoCreateState)
1460 notifyState = FALSE;
1462 gtk_toggle_button_set_active (sxed->notifyOpt, notifyState);
1473 xaccSchedXactionGetAdvanceCreation (sxed->sx);
1475 if (daysInAdvance != 0)
1477 gtk_toggle_button_set_active (sxed->advanceOpt, TRUE);
1478 gtk_spin_button_set_value (sxed->advanceSpin,
1479 (gfloat)daysInAdvance);
1491 xaccSchedXactionGetAdvanceReminder (sxed->sx);
1493 if (daysInAdvance != 0)
1495 gtk_toggle_button_set_active (sxed->remindOpt, TRUE);
1496 gtk_spin_button_set_value (sxed->remindSpin,
1497 (gfloat)daysInAdvance);
1508 GList *splitList = xaccSchedXactionGetSplits (sxed->sx);
1514 g_list_free (splitList);
1518 gnc_sxed_update_cal (sxed);
1523 set_endgroup_toggle_states (GncSxEditorDialog *sxed, EndType type)
1525 sxed->end_type = type;
1526 update_sensitivity (sxed);
1531 endgroup_rb_toggled_cb (GtkButton *b, gpointer d)
1534 GncSxEditorDialog *sxed;
1537 sxed = (GncSxEditorDialog*)d;
1538 id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (b),
"whichOneAmI"));
1542 case END_NEVER_OPTION:
1543 set_endgroup_toggle_states (sxed, END_NEVER);
1545 case END_DATE_OPTION:
1546 set_endgroup_toggle_states (sxed, END_DATE);
1548 case NUM_OCCUR_OPTION:
1549 set_endgroup_toggle_states (sxed, END_OCCUR);
1552 g_critical (
"Unknown id %d",
id);
1555 gnc_sxed_update_cal (sxed);
1566 gnc_sxed_reg_check_close (GncSxEditorDialog *sxed)
1568 gboolean pending_changes;
1570 const char *message =
1571 _(
"The current template transaction " 1572 "has been changed. " 1573 "Would you like to record the changes?");
1577 if (!pending_changes)
1582 if (gnc_verify_dialog (GTK_WINDOW (sxed->dialog), TRUE,
"%s", message))
1597 editor_component_sx_equality (gpointer
find_data,
1601 == ((GncSxEditorDialog*)user_data)->sx);
1605 gnc_sxed_update_cal (GncSxEditorDialog *sxed)
1607 GList *recurrences = NULL;
1608 GDate start_date, first_date;
1610 g_date_clear (&start_date, 1);
1612 gnc_frequency_save_to_recurrence (sxed->gncfreq, &recurrences, &start_date);
1613 recurrenceListNextInstance (recurrences, &start_date, &first_date);
1618 const GDate *last_sx_inst;
1620 last_sx_inst = xaccSchedXactionGetLastOccurDate (sxed->sx);
1621 if (g_date_valid (last_sx_inst)
1622 && g_date_valid (&first_date)
1623 && g_date_compare (last_sx_inst, &first_date) > 0)
1627 start_date = *last_sx_inst;
1628 recurrenceListNextInstance (recurrences, &start_date, &first_date);
1632 g_date_subtract_days (&start_date, 1);
1636 if (!g_date_valid (&first_date))
1639 gnc_dense_cal_store_clear (sxed->dense_cal_model);
1643 gnc_dense_cal_store_update_name (sxed->dense_cal_model, xaccSchedXactionGetName (sxed->sx));
1645 gchar *schedule_desc = recurrenceListToCompactString (recurrences);
1646 gnc_dense_cal_store_update_info (sxed->dense_cal_model, schedule_desc);
1647 g_free (schedule_desc);
1654 if (gtk_toggle_button_get_active (sxed->optEndDate))
1657 g_date_clear (&end_date, 1);
1659 gnc_dense_cal_store_update_recurrences_date_end (sxed->dense_cal_model, &start_date, recurrences, &end_date);
1661 else if (gtk_toggle_button_get_active (sxed->optEndNone))
1663 gnc_dense_cal_store_update_recurrences_no_end (sxed->dense_cal_model, &start_date, recurrences);
1665 else if (gtk_toggle_button_get_active (sxed->optEndCount))
1668 = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (sxed->endRemainSpin));
1669 gnc_dense_cal_store_update_recurrences_count_end (sxed->dense_cal_model, &start_date, recurrences, num_remain);
1673 g_error (
"unknown end condition");
1677 recurrenceListFree (&recurrences);
1684 gnc_sxed_update_cal ((GncSxEditorDialog*)ud);
1689 sxed_excal_update_adapt_cb (GtkWidget *o, gpointer ud)
1691 gnc_sxed_update_cal ((GncSxEditorDialog*)ud);
1696 on_sx_check_toggled_cb (GtkWidget *togglebutton, gpointer user_data)
1698 GtkWidget *widget_auto;
1699 GtkWidget *widget_notify;
1702 PINFO (
"Togglebutton is %p and user_data is %p", togglebutton, user_data);
1703 PINFO (
"Togglebutton builder name is %s", gtk_buildable_get_name (GTK_BUILDABLE (togglebutton)));
1706 table = g_object_get_data (G_OBJECT (user_data),
"prefs_widget_hash");
1709 widget_auto = g_hash_table_lookup (
table,
"pref/" GNC_PREFS_GROUP_SXED
"/" GNC_PREF_CREATE_AUTO);
1710 widget_notify = g_hash_table_lookup (
table,
"pref/" GNC_PREFS_GROUP_SXED
"/" GNC_PREF_NOTIFY);
1712 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget_auto)))
1713 gtk_widget_set_sensitive (widget_notify, TRUE);
1715 gtk_widget_set_sensitive (widget_notify, FALSE);
1718 widget_auto = g_hash_table_lookup (
table,
"pref/" GNC_PREFS_GROUP_STARTUP
"/" GNC_PREF_RUN_AT_FOPEN);
1719 widget_notify = g_hash_table_lookup (
table,
"pref/" GNC_PREFS_GROUP_STARTUP
"/" GNC_PREF_SHOW_AT_FOPEN);
1721 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget_auto)))
1722 gtk_widget_set_sensitive (widget_notify, TRUE);
1724 gtk_widget_set_sensitive (widget_notify, FALSE);
1731 typedef struct _acct_deletion_handler_data
1733 GList *affected_sxes;
1740 _open_editors (GtkDialog *dialog, gint response_code, gpointer data)
1743 gtk_widget_hide (adhd->dialog);
1746 for (sx_iter = adhd->affected_sxes; sx_iter; sx_iter = sx_iter->next)
1748 gnc_ui_scheduled_xaction_editor_dialog_create (GTK_WINDOW (adhd->parent),
1749 (SchedXaction*)sx_iter->data, FALSE);
1752 g_list_free (adhd->affected_sxes);
1753 gtk_widget_destroy (GTK_WIDGET (adhd->dialog));
1759 _sx_engine_event_handler (
QofInstance *ent,
QofEventId event_type, gpointer user_data, gpointer evt_data)
1763 GList *affected_sxes;
1765 if (!(event_type & QOF_EVENT_DESTROY))
1767 if (!GNC_IS_ACCOUNT (ent))
1769 acct = GNC_ACCOUNT (ent);
1779 GtkBuilder *builder;
1782 GtkListStore *name_list;
1784 GtkTreeViewColumn *name_column;
1785 GtkCellRenderer *renderer;
1787 builder = gtk_builder_new ();
1788 gnc_builder_add_from_file (builder,
"dialog-sx.glade",
"account_deletion_dialog");
1790 dialog = GTK_WIDGET (gtk_builder_get_object (builder,
"account_deletion_dialog"));
1793 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
1795 list = GTK_TREE_VIEW (gtk_builder_get_object (builder,
"sx_list"));
1798 gtk_tree_view_set_grid_lines (GTK_TREE_VIEW (list), gnc_tree_view_get_grid_lines_pref ());
1801 data->dialog = dialog;
1802 data->parent = parent;
1803 data->affected_sxes = affected_sxes;
1804 name_list = gtk_list_store_new (1, G_TYPE_STRING);
1805 for (sx_iter = affected_sxes; sx_iter; sx_iter = sx_iter->next)
1811 sx = (SchedXaction*)sx_iter->data;
1812 sx_name = xaccSchedXactionGetName (sx);
1813 gtk_list_store_append (name_list, &iter);
1814 gtk_list_store_set (name_list, &iter, 0, sx_name, -1);
1816 gtk_tree_view_set_model (list, GTK_TREE_MODEL (name_list));
1817 g_object_unref (G_OBJECT (name_list));
1819 renderer = gtk_cell_renderer_text_new ();
1820 name_column = gtk_tree_view_column_new_with_attributes (_(
"Name"),
1823 gtk_tree_view_append_column (list, name_column);
1825 g_signal_connect (G_OBJECT (dialog),
"response",
1826 G_CALLBACK (_open_editors), data);
1828 gtk_widget_show_all (GTK_WIDGET (dialog));
1829 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, data);
1830 g_object_unref (G_OBJECT (builder));
1836 gnc_ui_sx_initialize (
void)
1840 gnc_hook_add_dangler (HOOK_BOOK_OPENED,
1841 (GFunc)gnc_sx_sxsincelast_book_opened, NULL, NULL);
1846 "create_days_adj,remind_days_adj,sx_prefs",
1847 _(
"Scheduled Transactions"));
const GDate * xaccSchedXactionGetEndDate(const SchedXaction *sx)
Returns invalid date when there is no end-date specified.
gint xaccAccountForEachTransaction(const Account *acc, TransactionCallback proc, void *data)
The xaccAccountForEachTransaction() routine will traverse all of the transactions in account and call...
Public declarations for GncLedgerDisplay class.
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
void gnc_ledger_display_refresh(GNCLedgerDisplay *ld)
redisplay/redraw only the indicated window.
void gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num)
Sets the instance count to something other than the default.
GList * gnc_sx_get_schedule(const SchedXaction *sx)
void gnc_preferences_add_page(const gchar *filename, const gchar *widgetname, const gchar *tabname)
This function adds a full page of preferences to the preferences dialog.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
The instance data structure for a content plugin.
Date and Time handling routines.
gboolean gnc_split_register_save(SplitRegister *reg, gboolean do_commit)
Copy the contents of the current cursor to a split.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
utility functions for the GnuCash UI
#define PINFO(format, args...)
Print an informational note.
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num)
Set to '0' to turn off number-of-occurrences definition.
void gnc_plugin_page_merge_actions(GncPluginPage *page)
Add the actions for a content page to the specified window.
void gnc_embedded_window_close_page(GncEmbeddedWindow *window, GncPluginPage *page)
Remove a data plugin page from a window.
size_t qof_print_gdate(char *buf, size_t bufflen, const GDate *gd)
Convenience; calls through to qof_print_date_dmy_buff().
#define DEBUG(format, args...)
Print a debugging message.
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
gboolean gnc_commodity_equal(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equal.
void gnc_embedded_window_open_page(GncEmbeddedWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
GncEmbeddedWindow * gnc_embedded_window_new(const gchar *action_group_name, GActionEntry *action_entries, gint n_action_entries, const gchar *ui_filename, GtkWidget *enclosing_win, gboolean add_accelerators, gpointer user_data)
Create a new gnc embedded window plugin.
void gnc_split_register_load(SplitRegister *reg, GList *slist, GList *pre_filter_slist, Account *default_account)
Populates the rows of a register.
GList * gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct)
GncPluginPage * gnc_plugin_page_register_new_ledger(GNCLedgerDisplay *ledger)
Create a new "register" plugin page, given a pointer to an already created ledger.
gint qof_event_register_handler(QofEventHandler handler, gpointer user_data)
Register a handler for events.
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.
Account handling public routines.
Find the least common multiple of the arguments' denominators and use that as the denominator of the ...
gint QofEventId
Define the type of events allowed.
void gnc_gnome_help(GtkWindow *parent, const char *file_name, const char *anchor)
Launch the systems default help browser, gnome's yelp for linux, and open to a given link within a gi...
gboolean gnc_split_register_changed(SplitRegister *reg)
Returns TRUE if the register has changed cells.
Anchor Scheduled Transaction info in a book.
Functions for adding plugins to a GnuCash window.
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.
const gchar * gnc_plugin_page_get_simple_action_group_name(GncPluginPage *page)
Retrieve the simple action group name associated with this plugin page.
Public declarations of GnucashRegister class.
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
Dialog for handling user preferences.
#define xaccSchedXactionGetGUID(X)
All type declarations for the whole Gnucash engine.
Generic api to store and retrieve preferences.
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...
GNCLedgerDisplay * gnc_ledger_display_template_gl(char *id)
Displays a template ledger.
void xaccSchedXactionSetName(SchedXaction *sx, const gchar *newName)
A copy of the name is made.
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
gchar * guid_to_string(const GncGUID *guid)
The guid_to_string() routine returns a null-terminated string encoding of the id. ...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
void gnc_split_register_set_auto_complete(SplitRegister *reg, gboolean do_auto_complete)
Sets whether a register uses auto-completion.
Functions that are supported by all types of windows.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
time64 gnc_time(time64 *tbuf)
get the current time
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
SplitRegister * gnc_ledger_display_get_split_register(GNCLedgerDisplay *ld)
return the split register associated with a ledger display
void gnc_split_register_show_present_divider(SplitRegister *reg, gboolean show_present)
If TRUE, visually indicate the demarcation between splits with post dates prior to the present...
gboolean xaccSchedXactionHasOccurDef(const SchedXaction *sx)
Returns true if the scheduled transaction has a defined number of occurrences, false if not...
Scheduled Transactions public handling routines.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
void xaccSchedXactionSetEndDate(SchedXaction *sx, const GDate *newEnd)
Set to an invalid GDate to turn off 'end-date' definition.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
The type used to store guids in C.
time64 gnc_time64_get_day_start_gdate(const GDate *date)
The gnc_time64_get_day_start() routine will take the given time in GLib GDate format and adjust it to...
void xaccSchedXactionDestroy(SchedXaction *sx)
Cleans up and frees a SchedXaction and its associated data.
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.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...