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;
   283     GtkWidget *format_combobox;
   285     GtkWidget *position_combobox;
   287     GtkSpinButton *first_page_count;
   288     GtkWidget *custom_table;
   289     GtkSpinButton *payee_x, *payee_y;
   290     GtkSpinButton *date_x, *date_y;
   291     GtkSpinButton *words_x, *words_y;
   292     GtkSpinButton *number_x, *number_y;
   293     GtkSpinButton *address_x, *address_y;
   294     GtkSpinButton *notes_x, *notes_y;
   295     GtkSpinButton *memo_x, *memo_y;
   296     GtkSpinButton *splits_amount_x, *splits_amount_y;
   297     GtkSpinButton *splits_memo_x, *splits_memo_y;
   298     GtkSpinButton *splits_account_x, *splits_account_y;
   299     GtkSpinButton *translation_x, *translation_y;
   300     GtkSpinButton *check_rotation;
   301     GtkWidget *translation_label;
   303     GtkWidget *units_combobox;
   305     GtkWidget *date_format;
   307     GtkWidget *check_address_name;
   308     GtkWidget *check_address_1;
   309     GtkWidget *check_address_2;
   310     GtkWidget *check_address_3;
   311     GtkWidget *check_address_4;
   325 find_existing_format (GtkListStore *store, gchar *guid, GtkTreeIter *iter_out)
   330     g_return_val_if_fail(store, NULL);
   331     g_return_val_if_fail(guid, NULL);
   333     if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
   338         gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
   342         if (strcmp(format->
guid, guid) != 0)
   349     while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
   361 get_check_address( PrintCheckDialog *pcd)
   364     address = g_strconcat(gtk_entry_get_text(GTK_ENTRY(pcd->check_address_name)), 
"\n",
   365                           gtk_entry_get_text(GTK_ENTRY(pcd->check_address_1)), 
"\n",
   366                           gtk_entry_get_text(GTK_ENTRY(pcd->check_address_2)), 
"\n",
   367                           gtk_entry_get_text(GTK_ENTRY(pcd->check_address_3)), 
"\n",
   368                           gtk_entry_get_text(GTK_ENTRY(pcd->check_address_4)),
   375     const Transaction* trans;
   385     trans_amount->amount = gnc_numeric_add_fixed(trans_amount->amount, amount);
   391 get_check_amount(PrintCheckDialog *pcd)
   400         trans_amount.amount = gnc_numeric_zero();
   401         gnc_account_foreach_descendant(pcd->account, (AccountCb)subtotal_subaccount, &trans_amount);
   402         amount = trans_amount.amount;
   418 get_check_splits_amount(PrintCheckDialog *pcd)
   420     gchar* amount = NULL;
   427     if ( !s_list ) 
return NULL;
   429     amount = g_strconcat(
"", NULL);
   433         Split *split = node->data;
   435         if (split != pcd->split)
   437             const gchar* split_amount;
   441             if (amount && *amount)
   442                 amount = g_strconcat(amt_temp, 
"\n", split_amount, NULL);
   444                 amount = g_strconcat(amt_temp, split_amount, NULL);
   456 get_check_splits_memo(PrintCheckDialog *pcd)
   459     const gchar* split_memo;
   466     if ( !s_list ) 
return NULL;
   468     memo = g_strconcat(
"", NULL);
   472         Split *split = node->data;
   474         if (split != pcd->split)
   480                 memo = g_strconcat(memo_temp, 
"\n", split_memo, NULL);
   482                 memo = g_strconcat(memo_temp, split_memo, NULL);
   494 get_check_splits_account(PrintCheckDialog *pcd)
   496     gchar* account = NULL;
   503     if ( !s_list ) 
return NULL;
   505     account = g_strconcat(
"", NULL);
   509         Split *split = node->data;
   511         if (split != pcd->split)
   514             const gchar* aName = NULL;
   518             account_temp = account;
   519             if (account && *account)
   520                 account = g_strconcat(account_temp, 
"\n", aName, NULL);
   522                 account = g_strconcat(account_temp, aName, NULL);
   523             g_free(account_temp);
   535 check_format_has_address ( PrintCheckDialog *pcd )
   538     check_item_t *item = NULL;
   542     if ( !pcd ) 
return FALSE;
   545     if (g_list_length(pcd->splits) != 1)
   550     format = pcd->selected_format;
   551     if ( !format ) 
return TRUE;
   553     for (elem = pcd->selected_format->items; elem; elem = g_slist_next(elem))
   556         if ( item->type == ADDRESS ) 
return TRUE;
   563 gnc_ui_print_save_dialog(PrintCheckDialog *pcd)
   572     if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(pcd->format_combobox),
   575         model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
   576         gtk_tree_model_get(model, &iter, 
COL_DATA, &check, -1);
   578                               check ? check->
guid : 
"custom");
   580     active = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
   582     active = gtk_spin_button_get_value_as_int(pcd->first_page_count);
   584     active = gnc_date_format_get_format (GNC_DATE_FORMAT(pcd->date_format));
   588         format = gnc_date_format_get_custom (GNC_DATE_FORMAT(pcd->date_format));
   598                          gtk_spin_button_get_value(pcd->payee_x),
   599                          gtk_spin_button_get_value(pcd->payee_y));
   601                          gtk_spin_button_get_value(pcd->date_x),
   602                          gtk_spin_button_get_value(pcd->date_y));
   604                          gtk_spin_button_get_value(pcd->words_x),
   605                          gtk_spin_button_get_value(pcd->words_y));
   607                          gtk_spin_button_get_value(pcd->number_x),
   608                          gtk_spin_button_get_value(pcd->number_y));
   610                          gtk_spin_button_get_value(pcd->notes_x),
   611                          gtk_spin_button_get_value(pcd->notes_y));
   613                          gtk_spin_button_get_value(pcd->memo_x),
   614                          gtk_spin_button_get_value(pcd->memo_y));
   616                          gtk_spin_button_get_value(pcd->address_x),
   617                          gtk_spin_button_get_value(pcd->address_y));
   619                          gtk_spin_button_get_value(pcd->splits_amount_x),
   620                          gtk_spin_button_get_value(pcd->splits_amount_y));
   622                          gtk_spin_button_get_value(pcd->splits_memo_x),
   623                          gtk_spin_button_get_value(pcd->splits_memo_y));
   625                          gtk_spin_button_get_value(pcd->splits_account_x),
   626                          gtk_spin_button_get_value(pcd->splits_account_y));
   628                          gtk_spin_button_get_value(pcd->translation_x),
   629                          gtk_spin_button_get_value(pcd->translation_y));
   631                         gtk_spin_button_get_value(pcd->check_rotation));
   632     active = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->units_combobox));
   638 gnc_ui_print_restore_dialog(PrintCheckDialog *pcd)
   642     gchar *format, *guid;
   648     if (!(guid && *guid))
   649         gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
   650     else if (strcmp(guid, 
"custom") == 0)
   652         gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
   653                                  pcd->format_max - 1);
   657         model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
   658         if (find_existing_format(GTK_LIST_STORE(model), guid, &iter))
   660             gtk_combo_box_set_active_iter(GTK_COMBO_BOX(pcd->format_combobox), &iter);
   664             gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox), 0);
   673     if (active < 0 || active > pcd->position_max)
   675     gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->position_combobox), active);
   677     gtk_spin_button_set_value(pcd->first_page_count, (gdouble) active);
   679     gnc_date_format_set_format(GNC_DATE_FORMAT(pcd->date_format), active);
   683         if (format && *format)
   685             gnc_date_format_set_custom(GNC_DATE_FORMAT(pcd->date_format), format);
   692     gtk_spin_button_set_value(pcd->payee_x, x);
   693     gtk_spin_button_set_value(pcd->payee_y, y);
   696     gtk_spin_button_set_value(pcd->date_x, x);
   697     gtk_spin_button_set_value(pcd->date_y, y);
   699     gtk_spin_button_set_value(pcd->words_x, x);
   700     gtk_spin_button_set_value(pcd->words_y, y);
   702     gtk_spin_button_set_value(pcd->number_x, x);
   703     gtk_spin_button_set_value(pcd->number_y, y);
   705     gtk_spin_button_set_value(pcd->address_x, x);
   706     gtk_spin_button_set_value(pcd->address_y, y);
   708     gtk_spin_button_set_value(pcd->notes_x, x);
   709     gtk_spin_button_set_value(pcd->notes_y, y);
   711     gtk_spin_button_set_value(pcd->memo_x, x);
   712     gtk_spin_button_set_value(pcd->memo_y, y);
   714     gtk_spin_button_set_value(pcd->splits_amount_x, x);
   715     gtk_spin_button_set_value(pcd->splits_amount_y, y);
   717     gtk_spin_button_set_value(pcd->splits_memo_x, x);
   718     gtk_spin_button_set_value(pcd->splits_memo_y, y);
   720     gtk_spin_button_set_value(pcd->splits_account_x, x);
   721     gtk_spin_button_set_value(pcd->splits_account_y, y);
   723     gtk_spin_button_set_value(pcd->translation_x, x);
   724     gtk_spin_button_set_value(pcd->translation_y, y);
   726     gtk_spin_button_set_value(pcd->check_rotation, x);
   728     gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->units_combobox), active);
   733 pcd_get_custom_multip(PrintCheckDialog *pcd)
   737     selected = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->units_combobox));
   757 pcd_key_file_save_xy (GKeyFile *key_file, 
const gchar *group_name,
   758                       const gchar *key_name, gdouble multip,
   759                       GtkSpinButton *spin0, GtkSpinButton *spin1)
   763     dd[0] = multip * gtk_spin_button_get_value(spin0);
   764     dd[1] = multip * gtk_spin_button_get_value(spin1);
   767     dd[0] = round(dd[0] * 1000) / 1000;
   768     dd[1] = round(dd[1] * 1000) / 1000;
   769     g_key_file_set_double_list(key_file, group_name, key_name, dd, 2);
   778 pcd_key_file_save_item_xy (GKeyFile *key_file, 
int index,
   779                            CheckItemType type, gdouble multip,
   780                            GtkSpinButton *spin0, GtkSpinButton *spin1)
   783     key = g_strdup_printf(
"Type_%d", index);
   784     g_key_file_set_string(key_file, KF_GROUP_ITEMS, key,
   785                           CheckItemTypeasString(type));
   787     key = g_strdup_printf(
"Coords_%d", index);
   788     pcd_key_file_save_xy(key_file, KF_GROUP_ITEMS, key, multip, spin0, spin1);
   797 pcd_save_custom_data(PrintCheckDialog *pcd, 
const gchar *title)
   800     GError *error = NULL;
   806     gchar *filename, *pathname;
   808     multip = pcd_get_custom_multip(pcd);
   810     key_file = g_key_file_new();
   813     g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_GUID, buf);
   814     g_key_file_set_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE, title);
   815     g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, FALSE);
   816     g_key_file_set_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, FALSE);
   817     g_key_file_set_double(key_file, KF_GROUP_TOP, KF_KEY_ROTATION,
   818                           gtk_spin_button_get_value(pcd->check_rotation));
   819     pcd_key_file_save_xy(key_file, KF_GROUP_TOP, KF_KEY_TRANSLATION, multip,
   820                          pcd->translation_x, pcd->translation_y);
   822     pcd_key_file_save_item_xy(key_file, i++, PAYEE, multip,
   823                               pcd->payee_x, pcd->payee_y);
   824     pcd_key_file_save_item_xy(key_file, i++, DATE, multip,
   825                               pcd->date_x, pcd->date_y);
   826     pcd_key_file_save_item_xy(key_file, i++, AMOUNT_WORDS, multip,
   827                               pcd->words_x, pcd->words_y);
   828     pcd_key_file_save_item_xy(key_file, i++, AMOUNT_NUMBER, multip,
   829                               pcd->number_x, pcd->number_y);
   830     pcd_key_file_save_item_xy(key_file, i++, ADDRESS, multip,
   831                               pcd->address_x, pcd->address_y);
   832     pcd_key_file_save_item_xy(key_file, i++, NOTES, multip,
   833                               pcd->notes_x, pcd->notes_y);
   834     pcd_key_file_save_item_xy(key_file, i++, MEMO, multip,
   835                               pcd->memo_x, pcd->memo_y);
   836     pcd_key_file_save_item_xy(key_file, i++, SPLITS_AMOUNT, multip,
   837                               pcd->splits_amount_x, pcd->splits_amount_y);
   838     pcd_key_file_save_item_xy(key_file, i++, SPLITS_MEMO, multip,
   839                               pcd->splits_memo_x, pcd->splits_memo_y);
   840     pcd_key_file_save_item_xy(key_file, i++, SPLITS_ACCOUNT, multip,
   841                               pcd->splits_account_x, pcd->splits_account_y);
   843     filename = g_strconcat(title, CHECK_NAME_EXTENSION, NULL);
   851             initialize_format_combobox(pcd);
   853         gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->format_combobox),
   854                                  pcd->format_max - 1);
   858         dialog = gtk_message_dialog_new(GTK_WINDOW(pcd->dialog),
   859                                         GTK_DIALOG_DESTROY_WITH_PARENT,
   861                                         GTK_BUTTONS_CLOSE, 
"%s",
   862                                         _(
"Cannot save check format file."));
   863         gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
   864                                                  _(
"Cannot open file %s"),
   866         gtk_dialog_run(GTK_DIALOG(dialog));
   867         gtk_widget_destroy(dialog);
   878 gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button)
   883     text = gtk_entry_get_text(GTK_ENTRY(editable));
   884     sensitive = text && *text;
   885     gtk_widget_set_sensitive(ok_button, sensitive);
   894 gnc_print_check_save_button_clicked(GtkButton *unused, PrintCheckDialog *pcd)
   896     GtkWidget *dialog, *entry, *button;
   900     builder = gtk_builder_new();
   901     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"format_title_dialog");
   904     dialog = GTK_WIDGET(gtk_builder_get_object (builder, 
"format_title_dialog"));
   905     entry = GTK_WIDGET(gtk_builder_get_object (builder, 
"format_title"));
   906     button = GTK_WIDGET(gtk_builder_get_object (builder, 
"ok_button"));
   907     gnc_check_format_title_changed(GTK_EDITABLE(entry), button);
   908     gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pcd);
   910     gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pcd->dialog));
   911     if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
   913         gtk_widget_destroy(dialog);
   914         g_object_unref(G_OBJECT(builder));
   918     title = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
   919     gtk_widget_destroy (dialog);
   921     g_object_unref(G_OBJECT(builder));
   923     pcd_save_custom_data(pcd, title);
   932 doubles_to_string(gdouble *dd, gint len)
   937     str = g_string_new_len(NULL, 50);
   938     for (i = 0; i < len; i++)
   939         g_string_append_printf(str, 
"%f ", dd[i]);
   940     return g_string_free(str, FALSE);
   954 format_read_item_placement(
const gchar *file,
   957     check_item_t *data = NULL;
   958     GError *error = NULL;
   960     gchar *key, *value, *name;
   967     for (item_num = 1;; item_num++)
   971         data = g_new0(check_item_t, 1);
   976         key = g_strdup_printf(
"%s_%d", KF_KEY_TYPE, item_num);
   977         value = g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
   980             if ((error->domain == G_KEY_FILE_ERROR)
   981                     && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND))
   988         DEBUG(
"Check file %s, group %s, key %s, value: %s",
   989                 file, KF_GROUP_ITEMS, key, value);
   993         name = g_utf8_strup(value, -1);
   994         data->type = CheckItemTypefromString(name);
  1000         key = g_strdup_printf(
"%s_%d", KF_KEY_COORDS, item_num);
  1001         dd = g_key_file_get_double_list(key_file, KF_GROUP_ITEMS,
  1002                                         key, &dd_len, &error);
  1005         value = doubles_to_string(dd, dd_len);
  1006         DEBUG(
"Check file %s, group %s, key %s, length %"G_GSIZE_FORMAT
"; values: %s",
  1007                 file, KF_GROUP_ITEMS, key, dd_len, value);
  1023             (
"Check file %s, group %s, key %s, error: 2 or 4 values only",
  1024              file, KF_GROUP_ITEMS, key);
  1036         if (data->type != PICTURE)
  1038             key = g_strdup_printf(
"%s_%d", KF_KEY_FONT, item_num);
  1040                 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
  1043                 DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1044                         file, KF_GROUP_ITEMS, key, data->font);
  1048                 if (!((error->domain == G_KEY_FILE_ERROR)
  1049                         && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1050                     g_warning(
"Check file %s, group %s, key %s, error: %s",
  1051                               file, KF_GROUP_ITEMS, key, error->message);
  1052                 g_clear_error(&error);
  1056             key = g_strdup_printf(
"%s_%d", KF_KEY_ALIGN, item_num);
  1058                 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key, &error);
  1061                 DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1062                         file, KF_GROUP_ITEMS, key, value);
  1063                 name = g_utf8_strdown(value, -1);
  1064                 if (strcmp(name, 
"right") == 0)
  1065                     data->align = PANGO_ALIGN_RIGHT;
  1066                 else if (strcmp(name, 
"center") == 0)
  1067                     data->align = PANGO_ALIGN_CENTER;
  1069                     data->align = PANGO_ALIGN_LEFT;
  1075                 if (!((error->domain == G_KEY_FILE_ERROR)
  1076                         && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1077                     g_warning(
"Check file %s, group %s, key %s, error: %s",
  1078                               file, KF_GROUP_ITEMS, key, error->message);
  1079                 data->align = PANGO_ALIGN_LEFT;
  1080                 g_clear_error(&error);
  1084             key = g_strdup_printf(
"%s_%d", KF_KEY_BLOCKING, item_num);
  1086                 g_key_file_get_boolean(key_file, KF_GROUP_ITEMS, key, &error);
  1089                 DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1090                         file, KF_GROUP_ITEMS, key, bval);
  1091                 data->blocking = bval;
  1095                 if (!((error->domain == G_KEY_FILE_ERROR)
  1096                         && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1097                     g_warning(
"Check file %s, group %s, key %s, error: %s",
  1098                               file, KF_GROUP_ITEMS, key, error->message);
  1100                 g_clear_error(&error);
  1108             key = g_strdup_printf(
"%s_%d", KF_KEY_FILENAME, item_num);
  1110                 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key,
  1114             DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1115                     file, KF_GROUP_ITEMS, key, data->filename);
  1119             key = g_strdup_printf(
"%s_%d", KF_KEY_TEXT, item_num);
  1121                 g_key_file_get_string(key_file, KF_GROUP_ITEMS, key,
  1125             DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1126                     file, KF_GROUP_ITEMS, key, data->text);
  1131             key = g_strdup_printf(
"%s_%d", KF_KEY_DATE_FORMAT, item_num);
  1132             bval = g_key_file_get_boolean(key_file, KF_GROUP_ITEMS, key, &error);
  1135                 DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1136                         file, KF_GROUP_ITEMS, key, bval);
  1137                 data->print_date_format = bval;
  1141                 if (!((error->domain == G_KEY_FILE_ERROR)
  1142                         && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1143                     g_warning(
"Check file %s, group %s, key %s, error: %s",
  1144                               file, KF_GROUP_ITEMS, key, error->message);
  1146                 g_clear_error(&error);
  1154         list = g_slist_append(list, data);
  1162     g_warning(
"Check file %s, group %s, key %s, error: %s",
  1163               file, KF_GROUP_ITEMS, key, error->message);
  1166         g_error_free(error);
  1178 format_free_item_placement(check_item_t *data)
  1185         g_free(data->filename);
  1196 format_read_multicheck_info(
const gchar *file,
  1199     GError *error = NULL;
  1200     GSList *list = NULL;
  1201     gchar *key, **names;
  1205     key = g_strdup_printf(
"%s", KF_KEY_HEIGHT);
  1206     format->
height = g_key_file_get_double(key_file, KF_GROUP_POS, key, &error);
  1209         if ((error->domain == G_KEY_FILE_ERROR)
  1210                 && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
  1211                     || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1213             g_clear_error(&error);
  1218             g_warning(
"Check file %s, error reading group %s, key %s: %s",
  1219                       file, KF_GROUP_POS, key, error->message);
  1225     names = g_key_file_get_string_list(key_file, KF_GROUP_POS, KF_KEY_NAMES,
  1229         if ((error->domain == G_KEY_FILE_ERROR)
  1230                 && ((error->code == G_KEY_FILE_ERROR_GROUP_NOT_FOUND)
  1231                     || (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1237         g_warning(
"Check file %s, error reading group %s, key %s: %s",
  1238                   file, KF_GROUP_POS, key, error->message);
  1243     for (i = 0; i < length; i++)
  1244         list = g_slist_append(list, g_strdup(names[i]));
  1254 free_check_position(gchar *name)
  1265 format_read_general_info(
const gchar *file,
  1268     GError *error = NULL;
  1274     value = g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_GUID, &error);
  1277         g_warning(
"Check file %s, group %s, key %s, error: %s",
  1278                   file, KF_GROUP_TOP, KF_KEY_GUID, error->message);
  1279         g_error_free(error);
  1282     parts = g_strsplit(value, 
"-", -1);
  1283     format->
guid = g_strjoinv(
"", parts);
  1285     DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1286             file, KF_GROUP_TOP, KF_KEY_GUID, format->
guid);
  1289         g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_TITLE, &error);
  1292         DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1293                 file, KF_GROUP_TOP, KF_KEY_TITLE, format->
title);
  1297         g_warning(
"Check file %s, group %s, key %s, error: %s",
  1298                   file, KF_GROUP_TOP, KF_KEY_TITLE, error->message);
  1303         g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_BLOCKING,
  1307         DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1308                 file, KF_GROUP_TOP, KF_KEY_BLOCKING, format->
blocking);
  1312         if (!((error->domain == G_KEY_FILE_ERROR)
  1313                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1314             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1315                       file, KF_GROUP_TOP, KF_KEY_BLOCKING, error->message);
  1324         g_clear_error(&error);
  1328         g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_DATE_FORMAT,
  1332         DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1337         if (!((error->domain == G_KEY_FILE_ERROR)
  1338                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1339             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1340                       file, KF_GROUP_TOP, KF_KEY_DATE_FORMAT, error->message);
  1349         g_clear_error(&error);
  1353         g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_GRID,
  1357         DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1358                 file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, format->
show_grid);
  1362         if (!((error->domain == G_KEY_FILE_ERROR)
  1363                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1364             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1365                       file, KF_GROUP_TOP, KF_KEY_SHOW_GRID, error->message);
  1367         g_clear_error(&error);
  1371         g_key_file_get_boolean(key_file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES,
  1375         DEBUG(
"Check file %s, group %s, key %s, value: %d",
  1376                 file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, format->
show_boxes);
  1380         if (!((error->domain == G_KEY_FILE_ERROR)
  1381                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1382             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1383                       file, KF_GROUP_TOP, KF_KEY_SHOW_BOXES, error->message);
  1385         g_clear_error(&error);
  1389         g_key_file_get_string(key_file, KF_GROUP_TOP, KF_KEY_FONT, &error);
  1392         DEBUG(
"Check file %s, group %s, key %s, value: %s",
  1393                 file, KF_GROUP_TOP, KF_KEY_FONT, format->
font);
  1397         if (!((error->domain == G_KEY_FILE_ERROR)
  1398                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1399             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1400                       file, KF_GROUP_TOP, KF_KEY_FONT, error->message);
  1401         g_clear_error(&error);
  1405         g_key_file_get_double(key_file, KF_GROUP_TOP, KF_KEY_ROTATION, &error);
  1408         DEBUG(
"Check file %s, group %s, key %s, value: %f",
  1409                 file, KF_GROUP_TOP, KF_KEY_ROTATION, format->
rotation);
  1413         if (!((error->domain == G_KEY_FILE_ERROR)
  1414                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1415             g_warning(
"Check file %s, group %s, key %s, error: %s",
  1416                       file, KF_GROUP_TOP, KF_KEY_ROTATION, error->message);
  1418         g_clear_error(&error);
  1421     dd = g_key_file_get_double_list(key_file, KF_GROUP_TOP, KF_KEY_TRANSLATION,
  1425         value = doubles_to_string(dd, dd_len);
  1426         DEBUG(
"Check file %s, group %s, key %s, length %"G_GSIZE_FORMAT
"; values: %s",
  1427                 file, KF_GROUP_TOP, KF_KEY_TRANSLATION, dd_len, value);
  1437             g_warning(
"Check file %s, error top %s, key %s: 2 values only",
  1438                       file, KF_GROUP_TOP, KF_KEY_TRANSLATION);
  1444         if (!((error->domain == G_KEY_FILE_ERROR)
  1445                 && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)))
  1446             g_warning(
"Check file %s, group top %s, key %s: %s",
  1447                       file, KF_GROUP_ITEMS, KF_KEY_TRANSLATION, error->message);
  1448         g_clear_error(&error);
  1460     g_return_if_fail(data);
  1462     g_free(data->filename);
  1463     g_free(data->title);
  1465     g_slist_foreach(data->positions, (GFunc) free_check_position, NULL);
  1466     g_slist_free(data->positions);
  1467     g_slist_foreach(data->items, (GFunc) format_free_item_placement, NULL);
  1468     g_slist_free(data->items);
  1478 read_one_check_format(PrintCheckDialog *pcd, 
const gchar *groupname,
  1479                       const gchar *dirname, 
const gchar *file)
  1485     pathname = g_build_filename(dirname, file, (
char *)NULL);
  1490         g_warning(
"Check file %s, cannot load file", file);
  1495     format->
group = groupname;
  1497     if (format_read_general_info(file, key_file, format))
  1499         format->
positions = format_read_multicheck_info(file, key_file, format);
  1500         format->
items = format_read_item_placement(file, key_file, format);
  1503     g_key_file_free(key_file);
  1504     if ((NULL == format->
title) || (NULL == format->
items))
  1506         g_warning(
"Check file %s, no items read. Dropping file.", file);
  1507         free_check_format(format);
  1520 read_one_check_directory(PrintCheckDialog *pcd, GtkListStore *store,
  1521                          const gchar *groupname, 
const gchar *dirname)
  1525     const gchar *filename;
  1528     gboolean found = FALSE;
  1530     dir = g_dir_open(dirname, 0, NULL);
  1534     while ((filename = g_dir_read_name(dir)) != NULL)
  1536         if (g_str_has_prefix(filename, 
"#"))
  1538         if (!g_str_has_suffix(filename, 
".chk"))
  1541         format = read_one_check_format(pcd, groupname, dirname, filename);
  1545         existing = find_existing_format(store, format->
guid, NULL);
  1548             dialog = gtk_message_dialog_new
  1549                      (GTK_WINDOW(pcd->dialog),
  1550                       GTK_DIALOG_DESTROY_WITH_PARENT,
  1551                       GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, 
"%s",
  1552                       _(
"There is a duplicate check format file."));
  1553             gtk_message_dialog_format_secondary_text
  1554             (GTK_MESSAGE_DIALOG(dialog),
  1561              _(
"The GUIDs in the %s check format file '%s' and "  1562                "the %s check format file '%s' match."),
  1563              existing->group, existing->filename,
  1565             gtk_dialog_run(GTK_DIALOG(dialog));
  1566             gtk_widget_destroy(dialog);
  1567             free_check_format (format);
  1571             gtk_list_store_append(store, &iter);
  1583         gtk_list_store_append(store, &iter);
  1584         gtk_list_store_set(store, &iter, 
COL_SEP, TRUE, -1);
  1594 read_formats(PrintCheckDialog *pcd, GtkListStore *store)
  1596     gchar *dirname, *pkgdatadir;
  1598     pkgdatadir = gnc_path_get_pkgdatadir();
  1599     dirname = g_build_filename(pkgdatadir, CHECK_FMT_DIR, (
char *)NULL);
  1603     read_one_check_directory(pcd, store, _(
"application"), dirname);
  1611     read_one_check_directory(pcd, store, _(
"user"), dirname);
  1617 format_is_a_separator (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
  1621     gtk_tree_model_get(model, iter, 
COL_SEP, &separator, -1);
  1627 initialize_format_combobox (PrintCheckDialog *pcd)
  1629     GtkListStore *store;
  1632     store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
  1633     read_formats(pcd, store);
  1634     gtk_list_store_append(store, &iter);
  1635     gtk_list_store_set(store, &iter, 
COL_NAME, _(
"Custom"), -1);
  1636     pcd->format_max = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL);
  1637     gtk_combo_box_set_model(GTK_COMBO_BOX(pcd->format_combobox),
  1638                             GTK_TREE_MODEL(store));
  1639     gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(pcd->format_combobox),
  1640                                          format_is_a_separator, NULL, NULL);
  1641     g_object_unref (store);
  1652 gnc_ui_print_check_dialog_create(GtkWidget *parent,
  1656     PrintCheckDialog *pcd;
  1657     GtkBuilder *builder;
  1660     Transaction *trans = NULL;
  1662     pcd = g_new0(PrintCheckDialog, 1);
  1663     pcd->caller_window = GTK_WINDOW(parent);
  1664     pcd->splits = g_list_copy(splits);
  1665     pcd->account = account;
  1667     builder = gtk_builder_new();
  1668     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment1");
  1669     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment2");
  1670     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment3");
  1671     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment4");
  1672     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment5");
  1673     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment6");
  1674     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment7");
  1675     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment8");
  1676     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment9");
  1677     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment10");
  1678     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment11");
  1679     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment12");
  1680     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment13");
  1681     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment14");
  1682     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment15");
  1683     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment16");
  1684     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment17");
  1685     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment18");
  1686     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment19");
  1687     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment20");
  1688     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment21");
  1689     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment22");
  1690     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment23");
  1691     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"adjustment24");
  1692     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"liststore1");
  1693     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"liststore2");
  1694     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"liststore3");
  1695     gnc_builder_add_from_file (builder, 
"dialog-print-check.glade", 
"print_check_dialog");
  1697     gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pcd);
  1699     pcd->builder = builder;
  1700     pcd->dialog = GTK_WIDGET(gtk_builder_get_object (builder, 
"print_check_dialog"));
  1703     gtk_widget_set_name (GTK_WIDGET(pcd->dialog), 
"gnc-id-print-check");
  1706     pcd->format_combobox = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_format_combobox"));
  1707     pcd->position_combobox = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_position_combobox"));
  1708     pcd->first_page_count = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"first_page_count_entry"));
  1710     pcd->custom_table = GTK_WIDGET(gtk_builder_get_object (builder, 
"custom_table"));
  1711     pcd->payee_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"payee_x_entry"));
  1712     pcd->payee_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"payee_y_entry"));
  1713     pcd->date_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"date_x_entry"));
  1714     pcd->date_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"date_y_entry"));
  1715     pcd->words_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"amount_words_x_entry"));
  1716     pcd->words_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"amount_words_y_entry"));
  1717     pcd->number_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"amount_numbers_x_entry"));
  1718     pcd->number_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"amount_numbers_y_entry"));
  1719     pcd->notes_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"notes_x_entry"));
  1720     pcd->notes_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"notes_y_entry"));
  1721     pcd->memo_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"memo_x_entry"));
  1722     pcd->memo_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"memo_y_entry"));
  1723     pcd->address_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"address_x_entry"));
  1724     pcd->address_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"address_y_entry"));
  1725     pcd->splits_amount_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_amount_x_entry"));
  1726     pcd->splits_amount_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_amount_y_entry"));
  1727     pcd->splits_memo_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_memo_x_entry"));
  1728     pcd->splits_memo_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_memo_y_entry"));
  1729     pcd->splits_account_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_account_x_entry"));
  1730     pcd->splits_account_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"splits_account_y_entry"));
  1731     pcd->translation_x = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"translation_x_entry"));
  1732     pcd->translation_y = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"translation_y_entry"));
  1733     pcd->translation_label = GTK_WIDGET(gtk_builder_get_object (builder, 
"translation_label"));
  1734     pcd->check_rotation = GTK_SPIN_BUTTON(gtk_builder_get_object (builder, 
"check_rotation_entry"));
  1735     pcd->units_combobox = GTK_WIDGET(gtk_builder_get_object (builder, 
"units_combobox"));
  1737     gtk_window_set_transient_for(GTK_WINDOW(pcd->dialog), pcd->caller_window);
  1740     table = GTK_WIDGET(gtk_builder_get_object (builder, 
"options_table"));
  1741     pcd->date_format = gnc_date_format_new_without_label();
  1742     gtk_grid_attach (GTK_GRID(
table), pcd->date_format, 1, 4, 1, 1);
  1746     pcd->default_font = font && *font ? font : g_strdup(DEFAULT_FONT);
  1749     initialize_format_combobox(pcd);
  1752     pcd->check_address_name = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_address_name"));
  1753     pcd->check_address_1 = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_address_1"));
  1754     pcd->check_address_2 = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_address_2"));
  1755     pcd->check_address_3 = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_address_3"));
  1756     pcd->check_address_4 = GTK_WIDGET(gtk_builder_get_object (builder, 
"check_address_4"));
  1760     if (g_list_length(pcd->splits) == 1)
  1771             gtk_entry_set_text(GTK_ENTRY(pcd->check_address_name), gncOwnerGetName(&owner));
  1772             gtk_entry_set_text(GTK_ENTRY(pcd->check_address_1), gncAddressGetAddr1 (gncOwnerGetAddr(&owner)));
  1773             gtk_entry_set_text(GTK_ENTRY(pcd->check_address_2), gncAddressGetAddr2 (gncOwnerGetAddr(&owner)));
  1774             gtk_entry_set_text(GTK_ENTRY(pcd->check_address_3), gncAddressGetAddr3 (gncOwnerGetAddr(&owner)));
  1775             gtk_entry_set_text(GTK_ENTRY(pcd->check_address_4), gncAddressGetAddr4 (gncOwnerGetAddr(&owner)));
  1780     if ( trans && (0 == gtk_entry_get_text_length (GTK_ENTRY(pcd->check_address_name))) )
  1783     gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, 
"lower_left")));
  1785     gnc_ui_print_restore_dialog(pcd);
  1786     gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(pcd->dialog), GTK_WINDOW (parent));
  1788     g_object_unref(G_OBJECT(builder));
  1789     gtk_widget_show_all(pcd->dialog);
  1801 draw_grid(GtkPrintContext *context, gint width, gint height, 
const gchar *font)
  1803     const double dash_pattern[2] = { 1.0, 5.0 };
  1804     PangoFontDescription *desc;
  1805     PangoLayout *layout;
  1811     layout = gtk_print_context_create_pango_layout(context);
  1812     desc = pango_font_description_from_string(font);
  1813     pango_layout_set_font_description(layout, desc);
  1814     pango_font_description_free(desc);
  1815     pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
  1816     pango_layout_set_width(layout, -1);
  1819     cr = gtk_print_context_get_cairo_context(context);
  1821     cairo_set_line_width(cr, 1.0);
  1822     cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
  1823     cairo_set_dash(cr, dash_pattern, 2, 0);
  1826     for (i = -200; i < (height + 200); i += 50)
  1828         text = g_strdup_printf(
"%d", (
int)i);
  1829         cairo_move_to(cr, -200, i);
  1830         cairo_line_to(cr, width + 200, i);
  1832         pango_layout_set_text(layout, text, -1);
  1833         cairo_move_to(cr, 0, i);
  1834         pango_cairo_show_layout(cr, layout);
  1839     for (i = -200; i < (width + 200); i += 50)
  1841         text = g_strdup_printf(
"%d", (
int)i);
  1842         cairo_move_to(cr, i, -200);
  1843         cairo_line_to(cr, i, height + 200);
  1845         pango_layout_set_text(layout, text, -1);
  1846         cairo_move_to(cr, i, 0);
  1847         pango_cairo_show_layout(cr, layout);
  1853     g_object_unref(layout);
  1863 draw_text(GtkPrintContext *context, 
const gchar *text, check_item_t *data,
  1864           PangoFontDescription *default_desc)
  1866     PangoFontDescription *desc;
  1867     PangoLayout *layout;
  1869     gint layout_height, layout_width;
  1870     gdouble width, height;
  1873     if ((NULL == text) || (strlen(text) == 0))
  1877     layout = gtk_print_context_create_pango_layout(context);
  1880         desc = pango_font_description_from_string(data->font);
  1881         pango_layout_set_font_description(layout, desc);
  1882         pango_font_description_free(desc);
  1886         pango_layout_set_font_description(layout, default_desc);
  1888     pango_layout_set_alignment(layout,
  1889                                data->w ? data->align : PANGO_ALIGN_LEFT);
  1890     pango_layout_set_width(layout, data->w ? data->w * PANGO_SCALE : -1);
  1891     pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
  1892     if ( data->blocking )
  1894         new_text = g_strdup_printf(
"***%s***", text);
  1895         pango_layout_set_text(layout, new_text, -1);
  1900         pango_layout_set_text(layout, text, -1);
  1902     pango_layout_get_size(layout, &layout_width, &layout_height);
  1903     width = (gdouble) layout_width / PANGO_SCALE;
  1904     height = (gdouble) layout_height / PANGO_SCALE;
  1906     cr = gtk_print_context_get_cairo_context(context);
  1910     if (data->w && data->h)
  1912         DEBUG(
"Text clip rectangle, coords %f,%f, size %f,%f",
  1913                 data->x, data->y - data->h, data->w, data->h);
  1914         cairo_rectangle(cr, data->x, data->y - data->h, data->w, data->h);
  1915         cairo_clip_preserve(cr);
  1919     DEBUG(
"Text move to %f,%f, print '%s'", data->x, data->y,
  1920             text ? text : 
"(null)");
  1921     cairo_move_to(cr, data->x, data->y - height);
  1922     pango_cairo_show_layout(cr, layout);
  1926     g_object_unref(layout);
  1942 read_image (
const gchar *filename)
  1945     gchar *pkgdatadir, *dirname, *tmp_name;
  1947     if (g_path_is_absolute(filename))
  1948         return gtk_image_new_from_file(filename);
  1950     pkgdatadir = gnc_path_get_pkgdatadir();
  1951     tmp_name = g_build_filename(pkgdatadir, CHECK_FMT_DIR, filename, (
char *)NULL);
  1952     if (!g_file_test(tmp_name, G_FILE_TEST_EXISTS))
  1956         tmp_name = g_build_filename(dirname, filename, (
char *)NULL);
  1959     image = gtk_image_new_from_file(tmp_name);
  1970 draw_picture(GtkPrintContext *context, check_item_t *data)
  1973     GdkPixbuf *pixbuf, *scaled_pixbuf;
  1976     gdouble scale_w, scale_h, scale;
  1978     cr = gtk_print_context_get_cairo_context(context);
  1982     image = GTK_IMAGE(read_image(data->filename));
  1983     pixbuf = gtk_image_get_pixbuf(image);
  1986         g_object_ref(pixbuf);
  1990         GtkIconTheme *def_theme = gtk_icon_theme_get_default ();
  1992         g_warning(
"Filename '%s' cannot be read or understood.",
  1995         pixbuf = gtk_icon_theme_load_icon (def_theme,
  1998                           GTK_ICON_LOOKUP_USE_BUILTIN,
  2001     pix_w = gdk_pixbuf_get_width(pixbuf);
  2002     pix_h = gdk_pixbuf_get_height(pixbuf);
  2005     if (data->w && data->h)
  2007         cairo_rectangle(cr, data->x, data->y - data->h, data->w, data->h);
  2008         DEBUG(
"Picture clip rectangle, user coords %f,%f, user size %f,%f",
  2009                 data->x, data->y - data->h, data->w, data->h);
  2013         cairo_rectangle(cr, data->x, data->y - pix_h, pix_w, pix_h);
  2014         DEBUG(
"Picture clip rectangle, user coords %f,%f, pic size %d,%d",
  2015                 data->x, data->y - data->h, pix_w, pix_h);
  2017     cairo_clip_preserve(cr);
  2020     scale_w = scale_h = 1;
  2021     if (data->w && (pix_w > data->w))
  2022         scale_w = data->w / pix_w;
  2023     if (data->h && (pix_h > data->h))
  2024         scale_h = data->h / pix_h;
  2025     scale = MIN(scale_w, scale_h);
  2029         scaled_pixbuf = gdk_pixbuf_scale_simple(pixbuf, pix_w * scale,
  2031                                                 GDK_INTERP_BILINEAR);
  2032         pix_h = gdk_pixbuf_get_height(scaled_pixbuf);
  2033         gdk_cairo_set_source_pixbuf(cr, scaled_pixbuf, data->x,
  2036         g_object_unref(scaled_pixbuf);
  2040         gdk_cairo_set_source_pixbuf(cr, pixbuf, data->x, data->y - pix_h);
  2042     g_object_unref(pixbuf);
  2047     gtk_widget_destroy(GTK_WIDGET(image));
  2051 #define DATE_FMT_HEIGHT 8  2052 #define DATE_FMT_SLOP   2  2067 draw_date_format(GtkPrintContext *context, 
const gchar *date_format,
  2068                  check_item_t *data, PangoFontDescription *default_desc,
  2071     PangoFontDescription *date_desc;
  2072     check_item_t date_item;
  2073     gchar *text = NULL, *expanded = NULL;
  2077     if ( !data->print_date_format ) 
return;
  2079     date_desc = pango_font_description_copy_static(default_desc);
  2080     pango_font_description_set_size(date_desc, DATE_FMT_HEIGHT * PANGO_SCALE);
  2082     date_item.y += (DATE_FMT_HEIGHT + DATE_FMT_SLOP);
  2083     date_item.w = width;
  2084     date_item.h = DATE_FMT_HEIGHT + DATE_FMT_SLOP;
  2085     date_item.align = PANGO_ALIGN_CENTER;
  2088     cdn_fmt = g_string_new_len(NULL, 50);
  2089     for (c = date_format; c && *c; )
  2091         if ((c[0] != 
'%') || (c[1] == 
'\0'))
  2099             cdn_fmt = g_string_append(cdn_fmt, 
"YYYYMMDD");
  2102             cdn_fmt = g_string_append(cdn_fmt, 
"YYYY");
  2105             cdn_fmt = g_string_append(cdn_fmt, 
"YY");
  2108             cdn_fmt = g_string_append(cdn_fmt, 
"MM");
  2112             cdn_fmt = g_string_append(cdn_fmt, 
"DD");
  2115             expanded = g_strdup_printf(
"%s%s",
  2126     text = g_string_free(cdn_fmt, FALSE);
  2127     draw_text(context, text, &date_item, date_desc);
  2131     pango_font_description_free(date_desc);
  2139 draw_page_items(GtkPrintContext *context,
  2142     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
  2143     PangoFontDescription *default_desc;
  2147     const gchar *date_format;
  2148     gchar *text = NULL, buf[100];
  2152     gchar *address = NULL;
  2156     g_return_if_fail(trans);
  2157     amount = get_check_amount(pcd);
  2160         default_desc = pango_font_description_from_string(format->
font);
  2162         default_desc = pango_font_description_from_string(pcd->default_font);
  2165     for (elem = format->
items; elem; elem = g_slist_next(elem))
  2174             g_date_clear (&date, 1);
  2177                 gnc_date_format_get_custom(GNC_DATE_FORMAT
  2178                                            (pcd->date_format));
  2179             g_date_strftime(buf, 100, date_format, &date);
  2180             width = draw_text(context, buf, item, default_desc);
  2181             draw_date_format(context, date_format, item, default_desc, width);
  2198             draw_text(context, gnc_get_action_num(trans, pcd->split), item,
  2203             draw_text(context, gnc_get_num_action(trans, pcd->split), item,
  2208             info = gnc_default_print_info(FALSE);
  2210                       item, default_desc);
  2214             text = numeric_to_words(amount);
  2215             draw_text(context, text, item, default_desc);
  2220             draw_text(context, item->text, item, default_desc);
  2224             address = get_check_address(pcd);
  2225             draw_text(context, address, item, default_desc);
  2230             text = get_check_splits_amount(pcd);
  2231             draw_text(context, text, item, default_desc);
  2236             text = get_check_splits_memo(pcd);
  2237             draw_text(context, text, item, default_desc);
  2241         case SPLITS_ACCOUNT:
  2242             text = get_check_splits_account(pcd);
  2243             draw_text(context, text, item, default_desc);
  2248             draw_picture(context, item);
  2252             text = g_strdup_printf(
"(unknown check field, type %d)", item->type);
  2253             draw_text(context, text, item, default_desc);
  2259     pango_font_description_free(default_desc);
  2267 draw_page_boxes(GtkPrintContext *context,
  2274     cr = gtk_print_context_get_cairo_context(context);
  2277     for (elem = format->
items; elem; elem = g_slist_next(elem))
  2280         if (!item->w || !item->h)
  2282         cairo_rectangle(cr, item->x, item->y - item->h, item->w, item->h);
  2294 draw_check_format(GtkPrintContext *context, gint position,
  2297     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
  2298     gdouble x, y, r, multip;
  2299     cairo_t *cr = gtk_print_context_get_cairo_context(context);
  2302     if ((position > 0) && (position < pcd->position_max))
  2307         cairo_translate(cr, 0, format->
height); 
  2309         DEBUG(
"Position %d translated by %f relative to previous check (pre-defined)", position, format->
height);
  2310         DEBUG(
"                      by %f relative to page (pre-defined)", position * format->
height);
  2312     else if (position == pcd->position_max)
  2315         multip = pcd_get_custom_multip(pcd);
  2316         x = multip * gtk_spin_button_get_value(pcd->translation_x);
  2317         y = multip * gtk_spin_button_get_value(pcd->translation_y);
  2318         cairo_translate(cr, x, y);
  2319         DEBUG(
"Position translated by %f,%f (custom)", x, y);
  2320         r = gtk_spin_button_get_value(pcd->check_rotation);
  2321         cairo_rotate(cr, r * DEGREES_TO_RADIANS);
  2322         DEBUG(
"Position rotated by %f degrees (custom)", r);
  2328         draw_page_boxes(context, format, user_data);
  2331     draw_page_items(context, format, user_data);
  2336 draw_check_custom(GtkPrintContext *context, gpointer user_data)
  2338     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
  2340     PangoFontDescription *desc;
  2344     const gchar *date_format;
  2345     gchar *text = NULL, buf[100];
  2346     check_item_t item = { 0 };
  2347     gdouble x, y, multip, degrees;
  2353     g_return_if_fail(trans);
  2355     desc = pango_font_description_from_string(pcd->default_font);
  2357     multip = pcd_get_custom_multip(pcd);
  2358     degrees = gtk_spin_button_get_value(pcd->check_rotation);
  2359     cr = gtk_print_context_get_cairo_context(context);
  2360     cairo_rotate(cr, degrees * DEGREES_TO_RADIANS);
  2361     DEBUG(
"Page rotated by %f degrees", degrees);
  2363     x = multip * gtk_spin_button_get_value(pcd->translation_x);
  2364     y = multip * gtk_spin_button_get_value(pcd->translation_y);
  2365     cairo_translate(cr, x, y);
  2366     DEBUG(
"Page translated by %f,%f", x, y);
  2368     item.x = multip * gtk_spin_button_get_value(pcd->payee_x);
  2369     item.y = multip * gtk_spin_button_get_value(pcd->payee_y);
  2372     item.x = multip * gtk_spin_button_get_value(pcd->date_x);
  2373     item.y = multip * gtk_spin_button_get_value(pcd->date_y);
  2374     g_date_clear (&date, 1);
  2376     date_format = gnc_date_format_get_custom(GNC_DATE_FORMAT(pcd->date_format));
  2377     g_date_strftime(buf, 100, date_format, &date);
  2378     draw_text(context, buf, &item, desc);
  2380     item.x = multip * gtk_spin_button_get_value(pcd->number_x);
  2381     item.y = multip * gtk_spin_button_get_value(pcd->number_y);
  2382     info = gnc_default_print_info(FALSE);
  2386     item.x = multip * gtk_spin_button_get_value(pcd->words_x);
  2387     item.y = multip * gtk_spin_button_get_value(pcd->words_y);
  2388     text = numeric_to_words(amount);
  2389     draw_text(context, text, &item, desc);
  2392     item.x = multip * gtk_spin_button_get_value(pcd->address_x);
  2393     item.y = multip * gtk_spin_button_get_value(pcd->address_y);
  2394     address = get_check_address(pcd);
  2395     draw_text(context, address, &item, desc);
  2398     item.x = multip * gtk_spin_button_get_value(pcd->splits_amount_x);
  2399     item.y = multip * gtk_spin_button_get_value(pcd->splits_amount_y);
  2400     text = get_check_splits_amount(pcd);
  2401     draw_text(context, text, &item, desc);
  2404     item.x = multip * gtk_spin_button_get_value(pcd->splits_memo_x);
  2405     item.y = multip * gtk_spin_button_get_value(pcd->splits_memo_y);
  2406     text = get_check_splits_memo(pcd);
  2407     draw_text(context, text, &item, desc);
  2410     item.x = multip * gtk_spin_button_get_value(pcd->splits_account_x);
  2411     item.y = multip * gtk_spin_button_get_value(pcd->splits_account_y);
  2412     text = get_check_splits_account(pcd);
  2413     draw_text(context, text, &item, desc);
  2416     item.x = multip * gtk_spin_button_get_value(pcd->notes_x);
  2417     item.y = multip * gtk_spin_button_get_value(pcd->notes_y);
  2420     item.x = multip * gtk_spin_button_get_value(pcd->memo_x);
  2421     item.y = multip * gtk_spin_button_get_value(pcd->memo_y);
  2424     pango_font_description_free(desc);
  2433 draw_page(GtkPrintOperation *operation,
  2434           GtkPrintContext *context, gint page_nr, gpointer user_data)
  2436     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
  2438     cairo_t *cr = gtk_print_context_get_cairo_context(context);
  2440     format = pcd->selected_format;
  2443         gint    first_check, last_check;
  2444         gint    first_page_count;
  2445         guint   check_count = g_list_length(pcd->splits);
  2447         gint    position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
  2448         gint    last_blank_check_pos;
  2449         gint    checks_per_page;
  2452         if (position == pcd->position_max)
  2455             checks_per_page = 1;
  2456             first_page_count = 1;
  2460             checks_per_page = pcd->position_max;
  2461             first_page_count = gtk_spin_button_get_value_as_int(pcd->first_page_count);
  2467             last_check = first_page_count - 1;
  2468             next_split = pcd->splits;
  2472             first_check = first_page_count + (page_nr - 1) * checks_per_page;
  2473             last_check = MIN(check_count - 1, first_check + checks_per_page - 1);
  2474             next_split = g_list_nth(pcd->splits, first_check);
  2476             if (position < pcd->position_max)
  2483         cairo_rotate(cr, format->
rotation * DEGREES_TO_RADIANS);
  2490                       gtk_print_context_get_width(context),
  2491                       gtk_print_context_get_height(context),
  2495         last_blank_check_pos = position - 1;
  2498                 && (last_blank_check_pos > 0)      
  2499                 && (position < pcd->position_max)) 
  2500             cairo_translate(cr, 0, format->
height * last_blank_check_pos);
  2502         for (check_number = first_check; check_number <= last_check;
  2503                 check_number++, position++)
  2505             pcd->split = (Split *) next_split->data;
  2506             next_split = g_list_next(next_split);
  2507             draw_check_format(context, position, format, user_data);
  2513         pcd->split = (Split *) g_list_nth_data(pcd->splits, page_nr);
  2514         g_return_if_fail(pcd->split);
  2515         draw_check_custom(context, user_data);
  2525 begin_print(GtkPrintOperation *operation,
  2526             GtkPrintContext *context, gpointer user_data)
  2528     PrintCheckDialog *pcd = (PrintCheckDialog *) user_data;
  2529     guint check_count = g_list_length(pcd->splits);
  2531     gint position = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
  2533     if (pcd->selected_format 
  2534             && pcd->position_max > 1 
  2540             && position < pcd->position_max) 
  2544         gint first_page_count, remaining_count;
  2546         first_page_count = gtk_spin_button_get_value_as_int(pcd->first_page_count);
  2547         remaining_count = check_count - first_page_count;
  2549                 + remaining_count / pcd->position_max;
  2551         if ((remaining_count % pcd->position_max) > 0)
  2557         pages = check_count;
  2558     gtk_print_operation_set_n_pages(operation, pages);
  2566 gnc_ui_print_check_dialog_ok_cb(PrintCheckDialog *pcd)
  2568     GtkPrintOperation *print;
  2569     GtkPrintOperationResult res;
  2571     print = gtk_print_operation_new();
  2574     gtk_print_operation_set_unit(print, GTK_UNIT_POINTS);
  2575     gtk_print_operation_set_use_full_page(print, TRUE);
  2576     g_signal_connect(print, 
"begin_print", G_CALLBACK(begin_print), pcd);
  2577     g_signal_connect(print, 
"draw_page", G_CALLBACK(draw_page), pcd);
  2579     res = gtk_print_operation_run(print,
  2580                                   GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
  2581                                   pcd->caller_window, NULL);
  2583     if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
  2586     g_object_unref(print);
  2591 gnc_print_check_set_sensitive (GtkWidget *widget, gpointer data)
  2594     if (GTK_IS_LABEL(widget) || GTK_IS_SEPARATOR(widget))
  2596     sensitive = GPOINTER_TO_INT(data);
  2597     gtk_widget_set_sensitive(widget, sensitive);
  2602 gnc_print_check_format_changed (GtkComboBox *widget,
  2603                                 PrintCheckDialog *pcd)
  2605     GtkListStore *p_store;
  2606     GtkTreeModel *f_model;
  2607     GtkTreeIter f_iter, iter;
  2614     if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(pcd->format_combobox), &f_iter))
  2616     f_model = gtk_combo_box_get_model(GTK_COMBO_BOX(pcd->format_combobox));
  2617     gtk_tree_model_get(f_model, &f_iter, 
COL_DATA, &format, 
COL_SEP, &separator, -1);
  2621     pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
  2624     pcd->selected_format = format;
  2625     p_store = gtk_list_store_new (1, G_TYPE_STRING);
  2626     gtk_combo_box_set_model(GTK_COMBO_BOX(pcd->position_combobox),
  2627                             GTK_TREE_MODEL(p_store));
  2632             pcd->position_max = g_slist_length(format->
positions); 
  2633             for (elem = format->
positions; elem; elem = g_slist_next(elem))
  2635                 gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
  2636                 gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, elem->data, -1);
  2642             pcd->position_max = 1;
  2643             gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
  2644             gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _(
"Top"), -1);
  2649         pcd->position_max = 0;
  2651     gtk_list_store_append(GTK_LIST_STORE(p_store), &iter);
  2652     gtk_list_store_set (GTK_LIST_STORE(p_store), &iter, 0, _(
"Custom"), -1);
  2653     g_object_unref (p_store);
  2656     sensitive = (pcd->position_max > 0);
  2657     gtk_widget_set_sensitive(GTK_WIDGET(pcd->position_combobox), sensitive);
  2662     sensitive = (!separator && !format);
  2663     gtk_container_foreach(GTK_CONTAINER(pcd->custom_table),
  2664                           gnc_print_check_set_sensitive,
  2665                           GINT_TO_POINTER(sensitive));
  2669     pnum = MAX(MIN(pnum, pcd->position_max), 0);
  2670     gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->position_combobox), pnum);
  2673     sensitive = check_format_has_address(pcd);
  2674     gtk_widget_set_sensitive(pcd->check_address_name, sensitive);
  2675     gtk_widget_set_sensitive(pcd->check_address_1, sensitive);
  2676     gtk_widget_set_sensitive(pcd->check_address_2, sensitive);
  2677     gtk_widget_set_sensitive(pcd->check_address_3, sensitive);
  2678     gtk_widget_set_sensitive(pcd->check_address_4, sensitive);
  2683 gnc_print_check_position_changed (GtkComboBox *widget,
  2684                                   PrintCheckDialog *pcd)
  2689     gint first_page_max, first_page_min, first_page_value;
  2691     pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
  2694     sensitive = pnum == pcd->position_max;
  2695     gtk_widget_set_sensitive(GTK_WIDGET(pcd->translation_x), sensitive);
  2696     gtk_widget_set_sensitive(GTK_WIDGET(pcd->translation_y), sensitive);
  2697     gtk_widget_set_sensitive(GTK_WIDGET(pcd->check_rotation), sensitive);
  2698     gtk_widget_set_sensitive(GTK_WIDGET(pcd->units_combobox), sensitive);
  2701     check_count = g_list_length(pcd->splits);
  2702     first_page_max = MAX(1, MIN(pcd->position_max - pnum, check_count));
  2704     pnum = gtk_spin_button_get_value_as_int(pcd->first_page_count);
  2705     first_page_value = MAX(MIN(pnum, first_page_max), first_page_min);
  2706     gtk_spin_button_set_range(pcd->first_page_count, (gdouble)first_page_min, (gdouble)first_page_max);
  2707     gtk_spin_button_set_value(pcd->first_page_count, (gdouble)first_page_value);
  2708     sensitive = first_page_max > 1;
  2709     gtk_widget_set_sensitive(GTK_WIDGET(pcd->first_page_count), sensitive);
  2714 gnc_ui_print_check_response_cb(GtkDialog *dialog,
  2716                                PrintCheckDialog *pcd)
  2720     case GTK_RESPONSE_HELP:
  2724     case GTK_RESPONSE_OK:
  2725         gnc_ui_print_check_dialog_ok_cb(pcd);
  2726         gnc_ui_print_save_dialog(pcd);
  2727         gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog));
  2730     case GTK_RESPONSE_CANCEL:
  2731         gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog));
  2735     gtk_widget_destroy(pcd->dialog);
  2736     g_free(pcd->default_font);
  2737     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. 
 
char * 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. 
 
gnc_numeric xaccTransGetAccountAmount(const Transaction *trans, const Account *acc)
Same as xaccTransGetAccountValue, but uses the Account's commodity. 
 
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.