summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 666c1a4)
raw | patch | inline | side by side (parent: 666c1a4)
author | keescook <keescook@users.sourceforge.net> | |
Mon, 5 Feb 2007 17:54:07 +0000 (17:54 +0000) | ||
committer | keescook <keescook@users.sourceforge.net> | |
Mon, 5 Feb 2007 17:54:07 +0000 (17:54 +0000) |
configure.ac | patch | blob | history | |
src/Makefile.am | patch | blob | history | |
src/extension/internal/ps.cpp | patch | blob | history | |
src/extension/internal/ps.h | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 3709c6ae99dc2df01da1b87ac0800de899d2e3b6..f5073792c092776c73e260d7d9894644e40fbfc5 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_DEFINE(HAVE_CAIRO_PDF, 1, [Whether the Cairo PDF backend is available])
fi
+PKG_CHECK_MODULES(GTK_UNIX_PRINT, gtk+-unix-print-2.0, gtk_unix_print=yes, gtk_unix_print=no)
+if test "x$gtk_unix_print" = "xyes"; then
+ AC_DEFINE(HAVE_GTK_UNIX_PRINT, 1, [Whether the GTK Unix printing backend is available])
+fi
+
dnl Shouldn't we test for libpng and libz?
INKSCAPE_LIBS="$INKSCAPE_LIBS -lpng -lz"
diff --git a/src/Makefile.am b/src/Makefile.am
index 1899832d7092fe5c4a097143b6e160e31b39c9d2..7719cd2166a2be1b315db61d5163c2230a1f42ce 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
$(GNOME_VFS_CFLAGS) \
$(INKBOARD_CFLAGS) \
$(XFT_CFLAGS) \
+ $(GTK_UNIX_PRINT_CFLAGS) \
-DPOTRACE=\"potrace\" \
$(INKSCAPE_CFLAGS) \
-I$(top_srcdir)/cxxtest
index 8eba5fb18ead58592c9ee4527882f4e31465c4aa..c1c8bf49173d1977dca70cd67849a7306fe4111d 100644 (file)
#include <gtk/gtkentry.h>
#include <gtk/gtktooltips.h>
+#include <gtk/gtkprintunixdialog.h>
+
#include <glibmm/i18n.h>
#include "display/nr-arena-item.h"
#include "display/canvas-bpath.h"
return;
}
+static void
+unix_print_complete (GtkPrintJob *print_job,
+ gpointer user_data,
+ GError *error)
+{
+ fprintf(stderr,"job finished: %s\n",error ? error->message : "no error");
+}
+
+static void
+unix_print_dialog (const gchar * ps_file, const gchar * jobname)
+{
+ GtkWidget* dlg = gtk_print_unix_dialog_new(_("Print"), NULL);
+
+/*
+ gtk_print_unix_dialog_add_custom_tab (GtkPrintUnixDialog *dialog,
+ GtkWidget *child,
+ GtkWidget *tab_label);
+*/
+
+ int const response = gtk_dialog_run(GTK_DIALOG(dlg));
+
+ if (response == GTK_RESPONSE_OK) {
+ GtkPrinter* printer = gtk_print_unix_dialog_get_selected_printer(GTK_PRINT_UNIX_DIALOG(dlg));
+
+ fprintf(stderr,"Selected printer '%s'\n",gtk_printer_get_name (printer));
+
+ if (gtk_printer_accepts_ps (printer)) {
+ GtkPrintJob* job = gtk_print_job_new (jobname, printer,
+ gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG(dlg)),
+ gtk_print_unix_dialog_get_page_setup(GTK_PRINT_UNIX_DIALOG(dlg)));
+
+
+ GError * error = NULL;
+ if ( gtk_print_job_set_source_file (job, ps_file, &error)) {
+ fprintf(stderr,"sending...\n");
+ gtk_print_job_send (job, unix_print_complete, NULL, NULL);
+ }
+ else {
+ fprintf(stderr,"Could not set print source: %s\n",error ? error->message : "unknown error");
+ }
+ }
+ else {
+ fprintf(stderr,"Printer can't support PS output\n");
+ }
+ }
+ else if (response == GTK_RESPONSE_APPLY) {
+ fprintf(stderr,"preview not available\n");
+ }
+
+ gtk_widget_destroy(dlg);
+}
+
+
unsigned int
PrintPS::setup(Inkscape::Extension::Print * mod)
{
g_object_ref((GObject *) tt);
gtk_object_sink((GtkObject *) tt);
+#ifdef HAVE_GTK_UNIX_PRINT
+ GtkWidget *dlg = gtk_dialog_new_with_buttons(_("Print Configuration"),
+#else
GtkWidget *dlg = gtk_dialog_new_with_buttons(_("Print Destination"),
+#endif
// SP_DT_WIDGET(SP_ACTIVE_DESKTOP)->window,
NULL,
(GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
+#ifdef HAVE_GTK_UNIX_PRINT
+ GTK_STOCK_GO_FORWARD,
+#else
GTK_STOCK_PRINT,
+#endif
GTK_RESPONSE_OK,
NULL);
GtkWidget *l = gtk_label_new(_("Resolution:"));
gtk_box_pack_end(GTK_BOX(hb), l, FALSE, FALSE, 0);
+#ifndef HAVE_GTK_UNIX_PRINT
/* Print destination frame */
f = gtk_frame_new(_("Print destination"));
gtk_box_pack_start(GTK_BOX(vbox), f, FALSE, FALSE, 4);
// pressing enter in the destination field is the same as clicking Print:
gtk_entry_set_activates_default(GTK_ENTRY(e), TRUE);
+#endif
gtk_widget_show_all(vbox);
_bitmap = gtk_toggle_button_get_active((GtkToggleButton *) rb);
sstr = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
_dpi = (unsigned int) MAX((int)(atof(sstr)), 1);
+#ifndef HAVE_GTK_UNIX_PRINT
/* Arrgh, have to do something */
fn = gtk_entry_get_text(GTK_ENTRY(e));
/* skip leading whitespace, bug #1068483 */
while (fn && *fn==' ') { fn++; }
/* g_print("Printing to %s\n", fn); */
+ mod->set_param_string("destination", (gchar *)fn);
+#else
+ /* unix print dialog prints to a tempfile */
+ char * filename = strdup("/tmp/inkscape-ps-XXXXXX");
+ int tmpfd = mkstemp(filename);
+ close(tmpfd);
+ Glib::ustring dest = ">";
+ dest+=filename;
+ free(filename);
+ mod->set_param_string("destination", dest.c_str());
+#endif
mod->set_param_bool("bitmap", _bitmap);
mod->set_param_string("resolution", (gchar *)sstr);
- mod->set_param_string("destination", (gchar *)fn);
ret = TRUE;
}
epsexport = g_str_has_suffix(fn,".eps");
while (isspace(*fn)) fn += 1;
Inkscape::IO::dump_fopen_call(fn, "K");
+ _tmpfilename = fn;
osf = Inkscape::IO::fopen_utf8name(fn, "w+");
if (!osf) {
fprintf(stderr, "inkscape: fopen(%s): %s\n",
{
while((c = fgetc(_stream))!=EOF) fputc(c, _begin_stream);
}
- fclose(_begin_stream);
+ fclose(_stream);
+ _stream = _begin_stream;
}
+#ifdef HAVE_GTK_UNIX_PRINT
+ /* redirect output to new print dialog */
+ fseek(_stream, 0, SEEK_SET);
+ Glib::ustring output = _tmpfilename;
+ unix_print_dialog(output.c_str(),"job name");
+ unlink(output.c_str());
+ /* end redirected new print dialog */
+#endif
+
/* fixme: should really use pclose for popen'd streams */
fclose(_stream);
- _stream = 0;
+ _stream = NULL;
+
_latin1_encoded_fonts.clear();
g_tree_destroy(_fonts);
index 673cde82c4722e470546b3f31da17f112c3c40b8..5f3388d55c3eb17e38c6d77b73ce993cf1447c09 100644 (file)
float _height;
FILE * _begin_stream;//stream to print prolog and document setup of EPS, if font embedding
FILE * _stream;//(main) stream to print the (E)PS output, or only the script part following prolog/document setup, if font embedding
+ Glib::ustring _tmpfilename;
unsigned short _dpi;
bool _bitmap;