+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
/*
* (GLABELS) Label and Business Card Creation program for GNOME
*
static gchar *input = NULL;
static struct poptOption options[] = {
- {"help", '?', POPT_ARG_NONE, &help_flag, 1,
- N_("print this message"), NULL},
- {"version", 'v', POPT_ARG_NONE, &version_flag, 0,
- N_("print the version of glabels-batch being used"), NULL},
- {"output", 'o', POPT_ARG_STRING, &output, 0,
- N_("set output filename (default=\"output.ps\")"), N_("filename")},
- {"sheets", 's', POPT_ARG_INT, &n_sheets, 0,
- N_("number of sheets (default=1)"), N_("sheets")},
- {"copies", 'c', POPT_ARG_INT, &n_copies, 0,
- N_("number of copies (default=1)"), N_("copies")},
- {"first", 'f', POPT_ARG_INT, &first, 0,
- N_("first label on first sheet (default=1)"), N_("first")},
- {"outline", 'l', POPT_ARG_NONE, &outline_flag, 0,
- N_("print outlines (to test printer alignment)"), NULL},
- {"reverse", 'r', POPT_ARG_NONE, &reverse_flag, 0,
- N_("print in reverse (i.e. a mirror image)"), NULL},
- {"cropmarks", 'C', POPT_ARG_NONE, &crop_marks_flag, 0,
- N_("print crop marks"), NULL},
- {"input", 'i', POPT_ARG_STRING, &input, 0,
- N_("input file for merging"), N_("filename")},
- {NULL, '\0', 0, NULL, 0, NULL, NULL}
+ {"help", '?', POPT_ARG_NONE, &help_flag, 1,
+ N_("print this message"), NULL},
+ {"version", 'v', POPT_ARG_NONE, &version_flag, 0,
+ N_("print the version of glabels-batch being used"), NULL},
+ {"output", 'o', POPT_ARG_STRING, &output, 0,
+ N_("set output filename (default=\"output.ps\")"), N_("filename")},
+ {"sheets", 's', POPT_ARG_INT, &n_sheets, 0,
+ N_("number of sheets (default=1)"), N_("sheets")},
+ {"copies", 'c', POPT_ARG_INT, &n_copies, 0,
+ N_("number of copies (default=1)"), N_("copies")},
+ {"first", 'f', POPT_ARG_INT, &first, 0,
+ N_("first label on first sheet (default=1)"), N_("first")},
+ {"outline", 'l', POPT_ARG_NONE, &outline_flag, 0,
+ N_("print outlines (to test printer alignment)"), NULL},
+ {"reverse", 'r', POPT_ARG_NONE, &reverse_flag, 0,
+ N_("print in reverse (i.e. a mirror image)"), NULL},
+ {"cropmarks", 'C', POPT_ARG_NONE, &crop_marks_flag, 0,
+ N_("print crop marks"), NULL},
+ {"input", 'i', POPT_ARG_STRING, &input, 0,
+ N_("input file for merging"), N_("filename")},
+ {NULL, '\0', 0, NULL, 0, NULL, NULL}
};
int
main (int argc, char **argv)
{
- GnomeProgram *program;
- poptContext pctx;
- gchar **args;
- gint rc;
- GSList *p, *file_list = NULL;
- gint n_files;
- GnomePrintJob *job = NULL;
- gchar *abs_fn;
- GnomePrintConfig *config = NULL;
- glLabel *label = NULL;
- glMerge *merge = NULL;
- glXMLLabelStatus status;
- glPrintFlags flags;
-
- bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR);
- textdomain (GETTEXT_PACKAGE);
-
- /* Initialize minimal gnome program */
- program = gnome_program_init ("glabels-batch", VERSION,
- LIBGNOME_MODULE, 1, argv,
- GNOME_PROGRAM_STANDARD_PROPERTIES,
- NULL);
-
- /* argument parsing */
- pctx = poptGetContext (NULL, argc, (const char **)argv, options, 0);
- poptSetOtherOptionHelp (pctx, _("[OPTION...] GLABELS_FILE...") );
- if ( (rc = poptGetNextOpt(pctx)) < -1 ) {
- fprintf (stderr, "%s: %s\n",
- poptBadOption (pctx,0), poptStrerror(rc));
- poptPrintUsage (pctx, stderr, 0);
- return -1;
- }
- if ( version_flag ) {
- fprintf ( stderr, "glabels-batch %s\n", VERSION );
- return -1;
- }
- if ( help_flag ) {
- poptPrintHelp (pctx, stderr, 0);
- return -1;
- }
- args = (char **) poptGetArgs (pctx);
- for (n_files = 0; args && args[n_files]; n_files++) {
- file_list = g_slist_append (file_list, args[n_files]);
- }
- if ( !n_files ) {
- fprintf ( stderr, _("missing glabels file\n") );
- poptPrintHelp (pctx, stderr, 0);
- return -1;
- }
- poptFreeContext (pctx);
-
- flags.outline = outline_flag;
- flags.reverse = reverse_flag;
- flags.crop_marks = crop_marks_flag;
-
- /* initialize components */
- gl_debug_init ();
- gl_merge_init ();
- gl_paper_init ();
- gl_template_init ();
-
- /* now print the files */
- for (p = file_list; p; p = p->next) {
- g_print ("LABEL FILE = %s\n", (gchar *) p->data);
- label = gl_xml_label_open (p->data, &status);
-
-
- if ( status == XML_LABEL_OK ) {
-
- if (input != NULL) {
- merge = gl_label_get_merge (label);
- if (merge != NULL) {
- gl_merge_set_src(merge, input);
- gl_label_set_merge(label, merge);
- } else {
- fprintf ( stderr,
- _("cannot perform document merge with glabels file %s\n"),
- (char *)p->data );
- }
- }
- if ( job == NULL ) {
- job = gnome_print_job_new (NULL);
- abs_fn = gl_util_make_absolute ( output );
- config = gnome_print_job_get_config (job);
- gnome_print_config_set (config,
- "Printer",
- "GENERIC");
- gnome_print_config_set (config,
- "Settings.Transport.Backend",
- "file");
- gnome_print_config_set (config,
- GNOME_PRINT_KEY_OUTPUT_FILENAME,
- abs_fn);
- g_free( abs_fn );
- }
-
- gl_print_batch (job, label, n_sheets, n_copies, first, &flags);
- g_object_unref (label);
- }
- else {
- fprintf ( stderr, _("cannot open glabels file %s\n"),
- (char *)p->data );
- }
- }
- if ( job != NULL ) {
-
- gnome_print_job_close (job);
- gnome_print_job_print (job);
-
- g_object_unref (job);
- }
-
- g_slist_free (file_list);
-
- return 0;
+ GnomeProgram *program;
+ poptContext pctx;
+ gchar **args;
+ gint rc;
+ GSList *p, *file_list = NULL;
+ gint n_files;
+ GnomePrintJob *job = NULL;
+ gchar *abs_fn;
+ GnomePrintConfig *config = NULL;
+ glLabel *label = NULL;
+ glMerge *merge = NULL;
+ glXMLLabelStatus status;
+ glPrintFlags flags;
+
+ bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR);
+ textdomain (GETTEXT_PACKAGE);
+
+ /* Initialize minimal gnome program */
+ program = gnome_program_init ("glabels-batch", VERSION,
+ LIBGNOME_MODULE, 1, argv,
+ GNOME_PROGRAM_STANDARD_PROPERTIES,
+ NULL);
+
+ /* argument parsing */
+ pctx = poptGetContext (NULL, argc, (const char **)argv, options, 0);
+ poptSetOtherOptionHelp (pctx, _("[OPTION...] GLABELS_FILE...") );
+ if ( (rc = poptGetNextOpt(pctx)) < -1 ) {
+ fprintf (stderr, "%s: %s\n",
+ poptBadOption (pctx,0), poptStrerror(rc));
+ poptPrintUsage (pctx, stderr, 0);
+ return -1;
+ }
+ if ( version_flag ) {
+ fprintf ( stderr, "glabels-batch %s\n", VERSION );
+ return -1;
+ }
+ if ( help_flag ) {
+ poptPrintHelp (pctx, stderr, 0);
+ return -1;
+ }
+ args = (char **) poptGetArgs (pctx);
+ for (n_files = 0; args && args[n_files]; n_files++) {
+ file_list = g_slist_append (file_list, args[n_files]);
+ }
+ if ( !n_files ) {
+ fprintf ( stderr, _("missing glabels file\n") );
+ poptPrintHelp (pctx, stderr, 0);
+ return -1;
+ }
+ poptFreeContext (pctx);
+
+ flags.outline = outline_flag;
+ flags.reverse = reverse_flag;
+ flags.crop_marks = crop_marks_flag;
+
+ /* initialize components */
+ gl_debug_init ();
+ gl_merge_init ();
+ gl_paper_init ();
+ gl_template_init ();
+
+ /* now print the files */
+ for (p = file_list; p; p = p->next) {
+ g_print ("LABEL FILE = %s\n", (gchar *) p->data);
+ label = gl_xml_label_open (p->data, &status);
+
+
+ if ( status == XML_LABEL_OK ) {
+
+ if (input != NULL) {
+ merge = gl_label_get_merge (label);
+ if (merge != NULL) {
+ gl_merge_set_src(merge, input);
+ gl_label_set_merge(label, merge);
+ } else {
+ fprintf ( stderr,
+ _("cannot perform document merge with glabels file %s\n"),
+ (char *)p->data );
+ }
+ }
+ if ( job == NULL ) {
+ job = gnome_print_job_new (NULL);
+ abs_fn = gl_util_make_absolute ( output );
+ config = gnome_print_job_get_config (job);
+ gnome_print_config_set (config,
+ (guchar*)"Printer",
+ (guchar*)"GENERIC");
+ gnome_print_config_set (config,
+ (guchar*)"Settings.Transport.Backend",
+ (guchar*)"file");
+ gnome_print_config_set (config,
+ (guchar*)GNOME_PRINT_KEY_OUTPUT_FILENAME,
+ (guchar*)abs_fn);
+ g_free( abs_fn );
+ }
+
+ gl_print_batch (job, label, n_sheets, n_copies, first, &flags);
+ g_object_unref (label);
+ }
+ else {
+ fprintf ( stderr, _("cannot open glabels file %s\n"),
+ (char *)p->data );
+ }
+ }
+ if ( job != NULL ) {
+
+ gnome_print_job_close (job);
+ gnome_print_job_print (job);
+
+ g_object_unref (job);
+ }
+
+ g_slist_free (file_list);
+
+ return 0;
}