GnuCash 7574033+
Loading...
Searching...
No Matches
dialog-print-check.c File Reference

Print Checks Dialog. More...

#include <config.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <stdio.h>
#include <locale.h>
#include <math.h>
#include "qof.h"
#include "gnc-date.h"
#include "gnc-prefs.h"
#include "gnc-numeric.h"
#include "gnc-plugin-page-register.h"
#include "dialog-print-check.h"
#include "dialog-utils.h"
#include "print-session.h"
#include "gnc-ui.h"
#include "gnc-date-format.h"
#include "gnc-ui-util.h"
#include "gnc-path.h"
#include "gnc-filepath-utils.h"
#include "gnc-gkeyfile-utils.h"
#include "gnc-engine.h"
#include "engine-helpers.h"
#include "Split.h"
#include "Transaction.h"

Go to the source code of this file.

Data Structures

struct  check_item_t
struct  check_format_t
struct  PrintCheckDialog
struct  _trans_amount

Macros

#define G_LOG_DOMAIN   "gnc.printing.checks"
#define GNC_PREFS_GROUP   "dialogs.checkprinting"
#define GNC_PREF_CHECK_FORMAT_GUID   "check-format-guid"
#define GNC_PREF_CHECK_POSITION   "check-position"
#define GNC_PREF_FIRST_PAGE_COUNT   "first-page-count"
#define GNC_PREF_DATE_FORMAT_USER   "date-format-user"
#define GNC_PREF_CUSTOM_PAYEE   "custom-payee"
#define GNC_PREF_CUSTOM_DATE   "custom-date"
#define GNC_PREF_CUSTOM_WORDS   "custom-amount-words"
#define GNC_PREF_CUSTOM_NUMBER   "custom-amount-number"
#define GNC_PREF_CUSTOM_ADDRESS   "custom-address"
#define GNC_PREF_CUSTOM_NOTES   "custom-notes"
#define GNC_PREF_CUSTOM_MEMO   "custom-memo"
#define GNC_PREF_CUSTOM_TRANSLATION   "custom-translation"
#define GNC_PREF_CUSTOM_ROTATION   "custom-rotation"
#define GNC_PREF_CUSTOM_UNITS   "custom-units"
#define GNC_PREF_PRINT_DATE_FMT   "print-date-format"
#define GNC_PREF_DEFAULT_FONT   "default-font"
#define GNC_PREF_BLOCKING_CHARS   "blocking-chars"
#define GNC_PREF_SPLITS_AMOUNT   "splits-amount"
#define GNC_PREF_SPLITS_MEMO   "splits-memo"
#define GNC_PREF_SPLITS_ACCOUNT   "splits-account"
#define DEFAULT_FONT   "sans 12"
#define CHECK_FMT_DIR   "checks"
#define CHECK_NAME_EXTENSION   ".chk"
#define DEGREES_TO_RADIANS   (G_PI / 180.0)
#define BLOCKING_CHAR_OFF   0
#define BLOCKING_CHAR_ON   1
#define KF_GROUP_TOP   "Top"
#define KF_GROUP_POS   "Check Positions"
#define KF_GROUP_ITEMS   "Check Items"
#define KF_KEY_GUID   "Guid"
#define KF_KEY_TITLE   "Title"
#define KF_KEY_ROTATION   "Rotation"
#define KF_KEY_TRANSLATION   "Translation"
#define KF_KEY_FONT   "Font"
#define KF_KEY_ALIGN   "Align"
#define KF_KEY_BLOCKING   "Blocking_Chars"
#define KF_KEY_SHOW_GRID   "Show_Grid"
#define KF_KEY_SHOW_BOXES   "Show_Boxes"
#define KF_KEY_NAMES   "Names"
#define KF_KEY_HEIGHT   "Height"
#define KF_KEY_TYPE   "Type"
#define KF_KEY_COORDS   "Coords"
#define KF_KEY_TEXT   "Text"
#define KF_KEY_FILENAME   "Filename"
#define KF_KEY_DATE_FORMAT   "DateFormat"
#define KF_KEY_SPLITS_AMOUNT   "SplitsAmount"
#define KF_KEY_SPLITS_MEMO   "SplitsMemo"
#define KF_KEY_SPLITS_ACCOUNT   "SplitsAccount"
#define ENUM_CHECK_ITEM_TYPE(_)

Enumerations

enum  format_combo_col { COL_NAME = 0 , COL_DATA , COL_SEP }
enum  CheckItemType { ENUM_CHECK_ITEM_TYPE =(ENUM_BODY) }

Functions

gchar * get_check_address (PrintCheckDialog *pcd)

Split printing functions

#define DATE_FMT_HEIGHT   8
#define DATE_FMT_SLOP   2
void gnc_ui_print_check_response_cb (GtkDialog *dialog, gint response, PrintCheckDialog *pcd)
void gnc_print_check_format_changed (GtkComboBox *widget, PrintCheckDialog *pcd)
void gnc_print_check_position_changed (GtkComboBox *widget, PrintCheckDialog *pcd)
void gnc_print_check_save_button_clicked (GtkButton *button, PrintCheckDialog *pcd)
void gnc_check_format_title_changed (GtkEditable *editable, GtkWidget *ok_button)
gchar * get_check_splits_amount (PrintCheckDialog *pcd)
gchar * get_check_splits_memo (PrintCheckDialog *pcd)
gchar * get_check_splits_account (PrintCheckDialog *pcd)
void gnc_ui_print_check_dialog_create (GtkWidget *parent, GList *splits, Account *account)

Detailed Description

Print Checks Dialog.

Author
Copyright (C) 2000 Bill Gribble grib@.nosp@m.bill.nosp@m.gribb.nosp@m.le.c.nosp@m.om
Copyright (C) 2006,2007 David Hampton hampt.nosp@m.on@e.nosp@m.mploy.nosp@m.ees..nosp@m.org

Definition in file dialog-print-check.c.

Macro Definition Documentation

◆ BLOCKING_CHAR_OFF

#define BLOCKING_CHAR_OFF   0

Definition at line 94 of file dialog-print-check.c.

◆ BLOCKING_CHAR_ON

#define BLOCKING_CHAR_ON   1

Definition at line 95 of file dialog-print-check.c.

◆ CHECK_FMT_DIR

#define CHECK_FMT_DIR   "checks"

Definition at line 90 of file dialog-print-check.c.

◆ CHECK_NAME_EXTENSION

#define CHECK_NAME_EXTENSION   ".chk"

Definition at line 91 of file dialog-print-check.c.

◆ DATE_FMT_HEIGHT

#define DATE_FMT_HEIGHT   8

Definition at line 2051 of file dialog-print-check.c.

◆ DATE_FMT_SLOP

#define DATE_FMT_SLOP   2

Definition at line 2052 of file dialog-print-check.c.

◆ DEFAULT_FONT

#define DEFAULT_FONT   "sans 12"

Definition at line 89 of file dialog-print-check.c.

◆ DEGREES_TO_RADIANS

#define DEGREES_TO_RADIANS   (G_PI / 180.0)

Definition at line 92 of file dialog-print-check.c.

◆ ENUM_CHECK_ITEM_TYPE

#define ENUM_CHECK_ITEM_TYPE ( _)
Value:
_(NONE,) \
_(PAYEE,) \
_(DATE,) \
_(NOTES,) \
_(CHECK_NUMBER,) \
\
_(MEMO,) \
_(ACTION,) \
_(AMOUNT_NUMBER,) \
_(AMOUNT_WORDS,) \
\
_(TEXT,) \
_(ADDRESS,) \
_(DATE_FORMAT,) \
_(SPLITS_AMOUNT,) \
_(SPLITS_MEMO,) \
_(SPLITS_ACCOUNT,) \
_(PICTURE,)

Definition at line 154 of file dialog-print-check.c.

154#define ENUM_CHECK_ITEM_TYPE(_) \
155 _(NONE,) \
156 _(PAYEE,) \
157 _(DATE,) \
158 _(NOTES,) \
159 _(CHECK_NUMBER,) \
160 \
161 _(MEMO,) \
162 _(ACTION,) \
163 _(AMOUNT_NUMBER,) \
164 _(AMOUNT_WORDS,) \
165 \
166 _(TEXT,) \
167 _(ADDRESS,) \
168 _(DATE_FORMAT,) \
169 _(SPLITS_AMOUNT,) \
170 _(SPLITS_MEMO,) \
171 _(SPLITS_ACCOUNT,) \
172 _(PICTURE,)

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "gnc.printing.checks"

Definition at line 60 of file dialog-print-check.c.

◆ GNC_PREF_BLOCKING_CHARS

#define GNC_PREF_BLOCKING_CHARS   "blocking-chars"

Definition at line 83 of file dialog-print-check.c.

◆ GNC_PREF_CHECK_FORMAT_GUID

#define GNC_PREF_CHECK_FORMAT_GUID   "check-format-guid"

Definition at line 67 of file dialog-print-check.c.

◆ GNC_PREF_CHECK_POSITION

#define GNC_PREF_CHECK_POSITION   "check-position"

Definition at line 68 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_ADDRESS

#define GNC_PREF_CUSTOM_ADDRESS   "custom-address"

Definition at line 75 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_DATE

#define GNC_PREF_CUSTOM_DATE   "custom-date"

Definition at line 72 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_MEMO

#define GNC_PREF_CUSTOM_MEMO   "custom-memo"

Definition at line 77 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_NOTES

#define GNC_PREF_CUSTOM_NOTES   "custom-notes"

Definition at line 76 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_NUMBER

#define GNC_PREF_CUSTOM_NUMBER   "custom-amount-number"

Definition at line 74 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_PAYEE

#define GNC_PREF_CUSTOM_PAYEE   "custom-payee"

Definition at line 71 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_ROTATION

#define GNC_PREF_CUSTOM_ROTATION   "custom-rotation"

Definition at line 79 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_TRANSLATION

#define GNC_PREF_CUSTOM_TRANSLATION   "custom-translation"

Definition at line 78 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_UNITS

#define GNC_PREF_CUSTOM_UNITS   "custom-units"

Definition at line 80 of file dialog-print-check.c.

◆ GNC_PREF_CUSTOM_WORDS

#define GNC_PREF_CUSTOM_WORDS   "custom-amount-words"

Definition at line 73 of file dialog-print-check.c.

◆ GNC_PREF_DATE_FORMAT_USER

#define GNC_PREF_DATE_FORMAT_USER   "date-format-user"

Definition at line 70 of file dialog-print-check.c.

◆ GNC_PREF_DEFAULT_FONT

#define GNC_PREF_DEFAULT_FONT   "default-font"

Definition at line 82 of file dialog-print-check.c.

◆ GNC_PREF_FIRST_PAGE_COUNT

#define GNC_PREF_FIRST_PAGE_COUNT   "first-page-count"

Definition at line 69 of file dialog-print-check.c.

◆ GNC_PREF_PRINT_DATE_FMT

#define GNC_PREF_PRINT_DATE_FMT   "print-date-format"

Definition at line 81 of file dialog-print-check.c.

◆ GNC_PREF_SPLITS_ACCOUNT

#define GNC_PREF_SPLITS_ACCOUNT   "splits-account"

Definition at line 86 of file dialog-print-check.c.

◆ GNC_PREF_SPLITS_AMOUNT

#define GNC_PREF_SPLITS_AMOUNT   "splits-amount"

Definition at line 84 of file dialog-print-check.c.

◆ GNC_PREF_SPLITS_MEMO

#define GNC_PREF_SPLITS_MEMO   "splits-memo"

Definition at line 85 of file dialog-print-check.c.

◆ GNC_PREFS_GROUP

#define GNC_PREFS_GROUP   "dialogs.checkprinting"

Definition at line 66 of file dialog-print-check.c.

◆ KF_GROUP_ITEMS

#define KF_GROUP_ITEMS   "Check Items"

Definition at line 99 of file dialog-print-check.c.

◆ KF_GROUP_POS

#define KF_GROUP_POS   "Check Positions"

Definition at line 98 of file dialog-print-check.c.

◆ KF_GROUP_TOP

#define KF_GROUP_TOP   "Top"

Definition at line 97 of file dialog-print-check.c.

◆ KF_KEY_ALIGN

#define KF_KEY_ALIGN   "Align"

Definition at line 105 of file dialog-print-check.c.

◆ KF_KEY_BLOCKING

#define KF_KEY_BLOCKING   "Blocking_Chars"

Definition at line 106 of file dialog-print-check.c.

◆ KF_KEY_COORDS

#define KF_KEY_COORDS   "Coords"

Definition at line 112 of file dialog-print-check.c.

◆ KF_KEY_DATE_FORMAT

#define KF_KEY_DATE_FORMAT   "DateFormat"

Definition at line 115 of file dialog-print-check.c.

◆ KF_KEY_FILENAME

#define KF_KEY_FILENAME   "Filename"

Definition at line 114 of file dialog-print-check.c.

◆ KF_KEY_FONT

#define KF_KEY_FONT   "Font"

Definition at line 104 of file dialog-print-check.c.

◆ KF_KEY_GUID

#define KF_KEY_GUID   "Guid"

Definition at line 100 of file dialog-print-check.c.

◆ KF_KEY_HEIGHT

#define KF_KEY_HEIGHT   "Height"

Definition at line 110 of file dialog-print-check.c.

◆ KF_KEY_NAMES

#define KF_KEY_NAMES   "Names"

Definition at line 109 of file dialog-print-check.c.

◆ KF_KEY_ROTATION

#define KF_KEY_ROTATION   "Rotation"

Definition at line 102 of file dialog-print-check.c.

◆ KF_KEY_SHOW_BOXES

#define KF_KEY_SHOW_BOXES   "Show_Boxes"

Definition at line 108 of file dialog-print-check.c.

◆ KF_KEY_SHOW_GRID

#define KF_KEY_SHOW_GRID   "Show_Grid"

Definition at line 107 of file dialog-print-check.c.

◆ KF_KEY_SPLITS_ACCOUNT

#define KF_KEY_SPLITS_ACCOUNT   "SplitsAccount"

Definition at line 118 of file dialog-print-check.c.

◆ KF_KEY_SPLITS_AMOUNT

#define KF_KEY_SPLITS_AMOUNT   "SplitsAmount"

Definition at line 116 of file dialog-print-check.c.

◆ KF_KEY_SPLITS_MEMO

#define KF_KEY_SPLITS_MEMO   "SplitsMemo"

Definition at line 117 of file dialog-print-check.c.

◆ KF_KEY_TEXT

#define KF_KEY_TEXT   "Text"

Definition at line 113 of file dialog-print-check.c.

◆ KF_KEY_TITLE

#define KF_KEY_TITLE   "Title"

Definition at line 101 of file dialog-print-check.c.

◆ KF_KEY_TRANSLATION

#define KF_KEY_TRANSLATION   "Translation"

Definition at line 103 of file dialog-print-check.c.

◆ KF_KEY_TYPE

#define KF_KEY_TYPE   "Type"

Definition at line 111 of file dialog-print-check.c.

Enumeration Type Documentation

◆ CheckItemType

enum CheckItemType

Definition at line 174 of file dialog-print-check.c.

◆ format_combo_col

Enumerator
COL_NAME 

This column holds a copy of the check format name and is what is displayed to the user in the combobox.

It is NULL for separator lines.

COL_DATA 

This column holds a pointer to the check format data read in from a file.

It is NULL for the custom check format and for separator lines.

COL_SEP 

This column contains the value TRUE if this entry specifies a separator line.

Definition at line 122 of file dialog-print-check.c.

123{
124 COL_NAME = 0,
128 COL_DATA,
132 COL_SEP,
format_combo_col
@ COL_DATA
This column holds a pointer to the check format data read in from a file.
@ COL_SEP
This column contains the value TRUE if this entry specifies a separator line.

Function Documentation

◆ get_check_address()

gchar * get_check_address ( PrintCheckDialog * pcd)

Definition at line 361 of file dialog-print-check.c.

362{
363 gchar *address;
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)),
369 NULL);
370 return address;
371}

◆ get_check_splits_account()

gchar * get_check_splits_account ( PrintCheckDialog * pcd)

Definition at line 494 of file dialog-print-check.c.

495{
496 gchar* account = NULL;
497 Transaction *trans;
498 GList *node;
499 SplitList* s_list;
500
501 trans = xaccSplitGetParent(pcd->split);
502 s_list = xaccTransGetSplitList(trans);
503 if ( !s_list ) return NULL;
504
505 account = g_strconcat("", NULL);
506 node = s_list;
507 while ( node )
508 {
509 Split *split = node->data;
510 /* Include all splits except the main split for the check */
511 if (split != pcd->split)
512 {
513 gchar* account_temp;
514 const gchar* aName = NULL;
515 Account *pAccount;
516 pAccount = xaccSplitGetAccount(split);
517 aName = gnc_get_account_name_for_register(pAccount);
518 account_temp = account;
519 if (account && *account)
520 account = g_strconcat(account_temp, "\n", aName, NULL);
521 else
522 account = g_strconcat(account_temp, aName, NULL);
523 g_free(account_temp);
524 }
525 node = node->next;
526 }
527 return account;
528}
SplitList * xaccTransGetSplitList(const Transaction *trans)
The xaccTransGetSplitList() method returns a GList of the splits in a transaction.
GList SplitList
GList of Split.
Definition gnc-engine.h:207
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 ...
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
STRUCTS.

◆ get_check_splits_amount()

gchar * get_check_splits_amount ( PrintCheckDialog * pcd)

Definition at line 418 of file dialog-print-check.c.

419{
420 gchar* amount = NULL;
421 Transaction *trans;
422 GList *node;
423 SplitList* s_list;
424
425 trans = xaccSplitGetParent(pcd->split);
426 s_list = xaccTransGetSplitList(trans);
427 if ( !s_list ) return NULL;
428
429 amount = g_strconcat("", NULL);
430 node = s_list;
431 while ( node )
432 {
433 Split *split = node->data;
434 /* Include all splits except the main split for the check */
435 if (split != pcd->split)
436 {
437 const gchar* split_amount;
438 gchar* amt_temp;
439 split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
440 amt_temp = amount;
441 if (amount && *amount)
442 amount = g_strconcat(amt_temp, "\n", split_amount, NULL);
443 else
444 amount = g_strconcat(amt_temp, split_amount, NULL);
445 g_free(amt_temp);
446 }
447 node = node->next;
448 }
449 return amount;
450}
const char * xaccPrintAmount(gnc_numeric val, GNCPrintAmountInfo info)
Make a string representation of a gnc_numeric.
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.

◆ get_check_splits_memo()

gchar * get_check_splits_memo ( PrintCheckDialog * pcd)

Definition at line 456 of file dialog-print-check.c.

457{
458 gchar* memo = NULL;
459 const gchar* split_memo;
460 Transaction *trans;
461 GList *node;
462 SplitList* s_list;
463
464 trans = xaccSplitGetParent(pcd->split);
465 s_list = xaccTransGetSplitList(trans);
466 if ( !s_list ) return NULL;
467
468 memo = g_strconcat("", NULL);
469 node = s_list;
470 while ( node )
471 {
472 Split *split = node->data;
473 /* Include all splits except the main split for the check */
474 if (split != pcd->split)
475 {
476 gchar* memo_temp;
477 split_memo = xaccSplitGetMemo(split);
478 memo_temp = memo;
479 if (memo && *memo)
480 memo = g_strconcat(memo_temp, "\n", split_memo, NULL);
481 else
482 memo = g_strconcat(memo_temp, split_memo, NULL);
483 g_free(memo_temp);
484 }
485 node = node->next;
486 }
487 return memo;
488}
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.

◆ gnc_check_format_title_changed()

void gnc_check_format_title_changed ( GtkEditable * editable,
GtkWidget * ok_button )

Definition at line 878 of file dialog-print-check.c.

879{
880 const gchar *text;
881 gboolean sensitive;
882
883 text = gtk_entry_get_text(GTK_ENTRY(editable));
884 sensitive = text && *text;
885 gtk_widget_set_sensitive(ok_button, sensitive);
886}

◆ gnc_print_check_format_changed()

void gnc_print_check_format_changed ( GtkComboBox * widget,
PrintCheckDialog * pcd )

Definition at line 2602 of file dialog-print-check.c.

2604{
2605 GtkListStore *p_store;
2606 GtkTreeModel *f_model;
2607 GtkTreeIter f_iter, iter;
2608 gboolean sensitive;
2609 gint pnum;
2610 check_format_t *format;
2611 gboolean separator;
2612 GSList *elem;
2613
2614 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(pcd->format_combobox), &f_iter))
2615 return;
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);
2618 if (separator)
2619 return;
2620
2621 pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2622
2623 /* Update the positions 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));
2628 if (format)
2629 {
2630 if (format->positions)
2631 {
2632 pcd->position_max = g_slist_length(format->positions); /* -1 for 0 base, +1 for custom entry */
2633 for (elem = format->positions; elem; elem = g_slist_next(elem))
2634 {
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);
2637 }
2638 }
2639 else
2640 {
2641 /* Invent a "Top" position if format has no positions */
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);
2645 }
2646 }
2647 else
2648 {
2649 pcd->position_max = 0;
2650 }
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);
2654
2655 /* If there's only one thing in the position combobox, make it insensitive */
2656 sensitive = (pcd->position_max > 0);
2657 gtk_widget_set_sensitive(GTK_WIDGET(pcd->position_combobox), sensitive);
2658
2659 /* Update the custom page, this must be done before setting the active
2660 entry in the position combo box since gnc_print_check_position_changed
2661 will adjust these settings in some cases. */
2662 sensitive = (!separator && !format);
2663 gtk_container_foreach(GTK_CONTAINER(pcd->custom_table),
2664 gnc_print_check_set_sensitive,
2665 GINT_TO_POINTER(sensitive));
2666
2667 /* Set the active entry in the position combo box, this will trigger a
2668 call to gnc_print_check_position_changed */
2669 pnum = MAX(MIN(pnum, pcd->position_max), 0);
2670 gtk_combo_box_set_active(GTK_COMBO_BOX(pcd->position_combobox), pnum);
2671
2672 /* Update address fields */
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);
2679}
GSList * positions
Names of the checks on the page.

◆ gnc_print_check_position_changed()

void gnc_print_check_position_changed ( GtkComboBox * widget,
PrintCheckDialog * pcd )

Definition at line 2683 of file dialog-print-check.c.

2685{
2686 gboolean sensitive;
2687 gint pnum;
2688 guint check_count;
2689 gint first_page_max, first_page_min, first_page_value;
2690
2691 pnum = gtk_combo_box_get_active(GTK_COMBO_BOX(pcd->position_combobox));
2692
2693 /* Make the translation and rotation fields active if the position is "custom" */
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);
2699
2700 /* Set up the first page check count spin box */
2701 check_count = g_list_length(pcd->splits);
2702 first_page_max = MAX(1, MIN(pcd->position_max - pnum, check_count));
2703 first_page_min = 1;
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);
2710}

◆ gnc_print_check_save_button_clicked()

void gnc_print_check_save_button_clicked ( GtkButton * button,
PrintCheckDialog * pcd )

Definition at line 894 of file dialog-print-check.c.

895{
896 GtkWidget *dialog, *entry, *button;
897 GtkBuilder *builder;
898 gchar *title;
899
900 builder = gtk_builder_new();
901 gnc_builder_add_from_file (builder, "dialog-print-check.glade", "format_title_dialog");
902
903 /* Get a title for the new check format. */
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);
909
910 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(pcd->dialog));
911 if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
912 {
913 gtk_widget_destroy(dialog);
914 g_object_unref(G_OBJECT(builder));
915 return;
916 }
917
918 title = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
919 gtk_widget_destroy (dialog);
920
921 g_object_unref(G_OBJECT(builder));
922
923 pcd_save_custom_data(pcd, title);
924 g_free(title);
925}

◆ gnc_ui_print_check_dialog_create()

void gnc_ui_print_check_dialog_create ( GtkWidget * parent,
GList * splits,
Account * account )

Definition at line 1652 of file dialog-print-check.c.

1655{
1656 PrintCheckDialog *pcd;
1657 GtkBuilder *builder;
1658 GtkWidget *table;
1659 gchar *font;
1660 Transaction *trans = NULL;
1661
1662 pcd = g_new0(PrintCheckDialog, 1);
1663 pcd->caller_window = GTK_WINDOW(parent);
1664 pcd->splits = g_list_copy(splits);
1665 pcd->account = account;
1666
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");
1696
1697 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pcd);
1698
1699 pcd->builder = builder;
1700 pcd->dialog = GTK_WIDGET(gtk_builder_get_object (builder, "print_check_dialog"));
1701
1702 // Set the name for this dialog so it can be easily manipulated with css
1703 gtk_widget_set_name (GTK_WIDGET(pcd->dialog), "gnc-id-print-check");
1704
1705 /* now pick out the relevant child widgets */
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"));
1709
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"));
1736
1737 gtk_window_set_transient_for(GTK_WINDOW(pcd->dialog), pcd->caller_window);
1738
1739 /* Create and attach the date-format chooser */
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);
1743
1744 /* Default font (set in preferences) */
1745 font = gnc_prefs_get_string(GNC_PREFS_GROUP, GNC_PREF_DEFAULT_FONT);
1746 pcd->default_font = font && *font ? font : g_strdup(DEFAULT_FONT);
1747
1748 /* Update the combo boxes bases on the available check formats */
1749 initialize_format_combobox(pcd);
1750
1751 /* address */
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"));
1757 /* fill in any available address data */
1758 /* Can't access business objects e.g. Customer,Vendor,Employee because
1759 * it would create build problems */
1760 if (g_list_length(pcd->splits) == 1)
1761 {
1762 GncOwner txn_owner;
1763
1764 trans = xaccSplitGetParent((Split *)(pcd->splits->data));
1765 if (gncOwnerGetOwnerFromTxn (trans, &txn_owner))
1766 {
1767 GncOwner owner;
1768 gncOwnerCopy (gncOwnerGetEndOwner (&txn_owner), &owner);
1769
1770 /* Got a business owner, get the address */
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)));
1776 }
1777 }
1778
1779 /* Use transaction description as address name if no better address has been found */
1780 if ( trans && (0 == gtk_entry_get_text_length (GTK_ENTRY(pcd->check_address_name))) )
1781 gtk_entry_set_text(GTK_ENTRY(pcd->check_address_name), xaccTransGetDescription(trans));
1782
1783 gtk_widget_destroy(GTK_WIDGET(gtk_builder_get_object (builder, "lower_left")));
1784
1785 gnc_ui_print_restore_dialog(pcd);
1786 gnc_restore_window_size(GNC_PREFS_GROUP, GTK_WINDOW(pcd->dialog), GTK_WINDOW (parent));
1787
1788 g_object_unref(G_OBJECT(builder));
1789 gtk_widget_show_all(pcd->dialog);
1790}
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
Definition gncOwner.c:572
gboolean gncOwnerGetOwnerFromTxn(Transaction *txn, GncOwner *owner)
Convenience function to get the owner from a transaction.
Definition gncOwner.c:674
gchar * gnc_prefs_get_string(const gchar *group, const gchar *pref_name)
Get a string value from the preferences backend.

◆ gnc_ui_print_check_response_cb()

void gnc_ui_print_check_response_cb ( GtkDialog * dialog,
gint response,
PrintCheckDialog * pcd )

Definition at line 2714 of file dialog-print-check.c.

2717{
2718 switch (response)
2719 {
2720 case GTK_RESPONSE_HELP:
2721 gnc_gnome_help (GTK_WINDOW(dialog), DF_MANUAL, DL_PRINTCHECK);
2722 return;
2723
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));
2728 break;
2729
2730 case GTK_RESPONSE_CANCEL:
2731 gnc_save_window_size(GNC_PREFS_GROUP, GTK_WINDOW(dialog));
2732 break;
2733 }
2734
2735 gtk_widget_destroy(pcd->dialog);
2736 g_free(pcd->default_font);
2737 g_list_free(pcd->splits);
2738 g_free(pcd);
2739}
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...