Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMartin Kretzschmar <martink@src.gnome.org>2004-12-22 22:00:20 (GMT)
committer Martin Kretzschmar <martink@src.gnome.org>2004-12-22 22:00:20 (GMT)
commit042e7f3f564b9b0f3ab59302235d98febce420e6 (patch)
tree0c1c3c34352e175d6277711c5a99a5ef51c5c14e /shell
parentca0836cb912f3b88834cae97774079314727c6e2 (diff)
Set up a print dialog for "PostScript injection" method.
* shell/ev-window.c (ev_window_cmd_file_print, ev_window_print) (using_postscript_printer): Set up a print dialog for "PostScript injection" method. * shell/ev-print-job.h, shell/ev-print-job.c: stub classes for EvPrintJob. * shell/Makefile.am (evince_SOURCES): add ev-print-job.[ch]
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/ev-print-job.c62
-rw-r--r--shell/ev-print-job.h43
-rw-r--r--shell/ev-window.c92
4 files changed, 197 insertions, 2 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 4740485..33e7483 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -23,6 +23,8 @@ evince_SOURCES= \
ev-application.h \
ev-marshal.c \
ev-marshal.h \
+ ev-print-job.c \
+ ev-print-job.h \
ev-view.c \
ev-view.h \
ev-window.c \
diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c
new file mode 100644
index 0000000..ea261c3
--- /dev/null
+++ b/shell/ev-print-job.c
@@ -0,0 +1,62 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince 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.
+ *
+ * Evince 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 <glib.h>
+#include <glib-object.h>
+
+#include "ev-print-job.h"
+
+#define EV_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_PRINT_JOB, EvPrintJobClass))
+#define EV_IS_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_PRINT_JOB))
+#define EV_PRINT_JOB_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_PRINT_JOB, EvPrintJobClass))
+
+struct _EvPrintJob {
+ GObject parent_instance;
+};
+
+struct _EvPrintJobClass {
+ GObjectClass parent_class;
+};
+
+
+G_DEFINE_TYPE (EvPrintJob, ev_print_job, G_TYPE_OBJECT);
+
+static void
+ev_print_job_class_init (EvPrintJobClass *ev_print_job_class)
+{
+ GObjectClass *g_object_class;
+
+ g_object_class = G_OBJECT_CLASS (ev_print_job_class);
+}
+
+static void
+ev_print_job_init (EvPrintJob *ev_print_job)
+{
+}
+
+void
+ev_print_job_print (EvPrintJob *job, GtkWindow *parent)
+{
+ g_return_if_fail (EV_IS_PRINT_JOB (job));
+ /* FIXME */
+ g_printerr ("Printing...\n");
+}
diff --git a/shell/ev-print-job.h b/shell/ev-print-job.h
new file mode 100644
index 0000000..0b5dc2a
--- /dev/null
+++ b/shell/ev-print-job.h
@@ -0,0 +1,43 @@
+/* this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2004 Martin Kretzschmar
+ *
+ * Author:
+ * Martin Kretzschmar <martink@gnome.org>
+ *
+ * Evince 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.
+ *
+ * Evince 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 EV_PRINT_JOB_H
+#define EV_PRINT_JOB_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvPrintJob EvPrintJob;
+typedef struct _EvPrintJobClass EvPrintJobClass;
+
+#define EV_TYPE_PRINT_JOB (ev_print_job_get_type())
+#define EV_PRINT_JOB(object) (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_PRINT_JOB, EvPrintJob))
+#define EV_IS_PRINT_JOB(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_PRINT_JOB))
+
+GType ev_print_job_get_type (void);
+void ev_print_job_print (EvPrintJob *job, GtkWindow *parent);
+
+G_END_DECLS
+
+#endif /* !EV_PRINT_JOB_H */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 4e1cc65..0ca5df0 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -33,6 +33,7 @@
#include "ev-sidebar-bookmarks.h"
#include "ev-sidebar-thumbnails.h"
#include "ev-view.h"
+#include "ev-print-job.h"
#include "eggfindbar.h"
#include "pdf-document.h"
@@ -42,6 +43,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
+#include <libgnomeprintui/gnome-print-dialog.h>
#include <string.h>
@@ -300,11 +302,97 @@ ev_window_cmd_file_open (GtkAction *action, EvWindow *ev_window)
ev_application_open (EV_APP, NULL);
}
+static gboolean
+using_postscript_printer (GnomePrintConfig *config)
+{
+ const guchar *driver;
+ const guchar *transport;
+
+ driver = gnome_print_config_get (
+ config, (const guchar *)"Settings.Engine.Backend.Driver");
+
+ transport = gnome_print_config_get (
+ config, (const guchar *)"Settings.Transport.Backend");
+
+ if (driver) {
+ if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
+ return TRUE;
+ else
+ return FALSE;
+ } else if (transport) {
+ if (!strcmp ((const gchar *)transport, "CUPS"))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
-ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
+ev_window_print (EvWindow *ev_window)
{
+ GnomePrintConfig *config;
+ GnomePrintJob *job;
+ GtkWidget *print_dialog;
+ EvPrintJob *print_job = NULL;
+
g_return_if_fail (EV_IS_WINDOW (ev_window));
- /* FIXME */
+ g_return_if_fail (ev_window->priv->document != NULL);
+
+ config = gnome_print_config_default ();
+ job = gnome_print_job_new (config);
+
+ print_dialog = gnome_print_dialog_new (job, _("Print"),
+ (GNOME_PRINT_DIALOG_RANGE |
+ GNOME_PRINT_DIALOG_COPIES));
+ gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
+ GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
+ FALSE);
+
+ while (TRUE) {
+ int response;
+ response = gtk_dialog_run (GTK_DIALOG (print_dialog));
+
+ if (response != GNOME_PRINT_DIALOG_RESPONSE_PRINT)
+ break;
+
+ /* FIXME: Change this when we have the first backend
+ * that can print more than postscript
+ */
+ if (!using_postscript_printer (config)) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (print_dialog), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
+ _("Printing is not supported on this printer."));
+ gtk_message_dialog_format_secondary_text (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("You were trying to print to a printer using the \"%s\" driver. This program requires a PostScript printer driver."),
+ gnome_print_config_get (
+ config, "Settings.Engine.Backend.Driver"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ continue;
+ }
+
+ print_job = g_object_new (EV_TYPE_PRINT_JOB,
+ "document", ev_window->priv->document,
+ "print-dialog", print_dialog,
+ NULL);
+ break;
+ }
+
+ gtk_widget_destroy (print_dialog);
+
+ if (print_job != NULL)
+ ev_print_job_print (print_job, GTK_WINDOW (ev_window));
+}
+
+static void
+ev_window_cmd_file_print (GtkAction *action, EvWindow *ev_window)
+{
+ ev_window_print (ev_window);
}
static void