From b3e89167d2b78e0c48ce7239db145b8be9d48757 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 22 Jun 2003 05:40:12 +0000 Subject: [PATCH] - Created Makefile.am in ./data and ./pixmaps directories - Modified ./configure.in and ./Makefile.am to work with these Makefiles - Moved glabels.desktop to ./data directory - Changed version to 1.92.0 in ./configure.in - Added page-sizes.paper to ./data -- it seems to be less hassle to maintain a local paper size database. - Added paper.[ch] and xml-paper.[ch] to ./src. - Converted to libgnomeprint-2.2 -- serious hack: ignoring the fact that gnome-printer-selector is private. - Added files to ./po/POTFILES.in git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@261 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/Makefile.am | 8 + glabels2/src/debug.c | 2 + glabels2/src/debug.h | 3 + glabels2/src/glabels-batch.c | 22 +- glabels2/src/glabels.c | 6 + glabels2/src/paper.c | 396 +++++++++++++++++++++++++++++++ glabels2/src/paper.h | 60 +++++ glabels2/src/prefs-dialog.c | 16 +- glabels2/src/prefs.c | 15 +- glabels2/src/print-dialog.c | 52 ++-- glabels2/src/print.c | 28 +-- glabels2/src/print.h | 12 +- glabels2/src/template.c | 63 +---- glabels2/src/template.h | 11 - glabels2/src/wdgt-media-select.c | 35 +-- glabels2/src/wdgt-mini-preview.c | 1 - glabels2/src/xml-paper.c | 126 ++++++++++ glabels2/src/xml-paper.h | 37 +++ glabels2/src/xml-template.c | 14 +- 19 files changed, 757 insertions(+), 150 deletions(-) create mode 100644 glabels2/src/paper.c create mode 100644 glabels2/src/paper.h create mode 100644 glabels2/src/xml-paper.c create mode 100644 glabels2/src/xml-paper.h diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index b2c8b384..8e82f1a6 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -114,12 +114,16 @@ glabels_SOURCES = \ label-barcode.h \ template.c \ template.h \ + paper.c \ + paper.h \ xml-label.c \ xml-label.h \ xml-label-04.c \ xml-label-04.h \ xml-template.c \ xml-template.h \ + xml-paper.c \ + xml-paper.h \ xml.c \ xml.h \ pixbuf-cache.c \ @@ -212,12 +216,16 @@ glabels_batch_SOURCES = \ label-barcode.h \ template.c \ template.h \ + paper.c \ + paper.h \ xml-label.c \ xml-label.h \ xml-label-04.c \ xml-label-04.h \ xml-template.c \ xml-template.h \ + xml-paper.c \ + xml-paper.h \ xml.c \ xml.h \ pixbuf-cache.c \ diff --git a/glabels2/src/debug.c b/glabels2/src/debug.c index 20bf9309..1ea493a4 100644 --- a/glabels2/src/debug.c +++ b/glabels2/src/debug.c @@ -40,6 +40,7 @@ gint gl_debug_print = 0; gint gl_debug_file = 0; gint gl_debug_label = 0; gint gl_debug_template = 0; +gint gl_debug_paper = 0; gint gl_debug_xml = 0; gint gl_debug_merge = 0; gint gl_debug_commands = 0; @@ -80,6 +81,7 @@ gl_debug (gint section, (gl_debug_file && section == GL_DEBUG_FILE) || (gl_debug_label && section == GL_DEBUG_LABEL) || (gl_debug_template && section == GL_DEBUG_TEMPLATE) || + (gl_debug_paper && section == GL_DEBUG_PAPER) || (gl_debug_xml && section == GL_DEBUG_XML) || (gl_debug_merge && section == GL_DEBUG_MERGE) || (gl_debug_commands && section == GL_DEBUG_COMMANDS) || diff --git a/glabels2/src/debug.h b/glabels2/src/debug.h index e2ac1358..c391bee6 100644 --- a/glabels2/src/debug.h +++ b/glabels2/src/debug.h @@ -40,6 +40,7 @@ typedef enum { GL_DEBUG_FILE, GL_DEBUG_LABEL, GL_DEBUG_TEMPLATE, + GL_DEBUG_PAPER, GL_DEBUG_XML, GL_DEBUG_MERGE, GL_DEBUG_UNDO, @@ -61,6 +62,7 @@ extern gint gl_debug_prefs; extern gint gl_debug_file; extern gint gl_debug_label; extern gint gl_debug_template; +extern gint gl_debug_paper; extern gint gl_debug_xml; extern gint gl_debug_merge; extern gint gl_debug_commands; @@ -84,6 +86,7 @@ extern gint gl_debug_wdgt; #define DEBUG_FILE GL_DEBUG_FILE, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_LABEL GL_DEBUG_LABEL, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_TEMPLATE GL_DEBUG_TEMPLATE,__FILE__, __LINE__, __FUNCTION__ +#define DEBUG_PAPER GL_DEBUG_PAPER, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_XML GL_DEBUG_XML, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_MERGE GL_DEBUG_MERGE, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_UNDO GL_DEBUG_UNDO, __FILE__, __LINE__, __FUNCTION__ diff --git a/glabels2/src/glabels-batch.c b/glabels2/src/glabels-batch.c index 63fed962..dbef6eeb 100644 --- a/glabels2/src/glabels-batch.c +++ b/glabels2/src/glabels-batch.c @@ -23,10 +23,11 @@ #include #include -#include +#include #include "merge-init.h" #include "xml-label.h" +#include "paper.h" #include "template.h" #include "print.h" #include "util.h" @@ -74,7 +75,7 @@ main (int argc, char **argv) gint rc; GSList *p, *file_list = NULL; gint n_files; - GnomePrintMaster *master = NULL; + GnomePrintJob *job = NULL; gchar *abs_fn; GnomePrintConfig *config = NULL; glLabel *label = NULL; @@ -118,6 +119,7 @@ main (int argc, char **argv) /* initialize components */ gl_merge_init (); + gl_paper_init (); gl_template_init (); /* now print the files */ @@ -126,11 +128,11 @@ main (int argc, char **argv) label = gl_xml_label_open (p->data, &status); if ( status == XML_LABEL_OK ) { - if ( master == NULL ) { - master = gnome_print_master_new (); + if ( job == NULL ) { + job = gnome_print_job_new (NULL); } - gl_print_batch (master, label, n_sheets, n_copies, + gl_print_batch (job, label, n_sheets, n_copies, outline_flag, reverse_flag); g_object_unref (label); @@ -140,16 +142,16 @@ main (int argc, char **argv) (char *)p->data ); } } - if ( master != NULL ) { + if ( job != NULL ) { abs_fn = gl_util_make_absolute ( output ); - gnome_print_master_print_to_file (master, abs_fn); + gnome_print_job_print_to_file (job, abs_fn); g_free( abs_fn ); - gnome_print_master_close (master); - gnome_print_master_print (master); + gnome_print_job_close (job); + gnome_print_job_print (job); - g_object_unref (master); + g_object_unref (job); } g_slist_free (file_list); diff --git a/glabels2/src/glabels.c b/glabels2/src/glabels.c index 150a3f8e..3cdbca45 100644 --- a/glabels2/src/glabels.c +++ b/glabels2/src/glabels.c @@ -29,6 +29,7 @@ #include "splash.h" #include "stock.h" #include "merge-init.h" +#include "paper.h" #include "template.h" #include "prefs.h" #include "debug.h" @@ -68,6 +69,9 @@ static const struct poptOption options [] = { "debug-template", '\0', POPT_ARG_NONE, &gl_debug_template, 0, N_("Show template debugging messages."), NULL }, + { "debug-paper", '\0', POPT_ARG_NONE, &gl_debug_paper, 0, + N_("Show paper debugging messages."), NULL }, + { "debug-xml", '\0', POPT_ARG_NONE, &gl_debug_xml, 0, N_("Show xml debugging messages."), NULL }, @@ -166,6 +170,8 @@ main (int argc, char **argv) gl_prefs_init (); gl_prefs_load_settings (); + /* Initialize subsystems */ + gl_paper_init(); gl_template_init(); gl_merge_init(); gl_recent_init(); diff --git a/glabels2/src/paper.c b/glabels2/src/paper.c new file mode 100644 index 00000000..807ed492 --- /dev/null +++ b/glabels2/src/paper.c @@ -0,0 +1,396 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * paper.c: paper module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include +#include + +#include "paper.h" +#include "xml-paper.h" + +#include "debug.h" + +#define GL_DATA_DIR gnome_program_locate_file (NULL,\ + GNOME_FILE_DOMAIN_APP_DATADIR,\ + "glabels",\ + FALSE, NULL) + + +/*===========================================*/ +/* Private types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +static GList *papers = NULL; + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static GList *read_papers (void); +static gchar *get_home_data_dir (void); +static GList *read_paper_files_from_dir (GList *papers, + const gchar *dirname); + + +/*****************************************************************************/ +/* Initialize module. */ +/*****************************************************************************/ +void +gl_paper_init (void) +{ + GList *page_sizes, *p; + + gl_debug (DEBUG_PAPER, "START"); + + papers = read_papers (); + + gl_debug (DEBUG_PAPER, "END"); +} + +/*****************************************************************************/ +/* Get a list of valid page size ids */ +/*****************************************************************************/ +GList * +gl_paper_get_id_list (void) +{ + GList *ids = NULL; + GList *p; + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + for ( p=papers; p != NULL; p=p->next ) { + paper = (glPaper *)p->data; + ids = g_list_append (ids, g_strdup (paper->id)); + } + + ids = g_list_append (ids, g_strdup ("Other")); + + gl_debug (DEBUG_PAPER, "END"); + return ids; +} + +/*****************************************************************************/ +/* Free a list of page size ids. */ +/*****************************************************************************/ +void +gl_paper_free_id_list (GList **ids) +{ + GList *p; + + gl_debug (DEBUG_PAPER, "START"); + + for (p = *ids; p != NULL; p = p->next) { + g_free (p->data); + p->data = NULL; + } + + g_list_free (*ids); + *ids = NULL; + + gl_debug (DEBUG_PAPER, "END"); +} + +/*****************************************************************************/ +/* Get a list of valid page size names */ +/*****************************************************************************/ +GList * +gl_paper_get_name_list (void) +{ + GList *names = NULL; + GList *p; + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + for ( p=papers; p != NULL; p=p->next ) { + paper = (glPaper *)p->data; + names = g_list_append (names, g_strdup (paper->name)); + } + + names = g_list_append (names, g_strdup ("Other")); + + gl_debug (DEBUG_PAPER, "END"); + return names; +} + +/*****************************************************************************/ +/* Free a list of page size names. */ +/*****************************************************************************/ +void +gl_paper_free_name_list (GList **names) +{ + GList *p; + + gl_debug (DEBUG_PAPER, "START"); + + for (p = *names; p != NULL; p = p->next) { + g_free (p->data); + p->data = NULL; + } + + g_list_free (*names); + *names = NULL; + + gl_debug (DEBUG_PAPER, "END"); +} + +/*****************************************************************************/ +/* Return a paper structure from id. */ +/*****************************************************************************/ +glPaper * +gl_paper_from_id (const gchar *id) +{ + GList *p; + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + if (id == NULL) { + /* If no id, return first paper as a default */ + return gl_paper_dup ((glPaper *) papers->data); + } + + for (p = papers; p != NULL; p = p->next) { + paper = (glPaper *) p->data; + if (g_strcasecmp (paper->id, id) == 0) { + gl_debug (DEBUG_PAPER, "END"); + return gl_paper_dup (paper); + } + } + + gl_debug (DEBUG_PAPER, "END"); + return NULL; +} + +/*****************************************************************************/ +/* Return a paper structure from name. */ +/*****************************************************************************/ +glPaper * +gl_paper_from_name (const gchar *name) +{ + GList *p; + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + if (name == NULL) { + /* If no name, return first paper as a default */ + return gl_paper_dup ((glPaper *) papers->data); + } + + for (p = papers; p != NULL; p = p->next) { + paper = (glPaper *) p->data; + if (g_strcasecmp (paper->name, name) == 0) { + gl_debug (DEBUG_PAPER, "END"); + return gl_paper_dup (paper); + } + } + + gl_debug (DEBUG_PAPER, "END"); + return NULL; +} + +/*****************************************************************************/ +/* Lookup paper id from name. */ +/*****************************************************************************/ +gchar * +gl_paper_lookup_id_from_name (const gchar *name) +{ + glPaper *paper; + gchar *id = NULL; + + gl_debug (DEBUG_PAPER, "START"); + + paper = gl_paper_from_name (name); + if ( paper != NULL ) { + id = g_strdup (paper->id); + gl_paper_free (&paper); + } + + gl_debug (DEBUG_PAPER, "END"); + return id; +} + +/*****************************************************************************/ +/* Lookup paper name from id. */ +/*****************************************************************************/ +gchar * +gl_paper_lookup_name_from_id (const gchar *id) +{ + glPaper *paper; + gchar *name = NULL; + + gl_debug (DEBUG_PAPER, "START"); + + paper = gl_paper_from_id (id); + if ( paper != NULL ) { + name = g_strdup (paper->name); + gl_paper_free (&paper); + } + + gl_debug (DEBUG_PAPER, "END"); + return name; +} + +/*****************************************************************************/ +/* Copy a paper. */ +/*****************************************************************************/ +glPaper *gl_paper_dup (const glPaper *orig_paper) +{ + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + paper = g_new0 (glPaper,1); + + paper->id = g_strdup (orig_paper->id); + paper->name = g_strdup (orig_paper->name); + paper->width = orig_paper->width; + paper->height = orig_paper->height; + + gl_debug (DEBUG_PAPER, "END"); + return paper; +} + +/*****************************************************************************/ +/* Free up a paper. */ +/*****************************************************************************/ +void gl_paper_free (glPaper **paper) +{ + GList *p; + + gl_debug (DEBUG_PAPER, "START"); + + if ( *paper != NULL ) { + + g_free ((*paper)->id); + (*paper)->name = NULL; + + g_free ((*paper)->name); + (*paper)->name = NULL; + + g_free (*paper); + *paper = NULL; + + } + + gl_debug (DEBUG_PAPER, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Read papers from various files. */ +/*--------------------------------------------------------------------------*/ +static GList * +read_papers (void) +{ + gchar *home_data_dir = get_home_data_dir (); + GList *papers = NULL; + + gl_debug (DEBUG_PAPER, "START"); + + papers = read_paper_files_from_dir (papers, GL_DATA_DIR); + papers = read_paper_files_from_dir (papers, home_data_dir); + + g_free (home_data_dir); + + if (papers == NULL) { + g_warning (_("No paper files found!")); + } + + gl_debug (DEBUG_PAPER, "END"); + return papers; +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. get '~/.glabels' directory path. */ +/*--------------------------------------------------------------------------*/ +static gchar * +get_home_data_dir (void) +{ + gchar *dir = gnome_util_prepend_user_home (".glabels"); + + gl_debug (DEBUG_PAPER, "START"); + + /* Try to create ~/.glabels directory. If it exists, no problem. */ + mkdir (dir, 0775); + + gl_debug (DEBUG_PAPER, "END"); + return dir; +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Read all paper files from given directory. Append to list. */ +/*--------------------------------------------------------------------------*/ +static GList * +read_paper_files_from_dir (GList *papers, + const gchar *dirname) +{ + GDir *dp; + const gchar *filename, *extension; + gchar *full_filename = NULL; + GError *gerror = NULL; + + gl_debug (DEBUG_PAPER, "START"); + + if (dirname == NULL) + return papers; + + dp = g_dir_open (dirname, 0, &gerror); + if (gerror != NULL) { + g_warning ("cannot open data directory: %s", gerror->message ); + gl_debug (DEBUG_PAPER, "END"); + return papers; + } + + while ((filename = g_dir_read_name (dp)) != NULL) { + + extension = strrchr (filename, '.'); + + if (extension != NULL) { + + if (strcasecmp (extension, ".paper") == 0) { + + full_filename = + g_build_filename (dirname, filename, NULL); + papers = + gl_xml_paper_read_papers_from_file (papers, + full_filename); + g_free (full_filename); + + } + + } + + } + + g_dir_close (dp); + + gl_debug (DEBUG_PAPER, "END"); + return papers; +} + diff --git a/glabels2/src/paper.h b/glabels2/src/paper.h new file mode 100644 index 00000000..a765204b --- /dev/null +++ b/glabels2/src/paper.h @@ -0,0 +1,60 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * paper.h: paper module header file + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __PAPER_H__ +#define __PAPER_H__ + +#include + +G_BEGIN_DECLS + +/* + * Paper + */ +typedef struct { + gchar *id; + gchar *name; + gdouble width; + gdouble height; +} glPaper; + + +void gl_paper_init (void); + +GList *gl_paper_get_id_list (void); +void gl_paper_free_id_list (GList **ids); + +GList *gl_paper_get_name_list (void); +void gl_paper_free_name_list (GList **names); + +glPaper *gl_paper_from_id (const gchar *id); +glPaper *gl_paper_from_name (const gchar *name); + +gchar *gl_paper_lookup_id_from_name (const gchar *name); +gchar *gl_paper_lookup_name_from_id (const gchar *id); + +glPaper *gl_paper_dup (const glPaper *orig); +void gl_paper_free (glPaper **paper); + +G_END_DECLS + +#endif diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index 3466ca90..e810648b 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -35,8 +35,8 @@ /* Private macros and constants. */ /*========================================================*/ -#define US_LETTER "US Letter" -#define A4 "A4" +#define US_LETTER_ID "US-Letter" +#define A4_ID "A4" /*========================================================*/ /* Private types. */ @@ -306,7 +306,7 @@ locale_page (glPrefsDialog *dlg) radio_group = NULL; dlg->private->page_size_us_letter_radio = - gtk_radio_button_new_with_label (radio_group, US_LETTER); + gtk_radio_button_new_with_label (radio_group, _("US Letter")); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->page_size_us_letter_radio)); @@ -314,7 +314,7 @@ locale_page (glPrefsDialog *dlg) dlg->private->page_size_us_letter_radio); dlg->private->page_size_a4_radio = - gtk_radio_button_new_with_label (radio_group, A4); + gtk_radio_button_new_with_label (radio_group, _("A4")); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->page_size_a4_radio)); gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), @@ -440,11 +440,11 @@ static update_locale_page_from_prefs (glPrefsDialog *dlg) break; } - if ( g_strcasecmp(gl_prefs->default_page_size, US_LETTER) == 0) { + if ( g_strcasecmp(gl_prefs->default_page_size, US_LETTER_ID) == 0) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(dlg->private->page_size_us_letter_radio), TRUE); - } else if ( g_strcasecmp(gl_prefs->default_page_size, A4) == 0) { + } else if ( g_strcasecmp(gl_prefs->default_page_size, A4_ID) == 0) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(dlg->private->page_size_a4_radio), TRUE); @@ -530,11 +530,11 @@ static update_prefs_from_locale_page (glPrefsDialog *dlg) if (gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(dlg->private->page_size_us_letter_radio))) { - gl_prefs->default_page_size = US_LETTER; + gl_prefs->default_page_size = US_LETTER_ID; } if (gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON(dlg->private->page_size_a4_radio))) { - gl_prefs->default_page_size = A4; + gl_prefs->default_page_size = A4_ID; } gl_prefs_save_settings (); diff --git a/glabels2/src/prefs.c b/glabels2/src/prefs.c index c91618b2..d513e643 100644 --- a/glabels2/src/prefs.c +++ b/glabels2/src/prefs.c @@ -27,6 +27,7 @@ #include "prefs.h" #include "util.h" +#include "paper.h" #include "debug.h" @@ -69,7 +70,7 @@ glPreferences *gl_prefs = NULL; /* Default values */ #define DEFAULT_UNITS_STRING units_to_string (GL_PREFS_UNITS_INCHES) -#define DEFAULT_PAGE_SIZE "US Letter" +#define DEFAULT_PAGE_SIZE "US-Letter" #define DEFAULT_FONT_FAMILY "Helvetica" #define DEFAULT_FONT_SIZE 14.0 @@ -267,7 +268,8 @@ gl_prefs_save_settings (void) void gl_prefs_load_settings (void) { - gchar *string; + gchar *string; + glPaper *paper; gl_debug (DEBUG_PREFS, "START"); @@ -396,6 +398,15 @@ gl_prefs_load_settings (void) 4); + /* Proof read the default page size -- it must be a valid id. */ + /* (For compatability with older versions.) */ + paper = gl_paper_from_id (gl_prefs->default_page_size); + if ( paper == NULL ) { + gl_prefs->default_page_size = g_strdup (DEFAULT_PAGE_SIZE); + } else { + gl_paper_free (&paper); + } + gl_debug (DEBUG_PREFS, "max_recents = %d", gl_prefs->max_recents); gl_debug (DEBUG_PREFS, "END"); diff --git a/glabels2/src/print-dialog.c b/glabels2/src/print-dialog.c index e4d76d10..bb31dcdb 100644 --- a/glabels2/src/print-dialog.c +++ b/glabels2/src/print-dialog.c @@ -25,11 +25,9 @@ #include #include #include -#include -#include #include -#include -#include +#include +#include #include "print-dialog.h" #include "hig.h" @@ -43,6 +41,15 @@ #include "debug.h" +/***************************************************************************/ +/* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2. */ +/* */ +/* I know that I'm asking for trouble, but here are standin prototypes: */ +GtkWidget *gnome_printer_selector_new (GnomePrintConfig *config); +GnomePrintConfig *gnome_printer_selector_get_config (GtkWidget *psel); +#define GNOME_PRINTER_SELECTOR(x) (x) +/***************************************************************************/ + /*===========================================*/ /* Private types. */ /*===========================================*/ @@ -60,6 +67,7 @@ static gint first = 1, last = 1, n_sheets = 0, n_copies = 1; /*===========================================*/ /* Private function prototypes. */ /*===========================================*/ + static GtkWidget *job_page_new (GtkWidget *dlg, glLabel *label); static GtkWidget *printer_page_new (GtkWidget *dlg, glLabel *label); @@ -221,8 +229,9 @@ printer_page_new (GtkWidget *dlg, vbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); + /* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2 */ printer_select = - gnome_printer_selection_new (gnome_print_config_default ()); + gnome_printer_selector_new (gnome_print_config_default ()); gtk_widget_show (printer_select); gl_hig_vbox_add_widget (GL_HIG_VBOX(vbox), printer_select); @@ -258,7 +267,8 @@ print_response (GtkDialog *dlg, printer_select = g_object_get_data (G_OBJECT(dlg), "printer_select"); - config = gnome_printer_selection_get_config (GNOME_PRINTER_SELECTION(printer_select)); + /* FIXME: GnomePrinterSelector is not public in libgnomeprintui-2.2. */ + config = gnome_printer_selector_get_config (GNOME_PRINTER_SELECTOR(printer_select)); outline_flag = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON @@ -314,22 +324,22 @@ print_sheets (GnomePrintConfig *config, gboolean outline_flag, gboolean reverse_flag) { - GnomePrintMaster *master; + GnomePrintJob *job; - master = gnome_print_master_new_from_config (config); - gl_print_simple (master, label, n_sheets, first, last, + job = gnome_print_job_new (config); + gl_print_simple (job, label, n_sheets, first, last, outline_flag, reverse_flag); - gnome_print_master_close (master); + gnome_print_job_close (job); if (preview_flag) { GtkWidget *preview_widget = - gnome_print_master_preview_new (master, _("Print preview")); + gnome_print_job_preview_new (job, _("Print preview")); gtk_widget_show (GTK_WIDGET (preview_widget)); } else { - gnome_print_master_print (master); + gnome_print_job_print (job); } - g_object_unref (G_OBJECT (master)); + g_object_unref (G_OBJECT (job)); } /*---------------------------------------------------------------------------*/ @@ -345,28 +355,28 @@ print_sheets_merge (GnomePrintConfig *config, gboolean outline_flag, gboolean reverse_flag) { - GnomePrintMaster *master; + GnomePrintJob *job; - master = gnome_print_master_new_from_config (config); + job = gnome_print_job_new (config); if ( collate_flag ) { - gl_print_merge_collated (master, label, + gl_print_merge_collated (job, label, n_copies, first, outline_flag, reverse_flag); } else { - gl_print_merge_uncollated (master, label, + gl_print_merge_uncollated (job, label, n_copies, first, outline_flag, reverse_flag); } - gnome_print_master_close (master); + gnome_print_job_close (job); if (preview_flag) { GtkWidget *preview_widget = - gnome_print_master_preview_new (master, _("Print preview")); + gnome_print_job_preview_new (job, _("Print preview")); gtk_widget_show (GTK_WIDGET (preview_widget)); } else { - gnome_print_master_print (master); + gnome_print_job_print (job); } - g_object_unref (G_OBJECT (master)); + g_object_unref (G_OBJECT (job)); } diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 0e62f215..03dee0ca 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include "print.h" #include "label.h" @@ -74,7 +72,7 @@ typedef struct _PrintInfo { /*=========================================================================*/ /* Private function prototypes. */ /*=========================================================================*/ -static PrintInfo *print_info_new (GnomePrintMaster *master, +static PrintInfo *print_info_new (GnomePrintJob *job, glLabel *label); static void print_info_free (PrintInfo **pi); @@ -162,7 +160,7 @@ static void create_clipped_circle_path (GnomePrintContext *pc, /* Simple (no merge data) print command. */ /*****************************************************************************/ void -gl_print_simple (GnomePrintMaster *master, +gl_print_simple (GnomePrintJob *job, glLabel *label, gint n_sheets, gint first, @@ -176,7 +174,7 @@ gl_print_simple (GnomePrintMaster *master, gl_debug (DEBUG_PRINT, "START"); - pi = print_info_new (master, label); + pi = print_info_new (job, label); origins = gl_template_get_origins (pi->template); @@ -206,7 +204,7 @@ gl_print_simple (GnomePrintMaster *master, /* Merge print command (collated copies) */ /*****************************************************************************/ void -gl_print_merge_collated (GnomePrintMaster *master, +gl_print_merge_collated (GnomePrintJob *job, glLabel *label, gint n_copies, gint first, @@ -226,7 +224,7 @@ gl_print_merge_collated (GnomePrintMaster *master, merge = gl_label_get_merge (label); record_list = gl_merge_get_record_list (merge); - pi = print_info_new (master, label); + pi = print_info_new (job, label); n_labels_per_page = gl_template_get_n_labels (pi->template); origins = gl_template_get_origins (pi->template); @@ -274,7 +272,7 @@ gl_print_merge_collated (GnomePrintMaster *master, /* Merge print command (uncollated copies) */ /*****************************************************************************/ void -gl_print_merge_uncollated (GnomePrintMaster *master, +gl_print_merge_uncollated (GnomePrintJob *job, glLabel *label, gint n_copies, gint first, @@ -294,7 +292,7 @@ gl_print_merge_uncollated (GnomePrintMaster *master, merge = gl_label_get_merge (label); record_list = gl_merge_get_record_list (merge); - pi = print_info_new (master, label); + pi = print_info_new (job, label); n_labels_per_page = gl_template_get_n_labels (pi->template); origins = gl_template_get_origins (pi->template); @@ -344,7 +342,7 @@ gl_print_merge_uncollated (GnomePrintMaster *master, /* Batch print. Call appropriate function above. */ /*****************************************************************************/ void -gl_print_batch (GnomePrintMaster *master, +gl_print_batch (GnomePrintJob *job, glLabel *label, gint n_sheets, gint n_copies, @@ -363,10 +361,10 @@ gl_print_batch (GnomePrintMaster *master, if ( merge == NULL ) { n_per_page = gl_template_get_n_labels(template); - gl_print_simple (master, label, n_sheets, 1, n_per_page, + gl_print_simple (job, label, n_sheets, 1, n_per_page, outline_flag, reverse_flag); } else { - gl_print_merge_collated (master, label, n_copies, 1, + gl_print_merge_collated (job, label, n_copies, 1, outline_flag, reverse_flag); } gl_template_free (&template); @@ -380,7 +378,7 @@ gl_print_batch (GnomePrintMaster *master, /* PRIVATE. new print info structure */ /*---------------------------------------------------------------------------*/ static PrintInfo * -print_info_new (GnomePrintMaster *master, +print_info_new (GnomePrintJob *job, glLabel *label) { PrintInfo *pi = g_new0 (PrintInfo, 1); @@ -395,8 +393,8 @@ print_info_new (GnomePrintMaster *master, return NULL; } - pi->pc = gnome_print_master_get_context (master); - pi->config = gnome_print_master_get_config (master); + pi->pc = gnome_print_job_get_context (job); + pi->config = gnome_print_job_get_config (job); if ((template != NULL) && (template->page_size != NULL)) { diff --git a/glabels2/src/print.h b/glabels2/src/print.h index df7e827a..bdf3010f 100644 --- a/glabels2/src/print.h +++ b/glabels2/src/print.h @@ -23,13 +23,13 @@ #define __PRINT_H__ #include -#include -#include +#include + #include "label.h" G_BEGIN_DECLS -void gl_print_simple (GnomePrintMaster *master, +void gl_print_simple (GnomePrintJob *job, glLabel *label, gint n_sheets, gint first, @@ -37,21 +37,21 @@ void gl_print_simple (GnomePrintMaster *master, gboolean outline_flag, gboolean reverse_flag); -void gl_print_merge_collated (GnomePrintMaster *master, +void gl_print_merge_collated (GnomePrintJob *job, glLabel *label, gint n_copies, gint first, gboolean outline_flag, gboolean reverse_flag); -void gl_print_merge_uncollated (GnomePrintMaster *master, +void gl_print_merge_uncollated (GnomePrintJob *job, glLabel *label, gint n_copies, gint first, gboolean outline_flag, gboolean reverse_flag); -void gl_print_batch (GnomePrintMaster *master, +void gl_print_batch (GnomePrintJob *job, glLabel *label, gint n_sheets, gint n_bcopies, diff --git a/glabels2/src/template.c b/glabels2/src/template.c index de953614..36b4f9ba 100644 --- a/glabels2/src/template.c +++ b/glabels2/src/template.c @@ -23,13 +23,13 @@ #include #include -#include #include "prefs.h" #include "util.h" #include "xml.h" #include "template.h" #include "xml-template.h" +#include "paper.h" #include "debug.h" @@ -82,61 +82,14 @@ gl_template_init (void) templates = read_templates (); - page_sizes = gl_template_get_page_size_list (); + page_sizes = gl_paper_get_id_list (); for ( p=page_sizes; p != NULL; p=p->next ) { if ( g_strcasecmp(p->data, "Other") != 0 ) { templates = g_list_append (templates, template_full_page (p->data)); } } - gl_template_free_page_size_list (&page_sizes); - - gl_debug (DEBUG_TEMPLATE, "END"); -} - -/*****************************************************************************/ -/* Get a list of valid page size names */ -/*****************************************************************************/ -GList * -gl_template_get_page_size_list (void) -{ - GList *names = NULL; - GList *p, *paper_list; - GnomePrintPaper *paper; - - gl_debug (DEBUG_TEMPLATE, "START"); - - paper_list = gnome_print_paper_get_list(); - for ( p=paper_list; p != NULL; p=p->next ) { - paper = (GnomePrintPaper *)p->data; - if ( g_strcasecmp(paper->name, "custom") != 0 ) { - names = g_list_append (names, g_strdup (paper->name)); - } - } - - names = g_list_append (names, g_strdup ("Other")); - - gl_debug (DEBUG_TEMPLATE, "END"); - return names; -} - -/*****************************************************************************/ -/* Free a list of page size names. */ -/*****************************************************************************/ -void -gl_template_free_page_size_list (GList **names) -{ - GList *p_name; - - gl_debug (DEBUG_TEMPLATE, "START"); - - for (p_name = *names; p_name != NULL; p_name = p_name->next) { - g_free (p_name->data); - p_name->data = NULL; - } - - g_list_free (*names); - *names = NULL; + gl_paper_free_id_list (&page_sizes); gl_debug (DEBUG_TEMPLATE, "END"); } @@ -210,7 +163,7 @@ gl_template_from_name (const gchar *name) if (name == NULL) { /* If no name, return first template as a default */ - return (glTemplate *) templates->data; + return gl_template_dup ((glTemplate *) templates->data); } split_name = g_strsplit (name, ":", 2); @@ -329,10 +282,10 @@ void gl_template_free (glTemplate **template) static glTemplate * template_full_page (const gchar *page_size) { - const GnomePrintPaper *paper; + glPaper *paper; glTemplate *template; - paper = gnome_print_paper_get_by_name (page_size); + paper = gl_paper_from_id (page_size); if ( paper == NULL ) { return NULL; } @@ -360,6 +313,8 @@ template_full_page (const gchar *page_size) g_list_append (template->label.any.markups, gl_template_markup_margin_new (5.0)); + gl_paper_free (&paper); + return template; } @@ -374,8 +329,6 @@ read_templates (void) gl_debug (DEBUG_TEMPLATE, "START"); - LIBXML_TEST_VERSION; - templates = read_template_files_from_dir (templates, GL_DATA_DIR); templates = read_template_files_from_dir (templates, home_data_dir); diff --git a/glabels2/src/template.h b/glabels2/src/template.h index 43a25f75..68b2e823 100644 --- a/glabels2/src/template.h +++ b/glabels2/src/template.h @@ -24,8 +24,6 @@ #define __TEMPLATE_H__ #include -#include -#include G_BEGIN_DECLS @@ -138,9 +136,6 @@ typedef struct { void gl_template_init (void); -GList *gl_template_get_page_size_list (void); -void gl_template_free_page_size_list (GList **sizes); - GList *gl_template_get_name_list (const gchar *page_size); void gl_template_free_name_list (GList **names); @@ -149,12 +144,6 @@ glTemplate *gl_template_from_name (const gchar *name); glTemplate *gl_template_dup (const glTemplate *orig); void gl_template_free (glTemplate **template); -glTemplate *gl_template_xml_parse_sheet (xmlNodePtr sheet_node); - -void gl_template_xml_add_sheet (const glTemplate *template, - xmlNodePtr root, - xmlNsPtr ns); - gchar *gl_template_get_label_size_desc (const glTemplate *template); void gl_template_get_label_size (const glTemplate *template, gdouble *w, diff --git a/glabels2/src/wdgt-media-select.c b/glabels2/src/wdgt-media-select.c index 0ef77192..fec3aa5c 100644 --- a/glabels2/src/wdgt-media-select.c +++ b/glabels2/src/wdgt-media-select.c @@ -28,6 +28,7 @@ #include "wdgt-mini-preview.h" #include "prefs.h" #include "util.h" +#include "paper.h" #include "marshal.h" #include "debug.h" @@ -189,11 +190,13 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) GtkSizeGroup *label_size_group; gchar *name; GList *template_names, *page_sizes = NULL; - const gchar *page_size; + const gchar *page_size_id; + gchar *page_size_name; gl_debug (DEBUG_MEDIA_SELECT, "START"); - page_size = gl_prefs_get_page_size (); + page_size_id = gl_prefs_get_page_size (); + page_size_name = gl_paper_lookup_name_from_id (page_size_id); wvbox = GTK_WIDGET (media_select); @@ -203,22 +206,22 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) /* Page size selection control */ gl_debug (DEBUG_MEDIA_SELECT, "Creating page size combo..."); wcombo = gtk_combo_new (); - page_sizes = gl_template_get_page_size_list (); + page_sizes = gl_paper_get_name_list (); gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), page_sizes); - gl_template_free_page_size_list (&page_sizes); + gl_paper_free_name_list (&page_sizes); media_select->page_size_entry = GTK_COMBO (wcombo)->entry; gtk_entry_set_editable (GTK_ENTRY (media_select->page_size_entry), FALSE); gtk_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, FALSE); gtk_widget_set_size_request (media_select->page_size_entry, 100, -1); gtk_entry_set_text (GTK_ENTRY (media_select->page_size_entry), - page_size); + page_size_name); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); /* Actual selection control */ gl_debug (DEBUG_MEDIA_SELECT, "Creating template combo..."); - gl_debug (DEBUG_MEDIA_SELECT, "page_size = %s", page_size); - template_names = gl_template_get_name_list (page_size); + gl_debug (DEBUG_MEDIA_SELECT, "page_size_name = %s", page_size_name); + template_names = gl_template_get_name_list (page_size_id); media_select->template_combo = gtk_combo_new (); gtk_combo_set_popdown_strings (GTK_COMBO (media_select->template_combo), template_names); @@ -317,6 +320,8 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) G_CALLBACK (template_entry_changed_cb), media_select); + g_free (page_size_name); + gl_debug (DEBUG_MEDIA_SELECT, "END"); } @@ -328,17 +333,18 @@ page_size_entry_changed_cb (GtkEntry *entry, gpointer user_data) { glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data); - gchar *page_size; + gchar *page_size_name, *page_size_id; GList *template_names; gl_debug (DEBUG_MEDIA_SELECT, "START"); /* Update template selections for new page size */ - page_size = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - if ( strlen(page_size) ) { - gl_debug (DEBUG_MEDIA_SELECT, "page_size = \"%s\"", page_size); - template_names = gl_template_get_name_list (page_size); + page_size_name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); + if ( strlen(page_size_name) ) { + gl_debug (DEBUG_MEDIA_SELECT, "page_size_name = \"%s\"", page_size_name); + page_size_id = gl_paper_lookup_id_from_name (page_size_name); + template_names = gl_template_get_name_list (page_size_id); if (template_names == NULL) { template_names = g_list_append (template_names, g_strdup("")); } @@ -347,8 +353,9 @@ page_size_entry_changed_cb (GtkEntry *entry, gtk_entry_set_text (GTK_ENTRY (media_select->template_entry), template_names->data); gl_template_free_name_list (&template_names); + g_free (page_size_id); } - g_free (page_size); + g_free (page_size_name); gl_debug (DEBUG_MEDIA_SELECT, "END"); } @@ -371,7 +378,7 @@ template_entry_changed_cb (GtkEntry *entry, if ( strlen(name) ) { gl_debug (DEBUG_MEDIA_SELECT, "name = \"%s\"", name); gl_wdgt_mini_preview_set_label (GL_WDGT_MINI_PREVIEW (media_select->mini_preview), - name); + name); gl_debug (DEBUG_MEDIA_SELECT, "m1"); details_update (media_select, name); gl_debug (DEBUG_MEDIA_SELECT, "m2"); diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 48a6e04e..5f39fa60 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -23,7 +23,6 @@ #include #include -#include #include "wdgt-mini-preview.h" #include "marshal.h" diff --git a/glabels2/src/xml-paper.c b/glabels2/src/xml-paper.c new file mode 100644 index 00000000..41b0dec3 --- /dev/null +++ b/glabels2/src/xml-paper.c @@ -0,0 +1,126 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * xml-paper.c: paper xml module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include + +#include "xml.h" +#include "xml-paper.h" + +#include "debug.h" + +/*===========================================*/ +/* Private types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +glPaper *gl_xml_paper_parse_paper (xmlNodePtr paper_node); + + + +/*****************************************************************************/ +/* Read papers from paper file. */ +/*****************************************************************************/ +GList * +gl_xml_paper_read_papers_from_file (GList *papers, + gchar *xml_filename) +{ + xmlDocPtr doc; + xmlNodePtr root, node; + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + LIBXML_TEST_VERSION; + + doc = xmlParseFile (xml_filename); + if (!doc) { + g_warning ("\"%s\" is not a glabels paper file (not XML)", + xml_filename); + return papers; + } + + root = xmlDocGetRootElement (doc); + if (!root || !root->name) { + g_warning ("\"%s\" is not a glabels paper file (no root node)", + xml_filename); + xmlFreeDoc (doc); + return papers; + } + if (!xmlStrEqual (root->name, "GLabels-paper-sizes")) { + g_warning ("\"%s\" is not a glabels paper file (wrong root node)", + xml_filename); + xmlFreeDoc (doc); + return papers; + } + + for (node = root->xmlChildrenNode; node != NULL; node = node->next) { + + if (xmlStrEqual (node->name, "Paper-size")) { + paper = gl_xml_paper_parse_paper (node); + papers = g_list_append (papers, paper); + } else { + if ( !xmlNodeIsText(node) ) { + if (!xmlStrEqual (node->name,"comment")) { + g_warning ("bad node = \"%s\"",node->name); + } + } + } + } + + xmlFreeDoc (doc); + + gl_debug (DEBUG_PAPER, "END"); + return papers; +} + +/*****************************************************************************/ +/* Parse XML paper Node. */ +/*****************************************************************************/ +glPaper * +gl_xml_paper_parse_paper (xmlNodePtr paper_node) +{ + glPaper *paper; + + gl_debug (DEBUG_PAPER, "START"); + + paper = g_new0 (glPaper, 1); + + paper->id = xmlGetProp (paper_node, "id"); + paper->name = xmlGetProp (paper_node, "_name"); + + paper->width = gl_xml_get_prop_length (paper_node, "width", 0); + paper->height = gl_xml_get_prop_length (paper_node, "height", 0); + + gl_debug (DEBUG_PAPER, "END"); + + return paper; +} + diff --git a/glabels2/src/xml-paper.h b/glabels2/src/xml-paper.h new file mode 100644 index 00000000..6bae5087 --- /dev/null +++ b/glabels2/src/xml-paper.h @@ -0,0 +1,37 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * xml-paper.h: paper xml module header file + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __XML_PAPER_H__ +#define __XML_PAPER_H__ + +#include + +#include "paper.h" + +G_BEGIN_DECLS + +GList *gl_xml_paper_read_papers_from_file (GList *papers, + gchar *xml_filename); + +G_END_DECLS + +#endif /* __XML_PAPER_H__ */ diff --git a/glabels2/src/xml-template.c b/glabels2/src/xml-template.c index 340ba60e..6327e60a 100644 --- a/glabels2/src/xml-template.c +++ b/glabels2/src/xml-template.c @@ -23,9 +23,9 @@ #include #include -#include #include "util.h" +#include "paper.h" #include "xml.h" #include "xml-template.h" @@ -81,6 +81,8 @@ gl_xml_template_read_templates_from_file (GList *templates, gl_debug (DEBUG_TEMPLATE, "START"); + LIBXML_TEST_VERSION; + doc = xmlParseFile (xml_filename); if (!doc) { g_warning ("\"%s\" is not a glabels template file (not XML)", @@ -130,7 +132,7 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node) { glTemplate *template; xmlNodePtr node; - const GnomePrintPaper *paper; + glPaper *paper; gl_debug (DEBUG_TEMPLATE, "START"); @@ -141,22 +143,20 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node) gl_debug (DEBUG_TEMPLATE, "Sheet = %s", template->name->data); template->page_size = xmlGetProp (sheet_node, "size"); - if ( xmlStrEqual (template->page_size,"US-Letter")) { - template->page_size = "US Letter"; - } if (xmlStrEqual (template->page_size, "Other")) { template->page_width = gl_xml_get_prop_length (sheet_node, "width", 0); template->page_height = gl_xml_get_prop_length (sheet_node, "height", 0); } else { - paper = gnome_print_paper_get_by_name (template->page_size); + paper = gl_paper_from_id (template->page_size); if (paper != NULL) { template->page_width = paper->width; template->page_height = paper->height; } else { - g_warning (_("Unknown page size \"%s\""), template->page_size); + g_warning (_("Unknown page size id \"%s\""), template->page_size); } + gl_paper_free (&paper); } template->description = xmlGetProp (sheet_node, "description"); -- 2.39.5