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 \
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 \
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;
(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) ||
GL_DEBUG_FILE,
GL_DEBUG_LABEL,
GL_DEBUG_TEMPLATE,
+ GL_DEBUG_PAPER,
GL_DEBUG_XML,
GL_DEBUG_MERGE,
GL_DEBUG_UNDO,
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;
#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__
#include <config.h>
#include <gnome.h>
-#include <libgnomeprint/gnome-print-master.h>
+#include <libgnomeprint/gnome-print-job.h>
#include "merge-init.h"
#include "xml-label.h"
+#include "paper.h"
#include "template.h"
#include "print.h"
#include "util.h"
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;
/* initialize components */
gl_merge_init ();
+ gl_paper_init ();
gl_template_init ();
/* now print the files */
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);
(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);
#include "splash.h"
#include "stock.h"
#include "merge-init.h"
+#include "paper.h"
#include "template.h"
#include "prefs.h"
#include "debug.h"
{ "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 },
gl_prefs_init ();
gl_prefs_load_settings ();
+ /* Initialize subsystems */
+ gl_paper_init();
gl_template_init();
gl_merge_init();
gl_recent_init();
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * paper.c: paper module
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * 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 <config.h>
+
+#include <string.h>
+#include <libgnome/libgnome.h>
+
+#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);
+
+\f
+/*****************************************************************************/
+/* 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;
+}
+
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * paper.h: paper module header file
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * 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 <glib.h>
+
+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
/* Private macros and constants. */
/*========================================================*/
-#define US_LETTER "US Letter"
-#define A4 "A4"
+#define US_LETTER_ID "US-Letter"
+#define A4_ID "A4"
/*========================================================*/
/* Private types. */
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));
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),
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);
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 ();
#include "prefs.h"
#include "util.h"
+#include "paper.h"
#include "debug.h"
/* 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
void
gl_prefs_load_settings (void)
{
- gchar *string;
+ gchar *string;
+ glPaper *paper;
gl_debug (DEBUG_PREFS, "START");
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");
#include <time.h>
#include <ctype.h>
#include <gtk/gtk.h>
-#include <libgnomeprint/gnome-print-paper.h>
-#include <libgnomeprintui/gnome-printer-dialog.h>
#include <libgnomeprintui/gnome-print-dialog.h>
-#include <libgnomeprint/gnome-print-master.h>
-#include <libgnomeprintui/gnome-print-master-preview.h>
+#include <libgnomeprint/gnome-print-job.h>
+#include <libgnomeprintui/gnome-print-job-preview.h>
#include "print-dialog.h"
#include "hig.h"
#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. */
/*===========================================*/
/*===========================================*/
/* Private function prototypes. */
/*===========================================*/
+
static GtkWidget *job_page_new (GtkWidget *dlg, glLabel *label);
static GtkWidget *printer_page_new (GtkWidget *dlg, glLabel *label);
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);
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
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));
}
/*---------------------------------------------------------------------------*/
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));
}
#include <time.h>
#include <ctype.h>
#include <gtk/gtk.h>
-#include <libgnomeprint/gnome-print-paper.h>
-#include <libgnomeprintui/gnome-printer-dialog.h>
#include "print.h"
#include "label.h"
/*=========================================================================*/
/* 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);
/* Simple (no merge data) print command. */
/*****************************************************************************/
void
-gl_print_simple (GnomePrintMaster *master,
+gl_print_simple (GnomePrintJob *job,
glLabel *label,
gint n_sheets,
gint first,
gl_debug (DEBUG_PRINT, "START");
- pi = print_info_new (master, label);
+ pi = print_info_new (job, label);
origins = gl_template_get_origins (pi->template);
/* 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,
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);
/* 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,
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);
/* 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,
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);
/* 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);
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)) {
#define __PRINT_H__
#include <gnome.h>
-#include <libgnomeprint/gnome-print-master.h>
-#include <libgnomeprintui/gnome-print-master-preview.h>
+#include <libgnomeprint/gnome-print-job.h>
+
#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,
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,
#include <config.h>
#include <string.h>
-#include <libgnomeprint/gnome-print-paper.h>
#include "prefs.h"
#include "util.h"
#include "xml.h"
#include "template.h"
#include "xml-template.h"
+#include "paper.h"
#include "debug.h"
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");
}
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);
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;
}
g_list_append (template->label.any.markups,
gl_template_markup_margin_new (5.0));
+ gl_paper_free (&paper);
+
return template;
}
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);
#define __TEMPLATE_H__
#include <libgnome/libgnome.h>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
G_BEGIN_DECLS
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);
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,
#include "wdgt-mini-preview.h"
#include "prefs.h"
#include "util.h"
+#include "paper.h"
#include "marshal.h"
#include "debug.h"
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);
/* 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);
G_CALLBACK (template_entry_changed_cb),
media_select);
+ g_free (page_size_name);
+
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
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(""));
}
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");
}
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");
#include <config.h>
#include <math.h>
-#include <libgnomeprint/gnome-print-paper.h>
#include "wdgt-mini-preview.h"
#include "marshal.h"
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * xml-paper.c: paper xml module
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * 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 <config.h>
+
+#include <string.h>
+
+#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);
+
+
+\f
+/*****************************************************************************/
+/* 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;
+}
+
--- /dev/null
+/*
+ * (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ * xml-paper.h: paper xml module header file
+ *
+ * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
+ *
+ * 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 <libgnome/libgnome.h>
+
+#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__ */
#include <config.h>
#include <string.h>
-#include <libgnomeprint/gnome-print-paper.h>
#include "util.h"
+#include "paper.h"
#include "xml.h"
#include "xml-template.h"
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)",
{
glTemplate *template;
xmlNodePtr node;
- const GnomePrintPaper *paper;
+ glPaper *paper;
gl_debug (DEBUG_TEMPLATE, "START");
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");