From 9ca73549ce80b803719c4985aa11a6cac61a3c77 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Tue, 27 Mar 2007 01:10:09 +0000 Subject: [PATCH] Add a preference for printing "***" immediately before and after all text fields on checks. Implements enhancement request #420224. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15758 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/glade/preferences.glade | 77 ++++++++++++++----- src/gnome/dialog-print-check.c | 27 ++++++- ...pps_gnucash_dialog_print_checks.schemas.in | 36 +++++++++ 3 files changed, 117 insertions(+), 23 deletions(-) diff --git a/src/gnome-utils/glade/preferences.glade b/src/gnome-utils/glade/preferences.glade index 44bb0d1fae..0a3f0491a6 100644 --- a/src/gnome-utils/glade/preferences.glade +++ b/src/gnome-utils/glade/preferences.glade @@ -2274,22 +2274,39 @@ - + True - True - True - True - False - False - True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + Below the actual date, print the format of that date in 8 point type. + True + Print _date format + True + GTK_RELIEF_NORMAL + True + False + False + True + + - 1 + 0 4 - 2 - 3 + 1 + 2 fill - + fill @@ -2308,7 +2325,7 @@ True - Default _Font: + Default _font: True True GTK_JUSTIFY_LEFT @@ -2329,15 +2346,35 @@ 0 1 - 2 - 3 + 3 + 4 fill fill - + + True + True + True + True + False + False + True + + + 1 + 4 + 3 + 4 + fill + + + + + + True 0.5 0.5 @@ -2349,11 +2386,11 @@ 0 - + True - Below the actual date, print the format of that date in 8 point type. + Print '***' before and after each text field on the check. True - Print _Date Format + Print _blocking chars True GTK_RELIEF_NORMAL True @@ -2366,8 +2403,8 @@ 0 4 - 1 - 2 + 2 + 3 fill fill diff --git a/src/gnome/dialog-print-check.c b/src/gnome/dialog-print-check.c index b6fc67bd2b..5480113615 100644 --- a/src/gnome/dialog-print-check.c +++ b/src/gnome/dialog-print-check.c @@ -1,7 +1,7 @@ /********************************************************************\ * dialog-print-check.c : dialog to control check printing. * * Copyright (C) 2000 Bill Gribble * - * Copyright (C) 2006 David Hampton * + * Copyright (C) 2006,2007 David Hampton * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -69,6 +69,7 @@ #define KEY_CUSTOM_UNITS "custom_units" #define KEY_PRINT_DATE_FMT "print_date_format" #define KEY_DEFAULT_FONT "default_font" +#define KEY_BLOCKING_CHARS "blocking_chars" #define DEFAULT_FONT "sans 12" @@ -1311,6 +1312,10 @@ draw_text(GncPrintContext * context, const gchar * text, check_item_t * data, cairo_t *cr; gint layout_height, layout_width; gdouble width, height; + gchar *new_text; + + if ((NULL == text) || (strlen(text) == 0)) + return 0.0; /* Initialize for printing text */ layout = gtk_print_context_create_pango_layout(context); @@ -1324,7 +1329,13 @@ draw_text(GncPrintContext * context, const gchar * text, check_item_t * data, pango_layout_set_alignment(layout, data->w ? data->align : PANGO_ALIGN_LEFT); pango_layout_set_width(layout, data->w ? data->w * PANGO_SCALE : -1); - pango_layout_set_text(layout, text, -1); + if (gnc_gconf_get_bool(GCONF_SECTION, KEY_BLOCKING_CHARS, NULL)) { + new_text = g_strdup_printf("***%s***", text); + pango_layout_set_text(layout, new_text, -1); + g_free(new_text); + } else { + pango_layout_set_text(layout, text, -1); + } pango_layout_get_size(layout, &layout_width, &layout_height); width = (gdouble) layout_width / PANGO_SCALE; height = (gdouble) layout_height / PANGO_SCALE; @@ -1352,6 +1363,10 @@ draw_text(GncPrintContext * context, const gchar * text, check_item_t * data, return width; #else gdouble x0, x1, y0, y1; + gchar *new_text; + + if ((NULL == text) || (strlen(text) == 0)) + return 0.0; /* Clip text to the enclosing rectangle */ gnome_print_gsave(context); @@ -1374,7 +1389,13 @@ draw_text(GncPrintContext * context, const gchar * text, check_item_t * data, g_debug("Text move to %f,%f, print '%s'", data->x, data->y, text ? text : "(null)"); gnome_print_moveto(context, data->x, data->y); - gnome_print_show(context, text); + if (gnc_gconf_get_bool(GCONF_SECTION, KEY_BLOCKING_CHARS, NULL)) { + new_text = g_strdup_printf("***%s***", text); + gnome_print_show(context, new_text); + g_free(new_text); + } else { + gnome_print_show(context, text); + } gnome_print_grestore(context); return 0.0; #endif diff --git a/src/gnome/schemas/apps_gnucash_dialog_print_checks.schemas.in b/src/gnome/schemas/apps_gnucash_dialog_print_checks.schemas.in index 2e8a1ea06d..d65f0951c9 100644 --- a/src/gnome/schemas/apps_gnucash_dialog_print_checks.schemas.in +++ b/src/gnome/schemas/apps_gnucash_dialog_print_checks.schemas.in @@ -122,5 +122,41 @@ + + /schemas/apps/gnucash/dialogs/print_checks/print_date_format + /apps/gnucash/dialogs/print_checks/print_date_format + gnucash + bool + FALSE + + Print the date format below the date. + Each time the date is printed, print the date format immediately below in 8 point type using the characters Y, M, and D. + + + + + /schemas/apps/gnucash/dialogs/print_checks/default_font + /apps/gnucash/dialogs/print_checks/default_font + gnucash + string + sans 10 + + The default check printing font + The default font to use when printing checks. This value will be overridden by any font specified in a check description file. + + + + + /schemas/apps/gnucash/dialogs/print_checks/blocking_chars + /apps/gnucash/dialogs/print_checks/blocking_chars + gnucash + bool + FALSE + + Print '***' before and after strings. + Print '***' before and after strings. + + +