From e9c9fd0f3c2de33599c34df06c891bcaba8e7aaf Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 2 Dec 2007 01:47:34 +0000 Subject: [PATCH] Make use GTK print dialog, among other details. --- inkscape-0.45.1-gtkprint.patch | 215 +++++++++++++++++++++++++++++++++ inkscape.spec | 25 +++- 2 files changed, 237 insertions(+), 3 deletions(-) create mode 100644 inkscape-0.45.1-gtkprint.patch diff --git a/inkscape-0.45.1-gtkprint.patch b/inkscape-0.45.1-gtkprint.patch new file mode 100644 index 0000000..239b62d --- /dev/null +++ b/inkscape-0.45.1-gtkprint.patch @@ -0,0 +1,215 @@ +Patch from upstream SVN, by Kees Cook of Ubuntu + +Index: src/extension/internal/ps.cpp +=================================================================== +--- src/extension/internal/ps.cpp (revision 14039) ++++ src/extension/internal/ps.cpp (revision 14040) +@@ -43,6 +43,8 @@ + #include + #include + ++#include ++ + #include + #include "display/nr-arena-item.h" + #include "display/canvas-bpath.h" +@@ -102,6 +104,59 @@ + 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) + { +@@ -118,13 +173,21 @@ + 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); + +@@ -180,6 +243,7 @@ + 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); +@@ -204,6 +268,7 @@ + + // 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); + +@@ -218,15 +283,26 @@ + _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; + } + +@@ -283,6 +359,7 @@ + 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", +@@ -582,12 +659,23 @@ + { + 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: src/extension/internal/ps.h +=================================================================== +--- src/extension/internal/ps.h (revision 14039) ++++ src/extension/internal/ps.h (revision 14040) +@@ -36,6 +36,7 @@ + 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; +Index: src/Makefile.am +=================================================================== +--- src/Makefile.am (revision 14039) ++++ src/Makefile.am (revision 14040) +@@ -20,6 +20,7 @@ + $(GNOME_VFS_CFLAGS) \ + $(INKBOARD_CFLAGS) \ + $(XFT_CFLAGS) \ ++ $(GTK_UNIX_PRINT_CFLAGS) \ + -DPOTRACE=\"potrace\" \ + $(INKSCAPE_CFLAGS) \ + -I$(top_srcdir)/cxxtest +Index: configure.ac +=================================================================== +--- configure.ac (revision 14039) ++++ configure.ac (revision 14040) +@@ -525,6 +525,11 @@ + 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/inkscape.spec b/inkscape.spec index 668e4df..96252bc 100644 --- a/inkscape.spec +++ b/inkscape.spec @@ -2,7 +2,7 @@ Name: inkscape Version: 0.45.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Vector-based drawing program using SVG Group: Applications/Productivity @@ -11,6 +11,7 @@ URL: http://inkscape.sourceforge.net/ Source0: http://download.sourceforge.net/inkscape/inkscape-%{version}.tar.gz Patch0: inkscape-0.44.1-psinput.patch Patch1: inkscape-0.45-python.patch +Patch2: inkscape-0.45.1-gtkprint.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: atk-devel @@ -33,6 +34,13 @@ BuildRequires: openssl-devel BuildRequires: dos2unix BuildRequires: perl-XML-Parser BuildRequires: python-devel +%if %{fedora} > 7 +BuildRequires: popt-devel +%else +BuildRequires: popt +%endif +# The following are needed due to gtkprint patch changing configure.ac +BuildRequires: autoconf automake17 intltool %{?_with_inkboard:BuildRequires: loudmouth-devel >= 1.0} Requires: pstoedit @@ -60,12 +68,16 @@ C and C++, using the Gtk+ toolkit and optionally some Gnome libraries. %setup -q %patch0 -p1 -b .psinput %patch1 -p1 -b .python +%patch2 -p0 -b .gtkprint find -type f -regex '.*\.\(cpp\|h\)' -perm +111 -exec chmod -x {} ';' find share/extensions/ -type f -regex '.*\.py' -perm +111 -exec chmod -x {} ';' dos2unix share/extensions/*.py %build +intltoolize --force +autoconf +autoheader %configure \ --disable-dependency-tracking \ --with-xinerama \ @@ -92,6 +104,7 @@ rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/extensions/txt2svg.* desktop-file-install --vendor fedora --delete-original \ --dir ${RPM_BUILD_ROOT}%{_datadir}/applications \ --add-category X-Fedora \ + --add-mime-type image/svg+xml-compressed \ ${RPM_BUILD_ROOT}/usr/share/applications/%{name}.desktop @@ -119,6 +132,12 @@ update-desktop-database %{_datadir}/applications > /dev/null 2>&1 || : %changelog +* Sat Dec 01 2007 Lubomir Kundrak - 0.45.1-2 +- Use GTK print dialog +- Added compressed SVG association (#245413) +- popt headers went into popt-devel, post Fedora 7 +- Fix macro usage in changelog + * Wed Mar 21 2007 Denis Leroy - 0.45.1-1 - Update to bugfix release 0.45.1 - Added R to ImageMagick-perl (#231563) @@ -244,9 +263,9 @@ update-desktop-database %{_datadir}/applications > /dev/null 2>&1 || : * Tue Mar 16 2004 P Linnell 0:0.37.0.fdr.6 - fix typo in provides * Tue Mar 16 2004 P Linnell 0:0.37.0.fdr.5 -- add %{release} to provides perl(SpSVG) = %{epoch}:%{version}:%{release} only +- add %%{release} to provides perl(SpSVG) = %%{epoch}:%%{version}:%%{release} only * Tue Mar 16 2004 P Linnell 0:0.37.0.fdr.4 -- add %{release} to provides +- add %%{release} to provides * Sun Mar 14 2004 P Linnell 0:0.37.0.fdr.3 - add arch dependent flags * Thu Mar 11 2004 P Linnell 0:0.37.0.fdr.2