2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * glabels.c: main program module
6 * Copyright (C) 2001 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <libgnomeprint/gnome-print-master.h>
29 #include "xml-label.h"
34 /*============================================*/
36 /*============================================*/
37 static gboolean help_flag = FALSE;
38 static gboolean version_flag = FALSE;
39 static gchar *output = "output.ps";
40 static gint n_copies = 1;
41 static gint n_sheets = 1;
42 static gboolean outline_flag = FALSE;
43 static gboolean reverse_flag = FALSE;
45 static struct poptOption options[] = {
46 {"help", 'h', POPT_ARG_NONE, &help_flag, 1,
47 N_("print this message"), NULL},
48 {"version", 'v', POPT_ARG_NONE, &version_flag, 0,
49 N_("print the version of glabels-batch being used"), NULL},
50 {"output", 'o', POPT_ARG_STRING, &output, 0,
51 N_("set output filename (default=\"output.ps\")"), N_("filename")},
52 {"sheets", 's', POPT_ARG_INT, &n_sheets, 0,
53 N_("number of sheets (default=1)"), N_("sheets")},
54 {"copies", 'c', POPT_ARG_INT, &n_copies, 0,
55 N_("number of copies (default=1)"), N_("copies")},
56 {"outline", 'l', POPT_ARG_NONE, &outline_flag, 0,
57 N_("print outlines (to test printer alignment)"), NULL},
58 {"reverse", 'r', POPT_ARG_NONE, &reverse_flag, 0,
59 N_("print in reverse (i.e. a mirror image)"), NULL},
60 {NULL, '\0', 0, NULL, 0, NULL, NULL}
65 /*****************************************************************************/
67 /*****************************************************************************/
75 GSList *p, *file_list = NULL;
77 GnomePrintMaster *master = NULL;
79 GnomePrintConfig *config = NULL;
80 glLabel *label = NULL;
81 glXMLLabelStatus status;
83 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
88 /* argument parsing */
89 pctx = poptGetContext (NULL, argc, argv, options, 0);
90 poptSetOtherOptionHelp (pctx, _("[OPTION...] GLABELS_FILE...") );
91 if ( (rc = poptGetNextOpt(pctx)) < -1 ) {
92 fprintf (stderr, "%s: %s\n",
93 poptBadOption (pctx,0), poptStrerror(rc));
94 poptPrintUsage (pctx, stderr, 0);
98 fprintf ( stderr, "glabels-batch %s\n", VERSION );
101 poptPrintHelp (pctx, stderr, 0);
104 args = (char **) poptGetArgs (pctx);
105 for (n_files = 0; args && args[n_files]; n_files++) {
106 file_list = g_slist_append (file_list, args[n_files]);
109 fprintf ( stderr, _("missing glabels file\n") );
110 poptPrintHelp (pctx, stderr, 0);
113 poptFreeContext (pctx);
115 /* initialize components */
119 /* now print the files */
120 for (p = file_list; p; p = p->next) {
121 gl_xml_label_open (p->data, &status);
122 if ( status == XML_LABEL_OK ) {
124 if ( master == NULL ) {
125 master = gnome_print_master_new ();
126 config = gnome_print_master_get_config (master);
127 abs_fn = gl_util_make_absolute ( output );
128 gnome_print_config_set (config,
129 GNOME_PRINT_KEY_OUTPUT_FILENAME,
134 gl_print_batch( master, label, n_sheets, n_copies,
135 outline_flag, reverse_flag );
137 g_object_unref( label );
140 fprintf ( stderr, _("cannot open glabels file %s\n"),
144 if ( master != NULL ) {
145 gnome_print_master_print (master);
148 g_slist_free (file_list);