]> git.sur5r.net Git - glabels/commitdiff
- xml-template.c: use page size name as a fallback if id doesn't exist.
authorJim Evins <evins@snaught.com>
Sat, 28 Jun 2003 03:30:49 +0000 (03:30 +0000)
committerJim Evins <evins@snaught.com>
Sat, 28 Jun 2003 03:30:49 +0000 (03:30 +0000)
- 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

glabels2/src/print.c
glabels2/src/xml-template.c

index 03dee0ca32252bc0936f2704f9dc9fafaf014600..2b72170dd6c221cde532d22837dd3a8380bb7256 100644 (file)
@@ -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;
 
index 7beda196283a5799fe1868c93ccb8ae5d5b360c8..79ad7ef3242306a216ec63cc98e04bb392435e27 100644 (file)
@@ -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);
        }