34 #include <glib/gi18n.h> 44 #include "dialog-print-check.h" 45 #include "dialog-utils.h" 48 #include "gnc-date-format.h" 55 #include "engine-helpers.h" 60 #define G_LOG_DOMAIN "gnc.printing.checks" 64 G_GNUC_UNUSED
static QofLogModule log_module =
"gnc.printing.checks";
66 #define GNC_PREFS_GROUP "dialogs.checkprinting" 67 #define GNC_PREF_CHECK_FORMAT_GUID "check-format-guid" 68 #define GNC_PREF_CHECK_POSITION "check-position" 69 #define GNC_PREF_FIRST_PAGE_COUNT "first-page-count" 70 #define GNC_PREF_DATE_FORMAT_USER "date-format-user" 71 #define GNC_PREF_CUSTOM_PAYEE "custom-payee" 72 #define GNC_PREF_CUSTOM_DATE "custom-date" 73 #define GNC_PREF_CUSTOM_WORDS "custom-amount-words" 74 #define GNC_PREF_CUSTOM_NUMBER "custom-amount-number" 75 #define GNC_PREF_CUSTOM_ADDRESS "custom-address" 76 #define GNC_PREF_CUSTOM_NOTES "custom-notes" 77 #define GNC_PREF_CUSTOM_MEMO "custom-memo" 78 #define GNC_PREF_CUSTOM_TRANSLATION "custom-translation" 79 #define GNC_PREF_CUSTOM_ROTATION "custom-rotation" 80 #define GNC_PREF_CUSTOM_UNITS "custom-units" 81 #define GNC_PREF_PRINT_DATE_FMT "print-date-format" 82 #define GNC_PREF_DEFAULT_FONT "default-font" 83 #define GNC_PREF_BLOCKING_CHARS "blocking-chars" 84 #define GNC_PREF_SPLITS_AMOUNT "splits-amount" 85 #define GNC_PREF_SPLITS_MEMO "splits-memo" 86 #define GNC_PREF_SPLITS_ACCOUNT "splits-account" 89 #define DEFAULT_FONT "sans 12" 90 #define CHECK_FMT_DIR "checks" 91 #define CHECK_NAME_EXTENSION ".chk" 92 #define DEGREES_TO_RADIANS (G_PI / 180.0) 94 #define BLOCKING_CHAR_OFF 0 95 #define BLOCKING_CHAR_ON 1 97 #define KF_GROUP_TOP "Top" 98 #define KF_GROUP_POS "Check Positions" 99 #define KF_GROUP_ITEMS "Check Items" 100 #define KF_KEY_GUID "Guid" 101 #define KF_KEY_TITLE "Title" 102 #define KF_KEY_ROTATION "Rotation" 103 #define KF_KEY_TRANSLATION "Translation" 104 #define KF_KEY_FONT "Font" 105 #define KF_KEY_ALIGN "Align" 106 #define KF_KEY_BLOCKING "Blocking_Chars" 107 #define KF_KEY_SHOW_GRID "Show_Grid" 108 #define KF_KEY_SHOW_BOXES "Show_Boxes" 109 #define KF_KEY_NAMES "Names" 110 #define KF_KEY_HEIGHT "Height" 111 #define KF_KEY_TYPE "Type" 112 #define KF_KEY_COORDS "Coords" 113 #define KF_KEY_TEXT "Text" 114 #define KF_KEY_FILENAME "Filename" 115 #define KF_KEY_DATE_FORMAT "DateFormat" 116 #define KF_KEY_SPLITS_AMOUNT "SplitsAmount" 117 #define KF_KEY_SPLITS_MEMO "SplitsMemo" 118 #define KF_KEY_SPLITS_ACCOUNT "SplitsAccount" 122 typedef enum format_combo_col_t
136 void gnc_ui_print_check_response_cb (GtkDialog *dialog, gint response, PrintCheckDialog *pcd);
137 void gnc_print_check_format_changed (GtkComboBox *widget, PrintCheckDialog *pcd);
138 void gnc_print_check_position_changed (GtkComboBox *widget, PrintCheckDialog *pcd);
139 void gnc_print_check_save_button_clicked (GtkButton *button, PrintCheckDialog *pcd);
140 void gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button);
142 static void initialize_format_combobox (PrintCheckDialog *pcd);
143 gchar* get_check_address (PrintCheckDialog *pcd);
144 static gboolean check_format_has_address (PrintCheckDialog *pcd);
145 gchar* get_check_splits_amount (PrintCheckDialog *pcd);
146 gchar* get_check_splits_memo (PrintCheckDialog *pcd);
147 gchar* get_check_splits_account (PrintCheckDialog *pcd);
154 #define ENUM_CHECK_ITEM_TYPE(_) \ 174 DEFINE_ENUM(CheckItemType, ENUM_CHECK_ITEM_TYPE)
176 FROM_STRING_FUNC(CheckItemType, ENUM_CHECK_ITEM_TYPE)
177 AS_STRING_DEC(CheckItemType, ENUM_CHECK_ITEM_TYPE)
178 AS_STRING_FUNC(CheckItemType, ENUM_CHECK_ITEM_TYPE)
183 typedef struct _check_item
213 gboolean print_date_format;
217 PangoAlignment align;
227 typedef struct _check_format
243 gboolean print_date_format;
277 GtkWindow *caller_window;
282 GtkWidget *format_combobox;
284 GtkWidget *position_combobox;
286 GtkSpinButton *first_page_count;
287 GtkWidget *custom_table;
288 GtkSpinButton *payee_x, *payee_y;
289 GtkSpinButton *date_x, *date_y;
290 GtkSpinButton *words_x, *words_y;
291 GtkSpinButton *number_x, *number_y;
292 GtkSpinButton *address_x, *address_y;
293 GtkSpinButton *notes_x, *notes_y;
294 GtkSpinButton *memo_x, *memo_y;
295 GtkSpinButton *splits_amount_x, *splits_amount_y;
296 GtkSpinButton *splits_memo_x, *splits_memo_y;
297 GtkSpinButton *splits_account_x, *splits_account_y;
298 GtkSpinButton *translation_x, *translation_y;
299 GtkSpinButton *check_rotation;
300 GtkWidget *translation_label;
302 GtkWidget *units_combobox;
304 GtkWidget *date_format;
306 GtkWidget *check_address_name;
307 GtkWidget *check_address_1;
308 GtkWidget *check_address_2;
309 GtkWidget *check_address_3;
310 GtkWidget *check_address_4;
324 find_existing_format (GtkListStore *store, gchar *guid, GtkTreeIter *iter_out)
329 g_return_val_if_fail(store, NULL);
330 g_return_val_if_fail(guid, NULL);
332 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
337 gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
341 if (strcmp(format->
guid, guid) != 0)
348 while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
360 get_check_address( PrintCheckDialog *pcd)
363 address = g_strconcat(gtk_entry_get_text(GTK_ENTRY(pcd->check_address_name)),
"\n",
364 gtk_entry_get_text(GTK_ENTRY(pcd->check_address_1)),
"\n",
365 gtk_entry_get_text(GTK_ENTRY(pcd->check_address_2)),
"\n",
366 gtk_entry_get_text(GTK_ENTRY(pcd->check_address_3)),
"\n",
367 gtk_entry_get_text(GTK_ENTRY(pcd->check_address_4)),
379 get_check_splits_amount(PrintCheckDialog *pcd)
381 gchar* amount = NULL;
388 if ( !s_list )
return NULL;
390 amount = g_strconcat(
"", NULL);
394 Split *split = node->data;
396 if (split != pcd->split)
398 const gchar* split_amount;
402 if (amount && *amount)
403 amount = g_strconcat(amt_temp,
"\n", split_amount, NULL);
405 amount = g_strconcat(amt_temp, split_amount, NULL);
417 get_check_splits_memo(PrintCheckDialog *pcd)
420 const gchar* split_memo;
427 if ( !s_list )
return NULL;
429 memo = g_strconcat(
"", NULL);
433 Split *split = node->data;
435 if (split != pcd->split)
441 memo = g_strconcat(memo_temp,
"\n", split_memo, NULL);
443 memo = g_strconcat(memo_temp, split_memo, NULL);
455 get_check_splits_account(PrintCheckDialog *pcd)
457 gchar* account = NULL;
464 if ( !s_list )
return NULL;
466 account = g_strconcat(
"", NULL);
470 Split *split = node->data;
472 if (split != pcd->split)
475 const gchar* aName = NULL;
479 account_temp = account;
480 if (account && *account)
481 account = g_strconcat(account_temp,
"\n", aName, NULL);
483 account = g_strconcat(account_temp, aName, NULL);
484 g_free(account_temp);
496 check_format_has_address ( PrintCheckDialog *pcd )
499 check_item_t *item = NULL;
503 if ( !pcd )
return FALSE;
506 if (g_list_length(pcd->splits) != 1)
511 format = pcd->selected_format;
512 if ( !format )
return TRUE;
514 for (elem = pcd->selected_format->items; elem; elem = g_slist_next(elem))
517 if ( item->type == ADDRESS )
return TRUE;
524 gnc_ui_print_save_dialog(PrintCheckDialog *pcd)
533 if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(pcd->format_combobox),
536 model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
537 gtk_tree_model_get(model, &iter,
COL_DATA, &check, -1);
539 check ? check->
guid :
"custom");
541 active = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
543 active = gtk_spin_button_get_value_as_int(pcd->first_page_count);
545 active = gnc_date_format_get_format (GNC_DATE_FORMAT(pcd->date_format));
549 format = gnc_date_format_get_custom (GNC_DATE_FORMAT(pcd->date_format));
559 gtk_spin_button_get_value(pcd->payee_x),
560 gtk_spin_button_get_value(pcd->payee_y));
562 gtk_spin_button_get_value(pcd->date_x),
563 gtk_spin_button_get_value(pcd->date_y));
565 gtk_spin_button_get_value(pcd->words_x),
566 gtk_spin_button_get_value(pcd->words_y));
568 gtk_spin_button_get_value(pcd->number_x),
569 gtk_spin_button_get_value(pcd->number_y));
571 gtk_spin_button_get_value(pcd->notes_x),
572 gtk_spin_button_get_value(pcd->notes_y));
574 gtk_spin_button_get_value(pcd->memo_x),
575 gtk_spin_button_get_value(pcd->memo_y));
577 gtk_spin_button_get_value(pcd->address_x),
578 gtk_spin_button_get_value(pcd->address_y));
580 gtk_spin_button_get_value(pcd->splits_amount_x),
581 gtk_spin_button_get_value(pcd->splits_amount_y));
583 gtk_spin_button_get_value(pcd->splits_memo_x),
584 gtk_spin_button_get_value(pcd->splits_memo_y));
586 gtk_spin_button_get_value(pcd->splits_account_x),
587 gtk_spin_button_get_value(pcd->splits_account_y));
589 gtk_spin_button_get_value(pcd->translation_x),
590 gtk_spin_button_get_value(pcd->translation_y));
592 gtk_spin_button_get_value(pcd->check_rotation));
593 active = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->units_combobox));
599 gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
603 gchar *format, *guid;
609 if (!(guid && *guid))
610 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
611 else if (strcmp(guid,
"custom") == 0)
613 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
614 pcd->format_max - 1);
618 model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
619 if (find_existing_format(GTK_LIST_STORE(model), guid, &iter))
621 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(pcd->format_combobox), &iter);
625 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
634 if (active < 0 || active > pcd->position_max)
636 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->position_combobox), active);
638 gtk_spin_button_set_value(pcd->first_page_count, (gdouble) active);
640 gnc_date_format_set_format(GNC_DATE_FORMAT(pcd->date_format), active);
644 if (format && *format)
646 gnc_date_format_set_custom(GNC_DATE_FORMAT(pcd->date_format), format);
653 gtk_spin_button_set_value(pcd->payee_x, x);
654 gtk_spin_button_set_value(pcd->payee_y, y);
657 gtk_spin_button_set_value(pcd->date_x, x);
658 gtk_spin_button_set_value(pcd->date_y, y);
660 gtk_spin_button_set_value(pcd->words_x, x);
661 gtk_spin_button_set_value(pcd->words_y, y);
663 gtk_spin_button_set_value(pcd->number_x, x);
664 gtk_spin_button_set_value(pcd->number_y, y);
666 gtk_spin_button_set_value(pcd->address_x, x);
667 gtk_spin_button_set_value(pcd->address_y, y);
669 gtk_spin_button_set_value(pcd->notes_x, x);
670 gtk_spin_button_set_value(pcd->notes_y, y);
672 gtk_spin_button_set_value(pcd->memo_x, x);
673 gtk_spin_button_set_value(pcd->memo_y, y);
675 gtk_spin_button_set_value(pcd->splits_amount_x, x);
676 gtk_spin_button_set_value(pcd->splits_amount_y, y);
678 gtk_spin_button_set_value(pcd->splits_memo_x, x);
679 gtk_spin_button_set_value(pcd->splits_memo_y, y);
681 gtk_spin_button_set_value(pcd->splits_account_x, x);
682 gtk_spin_button_set_value(pcd->splits_account_y, y);
684 gtk_spin_button_set_value(pcd->translation_x, x);
685 gtk_spin_button_set_value(pcd->translation_y, y);
687 gtk_spin_button_set_value(pcd->check_rotation, x);
689 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->units_combobox), active);
694 pcd_get_custom_multip(PrintCheckDialog *pcd)
698 selected = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->units_combobox));
718 pcd_key_file_save_xy (GKeyFile *key_file,
const gchar *group_name,
719 const gchar *key_name, gdouble multip,
720 GtkSpinButton *spin0, GtkSpinButton *spin1)
724 dd[0] = multip * gtk_spin_button_get_value(spin0);
725 dd[1] = multip * gtk_spin_button_get_value(spin1);
728 dd[0] = round(dd[0] * 1000) / 1000;
729 dd[1] = round(dd[1] * 1000) / 1000;
730 g_key_file_set_double_list(key_file, group_name, key_name, dd, 2);
739 pcd_key_file_save_item_xy (GKeyFile *key_file,
int index,
740 CheckItemType type, gdouble multip,
741 GtkSpinButton *spin0, GtkSpinButton *spin1)
744 key = g_strdup_printf(
"Type_%d", index);
745 g_key_file_set_string(key_file, KF_GROUP_ITEMS, key,
746 CheckItemTypeasString(type));
748 key = g_strdup_printf(
"Coords_%d", index);
749 pcd_key_file_save_xy(key_file, KF_GROUP_ITEMS, key, multip, spin0, spin1);
758 pcd_save_custom_data(PrintCheckDialog *pcd,
const gchar *title)
761 GError *error = NULL;
767 gchar *filename, *pathname;
769 multip = pcd_get_custom_multip(pcd);
771 key_file = g_key_file_new();
774 g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_GUID, buf);
775 g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE, title);
776 g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, FALSE);
777 g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, FALSE);
778 g_key_file_set_double(key_file, KF_GROUP_TOP, KF_KEY_ROTATION,
779 gtk_spin_button_get_value(pcd->check_rotation));
780 pcd_key_file_save_xy(key_file, KF_GROUP_TOP, KF_KEY_TRANSLATION, multip,
781 pcd->translation_x, pcd->translation_y);
783 pcd_key_file_save_item_xy(key_file, i++, PAYEE, multip,
784 pcd->payee_x, pcd->payee_y);
785 pcd_key_file_save_item_xy(key_file, i++, DATE, multip,
786 pcd->date_x, pcd->date_y);
787 pcd_key_file_save_item_xy(key_file, i++, AMOUNT_WORDS, multip,
788 pcd->words_x, pcd->words_y);
789 pcd_key_file_save_item_xy(key_file, i++, AMOUNT_NUMBER, multip,
790 pcd->number_x, pcd->number_y);
791 pcd_key_file_save_item_xy(key_file, i++, ADDRESS, multip,
792 pcd->address_x, pcd->address_y);
793 pcd_key_file_save_item_xy(key_file, i++, NOTES, multip,
794 pcd->notes_x, pcd->notes_y);
795 pcd_key_file_save_item_xy(key_file, i++, MEMO, multip,
796 pcd->memo_x, pcd->memo_y);
797 pcd_key_file_save_item_xy(key_file, i++, SPLITS_AMOUNT, multip,
798 pcd->splits_amount_x, pcd->splits_amount_y);
799 pcd_key_file_save_item_xy(key_file, i++, SPLITS_MEMO, multip,
800 pcd->splits_memo_x, pcd->splits_memo_y);
801 pcd_key_file_save_item_xy(key_file, i++, SPLITS_ACCOUNT, multip,
802 pcd->splits_account_x, pcd->splits_account_y);
804 filename = g_strconcat(title, CHECK_NAME_EXTENSION, NULL);
812 initialize_format_combobox(pcd);
814 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
815 pcd->format_max - 1);
819 dialog = gtk_message_dialog_new(GTK_WINDOW(pcd->dialog),
820 GTK_DIALOG_DESTROY_WITH_PARENT,
822 GTK_BUTTONS_CLOSE,
"%s",
823 _(
"Cannot save check format file."));
824 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
825 _(
"Cannot open file %s"),
827 gtk_dialog_run(GTK_DIALOG(dialog));
828 gtk_widget_destroy(dialog);
839 gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button)
844 text = gtk_entry_get_text(GTK_ENTRY(editable));
845 sensitive = text && *text;
846 gtk_widget_set_sensitive(ok_button, sensitive);
855 gnc_print_check_save_button_clicked(GtkButton *unused, PrintCheckDialog *pcd)
857 GtkWidget *dialog, *entry, *button;
861 builder = gtk_builder_new();
862 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"format_title_dialog");
865 dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"format_title_dialog"));
866 entry = GTK_WIDGET(gtk_builder_get_object (builder,
"format_title"));
867 button = GTK_WIDGET(gtk_builder_get_object (builder,
"ok_button"));
868 gnc_check_format_title_changed(GTK_EDITABLE(entry), button);
869 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pcd);
871 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pcd->dialog));
872 if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
874 gtk_widget_destroy(dialog);
875 g_object_unref(G_OBJECT(builder));
879 title = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
880 gtk_widget_destroy (dialog);
882 g_object_unref(G_OBJECT(builder));
884 pcd_save_custom_data(pcd, title);
893 doubles_to_string(gdouble *dd, gint len)
898 str = g_string_new_len(NULL, 50);
899 for (i = 0; i < len; i++)
900 g_string_append_printf(str,
"%f ", dd[i]);
901 return g_string_free(str, FALSE);
915 format_read_item_placement(
const gchar *file,
918 check_item_t *data = NULL;
919 GError *error = NULL;
921 gchar *key, *value, *name;
928 for (item_num = 1;; item_num++)
932 data = g_new0(check_item_t, 1);
937 key = g_strdup_printf(
"%s_%d", KF_KEY_TYPE, item_num);
938 value = g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
941 if ((error->domain == G_KEY_FILE_ERROR)
942 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND))
949 DEBUG(
"Check file %s, group %s, key %s, value: %s",
950 file, KF_GROUP_ITEMS, key, value);
954 name = g_utf8_strup(value, -1);
955 data->type = CheckItemTypefromString(name);
961 key = g_strdup_printf(
"%s_%d", KF_KEY_COORDS, item_num);
962 dd = g_key_file_get_double_list(key_file, KF_GROUP_ITEMS,
963 key, &dd_len, &error);
966 value = doubles_to_string(dd, dd_len);
967 DEBUG(
"Check file %s, group %s, key %s, length %"G_GSIZE_FORMAT
"; values: %s",
968 file, KF_GROUP_ITEMS, key, dd_len, value);
984 (
"Check file %s, group %s, key %s, error: 2 or 4 values only",
985 file, KF_GROUP_ITEMS, key);
997 if (data->type != PICTURE)
999 key = g_strdup_printf(
"%s_%d", KF_KEY_FONT, item_num);
1001 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
1004 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1005 file, KF_GROUP_ITEMS, key, data->font);
1009 if (!((error->domain == G_KEY_FILE_ERROR)
1010 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1011 g_warning(
"Check file %s, group %s, key %s, error: %s",
1012 file, KF_GROUP_ITEMS, key, error->message);
1013 g_clear_error(&error);
1017 key = g_strdup_printf(
"%s_%d", KF_KEY_ALIGN, item_num);
1019 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
1022 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1023 file, KF_GROUP_ITEMS, key, value);
1024 name = g_utf8_strdown(value, -1);
1025 if (strcmp(name,
"right") == 0)
1026 data->align = PANGO_ALIGN_RIGHT;
1027 else if (strcmp(name,
"center") == 0)
1028 data->align = PANGO_ALIGN_CENTER;
1030 data->align = PANGO_ALIGN_LEFT;
1036 if (!((error->domain == G_KEY_FILE_ERROR)
1037 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1038 g_warning(
"Check file %s, group %s, key %s, error: %s",
1039 file, KF_GROUP_ITEMS, key, error->message);
1040 data->align = PANGO_ALIGN_LEFT;
1041 g_clear_error(&error);
1045 key = g_strdup_printf(
"%s_%d", KF_KEY_BLOCKING, item_num);
1047 g_key_file_get_boolean(key_file, KF_GROUP_ITEMS, key, &error);
1050 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1051 file, KF_GROUP_ITEMS, key, bval);
1052 data->blocking = bval;
1056 if (!((error->domain == G_KEY_FILE_ERROR)
1057 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1058 g_warning(
"Check file %s, group %s, key %s, error: %s",
1059 file, KF_GROUP_ITEMS, key, error->message);
1061 g_clear_error(&error);
1069 key = g_strdup_printf(
"%s_%d", KF_KEY_FILENAME, item_num);
1071 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key,
1075 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1076 file, KF_GROUP_ITEMS, key, data->filename);
1080 key = g_strdup_printf(
"%s_%d", KF_KEY_TEXT, item_num);
1082 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key,
1086 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1087 file, KF_GROUP_ITEMS, key, data->text);
1092 key = g_strdup_printf(
"%s_%d", KF_KEY_DATE_FORMAT, item_num);
1093 bval = g_key_file_get_boolean(key_file, KF_GROUP_ITEMS, key, &error);
1096 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1097 file, KF_GROUP_ITEMS, key, bval);
1098 data->print_date_format = bval;
1102 if (!((error->domain == G_KEY_FILE_ERROR)
1103 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1104 g_warning(
"Check file %s, group %s, key %s, error: %s",
1105 file, KF_GROUP_ITEMS, key, error->message);
1107 g_clear_error(&error);
1115 list = g_slist_append(list, data);
1123 g_warning(
"Check file %s, group %s, key %s, error: %s",
1124 file, KF_GROUP_ITEMS, key, error->message);
1127 g_error_free(error);
1139 format_free_item_placement(check_item_t *data)
1146 g_free(data->filename);
1157 format_read_multicheck_info(
const gchar *file,
1160 GError *error = NULL;
1161 GSList *list = NULL;
1162 gchar *key, **names;
1166 key = g_strdup_printf(
"%s", KF_KEY_HEIGHT);
1167 format->
height = g_key_file_get_double(key_file, KF_GROUP_POS, key, &error);
1170 if ((error->domain == G_KEY_FILE_ERROR)
1171 && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
1172 || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1174 g_clear_error(&error);
1179 g_warning(
"Check file %s, error reading group %s, key %s: %s",
1180 file, KF_GROUP_POS, key, error->message);
1186 names = g_key_file_get_string_list(key_file, KF_GROUP_POS, KF_KEY_NAMES,
1190 if ((error->domain == G_KEY_FILE_ERROR)
1191 && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
1192 || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1198 g_warning(
"Check file %s, error reading group %s, key %s: %s",
1199 file, KF_GROUP_POS, key, error->message);
1204 for (i = 0; i < length; i++)
1205 list = g_slist_append(list, g_strdup(names[i]));
1215 free_check_position(gchar *name)
1226 format_read_general_info(
const gchar *file,
1229 GError *error = NULL;
1235 value = g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_GUID, &error);
1238 g_warning(
"Check file %s, group %s, key %s, error: %s",
1239 file, KF_GROUP_TOP, KF_KEY_GUID, error->message);
1240 g_error_free(error);
1243 parts = g_strsplit(value,
"-", -1);
1244 format->
guid = g_strjoinv(
"", parts);
1246 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1247 file, KF_GROUP_TOP, KF_KEY_GUID, format->
guid);
1250 g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE, &error);
1253 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1254 file, KF_GROUP_TOP, KF_KEY_TITLE, format->
title);
1258 g_warning(
"Check file %s, group %s, key %s, error: %s",
1259 file, KF_GROUP_TOP, KF_KEY_TITLE, error->message);
1264 g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_BLOCKING,
1268 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1269 file, KF_GROUP_TOP, KF_KEY_BLOCKING, format->
blocking);
1273 if (!((error->domain == G_KEY_FILE_ERROR)
1274 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1275 g_warning(
"Check file %s, group %s, key %s, error: %s",
1276 file, KF_GROUP_TOP, KF_KEY_BLOCKING, error->message);
1285 g_clear_error(&error);
1289 g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_DATE_FORMAT,
1293 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1298 if (!((error->domain == G_KEY_FILE_ERROR)
1299 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1300 g_warning(
"Check file %s, group %s, key %s, error: %s",
1301 file, KF_GROUP_TOP, KF_KEY_DATE_FORMAT, error->message);
1310 g_clear_error(&error);
1314 g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_GRID,
1318 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1319 file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, format->
show_grid);
1323 if (!((error->domain == G_KEY_FILE_ERROR)
1324 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1325 g_warning(
"Check file %s, group %s, key %s, error: %s",
1326 file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, error->message);
1328 g_clear_error(&error);
1332 g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES,
1336 DEBUG(
"Check file %s, group %s, key %s, value: %d",
1337 file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, format->
show_boxes);
1341 if (!((error->domain == G_KEY_FILE_ERROR)
1342 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1343 g_warning(
"Check file %s, group %s, key %s, error: %s",
1344 file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, error->message);
1346 g_clear_error(&error);
1350 g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_FONT, &error);
1353 DEBUG(
"Check file %s, group %s, key %s, value: %s",
1354 file, KF_GROUP_TOP, KF_KEY_FONT, format->
font);
1358 if (!((error->domain == G_KEY_FILE_ERROR)
1359 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1360 g_warning(
"Check file %s, group %s, key %s, error: %s",
1361 file, KF_GROUP_TOP, KF_KEY_FONT, error->message);
1362 g_clear_error(&error);
1366 g_key_file_get_double(key_file, KF_GROUP_TOP, KF_KEY_ROTATION, &error);
1369 DEBUG(
"Check file %s, group %s, key %s, value: %f",
1370 file, KF_GROUP_TOP, KF_KEY_ROTATION, format->
rotation);
1374 if (!((error->domain == G_KEY_FILE_ERROR)
1375 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1376 g_warning(
"Check file %s, group %s, key %s, error: %s",
1377 file, KF_GROUP_TOP, KF_KEY_ROTATION, error->message);
1379 g_clear_error(&error);
1382 dd = g_key_file_get_double_list(key_file, KF_GROUP_TOP, KF_KEY_TRANSLATION,
1386 value = doubles_to_string(dd, dd_len);
1387 DEBUG(
"Check file %s, group %s, key %s, length %"G_GSIZE_FORMAT
"; values: %s",
1388 file, KF_GROUP_TOP, KF_KEY_TRANSLATION, dd_len, value);
1398 g_warning(
"Check file %s, error top %s, key %s: 2 values only",
1399 file, KF_GROUP_TOP, KF_KEY_TRANSLATION);
1405 if (!((error->domain == G_KEY_FILE_ERROR)
1406 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
1407 g_warning(
"Check file %s, group top %s, key %s: %s",
1408 file, KF_GROUP_ITEMS, KF_KEY_TRANSLATION, error->message);
1409 g_clear_error(&error);
1421 g_return_if_fail(data);
1423 g_free(data->filename);
1424 g_free(data->title);
1426 g_slist_foreach(data->positions, (GFunc) free_check_position, NULL);
1427 g_slist_free(data->positions);
1428 g_slist_foreach(data->items, (GFunc) format_free_item_placement, NULL);
1429 g_slist_free(data->items);
1439 read_one_check_format(PrintCheckDialog *pcd,
const gchar *groupname,
1440 const gchar *dirname,
const gchar *file)
1446 pathname = g_build_filename(dirname, file, (
char *)NULL);
1451 g_warning(
"Check file %s, cannot load file", file);
1456 format->
group = groupname;
1458 if (format_read_general_info(file, key_file, format))
1460 format->
positions = format_read_multicheck_info(file, key_file, format);
1461 format->
items = format_read_item_placement(file, key_file, format);
1464 g_key_file_free(key_file);
1465 if ((NULL == format->
title) || (NULL == format->
items))
1467 g_warning(
"Check file %s, no items read. Dropping file.", file);
1468 free_check_format(format);
1481 read_one_check_directory(PrintCheckDialog *pcd, GtkListStore *store,
1482 const gchar *groupname,
const gchar *dirname)
1486 const gchar *filename;
1489 gboolean found = FALSE;
1491 dir = g_dir_open(dirname, 0, NULL);
1495 while ((filename = g_dir_read_name(dir)) != NULL)
1497 if (g_str_has_prefix(filename,
"#"))
1499 if (!g_str_has_suffix(filename,
".chk"))
1502 format = read_one_check_format(pcd, groupname, dirname, filename);
1506 existing = find_existing_format(store, format->
guid, NULL);
1509 dialog = gtk_message_dialog_new
1510 (GTK_WINDOW(pcd->dialog),
1511 GTK_DIALOG_DESTROY_WITH_PARENT,
1512 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
"%s",
1513 _(
"There is a duplicate check format file."));
1514 gtk_message_dialog_format_secondary_text
1515 (GTK_MESSAGE_DIALOG(dialog),
1522 _(
"The GUIDs in the %s check format file '%s' and " 1523 "the %s check format file '%s' match."),
1524 existing->group, existing->filename,
1526 gtk_dialog_run(GTK_DIALOG(dialog));
1527 gtk_widget_destroy(dialog);
1528 free_check_format (format);
1532 gtk_list_store_append(store, &iter);
1544 gtk_list_store_append(store, &iter);
1545 gtk_list_store_set(store, &iter,
COL_SEP, TRUE, -1);
1555 read_formats(PrintCheckDialog *pcd, GtkListStore *store)
1557 gchar *dirname, *pkgdatadir;
1559 pkgdatadir = gnc_path_get_pkgdatadir();
1560 dirname = g_build_filename(pkgdatadir, CHECK_FMT_DIR, (
char *)NULL);
1564 read_one_check_directory(pcd, store, _(
"application"), dirname);
1572 read_one_check_directory(pcd, store, _(
"user"), dirname);
1578 format_is_a_separator (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
1582 gtk_tree_model_get(model, iter,
COL_SEP, &separator, -1);
1588 initialize_format_combobox (PrintCheckDialog *pcd)
1590 GtkListStore *store;
1593 store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
1594 read_formats(pcd, store);
1595 gtk_list_store_append(store, &iter);
1596 gtk_list_store_set(store, &iter,
COL_NAME, _(
"Custom"), -1);
1597 pcd->format_max = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
1598 gtk_combo_box_set_model(GTK_COMBO_BOX(pcd->format_combobox),
1599 GTK_TREE_MODEL(store));
1600 gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(pcd->format_combobox),
1601 format_is_a_separator, NULL, NULL);
1602 g_object_unref (store);
1611 gnc_ui_print_check_dialog_create(GtkWidget *parent,
1614 PrintCheckDialog *pcd;
1615 GtkBuilder *builder;
1618 Transaction *trans = NULL;
1620 pcd = g_new0(PrintCheckDialog, 1);
1621 pcd->caller_window = GTK_WINDOW(parent);
1622 pcd->splits = g_list_copy(splits);
1624 builder = gtk_builder_new();
1625 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment1");
1626 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment2");
1627 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment3");
1628 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment4");
1629 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment5");
1630 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment6");
1631 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment7");
1632 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment8");
1633 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment9");
1634 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment10");
1635 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment11");
1636 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment12");
1637 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment13");
1638 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment14");
1639 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment15");
1640 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment16");
1641 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment17");
1642 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment18");
1643 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment19");
1644 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment20");
1645 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment21");
1646 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment22");
1647 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment23");
1648 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"adjustment24");
1649 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"liststore1");
1650 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"liststore2");
1651 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"liststore3");
1652 gnc_builder_add_from_file (builder,
"dialog-print-check.glade",
"print_check_dialog");
1654 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pcd);
1656 pcd->builder = builder;
1657 pcd->dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"print_check_dialog"));
1660 gtk_widget_set_name (GTK_WIDGET(pcd->dialog),
"gnc-id-print-check");
1663 pcd->format_combobox = GTK_WIDGET(gtk_builder_get_object (builder,
"check_format_combobox"));
1664 pcd->position_combobox = GTK_WIDGET(gtk_builder_get_object (builder,
"check_position_combobox"));
1665 pcd->first_page_count = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"first_page_count_entry"));
1667 pcd->custom_table = GTK_WIDGET(gtk_builder_get_object (builder,
"custom_table"));
1668 pcd->payee_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"payee_x_entry"));
1669 pcd->payee_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"payee_y_entry"));
1670 pcd->date_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"date_x_entry"));
1671 pcd->date_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"date_y_entry"));
1672 pcd->words_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"amount_words_x_entry"));
1673 pcd->words_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"amount_words_y_entry"));
1674 pcd->number_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"amount_numbers_x_entry"));
1675 pcd->number_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"amount_numbers_y_entry"));
1676 pcd->notes_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"notes_x_entry"));
1677 pcd->notes_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"notes_y_entry"));
1678 pcd->memo_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"memo_x_entry"));
1679 pcd->memo_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"memo_y_entry"));
1680 pcd->address_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"address_x_entry"));
1681 pcd->address_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"address_y_entry"));
1682 pcd->splits_amount_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_amount_x_entry"));
1683 pcd->splits_amount_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_amount_y_entry"));
1684 pcd->splits_memo_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_memo_x_entry"));
1685 pcd->splits_memo_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_memo_y_entry"));
1686 pcd->splits_account_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_account_x_entry"));
1687 pcd->splits_account_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"splits_account_y_entry"));
1688 pcd->translation_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"translation_x_entry"));
1689 pcd->translation_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"translation_y_entry"));
1690 pcd->translation_label = GTK_WIDGET(gtk_builder_get_object (builder,
"translation_label"));
1691 pcd->check_rotation = GTK_SPIN_BUTTON(gtk_builder_get_object (builder,
"check_rotation_entry"));
1692 pcd->units_combobox = GTK_WIDGET(gtk_builder_get_object (builder,
"units_combobox"));
1694 gtk_window_set_transient_for(GTK_WINDOW(pcd->dialog), pcd->caller_window);
1697 table = GTK_WIDGET(gtk_builder_get_object (builder,
"options_table"));
1698 pcd->date_format = gnc_date_format_new_without_label();
1699 gtk_grid_attach (GTK_GRID(
table), pcd->date_format, 1, 4, 1, 1);
1703 pcd->default_font = font && *font ? font : g_strdup(DEFAULT_FONT);
1706 initialize_format_combobox(pcd);
1709 pcd->check_address_name = GTK_WIDGET(gtk_builder_get_object (builder,
"check_address_name"));
1710 pcd->check_address_1 = GTK_WIDGET(gtk_builder_get_object (builder,
"check_address_1"));
1711 pcd->check_address_2 = GTK_WIDGET(gtk_builder_get_object (builder,
"check_address_2"));
1712 pcd->check_address_3 = GTK_WIDGET(gtk_builder_get_object (builder,
"check_address_3"));
1713 pcd->check_address_4 = GTK_WIDGET(gtk_builder_get_object (builder,
"check_address_4"));
1717 if (g_list_length(pcd->splits) == 1)
1728 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_name), gncOwnerGetName(&owner));
1729 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_1), gncAddressGetAddr1 (gncOwnerGetAddr(&owner)));
1730 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_2), gncAddressGetAddr2 (gncOwnerGetAddr(&owner)));
1731 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_3), gncAddressGetAddr3 (gncOwnerGetAddr(&owner)));
1732 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_4), gncAddressGetAddr4 (gncOwnerGetAddr(&owner)));
1737 if ( trans && (0 == gtk_entry_get_text_length (GTK_ENTRY(pcd->check_address_name))) )
1740 gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder,
"lower_left")));
1742 gnc_ui_print_restore_dialog(pcd);
1743 gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(pcd->dialog), GTK_WINDOW (parent));
1745 g_object_unref(G_OBJECT(builder));
1746 gtk_widget_show_all(pcd->dialog);
1758 draw_grid(GtkPrintContext *context, gint width, gint height,
const gchar *font)
1760 const double dash_pattern[2] = { 1.0, 5.0 };
1761 PangoFontDescription *desc;
1762 PangoLayout *layout;
1768 layout = gtk_print_context_create_pango_layout(context);
1769 desc = pango_font_description_from_string(font);
1770 pango_layout_set_font_description(layout, desc);
1771 pango_font_description_free(desc);
1772 pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
1773 pango_layout_set_width(layout, -1);
1776 cr = gtk_print_context_get_cairo_context(context);
1778 cairo_set_line_width(cr, 1.0);
1779 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
1780 cairo_set_dash(cr, dash_pattern, 2, 0);
1783 for (i = -200; i < (height + 200); i += 50)
1785 text = g_strdup_printf(
"%d", (
int)i);
1786 cairo_move_to(cr, -200, i);
1787 cairo_line_to(cr, width + 200, i);
1789 pango_layout_set_text(layout, text, -1);
1790 cairo_move_to(cr, 0, i);
1791 pango_cairo_show_layout(cr, layout);
1796 for (i = -200; i < (width + 200); i += 50)
1798 text = g_strdup_printf(
"%d", (
int)i);
1799 cairo_move_to(cr, i, -200);
1800 cairo_line_to(cr, i, height + 200);
1802 pango_layout_set_text(layout, text, -1);
1803 cairo_move_to(cr, i, 0);
1804 pango_cairo_show_layout(cr, layout);
1810 g_object_unref(layout);
1820 draw_text(GtkPrintContext *context,
const gchar *text, check_item_t *data,
1821 PangoFontDescription *default_desc)
1823 PangoFontDescription *desc;
1824 PangoLayout *layout;
1826 gint layout_height, layout_width;
1827 gdouble width, height;
1830 if ((NULL == text) || (strlen(text) == 0))
1834 layout = gtk_print_context_create_pango_layout(context);
1837 desc = pango_font_description_from_string(data->font);
1838 pango_layout_set_font_description(layout, desc);
1839 pango_font_description_free(desc);
1843 pango_layout_set_font_description(layout, default_desc);
1845 pango_layout_set_alignment(layout,
1846 data->w ? data->align : PANGO_ALIGN_LEFT);
1847 pango_layout_set_width(layout, data->w ? data->w * PANGO_SCALE : -1);
1848 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
1849 if ( data->blocking )
1851 new_text = g_strdup_printf(
"***%s***", text);
1852 pango_layout_set_text(layout, new_text, -1);
1857 pango_layout_set_text(layout, text, -1);
1859 pango_layout_get_size(layout, &layout_width, &layout_height);
1860 width = (gdouble) layout_width / PANGO_SCALE;
1861 height = (gdouble) layout_height / PANGO_SCALE;
1863 cr = gtk_print_context_get_cairo_context(context);
1867 if (data->w && data->h)
1869 DEBUG(
"Text clip rectangle, coords %f,%f, size %f,%f",
1870 data->x, data->y - data->h, data->w, data->h);
1871 cairo_rectangle(cr, data->x, data->y - data->h, data->w, data->h);
1872 cairo_clip_preserve(cr);
1876 DEBUG(
"Text move to %f,%f, print '%s'", data->x, data->y,
1877 text ? text :
"(null)");
1878 cairo_move_to(cr, data->x, data->y - height);
1879 pango_cairo_show_layout(cr, layout);
1883 g_object_unref(layout);
1899 read_image (
const gchar *filename)
1902 gchar *pkgdatadir, *dirname, *tmp_name;
1904 if (g_path_is_absolute(filename))
1905 return gtk_image_new_from_file(filename);
1907 pkgdatadir = gnc_path_get_pkgdatadir();
1908 tmp_name = g_build_filename(pkgdatadir, CHECK_FMT_DIR, filename, (
char *)NULL);
1909 if (!g_file_test(tmp_name, G_FILE_TEST_EXISTS))
1913 tmp_name = g_build_filename(dirname, filename, (
char *)NULL);
1916 image = gtk_image_new_from_file(tmp_name);
1927 draw_picture(GtkPrintContext *context, check_item_t *data)
1930 GdkPixbuf *pixbuf, *scaled_pixbuf;
1933 gdouble scale_w, scale_h, scale;
1935 cr = gtk_print_context_get_cairo_context(context);
1939 image = GTK_IMAGE(read_image(data->filename));
1940 pixbuf = gtk_image_get_pixbuf(image);
1943 g_object_ref(pixbuf);
1947 GtkIconTheme *def_theme = gtk_icon_theme_get_default ();
1949 g_warning(
"Filename '%s' cannot be read or understood.",
1952 pixbuf = gtk_icon_theme_load_icon (def_theme,
1955 GTK_ICON_LOOKUP_USE_BUILTIN,
1958 pix_w = gdk_pixbuf_get_width(pixbuf);
1959 pix_h = gdk_pixbuf_get_height(pixbuf);
1962 if (data->w && data->h)
1964 cairo_rectangle(cr, data->x, data->y - data->h, data->w, data->h);
1965 DEBUG(
"Picture clip rectangle, user coords %f,%f, user size %f,%f",
1966 data->x, data->y - data->h, data->w, data->h);
1970 cairo_rectangle(cr, data->x, data->y - pix_h, pix_w, pix_h);
1971 DEBUG(
"Picture clip rectangle, user coords %f,%f, pic size %d,%d",
1972 data->x, data->y - data->h, pix_w, pix_h);
1974 cairo_clip_preserve(cr);
1977 scale_w = scale_h = 1;
1978 if (data->w && (pix_w > data->w))
1979 scale_w = data->w / pix_w;
1980 if (data->h && (pix_h > data->h))
1981 scale_h = data->h / pix_h;
1982 scale = MIN(scale_w, scale_h);
1986 scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf, pix_w * scale,
1988 GDK_INTERP_BILINEAR);
1989 pix_h = gdk_pixbuf_get_height(scaled_pixbuf);
1990 gdk_cairo_set_source_pixbuf(cr, scaled_pixbuf, data->x,
1993 g_object_unref(scaled_pixbuf);
1997 gdk_cairo_set_source_pixbuf(cr, pixbuf, data->x, data->y - pix_h);
1999 g_object_unref(pixbuf);
2004 gtk_widget_destroy(GTK_WIDGET(image));
2008 #define DATE_FMT_HEIGHT 8 2009 #define DATE_FMT_SLOP 2 2024 draw_date_format(GtkPrintContext *context,
const gchar *date_format,
2025 check_item_t *data, PangoFontDescription *default_desc,
2028 PangoFontDescription *date_desc;
2029 check_item_t date_item;
2030 gchar *text = NULL, *expanded = NULL;
2034 setlocale(LC_ALL, NULL);
2035 if ( !data->print_date_format )
return;
2037 date_desc = pango_font_description_copy_static(default_desc);
2038 pango_font_description_set_size(date_desc, DATE_FMT_HEIGHT * PANGO_SCALE);
2040 date_item.y += (DATE_FMT_HEIGHT + DATE_FMT_SLOP);
2041 date_item.w = width;
2042 date_item.h = DATE_FMT_HEIGHT + DATE_FMT_SLOP;
2043 date_item.align = PANGO_ALIGN_CENTER;
2046 cdn_fmt = g_string_new_len(NULL, 50);
2047 for (c = date_format; c && *c; )
2049 if ((c[0] !=
'%') || (c[1] ==
'\0'))
2057 cdn_fmt = g_string_append(cdn_fmt,
"YYYYMMDD");
2060 cdn_fmt = g_string_append(cdn_fmt,
"YYYY");
2063 cdn_fmt = g_string_append(cdn_fmt,
"YY");
2066 cdn_fmt = g_string_append(cdn_fmt,
"MM");
2070 cdn_fmt = g_string_append(cdn_fmt,
"DD");
2073 expanded = g_strdup_printf(
"%s%s",
2084 text = g_string_free(cdn_fmt, FALSE);
2085 draw_text(context, text, &date_item, date_desc);
2089 pango_font_description_free(date_desc);
2097 draw_page_items(GtkPrintContext *context,
2100 PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
2101 PangoFontDescription *default_desc;
2105 const gchar *date_format;
2106 gchar *text = NULL, buf[100];
2110 gchar *address = NULL;
2114 g_return_if_fail(trans);
2118 default_desc = pango_font_description_from_string(format->
font);
2120 default_desc = pango_font_description_from_string(pcd->default_font);
2123 for (elem = format->
items; elem; elem = g_slist_next(elem))
2132 g_date_clear (&date, 1);
2135 gnc_date_format_get_custom(GNC_DATE_FORMAT
2136 (pcd->date_format));
2137 g_date_strftime(buf, 100, date_format, &date);
2138 width = draw_text(context, buf, item, default_desc);
2139 draw_date_format(context, date_format, item, default_desc, width);
2156 draw_text(context, gnc_get_action_num(trans, pcd->split), item,
2161 draw_text(context, gnc_get_num_action(trans, pcd->split), item,
2166 info = gnc_default_print_info(FALSE);
2168 item, default_desc);
2172 text = numeric_to_words(amount);
2173 draw_text(context, text, item, default_desc);
2178 draw_text(context, item->text, item, default_desc);
2182 address = get_check_address(pcd);
2183 draw_text(context, address, item, default_desc);
2188 text = get_check_splits_amount(pcd);
2189 draw_text(context, text, item, default_desc);
2194 text = get_check_splits_memo(pcd);
2195 draw_text(context, text, item, default_desc);
2199 case SPLITS_ACCOUNT:
2200 text = get_check_splits_account(pcd);
2201 draw_text(context, text, item, default_desc);
2206 draw_picture(context, item);
2210 text = g_strdup_printf(
"(unknown check field, type %d)", item->type);
2211 draw_text(context, text, item, default_desc);
2217 pango_font_description_free(default_desc);
2225 draw_page_boxes(GtkPrintContext *context,
2232 cr = gtk_print_context_get_cairo_context(context);
2235 for (elem = format->
items; elem; elem = g_slist_next(elem))
2238 if (!item->w || !item->h)
2240 cairo_rectangle(cr, item->x, item->y - item->h, item->w, item->h);
2252 draw_check_format(GtkPrintContext *context, gint position,
2255 PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
2256 gdouble x, y, r, multip;
2257 cairo_t *cr = gtk_print_context_get_cairo_context(context);
2260 if ((position > 0) && (position < pcd->position_max))
2265 cairo_translate(cr, 0, format->
height);
2267 DEBUG(
"Position %d translated by %f relative to previous check (pre-defined)", position, format->
height);
2268 DEBUG(
" by %f relative to page (pre-defined)", position * format->
height);
2270 else if (position == pcd->position_max)
2273 multip = pcd_get_custom_multip(pcd);
2274 x = multip * gtk_spin_button_get_value(pcd->translation_x);
2275 y = multip * gtk_spin_button_get_value(pcd->translation_y);
2276 cairo_translate(cr, x, y);
2277 DEBUG(
"Position translated by %f,%f (custom)", x, y);
2278 r = gtk_spin_button_get_value(pcd->check_rotation);
2279 cairo_rotate(cr, r * DEGREES_TO_RADIANS);
2280 DEBUG(
"Position rotated by %f degrees (custom)", r);
2286 draw_page_boxes(context, format, user_data);
2289 draw_page_items(context, format, user_data);
2294 draw_check_custom(GtkPrintContext *context, gpointer user_data)
2296 PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
2298 PangoFontDescription *desc;
2302 const gchar *date_format;
2303 gchar *text = NULL, buf[100];
2304 check_item_t item = { 0 };
2305 gdouble x, y, multip, degrees;
2311 g_return_if_fail(trans);
2313 desc = pango_font_description_from_string(pcd->default_font);
2315 multip = pcd_get_custom_multip(pcd);
2316 degrees = gtk_spin_button_get_value(pcd->check_rotation);
2317 cr = gtk_print_context_get_cairo_context(context);
2318 cairo_rotate(cr, degrees * DEGREES_TO_RADIANS);
2319 DEBUG(
"Page rotated by %f degrees", degrees);
2321 x = multip * gtk_spin_button_get_value(pcd->translation_x);
2322 y = multip * gtk_spin_button_get_value(pcd->translation_y);
2323 cairo_translate(cr, x, y);
2324 DEBUG(
"Page translated by %f,%f", x, y);
2326 item.x = multip * gtk_spin_button_get_value(pcd->payee_x);
2327 item.y = multip * gtk_spin_button_get_value(pcd->payee_y);
2330 item.x = multip * gtk_spin_button_get_value(pcd->date_x);
2331 item.y = multip * gtk_spin_button_get_value(pcd->date_y);
2332 g_date_clear (&date, 1);
2334 date_format = gnc_date_format_get_custom(GNC_DATE_FORMAT(pcd->date_format));
2335 g_date_strftime(buf, 100, date_format, &date);
2336 draw_text(context, buf, &item, desc);
2338 item.x = multip * gtk_spin_button_get_value(pcd->number_x);
2339 item.y = multip * gtk_spin_button_get_value(pcd->number_y);
2340 info = gnc_default_print_info(FALSE);
2344 item.x = multip * gtk_spin_button_get_value(pcd->words_x);
2345 item.y = multip * gtk_spin_button_get_value(pcd->words_y);
2346 text = numeric_to_words(amount);
2347 draw_text(context, text, &item, desc);
2350 item.x = multip * gtk_spin_button_get_value(pcd->address_x);
2351 item.y = multip * gtk_spin_button_get_value(pcd->address_y);
2352 address = get_check_address(pcd);
2353 draw_text(context, address, &item, desc);
2356 item.x = multip * gtk_spin_button_get_value(pcd->splits_amount_x);
2357 item.y = multip * gtk_spin_button_get_value(pcd->splits_amount_y);
2358 text = get_check_splits_amount(pcd);
2359 draw_text(context, text, &item, desc);
2362 item.x = multip * gtk_spin_button_get_value(pcd->splits_memo_x);
2363 item.y = multip * gtk_spin_button_get_value(pcd->splits_memo_y);
2364 text = get_check_splits_memo(pcd);
2365 draw_text(context, text, &item, desc);
2368 item.x = multip * gtk_spin_button_get_value(pcd->splits_account_x);
2369 item.y = multip * gtk_spin_button_get_value(pcd->splits_account_y);
2370 text = get_check_splits_account(pcd);
2371 draw_text(context, text, &item, desc);
2374 item.x = multip * gtk_spin_button_get_value(pcd->notes_x);
2375 item.y = multip * gtk_spin_button_get_value(pcd->notes_y);
2378 item.x = multip * gtk_spin_button_get_value(pcd->memo_x);
2379 item.y = multip * gtk_spin_button_get_value(pcd->memo_y);
2382 pango_font_description_free(desc);
2391 draw_page(GtkPrintOperation *operation,
2392 GtkPrintContext *context, gint page_nr, gpointer user_data)
2394 PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
2396 cairo_t *cr = gtk_print_context_get_cairo_context(context);
2398 format = pcd->selected_format;
2401 gint first_check, last_check;
2402 gint first_page_count;
2403 guint check_count = g_list_length(pcd->splits);
2405 gint position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2406 gint last_blank_check_pos;
2407 gint checks_per_page;
2410 if (position == pcd->position_max)
2413 checks_per_page = 1;
2414 first_page_count = 1;
2418 checks_per_page = pcd->position_max;
2419 first_page_count = gtk_spin_button_get_value_as_int(pcd->first_page_count);
2425 last_check = first_page_count - 1;
2426 next_split = pcd->splits;
2430 first_check = first_page_count + (page_nr - 1) * checks_per_page;
2431 last_check = MIN(check_count - 1, first_check + checks_per_page - 1);
2432 next_split = g_list_nth(pcd->splits, first_check);
2434 if (position < pcd->position_max)
2441 cairo_rotate(cr, format->
rotation * DEGREES_TO_RADIANS);
2448 gtk_print_context_get_width(context),
2449 gtk_print_context_get_height(context),
2453 last_blank_check_pos = position - 1;
2456 && (last_blank_check_pos > 0)
2457 && (position < pcd->position_max))
2458 cairo_translate(cr, 0, format->
height * last_blank_check_pos);
2460 for (check_number = first_check; check_number <= last_check;
2461 check_number++, position++)
2463 pcd->split = (Split *) next_split->data;
2464 next_split = g_list_next(next_split);
2465 draw_check_format(context, position, format, user_data);
2471 pcd->split = (Split *) g_list_nth_data(pcd->splits, page_nr);
2472 g_return_if_fail(pcd->split);
2473 draw_check_custom(context, user_data);
2483 begin_print(GtkPrintOperation *operation,
2484 GtkPrintContext *context, gpointer user_data)
2486 PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
2487 guint check_count = g_list_length(pcd->splits);
2489 gint position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2491 if (pcd->selected_format
2492 && pcd->position_max > 1
2498 && position < pcd->position_max)
2502 gint first_page_count, remaining_count;
2504 first_page_count = gtk_spin_button_get_value_as_int(pcd->first_page_count);
2505 remaining_count = check_count - first_page_count;
2507 + remaining_count / pcd->position_max;
2509 if ((remaining_count % pcd->position_max) > 0)
2515 pages = check_count;
2516 gtk_print_operation_set_n_pages(operation, pages);
2524 gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog *pcd)
2526 GtkPrintOperation *print;
2527 GtkPrintOperationResult res;
2529 print = gtk_print_operation_new();
2532 gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
2533 gtk_print_operation_set_use_full_page(print, TRUE);
2534 g_signal_connect(print,
"begin_print", G_CALLBACK(begin_print), pcd);
2535 g_signal_connect(print,
"draw_page", G_CALLBACK(draw_page), pcd);
2537 res = gtk_print_operation_run(print,
2538 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
2539 pcd->caller_window, NULL);
2541 if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
2544 g_object_unref(print);
2549 gnc_print_check_set_sensitive (GtkWidget *widget, gpointer data)
2552 if (GTK_IS_LABEL(widget) || GTK_IS_SEPARATOR(widget))
2554 sensitive = GPOINTER_TO_INT(data);
2555 gtk_widget_set_sensitive(widget, sensitive);
2560 gnc_print_check_format_changed (GtkComboBox *widget,
2561 PrintCheckDialog *pcd)
2563 GtkListStore *p_store;
2564 GtkTreeModel *f_model;
2565 GtkTreeIter f_iter, iter;
2572 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(pcd->format_combobox), &f_iter))
2574 f_model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
2575 gtk_tree_model_get(f_model, &f_iter,
COL_DATA, &format,
COL_SEP, &separator, -1);
2579 pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2582 pcd->selected_format = format;
2583 p_store = gtk_list_store_new (1, G_TYPE_STRING);
2584 gtk_combo_box_set_model(GTK_COMBO_BOX(pcd->position_combobox),
2585 GTK_TREE_MODEL(p_store));
2590 pcd->position_max = g_slist_length(format->
positions);
2591 for (elem = format->
positions; elem; elem = g_slist_next(elem))
2593 gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
2594 gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, elem->data, -1);
2600 pcd->position_max = 1;
2601 gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
2602 gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _(
"Top"), -1);
2607 pcd->position_max = 0;
2609 gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
2610 gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _(
"Custom"), -1);
2611 g_object_unref (p_store);
2614 sensitive = (pcd->position_max > 0);
2615 gtk_widget_set_sensitive(GTK_WIDGET(pcd->position_combobox), sensitive);
2620 sensitive = (!separator && !format);
2621 gtk_container_foreach(GTK_CONTAINER(pcd->custom_table),
2622 gnc_print_check_set_sensitive,
2623 GINT_TO_POINTER(sensitive));
2627 pnum = MAX(MIN(pnum, pcd->position_max), 0);
2628 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->position_combobox), pnum);
2631 sensitive = check_format_has_address(pcd);
2632 gtk_widget_set_sensitive(pcd->check_address_name, sensitive);
2633 gtk_widget_set_sensitive(pcd->check_address_1, sensitive);
2634 gtk_widget_set_sensitive(pcd->check_address_2, sensitive);
2635 gtk_widget_set_sensitive(pcd->check_address_3, sensitive);
2636 gtk_widget_set_sensitive(pcd->check_address_4, sensitive);
2641 gnc_print_check_position_changed (GtkComboBox *widget,
2642 PrintCheckDialog *pcd)
2647 gint first_page_max, first_page_min, first_page_value;
2649 pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2652 sensitive = pnum == pcd->position_max;
2653 gtk_widget_set_sensitive(GTK_WIDGET(pcd->translation_x), sensitive);
2654 gtk_widget_set_sensitive(GTK_WIDGET(pcd->translation_y), sensitive);
2655 gtk_widget_set_sensitive(GTK_WIDGET(pcd->check_rotation), sensitive);
2656 gtk_widget_set_sensitive(GTK_WIDGET(pcd->units_combobox), sensitive);
2659 check_count = g_list_length(pcd->splits);
2660 first_page_max = MAX(1, MIN(pcd->position_max - pnum, check_count));
2662 pnum = gtk_spin_button_get_value_as_int(pcd->first_page_count);
2663 first_page_value = MAX(MIN(pnum, first_page_max), first_page_min);
2664 gtk_spin_button_set_range(pcd->first_page_count, (gdouble)first_page_min, (gdouble)first_page_max);
2665 gtk_spin_button_set_value(pcd->first_page_count, (gdouble)first_page_value);
2666 sensitive = first_page_max > 1;
2667 gtk_widget_set_sensitive(GTK_WIDGET(pcd->first_page_count), sensitive);
2672 gnc_ui_print_check_response_cb(GtkDialog *dialog,
2674 PrintCheckDialog *pcd)
2678 case GTK_RESPONSE_HELP:
2682 case GTK_RESPONSE_OK:
2683 gnc_ui_print_check_dialog_ok_cb(pcd);
2684 gnc_ui_print_save_dialog(pcd);
2685 gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog));
2688 case GTK_RESPONSE_CANCEL:
2689 gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog));
2693 gtk_widget_destroy(pcd->dialog);
2694 g_free(pcd->default_font);
2695 g_list_free(pcd->splits);
void guid_replace(GncGUID *guid)
Generate a new guid.
Used by the check printing code.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.
Date and Time handling routines.
gboolean gncOwnerGetOwnerFromTxn(Transaction *txn, GncOwner *owner)
Convenience function to get the owner from a transaction.
gchar * gnc_build_userdata_path(const gchar *filename)
Make a path to filename in the user's gnucash data directory.
utility functions for the GnuCash UI
An exact-rational-number library for gnucash.
#define DEBUG(format, args...)
Print a debugging message.
gboolean gnc_prefs_set_int(const gchar *group, const gchar *pref_name, gint value)
Store an integer value into the preferences backend.
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
GKeyFile helper routines.
void gnc_print_operation_save_print_settings(GtkPrintOperation *op)
Retrieve the print settings from the GtkPrintOperation op and save them in a static variable...
void gnc_prefs_reset(const gchar *group, const gchar *pref_name)
Reset a preference to its default value in the preferences backend.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
API for Transactions and Splits (journal entries)
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
gboolean gnc_prefs_set_string(const gchar *group, const gchar *pref_name, const gchar *value)
Store a string into the preferences backend.
const gchar * gnc_userdata_dir(void)
Ensure that the user's configuration directory exists and is minimally populated. ...
gint gnc_prefs_get_int(const gchar *group, const gchar *pref_name)
Get an integer value from the preferences backend.
gboolean gnc_key_file_save_to_file(const gchar *filename, GKeyFile *key_file, GError **error)
Write a key/value file from memory to disk.
const char * xaccTransGetNotes(const Transaction *trans)
Gets the transaction Notes.
gchar * gnc_get_account_name_for_register(const Account *account)
Get either the full name of the account or the simple name, depending on the configuration parameter ...
GList SplitList
GList of Split.
Functions providing a register page for the GnuCash UI.
void gnc_print_operation_init(GtkPrintOperation *op, const gchar *jobname)
If print settings have been saved by gnc_print_operation_save_print_settings(), then set them on the ...
This column holds a pointer to the check format data read in from a file.
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...
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
gboolean gnc_prefs_set_float(const gchar *group, const gchar *pref_name, gdouble value)
Store a float value into the preferences backend.
gboolean gnc_prefs_set_coords(const gchar *group, const gchar *pref_name, gdouble x, gdouble y)
Store coordinates into the preferences backend.
void gnc_prefs_get_coords(const gchar *group, const gchar *pref_name, gdouble *x, gdouble *y)
Get a pair of coordinates from the preferences backend.
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
gnc_numeric gnc_numeric_abs(gnc_numeric a)
Returns a newly created gnc_numeric that is the absolute value of the given gnc_numeric value...
All type declarations for the whole Gnucash engine.
Generic api to store and retrieve preferences.
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
FROM_STRING_DEC(CheckItemType, ENUM_CHECK_ITEM_TYPE)
File path resolution utility functions.
Take from locale information.
This column contains the value TRUE if this entry specifies a separator line.
GKeyFile * gnc_key_file_load_from_file(const gchar *filename, gboolean ignore_error, gboolean return_empty_struct, GError **caller_error)
Open and read a key/value file from disk into memory.
API for Transactions and Splits (journal entries)
const gchar * qof_date_format_get_string(QofDateFormat df)
This function returns a strftime formatting string for printing an all numeric date (e...
The type used to store guids in C.
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
This column holds a copy of the check format name and is what is displayed to the user in the combobo...
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.