From: Jim Evins Date: Sat, 28 Jun 2003 03:30:49 +0000 (+0000) Subject: - xml-template.c: use page size name as a fallback if id doesn't exist. X-Git-Tag: glabels-2_3_0~624 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=23225999ec5847db64faffcae78e0aa136a6c1ed;p=glabels - xml-template.c: use page size name as a fallback if id doesn't exist. - print.c: don't set page size id for config git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@265 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 03dee0ca..2b72170d 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -40,8 +40,6 @@ #include "debug.h" -#define GL_PRINT_DEFAULT_PAPER "US Letter" - #define ARC_FINE 2 /* Resolution in degrees of large arcs */ #define ARC_COURSE 5 /* Resolution in degrees of small arcs */ @@ -386,44 +384,31 @@ print_info_new (GnomePrintJob *job, gl_debug (DEBUG_PRINT, "START"); + g_return_val_if_fail (job && GNOME_IS_PRINT_JOB (job), NULL); + g_return_val_if_fail (label && GL_IS_LABEL (label), NULL); + template = gl_label_get_template (label); - if (template == NULL) { - g_warning ("Label has no template"); - return NULL; - } + g_return_val_if_fail (template, NULL); + g_return_val_if_fail (template->page_size, NULL); + g_return_val_if_fail (template->page_width > 0, NULL); + g_return_val_if_fail (template->page_height > 0, NULL); pi->pc = gnome_print_job_get_context (job); pi->config = gnome_print_job_get_config (job); - if ((template != NULL) && (template->page_size != NULL)) { - - gl_debug (DEBUG_PRINT, - "setting page size = \"%s\"", template->page_size); - - /* Currently cannot set page size directly from name, */ - /* since we must set Ids not Names and there is no */ - /* way to do the reverse lookup of Id from Name. */ - /* Sometimes they are the same, but not always */ - /* (e.g. for the name "US Letter" id="USLetter" */ - /* So we always use the "Custom" Id. */ - gnome_print_config_set (pi->config, - GNOME_PRINT_KEY_PAPER_SIZE, - "Custom"); - gnome_print_config_set_length (pi->config, - GNOME_PRINT_KEY_PAPER_WIDTH, - template->page_width, - GNOME_PRINT_PS_UNIT); - gnome_print_config_set_length (pi->config, - GNOME_PRINT_KEY_PAPER_HEIGHT, - template->page_height, - GNOME_PRINT_PS_UNIT); - } else { - g_warning ("Cannot determine correct page size."); - gnome_print_config_set (pi->config, - GNOME_PRINT_KEY_PAPER_SIZE, - GL_PRINT_DEFAULT_PAPER); - } + gl_debug (DEBUG_PRINT, + "setting page size = \"%s\"", template->page_size); + + gnome_print_config_set_length (pi->config, + GNOME_PRINT_KEY_PAPER_WIDTH, + template->page_width, + GNOME_PRINT_PS_UNIT); + gnome_print_config_set_length (pi->config, + GNOME_PRINT_KEY_PAPER_HEIGHT, + template->page_height, + GNOME_PRINT_PS_UNIT); + pi->page_width = template->page_width; pi->page_height = template->page_height; diff --git a/glabels2/src/xml-template.c b/glabels2/src/xml-template.c index 7beda196..79ad7ef3 100644 --- a/glabels2/src/xml-template.c +++ b/glabels2/src/xml-template.c @@ -152,11 +152,19 @@ gl_xml_template_parse_sheet (xmlNodePtr sheet_node) } else { paper = gl_paper_from_id (template->page_size); + if (paper == NULL) { + /* This should always be an id, but just in case a name + slips by! */ + g_warning (_("Unknown page size id \"%s\", trying as name"), + template->page_size); + paper = gl_paper_from_name (template->page_size); + } if (paper != NULL) { template->page_width = paper->width; template->page_height = paper->height; } else { - g_warning (_("Unknown page size id \"%s\""), template->page_size); + g_warning (_("Unknown page size id or name \"%s\""), + template->page_size); } gl_paper_free (&paper); }