Merge the gtk-printing branch. For more detailed ChangeLog entries, see
2006-04-21 Alexander Larsson <alexl@redhat.com> Merge the gtk-printing branch. For more detailed ChangeLog entries, see the branch. * .cvsignore: * Makefile.am: * configure.in: * docs/tools/widgets.c: * gtk+-unix-print-2.0.pc.in: * gtk/Makefile.am: * gtk/gen-paper-names.c: * gtk/gtk.h: * gtk/gtk.symbols: * gtk/gtkenums.h: * gtk/gtkiconfactory.c: * gtk/gtkmarshalers.list: * gtk/gtkpagesetup.[ch]: * gtk/gtkpagesetupunixdialog.[ch]: * gtk/gtkpapersize.[ch]: * gtk/gtkprint-win32.[ch]: * gtk/gtkprintbackend.[ch]: * gtk/gtkprintcontext.[ch]: * gtk/gtkprinter-private.h: * gtk/gtkprinter.[ch]: * gtk/gtkprinteroption.[ch]: * gtk/gtkprinteroptionset.[ch]: * gtk/gtkprinteroptionwidget.[ch]: * gtk/gtkprintjob.[ch]: * gtk/gtkprintoperation-private.h: * gtk/gtkprintoperation-unix.c: * gtk/gtkprintoperation-win32.c: * gtk/gtkprintoperation.[ch]: * gtk/gtkprintsettings.[ch]: * gtk/gtkprintunixdialog.[ch]: * gtk/paper_names.c: * gtk/paper_names_offsets.c: Platform independent printing API and implementations for unix and windows. * gtk/gtkstock.h: * gtk/stock-icons/24/gtk-orientation-landscape.png: * gtk/stock-icons/24/gtk-orientation-portrait.png: * gtk/stock-icons/24/gtk-orientation-reverse-landscape.png: Add stock icons for page orientation. * modules/Makefile.am: * modules/printbackends/Makefile.am: * modules/printbackends/cups/Makefile.am: * modules/printbackends/cups/gtkcupsutils.[ch]: * modules/printbackends/cups/gtkprintbackendcups.[ch]: * modules/printbackends/cups/gtkprintercups.[ch]: Cups printing backend for unix. * modules/printbackends/lpr/Makefile.am: * modules/printbackends/lpr/gtkprintbackendlpr.[ch]: lpr printing backend for unix. * modules/printbackends/pdf/Makefile.am: * modules/printbackends/pdf/gtkprintbackendpdf.[ch]: print-to-pdf printing backend for unix. * tests/.cvsignore: * tests/Makefile.am: * tests/print-editor.c: Test application for printing. * gdk/gdk.symbols: * gdk/win32/gdkevents-win32.c: * gdk/win32/gdkwin32.h: Add gdk_win32_set_modal_dialog_libgtk_only so that we can pump the mainloop while displaying a win32 common dialog. * gdk/directfb/Makefile.am: Whitespace cleanup.
This commit is contained in:
parent
ea32742b93
commit
27f746fbd0
@ -19,6 +19,7 @@ stamp-h.in
|
||||
gtk+.spec
|
||||
gtk+-2.0.pc
|
||||
gtk+-2.0-uninstalled.pc
|
||||
gtk+-unix-print-2.0.pc
|
||||
gtk+-linux-fb-2.0.pc
|
||||
gtk+-nanox-2.0.pc
|
||||
gtk+-x11-2.0.pc
|
||||
|
77
ChangeLog
77
ChangeLog
@ -1,3 +1,80 @@
|
||||
2006-04-21 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
Merge the gtk-printing branch.
|
||||
For more detailed ChangeLog entries, see the branch.
|
||||
|
||||
* .cvsignore:
|
||||
* Makefile.am:
|
||||
* configure.in:
|
||||
* docs/tools/widgets.c:
|
||||
* gtk+-unix-print-2.0.pc.in:
|
||||
* gtk/Makefile.am:
|
||||
* gtk/gen-paper-names.c:
|
||||
* gtk/gtk.h:
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkenums.h:
|
||||
* gtk/gtkiconfactory.c:
|
||||
* gtk/gtkmarshalers.list:
|
||||
* gtk/gtkpagesetup.[ch]:
|
||||
* gtk/gtkpagesetupunixdialog.[ch]:
|
||||
* gtk/gtkpapersize.[ch]:
|
||||
* gtk/gtkprint-win32.[ch]:
|
||||
* gtk/gtkprintbackend.[ch]:
|
||||
* gtk/gtkprintcontext.[ch]:
|
||||
* gtk/gtkprinter-private.h:
|
||||
* gtk/gtkprinter.[ch]:
|
||||
* gtk/gtkprinteroption.[ch]:
|
||||
* gtk/gtkprinteroptionset.[ch]:
|
||||
* gtk/gtkprinteroptionwidget.[ch]:
|
||||
* gtk/gtkprintjob.[ch]:
|
||||
* gtk/gtkprintoperation-private.h:
|
||||
* gtk/gtkprintoperation-unix.c:
|
||||
* gtk/gtkprintoperation-win32.c:
|
||||
* gtk/gtkprintoperation.[ch]:
|
||||
* gtk/gtkprintsettings.[ch]:
|
||||
* gtk/gtkprintunixdialog.[ch]:
|
||||
* gtk/paper_names.c:
|
||||
* gtk/paper_names_offsets.c:
|
||||
Platform independent printing API and implementations
|
||||
for unix and windows.
|
||||
|
||||
* gtk/gtkstock.h:
|
||||
* gtk/stock-icons/24/gtk-orientation-landscape.png:
|
||||
* gtk/stock-icons/24/gtk-orientation-portrait.png:
|
||||
* gtk/stock-icons/24/gtk-orientation-reverse-landscape.png:
|
||||
Add stock icons for page orientation.
|
||||
|
||||
* modules/Makefile.am:
|
||||
* modules/printbackends/Makefile.am:
|
||||
* modules/printbackends/cups/Makefile.am:
|
||||
* modules/printbackends/cups/gtkcupsutils.[ch]:
|
||||
* modules/printbackends/cups/gtkprintbackendcups.[ch]:
|
||||
* modules/printbackends/cups/gtkprintercups.[ch]:
|
||||
|
||||
Cups printing backend for unix.
|
||||
|
||||
* modules/printbackends/lpr/Makefile.am:
|
||||
* modules/printbackends/lpr/gtkprintbackendlpr.[ch]:
|
||||
lpr printing backend for unix.
|
||||
|
||||
* modules/printbackends/pdf/Makefile.am:
|
||||
* modules/printbackends/pdf/gtkprintbackendpdf.[ch]:
|
||||
print-to-pdf printing backend for unix.
|
||||
|
||||
* tests/.cvsignore:
|
||||
* tests/Makefile.am:
|
||||
* tests/print-editor.c:
|
||||
Test application for printing.
|
||||
|
||||
* gdk/gdk.symbols:
|
||||
* gdk/win32/gdkevents-win32.c:
|
||||
* gdk/win32/gdkwin32.h:
|
||||
Add gdk_win32_set_modal_dialog_libgtk_only so that we can pump the
|
||||
mainloop while displaying a win32 common dialog.
|
||||
|
||||
* gdk/directfb/Makefile.am:
|
||||
Whitespace cleanup.
|
||||
|
||||
2006-04-20 Paolo Borelli <pborelli@katamail.com>
|
||||
|
||||
* gtk/gtkcombobox.c: plug small leak (#339132)
|
||||
|
@ -1,3 +1,80 @@
|
||||
2006-04-21 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
Merge the gtk-printing branch.
|
||||
For more detailed ChangeLog entries, see the branch.
|
||||
|
||||
* .cvsignore:
|
||||
* Makefile.am:
|
||||
* configure.in:
|
||||
* docs/tools/widgets.c:
|
||||
* gtk+-unix-print-2.0.pc.in:
|
||||
* gtk/Makefile.am:
|
||||
* gtk/gen-paper-names.c:
|
||||
* gtk/gtk.h:
|
||||
* gtk/gtk.symbols:
|
||||
* gtk/gtkenums.h:
|
||||
* gtk/gtkiconfactory.c:
|
||||
* gtk/gtkmarshalers.list:
|
||||
* gtk/gtkpagesetup.[ch]:
|
||||
* gtk/gtkpagesetupunixdialog.[ch]:
|
||||
* gtk/gtkpapersize.[ch]:
|
||||
* gtk/gtkprint-win32.[ch]:
|
||||
* gtk/gtkprintbackend.[ch]:
|
||||
* gtk/gtkprintcontext.[ch]:
|
||||
* gtk/gtkprinter-private.h:
|
||||
* gtk/gtkprinter.[ch]:
|
||||
* gtk/gtkprinteroption.[ch]:
|
||||
* gtk/gtkprinteroptionset.[ch]:
|
||||
* gtk/gtkprinteroptionwidget.[ch]:
|
||||
* gtk/gtkprintjob.[ch]:
|
||||
* gtk/gtkprintoperation-private.h:
|
||||
* gtk/gtkprintoperation-unix.c:
|
||||
* gtk/gtkprintoperation-win32.c:
|
||||
* gtk/gtkprintoperation.[ch]:
|
||||
* gtk/gtkprintsettings.[ch]:
|
||||
* gtk/gtkprintunixdialog.[ch]:
|
||||
* gtk/paper_names.c:
|
||||
* gtk/paper_names_offsets.c:
|
||||
Platform independent printing API and implementations
|
||||
for unix and windows.
|
||||
|
||||
* gtk/gtkstock.h:
|
||||
* gtk/stock-icons/24/gtk-orientation-landscape.png:
|
||||
* gtk/stock-icons/24/gtk-orientation-portrait.png:
|
||||
* gtk/stock-icons/24/gtk-orientation-reverse-landscape.png:
|
||||
Add stock icons for page orientation.
|
||||
|
||||
* modules/Makefile.am:
|
||||
* modules/printbackends/Makefile.am:
|
||||
* modules/printbackends/cups/Makefile.am:
|
||||
* modules/printbackends/cups/gtkcupsutils.[ch]:
|
||||
* modules/printbackends/cups/gtkprintbackendcups.[ch]:
|
||||
* modules/printbackends/cups/gtkprintercups.[ch]:
|
||||
|
||||
Cups printing backend for unix.
|
||||
|
||||
* modules/printbackends/lpr/Makefile.am:
|
||||
* modules/printbackends/lpr/gtkprintbackendlpr.[ch]:
|
||||
lpr printing backend for unix.
|
||||
|
||||
* modules/printbackends/pdf/Makefile.am:
|
||||
* modules/printbackends/pdf/gtkprintbackendpdf.[ch]:
|
||||
print-to-pdf printing backend for unix.
|
||||
|
||||
* tests/.cvsignore:
|
||||
* tests/Makefile.am:
|
||||
* tests/print-editor.c:
|
||||
Test application for printing.
|
||||
|
||||
* gdk/gdk.symbols:
|
||||
* gdk/win32/gdkevents-win32.c:
|
||||
* gdk/win32/gdkwin32.h:
|
||||
Add gdk_win32_set_modal_dialog_libgtk_only so that we can pump the
|
||||
mainloop while displaying a win32 common dialog.
|
||||
|
||||
* gdk/directfb/Makefile.am:
|
||||
Whitespace cleanup.
|
||||
|
||||
2006-04-20 Paolo Borelli <pborelli@katamail.com>
|
||||
|
||||
* gtk/gtkcombobox.c: plug small leak (#339132)
|
||||
|
@ -132,9 +132,10 @@ gdk-$(GDKTARGET)-2.0-uninstalled.pc: gdk-2.0-uninstalled.pc
|
||||
cp gdk-2.0-uninstalled.pc gdk-$(GDKTARGET)-2.0-uninstalled.pc
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA= gdk-pixbuf-2.0.pc gdk-$(GDKTARGET)-2.0.pc gtk+-$(GDKTARGET)-2.0.pc
|
||||
pkgconfig_DATA= gdk-pixbuf-2.0.pc gdk-$(GDKTARGET)-2.0.pc gtk+-$(GDKTARGET)-2.0.pc gtk+-unix-print-2.0.pc
|
||||
|
||||
DISTCLEANFILES = \
|
||||
gtk+-unix-print-2.0.pc \
|
||||
gtk+-$(GDKTARGET)-2.0.pc \
|
||||
gdk-$(GDKTARGET)-2.0.pc \
|
||||
gtk+-$(GDKTARGET)-2.0-uninstalled.pc \
|
||||
|
56
configure.in
56
configure.in
@ -416,6 +416,42 @@ if test "$gtk_ok" = "yes"; then
|
||||
[Define if _NL_TIME_FIRST_WEEKDAY is available])
|
||||
fi
|
||||
|
||||
# _NL_MEASUREMENT_MEASUREMENT is an enum and not a define
|
||||
AC_MSG_CHECKING([for _NL_MEASUREMENT_MEASUREMENT])
|
||||
AC_TRY_LINK([#include <langinfo.h>], [
|
||||
char c;
|
||||
c = *((unsigned char *) nl_langinfo(_NL_MEASUREMENT_MEASUREMENT));
|
||||
], gtk_ok=yes, gtk_ok=no)
|
||||
AC_MSG_RESULT($gtk_ok)
|
||||
if test "$gtk_ok" = "yes"; then
|
||||
AC_DEFINE([HAVE__NL_MEASUREMENT_MEASUREMENT], [1],
|
||||
[Define if _NL_MEASUREMENT_MEASUREMENT is available])
|
||||
fi
|
||||
|
||||
# _NL_PAPER_HEIGHT is an enum and not a define
|
||||
AC_MSG_CHECKING([for _NL_PAPER_HEIGHT])
|
||||
AC_TRY_LINK([#include <langinfo.h>], [
|
||||
char c;
|
||||
c = *((unsigned char *) nl_langinfo(_NL_PAPER_HEIGHT));
|
||||
], gtk_ok=yes, gtk_ok=no)
|
||||
AC_MSG_RESULT($gtk_ok)
|
||||
if test "$gtk_ok" = "yes"; then
|
||||
AC_DEFINE([HAVE__NL_PAPER_HEIGHT], [1],
|
||||
[Define if _NL_PAPER_HEIGHT is available])
|
||||
fi
|
||||
|
||||
# _NL_PAPER_WIDTH is an enum and not a define
|
||||
AC_MSG_CHECKING([for _NL_PAPER_WIDTH])
|
||||
AC_TRY_LINK([#include <langinfo.h>], [
|
||||
char c;
|
||||
c = *((unsigned char *) nl_langinfo(_NL_PAPER_WIDTH));
|
||||
], gtk_ok=yes, gtk_ok=no)
|
||||
AC_MSG_RESULT($gtk_ok)
|
||||
if test "$gtk_ok" = "yes"; then
|
||||
AC_DEFINE([HAVE__NL_PAPER_WIDTH], [1],
|
||||
[Define if _NL_PAPER_WIDTH is available])
|
||||
fi
|
||||
|
||||
# sigsetjmp is a macro on some platforms, so AC_CHECK_FUNCS is not reliable
|
||||
AC_MSG_CHECKING(for sigsetjmp)
|
||||
AC_TRY_LINK([#include <setjmp.h>], [
|
||||
@ -1499,6 +1535,21 @@ AC_SUBST(GTK_DEP_CFLAGS)
|
||||
AC_SUBST(GTK_DEBUG_FLAGS)
|
||||
AC_SUBST(GTK_XIM_FLAGS)
|
||||
|
||||
################################################################
|
||||
# Printing system checks
|
||||
################################################################
|
||||
|
||||
AC_PATH_PROG(CUPS_CONFIG, cups-config, no)
|
||||
if test "x$CUPS_CONFIG" != "xno"; then
|
||||
CUPS_CFLAGS=`cups-config --cflags | sed 's/-O[0-9]*//' | sed 's/-m[^\t]*//g'`
|
||||
CUPS_LIBS=`cups-config --libs`
|
||||
|
||||
AC_SUBST(CUPS_CFLAGS)
|
||||
AC_SUBST(CUPS_LIBS)
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_CUPS, test "x$CUPS_CONFIG" != "xno")
|
||||
|
||||
|
||||
################################################################
|
||||
# Strip -export-dynamic from the link lines of various libraries
|
||||
################################################################
|
||||
@ -1638,6 +1689,7 @@ Makefile
|
||||
gdk-pixbuf-2.0.pc
|
||||
gdk-2.0.pc
|
||||
gtk+-2.0.pc
|
||||
gtk+-unix-print-2.0.pc
|
||||
gdk-pixbuf-2.0-uninstalled.pc
|
||||
gdk-2.0-uninstalled.pc
|
||||
gtk+-2.0-uninstalled.pc
|
||||
@ -1684,6 +1736,10 @@ modules/engines/pixbuf/Makefile
|
||||
modules/engines/ms-windows/Makefile
|
||||
modules/engines/ms-windows/Theme/Makefile
|
||||
modules/engines/ms-windows/Theme/gtk-2.0/Makefile
|
||||
modules/printbackends/Makefile
|
||||
modules/printbackends/cups/Makefile
|
||||
modules/printbackends/lpr/Makefile
|
||||
modules/printbackends/pdf/Makefile
|
||||
perf/Makefile
|
||||
contrib/Makefile
|
||||
contrib/gdk-pixbuf-xlib/Makefile
|
||||
|
@ -1,3 +1,23 @@
|
||||
2006-04-21 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* gtk/Makefile.am:
|
||||
* gtk/gtk-docs.sgml:
|
||||
* gtk/gtk-sections.txt:
|
||||
* gtk/gtk.types:
|
||||
* gtk/images/pagesetupdialog.png:
|
||||
* gtk/images/printdialog.png:
|
||||
* gtk/tmpl/gtkpagesetup.sgml:
|
||||
* gtk/tmpl/gtkpagesetupunixdialog.sgml:
|
||||
* gtk/tmpl/gtkpapersize.sgml:
|
||||
* gtk/tmpl/gtkprintcontext.sgml:
|
||||
* gtk/tmpl/gtkprinter.sgml:
|
||||
* gtk/tmpl/gtkprintjob.sgml:
|
||||
* gtk/tmpl/gtkprintoperation.sgml:
|
||||
* gtk/tmpl/gtkprintsettings.sgml:
|
||||
* gtk/tmpl/gtkprintunixdialog.sgml:
|
||||
* gtk/visual_index.xml:
|
||||
Add docs for the printing support
|
||||
|
||||
2006-04-17 Emmanuele Bassi <ebassi@cvs.gnome.org>
|
||||
|
||||
* gtk/tmp/gtkicontheme.sgml: Fix the code of the look up example.
|
||||
|
@ -48,6 +48,10 @@ IGNORE_HFILES= \
|
||||
gtkmnemonichash.h \
|
||||
gtkpathbar.h \
|
||||
gtkplugprivate.h \
|
||||
gtkprintbackend.h \
|
||||
gtkprinteroptionwidget.h \
|
||||
gtkprinter-private.h \
|
||||
gtkprintoperation-private.h \
|
||||
gtkprivate.h \
|
||||
gtkrbtree.h \
|
||||
gtkrecentchooserdefault.h \
|
||||
@ -277,6 +281,8 @@ HTML_IMAGES = \
|
||||
$(srcdir)/images/multiline-text.png \
|
||||
$(srcdir)/images/notebook.png \
|
||||
$(srcdir)/images/panes.png \
|
||||
$(srcdir)/images/pagesetupdialog.png \
|
||||
$(srcdir)/images/printdialog.png \
|
||||
$(srcdir)/images/progressbar.png \
|
||||
$(srcdir)/images/radio-group.png \
|
||||
$(srcdir)/images/recentchooserdialog.png \
|
||||
|
@ -84,6 +84,15 @@
|
||||
<!ENTITY GtkPixmap SYSTEM "xml/gtkpixmap.xml">
|
||||
<!ENTITY GtkPlug SYSTEM "xml/gtkplug.xml">
|
||||
<!ENTITY GtkPreview SYSTEM "xml/gtkpreview.xml">
|
||||
<!ENTITY GtkPrintOperation SYSTEM "xml/gtkprintoperation.xml">
|
||||
<!ENTITY GtkPrintContext SYSTEM "xml/gtkprintcontext.xml">
|
||||
<!ENTITY GtkPrintSettings SYSTEM "xml/gtkprintsettings.xml">
|
||||
<!ENTITY GtkPageSetup SYSTEM "xml/gtkpagesetup.xml">
|
||||
<!ENTITY GtkPaperSize SYSTEM "xml/gtkpapersize.xml">
|
||||
<!ENTITY GtkPrinter SYSTEM "xml/gtkprinter.xml">
|
||||
<!ENTITY GtkPrintJob SYSTEM "xml/gtkprintjob.xml">
|
||||
<!ENTITY GtkPrintUnixDialog SYSTEM "xml/gtkprintunixdialog.xml">
|
||||
<!ENTITY GtkPageSetupUnixDialog SYSTEM "xml/gtkpagesetupunixdialog.xml">
|
||||
<!ENTITY GtkProgress SYSTEM "xml/gtkprogress.xml">
|
||||
<!ENTITY GtkProgressBar SYSTEM "xml/gtkprogressbar.xml">
|
||||
<!ENTITY GtkRadioAction SYSTEM "xml/gtkradioaction.xml">
|
||||
@ -513,6 +522,19 @@ that is, GUI components such as <link linkend="GtkButton">GtkButton</link> or
|
||||
&GtkScrolledWindow;
|
||||
</chapter>
|
||||
|
||||
<chapter id="Printing">
|
||||
<title>Printing</title>
|
||||
&GtkPrintOperation;
|
||||
&GtkPrintContext;
|
||||
&GtkPrintSettings;
|
||||
&GtkPageSetup;
|
||||
&GtkPaperSize;
|
||||
&GtkPrintUnixDialog;
|
||||
&GtkPrinter;
|
||||
&GtkPrintJob;
|
||||
&GtkPageSetupUnixDialog;
|
||||
</chapter>
|
||||
|
||||
<chapter id="MiscObjects">
|
||||
<title>Miscellaneous</title>
|
||||
&GtkAdjustment;
|
||||
|
@ -6057,3 +6057,333 @@ gtk_icon_factory_get_type
|
||||
gtk_icon_set_get_type
|
||||
gtk_icon_source_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprintoperation</FILE>
|
||||
<TITLE>High-level Printing API</TITLE>
|
||||
GtkPrintOperation
|
||||
GtkPrintStatus
|
||||
GtkPrintOperationResult
|
||||
GtkPrintError
|
||||
GTK_PRINT_ERROR
|
||||
gtk_print_error_quark
|
||||
gtk_print_operation_new
|
||||
gtk_print_operation_set_default_page_setup
|
||||
gtk_print_operation_get_default_page_setup
|
||||
gtk_print_operation_set_print_settings
|
||||
gtk_print_operation_get_print_settings
|
||||
gtk_print_operation_set_job_name
|
||||
gtk_print_operation_set_nr_of_pages
|
||||
gtk_print_operation_set_current_page
|
||||
gtk_print_operation_set_use_full_page
|
||||
gtk_print_operation_set_unit
|
||||
gtk_print_operation_set_show_dialog
|
||||
gtk_print_operation_set_pdf_target
|
||||
gtk_print_operation_run
|
||||
gtk_print_operation_get_status
|
||||
gtk_print_operation_is_finished
|
||||
gtk_print_run_page_setup_dialog
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINT_OPERATION
|
||||
GTK_PRINT_OPERATION
|
||||
GTK_IS_PRINT_OPERATION
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_print_operation_get_type
|
||||
GtkPrintOperationPrivate
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>gtk/gtkprintunixdialog.h</INCLUDE>
|
||||
<FILE>gtkprintunixdialog</FILE>
|
||||
<TITLE>GtkPrintUnixDialog</TITLE>
|
||||
GtkPrintUnixDialog
|
||||
gtk_print_unix_dialog_set_page_setup
|
||||
gtk_print_unix_dialog_get_page_setup
|
||||
gtk_print_unix_dialog_set_current_page
|
||||
gtk_print_unix_dialog_get_current_page
|
||||
gtk_print_unix_dialog_set_settings
|
||||
gtk_print_unix_dialog_get_settings
|
||||
gtk_print_unix_dialog_get_selected_printer
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINT_UNIX_DIALOG
|
||||
GTK_PRINT_UNIX_DIALOG
|
||||
GTK_PRINT_UNIX_DIALOG_CLASS
|
||||
GTK_IS_PRINT_UNIX_DIALOG
|
||||
GTK_IS_PRINT_UNIX_DIALOG_CLASS
|
||||
GTK_PRINT_UNIX_DIALOG_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkPrintUnixDialogPrivate
|
||||
gtk_print_unix_dialog_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprinter</FILE>
|
||||
<TITLE>GtkPrinter</TITLE>
|
||||
GtkPrinter
|
||||
GtkPrintBackend
|
||||
gtk_printer_new
|
||||
gtk_printer_get_backend
|
||||
gtk_printer_get_name
|
||||
gtk_printer_get_state_message
|
||||
gtk_printer_get_description
|
||||
gtk_printer_get_location
|
||||
gtk_printer_get_icon_name
|
||||
gtk_printer_get_job_count
|
||||
gtk_printer_is_active
|
||||
gtk_printer_is_virtual
|
||||
gtk_printer_is_default
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINTER
|
||||
GTK_PRINTER
|
||||
GTK_PRINTER_CLASS
|
||||
GTK_IS_PRINTER
|
||||
GTK_IS_PRINTER_CLASS
|
||||
GTK_PRINTER_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkPrinterPrivate
|
||||
gtk_printer_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprintsettings</FILE>
|
||||
<TITLE>GtkPrintSettings</TITLE>
|
||||
GtkPrintSettings
|
||||
GtkPrintSettingsFunc
|
||||
gtk_print_settings_new
|
||||
gtk_print_settings_copy
|
||||
gtk_print_settings_has_key
|
||||
gtk_print_settings_get
|
||||
gtk_print_settings_set
|
||||
gtk_print_settings_unset
|
||||
gtk_print_settings_foreach
|
||||
gtk_print_settings_get_bool
|
||||
gtk_print_settings_set_bool
|
||||
gtk_print_settings_get_double
|
||||
gtk_print_settings_get_double_with_default
|
||||
gtk_print_settings_set_double
|
||||
gtk_print_settings_get_length
|
||||
gtk_print_settings_set_length
|
||||
gtk_print_settings_get_int
|
||||
gtk_print_settings_get_int_with_default
|
||||
gtk_print_settings_set_int
|
||||
gtk_print_settings_get_printer
|
||||
gtk_print_settings_set_printer
|
||||
GtkPageOrientation
|
||||
gtk_print_settings_get_orientation
|
||||
gtk_print_settings_set_orientation
|
||||
gtk_print_settings_get_paper_size
|
||||
gtk_print_settings_set_paper_size
|
||||
gtk_print_settings_get_paper_width
|
||||
gtk_print_settings_set_paper_width
|
||||
gtk_print_settings_get_paper_height
|
||||
gtk_print_settings_set_paper_height
|
||||
gtk_print_settings_get_use_color
|
||||
gtk_print_settings_set_use_color
|
||||
gtk_print_settings_get_collate
|
||||
gtk_print_settings_set_collate
|
||||
gtk_print_settings_get_reverse
|
||||
gtk_print_settings_set_reverse
|
||||
GtkPrintDuplex
|
||||
gtk_print_settings_get_duplex
|
||||
gtk_print_settings_set_duplex
|
||||
GtkPrintQuality
|
||||
gtk_print_settings_get_quality
|
||||
gtk_print_settings_set_quality
|
||||
gtk_print_settings_get_num_copies
|
||||
gtk_print_settings_set_num_copies
|
||||
gtk_print_settings_get_number_up
|
||||
gtk_print_settings_set_number_up
|
||||
gtk_print_settings_get_resolution
|
||||
gtk_print_settings_set_resolution
|
||||
gtk_print_settings_get_scale
|
||||
gtk_print_settings_set_scale
|
||||
gtk_print_settings_get_print_to_file
|
||||
gtk_print_settings_set_print_to_file
|
||||
GtkPrintPages
|
||||
gtk_print_settings_get_print_pages
|
||||
gtk_print_settings_set_print_pages
|
||||
GtkPageRange
|
||||
gtk_print_settings_get_page_ranges
|
||||
gtk_print_settings_set_page_ranges
|
||||
GtkPageSet
|
||||
gtk_print_settings_get_page_set
|
||||
gtk_print_settings_set_page_set
|
||||
gtk_print_settings_get_default_source
|
||||
gtk_print_settings_set_default_source
|
||||
gtk_print_settings_get_media_type
|
||||
gtk_print_settings_set_media_type
|
||||
gtk_print_settings_get_dither
|
||||
gtk_print_settings_set_dither
|
||||
gtk_print_settings_get_finishings
|
||||
gtk_print_settings_set_finishings
|
||||
gtk_print_settings_get_output_bin
|
||||
gtk_print_settings_set_output_bin
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINT_SETTINGS
|
||||
GTK_PRINT_SETTINGS
|
||||
GTK_IS_PRINT_SETTINGS
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_print_settings_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkpapersize</FILE>
|
||||
<TITLE>GtkPaperSize</TITLE>
|
||||
GtkPaperSize
|
||||
GtkUnit
|
||||
GTK_PAPER_NAME_A3
|
||||
GTK_PAPER_NAME_A4
|
||||
GTK_PAPER_NAME_A5
|
||||
GTK_PAPER_NAME_B5
|
||||
GTK_PAPER_NAME_LETTER
|
||||
GTK_PAPER_NAME_EXECUTIVE
|
||||
GTK_PAPER_NAME_LEGAL
|
||||
gtk_paper_size_new
|
||||
gtk_paper_size_new_from_ppd
|
||||
gtk_paper_size_new_custom
|
||||
gtk_paper_size_copy
|
||||
gtk_paper_size_free
|
||||
gtk_paper_size_is_equal
|
||||
gtk_paper_size_get_name
|
||||
gtk_paper_size_get_display_name
|
||||
gtk_paper_size_get_ppd_name
|
||||
gtk_paper_size_get_width
|
||||
gtk_paper_size_get_height
|
||||
gtk_paper_size_is_custom
|
||||
gtk_paper_size_set_size
|
||||
gtk_paper_size_get_default_top_margin
|
||||
gtk_paper_size_get_default_bottom_margin
|
||||
gtk_paper_size_get_default_left_margin
|
||||
gtk_paper_size_get_default_right_margin
|
||||
gtk_paper_size_get_default
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PAPER_SIZE
|
||||
<SUBSECTION Private>
|
||||
gtk_paper_size_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkpagesetup</FILE>
|
||||
<TITLE>GtkPageSetup</TITLE>
|
||||
GtkPageSetup
|
||||
gtk_page_setup_new
|
||||
gtk_page_setup_copy
|
||||
gtk_page_setup_get_orientation
|
||||
gtk_page_setup_set_orientation
|
||||
gtk_page_setup_get_paper_size
|
||||
gtk_page_setup_set_paper_size
|
||||
gtk_page_setup_get_top_margin
|
||||
gtk_page_setup_set_top_margin
|
||||
gtk_page_setup_get_bottom_margin
|
||||
gtk_page_setup_set_bottom_margin
|
||||
gtk_page_setup_get_left_margin
|
||||
gtk_page_setup_set_left_margin
|
||||
gtk_page_setup_get_right_margin
|
||||
gtk_page_setup_set_right_margin
|
||||
gtk_page_setup_set_paper_size_and_default_margins
|
||||
gtk_page_setup_get_paper_width
|
||||
gtk_page_setup_get_paper_height
|
||||
gtk_page_setup_get_page_width
|
||||
gtk_page_setup_get_page_height
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PAGE_SETUP
|
||||
GTK_PAGE_SETUP
|
||||
GTK_IS_PAGE_SETUP
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_page_setup_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprintcontext</FILE>
|
||||
<TITLE>GtkPrintContext</TITLE>
|
||||
GtkPrintContext
|
||||
gtk_print_context_get_cairo
|
||||
gtk_print_context_get_page_setup
|
||||
gtk_print_context_get_width
|
||||
gtk_print_context_get_height
|
||||
gtk_print_context_get_dpi_x
|
||||
gtk_print_context_get_dpi_y
|
||||
gtk_print_context_get_fontmap
|
||||
gtk_print_context_create_context
|
||||
gtk_print_context_create_layout
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINT_CONTEXT
|
||||
GTK_PRINT_CONTEXT
|
||||
GTK_IS_PRINT_CONTEXT
|
||||
|
||||
<SUBSECTION Private>
|
||||
gtk_print_context_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<FILE>gtkprintjob</FILE>
|
||||
<TITLE>GtkPrintJob</TITLE>
|
||||
GtkPrintJob
|
||||
GtkPrintJobCompleteFunc
|
||||
gtk_print_job_new
|
||||
gtk_print_job_get_settings
|
||||
gtk_print_job_get_printer
|
||||
gtk_print_job_get_title
|
||||
gtk_print_job_get_status
|
||||
gtk_print_job_set_source_file
|
||||
gtk_print_job_get_surface
|
||||
gtk_print_job_send
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GTK_TYPE_PRINT_JOB
|
||||
GTK_PRINT_JOB
|
||||
GTK_PRINT_JOB_CLASS
|
||||
GTK_IS_PRINT_JOB
|
||||
GTK_IS_PRINT_JOB_CLASS
|
||||
GTK_PRINT_JOB_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkPrintJobPrivate
|
||||
gtk_print_job_get_type
|
||||
</SECTION>
|
||||
|
||||
|
||||
<SECTION>
|
||||
<INCLUDE>gtk/gtkpagesetupunixdialog.h</INCLUDE>
|
||||
<FILE>gtkpagesetupunixdialog</FILE>
|
||||
<TITLE>GtkPageSetupUnixDialog</TITLE>
|
||||
GtkPageSetupUnixDialog
|
||||
gtk_page_setup_unix_dialog_new
|
||||
gtk_page_setup_unix_dialog_set_page_setup
|
||||
gtk_page_setup_unix_dialog_get_page_setup
|
||||
gtk_page_setup_unix_dialog_set_print_settings
|
||||
gtk_page_setup_unix_dialog_get_print_settings
|
||||
|
||||
<SUBSECTION Standard>
|
||||
GtkPageSetupUnixDialogClass
|
||||
GTK_TYPE_PAGE_SETUP_UNIX_DIALOG
|
||||
GTK_PAGE_SETUP_UNIX_DIALOG
|
||||
GTK_PAGE_SETUP_UNIX_DIALOG_CLASS
|
||||
GTK_IS_PAGE_SETUP_UNIX_DIALOG
|
||||
GTK_IS_PAGE_SETUP_UNIX_DIALOG_CLASS
|
||||
GTK_PAGE_SETUP_UNIX_DIALOG_GET_CLASS
|
||||
|
||||
<SUBSECTION Private>
|
||||
GtkPageSetupUnixDialogPrivate
|
||||
gtk_page_setup_unix_dialog_get_type
|
||||
</SECTION>
|
||||
|
@ -96,10 +96,19 @@ gtk_notebook_get_type
|
||||
gtk_object_get_type
|
||||
gtk_old_editable_get_type
|
||||
gtk_option_menu_get_type
|
||||
gtk_page_setup_get_type
|
||||
gtk_page_setup_unix_dialog_get_type
|
||||
gtk_paned_get_type
|
||||
gtk_paper_size_get_type
|
||||
gtk_pixmap_get_type
|
||||
gtk_plug_get_type
|
||||
gtk_preview_get_type
|
||||
gtk_printer_get_type
|
||||
gtk_print_context_get_type
|
||||
gtk_print_job_get_type
|
||||
gtk_print_operation_get_type
|
||||
gtk_print_settings_get_type
|
||||
gtk_print_unix_dialog_get_type
|
||||
gtk_progress_bar_get_type
|
||||
gtk_progress_get_type
|
||||
gtk_radio_action_get_type
|
||||
|
BIN
docs/reference/gtk/images/pagesetupdialog.png
Normal file
BIN
docs/reference/gtk/images/pagesetupdialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
docs/reference/gtk/images/printdialog.png
Normal file
BIN
docs/reference/gtk/images/printdialog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
251
docs/reference/gtk/tmpl/gtkpagesetup.sgml
Normal file
251
docs/reference/gtk/tmpl/gtkpagesetup.sgml
Normal file
@ -0,0 +1,251 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPageSetup
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Stores page setup information
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
A GtkPageSetup object stores the page size, orientation and margins.
|
||||
The idea is that you can get one of these from the page setup dialog
|
||||
and then pass it to the #GtkPrittntOperation when printing.
|
||||
The benefit of splitting this out of the #GtkPrintSettings is that
|
||||
these affect the actual layout of the page, and thus need to be set
|
||||
long before user prints.
|
||||
</para>
|
||||
<para id="print-margins">
|
||||
The margins specified in this object are the "print margins", i.e. the
|
||||
parts of the page that the printer cannot print on. These are different
|
||||
from the layout margins that a word processor uses; they are typically
|
||||
used to determine the <emphasis>minimal</emphasis> size for the layout
|
||||
margins.
|
||||
</para>
|
||||
<para>
|
||||
To obtain a #GtkPageSetup use gtk_page_setup_new()
|
||||
to get the defaults, or use gtk_print_run_page_setup_dialog() to show
|
||||
the page setup dialog and receive the resulting page setup.
|
||||
</para>
|
||||
<example>
|
||||
<title>A page setup dialog</title>
|
||||
<programlisting>
|
||||
static GtkPrintSettings *settings = NULL;
|
||||
static GtkPageSetup *page_setup = NULL;
|
||||
|
||||
static void
|
||||
do_page_setup (void)
|
||||
{
|
||||
GtkPageSetup *new_page_setup;
|
||||
|
||||
if (settings == NULL)
|
||||
settings = gtk_print_settings_new (<!-- -->);
|
||||
|
||||
new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window),
|
||||
page_setup, settings);
|
||||
|
||||
if (page_setup)
|
||||
g_object_unref (page_setup);
|
||||
|
||||
page_setup = new_page_setup;
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPageSetup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_copy ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@other:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_orientation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_orientation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@orientation:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_paper_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_paper_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@size:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_top_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_top_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@margin:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_bottom_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_bottom_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@margin:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_left_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_left_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@margin:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_right_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_right_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@margin:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_set_paper_size_and_default_margins ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@size:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_paper_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_paper_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_page_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_get_page_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@setup:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
80
docs/reference/gtk/tmpl/gtkpagesetupunixdialog.sgml
Normal file
80
docs/reference/gtk/tmpl/gtkpagesetupunixdialog.sgml
Normal file
@ -0,0 +1,80 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPageSetupUnixDialog
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
A page setup dialog
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
GtkPageSetupUnixDialog implements a page setup dialog for platforms
|
||||
which don't provide a native page setup dialog, like Unix. It can
|
||||
be used very much like any other GTK+ dialog, at the cost of
|
||||
the portability offered by the <link
|
||||
linkend="gtk-High-level-Printing-API">high-level printing API</link>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPageSetupUnixDialog ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_unix_dialog_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@title:
|
||||
@parent:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_unix_dialog_set_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@page_setup:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_unix_dialog_get_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_unix_dialog_set_print_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@print_settings:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_page_setup_unix_dialog_get_print_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@Returns:
|
||||
|
||||
|
275
docs/reference/gtk/tmpl/gtkpapersize.sgml
Normal file
275
docs/reference/gtk/tmpl/gtkpapersize.sgml
Normal file
@ -0,0 +1,275 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPaperSize
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Support for named paper sizes
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
GtkPaperSize handles paper sizes. It uses the standard called
|
||||
"PWG 5101.1-2002 PWG: Standard for Media Standardized Names"
|
||||
<!-- FIXME link here -->
|
||||
to name the paper sizes (and to get the data for the page sizes).
|
||||
In addition to standard paper sizes, GtkPaperSize allows to
|
||||
construct custom paper sizes with arbitrary dimensions.
|
||||
</para>
|
||||
<para>
|
||||
The #GtkPaperSize object stores not only the dimensions (width
|
||||
and height) of a paper size and its name, it also provides
|
||||
default <link linkend="print-margins">print margins</link>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Printing support has been added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
#GtkPageSetup
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPaperSize ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkUnit ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_UNIT_PIXEL:
|
||||
@GTK_UNIT_POINTS:
|
||||
@GTK_UNIT_INCH:
|
||||
@GTK_UNIT_MM:
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_A3 ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_A4 ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_A5 ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_B5 ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_LETTER ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_EXECUTIVE ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### MACRO GTK_PAPER_NAME_LEGAL ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@name:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_new_from_ppd ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@ppd_name:
|
||||
@ppd_display_name:
|
||||
@width:
|
||||
@height:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_new_custom ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@name:
|
||||
@display_name:
|
||||
@width:
|
||||
@height:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_copy ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@other:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_free ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_is_equal ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size1:
|
||||
@size2:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_display_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_ppd_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_is_custom ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_set_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@width:
|
||||
@height:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_default_top_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_default_bottom_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_default_left_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_default_right_margin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@size:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_paper_size_get_default ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
175
docs/reference/gtk/tmpl/gtkprintcontext.sgml
Normal file
175
docs/reference/gtk/tmpl/gtkprintcontext.sgml
Normal file
@ -0,0 +1,175 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrintContext
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Encapsulates context for drawing pages
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
A GtkPrintContext encapsulates context information that is required when
|
||||
drawing pages for printing, such as the cairo context and important
|
||||
parameters like page size and resolution. It also lets you easily
|
||||
create #PangoLayout and #PangoContext objects that match the font metrics
|
||||
of the cairo surface.
|
||||
</para>
|
||||
<para>
|
||||
GtkPrintContext objects gets passed to the ::begin-print, ::end-print,
|
||||
::request-page-setup and ::draw-page signals on the #GtkPrintOperation.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Using GtkPrintContext in a ::draw-page callback</title>
|
||||
<programlisting>
|
||||
static void
|
||||
draw_page (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
int page_nr)
|
||||
{
|
||||
cairo_t *cr;
|
||||
PangoLayout *layout;
|
||||
PangoFontDescription *desc;
|
||||
|
||||
cr = gtk_print_context_get_cairo (context);
|
||||
|
||||
/* Draw a red rectangle, as wide as the paper (inside the margins) */
|
||||
cairo_set_source_rgb (cr, 1.0, 0, 0);
|
||||
cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50);
|
||||
|
||||
cairo_fill (cr);
|
||||
|
||||
/* Draw some lines */
|
||||
cairo_move_to (cr, 20, 10);
|
||||
cairo_line_to (cr, 40, 20);
|
||||
cairo_arc (cr, 60, 60, 20, 0, M_PI);
|
||||
cairo_line_to (cr, 80, 20);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
cairo_set_line_width (cr, 5);
|
||||
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
|
||||
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
|
||||
|
||||
cairo_stroke (cr);
|
||||
|
||||
/* Draw some text */
|
||||
layout = gtk_print_context_create_layout (context);
|
||||
pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
|
||||
desc = pango_font_description_from_string ("sans 28");
|
||||
pango_layout_set_font_description (layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
cairo_move_to (cr, 30, 20);
|
||||
pango_cairo_layout_path (cr, layout);
|
||||
|
||||
/* Font Outline */
|
||||
cairo_set_source_rgb (cr, 0.93, 1.0, 0.47);
|
||||
cairo_set_line_width (cr, 0.5);
|
||||
cairo_stroke_preserve (cr);
|
||||
|
||||
/* Font Fill */
|
||||
cairo_set_source_rgb (cr, 0, 0.0, 1.0);
|
||||
cairo_fill (cr);
|
||||
|
||||
g_object_unref (layout);
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrintContext ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_cairo ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_dpi_x ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_dpi_y ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_get_fontmap ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_create_context ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_context_create_layout ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@context:
|
||||
@Returns:
|
||||
|
||||
|
163
docs/reference/gtk/tmpl/gtkprinter.sgml
Normal file
163
docs/reference/gtk/tmpl/gtkprinter.sgml
Normal file
@ -0,0 +1,163 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrinter
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Represents a printer
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
A #GtkPrinter object represents a printer. You only need to
|
||||
deal directly with printers if you use the non-portable
|
||||
#GtkPrintUnixDialog API.
|
||||
</para>
|
||||
<para>
|
||||
A #GtkPrinter allows to get status information about the printer,
|
||||
such as its description, its location, the number of queued jobs,
|
||||
etc. Most importantly, a #GtkPrinter object can be used to create
|
||||
a #GtkPrintJob object, which lets you print to the printer.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrinter ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GtkPrinter::details-acquired ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer: the object which received the signal.
|
||||
@arg1:
|
||||
|
||||
<!-- ##### ARG GtkPrinter:backend ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:icon-name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:is-virtual ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:job-count ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:location ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrinter:state-message ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@name:
|
||||
@backend:
|
||||
@virtual:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_backend ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_state_message ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_location ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_icon_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_get_job_count ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_is_active ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_printer_is_virtual ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printer:
|
||||
@Returns:
|
||||
|
||||
|
159
docs/reference/gtk/tmpl/gtkprintjob.sgml
Normal file
159
docs/reference/gtk/tmpl/gtkprintjob.sgml
Normal file
@ -0,0 +1,159 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrintJob
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Represents a print job
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
A #GtkPrintJob object represents a job that is sent to a
|
||||
printer. You only need to deal directly with print jobs if
|
||||
you use the non-portable #GtkPrintUnixDialog API.
|
||||
</para>
|
||||
<para>
|
||||
Use gtk_print_job_get_surface() to obtain the cairo surface
|
||||
onto which the pages must be drawn. Use gtk_print_job_send()
|
||||
to send the finished job to the printer. If you don't use cairo
|
||||
#GtkPrintJob also supports printing of manually generated postscript,
|
||||
via gtk_print_job_set_source_file().
|
||||
<!-- FIXME more details needed here -->
|
||||
</para>
|
||||
<!-- FIXME examples ? -->
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrintJob ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintJob::status-changed ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printjob: the object which received the signal.
|
||||
|
||||
<!-- ##### ARG GtkPrintJob:page-setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrintJob:printer ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrintJob:settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkPrintJob:title ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### USER_FUNCTION GtkPrintJobCompleteFunc ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@user_data:
|
||||
@error:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@title:
|
||||
@printer:
|
||||
@settings:
|
||||
@page_setup:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_get_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_get_printer ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_get_title ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_get_status ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_set_source_file ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@filename:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_get_surface ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_job_send ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@print_job:
|
||||
@callback:
|
||||
@user_data:
|
||||
@dnotify:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
321
docs/reference/gtk/tmpl/gtkprintoperation.sgml
Normal file
321
docs/reference/gtk/tmpl/gtkprintoperation.sgml
Normal file
@ -0,0 +1,321 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrintOperation
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
High-level Printing API
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
GtkPrintOperation is the high-level, portable printing API. It looks
|
||||
a bit different than other GTK+ dialogs such as the #GtkFileChooser,
|
||||
since some platforms don't expose enough infrastructure to implement
|
||||
a good print dialog. On such platforms, GtkPrintOperation uses the
|
||||
native print dialog. On platforms which do not provide a native
|
||||
print dialog, GTK+ uses its own, see #GtkPrintUnixDialog.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The typical way to use the high-level printing API is to create a
|
||||
#GtkPrintOperation object with gtk_print_operation_new() when the user
|
||||
selects to print. Then you set some properties on it, e.g. the page size,
|
||||
any #GtkPrintSettings from previous print operations, the number of pages,
|
||||
the current page, etc.
|
||||
</para>
|
||||
<para>
|
||||
Then you start the print operation by calling gtk_print_operation_run().
|
||||
It will then show a dialog, let the user select a printer and options.
|
||||
When the user finished the dialog various signals will be emitted on the
|
||||
#GtkPrintOperation, the main one being ::draw-page, which you are supposed
|
||||
to catch and render the page on the provided #GtkPrintContext using Cairo.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>The high-level printing API</title>
|
||||
<programlisting>
|
||||
static GtkPrintSettings *settings = NULL;
|
||||
|
||||
static void
|
||||
do_print (void)
|
||||
{
|
||||
GtkPrintOperation *print;
|
||||
GtkPrintOperationResult res;
|
||||
|
||||
print = gtk_print_operation_new (<!-- -->);
|
||||
|
||||
if (settings != NULL)
|
||||
gtk_print_operation_set_print_settings (print, settings);
|
||||
|
||||
g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), NULL);
|
||||
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), NULL);
|
||||
|
||||
res = gtk_print_operation_run (print, GTK_WINDOW (main_window), NULL);
|
||||
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
|
||||
{
|
||||
if (settings != NULL)
|
||||
g_object_unref (settings);
|
||||
settings = g_object_ref (gtk_print_operation_get_print_settings (print));
|
||||
}
|
||||
|
||||
g_object_unref (print);
|
||||
}
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
#GtkPrintContext, #GtkPrintUnixDialog
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrintOperation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintOperation::begin-print ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printoperation: the object which received the signal.
|
||||
@arg1:
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintOperation::draw-page ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printoperation: the object which received the signal.
|
||||
@arg1:
|
||||
@arg2:
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintOperation::end-print ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printoperation: the object which received the signal.
|
||||
@arg1:
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintOperation::request-page-setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printoperation: the object which received the signal.
|
||||
@arg1:
|
||||
@arg2:
|
||||
@arg3:
|
||||
|
||||
<!-- ##### SIGNAL GtkPrintOperation::status-changed ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@printoperation: the object which received the signal.
|
||||
|
||||
<!-- ##### ENUM GtkPrintStatus ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_STATUS_INITIAL:
|
||||
@GTK_PRINT_STATUS_PREPARING:
|
||||
@GTK_PRINT_STATUS_GENERATING_DATA:
|
||||
@GTK_PRINT_STATUS_SENDING_DATA:
|
||||
@GTK_PRINT_STATUS_PENDING:
|
||||
@GTK_PRINT_STATUS_PENDING_ISSUE:
|
||||
@GTK_PRINT_STATUS_PRINTING:
|
||||
@GTK_PRINT_STATUS_FINISHED:
|
||||
@GTK_PRINT_STATUS_FINISHED_ABORTED:
|
||||
|
||||
<!-- ##### ENUM GtkPrintOperationResult ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_OPERATION_RESULT_ERROR:
|
||||
@GTK_PRINT_OPERATION_RESULT_APPLY:
|
||||
@GTK_PRINT_OPERATION_RESULT_CANCEL:
|
||||
|
||||
<!-- ##### ENUM GtkPrintError ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_ERROR_GENERAL:
|
||||
@GTK_PRINT_ERROR_INTERNAL_ERROR:
|
||||
@GTK_PRINT_ERROR_NOMEM:
|
||||
|
||||
<!-- ##### MACRO GTK_PRINT_ERROR ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_error_quark ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_default_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@default_page_setup:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_get_default_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_print_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@print_settings:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_get_print_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_job_name ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@job_name:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_nr_of_pages ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@n_pages:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_current_page ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@current_page:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_use_full_page ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@full_page:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_unit ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_show_dialog ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@show_dialog:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_set_pdf_target ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@filename:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_run ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@parent:
|
||||
@error:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_get_status ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_operation_is_finished ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@op:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_run_page_setup_dialog ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@parent:
|
||||
@page_setup:
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
697
docs/reference/gtk/tmpl/gtkprintsettings.sgml
Normal file
697
docs/reference/gtk/tmpl/gtkprintsettings.sgml
Normal file
@ -0,0 +1,697 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrintSettings
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
Stores print settings
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
A GtkPrintSettings object represents the settings of a print dialog in
|
||||
a system-independent way. The main use for this object is that once
|
||||
you've printed you can get a settings object that represents the settings
|
||||
the user chose, and the next time you print you can pass that object in so
|
||||
that the user doesn't have to re-set all his settings.
|
||||
</para>
|
||||
<para>
|
||||
Its also possible to enumerate the settings so that you can easily save
|
||||
the settings for the next time your app runs, or even store them in a
|
||||
document. The predefined keys try to use shared values as much as possible
|
||||
so that moving such a document between systems still works.
|
||||
</para>
|
||||
|
||||
<!-- TODO example of getting, storing and setting settings -->
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrintSettings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### USER_FUNCTION GtkPrintSettingsFunc ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@key:
|
||||
@value:
|
||||
@user_data:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_new ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_copy ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@other:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_has_key ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@value:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_unset ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_foreach ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@func:
|
||||
@user_data:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_bool ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_bool ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@value:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_double ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_double_with_default ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@def:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_double ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@value:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_length ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_length ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@value:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_int ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_int_with_default ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@def:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_int ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@key:
|
||||
@value:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_printer ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_printer ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@printer:
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkPageOrientation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PAGE_ORIENTATION_PORTRAIT:
|
||||
@GTK_PAGE_ORIENTATION_LANDSCAPE:
|
||||
@GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
|
||||
@GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_orientation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_orientation ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@orientation:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_paper_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_paper_size ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@paper_size:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_paper_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_paper_width ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@width:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_paper_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@unit:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_paper_height ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@width:
|
||||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_use_color ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_use_color ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@use_color:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_collate ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_collate ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@collate:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_reverse ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_reverse ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@reverse:
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkPrintDuplex ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_DUPLEX_SIMPLEX:
|
||||
@GTK_PRINT_DUPLEX_HORIZONTAL:
|
||||
@GTK_PRINT_DUPLEX_VERTICAL:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_duplex ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_duplex ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@duplex:
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkPrintQuality ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_QUALITY_LOW:
|
||||
@GTK_PRINT_QUALITY_NORMAL:
|
||||
@GTK_PRINT_QUALITY_HIGH:
|
||||
@GTK_PRINT_QUALITY_DRAFT:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_quality ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_quality ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@quality:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_num_copies ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_num_copies ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@num_copies:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_number_up ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_number_up ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@number_up:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_resolution ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_resolution ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@resolution:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_scale ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_scale ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@scale:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_print_to_file ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_print_to_file ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@print_to_file:
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkPrintPages ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PRINT_PAGES_ALL:
|
||||
@GTK_PRINT_PAGES_CURRENT:
|
||||
@GTK_PRINT_PAGES_RANGES:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_print_pages ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_print_pages ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@pages:
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPageRange ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@start:
|
||||
@end:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_page_ranges ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@num_ranges:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_page_ranges ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@page_ranges:
|
||||
@num_ranges:
|
||||
|
||||
|
||||
<!-- ##### ENUM GtkPageSet ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@GTK_PAGE_SET_ALL:
|
||||
@GTK_PAGE_SET_EVEN:
|
||||
@GTK_PAGE_SET_ODD:
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_page_set ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_page_set ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@page_set:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_default_source ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_default_source ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@default_source:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_media_type ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_media_type ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@media_type:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_dither ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_dither ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@dither:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_finishings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_finishings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@finishings:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_get_output_bin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_settings_set_output_bin ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@settings:
|
||||
@output_bin:
|
||||
|
||||
|
86
docs/reference/gtk/tmpl/gtkprintunixdialog.sgml
Normal file
86
docs/reference/gtk/tmpl/gtkprintunixdialog.sgml
Normal file
@ -0,0 +1,86 @@
|
||||
<!-- ##### SECTION Title ##### -->
|
||||
GtkPrintUnixDialog
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
A print dialog
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
GtkPrintUnixDialog implements a print dialog for platforms
|
||||
which don't provide a native print dialog, like Unix. It can
|
||||
be used very much like any other GTK+ dialog, at the cost of
|
||||
the portability offered by the <link
|
||||
linkend="gtk-High-level-Printing-API">high-level printing API</link>
|
||||
</para>
|
||||
<para>
|
||||
In order to print something with #GtkPrintUnixDialog, you need
|
||||
to use gtk_print_unix_dialog_get_selected_printer() to obtain
|
||||
a #GtkPrinter object and use it to construct a #GtkPrintJob using
|
||||
gtk_print_job_new().
|
||||
</para>
|
||||
|
||||
<!-- FIXME example here -->
|
||||
|
||||
<para>
|
||||
Printing support was added in GTK+ 2.10.
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
#GtkPageSetupUnixDialog, #GtkPrinter, #GtkPrintJob
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION Stability_Level ##### -->
|
||||
|
||||
|
||||
<!-- ##### STRUCT GtkPrintUnixDialog ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_unix_dialog_set_page_setup ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@page_setup:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_unix_dialog_set_current_page ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@current_page:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_unix_dialog_set_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@settings:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_unix_dialog_get_settings ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gtk_print_unix_dialog_get_selected_printer ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@dialog:
|
||||
@Returns:
|
||||
|
||||
|
@ -50,6 +50,12 @@
|
||||
<link linkend="GtkPaned">
|
||||
<inlinegraphic fileref="panes.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPageSetupUnixDialog">
|
||||
<inlinegraphic fileref="pagesetupdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkPrintUnixDialog">
|
||||
<inlinegraphic fileref="printdialog.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
<link linkend="GtkProgressBar">
|
||||
<inlinegraphic fileref="progressbar.png" format="PNG"></inlinegraphic>
|
||||
</link>
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <gtk/gtkprintunixdialog.h>
|
||||
#include <gtk/gtkpagesetupunixdialog.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdkx.h>
|
||||
@ -666,6 +668,43 @@ create_filesel (void)
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_print_dialog (void)
|
||||
{
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_print_unix_dialog_new ("Print Dialog", NULL);
|
||||
gtk_widget_set_size_request (widget, 505, 350);
|
||||
info = new_widget_info ("printdialog", widget, ASIS);
|
||||
info->include_decorations = TRUE;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_page_setup_dialog (void)
|
||||
{
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
GtkPageSetup *page_setup;
|
||||
GtkPrintSettings *settings;
|
||||
|
||||
page_setup = gtk_page_setup_new ();
|
||||
settings = gtk_print_settings_new ();
|
||||
widget = gtk_page_setup_unix_dialog_new ("Page Setup Dialog", NULL);
|
||||
gtk_page_setup_unix_dialog_set_page_setup (GTK_PAGE_SETUP_UNIX_DIALOG (widget),
|
||||
page_setup);
|
||||
gtk_page_setup_unix_dialog_set_print_settings (GTK_PAGE_SETUP_UNIX_DIALOG (widget),
|
||||
settings);
|
||||
|
||||
info = new_widget_info ("pagesetupdialog", widget, ASIS);
|
||||
gtk_widget_set_app_paintable (info->window, FALSE);
|
||||
info->include_decorations = TRUE;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
create_toolbar (void)
|
||||
{
|
||||
@ -940,6 +979,8 @@ get_all_widgets (void)
|
||||
retval = g_list_prepend (retval, create_fontsel ());
|
||||
retval = g_list_prepend (retval, create_assistant ());
|
||||
retval = g_list_prepend (retval, create_recent_chooser_dialog ());
|
||||
retval = g_list_prepend (retval, create_page_setup_dialog ());
|
||||
retval = g_list_prepend (retval, create_print_dialog ());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
## Makefile.am for gtk+/gdk/gdk-directfb
|
||||
|
||||
libgdkincludedir = $(includedir)/gtk-2.0/gdk
|
||||
libgdkgdk_directfbincludedir = $(includedir)/gtk-2.0/gdk/gdk-directfb
|
||||
|
||||
INCLUDES = \
|
||||
-DG_LOG_DOMAIN=\"Gdk-DirectFB\" \
|
||||
@ -23,8 +22,8 @@ libgdk_directfb_la_SOURCES = \
|
||||
gdkcolor-directfb.c \
|
||||
gdkcursor-directfb.c \
|
||||
gdkdnd-directfb.c \
|
||||
gdkdisplay-directfb.c \
|
||||
gdkdisplay-directfb.h \
|
||||
gdkdisplay-directfb.c \
|
||||
gdkdisplay-directfb.h \
|
||||
gdkdrawable-directfb.c \
|
||||
gdkevents-directfb.c \
|
||||
gdkfont-directfb.c \
|
||||
@ -50,8 +49,8 @@ libgdk_directfb_la_SOURCES = \
|
||||
x-cursors.xbm
|
||||
|
||||
libgdkinclude_HEADERS = \
|
||||
gdkdirectfb.h \
|
||||
gdkdirectfb.h \
|
||||
gdkprivate-directfb.h
|
||||
|
||||
|
||||
EXTRA_DIST = AUTHORS README TODO ChangeLog
|
||||
EXTRA_DIST = AUTHORS README TODO
|
||||
|
@ -1110,6 +1110,12 @@ gdk_win32_drawable_get_handle
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GDK_WIN32_H__)
|
||||
#if IN_FILE(__GDK_EVENTS_WIN32_C__)
|
||||
gdk_win32_set_modal_dialog_libgtk_only
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GDK_WIN32_H__)
|
||||
#if IN_FILE(__GDK_GC_WIN32_C__)
|
||||
gdk_win32_hdc_get
|
||||
|
@ -144,6 +144,9 @@ static gint current_root_x, current_root_y;
|
||||
static UINT msh_mousewheel;
|
||||
static UINT client_message;
|
||||
|
||||
static UINT got_gdk_events_message;
|
||||
static HWND modal_win32_dialog = NULL;
|
||||
|
||||
#ifdef HAVE_DIMM_H
|
||||
static IActiveIMMApp *active_imm_app = NULL;
|
||||
static IActiveIMMMessagePumpOwner *active_imm_msgpump_owner = NULL;
|
||||
@ -281,6 +284,9 @@ inner_window_procedure (HWND hwnd,
|
||||
/* If gdk_event_translate() returns TRUE, we return ret_val from
|
||||
* the window procedure.
|
||||
*/
|
||||
if (modal_win32_dialog)
|
||||
PostMessage (modal_win32_dialog, got_gdk_events_message,
|
||||
(WPARAM) 1, 0);
|
||||
return ret_val;
|
||||
}
|
||||
else
|
||||
@ -379,6 +385,7 @@ _gdk_events_init (void)
|
||||
msh_mousewheel = RegisterWindowMessage ("MSWHEEL_ROLLMSG");
|
||||
|
||||
client_message = RegisterWindowMessage ("GDK_WIN32_CLIENT_MESSAGE");
|
||||
got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
|
||||
|
||||
#if 0
|
||||
/* Check if we have some input locale identifier loaded that uses a
|
||||
@ -463,7 +470,8 @@ gdk_events_pending (void)
|
||||
{
|
||||
MSG msg;
|
||||
return (_gdk_event_queue_find_first (_gdk_display) ||
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
|
||||
(modal_win32_dialog == NULL &&
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
|
||||
}
|
||||
|
||||
GdkEvent*
|
||||
@ -3516,6 +3524,9 @@ _gdk_events_queue (GdkDisplay *display)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
if (modal_win32_dialog != NULL)
|
||||
return;
|
||||
|
||||
while (!_gdk_event_queue_find_first (display) &&
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
@ -3536,7 +3547,8 @@ gdk_event_prepare (GSource *source,
|
||||
*timeout = -1;
|
||||
|
||||
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
|
||||
(modal_win32_dialog == NULL &&
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
|
||||
|
||||
GDK_THREADS_LEAVE ();
|
||||
|
||||
@ -3553,7 +3565,8 @@ gdk_event_check (GSource *source)
|
||||
|
||||
if (event_poll_fd.revents & G_IO_IN)
|
||||
retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE));
|
||||
(modal_win32_dialog == NULL &&
|
||||
PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)));
|
||||
else
|
||||
retval = FALSE;
|
||||
|
||||
@ -3587,6 +3600,12 @@ gdk_event_dispatch (GSource *source,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_win32_set_modal_dialog_libgtk_only (HWND window)
|
||||
{
|
||||
modal_win32_dialog = window;
|
||||
}
|
||||
|
||||
static void
|
||||
check_for_too_much_data (GdkEvent *event)
|
||||
{
|
||||
|
@ -87,6 +87,7 @@ void gdk_win32_selection_add_targets (GdkWindow *owner,
|
||||
/* For internal GTK use only */
|
||||
GdkPixbuf * gdk_win32_icon_to_pixbuf_libgtk_only (HICON hicon);
|
||||
HICON gdk_win32_pixbuf_to_hicon_libgtk_only (GdkPixbuf *pixbuf);
|
||||
void gdk_win32_set_modal_dialog_libgtk_only (HWND window);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
14
gtk+-unix-print-2.0.pc.in
Normal file
14
gtk+-unix-print-2.0.pc.in
Normal file
@ -0,0 +1,14 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
target=@gdktarget@
|
||||
|
||||
gtk_binary_version=@GTK_BINARY_VERSION@
|
||||
gtk_host=@host@
|
||||
|
||||
Name: GTK+
|
||||
Description: GIMP Tool Kit Unix print support
|
||||
Version: @VERSION@
|
||||
Requires: gtk+-${target}-2.0 @GTK_PACKAGES@
|
||||
Cflags: -I${includedir}/gtk-unix-print-2.0
|
@ -6,7 +6,13 @@ if OS_UNIX
|
||||
SUBDIRS += xdgmime
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS=stock-icons theme-bits xdgmime
|
||||
DIST_SUBDIRS=theme-bits xdgmime
|
||||
|
||||
if HAVE_CUPS
|
||||
GTK_PRINT_BACKENDS=pdf,cups
|
||||
else
|
||||
GTK_PRINT_BACKENDS=pdf,lpr
|
||||
endif
|
||||
|
||||
INCLUDES = \
|
||||
-DG_LOG_DOMAIN=\"Gtk\" \
|
||||
@ -18,6 +24,7 @@ INCLUDES = \
|
||||
-DGTK_BINARY_VERSION=\"$(GTK_BINARY_VERSION)\" \
|
||||
-DGTK_HOST=\"$(host)\" \
|
||||
-DGTK_COMPILATION \
|
||||
-DGTK_PRINT_BACKENDS=\"$(GTK_PRINT_BACKENDS)\" \
|
||||
-I$(top_builddir)/gtk \
|
||||
-I$(top_srcdir) -I../gdk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
@ -26,6 +33,7 @@ INCLUDES = \
|
||||
-DGDK_DISABLE_DEPRECATED \
|
||||
-DGTK_DISABLE_DEPRECATED \
|
||||
-DGTK_FILE_SYSTEM_ENABLE_UNSUPPORTED \
|
||||
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
|
||||
$(GTK_DEBUG_FLAGS) \
|
||||
$(GTK_DEP_CFLAGS) \
|
||||
$(gtk_clipboard_dnd_c_sources_CFLAGS)
|
||||
@ -215,10 +223,15 @@ gtk_public_h_sources = \
|
||||
gtkobject.h \
|
||||
gtkoldeditable.h \
|
||||
gtkoptionmenu.h \
|
||||
gtkpagesetup.h \
|
||||
gtkpaned.h \
|
||||
gtkpapersize.h \
|
||||
gtkpixmap.h \
|
||||
gtkplug.h \
|
||||
gtkpreview.h \
|
||||
gtkprintcontext.h \
|
||||
gtkprintoperation.h \
|
||||
gtkprintsettings.h \
|
||||
gtkprivate.h \
|
||||
gtkprogress.h \
|
||||
gtkprogressbar.h \
|
||||
@ -295,6 +308,11 @@ gtk_public_h_sources = \
|
||||
gtkwidget.h \
|
||||
gtkwindow.h
|
||||
|
||||
gtk_unix_print_public_h_sources = \
|
||||
gtkpagesetupunixdialog.h \
|
||||
gtkprinter.h \
|
||||
gtkprintunixdialog.h
|
||||
|
||||
# Installed header files without compatibility guarantees
|
||||
# that are not include in gtk/gtk.h
|
||||
gtk_semi_private_h_sources = \
|
||||
@ -305,16 +323,17 @@ gtk_semi_private_h_sources = \
|
||||
gtk_private_h_sources = \
|
||||
gtkdndcursors.h \
|
||||
gtkentryprivate.h \
|
||||
gtkfilechooserdefault.h \
|
||||
gtkfilechooserembed.h \
|
||||
gtkfilechooserentry.h \
|
||||
gtkfilechooserdefault.h \
|
||||
gtkfilechooserprivate.h \
|
||||
gtkfilechooserutils.h \
|
||||
gtkfilesystemunix.h \
|
||||
gtkfilesystemmodel.h \
|
||||
gtkfilesystemunix.h \
|
||||
gtkiconcache.h \
|
||||
gtkpathbar.h \
|
||||
gtkplugprivate.h \
|
||||
gtkprintoperation-private.h\
|
||||
gtkrbtree.h \
|
||||
gtkrecentchooserdefault.h \
|
||||
gtkrecentchooserprivate.h \
|
||||
@ -323,17 +342,17 @@ gtk_private_h_sources = \
|
||||
gtksocketprivate.h \
|
||||
gtktextbtree.h \
|
||||
gtktextchildprivate.h \
|
||||
gtktextsegment.h \
|
||||
gtktexttypes.h \
|
||||
gtktextutil.h \
|
||||
gtktextiterprivate.h \
|
||||
gtktextmarkprivate.h \
|
||||
gtktextsegment.h \
|
||||
gtktexttagprivate.h \
|
||||
gtktexttypes.h \
|
||||
gtktextutil.h \
|
||||
gtkthemes.h \
|
||||
gtktoggleactionprivate.h\
|
||||
gtktreedatalist.h \
|
||||
gtktreeprivate.h \
|
||||
gtkwindow-decorate.h \
|
||||
gtktoggleactionprivate.h
|
||||
gtkwindow-decorate.h
|
||||
|
||||
# GTK+ C sources to build the library from
|
||||
gtk_c_sources = \
|
||||
@ -388,10 +407,10 @@ gtk_c_sources = \
|
||||
gtkexpander.c \
|
||||
gtkfilechooser.c \
|
||||
gtkfilechooserbutton.c \
|
||||
gtkfilechooserdefault.c \
|
||||
gtkfilechooserdialog.c \
|
||||
gtkfilechooserembed.c \
|
||||
gtkfilechooserentry.c \
|
||||
gtkfilechooserdefault.c \
|
||||
gtkfilechooserutils.c \
|
||||
gtkfilechooserwidget.c \
|
||||
gtkfilefilter.c \
|
||||
@ -414,8 +433,8 @@ gtk_c_sources = \
|
||||
gtkhseparator.c \
|
||||
gtkhsv.c \
|
||||
gtkhsv.h \
|
||||
gtkiconfactory.c \
|
||||
gtkiconcache.c \
|
||||
gtkiconfactory.c \
|
||||
gtkicontheme.c \
|
||||
gtkiconview.c \
|
||||
gtkimage.c \
|
||||
@ -454,11 +473,16 @@ gtk_c_sources = \
|
||||
gtkobject.c \
|
||||
gtkoldeditable.c \
|
||||
gtkoptionmenu.c \
|
||||
gtkpagesetup.c \
|
||||
gtkpaned.c \
|
||||
gtkpapersize.c \
|
||||
gtkpathbar.c \
|
||||
gtkpixmap.c \
|
||||
gtkplug.c \
|
||||
gtkpreview.c \
|
||||
gtkprintcontext.c \
|
||||
gtkprintoperation.c \
|
||||
gtkprintsettings.c \
|
||||
gtkprogress.c \
|
||||
gtkprogressbar.c \
|
||||
gtkradioaction.c \
|
||||
@ -480,11 +504,11 @@ gtk_c_sources = \
|
||||
gtkscale.c \
|
||||
gtkscrollbar.c \
|
||||
gtkscrolledwindow.c \
|
||||
gtksequence.c \
|
||||
gtkselection.c \
|
||||
gtkseparator.c \
|
||||
gtkseparatormenuitem.c \
|
||||
gtkseparatortoolitem.c \
|
||||
gtksequence.c \
|
||||
gtksettings.c \
|
||||
gtksignal.c \
|
||||
gtksizegroup.c \
|
||||
@ -554,13 +578,37 @@ gtk_c_sources = \
|
||||
$(gtk_clipboard_dnd_c_sources)
|
||||
|
||||
if OS_UNIX
|
||||
gtk_private_h_sources += gtkfilesystemunix.h
|
||||
gtk_c_sources += gtkfilesystemunix.c
|
||||
gtk_private_h_sources += \
|
||||
gtkfilesystemunix.h \
|
||||
gtkprintbackend.h \
|
||||
gtkprinter-private.h \
|
||||
gtkprinteroption.h \
|
||||
gtkprinteroptionset.h \
|
||||
gtkprinteroptionwidget.h \
|
||||
gtkprintjob.h
|
||||
|
||||
gtk_c_sources += \
|
||||
gtkfilesystemunix.c \
|
||||
gtkpagesetupunixdialog.c \
|
||||
gtkprinter.c \
|
||||
gtkprinteroption.c \
|
||||
gtkprinteroptionset.c \
|
||||
gtkprinteroptionwidget.c \
|
||||
gtkprintjob.c \
|
||||
gtkprintoperation-unix.c \
|
||||
gtkprintunixdialog.c \
|
||||
gtkprintbackend.c
|
||||
endif
|
||||
|
||||
if OS_WIN32
|
||||
gtk_private_h_sources += gtkfilesystemwin32.h
|
||||
gtk_c_sources += gtkfilesystemwin32.c
|
||||
gtk_private_h_sources +=
|
||||
gtkfilesystemwin32.h \
|
||||
gtkprint-win32.h
|
||||
|
||||
gtk_c_sources += \
|
||||
gtkfilesystemwin32.c \
|
||||
gtkprint-win32.c \
|
||||
gtkprintoperation-win32.c
|
||||
endif
|
||||
|
||||
if USE_X11
|
||||
@ -622,6 +670,9 @@ stamp_files = \
|
||||
# that don't serve as direct make target sources, i.e. they don't have
|
||||
# their own .lo rules and don't get publically installed
|
||||
gtk_extra_sources = \
|
||||
paper_names.c \
|
||||
paper_names_offsts.c \
|
||||
gen-paper-names.c \
|
||||
gtk.symbols \
|
||||
gtkversion.h.in \
|
||||
gtkmarshalers.list \
|
||||
@ -634,6 +685,7 @@ MAINTAINERCLEANFILES = $(gtk_built_sources) $(stamp_files)
|
||||
EXTRA_HEADERS =
|
||||
EXTRA_DIST = $(gtk_private_h_sources) $(gtk_extra_sources)
|
||||
EXTRA_DIST += $(gtk_built_sources)
|
||||
EXTRA_DIST += $(STOCK_ICONS)
|
||||
|
||||
#
|
||||
# rules to generate built sources
|
||||
@ -705,6 +757,9 @@ lib_LTLIBRARIES = $(gtktargetlib)
|
||||
gtkincludedir = $(includedir)/gtk-2.0/gtk
|
||||
gtkinclude_HEADERS = $(gtk_public_h_sources) $(gtk_semi_private_h_sources) $(gtk_built_public_sources) gtkversion.h
|
||||
|
||||
gtkunixprintincludedir = $(includedir)/gtk-unix-print-2.0/gtk
|
||||
gtkunixprintinclude_HEADERS = $(gtk_unix_print_public_h_sources)
|
||||
|
||||
libgtk_x11_2_0_la_SOURCES = $(gtk_c_sources)
|
||||
libgtk_linux_fb_2_0_la_SOURCES = $(gtk_c_sources)
|
||||
libgtk_win32_2_0_la_SOURCES = $(gtk_c_sources)
|
||||
@ -719,7 +774,7 @@ libgtk_directfb_2_0_la_LDFLAGS = $(libtool_opts)
|
||||
|
||||
libgtk_x11_2_0_la_LIBADD = $(libadd)
|
||||
libgtk_linux_fb_2_0_la_LIBADD = $(libadd)
|
||||
libgtk_win32_2_0_la_LIBADD = $(libadd) -lole32 -lgdi32
|
||||
libgtk_win32_2_0_la_LIBADD = $(libadd) -lole32 -lgdi32 -lcomdlg32 -lwinspool
|
||||
libgtk_win32_2_0_la_DEPENDENCIES = $(gtk_def) $(gtk_win32_res)
|
||||
libgtk_quartz_2_0_la_LIBADD = $(libadd)
|
||||
libgtk_directfb_2_0_la_LIBADD = $(libadd)
|
||||
@ -933,6 +988,9 @@ STOCK_ICONS = \
|
||||
stock-icons/24/gtk-network.png \
|
||||
stock-icons/24/gtk-new.png \
|
||||
stock-icons/24/gtk-open.png \
|
||||
stock-icons/24/gtk-orientation-reverse-landscape.png \
|
||||
stock-icons/24/gtk-orientation-landscape.png \
|
||||
stock-icons/24/gtk-orientation-portrait.png \
|
||||
stock-icons/24/gtk-paste.png \
|
||||
stock-icons/24/gtk-preferences.png \
|
||||
stock-icons/24/gtk-print.png \
|
||||
|
238
gtk/gen-paper-names.c
Normal file
238
gtk/gen-paper-names.c
Normal file
@ -0,0 +1,238 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 2006 Matthias Clasen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "paper_names.c"
|
||||
|
||||
static const gint n_infos = G_N_ELEMENTS (standard_names);
|
||||
static const gint n_extra = G_N_ELEMENTS (extra_ppd_names);
|
||||
|
||||
typedef struct {
|
||||
const gchar *s;
|
||||
gint len;
|
||||
gint suffix;
|
||||
gint offset;
|
||||
} NameInfo;
|
||||
|
||||
static NameInfo *names = NULL;
|
||||
static gint n_names = 0;
|
||||
|
||||
static void
|
||||
add_name (const gchar *name)
|
||||
{
|
||||
names[n_names].s = name;
|
||||
names[n_names].len = strlen (name);
|
||||
names[n_names].suffix = -1;
|
||||
names[n_names].offset = 0;
|
||||
|
||||
n_names++;
|
||||
}
|
||||
|
||||
static gint
|
||||
find_name (const gchar *name)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (!name)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < n_names; i++)
|
||||
{
|
||||
if (strcmp (names[i].s, name) == 0)
|
||||
return names[i].offset;
|
||||
}
|
||||
|
||||
fprintf (stderr, "BOO! %s not found\n", name);
|
||||
|
||||
return -2;
|
||||
}
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
#define POINTS_PER_INCH 72
|
||||
|
||||
static gboolean
|
||||
parse_media_size (const gchar *size,
|
||||
gdouble *width_mm,
|
||||
gdouble *height_mm)
|
||||
{
|
||||
const gchar *p;
|
||||
gchar *e;
|
||||
gdouble short_dim, long_dim;
|
||||
|
||||
p = size;
|
||||
|
||||
short_dim = g_ascii_strtod (p, &e);
|
||||
|
||||
if (p == e || *e != 'x')
|
||||
return FALSE;
|
||||
|
||||
p = e + 1; /* Skip x */
|
||||
|
||||
long_dim = g_ascii_strtod (p, &e);
|
||||
|
||||
if (p == e)
|
||||
return TRUE;
|
||||
|
||||
p = e;
|
||||
|
||||
if (strcmp (p, "in") == 0)
|
||||
{
|
||||
short_dim = short_dim * MM_PER_INCH;
|
||||
long_dim = long_dim * MM_PER_INCH;
|
||||
}
|
||||
else if (strcmp (p, "mm") != 0)
|
||||
return FALSE;
|
||||
|
||||
if (width_mm)
|
||||
*width_mm = short_dim;
|
||||
if (height_mm)
|
||||
*height_mm = long_dim;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gint i, j, offset;
|
||||
gdouble width, height;
|
||||
|
||||
names = (NameInfo *) malloc (sizeof (NameInfo) * (4 + n_infos + 2 * n_extra));
|
||||
n_names = 0;
|
||||
|
||||
/* collect names */
|
||||
for (i = 0; i < n_infos; i++)
|
||||
{
|
||||
add_name (standard_names[i].name);
|
||||
add_name (standard_names[i].display_name);
|
||||
if (standard_names[i].ppd_name)
|
||||
add_name (standard_names[i].ppd_name);
|
||||
}
|
||||
|
||||
for (i = 0; i < n_extra; i++)
|
||||
{
|
||||
add_name (extra_ppd_names[i].ppd_name);
|
||||
add_name (extra_ppd_names[i].standard_name);
|
||||
}
|
||||
|
||||
/* find suffixes and dupes */
|
||||
for (i = 0; i < n_names; i++)
|
||||
for (j = 0; j < n_names; j++)
|
||||
{
|
||||
if (i == j) continue;
|
||||
|
||||
if (names[i].len < names[j].len ||
|
||||
(names[i].len == names[j].len && j < i))
|
||||
{
|
||||
if (strcmp (names[i].s, names[j].s + names[j].len - names[i].len) == 0)
|
||||
{
|
||||
names[i].suffix = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate offsets for regular entries */
|
||||
offset = 0;
|
||||
for (i = 0; i < n_names; i++)
|
||||
{
|
||||
if (names[i].suffix == -1)
|
||||
{
|
||||
names[i].offset = offset;
|
||||
offset += names[i].len + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* calculate offsets for suffixes */
|
||||
for (i = 0; i < n_names; i++)
|
||||
{
|
||||
if (names[i].suffix != -1)
|
||||
{
|
||||
j = names[i].suffix;
|
||||
names[i].offset = names[j].offset + names[j].len - names[i].len;
|
||||
}
|
||||
}
|
||||
|
||||
printf ("/* Generated by gen-paper-names */\n\n");
|
||||
|
||||
/* write N_ marked names */
|
||||
|
||||
printf ("#if 0\n");
|
||||
for (i = 0; i < n_infos; i++)
|
||||
printf ("N_(\"%s\")\n", standard_names[i].display_name);
|
||||
printf ("#endif\n\n");
|
||||
|
||||
/* write strings */
|
||||
printf ("const char paper_names[] =");
|
||||
for (i = 0; i < n_names; i++)
|
||||
{
|
||||
if (names[i].suffix == -1)
|
||||
printf ("\n \"%s\\0\"", names[i].s);
|
||||
}
|
||||
printf (";\n\n");
|
||||
|
||||
/* dump PaperInfo array */
|
||||
printf ("typedef struct {\n"
|
||||
" int name;\n"
|
||||
" float width;\n"
|
||||
" float height;\n"
|
||||
" int display_name;\n"
|
||||
" int ppd_name;\n"
|
||||
"} PaperInfo;\n\n"
|
||||
"const PaperInfo standard_names_offsets[] = {\n");
|
||||
|
||||
for (i = 0; i < n_infos; i++)
|
||||
{
|
||||
width = height = 0.0;
|
||||
if (!parse_media_size (standard_names[i].size, &width, &height))
|
||||
printf ("failed to parse size %s\n", standard_names[i].size);
|
||||
|
||||
printf (" { %4d, %g, %g, %4d, %4d },\n",
|
||||
find_name (standard_names[i].name),
|
||||
width, height,
|
||||
find_name (standard_names[i].display_name),
|
||||
find_name (standard_names[i].ppd_name));
|
||||
}
|
||||
|
||||
printf ("};\n\n");
|
||||
|
||||
|
||||
/* dump extras */
|
||||
|
||||
printf ("const struct {\n"
|
||||
" int ppd_name;\n"
|
||||
" int standard_name;\n"
|
||||
"} extra_ppd_names_offsets[] = {\n");
|
||||
|
||||
for (i = 0; i < n_extra; i++)
|
||||
{
|
||||
printf (" { %4d, %4d },\n",
|
||||
find_name (extra_ppd_names[i].ppd_name),
|
||||
find_name (extra_ppd_names[i].standard_name));
|
||||
}
|
||||
|
||||
printf ("};\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -132,6 +132,7 @@
|
||||
#include <gtk/gtkpixmap.h>
|
||||
#include <gtk/gtkplug.h>
|
||||
#include <gtk/gtkpreview.h>
|
||||
#include <gtk/gtkprintoperation.h>
|
||||
#include <gtk/gtkprogress.h>
|
||||
#include <gtk/gtkprogressbar.h>
|
||||
#include <gtk/gtkradioaction.h>
|
||||
|
299
gtk/gtk.symbols
299
gtk/gtk.symbols
@ -2461,6 +2461,305 @@ gtk_preview_uninit
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PAGE_SETUP_H__)
|
||||
#if IN_FILE(__GTK_PAGE_SETUP_C__)
|
||||
gtk_page_setup_get_type G_GNUC_CONST
|
||||
gtk_page_setup_new
|
||||
gtk_page_setup_copy
|
||||
gtk_page_setup_get_orientation
|
||||
gtk_page_setup_set_orientation
|
||||
gtk_page_setup_get_paper_size
|
||||
gtk_page_setup_set_paper_size
|
||||
gtk_page_setup_get_top_margin
|
||||
gtk_page_setup_set_top_margin
|
||||
gtk_page_setup_get_bottom_margin
|
||||
gtk_page_setup_set_bottom_margin
|
||||
gtk_page_setup_get_left_margin
|
||||
gtk_page_setup_set_left_margin
|
||||
gtk_page_setup_get_right_margin
|
||||
gtk_page_setup_set_right_margin
|
||||
gtk_page_setup_set_paper_size_and_default_margins
|
||||
gtk_page_setup_get_paper_width
|
||||
gtk_page_setup_get_paper_height
|
||||
gtk_page_setup_get_page_width
|
||||
gtk_page_setup_get_page_height
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PAGE_SETUP_UNIX_DIALOG_H__)
|
||||
#if IN_FILE(__GTK_PAGE_SETUP_UNIX_DIALOG_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_page_setup_unix_dialog_get_type G_GNUC_CONST
|
||||
gtk_page_setup_unix_dialog_new
|
||||
gtk_page_setup_unix_dialog_set_page_setup
|
||||
gtk_page_setup_unix_dialog_get_page_setup
|
||||
gtk_page_setup_unix_dialog_set_print_settings
|
||||
gtk_page_setup_unix_dialog_get_print_settings
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PAPER_SIZE_H__)
|
||||
#if IN_FILE(__GTK_PAPER_SIZE_C__)
|
||||
gtk_paper_size_get_type G_GNUC_CONST
|
||||
gtk_paper_size_new
|
||||
gtk_paper_size_new_from_ppd
|
||||
gtk_paper_size_new_custom
|
||||
gtk_paper_size_copy
|
||||
gtk_paper_size_free
|
||||
gtk_paper_size_is_equal
|
||||
gtk_paper_size_get_name
|
||||
gtk_paper_size_get_display_name
|
||||
gtk_paper_size_get_ppd_name
|
||||
gtk_paper_size_get_width
|
||||
gtk_paper_size_get_height
|
||||
gtk_paper_size_is_custom
|
||||
gtk_paper_size_set_size
|
||||
gtk_paper_size_get_default_top_margin
|
||||
gtk_paper_size_get_default_bottom_margin
|
||||
gtk_paper_size_get_default_left_margin
|
||||
gtk_paper_size_get_default_right_margin
|
||||
gtk_paper_size_get_default
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_BACKEND_H__)
|
||||
#if IN_FILE(__GTK_PRINT_BACKEND_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_print_backend_get_type G_GNUC_CONST
|
||||
gtk_print_backend_get_printer_list
|
||||
gtk_print_backend_find_printer
|
||||
gtk_print_backend_print_stream
|
||||
gtk_print_backend_load_modules
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_CONTEXT_H__)
|
||||
#if IN_FILE(__GTK_PRINT_CONTEXT_C__)
|
||||
gtk_print_context_get_type G_GNUC_CONST
|
||||
gtk_print_context_get_cairo
|
||||
gtk_print_context_get_page_setup
|
||||
gtk_print_context_get_width
|
||||
gtk_print_context_get_height
|
||||
gtk_print_context_get_dpi_x
|
||||
gtk_print_context_get_dpi_y
|
||||
gtk_print_context_get_fontmap
|
||||
gtk_print_context_create_context
|
||||
gtk_print_context_create_layout
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINTER_H__)
|
||||
#if IN_FILE(__GTK_PRINTER_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_printer_get_type G_GNUC_CONST
|
||||
gtk_printer_new
|
||||
gtk_printer_get_backend
|
||||
gtk_printer_get_name
|
||||
gtk_printer_get_state_message
|
||||
gtk_printer_get_location
|
||||
gtk_printer_get_icon_name
|
||||
gtk_printer_get_job_count
|
||||
gtk_printer_is_active
|
||||
gtk_printer_is_virtual
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINTER_OPTION_H__)
|
||||
#if IN_FILE(__GTK_PRINTER_OPTION_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_printer_option_get_type
|
||||
gtk_printer_option_new
|
||||
gtk_printer_option_set
|
||||
gtk_printer_option_set_has_conflict
|
||||
gtk_printer_option_clear_has_conflict
|
||||
gtk_printer_option_set_boolean
|
||||
gtk_printer_option_allocate_choices
|
||||
gtk_printer_option_choices_from_array
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINTER_OPTION_SET_H__)
|
||||
#if IN_FILE(__GTK_PRINTER_OPTION_SET_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_printer_option_set_get_type G_GNUC_CONST
|
||||
gtk_printer_option_set_new
|
||||
gtk_printer_option_set_add
|
||||
gtk_printer_option_set_remove
|
||||
gtk_printer_option_set_foreach
|
||||
gtk_printer_option_set_clear_conflicts
|
||||
gtk_printer_option_set_get_groups
|
||||
gtk_printer_option_set_foreach_in_group
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINTER_OPTION_WIDGET_H__)
|
||||
#if IN_FILE(__GTK_PRINTER_OPTION_WIDGET_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_printer_option_widget_get_type G_GNUC_CONST
|
||||
gtk_printer_option_widget_new
|
||||
gtk_printer_option_widget_set_source
|
||||
gtk_printer_option_widget_has_external_label
|
||||
gtk_printer_option_widget_get_external_label
|
||||
gtk_printer_option_widget_get_value
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_JOB_H__)
|
||||
#if IN_FILE(__GTK_PRINT_JOB_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_print_job_get_type G_GNUC_CONST
|
||||
gtk_print_job_new
|
||||
gtk_print_job_get_settings
|
||||
gtk_print_job_get_printer
|
||||
gtk_print_job_get_title
|
||||
gtk_print_job_get_status
|
||||
gtk_print_job_set_source_file
|
||||
gtk_print_job_get_surface
|
||||
gtk_print_job_send
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_OPERATION_H__)
|
||||
#if IN_FILE(__GTK_PRINT_OPERATION_C__)
|
||||
gtk_print_error_quark
|
||||
gtk_print_operation_get_type G_GNUC_CONST
|
||||
gtk_print_operation_new
|
||||
gtk_print_operation_set_default_page_setup
|
||||
gtk_print_operation_get_default_page_setup
|
||||
gtk_print_operation_set_print_settings
|
||||
gtk_print_operation_get_print_settings
|
||||
gtk_print_operation_set_job_name
|
||||
gtk_print_operation_set_nr_of_pages
|
||||
gtk_print_operation_set_current_page
|
||||
gtk_print_operation_set_use_full_page
|
||||
gtk_print_operation_set_unit
|
||||
gtk_print_operation_set_show_dialog
|
||||
gtk_print_operation_set_pdf_target
|
||||
gtk_print_operation_run
|
||||
gtk_print_operation_get_status
|
||||
gtk_print_operation_get_status_string
|
||||
gtk_print_operation_is_finished
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_OPERATION_H__)
|
||||
#if IN_FILE(__GTK_PRINT_OPERATION_UNIX_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_print_run_page_setup_dialog
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_OPERATION_H__)
|
||||
#if IN_FILE(__GTK_PRINT_OPERATION_WIN32_C__)
|
||||
#ifdef G_OS_WIN32
|
||||
gtk_print_run_page_setup_dialog
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_SETTINGS_H__)
|
||||
#if IN_FILE(__GTK_PRINT_SETTINGS_C__)
|
||||
gtk_print_settings_get_type G_GNUC_CONST
|
||||
gtk_print_settings_new
|
||||
gtk_print_settings_copy
|
||||
gtk_print_settings_has_key
|
||||
gtk_print_settings_get
|
||||
gtk_print_settings_set
|
||||
gtk_print_settings_unset
|
||||
gtk_print_settings_foreach
|
||||
gtk_print_settings_get_bool
|
||||
gtk_print_settings_set_bool
|
||||
gtk_print_settings_get_double
|
||||
gtk_print_settings_get_double_with_default
|
||||
gtk_print_settings_set_double
|
||||
gtk_print_settings_get_length
|
||||
gtk_print_settings_set_length
|
||||
gtk_print_settings_get_int
|
||||
gtk_print_settings_get_int_with_default
|
||||
gtk_print_settings_get_printer
|
||||
gtk_print_settings_set_printer
|
||||
gtk_print_settings_get_orientation
|
||||
gtk_print_settings_set_orientation
|
||||
gtk_print_settings_get_paper_size
|
||||
gtk_print_settings_set_paper_size
|
||||
gtk_print_settings_get_paper_width
|
||||
gtk_print_settings_set_paper_width
|
||||
gtk_print_settings_get_paper_height
|
||||
gtk_print_settings_set_paper_height
|
||||
gtk_print_settings_get_use_color
|
||||
gtk_print_settings_set_use_color
|
||||
gtk_print_settings_get_collate
|
||||
gtk_print_settings_set_collate
|
||||
gtk_print_settings_get_reverse
|
||||
gtk_print_settings_set_reverse
|
||||
gtk_print_settings_get_duplex
|
||||
gtk_print_settings_set_duplex
|
||||
gtk_print_settings_get_quality
|
||||
gtk_print_settings_set_quality
|
||||
gtk_print_settings_get_num_copies
|
||||
gtk_print_settings_set_num_copies
|
||||
gtk_print_settings_get_number_up
|
||||
gtk_print_settings_set_number_up
|
||||
gtk_print_settings_get_resolution
|
||||
gtk_print_settings_set_resolution
|
||||
gtk_print_settings_get_scale
|
||||
gtk_print_settings_set_scale
|
||||
gtk_print_settings_get_print_to_file
|
||||
gtk_print_settings_set_print_to_file
|
||||
gtk_print_settings_get_print_pages
|
||||
gtk_print_settings_set_print_pages
|
||||
gtk_print_settings_get_page_ranges
|
||||
gtk_print_settings_set_page_ranges
|
||||
gtk_print_settings_get_page_set
|
||||
gtk_print_settings_set_page_set
|
||||
gtk_print_settings_get_default_source
|
||||
gtk_print_settings_set_default_source
|
||||
gtk_print_settings_get_media_type
|
||||
gtk_print_settings_set_media_type
|
||||
gtk_print_settings_get_dither
|
||||
gtk_print_settings_set_dither
|
||||
gtk_print_settings_get_finishings
|
||||
gtk_print_settings_set_finishings
|
||||
gtk_print_settings_get_output_bin
|
||||
gtk_print_settings_set_output_bin
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_UNIX_DIALOG_H__)
|
||||
#if IN_FILE(__GTK_PRINT_UNIX_DIALOG_C__)
|
||||
#ifdef G_OS_UNIX
|
||||
gtk_print_unix_dialog_get_type G_GNUC_CONST
|
||||
gtk_print_unix_dialog_new
|
||||
gtk_print_unix_dialog_set_page_setup
|
||||
gtk_print_unix_dialog_get_page_setup
|
||||
gtk_print_unix_dialog_set_current_page
|
||||
gtk_print_unix_dialog_get_current_page
|
||||
gtk_print_unix_dialog_set_settings
|
||||
gtk_print_unix_dialog_get_settings
|
||||
gtk_print_unix_dialog_get_selected_printer
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PRINT_WIN32_H__)
|
||||
#if IN_FILE(__GTK_PRINT_WIN32_C__)
|
||||
#ifdef G_OS_WIN32
|
||||
gtk_print_win32_devnames_free
|
||||
gtk_print_win32_devnames_from_win32
|
||||
gtk_print_win32_devnames_to_win32
|
||||
gtk_print_win32_devnames_from_printer_name
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_PROGRESS_BAR_H__)
|
||||
#if IN_FILE(__GTK_PROGRESS_BAR_C__)
|
||||
gtk_progress_bar_get_fraction
|
||||
|
@ -466,6 +466,46 @@ typedef enum
|
||||
GTK_PACK_DIRECTION_BTT
|
||||
} GtkPackDirection;
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINT_PAGES_ALL,
|
||||
GTK_PRINT_PAGES_CURRENT,
|
||||
GTK_PRINT_PAGES_RANGES
|
||||
} GtkPrintPages;
|
||||
|
||||
typedef enum {
|
||||
GTK_PAGE_SET_ALL,
|
||||
GTK_PAGE_SET_EVEN,
|
||||
GTK_PAGE_SET_ODD
|
||||
} GtkPageSet;
|
||||
|
||||
typedef enum {
|
||||
GTK_PAGE_ORIENTATION_PORTRAIT,
|
||||
GTK_PAGE_ORIENTATION_LANDSCAPE,
|
||||
GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT,
|
||||
GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE
|
||||
} GtkPageOrientation;
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINT_QUALITY_LOW,
|
||||
GTK_PRINT_QUALITY_NORMAL,
|
||||
GTK_PRINT_QUALITY_HIGH,
|
||||
GTK_PRINT_QUALITY_DRAFT
|
||||
} GtkPrintQuality;
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINT_DUPLEX_SIMPLEX,
|
||||
GTK_PRINT_DUPLEX_HORIZONTAL,
|
||||
GTK_PRINT_DUPLEX_VERTICAL
|
||||
} GtkPrintDuplex;
|
||||
|
||||
|
||||
typedef enum {
|
||||
GTK_UNIT_PIXEL,
|
||||
GTK_UNIT_POINTS,
|
||||
GTK_UNIT_INCH,
|
||||
GTK_UNIT_MM
|
||||
} GtkUnit;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_ENUMS_H__ */
|
||||
|
@ -450,6 +450,9 @@ get_default_icons (GtkIconFactory *factory)
|
||||
register_stock_icon (factory, GTK_STOCK_NETWORK);
|
||||
register_stock_icon (factory, GTK_STOCK_NEW);
|
||||
register_stock_icon (factory, GTK_STOCK_OPEN);
|
||||
register_stock_icon (factory, GTK_STOCK_ORIENTATION_PORTRAIT);
|
||||
register_stock_icon (factory, GTK_STOCK_ORIENTATION_LANDSCAPE);
|
||||
register_stock_icon (factory, GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
register_stock_icon (factory, GTK_STOCK_PASTE);
|
||||
register_stock_icon (factory, GTK_STOCK_PREFERENCES);
|
||||
register_stock_icon (factory, GTK_STOCK_PRINT);
|
||||
|
@ -78,6 +78,8 @@ VOID:OBJECT
|
||||
VOID:OBJECT,BOOLEAN
|
||||
VOID:OBJECT,BOXED,BOXED
|
||||
VOID:OBJECT,BOXED,UINT,UINT
|
||||
VOID:OBJECT,INT
|
||||
VOID:OBJECT,INT,OBJECT
|
||||
VOID:OBJECT,INT,INT
|
||||
VOID:OBJECT,INT,INT,BOXED,UINT,UINT
|
||||
VOID:OBJECT,OBJECT
|
||||
|
288
gtk/gtkpagesetup.c
Normal file
288
gtk/gtkpagesetup.c
Normal file
@ -0,0 +1,288 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkpagesetup.c: Page Setup
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkpagesetup.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
#define POINTS_PER_INCH 72
|
||||
|
||||
typedef struct _GtkPageSetupClass GtkPageSetupClass;
|
||||
|
||||
#define GTK_IS_PAGE_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PAGE_SETUP))
|
||||
#define GTK_PAGE_SETUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PAGE_SETUP, GtkPageSetupClass))
|
||||
#define GTK_PAGE_SETUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PAGE_SETUP, GtkPageSetupClass))
|
||||
|
||||
struct _GtkPageSetup
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPageOrientation orientation;
|
||||
GtkPaperSize *paper_size;
|
||||
/* These are stored in mm */
|
||||
double top_margin, bottom_margin, left_margin, right_margin;
|
||||
};
|
||||
|
||||
struct _GtkPageSetupClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkPageSetup, gtk_page_setup, G_TYPE_OBJECT)
|
||||
|
||||
static double
|
||||
to_mm (double len, GtkUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case GTK_UNIT_MM:
|
||||
return len;
|
||||
case GTK_UNIT_INCH:
|
||||
return len * MM_PER_INCH;
|
||||
default:
|
||||
case GTK_UNIT_PIXEL:
|
||||
g_warning ("Unsupported unit");
|
||||
/* Fall through */
|
||||
case GTK_UNIT_POINTS:
|
||||
return len * (MM_PER_INCH / POINTS_PER_INCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
from_mm (double len, GtkUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case GTK_UNIT_MM:
|
||||
return len;
|
||||
case GTK_UNIT_INCH:
|
||||
return len / MM_PER_INCH;
|
||||
default:
|
||||
case GTK_UNIT_PIXEL:
|
||||
g_warning ("Unsupported unit");
|
||||
/* Fall through */
|
||||
case GTK_UNIT_POINTS:
|
||||
return len / (MM_PER_INCH / POINTS_PER_INCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_page_setup_finalize (GObject *object)
|
||||
{
|
||||
GtkPageSetup *setup = GTK_PAGE_SETUP (object);
|
||||
|
||||
gtk_paper_size_free (setup->paper_size);
|
||||
|
||||
G_OBJECT_CLASS (gtk_page_setup_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_page_setup_init (GtkPageSetup *setup)
|
||||
{
|
||||
setup->paper_size = gtk_paper_size_new (NULL);
|
||||
setup->orientation = GTK_PAGE_ORIENTATION_PORTRAIT;
|
||||
setup->top_margin = gtk_paper_size_get_default_top_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->bottom_margin = gtk_paper_size_get_default_bottom_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->left_margin = gtk_paper_size_get_default_left_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->right_margin = gtk_paper_size_get_default_right_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_page_setup_class_init (GtkPageSetupClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *)class;
|
||||
|
||||
gobject_class->finalize = gtk_page_setup_finalize;
|
||||
}
|
||||
|
||||
GtkPageSetup *
|
||||
gtk_page_setup_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_PAGE_SETUP, NULL);
|
||||
}
|
||||
|
||||
GtkPageSetup *
|
||||
gtk_page_setup_copy (GtkPageSetup *other)
|
||||
{
|
||||
GtkPageSetup *copy;
|
||||
|
||||
copy = gtk_page_setup_new ();
|
||||
copy->orientation = other->orientation;
|
||||
copy->paper_size = gtk_paper_size_copy (other->paper_size);
|
||||
copy->top_margin = other->top_margin;
|
||||
copy->bottom_margin = other->bottom_margin;
|
||||
copy->left_margin = other->left_margin;
|
||||
copy->right_margin = other->right_margin;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
GtkPageOrientation
|
||||
gtk_page_setup_get_orientation (GtkPageSetup *setup)
|
||||
{
|
||||
return setup->orientation;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_orientation (GtkPageSetup *setup,
|
||||
GtkPageOrientation orientation)
|
||||
{
|
||||
setup->orientation = orientation;
|
||||
}
|
||||
|
||||
GtkPaperSize *
|
||||
gtk_page_setup_get_paper_size (GtkPageSetup *setup)
|
||||
{
|
||||
return setup->paper_size;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_paper_size (GtkPageSetup *setup,
|
||||
GtkPaperSize *size)
|
||||
{
|
||||
setup->paper_size = gtk_paper_size_copy (size);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_paper_size_and_default_margins (GtkPageSetup *setup,
|
||||
GtkPaperSize *size)
|
||||
{
|
||||
setup->paper_size = gtk_paper_size_copy (size);
|
||||
setup->top_margin = gtk_paper_size_get_default_top_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->bottom_margin = gtk_paper_size_get_default_bottom_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->left_margin = gtk_paper_size_get_default_left_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
setup->right_margin = gtk_paper_size_get_default_right_margin (setup->paper_size, GTK_UNIT_MM);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_top_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
return from_mm (setup->top_margin, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_top_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit)
|
||||
{
|
||||
setup->top_margin = to_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_bottom_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
return from_mm (setup->bottom_margin, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_bottom_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit)
|
||||
{
|
||||
setup->bottom_margin = to_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_left_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
return from_mm (setup->left_margin, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_left_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit)
|
||||
{
|
||||
setup->left_margin = to_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_right_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
return from_mm (setup->right_margin, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_page_setup_set_right_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit)
|
||||
{
|
||||
setup->right_margin = to_mm (margin, unit);
|
||||
}
|
||||
|
||||
/* These take orientation, but not margins into consideration */
|
||||
double
|
||||
gtk_page_setup_get_paper_width (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
if (setup->orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
|
||||
setup->orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
|
||||
return gtk_paper_size_get_width (setup->paper_size, unit);
|
||||
else
|
||||
return gtk_paper_size_get_height (setup->paper_size, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_paper_height (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
if (setup->orientation == GTK_PAGE_ORIENTATION_PORTRAIT ||
|
||||
setup->orientation == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT)
|
||||
return gtk_paper_size_get_height (setup->paper_size, unit);
|
||||
else
|
||||
return gtk_paper_size_get_width (setup->paper_size, unit);
|
||||
}
|
||||
|
||||
/* These take orientation, and margins into consideration */
|
||||
double
|
||||
gtk_page_setup_get_page_width (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
double width;
|
||||
|
||||
width = gtk_page_setup_get_paper_width (setup, GTK_UNIT_MM);
|
||||
width -= setup->left_margin + setup->right_margin;
|
||||
|
||||
return from_mm (width, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_page_setup_get_page_height (GtkPageSetup *setup,
|
||||
GtkUnit unit)
|
||||
{
|
||||
double height;
|
||||
|
||||
height = gtk_page_setup_get_paper_height (setup, GTK_UNIT_MM);
|
||||
height -= setup->top_margin + setup->bottom_margin;
|
||||
|
||||
return from_mm (height, unit);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PAGE_SETUP_C__
|
||||
#include "gtkaliasdef.c"
|
85
gtk/gtkpagesetup.h
Normal file
85
gtk/gtkpagesetup.h
Normal file
@ -0,0 +1,85 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkpagesetup.h: Page Setup
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PAGE_SETUP_H__
|
||||
#define __GTK_PAGE_SETUP_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkenums.h"
|
||||
#include "gtkpapersize.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkPageSetup GtkPageSetup;
|
||||
|
||||
#define GTK_TYPE_PAGE_SETUP (gtk_page_setup_get_type ())
|
||||
#define GTK_PAGE_SETUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PAGE_SETUP, GtkPageSetup))
|
||||
#define GTK_IS_PAGE_SETUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PAGE_SETUP))
|
||||
|
||||
GType gtk_page_setup_get_type (void) G_GNUC_CONST;
|
||||
GtkPageSetup * gtk_page_setup_new (void);
|
||||
GtkPageSetup * gtk_page_setup_copy (GtkPageSetup *other);
|
||||
GtkPageOrientation gtk_page_setup_get_orientation (GtkPageSetup *setup);
|
||||
void gtk_page_setup_set_orientation (GtkPageSetup *setup,
|
||||
GtkPageOrientation orientation);
|
||||
GtkPaperSize * gtk_page_setup_get_paper_size (GtkPageSetup *setup);
|
||||
void gtk_page_setup_set_paper_size (GtkPageSetup *setup,
|
||||
GtkPaperSize *size);
|
||||
double gtk_page_setup_get_top_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
void gtk_page_setup_set_top_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit);
|
||||
double gtk_page_setup_get_bottom_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
void gtk_page_setup_set_bottom_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit);
|
||||
double gtk_page_setup_get_left_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
void gtk_page_setup_set_left_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit);
|
||||
double gtk_page_setup_get_right_margin (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
void gtk_page_setup_set_right_margin (GtkPageSetup *setup,
|
||||
double margin,
|
||||
GtkUnit unit);
|
||||
|
||||
void gtk_page_setup_set_paper_size_and_default_margins (GtkPageSetup *setup,
|
||||
GtkPaperSize *size);
|
||||
|
||||
/* These take orientation, but not margins into consideration */
|
||||
double gtk_page_setup_get_paper_width (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
double gtk_page_setup_get_paper_height (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
|
||||
|
||||
/* These take orientation, and margins into consideration */
|
||||
double gtk_page_setup_get_page_width (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
double gtk_page_setup_get_page_height (GtkPageSetup *setup,
|
||||
GtkUnit unit);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PAGE_SETUP_H__ */
|
2016
gtk/gtkpagesetupunixdialog.c
Normal file
2016
gtk/gtkpagesetupunixdialog.c
Normal file
File diff suppressed because it is too large
Load Diff
73
gtk/gtkpagesetupunixdialog.h
Normal file
73
gtk/gtkpagesetupunixdialog.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* GtkPageSetupUnixDialog
|
||||
* Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PAGE_SETUP_UNIX_DIALOG_H__
|
||||
#define __GTK_PAGE_SETUP_UNIX_DIALOG_H__
|
||||
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkpagesetup.h"
|
||||
#include "gtkprintsettings.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PAGE_SETUP_UNIX_DIALOG (gtk_page_setup_unix_dialog_get_type ())
|
||||
#define GTK_PAGE_SETUP_UNIX_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PAGE_SETUP_UNIX_DIALOG, GtkPageSetupUnixDialog))
|
||||
#define GTK_PAGE_SETUP_UNIX_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PAGE_SETUP_UNIX_DIALOG, GtkPageSetupUnixDialogClass))
|
||||
#define GTK_IS_PAGE_SETUP_UNIX_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PAGE_SETUP_UNIX_DIALOG))
|
||||
#define GTK_IS_PAGE_SETUP_UNIX_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PAGE_SETUP_UNIX_DIALOG))
|
||||
#define GTK_PAGE_SETUP_UNIX_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PAGE_SETUP_UNIX_DIALOG, GtkPageSetupUnixDialogClass))
|
||||
|
||||
|
||||
typedef struct _GtkPageSetupUnixDialog GtkPageSetupUnixDialog;
|
||||
typedef struct _GtkPageSetupUnixDialogClass GtkPageSetupUnixDialogClass;
|
||||
typedef struct GtkPageSetupUnixDialogPrivate GtkPageSetupUnixDialogPrivate;
|
||||
|
||||
struct _GtkPageSetupUnixDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
|
||||
GtkPageSetupUnixDialogPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkPageSetupUnixDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
GType gtk_page_setup_unix_dialog_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gtk_page_setup_unix_dialog_new (const gchar *title,
|
||||
GtkWindow *parent);
|
||||
void gtk_page_setup_unix_dialog_set_page_setup (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPageSetup *page_setup);
|
||||
GtkPageSetup * gtk_page_setup_unix_dialog_get_page_setup (GtkPageSetupUnixDialog *dialog);
|
||||
void gtk_page_setup_unix_dialog_set_print_settings (GtkPageSetupUnixDialog *dialog,
|
||||
GtkPrintSettings *print_settings);
|
||||
GtkPrintSettings *gtk_page_setup_unix_dialog_get_print_settings (GtkPageSetupUnixDialog *dialog);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PAGE_SETUP_UNIX_DIALOG_H__ */
|
551
gtk/gtkpapersize.c
Normal file
551
gtk/gtkpapersize.c
Normal file
@ -0,0 +1,551 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkpapersize.c: Paper Size
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; 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 <stdlib.h>
|
||||
#include <locale.h>
|
||||
#if defined(HAVE__NL_PAPER_HEIGHT) && defined(HAVE__NL_PAPER_WIDTH)
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#include "gtkpapersize.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
#define POINTS_PER_INCH 72
|
||||
|
||||
#include "paper_names_offsets.c"
|
||||
|
||||
struct _GtkPaperSize
|
||||
{
|
||||
const PaperInfo *info;
|
||||
|
||||
/* If these are not set we fall back to info */
|
||||
char *name;
|
||||
char *display_name;
|
||||
char *ppd_name;
|
||||
|
||||
double width, height; /* Stored in mm */
|
||||
gboolean is_custom;
|
||||
};
|
||||
|
||||
GType
|
||||
gtk_paper_size_get_type (void)
|
||||
{
|
||||
static GType our_type = 0;
|
||||
|
||||
if (our_type == 0)
|
||||
our_type = g_boxed_type_register_static ("GtkPaperSize",
|
||||
(GBoxedCopyFunc)gtk_paper_size_copy,
|
||||
(GBoxedFreeFunc)gtk_paper_size_free);
|
||||
return our_type;
|
||||
}
|
||||
|
||||
static PaperInfo *
|
||||
lookup_paper_info (const char *name)
|
||||
{
|
||||
int lower = 0;
|
||||
int upper = G_N_ELEMENTS (standard_names_offsets) - 1;
|
||||
int mid;
|
||||
int cmp;
|
||||
|
||||
do
|
||||
{
|
||||
mid = (lower + upper) / 2;
|
||||
cmp = strcmp (name, paper_names + standard_names_offsets[mid].name);
|
||||
if (cmp < 0)
|
||||
upper = mid - 1;
|
||||
else if (cmp > 0)
|
||||
lower = mid + 1;
|
||||
else
|
||||
return &standard_names_offsets[mid];
|
||||
}
|
||||
while (lower <= upper);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static double
|
||||
to_mm (double len, GtkUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case GTK_UNIT_MM:
|
||||
return len;
|
||||
case GTK_UNIT_INCH:
|
||||
return len * MM_PER_INCH;
|
||||
default:
|
||||
case GTK_UNIT_PIXEL:
|
||||
g_warning ("Unsupported unit");
|
||||
/* Fall through */
|
||||
case GTK_UNIT_POINTS:
|
||||
return len * (MM_PER_INCH / POINTS_PER_INCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
from_mm (double len, GtkUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case GTK_UNIT_MM:
|
||||
return len;
|
||||
case GTK_UNIT_INCH:
|
||||
return len / MM_PER_INCH;
|
||||
default:
|
||||
case GTK_UNIT_PIXEL:
|
||||
g_warning ("Unsupported unit");
|
||||
/* Fall through */
|
||||
case GTK_UNIT_POINTS:
|
||||
return len / (MM_PER_INCH / POINTS_PER_INCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_media_size (const char *size,
|
||||
double *width_mm, double *height_mm)
|
||||
{
|
||||
const char *p;
|
||||
char *e;
|
||||
double short_dim, long_dim;
|
||||
|
||||
p = size;
|
||||
|
||||
short_dim = g_ascii_strtod (p, &e);
|
||||
|
||||
if (p == e || *e != 'x')
|
||||
return FALSE;
|
||||
|
||||
p = e + 1; /* Skip x */
|
||||
|
||||
long_dim = g_ascii_strtod (p, &e);
|
||||
|
||||
if (p == e)
|
||||
return FALSE;
|
||||
|
||||
p = e;
|
||||
|
||||
if (strcmp (p, "in") == 0)
|
||||
{
|
||||
short_dim = short_dim * MM_PER_INCH;
|
||||
long_dim = long_dim * MM_PER_INCH;
|
||||
}
|
||||
else if (strcmp (p, "mm") != 0)
|
||||
return FALSE;
|
||||
|
||||
if (width_mm)
|
||||
*width_mm = short_dim;
|
||||
if (height_mm)
|
||||
*height_mm = long_dim;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_full_media_size_name (const char *full_name,
|
||||
char **name,
|
||||
double *width_mm, double *height_mm)
|
||||
{
|
||||
const char *p;
|
||||
const char *end_of_name;
|
||||
|
||||
/* From the spec:
|
||||
media-size-self-describing-name =
|
||||
( class-in "_" size-name "_" short-dim "x" long-dim "in" ) |
|
||||
( class-mm "_" size-name "_" short-dim "x" long-dim "mm" )
|
||||
class-in = "custom" | "na" | "asme" | "roc" | "oe"
|
||||
class-mm = "custom" | "iso" | "jis" | "jpn" | "prc" | "om"
|
||||
size-name = ( lowalpha | digit ) *( lowalpha | digit | "-" )
|
||||
short-dim = dim
|
||||
long-dim = dim
|
||||
dim = integer-part [fraction-part] | "0" fraction-part
|
||||
integer-part = non-zero-digit *digit
|
||||
fraction-part = "." *digit non-zero-digit
|
||||
lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" |
|
||||
"j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" |
|
||||
"s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
|
||||
non-zero-digit = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
||||
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
||||
*/
|
||||
|
||||
p = strchr (full_name, '_');
|
||||
if (p == NULL)
|
||||
return FALSE;
|
||||
|
||||
p++; /* Skip _ */
|
||||
|
||||
p = strchr (p, '_');
|
||||
if (p == NULL)
|
||||
return FALSE;
|
||||
|
||||
end_of_name = p;
|
||||
|
||||
p++; /* Skip _ */
|
||||
|
||||
if (!parse_media_size (p, width_mm, height_mm))
|
||||
return FALSE;
|
||||
|
||||
if (name)
|
||||
*name = g_strndup (full_name, end_of_name - full_name);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkPaperSize *
|
||||
gtk_paper_size_new_from_info (const PaperInfo *info)
|
||||
{
|
||||
GtkPaperSize *size;
|
||||
|
||||
size = g_new0 (GtkPaperSize, 1);
|
||||
size->info = info;
|
||||
size->width = info->width;
|
||||
size->height = info->height;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
GtkPaperSize *
|
||||
gtk_paper_size_new (const char *name)
|
||||
{
|
||||
GtkPaperSize *size;
|
||||
char *short_name;
|
||||
double width, height;
|
||||
PaperInfo *info;
|
||||
|
||||
if (name == NULL)
|
||||
name = gtk_paper_size_get_default ();
|
||||
|
||||
if (parse_full_media_size_name (name, &short_name, &width, &height))
|
||||
{
|
||||
size = g_new0 (GtkPaperSize, 1);
|
||||
|
||||
size->width = width;
|
||||
size->height = height;
|
||||
size->name = short_name;
|
||||
size->display_name = g_strdup (short_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
info = lookup_paper_info (name);
|
||||
if (info != NULL)
|
||||
size = gtk_paper_size_new_from_info (info);
|
||||
else
|
||||
{
|
||||
g_warning ("Unknown paper size %s\n", name);
|
||||
size = g_new0 (GtkPaperSize, 1);
|
||||
size->name = g_strdup (name);
|
||||
size->display_name = g_strdup (name);
|
||||
/* Default to A4 size */
|
||||
size->width = 210;
|
||||
size->height = 297;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
GtkPaperSize *
|
||||
gtk_paper_size_new_from_ppd (const char *ppd_name,
|
||||
const char *ppd_display_name,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
char *name;
|
||||
const char *lookup_ppd_name;
|
||||
char *freeme;
|
||||
GtkPaperSize *size;
|
||||
int i;
|
||||
|
||||
lookup_ppd_name = ppd_name;
|
||||
|
||||
freeme = NULL;
|
||||
/* Strip out Traverse suffix in matching. */
|
||||
if (g_str_has_suffix (ppd_name, ".Transverse"))
|
||||
{
|
||||
lookup_ppd_name = freeme =
|
||||
g_strndup (ppd_name, strlen (ppd_name) - strlen (".Transverse"));
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(standard_names_offsets); i++)
|
||||
{
|
||||
if (standard_names_offsets[i].ppd_name != -1 &&
|
||||
strcmp (paper_names + standard_names_offsets[i].ppd_name, lookup_ppd_name) == 0)
|
||||
{
|
||||
size = gtk_paper_size_new_from_info (&standard_names_offsets[i]);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(extra_ppd_names_offsets); i++)
|
||||
{
|
||||
if (strcmp (paper_names + extra_ppd_names_offsets[i].ppd_name, lookup_ppd_name) == 0)
|
||||
{
|
||||
size = gtk_paper_size_new (paper_names + extra_ppd_names_offsets[i].standard_name);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
name = g_strdup_printf ("ppd_%s", ppd_name);
|
||||
size = gtk_paper_size_new_custom (name, ppd_display_name, width, height, GTK_UNIT_POINTS);
|
||||
g_free (name);
|
||||
|
||||
out:
|
||||
|
||||
if (size->info == NULL ||
|
||||
size->info->ppd_name == -1 ||
|
||||
strcmp (paper_names + size->info->ppd_name, ppd_name) != 0)
|
||||
size->ppd_name = g_strdup (ppd_name);
|
||||
|
||||
g_free (freeme);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
GtkPaperSize *
|
||||
gtk_paper_size_new_custom (const char *name,
|
||||
const char *display_name,
|
||||
double width,
|
||||
double height,
|
||||
GtkUnit unit)
|
||||
{
|
||||
GtkPaperSize *size;
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (unit != GTK_UNIT_PIXEL, NULL);
|
||||
|
||||
size = g_new0 (GtkPaperSize, 1);
|
||||
|
||||
size->name = g_strdup (name);
|
||||
size->display_name = g_strdup (display_name);
|
||||
size->is_custom = TRUE;
|
||||
|
||||
size->width = to_mm (width, unit);
|
||||
size->height = to_mm (height, unit);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
GtkPaperSize *
|
||||
gtk_paper_size_copy (GtkPaperSize *other)
|
||||
{
|
||||
GtkPaperSize *size;
|
||||
|
||||
size = g_new0 (GtkPaperSize, 1);
|
||||
|
||||
size->info = other->info;
|
||||
if (other->name)
|
||||
size->name = g_strdup (other->name);
|
||||
if (other->display_name)
|
||||
size->display_name = g_strdup (other->display_name);
|
||||
if (other->ppd_name)
|
||||
size->ppd_name = g_strdup (other->ppd_name);
|
||||
|
||||
size->width = other->width;
|
||||
size->height = other->height;
|
||||
size->is_custom = other->is_custom;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_paper_size_free (GtkPaperSize *size)
|
||||
{
|
||||
g_free (size->name);
|
||||
g_free (size->display_name);
|
||||
g_free (size->ppd_name);
|
||||
g_free (size);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_paper_size_is_equal (GtkPaperSize *size1,
|
||||
GtkPaperSize *size2)
|
||||
{
|
||||
if (size1->info != NULL && size2->info != NULL)
|
||||
return size1->info == size2->info;
|
||||
|
||||
return strcmp (gtk_paper_size_get_name (size1),
|
||||
gtk_paper_size_get_name (size2)) == 0;
|
||||
}
|
||||
|
||||
G_CONST_RETURN char *
|
||||
gtk_paper_size_get_name (GtkPaperSize *size)
|
||||
{
|
||||
if (size->name)
|
||||
return size->name;
|
||||
g_assert (size->info != NULL);
|
||||
return paper_names + size->info->name;
|
||||
}
|
||||
|
||||
G_CONST_RETURN char *
|
||||
gtk_paper_size_get_display_name (GtkPaperSize *size)
|
||||
{
|
||||
if (size->display_name)
|
||||
return size->display_name;
|
||||
g_assert (size->info != NULL);
|
||||
return gettext (paper_names + size->info->display_name);
|
||||
}
|
||||
|
||||
G_CONST_RETURN char *
|
||||
gtk_paper_size_get_ppd_name (GtkPaperSize *size)
|
||||
{
|
||||
if (size->ppd_name)
|
||||
return size->ppd_name;
|
||||
if (size->info)
|
||||
return paper_names + size->info->ppd_name;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double
|
||||
gtk_paper_size_get_width (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
return from_mm (size->width, unit);
|
||||
}
|
||||
double
|
||||
gtk_paper_size_get_height (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
return from_mm (size->height, unit);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_paper_size_is_custom (GtkPaperSize *size)
|
||||
{
|
||||
return size->is_custom;
|
||||
}
|
||||
|
||||
/* Only for custom sizes: */
|
||||
void
|
||||
gtk_paper_size_set_size (GtkPaperSize *size, double width, double height, GtkUnit unit)
|
||||
{
|
||||
g_return_if_fail (size != NULL);
|
||||
g_return_if_fail (size->is_custom);
|
||||
|
||||
size->width = to_mm (width, unit);
|
||||
size->height = to_mm (height, unit);
|
||||
}
|
||||
|
||||
#define NL_PAPER_GET(x) \
|
||||
((union { char *string; unsigned int word; })nl_langinfo(x)).word
|
||||
|
||||
G_CONST_RETURN char *
|
||||
gtk_paper_size_get_default (void)
|
||||
{
|
||||
char *locale, *freeme = NULL;
|
||||
const char *paper_size;
|
||||
|
||||
#if defined(HAVE__NL_PAPER_HEIGHT) && defined(HAVE__NL_PAPER_WIDTH)
|
||||
{
|
||||
int width = NL_PAPER_GET (_NL_PAPER_WIDTH);
|
||||
int height = NL_PAPER_GET (_NL_PAPER_HEIGHT);
|
||||
|
||||
if (width == 210 && height == 297)
|
||||
return GTK_PAPER_NAME_A4;
|
||||
|
||||
if (width == 216 && height == 279)
|
||||
return GTK_PAPER_NAME_LETTER;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
freeme = locale = g_win32_getlocale ();
|
||||
#elif defined(LC_PAPER)
|
||||
locale = setlocale(LC_PAPER, NULL);
|
||||
#else
|
||||
locale = setlocale(LC_MESSAGES, NULL);
|
||||
#endif
|
||||
|
||||
if (!locale)
|
||||
return GTK_PAPER_NAME_A4;
|
||||
|
||||
if (g_str_has_prefix (locale, "en_CA") ||
|
||||
g_str_has_prefix (locale, "en_US") ||
|
||||
g_str_has_prefix (locale, "es_PR") ||
|
||||
g_str_has_prefix (locale, "es_US"))
|
||||
paper_size = GTK_PAPER_NAME_LETTER;
|
||||
else
|
||||
paper_size = GTK_PAPER_NAME_A4;
|
||||
|
||||
g_free (freeme);
|
||||
return paper_size;
|
||||
}
|
||||
|
||||
/* These get the default margins used for the paper size. Its
|
||||
* larger than most printers margins, so that it will be within
|
||||
* the imageble area on any printer.
|
||||
*
|
||||
* I've taken the actual values used from the OSX page setup dialog.
|
||||
* I'm not sure exactly where they got these values for, but might
|
||||
* correspond to this (from ghostscript docs):
|
||||
*
|
||||
* All DeskJets have 0.5 inches (1.27cm) of unprintable bottom margin,
|
||||
* due to the mechanical arrangement used to grab the paper. Side margins
|
||||
* are approximately 0.25 inches (0.64cm) for U.S. letter paper, and 0.15
|
||||
* inches (0.38cm) for A4.
|
||||
*/
|
||||
|
||||
double
|
||||
gtk_paper_size_get_default_top_margin (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
double margin;
|
||||
|
||||
margin = to_mm (0.25, GTK_UNIT_INCH);
|
||||
return from_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
double margin;
|
||||
const char *name;
|
||||
|
||||
margin = to_mm (0.25, GTK_UNIT_INCH);
|
||||
|
||||
name = gtk_paper_size_get_name (size);
|
||||
if (strcmp (name, "na_letter") == 0 ||
|
||||
strcmp (name, "na_legal") == 0 ||
|
||||
strcmp (name, "iso_a4") == 0)
|
||||
margin = to_mm (0.56, GTK_UNIT_INCH);
|
||||
|
||||
return from_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_paper_size_get_default_left_margin (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
double margin;
|
||||
|
||||
margin = to_mm (0.25, GTK_UNIT_INCH);
|
||||
return from_mm (margin, unit);
|
||||
}
|
||||
|
||||
double
|
||||
gtk_paper_size_get_default_right_margin (GtkPaperSize *size, GtkUnit unit)
|
||||
{
|
||||
double margin;
|
||||
|
||||
margin = to_mm (0.25, GTK_UNIT_INCH);
|
||||
return from_mm (margin, unit);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PAPER_SIZE_C__
|
||||
#include "gtkaliasdef.c"
|
88
gtk/gtkpapersize.h
Normal file
88
gtk/gtkpapersize.h
Normal file
@ -0,0 +1,88 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkpapersize.h: Paper Size
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PAPER_SIZE_H__
|
||||
#define __GTK_PAPER_SIZE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkenums.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkPaperSize GtkPaperSize;
|
||||
|
||||
#define GTK_TYPE_PAPER_SIZE (gtk_paper_size_get_type ())
|
||||
|
||||
/* Common names, from PWG 5101.1-2002 PWG: Standard for Media Standardized Names */
|
||||
#define GTK_PAPER_NAME_A3 "iso_a3"
|
||||
#define GTK_PAPER_NAME_A4 "iso_a4"
|
||||
#define GTK_PAPER_NAME_A5 "iso_a5"
|
||||
#define GTK_PAPER_NAME_B5 "iso_b5"
|
||||
#define GTK_PAPER_NAME_LETTER "na_letter"
|
||||
#define GTK_PAPER_NAME_EXECUTIVE "na_executive"
|
||||
#define GTK_PAPER_NAME_LEGAL "na_legal"
|
||||
|
||||
GType gtk_paper_size_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkPaperSize *gtk_paper_size_new (const char *name);
|
||||
GtkPaperSize *gtk_paper_size_new_from_ppd (const char *ppd_name,
|
||||
const char *ppd_display_name,
|
||||
double width,
|
||||
double height);
|
||||
GtkPaperSize *gtk_paper_size_new_custom (const char *name,
|
||||
const char *display_name,
|
||||
double width,
|
||||
double height,
|
||||
GtkUnit unit);
|
||||
GtkPaperSize *gtk_paper_size_copy (GtkPaperSize *other);
|
||||
void gtk_paper_size_free (GtkPaperSize *size);
|
||||
gboolean gtk_paper_size_is_equal (GtkPaperSize *size1,
|
||||
GtkPaperSize *size2);
|
||||
|
||||
|
||||
/* The width is always the shortest side, measure in mm */
|
||||
G_CONST_RETURN char * gtk_paper_size_get_name (GtkPaperSize *size);
|
||||
G_CONST_RETURN char * gtk_paper_size_get_display_name (GtkPaperSize *size);
|
||||
G_CONST_RETURN char * gtk_paper_size_get_ppd_name (GtkPaperSize *size);
|
||||
|
||||
double gtk_paper_size_get_width (GtkPaperSize *size, GtkUnit unit);
|
||||
double gtk_paper_size_get_height (GtkPaperSize *size, GtkUnit unit);
|
||||
gboolean gtk_paper_size_is_custom (GtkPaperSize *size);
|
||||
|
||||
/* Only for custom sizes: */
|
||||
void gtk_paper_size_set_size (GtkPaperSize *size,
|
||||
double width,
|
||||
double height,
|
||||
GtkUnit unit);
|
||||
|
||||
double gtk_paper_size_get_default_top_margin (GtkPaperSize *size,
|
||||
GtkUnit unit);
|
||||
double gtk_paper_size_get_default_bottom_margin (GtkPaperSize *size,
|
||||
GtkUnit unit);
|
||||
double gtk_paper_size_get_default_left_margin (GtkPaperSize *size,
|
||||
GtkUnit unit);
|
||||
double gtk_paper_size_get_default_right_margin (GtkPaperSize *size,
|
||||
GtkUnit unit);
|
||||
|
||||
G_CONST_RETURN char * gtk_paper_size_get_default (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PAPER_SIZE_H__ */
|
111
gtk/gtkprint-win32.c
Normal file
111
gtk/gtkprint-win32.c
Normal file
@ -0,0 +1,111 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintoperation.c: Print Operation
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#define WINVER _WIN32_WINNT
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkprint-win32.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
void
|
||||
gtk_print_win32_devnames_free (GtkPrintWin32Devnames *devnames)
|
||||
{
|
||||
g_free (devnames->driver);
|
||||
g_free (devnames->device);
|
||||
g_free (devnames->output);
|
||||
g_free (devnames);
|
||||
}
|
||||
|
||||
GtkPrintWin32Devnames *
|
||||
gtk_print_win32_devnames_from_win32 (HGLOBAL global)
|
||||
{
|
||||
LPDEVNAMES win = GlobalLock (global);
|
||||
gunichar2 *data = (gunichar2 *)win;
|
||||
GtkPrintWin32Devnames *devnames = g_new (GtkPrintWin32Devnames, 1);
|
||||
|
||||
devnames->driver = g_utf16_to_utf8 (data + win->wDriverOffset,
|
||||
-1, NULL, NULL, NULL);
|
||||
devnames->device = g_utf16_to_utf8 (data + win->wDeviceOffset,
|
||||
-1, NULL, NULL, NULL);
|
||||
devnames->output = g_utf16_to_utf8 (data + win->wOutputOffset,
|
||||
-1, NULL, NULL, NULL);
|
||||
devnames->flags = win->wDefault;
|
||||
|
||||
GlobalUnlock (global);
|
||||
|
||||
return devnames;
|
||||
}
|
||||
|
||||
HGLOBAL
|
||||
gtk_print_win32_devnames_to_win32 (const GtkPrintWin32Devnames *devnames)
|
||||
{
|
||||
HGLOBAL global;
|
||||
LPDEVNAMES windevnames;
|
||||
gunichar2 *data;
|
||||
gunichar2 *driver, *device, *output;
|
||||
glong driver_len, device_len, output_len;
|
||||
int i;
|
||||
|
||||
driver = g_utf8_to_utf16 (devnames->driver, -1, NULL, &driver_len, NULL);
|
||||
device = g_utf8_to_utf16 (devnames->device, -1, NULL, &device_len, NULL);
|
||||
output = g_utf8_to_utf16 (devnames->output, -1, NULL, &output_len, NULL);
|
||||
|
||||
global = GlobalAlloc (GMEM_MOVEABLE,
|
||||
sizeof (DEVNAMES) +
|
||||
(driver_len + 1) * 2 +
|
||||
(device_len + 1) * 2 +
|
||||
(output_len + 1) * 2);
|
||||
|
||||
windevnames = GlobalLock (global);
|
||||
data = (gunichar2 *)windevnames;
|
||||
i = sizeof(DEVNAMES) / sizeof (gunichar2);
|
||||
|
||||
windevnames->wDriverOffset = i;
|
||||
memcpy (data + i, driver, (driver_len + 1) * sizeof (gunichar2));
|
||||
i += driver_len + 1;
|
||||
windevnames->wDeviceOffset = i;
|
||||
memcpy (data + i, device, (device_len + 1) * sizeof (gunichar2));
|
||||
i += device_len + 1;
|
||||
windevnames->wOutputOffset = i;
|
||||
memcpy (data + i, output, (output_len + 1) * sizeof (gunichar2));
|
||||
i += output_len + 1;
|
||||
windevnames->wDefault = devnames->flags;
|
||||
GlobalUnlock (global);
|
||||
|
||||
g_free (driver);
|
||||
g_free (device);
|
||||
g_free (output);
|
||||
|
||||
return global;
|
||||
}
|
||||
|
||||
HGLOBAL
|
||||
gtk_print_win32_devnames_from_printer_name (const char *printer)
|
||||
{
|
||||
const GtkPrintWin32Devnames devnames = { "", (char *)printer, "", 0 };
|
||||
return gtk_print_win32_devnames_to_win32 (&devnames);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PRINT_WIN32_C__
|
||||
#include "gtkaliasdef.c"
|
60
gtk/gtkprint-win32.h
Normal file
60
gtk/gtkprint-win32.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprint-win32.h: Win32 Print utils
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_WIN32_H__
|
||||
#define __GTK_PRINT_WIN32_H__
|
||||
|
||||
#include "win32/gdkwin32.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#ifndef START_PAGE_GENERAL
|
||||
#define START_PAGE_GENERAL 0xffffffff
|
||||
#endif
|
||||
|
||||
#ifndef PD_RESULT_CANCEL
|
||||
#define PD_RESULT_CANCEL 0
|
||||
#define PD_RESULT_PRINT 1
|
||||
#define PD_RESULT_APPLY 2
|
||||
#endif
|
||||
|
||||
#ifndef PD_NOCURRENTPAGE
|
||||
#define PD_NOCURRENTPAGE 0x00800000
|
||||
#endif
|
||||
|
||||
#ifndef PD_CURRENTPAGE
|
||||
#define PD_CURRENTPAGE 0x00400000
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
char *driver;
|
||||
char *device;
|
||||
char *output;
|
||||
int flags;
|
||||
} GtkPrintWin32Devnames;
|
||||
|
||||
void gtk_print_win32_devnames_free (GtkPrintWin32Devnames *devnames);
|
||||
GtkPrintWin32Devnames *gtk_print_win32_devnames_from_win32 (HGLOBAL global);
|
||||
HGLOBAL gtk_print_win32_devnames_to_win32 (const GtkPrintWin32Devnames *devnames);
|
||||
HGLOBAL gtk_print_win32_devnames_from_printer_name (const char *printer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_WIN32_H__ */
|
379
gtk/gtkprintbackend.c
Normal file
379
gtk/gtkprintbackend.c
Normal file
@ -0,0 +1,379 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackend.h: Abstract printer backend interfaces
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; 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 <gmodule.h>
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkmodules.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkprintbackend.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
static void gtk_print_backend_base_init (gpointer g_class);
|
||||
|
||||
GQuark
|
||||
gtk_print_backend_error_quark (void)
|
||||
{
|
||||
static GQuark quark = 0;
|
||||
if (quark == 0)
|
||||
quark = g_quark_from_static_string ("gtk-print-backend-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* GtkPrintBackendModule modules *
|
||||
*****************************************/
|
||||
|
||||
typedef struct _GtkPrintBackendModule GtkPrintBackendModule;
|
||||
typedef struct _GtkPrintBackendModuleClass GtkPrintBackendModuleClass;
|
||||
|
||||
struct _GtkPrintBackendModule
|
||||
{
|
||||
GTypeModule parent_instance;
|
||||
|
||||
GModule *library;
|
||||
|
||||
void (*init) (GTypeModule *module);
|
||||
void (*exit) (void);
|
||||
GtkPrintBackend* (*create) (void);
|
||||
|
||||
gchar *path;
|
||||
};
|
||||
|
||||
struct _GtkPrintBackendModuleClass
|
||||
{
|
||||
GTypeModuleClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkPrintBackendModule, _gtk_print_backend_module, G_TYPE_TYPE_MODULE);
|
||||
#define GTK_TYPE_PRINT_BACKEND_MODULE (_gtk_print_backend_module_get_type ())
|
||||
#define GTK_PRINT_BACKEND_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), GTK_TYPE_PRINT_BACKEND_MODULE, GtkPrintBackendModule))
|
||||
|
||||
static GSList *loaded_backends;
|
||||
|
||||
static gboolean
|
||||
gtk_print_backend_module_load (GTypeModule *module)
|
||||
{
|
||||
GtkPrintBackendModule *pb_module = GTK_PRINT_BACKEND_MODULE (module);
|
||||
gpointer initp, exitp, createp;
|
||||
|
||||
pb_module->library = g_module_open (pb_module->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
|
||||
if (!pb_module->library)
|
||||
{
|
||||
g_warning (g_module_error());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* extract symbols from the lib */
|
||||
if (!g_module_symbol (pb_module->library, "pb_module_init",
|
||||
&initp) ||
|
||||
!g_module_symbol (pb_module->library, "pb_module_exit",
|
||||
&exitp) ||
|
||||
!g_module_symbol (pb_module->library, "pb_module_create",
|
||||
&createp))
|
||||
{
|
||||
g_warning (g_module_error());
|
||||
g_module_close (pb_module->library);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pb_module->init = initp;
|
||||
pb_module->exit = exitp;
|
||||
pb_module->create = createp;
|
||||
|
||||
/* call the filesystems's init function to let it */
|
||||
/* setup anything it needs to set up. */
|
||||
pb_module->init (module);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_module_unload (GTypeModule *module)
|
||||
{
|
||||
GtkPrintBackendModule *pb_module = GTK_PRINT_BACKEND_MODULE (module);
|
||||
|
||||
pb_module->exit();
|
||||
|
||||
g_module_close (pb_module->library);
|
||||
pb_module->library = NULL;
|
||||
|
||||
pb_module->init = NULL;
|
||||
pb_module->exit = NULL;
|
||||
pb_module->create = NULL;
|
||||
}
|
||||
|
||||
/* This only will ever be called if an error occurs during
|
||||
* initialization
|
||||
*/
|
||||
static void
|
||||
gtk_print_backend_module_finalize (GObject *object)
|
||||
{
|
||||
GtkPrintBackendModule *module = GTK_PRINT_BACKEND_MODULE (object);
|
||||
|
||||
g_free (module->path);
|
||||
|
||||
G_OBJECT_CLASS (_gtk_print_backend_module_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_print_backend_module_class_init (GtkPrintBackendModuleClass *class)
|
||||
{
|
||||
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
module_class->load = gtk_print_backend_module_load;
|
||||
module_class->unload = gtk_print_backend_module_unload;
|
||||
|
||||
gobject_class->finalize = gtk_print_backend_module_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_print_backend_module_init (GtkPrintBackendModule *pb_module)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkPrintBackend *
|
||||
_gtk_print_backend_module_create (GtkPrintBackendModule *pb_module)
|
||||
{
|
||||
GtkPrintBackend *pb;
|
||||
|
||||
if (g_type_module_use (G_TYPE_MODULE (pb_module)))
|
||||
{
|
||||
pb = pb_module->create ();
|
||||
g_type_module_unuse (G_TYPE_MODULE (pb_module));
|
||||
return pb;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GtkPrintBackend *
|
||||
_gtk_print_backend_create (const char *backend_name)
|
||||
{
|
||||
GSList *l;
|
||||
char *module_path;
|
||||
char *full_name;
|
||||
GtkPrintBackendModule *pb_module;
|
||||
GtkPrintBackend *pb;
|
||||
|
||||
/* TODO: make module loading code work */
|
||||
for (l = loaded_backends; l != NULL; l = l->next)
|
||||
{
|
||||
pb_module = l->data;
|
||||
|
||||
if (strcmp (G_TYPE_MODULE (pb_module)->name, backend_name) == 0)
|
||||
return _gtk_print_backend_module_create (pb_module);
|
||||
}
|
||||
|
||||
pb = NULL;
|
||||
if (g_module_supported ())
|
||||
{
|
||||
full_name = g_strconcat ("printbackend-", backend_name, NULL);
|
||||
module_path = _gtk_find_module (full_name, "printbackends");
|
||||
g_free (full_name);
|
||||
|
||||
if (module_path)
|
||||
{
|
||||
pb_module = g_object_new (GTK_TYPE_PRINT_BACKEND_MODULE, NULL);
|
||||
|
||||
g_type_module_set_name (G_TYPE_MODULE (pb_module), backend_name);
|
||||
pb_module->path = g_strdup (module_path);
|
||||
|
||||
loaded_backends = g_slist_prepend (loaded_backends,
|
||||
pb_module);
|
||||
|
||||
pb = _gtk_print_backend_module_create (pb_module);
|
||||
}
|
||||
|
||||
g_free (module_path);
|
||||
}
|
||||
|
||||
return pb;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_initialize (void)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
gtk_settings_install_property (g_param_spec_string ("gtk-print-backends",
|
||||
P_("Default print backend"),
|
||||
P_("List of the GtkPrintBackend backends to use by default"),
|
||||
GTK_PRINT_BACKENDS,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GList *
|
||||
gtk_print_backend_load_modules ()
|
||||
{
|
||||
GList *result;
|
||||
GtkPrintBackend *backend;
|
||||
gchar *setting;
|
||||
gchar **backends;
|
||||
gint i;
|
||||
GtkSettings *settings;
|
||||
|
||||
result = NULL;
|
||||
|
||||
gtk_print_backend_initialize ();
|
||||
|
||||
settings = gtk_settings_get_default ();
|
||||
|
||||
g_object_get (settings, "gtk-print-backends", &setting, NULL);
|
||||
|
||||
backends = g_strsplit (setting, ",", -1);
|
||||
|
||||
for (i = 0; backends[i]; i++)
|
||||
{
|
||||
g_strchug (backends[i]);
|
||||
g_strchomp (backends[i]);
|
||||
backend = _gtk_print_backend_create (backends[i]);
|
||||
|
||||
if (backend)
|
||||
result = g_list_append (result, backend);
|
||||
}
|
||||
|
||||
g_strfreev (backends);
|
||||
g_free (setting);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* GtkPrintBackend *
|
||||
*****************************************/
|
||||
GType
|
||||
gtk_print_backend_get_type (void)
|
||||
{
|
||||
static GType print_backend_type = 0;
|
||||
|
||||
if (!print_backend_type)
|
||||
{
|
||||
static const GTypeInfo print_backend_info =
|
||||
{
|
||||
sizeof (GtkPrintBackendIface), /* class_size */
|
||||
gtk_print_backend_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
};
|
||||
|
||||
print_backend_type = g_type_register_static (G_TYPE_INTERFACE,
|
||||
"GtkPrintBackend",
|
||||
&print_backend_info, 0);
|
||||
|
||||
g_type_interface_add_prerequisite (print_backend_type, G_TYPE_OBJECT);
|
||||
}
|
||||
|
||||
return print_backend_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_base_init (gpointer g_class)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
|
||||
|
||||
g_signal_new ("printer-list-changed",
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_list_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
g_signal_new ("printer-added",
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_added),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
g_signal_new ("printer-removed",
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_removed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
g_signal_new ("printer-status-changed",
|
||||
iface_type,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintBackendIface, printer_status_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1, G_TYPE_OBJECT);
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
gtk_print_backend_get_printer_list (GtkPrintBackend *print_backend)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), NULL);
|
||||
|
||||
return GTK_PRINT_BACKEND_GET_IFACE (print_backend)->get_printer_list (print_backend);
|
||||
|
||||
}
|
||||
|
||||
GtkPrinter *
|
||||
gtk_print_backend_find_printer (GtkPrintBackend *print_backend,
|
||||
const gchar *printer_name)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_BACKEND (print_backend), NULL);
|
||||
|
||||
return GTK_PRINT_BACKEND_GET_IFACE (print_backend)->find_printer (print_backend, printer_name);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
gtk_print_backend_print_stream (GtkPrintBackend *print_backend,
|
||||
GtkPrintJob *job,
|
||||
gint data_fd,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_PRINT_BACKEND (print_backend));
|
||||
|
||||
GTK_PRINT_BACKEND_GET_IFACE (print_backend)->print_stream (print_backend,
|
||||
job,
|
||||
data_fd,
|
||||
callback,
|
||||
user_data,
|
||||
dnotify);
|
||||
}
|
||||
|
||||
#define __GTK_PRINT_BACKEND_C__
|
||||
#include "gtkaliasdef.c"
|
152
gtk/gtkprintbackend.h
Normal file
152
gtk/gtkprintbackend.h
Normal file
@ -0,0 +1,152 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackend.h: Abstract printer backend interfaces
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_BACKEND_H__
|
||||
#define __GTK_PRINT_BACKEND_H__
|
||||
|
||||
/* This is a "semi-private" header; it is meant only for
|
||||
* alternate GtkPrintDialog backend modules; no stability guarantees
|
||||
* are made at this point
|
||||
*/
|
||||
#ifndef GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED
|
||||
#error "GtkPrintBackend is not supported API for general use"
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include "gtkprinter-private.h"
|
||||
#include "gtkprintsettings.h"
|
||||
#include "gtkprinteroption.h"
|
||||
#include "gtkprintjob.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkPrintBackendIface GtkPrintBackendIface;
|
||||
|
||||
#define GTK_PRINT_BACKEND_ERROR (gtk_print_backend_error_quark ())
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* TODO: add specific errors */
|
||||
GTK_PRINT_BACKEND_ERROR_GENERIC
|
||||
} GtkPrintBackendError;
|
||||
|
||||
GQuark gtk_print_backend_error_quark (void);
|
||||
|
||||
#define GTK_TYPE_PRINT_BACKEND (gtk_print_backend_get_type ())
|
||||
#define GTK_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND, GtkPrintBackend))
|
||||
#define GTK_IS_PRINT_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND))
|
||||
#define GTK_PRINT_BACKEND_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_PRINT_BACKEND, GtkPrintBackendIface))
|
||||
|
||||
struct _GtkPrintBackendIface
|
||||
{
|
||||
GTypeInterface base_iface;
|
||||
|
||||
/* Global backend methods: */
|
||||
GList * (*get_printer_list) (GtkPrintBackend *printer_backend);
|
||||
|
||||
GtkPrinter * (*find_printer) (GtkPrintBackend *print_backend,
|
||||
const gchar *printer_name);
|
||||
void (*print_stream) (GtkPrintBackend *print_backend,
|
||||
GtkPrintJob *job,
|
||||
gint data_fd,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify);
|
||||
|
||||
/* Printer methods: */
|
||||
void (*printer_request_details) (GtkPrinter *printer);
|
||||
cairo_surface_t * (*printer_create_cairo_surface) (GtkPrinter *printer,
|
||||
gdouble height,
|
||||
gdouble width,
|
||||
gint cache_fd);
|
||||
GtkPrinterOptionSet * (*printer_get_options) (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
gboolean (*printer_mark_conflicts) (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options);
|
||||
void (*printer_get_settings_from_options) (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings);
|
||||
void (*printer_prepare_for_print) (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
GList * (*printer_list_papers) (GtkPrinter *printer);
|
||||
void (*printer_get_hard_margins) (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right);
|
||||
|
||||
/* Signals
|
||||
*/
|
||||
void (*printer_list_changed) (void);
|
||||
void (*printer_added) (GtkPrinter *printer);
|
||||
void (*printer_removed) (GtkPrinter *printer);
|
||||
void (*printer_status_changed) (GtkPrinter *printer);
|
||||
};
|
||||
|
||||
GType gtk_print_backend_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GList *gtk_print_backend_get_printer_list (GtkPrintBackend *print_backend);
|
||||
GtkPrinter *gtk_print_backend_find_printer (GtkPrintBackend *print_backend,
|
||||
const gchar *printer_name);
|
||||
void gtk_print_backend_print_stream (GtkPrintBackend *print_backend,
|
||||
GtkPrintJob *job,
|
||||
gint data_fd,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify);
|
||||
GList * gtk_print_backend_load_modules (void);
|
||||
|
||||
|
||||
/* Backend-only functions for GtkPrinter */
|
||||
|
||||
GtkPrinter *gtk_printer_new (const char *name,
|
||||
GtkPrintBackend *backend,
|
||||
gboolean is_virtual);
|
||||
gboolean gtk_printer_is_new (GtkPrinter *printer);
|
||||
void gtk_printer_set_is_new (GtkPrinter *printer,
|
||||
gboolean val);
|
||||
void gtk_printer_set_is_active (GtkPrinter *printer,
|
||||
gboolean val);
|
||||
void gtk_printer_set_has_details (GtkPrinter *printer,
|
||||
gboolean val);
|
||||
void gtk_printer_set_is_default (GtkPrinter *printer,
|
||||
gboolean val);
|
||||
void gtk_printer_set_icon_name (GtkPrinter *printer,
|
||||
const char *icon);
|
||||
gboolean gtk_printer_set_job_count (GtkPrinter *printer,
|
||||
int count);
|
||||
gboolean gtk_printer_set_location (GtkPrinter *printer,
|
||||
const char *location);
|
||||
gboolean gtk_printer_set_description (GtkPrinter *printer,
|
||||
const char *description);
|
||||
gboolean gtk_printer_set_state_message (GtkPrinter *printer,
|
||||
const char *message);
|
||||
void gtk_printer_set_is_active (GtkPrinter *printer,
|
||||
gboolean active);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_BACKEND_H__ */
|
406
gtk/gtkprintcontext.c
Normal file
406
gtk/gtkprintcontext.c
Normal file
@ -0,0 +1,406 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintcontext.c: Print Context
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkprintoperation-private.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
typedef struct _GtkPrintContextClass GtkPrintContextClass;
|
||||
|
||||
#define GTK_IS_PRINT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_CONTEXT))
|
||||
#define GTK_PRINT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_CONTEXT, GtkPrintContextClass))
|
||||
#define GTK_PRINT_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_CONTEXT, GtkPrintContextClass))
|
||||
|
||||
#define MM_PER_INCH 25.4
|
||||
#define POINTS_PER_INCH 72
|
||||
|
||||
struct _GtkPrintContext
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrintOperation *op;
|
||||
cairo_t *cr;
|
||||
GtkPageSetup *page_setup;
|
||||
PangoFontMap *fontmap;
|
||||
|
||||
gdouble pixels_per_unit_x;
|
||||
gdouble pixels_per_unit_y;
|
||||
};
|
||||
|
||||
struct _GtkPrintContextClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GtkPrintContext, gtk_print_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_print_context_finalize (GObject *object)
|
||||
{
|
||||
GtkPrintContext *context = GTK_PRINT_CONTEXT (object);
|
||||
|
||||
g_object_unref (context->fontmap);
|
||||
if (context->page_setup)
|
||||
g_object_unref (context->page_setup);
|
||||
|
||||
cairo_destroy (context->cr);
|
||||
|
||||
|
||||
G_OBJECT_CLASS (gtk_print_context_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_context_init (GtkPrintContext *context)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_context_class_init (GtkPrintContextClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *)class;
|
||||
|
||||
gobject_class->finalize = gtk_print_context_finalize;
|
||||
}
|
||||
|
||||
|
||||
GtkPrintContext *
|
||||
_gtk_print_context_new (GtkPrintOperation *op)
|
||||
{
|
||||
GtkPrintContext *context;
|
||||
|
||||
context = g_object_new (GTK_TYPE_PRINT_CONTEXT, NULL);
|
||||
|
||||
context->op = op;
|
||||
context->cr = cairo_create (op->priv->surface);
|
||||
|
||||
switch (op->priv->unit)
|
||||
{
|
||||
default:
|
||||
case GTK_UNIT_PIXEL:
|
||||
/* Do nothing, this is the cairo default unit */
|
||||
context->pixels_per_unit_x = 1.0;
|
||||
context->pixels_per_unit_y = 1.0;
|
||||
break;
|
||||
case GTK_UNIT_POINTS:
|
||||
context->pixels_per_unit_x = op->priv->dpi_x / POINTS_PER_INCH;
|
||||
context->pixels_per_unit_y = op->priv->dpi_y / POINTS_PER_INCH;
|
||||
break;
|
||||
case GTK_UNIT_INCH:
|
||||
context->pixels_per_unit_x = op->priv->dpi_x;
|
||||
context->pixels_per_unit_y = op->priv->dpi_y;
|
||||
break;
|
||||
case GTK_UNIT_MM:
|
||||
context->pixels_per_unit_x = op->priv->dpi_x / MM_PER_INCH;
|
||||
context->pixels_per_unit_y = op->priv->dpi_y / MM_PER_INCH;
|
||||
break;
|
||||
}
|
||||
cairo_scale (context->cr,
|
||||
context->pixels_per_unit_x,
|
||||
context->pixels_per_unit_y);
|
||||
|
||||
context->fontmap = pango_cairo_font_map_new ();
|
||||
/* We use the unit-scaled resolution, as we still want fonts given in points to work */
|
||||
pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (context->fontmap),
|
||||
op->priv->dpi_y / context->pixels_per_unit_y);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
|
||||
{
|
||||
cairo_t *cr = context->cr;
|
||||
cairo_matrix_t matrix;
|
||||
GtkPaperSize *paper_size;
|
||||
gdouble width, height;
|
||||
|
||||
paper_size = gtk_page_setup_get_paper_size (context->page_setup);
|
||||
|
||||
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
|
||||
width = width * context->op->priv->dpi_x / context->pixels_per_unit_x;
|
||||
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
|
||||
height = height * context->op->priv->dpi_y / context->pixels_per_unit_y;
|
||||
|
||||
switch (gtk_page_setup_get_orientation (context->page_setup))
|
||||
{
|
||||
default:
|
||||
case GTK_PAGE_ORIENTATION_PORTRAIT:
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_LANDSCAPE:
|
||||
cairo_translate (cr, width, 0);
|
||||
cairo_matrix_init (&matrix,
|
||||
0, 1,
|
||||
-1, 0,
|
||||
0, 0);
|
||||
cairo_transform (cr, &matrix);
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT:
|
||||
cairo_translate (cr, width, height);
|
||||
cairo_matrix_init (&matrix,
|
||||
-1, 0,
|
||||
0, -1,
|
||||
0, 0);
|
||||
cairo_transform (cr, &matrix);
|
||||
break;
|
||||
case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE:
|
||||
cairo_translate (cr, 0, height);
|
||||
cairo_matrix_init (&matrix,
|
||||
0, -1,
|
||||
1, 0,
|
||||
0, 0);
|
||||
cairo_transform (cr, &matrix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_context_translate_into_margin (GtkPrintContext *context)
|
||||
{
|
||||
gdouble left, top;
|
||||
|
||||
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
|
||||
|
||||
/* We do it this way to also handle GTK_UNIT_PIXELS */
|
||||
|
||||
left = gtk_page_setup_get_left_margin (context->page_setup, GTK_UNIT_INCH);
|
||||
top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
|
||||
|
||||
cairo_translate (context->cr,
|
||||
left * context->op->priv->dpi_x / context->pixels_per_unit_x,
|
||||
top * context->op->priv->dpi_y / context->pixels_per_unit_y);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_print_context_set_page_setup (GtkPrintContext *context,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_PRINT_CONTEXT (context));
|
||||
g_return_if_fail (page_setup == NULL ||
|
||||
GTK_IS_PAGE_SETUP (page_setup));
|
||||
|
||||
g_object_ref (page_setup);
|
||||
|
||||
if (context->page_setup != NULL)
|
||||
g_object_unref (context->page_setup);
|
||||
|
||||
context->page_setup = page_setup;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_cairo:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the cairo context that is associated with the
|
||||
* #GtkPrintContext.
|
||||
*
|
||||
* Return value: the cairo context of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
cairo_t *
|
||||
gtk_print_context_get_cairo (GtkPrintContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
|
||||
|
||||
return context->cr;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_page_setup:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the #GtkPageSetup that determines the page
|
||||
* dimensions of the #GtkPrintContext.
|
||||
*
|
||||
* Return value: the page setup of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
GtkPageSetup *
|
||||
gtk_print_context_get_page_setup (GtkPrintContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
|
||||
|
||||
return context->page_setup;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_width:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the width of the #GtkPrintContext, in pixels.
|
||||
*
|
||||
* Return value: the width of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
gdouble
|
||||
gtk_print_context_get_width (GtkPrintContext *context)
|
||||
{
|
||||
gdouble width;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
|
||||
|
||||
if (context->op->priv->use_full_page)
|
||||
width = gtk_page_setup_get_paper_width (context->page_setup, GTK_UNIT_INCH);
|
||||
else
|
||||
width = gtk_page_setup_get_page_width (context->page_setup, GTK_UNIT_INCH);
|
||||
|
||||
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
|
||||
return width * context->op->priv->dpi_x / context->pixels_per_unit_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_height:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the width of the #GtkPrintContext, in pixels.
|
||||
*
|
||||
* Return value: the height of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
gdouble
|
||||
gtk_print_context_get_height (GtkPrintContext *context)
|
||||
{
|
||||
gdouble height;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
|
||||
|
||||
if (context->op->priv->use_full_page)
|
||||
height = gtk_page_setup_get_paper_height (context->page_setup, GTK_UNIT_INCH);
|
||||
else
|
||||
height = gtk_page_setup_get_page_height (context->page_setup, GTK_UNIT_INCH);
|
||||
|
||||
/* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
|
||||
return height * context->op->priv->dpi_y / context->pixels_per_unit_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_dpi_x:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the horizontal resolution of the #GtkPrintContext,
|
||||
* in dots per inch.
|
||||
*
|
||||
* Return value: the horizontal resolution of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
gdouble
|
||||
gtk_print_context_get_dpi_x (GtkPrintContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
|
||||
|
||||
return context->op->priv->dpi_x;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_dpi_y:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Obtains the vertical resolution of the #GtkPrintContext,
|
||||
* in dots per inch.
|
||||
*
|
||||
* Return value: the vertical resolution of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
gdouble
|
||||
gtk_print_context_get_dpi_y (GtkPrintContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
|
||||
|
||||
return context->op->priv->dpi_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_get_fontmap:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Returns a #PangoFontMap that is suitable for use
|
||||
* with the #GtkPrintContext.
|
||||
*
|
||||
* Return value: the font map of @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
PangoFontMap *
|
||||
gtk_print_context_get_fontmap (GtkPrintContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
|
||||
|
||||
return context->fontmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_create_context:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Creates a new #PangoContext that can be used with the
|
||||
* #GtkPrintContext.
|
||||
*
|
||||
* Return value: a new Pango context for @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
PangoContext *
|
||||
gtk_print_context_create_context (GtkPrintContext *context)
|
||||
{
|
||||
PangoContext *pango_context;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
|
||||
|
||||
pango_context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (context->fontmap));
|
||||
|
||||
return pango_context;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_context_create_layout:
|
||||
* @context: a #GtkPrintContext
|
||||
*
|
||||
* Creates a new #PangoLayout that is suitable for use
|
||||
* with the #GtkPrintContext.
|
||||
*
|
||||
* Return value: a new Pango layout for @context
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
PangoLayout *
|
||||
gtk_print_context_create_layout (GtkPrintContext *context)
|
||||
{
|
||||
PangoContext *pango_context;
|
||||
PangoLayout *layout;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL);
|
||||
|
||||
pango_context = gtk_print_context_create_context (context);
|
||||
layout = pango_layout_new (pango_context);
|
||||
|
||||
pango_cairo_update_context (context->cr, pango_context);
|
||||
g_object_unref (pango_context);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PRINT_CONTEXT_C__
|
||||
#include "gtkaliasdef.c"
|
57
gtk/gtkprintcontext.h
Normal file
57
gtk/gtkprintcontext.h
Normal file
@ -0,0 +1,57 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintcontext.h: Print Context
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_CONTEXT_H__
|
||||
#define __GTK_PRINT_CONTEXT_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <pango/pango-layout.h>
|
||||
#include "gtkenums.h"
|
||||
#include "gtkpagesetup.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkPrintContext GtkPrintContext;
|
||||
|
||||
#define GTK_TYPE_PRINT_CONTEXT (gtk_print_context_get_type ())
|
||||
#define GTK_PRINT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_CONTEXT, GtkPrintContext))
|
||||
#define GTK_IS_PRINT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_CONTEXT))
|
||||
|
||||
GType gtk_print_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/* Rendering */
|
||||
cairo_t * gtk_print_context_get_cairo (GtkPrintContext *context);
|
||||
|
||||
GtkPageSetup *gtk_print_context_get_page_setup (GtkPrintContext *context);
|
||||
gdouble gtk_print_context_get_width (GtkPrintContext *context);
|
||||
gdouble gtk_print_context_get_height (GtkPrintContext *context);
|
||||
gdouble gtk_print_context_get_dpi_x (GtkPrintContext *context);
|
||||
gdouble gtk_print_context_get_dpi_y (GtkPrintContext *context);
|
||||
|
||||
/* Fonts */
|
||||
PangoFontMap *gtk_print_context_get_fontmap (GtkPrintContext *context);
|
||||
PangoContext *gtk_print_context_create_context (GtkPrintContext *context);
|
||||
PangoLayout * gtk_print_context_create_layout (GtkPrintContext *context);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_CONTEXT_H__ */
|
64
gtk/gtkprinter-private.h
Normal file
64
gtk/gtkprinter-private.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintoperation.h: Print Operation
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINTER_PRIVATE_H__
|
||||
#define __GTK_PRINTER_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "gtkprinter.h"
|
||||
#include "gtkprintoperation.h"
|
||||
#include "gtkprinteroptionset.h"
|
||||
#include "gtkpagesetup.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean _gtk_printer_has_details (GtkPrinter *printer);
|
||||
void _gtk_printer_request_details (GtkPrinter *printer);
|
||||
GtkPrinterOptionSet *_gtk_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
gboolean _gtk_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options);
|
||||
void _gtk_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings);
|
||||
void _gtk_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
gint cache_fd);
|
||||
GList * _gtk_printer_list_papers (GtkPrinter *printer);
|
||||
void _gtk_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right);
|
||||
GHashTable * _gtk_printer_get_custom_widgets (GtkPrinter *printer);
|
||||
|
||||
|
||||
/* GtkPrintJob private methods: */
|
||||
void gtk_print_job_set_status (GtkPrintJob *job,
|
||||
GtkPrintStatus status);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GTK_PRINT_OPERATION_PRIVATE_H__ */
|
587
gtk/gtkprinter.c
Normal file
587
gtk/gtkprinter.c
Normal file
@ -0,0 +1,587 @@
|
||||
/* GtkPrinter
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include "gtkprinter.h"
|
||||
#include "gtkprinter-private.h"
|
||||
#include "gtkprintbackend.h"
|
||||
#include "gtkprintjob.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define GTK_PRINTER_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINTER, GtkPrinterPrivate))
|
||||
|
||||
static void gtk_printer_finalize (GObject *object);
|
||||
|
||||
struct _GtkPrinterPrivate
|
||||
{
|
||||
gchar *name;
|
||||
gchar *location;
|
||||
gchar *description;
|
||||
gchar *icon_name;
|
||||
|
||||
guint is_active: 1;
|
||||
guint is_new: 1;
|
||||
guint is_virtual : 1;
|
||||
guint is_default : 1;
|
||||
guint has_details: 1;
|
||||
|
||||
gchar *state_message;
|
||||
gint job_count;
|
||||
|
||||
GtkPrintBackend *backend;
|
||||
};
|
||||
|
||||
enum {
|
||||
DETAILS_ACQUIRED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_BACKEND,
|
||||
PROP_IS_VIRTUAL,
|
||||
PROP_STATE_MESSAGE,
|
||||
PROP_LOCATION,
|
||||
PROP_ICON_NAME,
|
||||
PROP_JOB_COUNT
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void gtk_printer_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_printer_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
G_DEFINE_TYPE (GtkPrinter, gtk_printer, G_TYPE_OBJECT);
|
||||
|
||||
static int
|
||||
safe_strcmp (const char *a, const char *b)
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
if (a == NULL)
|
||||
return -1;
|
||||
if (b == NULL)
|
||||
return 1;
|
||||
return strcmp (a, b);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_class_init (GtkPrinterClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
object_class = (GObjectClass *) class;
|
||||
|
||||
object_class->finalize = gtk_printer_finalize;
|
||||
|
||||
object_class->set_property = gtk_printer_set_property;
|
||||
object_class->get_property = gtk_printer_get_property;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkPrinterPrivate));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_NAME,
|
||||
g_param_spec_string ("name",
|
||||
P_("Name"),
|
||||
P_("Name of the printer"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_BACKEND,
|
||||
g_param_spec_object ("backend",
|
||||
P_("Backend"),
|
||||
P_("Backend for the printer"),
|
||||
GTK_TYPE_PRINT_BACKEND,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_IS_VIRTUAL,
|
||||
g_param_spec_boolean ("is-virtual",
|
||||
P_("Is Virtual"),
|
||||
P_("False if this represents a real hardware printer"),
|
||||
FALSE,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_STATE_MESSAGE,
|
||||
g_param_spec_string ("state-message",
|
||||
P_("State Message"),
|
||||
P_("String giving the current state of the printer"),
|
||||
NULL,
|
||||
GTK_PARAM_READABLE));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_LOCATION,
|
||||
g_param_spec_string ("location",
|
||||
P_("Location"),
|
||||
P_("The location of the printer"),
|
||||
NULL,
|
||||
GTK_PARAM_READABLE));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_ICON_NAME,
|
||||
g_param_spec_string ("icon-name",
|
||||
P_("Icon Name"),
|
||||
P_("The icon name to use for the printer"),
|
||||
NULL,
|
||||
GTK_PARAM_READABLE));
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
PROP_JOB_COUNT,
|
||||
g_param_spec_int ("job-count",
|
||||
P_("Job Count"),
|
||||
P_("Number of jobs queued in the printer"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
|
||||
signals[DETAILS_ACQUIRED] =
|
||||
g_signal_new ("details-acquired",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrinterClass, details_acquired),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__BOOLEAN,
|
||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_init (GtkPrinter *printer)
|
||||
{
|
||||
printer->priv = GTK_PRINTER_GET_PRIVATE (printer);
|
||||
|
||||
printer->priv->name = NULL;
|
||||
printer->priv->location = NULL;
|
||||
printer->priv->description = NULL;
|
||||
printer->priv->icon_name = NULL;
|
||||
|
||||
printer->priv->is_active = TRUE;
|
||||
printer->priv->is_new = TRUE;
|
||||
printer->priv->has_details = FALSE;
|
||||
|
||||
printer->priv->state_message = NULL;
|
||||
printer->priv->job_count = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_finalize (GObject *object)
|
||||
{
|
||||
g_return_if_fail (object != NULL);
|
||||
|
||||
GtkPrinter *printer = GTK_PRINTER (object);
|
||||
|
||||
g_free (printer->priv->name);
|
||||
g_free (printer->priv->location);
|
||||
g_free (printer->priv->description);
|
||||
g_free (printer->priv->state_message);
|
||||
g_free (printer->priv->icon_name);
|
||||
|
||||
if (printer->priv->backend)
|
||||
g_object_unref (printer->priv->backend);
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_printer_parent_class)->finalize)
|
||||
G_OBJECT_CLASS (gtk_printer_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPrinter *printer = GTK_PRINTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_NAME:
|
||||
printer->priv->name = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_BACKEND:
|
||||
printer->priv->backend = GTK_PRINT_BACKEND (g_value_dup_object (value));
|
||||
break;
|
||||
|
||||
case PROP_IS_VIRTUAL:
|
||||
printer->priv->is_virtual = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPrinter *printer = GTK_PRINTER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_NAME:
|
||||
if (printer->priv->name)
|
||||
g_value_set_string (value, printer->priv->name);
|
||||
else
|
||||
g_value_set_string (value, "");
|
||||
break;
|
||||
case PROP_BACKEND:
|
||||
g_value_set_object (value, printer->priv->backend);
|
||||
break;
|
||||
case PROP_STATE_MESSAGE:
|
||||
if (printer->priv->state_message)
|
||||
g_value_set_string (value, printer->priv->state_message);
|
||||
else
|
||||
g_value_set_string (value, "");
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
if (printer->priv->location)
|
||||
g_value_set_string (value, printer->priv->location);
|
||||
else
|
||||
g_value_set_string (value, "");
|
||||
break;
|
||||
case PROP_ICON_NAME:
|
||||
if (printer->priv->icon_name)
|
||||
g_value_set_string (value, printer->priv->icon_name);
|
||||
else
|
||||
g_value_set_string (value, "");
|
||||
break;
|
||||
case PROP_JOB_COUNT:
|
||||
g_value_set_int (value, printer->priv->job_count);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_printer_new:
|
||||
*
|
||||
* Creates a new #GtkPrinter.
|
||||
*
|
||||
* Return value: a new #GtkPrinter
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
GtkPrinter *
|
||||
gtk_printer_new (const char *name,
|
||||
GtkPrintBackend *backend,
|
||||
gboolean virtual)
|
||||
{
|
||||
GObject *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_PRINTER,
|
||||
"name", name,
|
||||
"backend", backend,
|
||||
"is-virtual", virtual,
|
||||
NULL);
|
||||
|
||||
return (GtkPrinter *) result;
|
||||
}
|
||||
|
||||
GtkPrintBackend *
|
||||
gtk_printer_get_backend (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->backend;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_backend (GtkPrinter *printer,
|
||||
GtkPrintBackend *backend)
|
||||
{
|
||||
if (printer->priv->backend)
|
||||
g_object_unref (printer->priv->backend);
|
||||
|
||||
printer->priv->backend = g_object_ref (backend);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_printer_get_name (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->name;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_printer_get_description (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->description;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_set_description (GtkPrinter *printer,
|
||||
const char *description)
|
||||
{
|
||||
if (safe_strcmp (printer->priv->description, description) == 0)
|
||||
return FALSE;
|
||||
|
||||
g_free (printer->priv->description);
|
||||
printer->priv->description = g_strdup (description);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_printer_get_state_message (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->state_message;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_set_state_message (GtkPrinter *printer,
|
||||
const char *message)
|
||||
{
|
||||
if (safe_strcmp (printer->priv->state_message, message) == 0)
|
||||
return FALSE;
|
||||
|
||||
g_free (printer->priv->state_message);
|
||||
printer->priv->state_message = g_strdup (message);
|
||||
g_object_notify (G_OBJECT (printer), "state-message");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_printer_get_location (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->location;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_set_location (GtkPrinter *printer,
|
||||
const char *location)
|
||||
{
|
||||
if (safe_strcmp (printer->priv->location, location) == 0)
|
||||
return FALSE;
|
||||
|
||||
g_free (printer->priv->location);
|
||||
printer->priv->location = g_strdup (location);
|
||||
g_object_notify (G_OBJECT (printer), "location");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_printer_get_icon_name (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), NULL);
|
||||
|
||||
return printer->priv->icon_name;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_icon_name (GtkPrinter *printer,
|
||||
const char *icon)
|
||||
{
|
||||
g_free (printer->priv->icon_name);
|
||||
printer->priv->icon_name = g_strdup (icon);
|
||||
g_object_notify (G_OBJECT (printer), "icon-name");
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_printer_get_job_count (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), 0);
|
||||
|
||||
return printer->priv->job_count;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_set_job_count (GtkPrinter *printer,
|
||||
int count)
|
||||
{
|
||||
if (printer->priv->job_count == count)
|
||||
return FALSE;
|
||||
|
||||
printer->priv->job_count = count;
|
||||
|
||||
g_object_notify (G_OBJECT (printer), "job-count");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_printer_has_details (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
||||
|
||||
return printer->priv->has_details;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_has_details (GtkPrinter *printer,
|
||||
gboolean val)
|
||||
{
|
||||
printer->priv->has_details = val;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_is_active (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
||||
|
||||
return printer->priv->is_active;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_is_active (GtkPrinter *printer,
|
||||
gboolean val)
|
||||
{
|
||||
printer->priv->is_active = val;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gtk_printer_is_virtual (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), TRUE);
|
||||
|
||||
return printer->priv->is_virtual;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_is_new (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
||||
|
||||
return printer->priv->is_new;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_is_new (GtkPrinter *printer,
|
||||
gboolean val)
|
||||
{
|
||||
printer->priv->is_new = val;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gtk_printer_is_default (GtkPrinter *printer)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINTER (printer), FALSE);
|
||||
|
||||
return printer->priv->is_default;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_set_is_default (GtkPrinter *printer,
|
||||
gboolean val)
|
||||
{
|
||||
printer->priv->is_default = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_printer_request_details (GtkPrinter *printer)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
return backend_iface->printer_request_details (printer);
|
||||
}
|
||||
|
||||
GtkPrinterOptionSet *
|
||||
_gtk_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
return backend_iface->printer_get_options (printer, settings, page_setup);
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
return backend_iface->printer_mark_conflicts (printer, options);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
return backend_iface->printer_get_settings_from_options (printer, options, settings);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
return backend_iface->printer_prepare_for_print (printer, print_job, settings, page_setup);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
_gtk_printer_create_cairo_surface (GtkPrinter *printer,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
gint cache_fd)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
|
||||
return backend_iface->printer_create_cairo_surface (printer, width, height, cache_fd);
|
||||
}
|
||||
|
||||
GList *
|
||||
_gtk_printer_list_papers (GtkPrinter *printer)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
|
||||
return backend_iface->printer_list_papers (printer);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right)
|
||||
{
|
||||
GtkPrintBackendIface *backend_iface = GTK_PRINT_BACKEND_GET_IFACE (printer->priv->backend);
|
||||
|
||||
backend_iface->printer_get_hard_margins (printer, top, bottom, left, right);
|
||||
}
|
||||
|
||||
#define __GTK_PRINTER_C__
|
||||
#include "gtkaliasdef.c"
|
86
gtk/gtkprinter.h
Normal file
86
gtk/gtkprinter.h
Normal file
@ -0,0 +1,86 @@
|
||||
/* GtkPrinter
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINTER_H__
|
||||
#define __GTK_PRINTER_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
#include <gtk/gtkprintsettings.h>
|
||||
#include <gtk/gtkpagesetup.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINTER (gtk_printer_get_type ())
|
||||
#define GTK_PRINTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER, GtkPrinter))
|
||||
#define GTK_PRINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINTER, GtkPrinterClass))
|
||||
#define GTK_IS_PRINTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER))
|
||||
#define GTK_IS_PRINTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINTER))
|
||||
#define GTK_PRINTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINTER, GtkPrinterClass))
|
||||
|
||||
typedef struct _GtkPrinter GtkPrinter;
|
||||
typedef struct _GtkPrinterClass GtkPrinterClass;
|
||||
typedef struct _GtkPrinterPrivate GtkPrinterPrivate;
|
||||
typedef struct _GtkPrintBackend GtkPrintBackend;
|
||||
typedef struct _GtkPrintJob GtkPrintJob;
|
||||
|
||||
struct _GtkPrintBackend;
|
||||
struct _GtkPrintJob;
|
||||
|
||||
struct _GtkPrinter
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrinterPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkPrinterClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*details_acquired) (GtkPrinter *printer, gboolean success);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
GType gtk_printer_get_type (void) G_GNUC_CONST;
|
||||
GtkPrinter *gtk_printer_new (const char *name,
|
||||
GtkPrintBackend *backend,
|
||||
gboolean virtual);
|
||||
GtkPrintBackend *gtk_printer_get_backend (GtkPrinter *printer);
|
||||
const gchar *gtk_printer_get_name (GtkPrinter *printer);
|
||||
const gchar *gtk_printer_get_state_message (GtkPrinter *printer);
|
||||
const gchar *gtk_printer_get_description (GtkPrinter *printer);
|
||||
const gchar *gtk_printer_get_location (GtkPrinter *printer);
|
||||
const gchar *gtk_printer_get_icon_name (GtkPrinter *printer);
|
||||
gint gtk_printer_get_job_count (GtkPrinter *printer);
|
||||
gboolean gtk_printer_is_active (GtkPrinter *printer);
|
||||
gboolean gtk_printer_is_virtual (GtkPrinter *printer);
|
||||
gboolean gtk_printer_is_default (GtkPrinter *printer);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINTER_H__ */
|
219
gtk/gtkprinteroption.c
Normal file
219
gtk/gtkprinteroption.c
Normal file
@ -0,0 +1,219 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprinteroption.c: Handling possible settings for a specific printer setting
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; 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 <gmodule.h>
|
||||
|
||||
#include "gtkprinteroption.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
/*****************************************
|
||||
* GtkPrinterOption *
|
||||
*****************************************/
|
||||
|
||||
enum {
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkPrinterOption, gtk_printer_option, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_printer_option_finalize (GObject *object)
|
||||
{
|
||||
GtkPrinterOption *option = GTK_PRINTER_OPTION (object);
|
||||
int i;
|
||||
|
||||
g_free (option->name);
|
||||
g_free (option->display_text);
|
||||
g_free (option->value);
|
||||
for (i = 0; i < option->num_choices; i++)
|
||||
{
|
||||
g_free (option->choices[i]);
|
||||
g_free (option->choices_display[i]);
|
||||
}
|
||||
g_free (option->choices);
|
||||
g_free (option->choices_display);
|
||||
g_free (option->group);
|
||||
|
||||
G_OBJECT_CLASS (gtk_printer_option_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_init (GtkPrinterOption *option)
|
||||
{
|
||||
option->value = g_strdup ("");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_class_init (GtkPrinterOptionClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *)class;
|
||||
|
||||
gobject_class->finalize = gtk_printer_option_finalize;
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrinterOptionClass, changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
GtkPrinterOption *
|
||||
gtk_printer_option_new (const char *name, const char *display_text,
|
||||
GtkPrinterOptionType type)
|
||||
{
|
||||
GtkPrinterOption *option;
|
||||
|
||||
option = g_object_new (GTK_TYPE_PRINTER_OPTION, NULL);
|
||||
|
||||
option->name = g_strdup (name);
|
||||
option->display_text = g_strdup (display_text);
|
||||
option->type = type;
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
static void
|
||||
emit_changed (GtkPrinterOption *option)
|
||||
{
|
||||
g_signal_emit (option, signals[CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set (GtkPrinterOption *option,
|
||||
const char *value)
|
||||
{
|
||||
if (value == NULL)
|
||||
value = "";
|
||||
|
||||
if (strcmp (option->value, value) == 0)
|
||||
return;
|
||||
|
||||
if (option->type == GTK_PRINTER_OPTION_TYPE_PICKONE &&
|
||||
value != NULL)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < option->num_choices; i++)
|
||||
{
|
||||
if (g_ascii_strcasecmp (value, option->choices[i]) == 0)
|
||||
{
|
||||
value = option->choices[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == option->num_choices)
|
||||
return; /* Not found in availible choices */
|
||||
}
|
||||
|
||||
g_free (option->value);
|
||||
option->value = g_strdup (value);
|
||||
|
||||
emit_changed (option);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_boolean (GtkPrinterOption *option,
|
||||
gboolean value)
|
||||
{
|
||||
gtk_printer_option_set (option, value ? "True" : "False");
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_has_conflict (GtkPrinterOption *option,
|
||||
gboolean has_conflict)
|
||||
{
|
||||
has_conflict = has_conflict != 0;
|
||||
|
||||
if (option->has_conflict == has_conflict)
|
||||
return;
|
||||
|
||||
option->has_conflict = has_conflict;
|
||||
emit_changed (option);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_clear_has_conflict (GtkPrinterOption *option)
|
||||
{
|
||||
gtk_printer_option_set_has_conflict (option, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_allocate_choices (GtkPrinterOption *option,
|
||||
int num)
|
||||
{
|
||||
g_free (option->choices);
|
||||
g_free (option->choices_display);
|
||||
|
||||
option->num_choices = num;
|
||||
if (num == 0)
|
||||
{
|
||||
option->choices = NULL;
|
||||
option->choices_display = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
option->choices = g_new0 (char *, num);
|
||||
option->choices_display = g_new0 (char *, num);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_choices_from_array (GtkPrinterOption *option,
|
||||
int num_choices,
|
||||
char *choices[],
|
||||
char *choices_display[])
|
||||
{
|
||||
int i;
|
||||
|
||||
gtk_printer_option_allocate_choices (option, num_choices);
|
||||
for (i = 0; i < num_choices; i++)
|
||||
{
|
||||
option->choices[i] = g_strdup (choices[i]);
|
||||
option->choices_display[i] = g_strdup (choices_display[i]);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_option_has_choice (GtkPrinterOption *option,
|
||||
const char *choice)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < option->num_choices; i++)
|
||||
{
|
||||
if (strcmp (option->choices[i], choice) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PRINTER_OPTION_C__
|
||||
#include "gtkaliasdef.c"
|
113
gtk/gtkprinteroption.h
Normal file
113
gtk/gtkprinteroption.h
Normal file
@ -0,0 +1,113 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprinteroption.h: printer option
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINTER_OPTION_H__
|
||||
#define __GTK_PRINTER_OPTION_H__
|
||||
|
||||
/* This is a "semi-private" header; it is meant only for
|
||||
* alternate GtkPrintDialog backend modules; no stability guarantees
|
||||
* are made at this point
|
||||
*/
|
||||
#ifndef GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED
|
||||
#error "GtkPrintBackend is not supported API for general use"
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINTER_OPTION (gtk_printer_option_get_type ())
|
||||
#define GTK_PRINTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER_OPTION, GtkPrinterOption))
|
||||
#define GTK_IS_PRINTER_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER_OPTION))
|
||||
|
||||
typedef struct _GtkPrinterOption GtkPrinterOption;
|
||||
typedef struct _GtkPrinterOptionClass GtkPrinterOptionClass;
|
||||
|
||||
#define GTK_PRINTER_OPTION_GROUP_IMAGE_QUALITY "ImageQuality"
|
||||
#define GTK_PRINTER_OPTION_GROUP_FINISHING "Finishing"
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINTER_OPTION_TYPE_BOOLEAN,
|
||||
GTK_PRINTER_OPTION_TYPE_PICKONE,
|
||||
GTK_PRINTER_OPTION_TYPE_STRING,
|
||||
GTK_PRINTER_OPTION_TYPE_FILESAVE
|
||||
} GtkPrinterOptionType;
|
||||
|
||||
struct _GtkPrinterOption
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
char *name;
|
||||
char *display_text;
|
||||
GtkPrinterOptionType type;
|
||||
|
||||
char *value;
|
||||
|
||||
int num_choices;
|
||||
char **choices;
|
||||
char **choices_display;
|
||||
|
||||
gboolean has_conflict;
|
||||
char *group;
|
||||
};
|
||||
|
||||
struct _GtkPrinterOptionClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*changed) (GtkPrinterOption *option);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
GType gtk_printer_option_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkPrinterOption *gtk_printer_option_new (const char *name,
|
||||
const char *display_text,
|
||||
GtkPrinterOptionType type);
|
||||
void gtk_printer_option_set (GtkPrinterOption *option,
|
||||
const char *value);
|
||||
void gtk_printer_option_set_has_conflict (GtkPrinterOption *option,
|
||||
gboolean has_conflict);
|
||||
void gtk_printer_option_clear_has_conflict (GtkPrinterOption *option);
|
||||
void gtk_printer_option_set_boolean (GtkPrinterOption *option,
|
||||
gboolean value);
|
||||
void gtk_printer_option_allocate_choices (GtkPrinterOption *option,
|
||||
int num);
|
||||
void gtk_printer_option_choices_from_array (GtkPrinterOption *option,
|
||||
int num_choices,
|
||||
char *choices[],
|
||||
char *choices_display[]);
|
||||
gboolean gtk_printer_option_has_choice (GtkPrinterOption *option,
|
||||
const char *choice);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINTER_OPTION_H__ */
|
||||
|
||||
|
205
gtk/gtkprinteroptionset.c
Normal file
205
gtk/gtkprinteroptionset.c
Normal file
@ -0,0 +1,205 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackend.h: Abstract printer backend interfaces
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; 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 <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "gtkprinteroptionset.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
/*****************************************
|
||||
* GtkPrinterOptionSet *
|
||||
*****************************************/
|
||||
|
||||
enum {
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
/* ugly side-effect of aliasing */
|
||||
#undef gtk_printer_option_set
|
||||
|
||||
G_DEFINE_TYPE (GtkPrinterOptionSet, gtk_printer_option_set, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_printer_option_set_finalize (GObject *object)
|
||||
{
|
||||
GtkPrinterOptionSet *set = GTK_PRINTER_OPTION_SET (object);
|
||||
|
||||
g_hash_table_destroy (set->hash);
|
||||
g_ptr_array_foreach (set->array, (GFunc)g_object_unref, NULL);
|
||||
g_ptr_array_free (set->array, TRUE);
|
||||
|
||||
G_OBJECT_CLASS (gtk_printer_option_set_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_set_init (GtkPrinterOptionSet *set)
|
||||
{
|
||||
set->array = g_ptr_array_new ();
|
||||
set->hash = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_set_class_init (GtkPrinterOptionSetClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = (GObjectClass *)class;
|
||||
|
||||
gobject_class->finalize = gtk_printer_option_set_finalize;
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS (gobject_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrinterOptionSetClass, changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
emit_changed (GtkPrinterOptionSet *set)
|
||||
{
|
||||
g_signal_emit (set, signals[CHANGED], 0);
|
||||
}
|
||||
|
||||
GtkPrinterOptionSet *
|
||||
gtk_printer_option_set_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_PRINTER_OPTION_SET, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_remove (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOption *option)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < set->array->len; i++)
|
||||
{
|
||||
if (g_ptr_array_index (set->array, i) == option)
|
||||
{
|
||||
g_ptr_array_remove_index (set->array, i);
|
||||
g_hash_table_remove (set->hash, option->name);
|
||||
g_signal_handlers_disconnect_by_func (option, emit_changed, set);
|
||||
|
||||
g_object_unref (option);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_add (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOption *option)
|
||||
{
|
||||
g_object_ref (option);
|
||||
|
||||
if (gtk_printer_option_set_lookup (set, option->name))
|
||||
gtk_printer_option_set_remove (set, option);
|
||||
|
||||
g_ptr_array_add (set->array, option);
|
||||
g_hash_table_insert (set->hash, option->name, option);
|
||||
g_signal_connect_object (option, "changed", G_CALLBACK (emit_changed), set, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
GtkPrinterOption *
|
||||
gtk_printer_option_set_lookup (GtkPrinterOptionSet *set,
|
||||
const char *name)
|
||||
{
|
||||
gpointer ptr;
|
||||
|
||||
ptr = g_hash_table_lookup (set->hash, name);
|
||||
|
||||
return GTK_PRINTER_OPTION (ptr);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_clear_conflicts (GtkPrinterOptionSet *set)
|
||||
{
|
||||
gtk_printer_option_set_foreach (set,
|
||||
(GtkPrinterOptionSetFunc)gtk_printer_option_clear_has_conflict,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
safe_strcmp (const char *a, const char *b)
|
||||
{
|
||||
if (a == NULL)
|
||||
a = "";
|
||||
if (b == NULL)
|
||||
b = "";
|
||||
|
||||
return strcmp (a, b);
|
||||
}
|
||||
|
||||
GList *
|
||||
gtk_printer_option_set_get_groups (GtkPrinterOptionSet *set)
|
||||
{
|
||||
GtkPrinterOption *option;
|
||||
GList *list = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < set->array->len; i++)
|
||||
{
|
||||
option = g_ptr_array_index (set->array, i);
|
||||
|
||||
if (g_list_find_custom (list, option->group, (GCompareFunc)safe_strcmp) == NULL)
|
||||
list = g_list_prepend (list, g_strdup (option->group));
|
||||
}
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_foreach_in_group (GtkPrinterOptionSet *set,
|
||||
const char *group,
|
||||
GtkPrinterOptionSetFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkPrinterOption *option;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < set->array->len; i++)
|
||||
{
|
||||
option = g_ptr_array_index (set->array, i);
|
||||
|
||||
if (group == NULL ||
|
||||
(option->group != NULL && strcmp (group, option->group) == 0))
|
||||
func (option, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_set_foreach (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOptionSetFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
gtk_printer_option_set_foreach_in_group (set, NULL, func, user_data);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PRINTER_OPTION_SET_C__
|
||||
#include "gtkaliasdef.c"
|
96
gtk/gtkprinteroptionset.h
Normal file
96
gtk/gtkprinteroptionset.h
Normal file
@ -0,0 +1,96 @@
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprinteroptionset.h: printer option set
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINTER_OPTION_SET_H__
|
||||
#define __GTK_PRINTER_OPTION_SET_H__
|
||||
|
||||
/* This is a "semi-private" header; it is meant only for
|
||||
* alternate GtkPrintDialog backend modules; no stability guarantees
|
||||
* are made at this point
|
||||
*/
|
||||
#ifndef GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED
|
||||
#error "GtkPrintBackend is not supported API for general use"
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkprinteroption.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINTER_OPTION_SET (gtk_printer_option_set_get_type ())
|
||||
#define GTK_PRINTER_OPTION_SET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER_OPTION_SET, GtkPrinterOptionSet))
|
||||
#define GTK_IS_PRINTER_OPTION_SET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER_OPTION_SET))
|
||||
|
||||
typedef struct _GtkPrinterOptionSet GtkPrinterOptionSet;
|
||||
typedef struct _GtkPrinterOptionSetClass GtkPrinterOptionSetClass;
|
||||
|
||||
struct _GtkPrinterOptionSet
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
/*< private >*/
|
||||
GPtrArray *array;
|
||||
GHashTable *hash;
|
||||
};
|
||||
|
||||
struct _GtkPrinterOptionSetClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*changed) (GtkPrinterOptionSet *option);
|
||||
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
typedef void (*GtkPrinterOptionSetFunc) (GtkPrinterOption *option,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
GType gtk_printer_option_set_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkPrinterOptionSet *gtk_printer_option_set_new (void);
|
||||
void gtk_printer_option_set_add (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOption *option);
|
||||
void gtk_printer_option_set_remove (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOption *option);
|
||||
GtkPrinterOption * gtk_printer_option_set_lookup (GtkPrinterOptionSet *set,
|
||||
const char *name);
|
||||
void gtk_printer_option_set_foreach (GtkPrinterOptionSet *set,
|
||||
GtkPrinterOptionSetFunc func,
|
||||
gpointer user_data);
|
||||
void gtk_printer_option_set_clear_conflicts (GtkPrinterOptionSet *set);
|
||||
GList * gtk_printer_option_set_get_groups (GtkPrinterOptionSet *set);
|
||||
void gtk_printer_option_set_foreach_in_group (GtkPrinterOptionSet *set,
|
||||
const char *group,
|
||||
GtkPrinterOptionSetFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINTER_OPTION_SET_H__ */
|
617
gtk/gtkprinteroptionwidget.c
Normal file
617
gtk/gtkprinteroptionwidget.c
Normal file
@ -0,0 +1,617 @@
|
||||
/* GtkPrinterOptionWidget
|
||||
* Copyright (C) 2006 Alexander Larsson <alexl@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalignment.h"
|
||||
#include "gtkcheckbutton.h"
|
||||
#include "gtkcelllayout.h"
|
||||
#include "gtkcellrenderertext.h"
|
||||
#include "gtkcombobox.h"
|
||||
#include "gtkfilechooserbutton.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkliststore.h"
|
||||
#include "gtkstock.h"
|
||||
#include "gtktable.h"
|
||||
#include "gtktogglebutton.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include "gtkprinteroptionwidget.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define GTK_PRINTER_OPTION_WIDGET_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidgetPrivate))
|
||||
|
||||
static void gtk_printer_option_widget_finalize (GObject *object);
|
||||
|
||||
static void deconstruct_widgets (GtkPrinterOptionWidget *widget);
|
||||
static void construct_widgets (GtkPrinterOptionWidget *widget);
|
||||
static void update_widgets (GtkPrinterOptionWidget *widget);
|
||||
|
||||
struct GtkPrinterOptionWidgetPrivate
|
||||
{
|
||||
GtkPrinterOption *source;
|
||||
gulong source_changed_handler;
|
||||
|
||||
GtkWidget *check;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *entry;
|
||||
GtkWidget *image;
|
||||
GtkWidget *label;
|
||||
GtkWidget *filechooser;
|
||||
};
|
||||
|
||||
enum {
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SOURCE,
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkPrinterOptionWidget, gtk_printer_option_widget, GTK_TYPE_HBOX);
|
||||
|
||||
static void gtk_printer_option_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_printer_option_widget_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void
|
||||
gtk_printer_option_widget_class_init (GtkPrinterOptionWidgetClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GObjectClass *) class;
|
||||
widget_class = (GtkWidgetClass *) class;
|
||||
|
||||
object_class->finalize = gtk_printer_option_widget_finalize;
|
||||
object_class->set_property = gtk_printer_option_widget_set_property;
|
||||
object_class->get_property = gtk_printer_option_widget_get_property;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkPrinterOptionWidgetPrivate));
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrinterOptionWidgetClass, changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SOURCE,
|
||||
g_param_spec_object ("source",
|
||||
P_("Source option"),
|
||||
P_("The PrinterOption backing this widget"),
|
||||
GTK_TYPE_PRINTER_OPTION,
|
||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_widget_init (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
widget->priv = GTK_PRINTER_OPTION_WIDGET_GET_PRIVATE (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_widget_finalize (GObject *object)
|
||||
{
|
||||
GtkPrinterOptionWidget *widget;
|
||||
|
||||
widget = GTK_PRINTER_OPTION_WIDGET (object);
|
||||
|
||||
if (widget->priv->source)
|
||||
{
|
||||
g_object_unref (widget->priv->source);
|
||||
widget->priv->source = NULL;
|
||||
}
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize)
|
||||
G_OBJECT_CLASS (gtk_printer_option_widget_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_widget_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPrinterOptionWidget *widget;
|
||||
|
||||
widget = GTK_PRINTER_OPTION_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SOURCE:
|
||||
gtk_printer_option_widget_set_source (widget, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_option_widget_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPrinterOptionWidget *widget;
|
||||
|
||||
widget = GTK_PRINTER_OPTION_WIDGET (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SOURCE:
|
||||
g_value_set_object (value, widget->priv->source);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
emit_changed (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
g_signal_emit (widget, signals[CHANGED], 0);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_printer_option_widget_new (GtkPrinterOption *source)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_PRINTER_OPTION_WIDGET, "source", source, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
source_changed_cb (GtkPrinterOption *source,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
update_widgets (widget);
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *widget,
|
||||
GtkPrinterOption *source)
|
||||
{
|
||||
if (source)
|
||||
g_object_ref (source);
|
||||
|
||||
if (widget->priv->source)
|
||||
{
|
||||
g_signal_handler_disconnect (widget->priv->source,
|
||||
widget->priv->source_changed_handler);
|
||||
g_object_unref (widget->priv->source);
|
||||
}
|
||||
|
||||
widget->priv->source = source;
|
||||
|
||||
if (source)
|
||||
widget->priv->source_changed_handler =
|
||||
g_signal_connect (source, "changed", G_CALLBACK (source_changed_cb), widget);
|
||||
|
||||
construct_widgets (widget);
|
||||
update_widgets (widget);
|
||||
|
||||
g_object_notify (G_OBJECT (widget), "source");
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
combo_box_new (void)
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
GtkCellRenderer *cell;
|
||||
GtkListStore *store;
|
||||
|
||||
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
|
||||
combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
|
||||
"text", 0,
|
||||
NULL);
|
||||
|
||||
return combo_box;
|
||||
}
|
||||
|
||||
static void
|
||||
combo_box_append (GtkWidget *combo,
|
||||
const char *display_text,
|
||||
const char *value)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
GtkTreeIter iter;
|
||||
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
||||
store = GTK_LIST_STORE (model);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
0, display_text,
|
||||
1, value,
|
||||
-1);
|
||||
}
|
||||
|
||||
struct ComboSet {
|
||||
GtkComboBox *combo;
|
||||
const char *value;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
set_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
struct ComboSet *set_data = data;
|
||||
gboolean found;
|
||||
char *value;
|
||||
|
||||
gtk_tree_model_get (model, iter, 1, &value, -1);
|
||||
found = (strcmp (value, set_data->value) == 0);
|
||||
g_free (value);
|
||||
|
||||
if (found)
|
||||
gtk_combo_box_set_active_iter (set_data->combo, iter);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
static void
|
||||
combo_box_set (GtkWidget *combo,
|
||||
const char *value)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
struct ComboSet set_data;
|
||||
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
||||
store = GTK_LIST_STORE (model);
|
||||
|
||||
set_data.combo = GTK_COMBO_BOX (combo);
|
||||
set_data.value = value;
|
||||
gtk_tree_model_foreach (model, set_cb, &set_data);
|
||||
}
|
||||
|
||||
static char *
|
||||
combo_box_get (GtkWidget *combo)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
char *val;
|
||||
GtkTreeIter iter;
|
||||
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
||||
|
||||
val = NULL;
|
||||
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter))
|
||||
gtk_tree_model_get (model, &iter,
|
||||
1, &val,
|
||||
-1);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
deconstruct_widgets (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
if (widget->priv->check)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->check);
|
||||
widget->priv->check = NULL;
|
||||
}
|
||||
|
||||
if (widget->priv->combo)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->combo);
|
||||
widget->priv->combo = NULL;
|
||||
}
|
||||
|
||||
if (widget->priv->entry)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->entry);
|
||||
widget->priv->entry = NULL;
|
||||
}
|
||||
|
||||
/* make sure entry and combo are destroyed first */
|
||||
/* as we use the two of them to create the filechooser */
|
||||
if (widget->priv->filechooser)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->filechooser);
|
||||
widget->priv->filechooser = NULL;
|
||||
}
|
||||
|
||||
if (widget->priv->image)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->image);
|
||||
widget->priv->image = NULL;
|
||||
}
|
||||
|
||||
if (widget->priv->label)
|
||||
{
|
||||
gtk_widget_destroy (widget->priv->label);
|
||||
widget->priv->label = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_toggled_cb (GtkToggleButton *toggle_button,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
|
||||
gtk_printer_option_set_boolean (widget->priv->source,
|
||||
gtk_toggle_button_get_active (toggle_button));
|
||||
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
filesave_changed_cb (GtkWidget *w,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
char *value;
|
||||
char *directory;
|
||||
const char *file;
|
||||
|
||||
/* combine the value of the chooser with the value of the entry */
|
||||
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
|
||||
|
||||
/* TODO: how do we support nonlocal file systems? */
|
||||
directory = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget->priv->combo));
|
||||
file = gtk_entry_get_text (GTK_ENTRY (widget->priv->entry));
|
||||
|
||||
value = g_build_filename (directory, file, NULL);
|
||||
|
||||
if (value)
|
||||
gtk_printer_option_set (widget->priv->source, value);
|
||||
|
||||
g_free (directory);
|
||||
g_free (value);
|
||||
|
||||
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
combo_changed_cb (GtkWidget *combo,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
char *value;
|
||||
|
||||
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
|
||||
value = combo_box_get (combo);
|
||||
if (value)
|
||||
gtk_printer_option_set (widget->priv->source, value);
|
||||
g_free (value);
|
||||
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
entry_changed_cb (GtkWidget *entry,
|
||||
GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
g_signal_handler_block (widget->priv->source, widget->priv->source_changed_handler);
|
||||
value = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (value)
|
||||
gtk_printer_option_set (widget->priv->source, value);
|
||||
g_signal_handler_unblock (widget->priv->source, widget->priv->source_changed_handler);
|
||||
emit_changed (widget);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
construct_widgets (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOption *source;
|
||||
char *text;
|
||||
int i;
|
||||
|
||||
source = widget->priv->source;
|
||||
|
||||
deconstruct_widgets (widget);
|
||||
|
||||
if (source == NULL)
|
||||
{
|
||||
widget->priv->combo = combo_box_new ();
|
||||
combo_box_append (widget->priv->combo,_("Not available"), "None");
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (widget->priv->combo), 0);
|
||||
gtk_widget_set_sensitive (widget->priv->combo, FALSE);
|
||||
gtk_widget_show (widget->priv->combo);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->combo, TRUE, TRUE, 0);
|
||||
}
|
||||
else switch (source->type)
|
||||
{
|
||||
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
|
||||
widget->priv->check = gtk_check_button_new_with_mnemonic (source->display_text);
|
||||
g_signal_connect (widget->priv->check, "toggled", G_CALLBACK (check_toggled_cb), widget);
|
||||
gtk_widget_show (widget->priv->check);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->check, TRUE, TRUE, 0);
|
||||
break;
|
||||
case GTK_PRINTER_OPTION_TYPE_PICKONE:
|
||||
widget->priv->combo = combo_box_new ();
|
||||
for (i = 0; i < source->num_choices; i++)
|
||||
combo_box_append (widget->priv->combo,
|
||||
source->choices_display[i],
|
||||
source->choices[i]);
|
||||
gtk_widget_show (widget->priv->combo);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->combo, TRUE, TRUE, 0);
|
||||
g_signal_connect (widget->priv->combo, "changed", G_CALLBACK (combo_changed_cb), widget);
|
||||
|
||||
text = g_strdup_printf ("%s: ", source->display_text);
|
||||
widget->priv->label = gtk_label_new_with_mnemonic (text);
|
||||
g_free (text);
|
||||
gtk_widget_show (widget->priv->label);
|
||||
break;
|
||||
case GTK_PRINTER_OPTION_TYPE_STRING:
|
||||
widget->priv->entry = gtk_entry_new ();
|
||||
gtk_widget_show (widget->priv->entry);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->entry, TRUE, TRUE, 0);
|
||||
g_signal_connect (widget->priv->entry, "changed", G_CALLBACK (entry_changed_cb), widget);
|
||||
|
||||
text = g_strdup_printf ("%s: ", source->display_text);
|
||||
widget->priv->label = gtk_label_new_with_mnemonic (text);
|
||||
g_free (text);
|
||||
gtk_widget_show (widget->priv->label);
|
||||
|
||||
break;
|
||||
|
||||
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *align;
|
||||
|
||||
widget->priv->filechooser = gtk_table_new (2, 2, FALSE);
|
||||
|
||||
/* TODO: make this a gtkfilechooserentry once we move to GTK */
|
||||
widget->priv->entry = gtk_entry_new ();
|
||||
widget->priv->combo = gtk_file_chooser_button_new ("Print to PDF",
|
||||
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
||||
|
||||
align = gtk_alignment_new (0, 0.5, 0, 0);
|
||||
label = gtk_label_new ("Name:");
|
||||
gtk_container_add (GTK_CONTAINER (align), label);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), align,
|
||||
0, 1, 0, 1, GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), widget->priv->entry,
|
||||
1, 2, 0, 1, GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
align = gtk_alignment_new (0, 0.5, 0, 0);
|
||||
label = gtk_label_new ("Save in folder:");
|
||||
gtk_container_add (GTK_CONTAINER (align), label);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), align,
|
||||
0, 1, 1, 2, GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (widget->priv->filechooser), widget->priv->combo,
|
||||
1, 2, 1, 2, GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
gtk_widget_show_all (widget->priv->filechooser);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->filechooser, TRUE, TRUE, 0);
|
||||
|
||||
g_signal_connect (widget->priv->entry, "changed", G_CALLBACK (filesave_changed_cb), widget);
|
||||
|
||||
g_signal_connect (widget->priv->combo, "current-folder-changed", G_CALLBACK (filesave_changed_cb), widget);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
widget->priv->image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU);
|
||||
gtk_box_pack_start (GTK_BOX (widget), widget->priv->image, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
update_widgets (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
GtkPrinterOption *source;
|
||||
|
||||
source = widget->priv->source;
|
||||
|
||||
if (source == NULL)
|
||||
{
|
||||
gtk_widget_hide (widget->priv->image);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (source->type)
|
||||
{
|
||||
case GTK_PRINTER_OPTION_TYPE_BOOLEAN:
|
||||
if (strcmp (source->value, "True") == 0)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->priv->check), TRUE);
|
||||
else
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget->priv->check), FALSE);
|
||||
break;
|
||||
case GTK_PRINTER_OPTION_TYPE_PICKONE:
|
||||
combo_box_set (widget->priv->combo, source->value);
|
||||
break;
|
||||
case GTK_PRINTER_OPTION_TYPE_STRING:
|
||||
gtk_entry_set_text (GTK_ENTRY (widget->priv->entry), source->value);
|
||||
break;
|
||||
case GTK_PRINTER_OPTION_TYPE_FILESAVE:
|
||||
{
|
||||
char *basename = g_path_get_basename (source->value);
|
||||
char *dirname = g_path_get_dirname (source->value);
|
||||
gtk_entry_set_text (GTK_ENTRY (widget->priv->entry), basename);
|
||||
if (g_path_is_absolute (dirname))
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget->priv->combo),
|
||||
dirname);
|
||||
g_free (basename);
|
||||
g_free (dirname);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (source->has_conflict)
|
||||
gtk_widget_show (widget->priv->image);
|
||||
else
|
||||
gtk_widget_hide (widget->priv->image);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_printer_option_widget_has_external_label (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
return widget->priv->label != NULL;
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
return widget->priv->label;
|
||||
}
|
||||
|
||||
const char *
|
||||
gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *widget)
|
||||
{
|
||||
if (widget->priv->source)
|
||||
return widget->priv->source->value;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
#define __GTK_PRINTER_OPTION_WIDGET_C__
|
||||
#include "gtkaliasdef.c"
|
64
gtk/gtkprinteroptionwidget.h
Normal file
64
gtk/gtkprinteroptionwidget.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* GtkPrinterOptionWidget
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINTER_OPTION_WIDGET_H__
|
||||
#define __GTK_PRINTER_OPTION_WIDGET_H__
|
||||
|
||||
#include "gtkprinteroption.h"
|
||||
#include "gtkhbox.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINTER_OPTION_WIDGET (gtk_printer_option_widget_get_type ())
|
||||
#define GTK_PRINTER_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidget))
|
||||
#define GTK_PRINTER_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidgetClass))
|
||||
#define GTK_IS_PRINTER_OPTION_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER_OPTION_WIDGET))
|
||||
#define GTK_IS_PRINTER_OPTION_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINTER_OPTION_WIDGET))
|
||||
#define GTK_PRINTER_OPTION_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINTER_OPTION_WIDGET, GtkPrinterOptionWidgetClass))
|
||||
|
||||
|
||||
typedef struct _GtkPrinterOptionWidget GtkPrinterOptionWidget;
|
||||
typedef struct _GtkPrinterOptionWidgetClass GtkPrinterOptionWidgetClass;
|
||||
typedef struct GtkPrinterOptionWidgetPrivate GtkPrinterOptionWidgetPrivate;
|
||||
|
||||
struct _GtkPrinterOptionWidget
|
||||
{
|
||||
GtkHBox parent_instance;
|
||||
|
||||
GtkPrinterOptionWidgetPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkPrinterOptionWidgetClass
|
||||
{
|
||||
GtkHBoxClass parent_class;
|
||||
|
||||
void (*changed) (GtkPrinterOptionWidget *widget);
|
||||
};
|
||||
|
||||
GType gtk_printer_option_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gtk_printer_option_widget_new (GtkPrinterOption *source);
|
||||
void gtk_printer_option_widget_set_source (GtkPrinterOptionWidget *setting,
|
||||
GtkPrinterOption *source);
|
||||
gboolean gtk_printer_option_widget_has_external_label (GtkPrinterOptionWidget *setting);
|
||||
GtkWidget * gtk_printer_option_widget_get_external_label (GtkPrinterOptionWidget *setting);
|
||||
const char *gtk_printer_option_widget_get_value (GtkPrinterOptionWidget *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINTER_OPTION_WIDGET_H__ */
|
472
gtk/gtkprintjob.c
Normal file
472
gtk/gtkprintjob.c
Normal file
@ -0,0 +1,472 @@
|
||||
/* GtkPrintJob
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
#include "gtkintl.h"
|
||||
#include "gtkprivate.h"
|
||||
|
||||
#include "gtkprintjob.h"
|
||||
#include "gtkprinter.h"
|
||||
#include "gtkprintbackend.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
struct _GtkPrintJobPrivate
|
||||
{
|
||||
gchar *title;
|
||||
|
||||
int spool_file_fd;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
GtkPrintStatus status;
|
||||
GtkPrintBackend *backend;
|
||||
GtkPrinter *printer;
|
||||
GtkPrintSettings *settings;
|
||||
GtkPageSetup *page_setup;
|
||||
|
||||
gint printer_set : 1;
|
||||
gint page_setup_set : 1;
|
||||
gint settings_set : 1;
|
||||
};
|
||||
|
||||
|
||||
#define GTK_PRINT_JOB_GET_PRIVATE(o) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_PRINT_JOB, GtkPrintJobPrivate))
|
||||
|
||||
static void gtk_print_job_finalize (GObject *object);
|
||||
static void gtk_print_job_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_print_job_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static GObject* gtk_print_job_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_params);
|
||||
|
||||
enum {
|
||||
STATUS_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
GTK_PRINT_JOB_PROP_TITLE,
|
||||
GTK_PRINT_JOB_PROP_PRINTER,
|
||||
GTK_PRINT_JOB_PROP_PAGE_SETUP,
|
||||
GTK_PRINT_JOB_PROP_SETTINGS
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkPrintJob, gtk_print_job, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
gtk_print_job_class_init (GtkPrintJobClass *class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
object_class = (GObjectClass *) class;
|
||||
|
||||
object_class->finalize = gtk_print_job_finalize;
|
||||
object_class->constructor = gtk_print_job_constructor;
|
||||
object_class->set_property = gtk_print_job_set_property;
|
||||
object_class->get_property = gtk_print_job_get_property;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkPrintJobPrivate));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
GTK_PRINT_JOB_PROP_TITLE,
|
||||
g_param_spec_string ("title",
|
||||
P_("Title"),
|
||||
P_("Title of the print job"),
|
||||
NULL,
|
||||
GTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
GTK_PRINT_JOB_PROP_PRINTER,
|
||||
g_param_spec_object ("printer",
|
||||
P_("Printer"),
|
||||
P_("Printer to print the job to"),
|
||||
GTK_TYPE_PRINTER,
|
||||
GTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
GTK_PRINT_JOB_PROP_SETTINGS,
|
||||
g_param_spec_object ("settings",
|
||||
P_("Settings"),
|
||||
P_("Printer settings"),
|
||||
GTK_TYPE_PRINT_SETTINGS,
|
||||
GTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property (G_OBJECT_CLASS (class),
|
||||
GTK_PRINT_JOB_PROP_PAGE_SETUP,
|
||||
g_param_spec_object ("page-setup",
|
||||
P_("Page Setup"),
|
||||
P_("Page Setup"),
|
||||
GTK_TYPE_PAGE_SETUP,
|
||||
GTK_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
signals[STATUS_CHANGED] =
|
||||
g_signal_new ("status-changed",
|
||||
G_TYPE_FROM_CLASS (class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkPrintJobClass, status_changed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_job_init (GtkPrintJob *print_job)
|
||||
{
|
||||
print_job->priv = GTK_PRINT_JOB_GET_PRIVATE (print_job);
|
||||
print_job->priv->spool_file_fd = -1;
|
||||
|
||||
print_job->priv->title = g_strdup ("");
|
||||
print_job->priv->surface = NULL;
|
||||
print_job->priv->backend = NULL;
|
||||
print_job->priv->printer = NULL;
|
||||
|
||||
print_job->priv->printer_set = FALSE;
|
||||
print_job->priv->settings_set = FALSE;
|
||||
print_job->priv->page_setup_set = FALSE;
|
||||
print_job->priv->status = GTK_PRINT_STATUS_INITIAL;
|
||||
|
||||
print_job->print_pages = GTK_PRINT_PAGES_ALL;
|
||||
print_job->page_ranges = NULL;
|
||||
print_job->num_page_ranges = 0;
|
||||
print_job->collate = FALSE;
|
||||
print_job->reverse = FALSE;
|
||||
print_job->num_copies = 1;
|
||||
print_job->scale = 1.0;
|
||||
print_job->page_set = GTK_PAGE_SET_ALL;
|
||||
print_job->rotate_to_orientation = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static GObject*
|
||||
gtk_print_job_constructor (GType type,
|
||||
guint n_construct_properties,
|
||||
GObjectConstructParam *construct_params)
|
||||
{
|
||||
GtkPrintJob *job;
|
||||
GObject *object;
|
||||
|
||||
object =
|
||||
G_OBJECT_CLASS (gtk_print_job_parent_class)->constructor (type,
|
||||
n_construct_properties,
|
||||
construct_params);
|
||||
|
||||
job = GTK_PRINT_JOB (object);
|
||||
|
||||
g_assert (job->priv->printer_set &&
|
||||
job->priv->settings_set &&
|
||||
job->priv->page_setup_set);
|
||||
|
||||
_gtk_printer_prepare_for_print (job->priv->printer,
|
||||
job,
|
||||
job->priv->settings,
|
||||
job->priv->page_setup);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_print_job_finalize (GObject *object)
|
||||
{
|
||||
GtkPrintJob *print_job;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
|
||||
print_job = GTK_PRINT_JOB (object);
|
||||
|
||||
if (print_job->priv->spool_file_fd > 0)
|
||||
{
|
||||
close (print_job->priv->spool_file_fd);
|
||||
print_job->priv->spool_file_fd = -1;
|
||||
}
|
||||
|
||||
if (print_job->priv->backend)
|
||||
g_object_unref (G_OBJECT (print_job->priv->backend));
|
||||
|
||||
if (print_job->priv->printer)
|
||||
g_object_unref (G_OBJECT (print_job->priv->printer));
|
||||
|
||||
if (print_job->priv->surface)
|
||||
cairo_surface_destroy (print_job->priv->surface);
|
||||
|
||||
if (print_job->priv->settings)
|
||||
g_object_unref (print_job->priv->settings);
|
||||
|
||||
if (print_job->priv->page_setup)
|
||||
g_object_unref (print_job->priv->page_setup);
|
||||
|
||||
g_free (print_job->page_ranges);
|
||||
print_job->page_ranges = NULL;
|
||||
|
||||
g_free (print_job->priv->title);
|
||||
print_job->priv->title = NULL;
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize)
|
||||
G_OBJECT_CLASS (gtk_print_job_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_job_new:
|
||||
*
|
||||
* Creates a new #GtkPrintJob.
|
||||
*
|
||||
* Return value: a new #GtkPrintJob
|
||||
*
|
||||
* Since: 2.8
|
||||
**/
|
||||
GtkPrintJob *
|
||||
gtk_print_job_new (const gchar *title,
|
||||
GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
GObject *result;
|
||||
result = g_object_new (GTK_TYPE_PRINT_JOB,
|
||||
"title", title,
|
||||
"printer", printer,
|
||||
"settings", settings,
|
||||
"page-setup", page_setup,
|
||||
NULL);
|
||||
return (GtkPrintJob *) result;
|
||||
}
|
||||
|
||||
GtkPrintSettings *
|
||||
gtk_print_job_get_settings (GtkPrintJob *print_job)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
|
||||
|
||||
return print_job->priv->settings;
|
||||
}
|
||||
|
||||
GtkPrinter *
|
||||
gtk_print_job_get_printer (GtkPrintJob *print_job)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
|
||||
|
||||
return print_job->priv->printer;
|
||||
}
|
||||
|
||||
const char *
|
||||
gtk_print_job_get_title (GtkPrintJob *print_job)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), NULL);
|
||||
|
||||
return print_job->priv->title;
|
||||
}
|
||||
|
||||
GtkPrintStatus
|
||||
gtk_print_job_get_status (GtkPrintJob *print_job)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), GTK_PRINT_STATUS_FINISHED);
|
||||
|
||||
return print_job->priv->status;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_print_job_set_status (GtkPrintJob *job,
|
||||
GtkPrintStatus status)
|
||||
{
|
||||
if (job->priv->status == status)
|
||||
return;
|
||||
|
||||
job->priv->status = status;
|
||||
g_signal_emit (job, signals[STATUS_CHANGED], 0);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_print_job_set_source_file (GtkPrintJob *job,
|
||||
const char *filename,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), FALSE);
|
||||
|
||||
job->priv->spool_file_fd = g_open (filename, O_RDONLY|O_BINARY);
|
||||
if (job->priv->spool_file_fd < 0)
|
||||
{
|
||||
gchar *display_filename = g_filename_display_name (filename);
|
||||
int save_errno = errno;
|
||||
|
||||
g_set_error (error,
|
||||
G_FILE_ERROR,
|
||||
g_file_error_from_errno (save_errno),
|
||||
_("Failed to open file '%s': %s"),
|
||||
display_filename,
|
||||
g_strerror (save_errno));
|
||||
|
||||
g_free (display_filename);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
gtk_print_job_get_surface (GtkPrintJob *job,
|
||||
GError **error)
|
||||
{
|
||||
char *filename;
|
||||
double width, height;
|
||||
GtkPaperSize *paper_size;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (job), NULL);
|
||||
|
||||
if (job->priv->surface)
|
||||
return job->priv->surface;
|
||||
|
||||
job->priv->spool_file_fd = g_file_open_tmp ("gtkprint_XXXXXX",
|
||||
&filename,
|
||||
error);
|
||||
if (job->priv->spool_file_fd == -1)
|
||||
return NULL;
|
||||
|
||||
fchmod (job->priv->spool_file_fd, S_IRUSR | S_IWUSR);
|
||||
unlink (filename);
|
||||
|
||||
paper_size = gtk_page_setup_get_paper_size (job->priv->page_setup);
|
||||
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS);
|
||||
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS);
|
||||
|
||||
job->priv->surface = _gtk_printer_create_cairo_surface (job->priv->printer,
|
||||
width, height,
|
||||
job->priv->spool_file_fd);
|
||||
|
||||
return job->priv->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_job_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
|
||||
{
|
||||
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
||||
GtkPrintSettings *settings;
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case GTK_PRINT_JOB_PROP_TITLE:
|
||||
job->priv->title = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case GTK_PRINT_JOB_PROP_PRINTER:
|
||||
job->priv->printer = GTK_PRINTER (g_value_dup_object (value));
|
||||
job->priv->printer_set = TRUE;
|
||||
job->priv->backend = g_object_ref (gtk_printer_get_backend (job->priv->printer));
|
||||
break;
|
||||
|
||||
case GTK_PRINT_JOB_PROP_PAGE_SETUP:
|
||||
job->priv->page_setup = GTK_PAGE_SETUP (g_value_dup_object (value));
|
||||
job->priv->page_setup_set = TRUE;
|
||||
break;
|
||||
|
||||
case GTK_PRINT_JOB_PROP_SETTINGS:
|
||||
/* We save a copy of the settings since we modify
|
||||
* if when preparing the printer job. */
|
||||
settings = GTK_PRINT_SETTINGS (g_value_get_object (value));
|
||||
job->priv->settings = gtk_print_settings_copy (settings);
|
||||
job->priv->settings_set = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_job_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkPrintJob *job = GTK_PRINT_JOB (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case GTK_PRINT_JOB_PROP_TITLE:
|
||||
g_value_set_string (value, job->priv->title);
|
||||
break;
|
||||
case GTK_PRINT_JOB_PROP_PRINTER:
|
||||
g_value_set_object (value, job->priv->printer);
|
||||
break;
|
||||
case GTK_PRINT_JOB_PROP_SETTINGS:
|
||||
g_value_set_object (value, job->priv->settings);
|
||||
break;
|
||||
case GTK_PRINT_JOB_PROP_PAGE_SETUP:
|
||||
g_value_set_object (value, job->priv->page_setup);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_print_job_send (GtkPrintJob *print_job,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_PRINT_JOB (print_job), FALSE);
|
||||
g_return_val_if_fail (print_job->priv->spool_file_fd > 0, FALSE);
|
||||
|
||||
gtk_print_job_set_status (print_job, GTK_PRINT_STATUS_SENDING_DATA);
|
||||
lseek (print_job->priv->spool_file_fd, 0, SEEK_SET);
|
||||
gtk_print_backend_print_stream (print_job->priv->backend,
|
||||
print_job,
|
||||
print_job->priv->spool_file_fd,
|
||||
callback,
|
||||
user_data,
|
||||
dnotify);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define __GTK_PRINT_JOB_C__
|
||||
#include "gtkaliasdef.c"
|
106
gtk/gtkprintjob.h
Normal file
106
gtk/gtkprintjob.h
Normal file
@ -0,0 +1,106 @@
|
||||
/* GtkPrintJob
|
||||
* Copyright (C) 2006 Red Hat,Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINT_JOB_H__
|
||||
#define __GTK_PRINT_JOB_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
|
||||
#include <gtk/gtkprinter.h>
|
||||
#include <gtk/gtkprintoperation.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_JOB (gtk_print_job_get_type ())
|
||||
#define GTK_PRINT_JOB(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_JOB, GtkPrintJob))
|
||||
#define GTK_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_JOB, GtkPrintJobClass))
|
||||
#define GTK_IS_PRINT_JOB(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_JOB))
|
||||
#define GTK_IS_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_JOB))
|
||||
#define GTK_PRINT_JOB_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_JOB, GtkPrintJobClass))
|
||||
|
||||
|
||||
typedef struct _GtkPrintJobClass GtkPrintJobClass;
|
||||
typedef struct _GtkPrintJobPrivate GtkPrintJobPrivate;
|
||||
|
||||
typedef void (*GtkPrintJobCompleteFunc) (GtkPrintJob *print_job,
|
||||
void *user_data,
|
||||
GError *error);
|
||||
|
||||
struct _GtkPrinter;
|
||||
|
||||
struct _GtkPrintJob
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrintJobPrivate *priv;
|
||||
|
||||
/* Settings the client has to implement:
|
||||
* (These are read-only, set at initialization)
|
||||
*/
|
||||
GtkPrintPages print_pages;
|
||||
GtkPageRange *page_ranges;
|
||||
int num_page_ranges;
|
||||
GtkPageSet page_set;
|
||||
int num_copies;
|
||||
gboolean collate;
|
||||
gboolean reverse;
|
||||
double scale;
|
||||
gboolean rotate_to_orientation;
|
||||
};
|
||||
|
||||
struct _GtkPrintJobClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*status_changed) (GtkPrintJob *job);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
GType gtk_print_job_get_type (void) G_GNUC_CONST;
|
||||
GtkPrintJob *gtk_print_job_new (const gchar *title,
|
||||
GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
GtkPrintSettings *gtk_print_job_get_settings (GtkPrintJob *print_job);
|
||||
GtkPrinter *gtk_print_job_get_printer (GtkPrintJob *print_job);
|
||||
const char *gtk_print_job_get_title (GtkPrintJob *print_job);
|
||||
GtkPrintStatus gtk_print_job_get_status (GtkPrintJob *print_job);
|
||||
|
||||
gboolean gtk_print_job_set_source_file (GtkPrintJob *print_job,
|
||||
const char *filename,
|
||||
GError **error);
|
||||
cairo_surface_t *gtk_print_job_get_surface (GtkPrintJob *print_job,
|
||||
GError **error);
|
||||
gboolean gtk_print_job_send (GtkPrintJob *print_job,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify,
|
||||
GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_JOB_H__ */
|
87
gtk/gtkprintoperation-private.h
Normal file
87
gtk/gtkprintoperation-private.h
Normal file
@ -0,0 +1,87 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintoperation.h: Print Operation
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_OPERATION_PRIVATE_H__
|
||||
#define __GTK_PRINT_OPERATION_PRIVATE_H__
|
||||
|
||||
#include "gtkprintoperation.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _GtkPrintOperationPrivate
|
||||
{
|
||||
GtkPrintStatus status;
|
||||
char *status_string;
|
||||
GtkPageSetup *default_page_setup;
|
||||
GtkPrintSettings *print_settings;
|
||||
char *job_name;
|
||||
int nr_of_pages;
|
||||
int current_page;
|
||||
gboolean use_full_page;
|
||||
GtkUnit unit;
|
||||
gboolean show_dialog;
|
||||
char *pdf_target;
|
||||
|
||||
/* Data for the print job: */
|
||||
cairo_surface_t *surface;
|
||||
double dpi_x, dpi_y;
|
||||
|
||||
GtkPrintPages print_pages;
|
||||
GtkPageRange *page_ranges;
|
||||
int num_page_ranges;
|
||||
|
||||
int manual_num_copies;
|
||||
gboolean manual_collation;
|
||||
gboolean manual_reverse;
|
||||
gboolean manual_orientation;
|
||||
double manual_scale;
|
||||
GtkPageSet manual_page_set;
|
||||
|
||||
void *platform_data;
|
||||
|
||||
void (*start_page) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *print_context,
|
||||
GtkPageSetup *page_setup);
|
||||
void (*end_page) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *print_context);
|
||||
void (*end_run) (GtkPrintOperation *operation);
|
||||
GDestroyNotify free_platform_data;
|
||||
};
|
||||
|
||||
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
|
||||
GtkWindow *parent,
|
||||
gboolean *do_print,
|
||||
GError **error);
|
||||
|
||||
void _gtk_print_operation_set_status (GtkPrintOperation *op,
|
||||
GtkPrintStatus status,
|
||||
const char *string);
|
||||
|
||||
/* GtkPrintContext private functions: */
|
||||
|
||||
GtkPrintContext *_gtk_print_context_new (GtkPrintOperation *op);
|
||||
void _gtk_print_context_set_page_setup (GtkPrintContext *context,
|
||||
GtkPageSetup *page_setup);
|
||||
void _gtk_print_context_translate_into_margin (GtkPrintContext *context);
|
||||
void _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_OPERATION_PRIVATE_H__ */
|
243
gtk/gtkprintoperation-unix.c
Normal file
243
gtk/gtkprintoperation-unix.c
Normal file
@ -0,0 +1,243 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintoperation-unix.c: Print Operation Details for Unix and Unix like platforms
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gtkprintoperation-private.h"
|
||||
#include "gtkmarshal.h"
|
||||
#include "gtkmessagedialog.h"
|
||||
|
||||
#include "gtkprintunixdialog.h"
|
||||
#include "gtkpagesetupunixdialog.h"
|
||||
#include "gtkprintbackend.h"
|
||||
#include "gtkprinter.h"
|
||||
#include "gtkprintjob.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
typedef struct {
|
||||
GtkPrintJob *job; /* the job we are sending to the printer */
|
||||
gulong job_status_changed_tag;
|
||||
GtkWindow *parent; /* parent window just in case we need to throw error dialogs */
|
||||
} GtkPrintOperationUnix;
|
||||
|
||||
static void
|
||||
unix_start_page (GtkPrintOperation *op,
|
||||
GtkPrintContext *print_context,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
unix_end_page (GtkPrintOperation *op,
|
||||
GtkPrintContext *print_context)
|
||||
{
|
||||
cairo_t *cr;
|
||||
|
||||
cr = gtk_print_context_get_cairo (print_context);
|
||||
cairo_show_page (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
op_unix_free (GtkPrintOperationUnix *op_unix)
|
||||
{
|
||||
if (op_unix->job)
|
||||
{
|
||||
g_signal_handler_disconnect (op_unix->job,
|
||||
op_unix->job_status_changed_tag);
|
||||
g_object_unref (op_unix->job);
|
||||
}
|
||||
|
||||
g_free (op_unix);
|
||||
}
|
||||
|
||||
static void
|
||||
unix_finish_send (GtkPrintJob *job,
|
||||
void *user_data,
|
||||
GError *error)
|
||||
{
|
||||
GtkPrintOperationUnix *op_unix;
|
||||
GtkWindow *parent;
|
||||
|
||||
op_unix = (GtkPrintOperationUnix *) user_data;
|
||||
|
||||
parent = op_unix->parent;
|
||||
|
||||
if (error != NULL)
|
||||
{
|
||||
GtkWidget *edialog;
|
||||
edialog = gtk_message_dialog_new (parent,
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error printing: %s",
|
||||
error->message);
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (edialog));
|
||||
gtk_widget_destroy (edialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unix_end_run (GtkPrintOperation *op)
|
||||
{
|
||||
GtkPrintOperationUnix *op_unix = op->priv->platform_data;
|
||||
|
||||
/* TODO: Check for error */
|
||||
gtk_print_job_send (op_unix->job,
|
||||
unix_finish_send,
|
||||
op_unix, NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
job_status_changed_cb (GtkPrintJob *job, GtkPrintOperation *op)
|
||||
{
|
||||
_gtk_print_operation_set_status (op, gtk_print_job_get_status (job), NULL);
|
||||
}
|
||||
|
||||
GtkPrintOperationResult
|
||||
_gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *op,
|
||||
GtkWindow *parent,
|
||||
gboolean *do_print,
|
||||
GError **error)
|
||||
{
|
||||
GtkWidget *pd;
|
||||
GtkPrintOperationResult result;
|
||||
GtkPageSetup *page_setup;
|
||||
|
||||
result = GTK_PRINT_OPERATION_RESULT_CANCEL;
|
||||
|
||||
if (op->priv->default_page_setup)
|
||||
page_setup = gtk_page_setup_copy (op->priv->default_page_setup);
|
||||
else
|
||||
page_setup = gtk_page_setup_new ();
|
||||
|
||||
pd = gtk_print_unix_dialog_new (NULL, parent);
|
||||
|
||||
if (op->priv->print_settings)
|
||||
gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG (pd),
|
||||
op->priv->print_settings);
|
||||
|
||||
gtk_print_unix_dialog_set_page_setup (GTK_PRINT_UNIX_DIALOG (pd), page_setup);
|
||||
|
||||
*do_print = FALSE;
|
||||
if (gtk_dialog_run (GTK_DIALOG (pd)) == GTK_RESPONSE_OK)
|
||||
{
|
||||
GtkPrintOperationUnix *op_unix;
|
||||
GtkPrinter *printer;
|
||||
GtkPrintSettings *settings;
|
||||
|
||||
result = GTK_PRINT_OPERATION_RESULT_APPLY;
|
||||
|
||||
printer = gtk_print_unix_dialog_get_selected_printer (GTK_PRINT_UNIX_DIALOG (pd));
|
||||
if (printer == NULL)
|
||||
goto out;
|
||||
|
||||
*do_print = TRUE;
|
||||
|
||||
settings = gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (pd));
|
||||
gtk_print_operation_set_print_settings (op, settings);
|
||||
|
||||
op_unix = g_new0 (GtkPrintOperationUnix, 1);
|
||||
op_unix->job = gtk_print_job_new (op->priv->job_name,
|
||||
printer,
|
||||
settings,
|
||||
page_setup);
|
||||
g_object_unref (settings);
|
||||
|
||||
op->priv->surface = gtk_print_job_get_surface (op_unix->job, error);
|
||||
if (op->priv->surface == NULL)
|
||||
{
|
||||
*do_print = FALSE;
|
||||
op_unix_free (op_unix);
|
||||
result = GTK_PRINT_OPERATION_RESULT_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
_gtk_print_operation_set_status (op, gtk_print_job_get_status (op_unix->job), NULL);
|
||||
op_unix->job_status_changed_tag =
|
||||
g_signal_connect (op_unix->job, "status_changed",
|
||||
G_CALLBACK (job_status_changed_cb), op);
|
||||
|
||||
op_unix->parent = parent;
|
||||
|
||||
op->priv->dpi_x = 72;
|
||||
op->priv->dpi_y = 72;
|
||||
|
||||
op->priv->platform_data = op_unix;
|
||||
op->priv->free_platform_data = (GDestroyNotify) op_unix_free;
|
||||
|
||||
op->priv->print_pages = op_unix->job->print_pages;
|
||||
op->priv->page_ranges = op_unix->job->page_ranges;
|
||||
op->priv->num_page_ranges = op_unix->job->num_page_ranges;
|
||||
|
||||
op->priv->manual_num_copies = op_unix->job->num_copies;
|
||||
op->priv->manual_collation = op_unix->job->collate;
|
||||
op->priv->manual_reverse = op_unix->job->reverse;
|
||||
op->priv->manual_page_set = op_unix->job->page_set;
|
||||
op->priv->manual_scale = op_unix->job->scale;
|
||||
op->priv->manual_orientation = op_unix->job->rotate_to_orientation;
|
||||
}
|
||||
|
||||
op->priv->start_page = unix_start_page;
|
||||
op->priv->end_page = unix_end_page;
|
||||
op->priv->end_run = unix_end_run;
|
||||
|
||||
out:
|
||||
g_object_unref (page_setup);
|
||||
|
||||
gtk_widget_destroy (pd);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkPageSetup *
|
||||
gtk_print_run_page_setup_dialog (GtkWindow *parent,
|
||||
GtkPageSetup *page_setup,
|
||||
GtkPrintSettings *settings)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
GtkPageSetup *new_page_setup;
|
||||
|
||||
dialog = gtk_page_setup_unix_dialog_new (NULL, parent);
|
||||
if (page_setup)
|
||||
gtk_page_setup_unix_dialog_set_page_setup (GTK_PAGE_SETUP_UNIX_DIALOG (dialog),
|
||||
page_setup);
|
||||
gtk_page_setup_unix_dialog_set_print_settings (GTK_PAGE_SETUP_UNIX_DIALOG (dialog),
|
||||
settings);
|
||||
gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
new_page_setup = gtk_page_setup_unix_dialog_get_page_setup (GTK_PAGE_SETUP_UNIX_DIALOG (dialog));
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
return new_page_setup;
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_PRINT_OPERATION_UNIX_C__
|
||||
#include "gtkaliasdef.c"
|
1598
gtk/gtkprintoperation-win32.c
Normal file
1598
gtk/gtkprintoperation-win32.c
Normal file
File diff suppressed because it is too large
Load Diff
1153
gtk/gtkprintoperation.c
Normal file
1153
gtk/gtkprintoperation.c
Normal file
File diff suppressed because it is too large
Load Diff
144
gtk/gtkprintoperation.h
Normal file
144
gtk/gtkprintoperation.h
Normal file
@ -0,0 +1,144 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintoperation.h: Print Operation
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_OPERATION_H__
|
||||
#define __GTK_PRINT_OPERATION_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <cairo.h>
|
||||
#include "gtkmain.h"
|
||||
#include "gtkenums.h"
|
||||
#include "gtkwindow.h"
|
||||
#include "gtkpagesetup.h"
|
||||
#include "gtkprintsettings.h"
|
||||
#include "gtkprintcontext.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_OPERATION (gtk_print_operation_get_type ())
|
||||
#define GTK_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperation))
|
||||
#define GTK_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
|
||||
#define GTK_IS_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_OPERATION))
|
||||
#define GTK_IS_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_OPERATION))
|
||||
#define GTK_PRINT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_OPERATION, GtkPrintOperationClass))
|
||||
|
||||
typedef struct _GtkPrintOperationClass GtkPrintOperationClass;
|
||||
typedef struct _GtkPrintOperationPrivate GtkPrintOperationPrivate;
|
||||
typedef struct _GtkPrintOperation GtkPrintOperation;
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINT_STATUS_INITIAL,
|
||||
GTK_PRINT_STATUS_PREPARING,
|
||||
GTK_PRINT_STATUS_GENERATING_DATA,
|
||||
GTK_PRINT_STATUS_SENDING_DATA,
|
||||
GTK_PRINT_STATUS_PENDING,
|
||||
GTK_PRINT_STATUS_PENDING_ISSUE,
|
||||
GTK_PRINT_STATUS_PRINTING,
|
||||
GTK_PRINT_STATUS_FINISHED,
|
||||
GTK_PRINT_STATUS_FINISHED_ABORTED
|
||||
} GtkPrintStatus;
|
||||
|
||||
struct _GtkPrintOperation
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrintOperationPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkPrintOperationClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*begin_print) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context);
|
||||
void (*request_page_setup) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
gint page_nr,
|
||||
GtkPageSetup *setup);
|
||||
void (*draw_page) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
gint page_nr);
|
||||
void (*end_print) (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context);
|
||||
void (*status_changed) (GtkPrintOperation *operation);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
GTK_PRINT_OPERATION_RESULT_ERROR,
|
||||
GTK_PRINT_OPERATION_RESULT_APPLY,
|
||||
GTK_PRINT_OPERATION_RESULT_CANCEL
|
||||
} GtkPrintOperationResult;
|
||||
|
||||
#define GTK_PRINT_ERROR gtk_print_error_quark ()
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_PRINT_ERROR_GENERAL,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
GTK_PRINT_ERROR_NOMEM
|
||||
} GtkPrintError;
|
||||
|
||||
GQuark gtk_print_error_quark (void);
|
||||
|
||||
GType gtk_print_operation_get_type (void) G_GNUC_CONST;
|
||||
GtkPrintOperation * gtk_print_operation_new (void);
|
||||
void gtk_print_operation_set_default_page_setup (GtkPrintOperation *op,
|
||||
GtkPageSetup *default_page_setup);
|
||||
GtkPageSetup * gtk_print_operation_get_default_page_setup (GtkPrintOperation *op);
|
||||
void gtk_print_operation_set_print_settings (GtkPrintOperation *op,
|
||||
GtkPrintSettings *print_settings);
|
||||
GtkPrintSettings * gtk_print_operation_get_print_settings (GtkPrintOperation *op);
|
||||
void gtk_print_operation_set_job_name (GtkPrintOperation *op,
|
||||
const gchar *job_name);
|
||||
void gtk_print_operation_set_nr_of_pages (GtkPrintOperation *op,
|
||||
gint n_pages);
|
||||
void gtk_print_operation_set_current_page (GtkPrintOperation *op,
|
||||
gint current_page);
|
||||
void gtk_print_operation_set_use_full_page (GtkPrintOperation *op,
|
||||
gboolean full_page);
|
||||
void gtk_print_operation_set_unit (GtkPrintOperation *op,
|
||||
GtkUnit unit);
|
||||
void gtk_print_operation_set_show_dialog (GtkPrintOperation *op,
|
||||
gboolean show_dialog);
|
||||
void gtk_print_operation_set_pdf_target (GtkPrintOperation *op,
|
||||
const gchar *filename);
|
||||
GtkPrintOperationResult gtk_print_operation_run (GtkPrintOperation *op,
|
||||
GtkWindow *parent,
|
||||
GError **error);
|
||||
GtkPrintStatus gtk_print_operation_get_status (GtkPrintOperation *op);
|
||||
G_CONST_RETURN gchar * gtk_print_operation_get_status_string (GtkPrintOperation *op);
|
||||
gboolean gtk_print_operation_is_finished (GtkPrintOperation *op);
|
||||
|
||||
GtkPageSetup *gtk_print_run_page_setup_dialog (GtkWindow *parent,
|
||||
GtkPageSetup *page_setup,
|
||||
GtkPrintSettings *settings);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_OPERATION_H__ */
|
1230
gtk/gtkprintsettings.c
Normal file
1230
gtk/gtkprintsettings.c
Normal file
File diff suppressed because it is too large
Load Diff
196
gtk/gtkprintsettings.h
Normal file
196
gtk/gtkprintsettings.h
Normal file
@ -0,0 +1,196 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintsettings.h: Print Settings
|
||||
* Copyright (C) 2006, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINT_SETTINGS_H__
|
||||
#define __GTK_PRINT_SETTINGS_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkpapersize.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkPrintSettings GtkPrintSettings;
|
||||
|
||||
#define GTK_TYPE_PRINT_SETTINGS (gtk_print_settings_get_type ())
|
||||
#define GTK_PRINT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_SETTINGS, GtkPrintSettings))
|
||||
#define GTK_IS_PRINT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_SETTINGS))
|
||||
|
||||
typedef void (*GtkPrintSettingsFunc) (const gchar *key,
|
||||
const gchar *value,
|
||||
gpointer user_data);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint start;
|
||||
gint end;
|
||||
} GtkPageRange;
|
||||
|
||||
GType gtk_print_settings_get_type (void) G_GNUC_CONST;
|
||||
GtkPrintSettings *gtk_print_settings_new (void);
|
||||
|
||||
GtkPrintSettings *gtk_print_settings_copy (GtkPrintSettings *other);
|
||||
gboolean gtk_print_settings_has_key (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
void gtk_print_settings_set (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
const gchar *value);
|
||||
void gtk_print_settings_unset (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
void gtk_print_settings_foreach (GtkPrintSettings *settings,
|
||||
GtkPrintSettingsFunc func,
|
||||
gpointer user_data);
|
||||
gboolean gtk_print_settings_get_bool (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
void gtk_print_settings_set_bool (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gboolean value);
|
||||
gdouble gtk_print_settings_get_double (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
gdouble gtk_print_settings_get_double_with_default (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gdouble def);
|
||||
void gtk_print_settings_set_double (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gdouble value);
|
||||
gdouble gtk_print_settings_get_length (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
GtkUnit unit);
|
||||
void gtk_print_settings_set_length (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gdouble value,
|
||||
GtkUnit unit);
|
||||
gint gtk_print_settings_get_int (GtkPrintSettings *settings,
|
||||
const gchar *key);
|
||||
gint gtk_print_settings_get_int_with_default (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gint def);
|
||||
void gtk_print_settings_set_int (GtkPrintSettings *settings,
|
||||
const gchar *key,
|
||||
gint value);
|
||||
|
||||
#define GTK_PRINT_SETTINGS_PRINTER "printer"
|
||||
#define GTK_PRINT_SETTINGS_ORIENTATION "orientation"
|
||||
#define GTK_PRINT_SETTINGS_PAPER_FORMAT "paper-format"
|
||||
#define GTK_PRINT_SETTINGS_PAPER_WIDTH "paper-width"
|
||||
#define GTK_PRINT_SETTINGS_PAPER_HEIGHT "paper-height"
|
||||
#define GTK_PRINT_SETTINGS_NUM_COPIES "num-copies"
|
||||
#define GTK_PRINT_SETTINGS_DEFAULT_SOURCE "default-source"
|
||||
#define GTK_PRINT_SETTINGS_QUALITY "quality"
|
||||
#define GTK_PRINT_SETTINGS_RESOLUTION "resolution"
|
||||
#define GTK_PRINT_SETTINGS_USE_COLOR "use-color"
|
||||
#define GTK_PRINT_SETTINGS_DUPLEX "duplex"
|
||||
#define GTK_PRINT_SETTINGS_COLLATE "collate"
|
||||
#define GTK_PRINT_SETTINGS_REVERSE "reverse"
|
||||
#define GTK_PRINT_SETTINGS_MEDIA_TYPE "media-type"
|
||||
#define GTK_PRINT_SETTINGS_DITHER "dither"
|
||||
#define GTK_PRINT_SETTINGS_SCALE "scale"
|
||||
#define GTK_PRINT_SETTINGS_PRINT_PAGES "print-pages"
|
||||
#define GTK_PRINT_SETTINGS_PAGE_RANGES "page-ranges"
|
||||
#define GTK_PRINT_SETTINGS_PAGE_SET "page-set"
|
||||
#define GTK_PRINT_SETTINGS_PRINT_TO_FILE "print-to-file"
|
||||
#define GTK_PRINT_SETTINGS_FINISHINGS "finishings"
|
||||
#define GTK_PRINT_SETTINGS_NUMBER_UP "number-up"
|
||||
#define GTK_PRINT_SETTINGS_OUTPUT_BIN "output-bin"
|
||||
|
||||
#define GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION "win32-driver-version"
|
||||
#define GTK_PRINT_SETTINGS_WIN32_DRIVER_EXTRA "win32-driver-extra"
|
||||
|
||||
/* Helpers: */
|
||||
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_printer (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_printer (GtkPrintSettings *settings,
|
||||
const gchar *printer);
|
||||
GtkPageOrientation gtk_print_settings_get_orientation (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_orientation (GtkPrintSettings *settings,
|
||||
GtkPageOrientation orientation);
|
||||
GtkPaperSize * gtk_print_settings_get_paper_size (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_paper_size (GtkPrintSettings *settings,
|
||||
GtkPaperSize *paper_size);
|
||||
gdouble gtk_print_settings_get_paper_width (GtkPrintSettings *settings,
|
||||
GtkUnit unit);
|
||||
void gtk_print_settings_set_paper_width (GtkPrintSettings *settings,
|
||||
gdouble width,
|
||||
GtkUnit unit);
|
||||
gdouble gtk_print_settings_get_paper_height (GtkPrintSettings *settings,
|
||||
GtkUnit unit);
|
||||
void gtk_print_settings_set_paper_height (GtkPrintSettings *settings,
|
||||
gdouble width,
|
||||
GtkUnit unit);
|
||||
gboolean gtk_print_settings_get_use_color (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_use_color (GtkPrintSettings *settings,
|
||||
gboolean use_color);
|
||||
gboolean gtk_print_settings_get_collate (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_collate (GtkPrintSettings *settings,
|
||||
gboolean collate);
|
||||
gboolean gtk_print_settings_get_reverse (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_reverse (GtkPrintSettings *settings,
|
||||
gboolean reverse);
|
||||
GtkPrintDuplex gtk_print_settings_get_duplex (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_duplex (GtkPrintSettings *settings,
|
||||
GtkPrintDuplex duplex);
|
||||
GtkPrintQuality gtk_print_settings_get_quality (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_quality (GtkPrintSettings *settings,
|
||||
GtkPrintQuality quality);
|
||||
gint gtk_print_settings_get_num_copies (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_num_copies (GtkPrintSettings *settings,
|
||||
gint num_copies);
|
||||
gint gtk_print_settings_get_number_up (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_number_up (GtkPrintSettings *settings,
|
||||
gint number_up);
|
||||
gint gtk_print_settings_get_resolution (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_resolution (GtkPrintSettings *settings,
|
||||
gint resolution);
|
||||
gdouble gtk_print_settings_get_scale (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_scale (GtkPrintSettings *settings,
|
||||
gdouble scale);
|
||||
gboolean gtk_print_settings_get_print_to_file (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_print_to_file (GtkPrintSettings *settings,
|
||||
gboolean print_to_file);
|
||||
GtkPrintPages gtk_print_settings_get_print_pages (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_print_pages (GtkPrintSettings *settings,
|
||||
GtkPrintPages pages);
|
||||
GtkPageRange * gtk_print_settings_get_page_ranges (GtkPrintSettings *settings,
|
||||
gint *num_ranges);
|
||||
void gtk_print_settings_set_page_ranges (GtkPrintSettings *settings,
|
||||
GtkPageRange *page_ranges,
|
||||
gint num_ranges);
|
||||
GtkPageSet gtk_print_settings_get_page_set (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_page_set (GtkPrintSettings *settings,
|
||||
GtkPageSet page_set);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_default_source (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_default_source (GtkPrintSettings *settings,
|
||||
const gchar *default_source);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_media_type (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_media_type (GtkPrintSettings *settings,
|
||||
const gchar *media_type);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_dither (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_dither (GtkPrintSettings *settings,
|
||||
const gchar *dither);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_finishings (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_finishings (GtkPrintSettings *settings,
|
||||
const gchar *finishings);
|
||||
G_CONST_RETURN gchar *gtk_print_settings_get_output_bin (GtkPrintSettings *settings);
|
||||
void gtk_print_settings_set_output_bin (GtkPrintSettings *settings,
|
||||
const gchar *output_bin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_SETTINGS_H__ */
|
2577
gtk/gtkprintunixdialog.c
Normal file
2577
gtk/gtkprintunixdialog.c
Normal file
File diff suppressed because it is too large
Load Diff
81
gtk/gtkprintunixdialog.h
Normal file
81
gtk/gtkprintunixdialog.h
Normal file
@ -0,0 +1,81 @@
|
||||
/* GtkPrintUnixDialog
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINT_UNIX_DIALOG_H__
|
||||
#define __GTK_PRINT_UNIX_DIALOG_H__
|
||||
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkprinter.h"
|
||||
#include "gtkprintsettings.h"
|
||||
#include "gtkpagesetup.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_UNIX_DIALOG (gtk_print_unix_dialog_get_type ())
|
||||
#define GTK_PRINT_UNIX_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_UNIX_DIALOG, GtkPrintUnixDialog))
|
||||
#define GTK_PRINT_UNIX_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_UNIX_DIALOG, GtkPrintUnixDialogClass))
|
||||
#define GTK_IS_PRINT_UNIX_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_UNIX_DIALOG))
|
||||
#define GTK_IS_PRINT_UNIX_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_UNIX_DIALOG))
|
||||
#define GTK_PRINT_UNIX_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_UNIX_DIALOG, GtkPrintUnixDialogClass))
|
||||
|
||||
|
||||
typedef struct _GtkPrintUnixDialog GtkPrintUnixDialog;
|
||||
typedef struct _GtkPrintUnixDialogClass GtkPrintUnixDialogClass;
|
||||
typedef struct GtkPrintUnixDialogPrivate GtkPrintUnixDialogPrivate;
|
||||
|
||||
struct _GtkPrintUnixDialog
|
||||
{
|
||||
GtkDialog parent_instance;
|
||||
|
||||
GtkPrintUnixDialogPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GtkPrintUnixDialogClass
|
||||
{
|
||||
GtkDialogClass parent_class;
|
||||
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
void (*_gtk_reserved5) (void);
|
||||
void (*_gtk_reserved6) (void);
|
||||
void (*_gtk_reserved7) (void);
|
||||
};
|
||||
|
||||
GType gtk_print_unix_dialog_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gtk_print_unix_dialog_new (const gchar *title,
|
||||
GtkWindow *parent);
|
||||
|
||||
void gtk_print_unix_dialog_set_page_setup (GtkPrintUnixDialog *dialog,
|
||||
GtkPageSetup *page_setup);
|
||||
GtkPageSetup * gtk_print_unix_dialog_get_page_setup (GtkPrintUnixDialog *dialog);
|
||||
void gtk_print_unix_dialog_set_current_page (GtkPrintUnixDialog *dialog,
|
||||
gint current_page);
|
||||
gint gtk_print_unix_dialog_get_current_page (GtkPrintUnixDialog *dialog);
|
||||
void gtk_print_unix_dialog_set_settings (GtkPrintUnixDialog *dialog,
|
||||
GtkPrintSettings *settings);
|
||||
GtkPrintSettings *gtk_print_unix_dialog_get_settings (GtkPrintUnixDialog *dialog);
|
||||
GtkPrinter * gtk_print_unix_dialog_get_selected_printer (GtkPrintUnixDialog *dialog);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_UNIX_DIALOG_H__ */
|
@ -134,6 +134,9 @@ void gtk_stock_set_translate_func (const gchar *domain,
|
||||
#define GTK_STOCK_NO "gtk-no"
|
||||
#define GTK_STOCK_OK "gtk-ok"
|
||||
#define GTK_STOCK_OPEN "gtk-open"
|
||||
#define GTK_STOCK_ORIENTATION_PORTRAIT "gtk-orientation-portrait"
|
||||
#define GTK_STOCK_ORIENTATION_LANDSCAPE "gtk-orientation-landscape"
|
||||
#define GTK_STOCK_ORIENTATION_REVERSE_LANDSCAPE "gtk-orientation-reverse-landscape"
|
||||
#define GTK_STOCK_PASTE "gtk-paste"
|
||||
#define GTK_STOCK_PREFERENCES "gtk-preferences"
|
||||
#define GTK_STOCK_PRINT "gtk-print"
|
||||
|
192
gtk/paper_names.c
Normal file
192
gtk/paper_names.c
Normal file
@ -0,0 +1,192 @@
|
||||
#define N_(s) s
|
||||
|
||||
/* The paper size names are from:
|
||||
* PWG 5101.1-2002 PWG: Standard for Media Standardized Names
|
||||
*
|
||||
* The PPD names come from the PPD specification.
|
||||
*/
|
||||
|
||||
static const PaperInfo standard_names[] = {
|
||||
/* sorted by name, remember to sort when changing */
|
||||
{"asme_f", "28x40in", N_("asme_f")}, /* f 5 e1 */
|
||||
{"iso_2a0", "1189x1682mm", N_("A0x2")},
|
||||
{"iso_a0", "841x1189mm", N_("A0"), "A0"},
|
||||
{"iso_a0x3", "1189x2523mm", N_("A0x3")},
|
||||
{"iso_a1", "594x841mm", N_("A1"), "A1"},
|
||||
{"iso_a10", "26x37mm", N_("A10"), "A10"},
|
||||
{"iso_a1x3", "841x1783mm", N_("A1x3")},
|
||||
{"iso_a1x4", "841x2378mm", N_("A1x4")},
|
||||
{"iso_a2", "420x594mm", N_("A2"), "A2"},
|
||||
{"iso_a2x3", "594x1261mm", N_("A2x3")},
|
||||
{"iso_a2x4", "594x1682mm", N_("A2x4")},
|
||||
{"iso_a2x5", "594x2102mm", N_("A2x5")},
|
||||
{"iso_a3", "297x420mm", N_("A3"), "A3"},
|
||||
{"iso_a3-extra", "322x445mm", N_("A3 Extra"), "A3Extra"},
|
||||
{"iso_a3x3", "420x891mm", N_("A3x3")},
|
||||
{"iso_a3x4", "420x1189mm", N_("A3x4")},
|
||||
{"iso_a3x5", "420x1486mm", N_("A3x5")},
|
||||
{"iso_a3x6", "420x1783mm", N_("A3x6")},
|
||||
{"iso_a3x7", "420x2080mm", N_("A3x7")},
|
||||
{"iso_a4", "210x297mm", N_("A4"), "A4"},
|
||||
{"iso_a4-extra", "235.5x322.3mm", N_("A4 Extra"), "A4Extra"},
|
||||
{"iso_a4-tab", "225x297mm", N_("A4 Tab")},
|
||||
{"iso_a4x3", "297x630mm", N_("A4x3")},
|
||||
{"iso_a4x4", "297x841mm", N_("A4x4")},
|
||||
{"iso_a4x5", "297x1051mm", N_("A4x5")},
|
||||
{"iso_a4x6", "297x1261mm", N_("A4x6")},
|
||||
{"iso_a4x7", "297x1471mm", N_("A4x7")},
|
||||
{"iso_a4x8", "297x1682mm", N_("A4x8")},
|
||||
{"iso_a4x9", "297x1892mm", N_("A4x9")},
|
||||
{"iso_a5", "148x210mm", N_("A5"), "A5"},
|
||||
{"iso_a5-extra", "174x235mm", N_("A5 Extra"), "A5Extra"},
|
||||
{"iso_a6", "105x148mm", N_("A6"), "A6"},
|
||||
{"iso_a7", "74x105mm", N_("A7"), "A7"},
|
||||
{"iso_a8", "52x74mm", N_("A8"), "A8"},
|
||||
{"iso_a9", "37x52mm", N_("A9"), "A9"},
|
||||
{"iso_b0", "1000x1414mm", N_("B0"), "ISOB0"},
|
||||
{"iso_b1", "707x1000mm", N_("B1"), "ISOB1"},
|
||||
{"iso_b10", "31x44mm", N_("B10"), "ISOB10"},
|
||||
{"iso_b2", "500x707mm", N_("B2"), "ISOB2"},
|
||||
{"iso_b3", "353x500mm", N_("B3"), "ISOB3"},
|
||||
{"iso_b4", "250x353mm", N_("B4"), "ISOB4"},
|
||||
{"iso_b5", "176x250mm", N_("B5"), "ISOB5"},
|
||||
{"iso_b5-extra", "201x276mm", N_("B5 Extra"), "ISOB5Extra"},
|
||||
{"iso_b6", "125x176mm", N_("B6"), "ISOB6"},
|
||||
{"iso_b6c4", "125x324mm", N_("B6/C4")}, /* b6/c4 Envelope */
|
||||
{"iso_b7", "88x125mm", N_("B7"), "ISOB7"},
|
||||
{"iso_b8", "62x88mm", N_("B8"), "ISOB8"},
|
||||
{"iso_b9", "44x62mm", N_("B9"), "ISOB9"},
|
||||
{"iso_c0", "917x1297mm", N_("C0"), "EnvC0"},
|
||||
{"iso_c1", "648x917mm", N_("C1"), "EnvC1"},
|
||||
{"iso_c10", "28x40mm", N_("C10"), "EnvC10"},
|
||||
{"iso_c2", "458x648mm", N_("C2"), "EnvC2"},
|
||||
{"iso_c3", "324x458mm", N_("C3"), "EnvC3"},
|
||||
{"iso_c4", "229x324mm", N_("C4"), "EnvC4"},
|
||||
{"iso_c5", "162x229mm", N_("C5"), "EnvC5"},
|
||||
{"iso_c6", "114x162mm", N_("C6"), "EnvC6"},
|
||||
{"iso_c6c5", "114x229mm", N_("C6/C5"), "EnvC65"},
|
||||
{"iso_c7", "81x114mm", N_("C7"), "EnvC7"},
|
||||
{"iso_c7c6", "81x162mm", N_("C7/C6")}, /* c7/c6 Envelope */
|
||||
{"iso_c8", "57x81mm", N_("C8"), "EnvC8"},
|
||||
{"iso_c9", "40x57mm", N_("C9"), "EnvC9"},
|
||||
{"iso_dl", "110x220mm", N_("DL Envelope"), "EnvDL"}, /* iso-designated 1, 2 designated-long, dl Envelope */
|
||||
{"iso_ra0", "860x1220mm", N_("RA0")},
|
||||
{"iso_ra1", "610x860mm", N_("RA1")},
|
||||
{"iso_ra2", "430x610mm", N_("RA2")},
|
||||
{"iso_sra0", "900x1280mm", N_("SRA0")},
|
||||
{"iso_sra1", "640x900mm", N_("SRA1")},
|
||||
{"iso_sra2", "450x640mm", N_("SRA2")},
|
||||
{"jis_b0", "1030x1456mm", N_("JB0"), "B0"},
|
||||
{"jis_b1", "728x1030mm", N_("JB1"), "B1"},
|
||||
{"jis_b10", "32x45mm", N_("JB10"), "B10"},
|
||||
{"jis_b2", "515x728mm", N_("JB2"), "B2"},
|
||||
{"jis_b3", "364x515mm", N_("JB3"), "B3"},
|
||||
{"jis_b4", "257x364mm", N_("JB4"), "B4"},
|
||||
{"jis_b5", "182x257mm", N_("JB5"), "B5"},
|
||||
{"jis_b6", "128x182mm", N_("JB6"), "B6"},
|
||||
{"jis_b7", "91x128mm", N_("JB7"), "B7"},
|
||||
{"jis_b8", "64x91mm", N_("JB8"), "B8"},
|
||||
{"jis_b9", "45x64mm", N_("JB9"), "B9"},
|
||||
{"jis_exec", "216x330mm", N_("jis exec")},
|
||||
{"jpn_chou2", "111.1x146mm", N_("Choukei 2 Envelope")},
|
||||
{"jpn_chou3", "120x235mm", N_("Choukei 3 Envelope"), "EnvChou3"},
|
||||
{"jpn_chou4", "90x205mm", N_("Choukei 4 Envelope"), "EnvChou4"},
|
||||
{"jpn_hagaki", "100x148mm", N_("hagaki (postcard)"), "Postcard"},
|
||||
{"jpn_kahu", "240x322.1mm", N_("kahu Envelope")},
|
||||
{"jpn_kaku2", "240x332mm", N_("kaku2 Envelope"), "EnvKaku2"},
|
||||
{"jpn_oufuku", "148x200mm", N_("oufuku (reply postcard)"), "DoublePostcard"},
|
||||
{"jpn_you4", "105x235mm", N_("you4 Envelope")},
|
||||
{"na_10x11", "10x11in", N_("10x11"), "10x11"},
|
||||
{"na_10x13", "10x13in", N_("10x13"), "10x13"},
|
||||
{"na_10x14", "10x14in", N_("10x14"), "10x14"},
|
||||
{"na_10x15", "10x15in", N_("10x15")},
|
||||
{"na_10x15", "10x15in", N_("10x15")},
|
||||
{"na_11x12", "11x12in", N_("11x12"), "12x11"},
|
||||
{"na_11x15", "11x15in", N_("11x15"), "15x11"},
|
||||
{"na_12x19", "12x19in", N_("12x19")},
|
||||
{"na_5x7", "5x7in", N_("5x7")},
|
||||
{"na_6x9", "6x9in", N_("6x9 Envelope")},
|
||||
{"na_7x9", "7x9in", N_("7x9 Envelope"), "7x9"},
|
||||
{"na_9x11", "9x11in", N_("9x11 Envelope"), "9x11"},
|
||||
{"na_a2", "4.375x5.75in", N_("a2 Envelope")},
|
||||
{"na_arch-a", "9x12in", N_("Arch A"), "ARCHA"},
|
||||
{"na_arch-b", "12x18in", N_("Arch B"), "ARCHB"},
|
||||
{"na_arch-c", "18x24in", N_("Arch C"), "ARCHC"},
|
||||
{"na_arch-d", "24x36in", N_("Arch D"), "ARCHD"},
|
||||
{"na_arch-e", "36x48in", N_("Arch E"), "ARCHE"},
|
||||
{"na_b-plus", "12x19.17in", N_("b-plus")},
|
||||
{"na_c", "17x22in", N_("c"), "AnsiC"},
|
||||
{"na_c5", "6.5x9.5in", N_("c5 Envelope")},
|
||||
{"na_d", "22x34in", N_("d"), "AnsiD"},
|
||||
{"na_e", "34x44in", N_("e"), "AnsiE"},
|
||||
{"na_edp", "11x14in", N_("edp")},
|
||||
{"na_eur-edp", "12x14in", N_("European edp")},
|
||||
{"na_executive", "7.25x10.5in", N_("Executive"), "Executive"},
|
||||
{"na_f", "44x68in", N_("f")},
|
||||
{"na_fanfold-eur", "8.5x12in", N_("FanFold European"), "FanFoldGerman"},
|
||||
{"na_fanfold-us", "11x14.875in", N_("FanFold US"), "FanFoldUS"},
|
||||
{"na_foolscap", "8.5x13in", N_("FanFold German Legal"), "FanFoldGermanLegal"}, /* foolscap, german-legal-fanfold */
|
||||
{"na_govt-legal", "8x13in", N_("Government Legal")},
|
||||
{"na_govt-letter", "8x10in", N_("Government Letter"), "8x10"},
|
||||
{"na_index-3x5", "3x5in", N_("Index 3x5")},
|
||||
{"na_index-4x6", "4x6in", N_("Index 4x6 (postcard)")},
|
||||
{"na_index-4x6-ext", "6x8in", N_("Index 4x6 ext")},
|
||||
{"na_index-5x8", "5x8in", N_("Index 5x8")},
|
||||
{"na_invoice", "5.5x8.5in", N_("Invoice"), "Statement"}, /* invoice, statement, mini, half-letter */
|
||||
{"na_ledger", "11x17in", N_("Tabloid"), "Ledger"}, /* tabloid, engineering-b */
|
||||
{"na_legal", "8.5x14in", N_("US Legal"), "Legal"},
|
||||
{"na_legal-extra", "9.5x15in", N_("US Legal Extra"), "LegalExtra"},
|
||||
{"na_letter", "8.5x11in", N_("US Letter"), "Letter"},
|
||||
{"na_letter-extra", "9.5x12in", N_("US Letter Extra"), "LetterExtra"},
|
||||
{"na_letter-plus", "8.5x12.69in", N_("US Letter Plus"), "LetterPlus"},
|
||||
{"na_monarch", "3.875x7.5in", N_("Monarch Envelope"), "EnvMonarch"},
|
||||
{"na_number-10", "4.125x9.5in", N_("#10 Envelope"), "Env10"}, /* na-number-10-envelope 1, 2 comm-10 Envelope */
|
||||
{"na_number-11", "4.5x10.375in", N_("#11 Eenvelope"), "Env11"}, /* number-11 Envelope */
|
||||
{"na_number-12", "4.75x11in", N_("#12 Envelope"), "Env12"}, /* number-12 Envelope */
|
||||
{"na_number-14", "5x11.5in", N_("#14 Envelope"), "Env14"}, /* number-14 Envelope */
|
||||
{"na_number-9", "3.875x8.875in", N_("#9 Envelope"), "Env9"},
|
||||
{"na_personal", "3.625x6.5in", N_("Personal Envelope"), "EnvPersonal"},
|
||||
{"na_quarto", "8.5x10.83in", N_("Quarto"), "Quarto"},
|
||||
{"na_super-a", "8.94x14in", N_("Super A"), "SuperA"},
|
||||
{"na_super-b", "13x19in", N_("Super B"), "SuperB"},
|
||||
{"na_wide-format", "30x42in", N_("Wide Format")},
|
||||
{"om_dai-pa-kai", "275x395mm", N_("Dai-pa-kai")},
|
||||
{"om_folio", "210x330mm", N_("Folio"), "Folio"},
|
||||
{"om_folio-sp", "215x315mm", N_("Folio sp")},
|
||||
{"om_invite", "220x220mm", N_("Invite Envelope"), "EnvInvite"},
|
||||
{"om_italian", "110x230mm", N_("Italian Envelope"), "EnvItalian"},
|
||||
{"om_juuro-ku-kai", "198x275mm", N_("juuro-ku-kai")},
|
||||
{"om_pa-kai", "267x389mm", N_("pa-kai")},
|
||||
{"om_postfix", "114x229mm", N_("Postfix Envelope")},
|
||||
{"om_small-photo", "100x150mm", N_("Small Photo")},
|
||||
{"prc_1", "102x165mm", N_("prc1 Envelope"), "EnvPRC1"},
|
||||
{"prc_10", "324x458mm", N_("prc10 Envelope"), "EnvPRC10"},
|
||||
{"prc_16k", "146x215mm", N_("prc 16k"), "PRC16K"},
|
||||
{"prc_2", "102x176mm", N_("prc2 Envelope"), "EnvPRC2"},
|
||||
{"prc_3", "125x176mm", N_("prc3 Envelope"), "EnvPRC3"},
|
||||
{"prc_32k", "97x151mm", N_("prc 32k"), "PRC32K"},
|
||||
{"prc_4", "110x208mm", N_("prc4 Envelope"), "EnvPRC4"},
|
||||
{"prc_5", "110x220mm", N_("prc5 Envelope"), "EnvPRC5"},
|
||||
{"prc_6", "120x320mm", N_("prc6 Envelope"), "EnvPRC6"},
|
||||
{"prc_7", "160x230mm", N_("prc7 Envelope"), "EnvPRC7"},
|
||||
{"prc_8", "120x309mm", N_("prc8 Envelope"), "EnvPRC8"},
|
||||
{"roc_16k", "7.75x10.75in", N_("ROC 16k")},
|
||||
{"roc_8k", "10.75x15.5in", N_("ROC 8k")},
|
||||
};
|
||||
|
||||
/* Some page sizes have multiple PPD names in use.
|
||||
* The array above only contails the prefered one,
|
||||
* and this array fills out with the duplicates.
|
||||
*/
|
||||
const struct {
|
||||
const char *ppd_name;
|
||||
const char *standard_name;
|
||||
} extra_ppd_names[] = {
|
||||
/* sorted by ppd_name, remember to sort when changing */
|
||||
{ "C4", "iso_c4"},
|
||||
{ "C5", "iso_c5"},
|
||||
{ "C6", "iso_c6"},
|
||||
{ "Comm10", "na_number-10"},
|
||||
{ "DL", "iso_dl"},
|
||||
{ "Monarch", "na_monarch"},
|
||||
};
|
712
gtk/paper_names_offsets.c
Normal file
712
gtk/paper_names_offsets.c
Normal file
@ -0,0 +1,712 @@
|
||||
/* Generated by gen-paper-names */
|
||||
|
||||
#if 0
|
||||
N_("asme_f")
|
||||
N_("A0x2")
|
||||
N_("A0")
|
||||
N_("A0x3")
|
||||
N_("A1")
|
||||
N_("A10")
|
||||
N_("A1x3")
|
||||
N_("A1x4")
|
||||
N_("A2")
|
||||
N_("A2x3")
|
||||
N_("A2x4")
|
||||
N_("A2x5")
|
||||
N_("A3")
|
||||
N_("A3 Extra")
|
||||
N_("A3x3")
|
||||
N_("A3x4")
|
||||
N_("A3x5")
|
||||
N_("A3x6")
|
||||
N_("A3x7")
|
||||
N_("A4")
|
||||
N_("A4 Extra")
|
||||
N_("A4 Tab")
|
||||
N_("A4x3")
|
||||
N_("A4x4")
|
||||
N_("A4x5")
|
||||
N_("A4x6")
|
||||
N_("A4x7")
|
||||
N_("A4x8")
|
||||
N_("A4x9")
|
||||
N_("A5")
|
||||
N_("A5 Extra")
|
||||
N_("A6")
|
||||
N_("A7")
|
||||
N_("A8")
|
||||
N_("A9")
|
||||
N_("B0")
|
||||
N_("B1")
|
||||
N_("B10")
|
||||
N_("B2")
|
||||
N_("B3")
|
||||
N_("B4")
|
||||
N_("B5")
|
||||
N_("B5 Extra")
|
||||
N_("B6")
|
||||
N_("B6/C4")
|
||||
N_("B7")
|
||||
N_("B8")
|
||||
N_("B9")
|
||||
N_("C0")
|
||||
N_("C1")
|
||||
N_("C10")
|
||||
N_("C2")
|
||||
N_("C3")
|
||||
N_("C4")
|
||||
N_("C5")
|
||||
N_("C6")
|
||||
N_("C6/C5")
|
||||
N_("C7")
|
||||
N_("C7/C6")
|
||||
N_("C8")
|
||||
N_("C9")
|
||||
N_("DL Envelope")
|
||||
N_("RA0")
|
||||
N_("RA1")
|
||||
N_("RA2")
|
||||
N_("SRA0")
|
||||
N_("SRA1")
|
||||
N_("SRA2")
|
||||
N_("JB0")
|
||||
N_("JB1")
|
||||
N_("JB10")
|
||||
N_("JB2")
|
||||
N_("JB3")
|
||||
N_("JB4")
|
||||
N_("JB5")
|
||||
N_("JB6")
|
||||
N_("JB7")
|
||||
N_("JB8")
|
||||
N_("JB9")
|
||||
N_("jis exec")
|
||||
N_("Choukei 2 Envelope")
|
||||
N_("Choukei 3 Envelope")
|
||||
N_("Choukei 4 Envelope")
|
||||
N_("hagaki (postcard)")
|
||||
N_("kahu Envelope")
|
||||
N_("kaku2 Envelope")
|
||||
N_("oufuku (reply postcard)")
|
||||
N_("you4 Envelope")
|
||||
N_("10x11")
|
||||
N_("10x13")
|
||||
N_("10x14")
|
||||
N_("10x15")
|
||||
N_("10x15")
|
||||
N_("11x12")
|
||||
N_("11x15")
|
||||
N_("12x19")
|
||||
N_("5x7")
|
||||
N_("6x9 Envelope")
|
||||
N_("7x9 Envelope")
|
||||
N_("9x11 Envelope")
|
||||
N_("a2 Envelope")
|
||||
N_("Arch A")
|
||||
N_("Arch B")
|
||||
N_("Arch C")
|
||||
N_("Arch D")
|
||||
N_("Arch E")
|
||||
N_("b-plus")
|
||||
N_("c")
|
||||
N_("c5 Envelope")
|
||||
N_("d")
|
||||
N_("e")
|
||||
N_("edp")
|
||||
N_("European edp")
|
||||
N_("Executive")
|
||||
N_("f")
|
||||
N_("FanFold European")
|
||||
N_("FanFold US")
|
||||
N_("FanFold German Legal")
|
||||
N_("Government Legal")
|
||||
N_("Government Letter")
|
||||
N_("Index 3x5")
|
||||
N_("Index 4x6 (postcard)")
|
||||
N_("Index 4x6 ext")
|
||||
N_("Index 5x8")
|
||||
N_("Invoice")
|
||||
N_("Tabloid")
|
||||
N_("US Legal")
|
||||
N_("US Legal Extra")
|
||||
N_("US Letter")
|
||||
N_("US Letter Extra")
|
||||
N_("US Letter Plus")
|
||||
N_("Monarch Envelope")
|
||||
N_("#10 Envelope")
|
||||
N_("#11 Eenvelope")
|
||||
N_("#12 Envelope")
|
||||
N_("#14 Envelope")
|
||||
N_("#9 Envelope")
|
||||
N_("Personal Envelope")
|
||||
N_("Quarto")
|
||||
N_("Super A")
|
||||
N_("Super B")
|
||||
N_("Wide Format")
|
||||
N_("Dai-pa-kai")
|
||||
N_("Folio")
|
||||
N_("Folio sp")
|
||||
N_("Invite Envelope")
|
||||
N_("Italian Envelope")
|
||||
N_("juuro-ku-kai")
|
||||
N_("pa-kai")
|
||||
N_("Postfix Envelope")
|
||||
N_("Small Photo")
|
||||
N_("prc1 Envelope")
|
||||
N_("prc10 Envelope")
|
||||
N_("prc 16k")
|
||||
N_("prc2 Envelope")
|
||||
N_("prc3 Envelope")
|
||||
N_("prc 32k")
|
||||
N_("prc4 Envelope")
|
||||
N_("prc5 Envelope")
|
||||
N_("prc6 Envelope")
|
||||
N_("prc7 Envelope")
|
||||
N_("prc8 Envelope")
|
||||
N_("ROC 16k")
|
||||
N_("ROC 8k")
|
||||
#endif
|
||||
|
||||
const char paper_names[] =
|
||||
"asme_f\0"
|
||||
"iso_2a0\0"
|
||||
"A0x2\0"
|
||||
"iso_a0\0"
|
||||
"iso_a0x3\0"
|
||||
"A0x3\0"
|
||||
"iso_a1\0"
|
||||
"iso_a10\0"
|
||||
"A10\0"
|
||||
"iso_a1x3\0"
|
||||
"A1x3\0"
|
||||
"iso_a1x4\0"
|
||||
"A1x4\0"
|
||||
"iso_a2\0"
|
||||
"iso_a2x3\0"
|
||||
"A2x3\0"
|
||||
"iso_a2x4\0"
|
||||
"A2x4\0"
|
||||
"iso_a2x5\0"
|
||||
"A2x5\0"
|
||||
"iso_a3\0"
|
||||
"A3\0"
|
||||
"iso_a3-extra\0"
|
||||
"A3 Extra\0"
|
||||
"A3Extra\0"
|
||||
"iso_a3x3\0"
|
||||
"A3x3\0"
|
||||
"iso_a3x4\0"
|
||||
"A3x4\0"
|
||||
"iso_a3x5\0"
|
||||
"A3x5\0"
|
||||
"iso_a3x6\0"
|
||||
"A3x6\0"
|
||||
"iso_a3x7\0"
|
||||
"A3x7\0"
|
||||
"iso_a4\0"
|
||||
"A4\0"
|
||||
"iso_a4-extra\0"
|
||||
"A4 Extra\0"
|
||||
"A4Extra\0"
|
||||
"iso_a4-tab\0"
|
||||
"A4 Tab\0"
|
||||
"iso_a4x3\0"
|
||||
"A4x3\0"
|
||||
"iso_a4x4\0"
|
||||
"A4x4\0"
|
||||
"iso_a4x5\0"
|
||||
"A4x5\0"
|
||||
"iso_a4x6\0"
|
||||
"A4x6\0"
|
||||
"iso_a4x7\0"
|
||||
"A4x7\0"
|
||||
"iso_a4x8\0"
|
||||
"A4x8\0"
|
||||
"iso_a4x9\0"
|
||||
"A4x9\0"
|
||||
"iso_a5\0"
|
||||
"A5\0"
|
||||
"iso_a5-extra\0"
|
||||
"A5 Extra\0"
|
||||
"A5Extra\0"
|
||||
"iso_a6\0"
|
||||
"A6\0"
|
||||
"iso_a7\0"
|
||||
"A7\0"
|
||||
"iso_a8\0"
|
||||
"A8\0"
|
||||
"iso_a9\0"
|
||||
"A9\0"
|
||||
"iso_b0\0"
|
||||
"ISOB0\0"
|
||||
"iso_b1\0"
|
||||
"ISOB1\0"
|
||||
"iso_b10\0"
|
||||
"ISOB10\0"
|
||||
"iso_b2\0"
|
||||
"ISOB2\0"
|
||||
"iso_b3\0"
|
||||
"ISOB3\0"
|
||||
"iso_b4\0"
|
||||
"ISOB4\0"
|
||||
"iso_b5\0"
|
||||
"ISOB5\0"
|
||||
"iso_b5-extra\0"
|
||||
"B5 Extra\0"
|
||||
"ISOB5Extra\0"
|
||||
"iso_b6\0"
|
||||
"ISOB6\0"
|
||||
"iso_b6c4\0"
|
||||
"B6/C4\0"
|
||||
"iso_b7\0"
|
||||
"ISOB7\0"
|
||||
"iso_b8\0"
|
||||
"ISOB8\0"
|
||||
"iso_b9\0"
|
||||
"ISOB9\0"
|
||||
"iso_c0\0"
|
||||
"EnvC0\0"
|
||||
"iso_c1\0"
|
||||
"EnvC1\0"
|
||||
"iso_c10\0"
|
||||
"EnvC10\0"
|
||||
"iso_c2\0"
|
||||
"EnvC2\0"
|
||||
"iso_c3\0"
|
||||
"EnvC3\0"
|
||||
"iso_c4\0"
|
||||
"EnvC4\0"
|
||||
"iso_c5\0"
|
||||
"EnvC5\0"
|
||||
"iso_c6\0"
|
||||
"EnvC6\0"
|
||||
"iso_c6c5\0"
|
||||
"C6/C5\0"
|
||||
"EnvC65\0"
|
||||
"iso_c7\0"
|
||||
"EnvC7\0"
|
||||
"iso_c7c6\0"
|
||||
"C7/C6\0"
|
||||
"iso_c8\0"
|
||||
"EnvC8\0"
|
||||
"iso_c9\0"
|
||||
"EnvC9\0"
|
||||
"iso_dl\0"
|
||||
"DL Envelope\0"
|
||||
"EnvDL\0"
|
||||
"iso_ra0\0"
|
||||
"iso_ra1\0"
|
||||
"iso_ra2\0"
|
||||
"iso_sra0\0"
|
||||
"SRA0\0"
|
||||
"iso_sra1\0"
|
||||
"SRA1\0"
|
||||
"iso_sra2\0"
|
||||
"SRA2\0"
|
||||
"jis_b0\0"
|
||||
"JB0\0"
|
||||
"jis_b1\0"
|
||||
"JB1\0"
|
||||
"jis_b10\0"
|
||||
"JB10\0"
|
||||
"jis_b2\0"
|
||||
"JB2\0"
|
||||
"jis_b3\0"
|
||||
"JB3\0"
|
||||
"jis_b4\0"
|
||||
"JB4\0"
|
||||
"jis_b5\0"
|
||||
"JB5\0"
|
||||
"jis_b6\0"
|
||||
"JB6\0"
|
||||
"jis_b7\0"
|
||||
"JB7\0"
|
||||
"jis_b8\0"
|
||||
"JB8\0"
|
||||
"jis_b9\0"
|
||||
"JB9\0"
|
||||
"jis_exec\0"
|
||||
"jis exec\0"
|
||||
"jpn_chou2\0"
|
||||
"Choukei 2 Envelope\0"
|
||||
"jpn_chou3\0"
|
||||
"Choukei 3 Envelope\0"
|
||||
"EnvChou3\0"
|
||||
"jpn_chou4\0"
|
||||
"Choukei 4 Envelope\0"
|
||||
"EnvChou4\0"
|
||||
"jpn_hagaki\0"
|
||||
"hagaki (postcard)\0"
|
||||
"jpn_kahu\0"
|
||||
"kahu Envelope\0"
|
||||
"jpn_kaku2\0"
|
||||
"kaku2 Envelope\0"
|
||||
"EnvKaku2\0"
|
||||
"jpn_oufuku\0"
|
||||
"oufuku (reply postcard)\0"
|
||||
"DoublePostcard\0"
|
||||
"jpn_you4\0"
|
||||
"you4 Envelope\0"
|
||||
"na_10x11\0"
|
||||
"na_10x13\0"
|
||||
"na_10x14\0"
|
||||
"na_10x15\0"
|
||||
"na_11x12\0"
|
||||
"12x11\0"
|
||||
"na_11x15\0"
|
||||
"15x11\0"
|
||||
"na_12x19\0"
|
||||
"na_5x7\0"
|
||||
"na_6x9\0"
|
||||
"6x9 Envelope\0"
|
||||
"na_7x9\0"
|
||||
"7x9 Envelope\0"
|
||||
"na_9x11\0"
|
||||
"9x11 Envelope\0"
|
||||
"na_a2\0"
|
||||
"a2 Envelope\0"
|
||||
"na_arch-a\0"
|
||||
"Arch A\0"
|
||||
"ARCHA\0"
|
||||
"na_arch-b\0"
|
||||
"Arch B\0"
|
||||
"ARCHB\0"
|
||||
"na_arch-c\0"
|
||||
"Arch C\0"
|
||||
"ARCHC\0"
|
||||
"na_arch-d\0"
|
||||
"Arch D\0"
|
||||
"ARCHD\0"
|
||||
"na_arch-e\0"
|
||||
"Arch E\0"
|
||||
"ARCHE\0"
|
||||
"na_b-plus\0"
|
||||
"na_c\0"
|
||||
"AnsiC\0"
|
||||
"na_c5\0"
|
||||
"na_d\0"
|
||||
"AnsiD\0"
|
||||
"na_e\0"
|
||||
"AnsiE\0"
|
||||
"na_edp\0"
|
||||
"na_eur-edp\0"
|
||||
"European edp\0"
|
||||
"na_executive\0"
|
||||
"Executive\0"
|
||||
"na_f\0"
|
||||
"na_fanfold-eur\0"
|
||||
"FanFold European\0"
|
||||
"FanFoldGerman\0"
|
||||
"na_fanfold-us\0"
|
||||
"FanFold US\0"
|
||||
"FanFoldUS\0"
|
||||
"na_foolscap\0"
|
||||
"FanFold German Legal\0"
|
||||
"FanFoldGermanLegal\0"
|
||||
"na_govt-legal\0"
|
||||
"Government Legal\0"
|
||||
"na_govt-letter\0"
|
||||
"Government Letter\0"
|
||||
"8x10\0"
|
||||
"na_index-3x5\0"
|
||||
"Index 3x5\0"
|
||||
"na_index-4x6\0"
|
||||
"Index 4x6 (postcard)\0"
|
||||
"na_index-4x6-ext\0"
|
||||
"Index 4x6 ext\0"
|
||||
"na_index-5x8\0"
|
||||
"Index 5x8\0"
|
||||
"na_invoice\0"
|
||||
"Invoice\0"
|
||||
"Statement\0"
|
||||
"na_ledger\0"
|
||||
"Tabloid\0"
|
||||
"Ledger\0"
|
||||
"na_legal\0"
|
||||
"US Legal\0"
|
||||
"na_legal-extra\0"
|
||||
"US Legal Extra\0"
|
||||
"LegalExtra\0"
|
||||
"na_letter\0"
|
||||
"US Letter\0"
|
||||
"na_letter-extra\0"
|
||||
"US Letter Extra\0"
|
||||
"LetterExtra\0"
|
||||
"na_letter-plus\0"
|
||||
"US Letter Plus\0"
|
||||
"LetterPlus\0"
|
||||
"na_monarch\0"
|
||||
"Monarch Envelope\0"
|
||||
"EnvMonarch\0"
|
||||
"na_number-10\0"
|
||||
"#10 Envelope\0"
|
||||
"Env10\0"
|
||||
"na_number-11\0"
|
||||
"#11 Eenvelope\0"
|
||||
"Env11\0"
|
||||
"na_number-12\0"
|
||||
"#12 Envelope\0"
|
||||
"Env12\0"
|
||||
"na_number-14\0"
|
||||
"#14 Envelope\0"
|
||||
"Env14\0"
|
||||
"na_number-9\0"
|
||||
"#9 Envelope\0"
|
||||
"Env9\0"
|
||||
"na_personal\0"
|
||||
"Personal Envelope\0"
|
||||
"EnvPersonal\0"
|
||||
"na_quarto\0"
|
||||
"Quarto\0"
|
||||
"na_super-a\0"
|
||||
"Super A\0"
|
||||
"SuperA\0"
|
||||
"na_super-b\0"
|
||||
"Super B\0"
|
||||
"SuperB\0"
|
||||
"na_wide-format\0"
|
||||
"Wide Format\0"
|
||||
"om_dai-pa-kai\0"
|
||||
"Dai-pa-kai\0"
|
||||
"om_folio\0"
|
||||
"Folio\0"
|
||||
"om_folio-sp\0"
|
||||
"Folio sp\0"
|
||||
"om_invite\0"
|
||||
"Invite Envelope\0"
|
||||
"EnvInvite\0"
|
||||
"om_italian\0"
|
||||
"Italian Envelope\0"
|
||||
"EnvItalian\0"
|
||||
"om_juuro-ku-kai\0"
|
||||
"om_pa-kai\0"
|
||||
"om_postfix\0"
|
||||
"Postfix Envelope\0"
|
||||
"om_small-photo\0"
|
||||
"Small Photo\0"
|
||||
"prc_1\0"
|
||||
"prc1 Envelope\0"
|
||||
"EnvPRC1\0"
|
||||
"prc_10\0"
|
||||
"prc10 Envelope\0"
|
||||
"EnvPRC10\0"
|
||||
"prc_16k\0"
|
||||
"prc 16k\0"
|
||||
"PRC16K\0"
|
||||
"prc_2\0"
|
||||
"prc2 Envelope\0"
|
||||
"EnvPRC2\0"
|
||||
"prc_3\0"
|
||||
"prc3 Envelope\0"
|
||||
"EnvPRC3\0"
|
||||
"prc_32k\0"
|
||||
"prc 32k\0"
|
||||
"PRC32K\0"
|
||||
"prc_4\0"
|
||||
"prc4 Envelope\0"
|
||||
"EnvPRC4\0"
|
||||
"prc_5\0"
|
||||
"prc5 Envelope\0"
|
||||
"EnvPRC5\0"
|
||||
"prc_6\0"
|
||||
"prc6 Envelope\0"
|
||||
"EnvPRC6\0"
|
||||
"prc_7\0"
|
||||
"prc7 Envelope\0"
|
||||
"EnvPRC7\0"
|
||||
"prc_8\0"
|
||||
"prc8 Envelope\0"
|
||||
"EnvPRC8\0"
|
||||
"roc_16k\0"
|
||||
"ROC 16k\0"
|
||||
"roc_8k\0"
|
||||
"ROC 8k\0"
|
||||
"Comm10\0";
|
||||
|
||||
typedef struct {
|
||||
int name;
|
||||
float width;
|
||||
float height;
|
||||
int display_name;
|
||||
int ppd_name;
|
||||
} PaperInfo;
|
||||
|
||||
const PaperInfo standard_names_offsets[] = {
|
||||
{ 0, 711.2, 1016, 0, -1 },
|
||||
{ 7, 1189, 1682, 15, -1 },
|
||||
{ 20, 841, 1189, 1, 1 },
|
||||
{ 27, 1189, 2523, 36, -1 },
|
||||
{ 41, 594, 841, 1, 1 },
|
||||
{ 48, 26, 37, 56, 56 },
|
||||
{ 60, 841, 1783, 69, -1 },
|
||||
{ 74, 841, 2378, 83, -1 },
|
||||
{ 88, 420, 594, 1, 1 },
|
||||
{ 95, 594, 1261, 104, -1 },
|
||||
{ 109, 594, 1682, 118, -1 },
|
||||
{ 123, 594, 2102, 132, -1 },
|
||||
{ 137, 297, 420, 144, 144 },
|
||||
{ 147, 322, 445, 160, 169 },
|
||||
{ 177, 420, 891, 186, -1 },
|
||||
{ 191, 420, 1189, 200, -1 },
|
||||
{ 205, 420, 1486, 214, -1 },
|
||||
{ 219, 420, 1783, 228, -1 },
|
||||
{ 233, 420, 2080, 242, -1 },
|
||||
{ 247, 210, 297, 254, 254 },
|
||||
{ 257, 235.5, 322.3, 270, 279 },
|
||||
{ 287, 225, 297, 298, -1 },
|
||||
{ 305, 297, 630, 314, -1 },
|
||||
{ 319, 297, 841, 328, -1 },
|
||||
{ 333, 297, 1051, 342, -1 },
|
||||
{ 347, 297, 1261, 356, -1 },
|
||||
{ 361, 297, 1471, 370, -1 },
|
||||
{ 375, 297, 1682, 384, -1 },
|
||||
{ 389, 297, 1892, 398, -1 },
|
||||
{ 403, 148, 210, 410, 410 },
|
||||
{ 413, 174, 235, 426, 435 },
|
||||
{ 443, 105, 148, 450, 450 },
|
||||
{ 453, 74, 105, 460, 460 },
|
||||
{ 463, 52, 74, 470, 470 },
|
||||
{ 473, 37, 52, 480, 480 },
|
||||
{ 483, 1000, 1414, 493, 490 },
|
||||
{ 496, 707, 1000, 506, 503 },
|
||||
{ 509, 31, 44, 520, 517 },
|
||||
{ 524, 500, 707, 534, 531 },
|
||||
{ 537, 353, 500, 547, 544 },
|
||||
{ 550, 250, 353, 560, 557 },
|
||||
{ 563, 176, 250, 573, 570 },
|
||||
{ 576, 201, 276, 589, 598 },
|
||||
{ 609, 125, 176, 619, 616 },
|
||||
{ 622, 125, 324, 631, -1 },
|
||||
{ 637, 88, 125, 647, 644 },
|
||||
{ 650, 62, 88, 660, 657 },
|
||||
{ 663, 44, 62, 673, 670 },
|
||||
{ 676, 917, 1297, 686, 683 },
|
||||
{ 689, 648, 917, 699, 696 },
|
||||
{ 702, 28, 40, 713, 710 },
|
||||
{ 717, 458, 648, 727, 724 },
|
||||
{ 730, 324, 458, 740, 737 },
|
||||
{ 743, 229, 324, 634, 750 },
|
||||
{ 756, 162, 229, 766, 763 },
|
||||
{ 769, 114, 162, 779, 776 },
|
||||
{ 782, 114, 229, 791, 797 },
|
||||
{ 804, 81, 114, 814, 811 },
|
||||
{ 817, 81, 162, 826, -1 },
|
||||
{ 832, 57, 81, 842, 839 },
|
||||
{ 845, 40, 57, 855, 852 },
|
||||
{ 858, 110, 220, 865, 877 },
|
||||
{ 883, 860, 1220, 917, -1 },
|
||||
{ 891, 610, 860, 931, -1 },
|
||||
{ 899, 430, 610, 945, -1 },
|
||||
{ 907, 900, 1280, 916, -1 },
|
||||
{ 921, 640, 900, 930, -1 },
|
||||
{ 935, 450, 640, 944, -1 },
|
||||
{ 949, 1030, 1456, 956, 493 },
|
||||
{ 960, 728, 1030, 967, 506 },
|
||||
{ 971, 32, 45, 979, 520 },
|
||||
{ 984, 515, 728, 991, 534 },
|
||||
{ 995, 364, 515, 1002, 547 },
|
||||
{ 1006, 257, 364, 1013, 560 },
|
||||
{ 1017, 182, 257, 1024, 573 },
|
||||
{ 1028, 128, 182, 1035, 619 },
|
||||
{ 1039, 91, 128, 1046, 647 },
|
||||
{ 1050, 64, 91, 1057, 660 },
|
||||
{ 1061, 45, 64, 1068, 673 },
|
||||
{ 1072, 216, 330, 1081, -1 },
|
||||
{ 1090, 111.1, 146, 1100, -1 },
|
||||
{ 1119, 120, 235, 1129, 1148 },
|
||||
{ 1157, 90, 205, 1167, 1186 },
|
||||
{ 1195, 100, 148, 1206, 1322 },
|
||||
{ 1224, 240, 322.1, 1233, -1 },
|
||||
{ 1247, 240, 332, 1257, 1272 },
|
||||
{ 1281, 148, 200, 1292, 1316 },
|
||||
{ 1331, 105, 235, 1340, -1 },
|
||||
{ 1354, 254, 279.4, 1357, 1357 },
|
||||
{ 1363, 254, 330.2, 1366, 1366 },
|
||||
{ 1372, 254, 355.6, 1375, 1375 },
|
||||
{ 1381, 254, 381, 1384, -1 },
|
||||
{ 1381, 254, 381, 1384, -1 },
|
||||
{ 1390, 279.4, 304.8, 1393, 1399 },
|
||||
{ 1405, 279.4, 381, 1408, 1414 },
|
||||
{ 1420, 304.8, 482.6, 1423, -1 },
|
||||
{ 1429, 127, 177.8, 1432, -1 },
|
||||
{ 1436, 152.4, 228.6, 1443, -1 },
|
||||
{ 1456, 177.8, 228.6, 1463, 1459 },
|
||||
{ 1476, 228.6, 279.4, 1484, 1479 },
|
||||
{ 1498, 111.125, 146.05, 1504, -1 },
|
||||
{ 1516, 228.6, 304.8, 1526, 1533 },
|
||||
{ 1539, 304.8, 457.2, 1549, 1556 },
|
||||
{ 1562, 457.2, 609.6, 1572, 1579 },
|
||||
{ 1585, 609.6, 914.4, 1595, 1602 },
|
||||
{ 1608, 914.4, 1219.2, 1618, 1625 },
|
||||
{ 1631, 304.8, 486.918, 1634, -1 },
|
||||
{ 1641, 431.8, 558.8, 1079, 1646 },
|
||||
{ 1652, 165.1, 241.3, 3019, -1 },
|
||||
{ 1658, 558.8, 863.6, 1329, 1663 },
|
||||
{ 1669, 863.6, 1117.6, 875, 1674 },
|
||||
{ 1680, 279.4, 355.6, 1683, -1 },
|
||||
{ 1687, 304.8, 355.6, 1698, -1 },
|
||||
{ 1711, 184.15, 266.7, 1724, 1724 },
|
||||
{ 1734, 1117.6, 1727.2, 5, -1 },
|
||||
{ 1739, 215.9, 304.8, 1754, 1771 },
|
||||
{ 1785, 279.4, 377.825, 1799, 1810 },
|
||||
{ 1820, 215.9, 330.2, 1832, 1853 },
|
||||
{ 1872, 203.2, 330.2, 1886, -1 },
|
||||
{ 1903, 203.2, 254, 1918, 1936 },
|
||||
{ 1941, 76.2, 127, 1954, -1 },
|
||||
{ 1964, 101.6, 152.4, 1977, -1 },
|
||||
{ 1998, 152.4, 203.2, 2015, -1 },
|
||||
{ 2029, 127, 203.2, 2042, -1 },
|
||||
{ 2052, 139.7, 215.9, 2063, 2071 },
|
||||
{ 2081, 279.4, 431.8, 2091, 2099 },
|
||||
{ 2106, 215.9, 355.6, 2115, 1847 },
|
||||
{ 2124, 241.3, 381, 2139, 2154 },
|
||||
{ 2165, 215.9, 279.4, 2175, 1929 },
|
||||
{ 2185, 241.3, 304.8, 2201, 2217 },
|
||||
{ 2229, 215.9, 322.326, 2244, 2259 },
|
||||
{ 2270, 98.425, 190.5, 2281, 2298 },
|
||||
{ 2309, 104.775, 241.3, 2322, 2335 },
|
||||
{ 2341, 114.3, 263.525, 2354, 2368 },
|
||||
{ 2374, 120.65, 279.4, 2387, 2400 },
|
||||
{ 2406, 127, 292.1, 2419, 2432 },
|
||||
{ 2438, 98.425, 225.425, 2450, 2462 },
|
||||
{ 2467, 92.075, 165.1, 2479, 2497 },
|
||||
{ 2509, 215.9, 275.082, 2519, 2519 },
|
||||
{ 2526, 227.076, 355.6, 2537, 2545 },
|
||||
{ 2552, 330.2, 482.6, 2563, 2571 },
|
||||
{ 2578, 762, 1066.8, 2593, -1 },
|
||||
{ 2605, 275, 395, 2619, -1 },
|
||||
{ 2630, 210, 330, 2639, 2639 },
|
||||
{ 2645, 215, 315, 2657, -1 },
|
||||
{ 2666, 220, 220, 2676, 2692 },
|
||||
{ 2702, 110, 230, 2713, 2730 },
|
||||
{ 2741, 198, 275, 2744, -1 },
|
||||
{ 2757, 267, 389, 2612, -1 },
|
||||
{ 2767, 114, 229, 2778, -1 },
|
||||
{ 2795, 100, 150, 2810, -1 },
|
||||
{ 2822, 102, 165, 2828, 2842 },
|
||||
{ 2850, 324, 458, 2857, 2872 },
|
||||
{ 2881, 146, 215, 2889, 2897 },
|
||||
{ 2904, 102, 176, 2910, 2924 },
|
||||
{ 2932, 125, 176, 2938, 2952 },
|
||||
{ 2960, 97, 151, 2968, 2976 },
|
||||
{ 2983, 110, 208, 2989, 3003 },
|
||||
{ 3011, 110, 220, 3017, 3031 },
|
||||
{ 3039, 120, 320, 3045, 3059 },
|
||||
{ 3067, 160, 230, 3073, 3087 },
|
||||
{ 3095, 120, 309, 3101, 3115 },
|
||||
{ 3123, 196.85, 273.05, 3131, -1 },
|
||||
{ 3139, 273.05, 393.7, 3146, -1 },
|
||||
};
|
||||
|
||||
const struct {
|
||||
int ppd_name;
|
||||
int standard_name;
|
||||
} extra_ppd_names_offsets[] = {
|
||||
{ 634, 743 },
|
||||
{ 766, 756 },
|
||||
{ 779, 769 },
|
||||
{ 3153, 2309 },
|
||||
{ 880, 858 },
|
||||
{ 2301, 2270 },
|
||||
};
|
||||
|
BIN
gtk/stock-icons/24/gtk-orientation-landscape.png
Normal file
BIN
gtk/stock-icons/24/gtk-orientation-landscape.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 864 B |
BIN
gtk/stock-icons/24/gtk-orientation-portrait.png
Normal file
BIN
gtk/stock-icons/24/gtk-orientation-portrait.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 835 B |
BIN
gtk/stock-icons/24/gtk-orientation-reverse-landscape.png
Normal file
BIN
gtk/stock-icons/24/gtk-orientation-reverse-landscape.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 839 B |
@ -1 +1,6 @@
|
||||
SUBDIRS=input engines
|
||||
if OS_UNIX
|
||||
PRINTBACKENDS_SUBDIR=printbackends
|
||||
endif
|
||||
|
||||
SUBDIRS=input engines $(PRINTBACKENDS_SUBDIR)
|
||||
DIST_SUBDIRS=input engines printbackends
|
||||
|
7
modules/printbackends/Makefile.am
Normal file
7
modules/printbackends/Makefile.am
Normal file
@ -0,0 +1,7 @@
|
||||
if HAVE_CUPS
|
||||
CUPS_SUBDIR=cups
|
||||
endif
|
||||
|
||||
SUBDIRS=$(CUPS_SUBDIR) lpr pdf
|
||||
|
||||
DIST_SUBDIRS=cups pdf lpr
|
34
modules/printbackends/cups/Makefile.am
Normal file
34
modules/printbackends/cups/Makefile.am
Normal file
@ -0,0 +1,34 @@
|
||||
if OS_WIN32
|
||||
no_undefined = -no-undefined
|
||||
endif
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/gtk \
|
||||
-I$(top_builddir)/gtk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
-I$(top_builddir)/gdk \
|
||||
$(CUPS_CFLAGS) \
|
||||
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
|
||||
$(GTK_DEP_CFLAGS)
|
||||
|
||||
LDADDS = \
|
||||
$(GTK_DEP_LIBS) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
|
||||
backenddir = $(libdir)/gtk-2.0/$(GTK_BINARY_VERSION)/printbackends
|
||||
|
||||
backend_LTLIBRARIES = libprintbackend-cups.la
|
||||
|
||||
libprintbackend_cups_la_SOURCES = \
|
||||
gtkprintbackendcups.c \
|
||||
gtkprintercups.c \
|
||||
gtkcupsutils.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gtkprintbackendcups.h \
|
||||
gtkprintercups.h \
|
||||
gtkcupsutils.h
|
||||
|
||||
libprintbackend_cups_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
||||
libprintbackend_cups_la_LIBADD = $(LDADDS) $(CUPS_LIBS)
|
922
modules/printbackends/cups/gtkcupsutils.c
Normal file
922
modules/printbackends/cups/gtkcupsutils.c
Normal file
@ -0,0 +1,922 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkcupsutils.h: Statemachine implementation of POST and GET
|
||||
* cup calls which can be used to create a non-blocking cups API
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gtkcupsutils.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef void (*GtkCupsRequestStateFunc) (GtkCupsRequest *request);
|
||||
|
||||
static void _connect (GtkCupsRequest *request);
|
||||
static void _post_send (GtkCupsRequest *request);
|
||||
static void _post_write_request (GtkCupsRequest *request);
|
||||
static void _post_write_data (GtkCupsRequest *request);
|
||||
static void _post_check (GtkCupsRequest *request);
|
||||
static void _post_read_response (GtkCupsRequest *request);
|
||||
|
||||
static void _get_send (GtkCupsRequest *request);
|
||||
static void _get_check (GtkCupsRequest *request);
|
||||
static void _get_read_data (GtkCupsRequest *request);
|
||||
|
||||
struct _GtkCupsResult
|
||||
{
|
||||
gchar *error_msg;
|
||||
ipp_t *ipp_response;
|
||||
|
||||
guint is_error : 1;
|
||||
guint is_ipp_response : 1;
|
||||
};
|
||||
|
||||
|
||||
#define _GTK_CUPS_MAX_ATTEMPTS 10
|
||||
#define _GTK_CUPS_MAX_CHUNK_SIZE 8192
|
||||
|
||||
GtkCupsRequestStateFunc post_states[] = {_connect,
|
||||
_post_send,
|
||||
_post_write_request,
|
||||
_post_write_data,
|
||||
_post_check,
|
||||
_post_read_response};
|
||||
|
||||
GtkCupsRequestStateFunc get_states[] = {_connect,
|
||||
_get_send,
|
||||
_get_check,
|
||||
_get_read_data};
|
||||
|
||||
static void
|
||||
gtk_cups_result_set_error (GtkCupsResult *result,
|
||||
const char *error_msg,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
result->is_ipp_response = FALSE;
|
||||
|
||||
result->is_error = TRUE;
|
||||
|
||||
va_start (args, error_msg);
|
||||
result->error_msg = g_strdup_vprintf (error_msg, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
GtkCupsRequest *
|
||||
gtk_cups_request_new (http_t *connection,
|
||||
GtkCupsRequestType req_type,
|
||||
gint operation_id,
|
||||
gint data_fd,
|
||||
const char *server,
|
||||
const char *resource)
|
||||
{
|
||||
GtkCupsRequest *request;
|
||||
cups_lang_t *language;
|
||||
|
||||
request = g_new0 (GtkCupsRequest, 1);
|
||||
request->result = g_new0 (GtkCupsResult, 1);
|
||||
|
||||
request->result->error_msg = NULL;
|
||||
request->result->ipp_response = NULL;
|
||||
|
||||
request->result->is_error = FALSE;
|
||||
request->result->is_ipp_response = FALSE;
|
||||
|
||||
request->type = req_type;
|
||||
request->state = GTK_CUPS_REQUEST_START;
|
||||
|
||||
if (server)
|
||||
request->server = g_strdup (server);
|
||||
else
|
||||
request->server = g_strdup (cupsServer());
|
||||
|
||||
|
||||
if (resource)
|
||||
request->resource = g_strdup (resource);
|
||||
else
|
||||
request->resource = g_strdup ("/");
|
||||
|
||||
if (connection != NULL)
|
||||
{
|
||||
request->http = connection;
|
||||
request->own_http = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
request->http = NULL;
|
||||
request->http = httpConnectEncrypt (request->server, ippPort(), cupsEncryption());
|
||||
|
||||
if (request->http)
|
||||
httpBlocking (request->http, 0);
|
||||
|
||||
request->own_http = TRUE;
|
||||
}
|
||||
|
||||
request->last_status = HTTP_CONTINUE;
|
||||
|
||||
request->attempts = 0;
|
||||
request->data_fd = data_fd;
|
||||
|
||||
request->ipp_request = ippNew();
|
||||
request->ipp_request->request.op.operation_id = operation_id;
|
||||
request->ipp_request->request.op.request_id = 1;
|
||||
|
||||
language = cupsLangDefault ();
|
||||
|
||||
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
|
||||
"attributes-charset",
|
||||
NULL, "utf-8");
|
||||
|
||||
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
|
||||
"attributes-natural-language",
|
||||
NULL, language->language);
|
||||
|
||||
cupsLangFree (language);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cups_result_free (GtkCupsResult *result)
|
||||
{
|
||||
g_free (result->error_msg);
|
||||
|
||||
if (result->ipp_response)
|
||||
ippDelete (result->ipp_response);
|
||||
|
||||
g_free (result);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_cups_request_free (GtkCupsRequest *request)
|
||||
{
|
||||
if (request->own_http)
|
||||
if (request->http)
|
||||
httpClose (request->http);
|
||||
|
||||
if (request->ipp_request)
|
||||
ippDelete (request->ipp_request);
|
||||
|
||||
g_free (request->server);
|
||||
g_free (request->resource);
|
||||
|
||||
gtk_cups_result_free (request->result);
|
||||
|
||||
g_free (request);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_cups_request_read_write (GtkCupsRequest *request)
|
||||
{
|
||||
if (request->type == GTK_CUPS_POST)
|
||||
post_states[request->state](request);
|
||||
else if (request->type == GTK_CUPS_GET)
|
||||
get_states[request->state](request);
|
||||
|
||||
if (request->attempts > _GTK_CUPS_MAX_ATTEMPTS &&
|
||||
request->state != GTK_CUPS_REQUEST_DONE)
|
||||
{
|
||||
gtk_cups_result_set_error (request->result, "Too many failed attempts");
|
||||
request->state = GTK_CUPS_REQUEST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
}
|
||||
|
||||
if (request->state == GTK_CUPS_REQUEST_DONE)
|
||||
{
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
GtkCupsPollState
|
||||
gtk_cups_request_get_poll_state (GtkCupsRequest *request)
|
||||
{
|
||||
return request->poll_state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GtkCupsResult *
|
||||
gtk_cups_request_get_result (GtkCupsRequest *request)
|
||||
{
|
||||
return request->result;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_cups_request_ipp_add_string (GtkCupsRequest *request,
|
||||
ipp_tag_t group,
|
||||
ipp_tag_t tag,
|
||||
const char *name,
|
||||
const char *charset,
|
||||
const char *value)
|
||||
{
|
||||
ippAddString (request->ipp_request,
|
||||
group,
|
||||
tag,
|
||||
name,
|
||||
charset,
|
||||
value);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
ipp_tag_t value_tag;
|
||||
} ipp_option_t;
|
||||
|
||||
static const ipp_option_t ipp_options[] =
|
||||
{
|
||||
{ "blackplot", IPP_TAG_BOOLEAN },
|
||||
{ "brightness", IPP_TAG_INTEGER },
|
||||
{ "columns", IPP_TAG_INTEGER },
|
||||
{ "copies", IPP_TAG_INTEGER },
|
||||
{ "finishings", IPP_TAG_ENUM },
|
||||
{ "fitplot", IPP_TAG_BOOLEAN },
|
||||
{ "gamma", IPP_TAG_INTEGER },
|
||||
{ "hue", IPP_TAG_INTEGER },
|
||||
{ "job-k-limit", IPP_TAG_INTEGER },
|
||||
{ "job-page-limit", IPP_TAG_INTEGER },
|
||||
{ "job-priority", IPP_TAG_INTEGER },
|
||||
{ "job-quota-period", IPP_TAG_INTEGER },
|
||||
{ "landscape", IPP_TAG_BOOLEAN },
|
||||
{ "media", IPP_TAG_KEYWORD },
|
||||
{ "mirror", IPP_TAG_BOOLEAN },
|
||||
{ "natural-scaling", IPP_TAG_INTEGER },
|
||||
{ "number-up", IPP_TAG_INTEGER },
|
||||
{ "orientation-requested", IPP_TAG_ENUM },
|
||||
{ "page-bottom", IPP_TAG_INTEGER },
|
||||
{ "page-left", IPP_TAG_INTEGER },
|
||||
{ "page-ranges", IPP_TAG_RANGE },
|
||||
{ "page-right", IPP_TAG_INTEGER },
|
||||
{ "page-top", IPP_TAG_INTEGER },
|
||||
{ "penwidth", IPP_TAG_INTEGER },
|
||||
{ "ppi", IPP_TAG_INTEGER },
|
||||
{ "prettyprint", IPP_TAG_BOOLEAN },
|
||||
{ "printer-resolution", IPP_TAG_RESOLUTION },
|
||||
{ "print-quality", IPP_TAG_ENUM },
|
||||
{ "saturation", IPP_TAG_INTEGER },
|
||||
{ "scaling", IPP_TAG_INTEGER },
|
||||
{ "sides", IPP_TAG_KEYWORD },
|
||||
{ "wrap", IPP_TAG_BOOLEAN }
|
||||
};
|
||||
|
||||
|
||||
static ipp_tag_t
|
||||
_find_option_tag (const gchar *option)
|
||||
{
|
||||
int lower_bound, upper_bound, num_options;
|
||||
int current_option;
|
||||
ipp_tag_t result;
|
||||
|
||||
result = IPP_TAG_ZERO;
|
||||
|
||||
lower_bound = 0;
|
||||
upper_bound = num_options = (int)(sizeof(ipp_options) / sizeof(ipp_options[0])) - 1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int match;
|
||||
current_option = (int) (((upper_bound - lower_bound) / 2) + lower_bound);
|
||||
|
||||
match = strcasecmp(option, ipp_options[current_option].name);
|
||||
if (match == 0)
|
||||
{
|
||||
result = ipp_options[current_option].value_tag;
|
||||
return result;
|
||||
}
|
||||
else if (match < 0)
|
||||
{
|
||||
upper_bound = current_option - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lower_bound = current_option + 1;
|
||||
}
|
||||
|
||||
if (upper_bound == lower_bound && upper_bound == current_option)
|
||||
return result;
|
||||
|
||||
if (upper_bound < 0)
|
||||
return result;
|
||||
|
||||
if (lower_bound > num_options)
|
||||
return result;
|
||||
|
||||
if (upper_bound < lower_bound)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_cups_request_encode_option (GtkCupsRequest *request,
|
||||
const gchar *option,
|
||||
const gchar *value)
|
||||
{
|
||||
ipp_tag_t option_tag;
|
||||
|
||||
g_assert (option != NULL);
|
||||
g_assert (value != NULL);
|
||||
|
||||
option_tag = _find_option_tag (option);
|
||||
|
||||
if (option_tag == IPP_TAG_ZERO)
|
||||
{
|
||||
option_tag = IPP_TAG_NAME;
|
||||
if (strcasecmp (value, "true") == 0 ||
|
||||
strcasecmp (value, "false") == 0)
|
||||
{
|
||||
option_tag = IPP_TAG_BOOLEAN;
|
||||
}
|
||||
}
|
||||
|
||||
switch (option_tag)
|
||||
{
|
||||
case IPP_TAG_INTEGER:
|
||||
case IPP_TAG_ENUM:
|
||||
ippAddInteger (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option_tag,
|
||||
option,
|
||||
strtol (value, NULL, 0));
|
||||
break;
|
||||
|
||||
case IPP_TAG_BOOLEAN:
|
||||
{
|
||||
char b;
|
||||
b = 0;
|
||||
if (!strcasecmp(value, "true") ||
|
||||
!strcasecmp(value, "on") ||
|
||||
!strcasecmp(value, "yes"))
|
||||
b = 1;
|
||||
|
||||
ippAddBoolean(request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option,
|
||||
b);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case IPP_TAG_RANGE:
|
||||
{
|
||||
char *s;
|
||||
int lower;
|
||||
int upper;
|
||||
|
||||
if (*value == '-')
|
||||
{
|
||||
lower = 1;
|
||||
s = (char *)value;
|
||||
}
|
||||
else
|
||||
lower = strtol(value, &s, 0);
|
||||
|
||||
if (*s == '-')
|
||||
{
|
||||
if (s[1])
|
||||
upper = strtol(s + 1, NULL, 0);
|
||||
else
|
||||
upper = 2147483647;
|
||||
}
|
||||
else
|
||||
upper = lower;
|
||||
|
||||
ippAddRange (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option,
|
||||
lower,
|
||||
upper);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case IPP_TAG_RESOLUTION:
|
||||
{
|
||||
char *s;
|
||||
int xres;
|
||||
int yres;
|
||||
ipp_res_t units;
|
||||
|
||||
xres = strtol(value, &s, 0);
|
||||
|
||||
if (*s == 'x')
|
||||
yres = strtol(s + 1, &s, 0);
|
||||
else
|
||||
yres = xres;
|
||||
|
||||
if (strcasecmp(s, "dpc") == 0)
|
||||
units = IPP_RES_PER_CM;
|
||||
else
|
||||
units = IPP_RES_PER_INCH;
|
||||
|
||||
ippAddResolution (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option,
|
||||
units,
|
||||
xres,
|
||||
yres);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ippAddString (request->ipp_request,
|
||||
IPP_TAG_OPERATION,
|
||||
option_tag,
|
||||
option,
|
||||
NULL,
|
||||
value);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_connect (GtkCupsRequest *request)
|
||||
{
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
if (request->http == NULL)
|
||||
{
|
||||
request->http = httpConnectEncrypt (request->server, ippPort(), cupsEncryption());
|
||||
|
||||
if (request->http == NULL)
|
||||
request->attempts++;
|
||||
|
||||
if (request->http)
|
||||
httpBlocking (request->http, 0);
|
||||
|
||||
request->own_http = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
request->attempts = 0;
|
||||
request->state++;
|
||||
|
||||
/* we always write to the socket after we get
|
||||
the connection */
|
||||
request->poll_state = GTK_CUPS_HTTP_WRITE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_post_send (GtkCupsRequest *request)
|
||||
{
|
||||
gchar length[255];
|
||||
struct stat data_info;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_WRITE;
|
||||
|
||||
if (request->data_fd != 0)
|
||||
{
|
||||
fstat (request->data_fd, &data_info);
|
||||
sprintf (length, "%lu", (unsigned long)ippLength(request->ipp_request) + data_info.st_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (length, "%lu", (unsigned long)ippLength(request->ipp_request));
|
||||
}
|
||||
|
||||
httpClearFields(request->http);
|
||||
httpSetField(request->http, HTTP_FIELD_CONTENT_LENGTH, length);
|
||||
httpSetField(request->http, HTTP_FIELD_CONTENT_TYPE, "application/ipp");
|
||||
httpSetField(request->http, HTTP_FIELD_AUTHORIZATION, request->http->authstring);
|
||||
|
||||
if (httpPost(request->http, request->resource))
|
||||
{
|
||||
if (httpReconnect(request->http))
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Failed Post");
|
||||
}
|
||||
|
||||
request->attempts++;
|
||||
return;
|
||||
}
|
||||
|
||||
request->attempts = 0;
|
||||
|
||||
request->state = GTK_CUPS_POST_WRITE_REQUEST;
|
||||
request->ipp_request->state = IPP_IDLE;
|
||||
}
|
||||
|
||||
static void
|
||||
_post_write_request (GtkCupsRequest *request)
|
||||
{
|
||||
ipp_state_t ipp_status;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_WRITE;
|
||||
|
||||
ipp_status = ippWrite(request->http, request->ipp_request);
|
||||
|
||||
if (ipp_status == IPP_ERROR)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "%s",ippErrorString (cupsLastError ()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ipp_status == IPP_DATA)
|
||||
{
|
||||
if (request->data_fd != 0)
|
||||
request->state = GTK_CUPS_POST_WRITE_DATA;
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_POST_CHECK;
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_post_write_data (GtkCupsRequest *request)
|
||||
{
|
||||
ssize_t bytes;
|
||||
char buffer[_GTK_CUPS_MAX_CHUNK_SIZE];
|
||||
http_status_t http_status;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_WRITE;
|
||||
|
||||
if (httpCheck (request->http))
|
||||
http_status = httpUpdate(request->http);
|
||||
else
|
||||
http_status = request->last_status;
|
||||
|
||||
request->last_status = http_status;
|
||||
|
||||
|
||||
if (http_status == HTTP_CONTINUE || http_status == HTTP_OK)
|
||||
{
|
||||
/* send data */
|
||||
bytes = read(request->data_fd, buffer, _GTK_CUPS_MAX_CHUNK_SIZE);
|
||||
|
||||
if (bytes == 0)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_CHECK;
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
request->attempts = 0;
|
||||
return;
|
||||
}
|
||||
else if (bytes == -1)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Error reading from cache file: %s", strerror (errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (httpWrite(request->http, buffer, (int)bytes) < bytes)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Error writting to socket in Post %s", strerror (httpError (request->http)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
request->attempts++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_post_check (GtkCupsRequest *request)
|
||||
{
|
||||
http_status_t http_status;
|
||||
|
||||
http_status = request->last_status;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
if (http_status == HTTP_CONTINUE)
|
||||
{
|
||||
goto again;
|
||||
}
|
||||
else if (http_status == HTTP_UNAUTHORIZED)
|
||||
{
|
||||
/* TODO: callout for auth */
|
||||
g_warning ("NOT IMPLEMENTED: We need to prompt for authorization");
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Can't prompt for authorization");
|
||||
return;
|
||||
}
|
||||
else if (http_status == HTTP_ERROR)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
if (request->http->error != WSAENETDOWN &&
|
||||
request->http->error != WSAENETUNREACH)
|
||||
#else
|
||||
if (request->http->error != ENETDOWN &&
|
||||
request->http->error != ENETUNREACH)
|
||||
#endif /* G_OS_WIN32 */
|
||||
{
|
||||
request->attempts++;
|
||||
goto again;
|
||||
}
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Unknown HTTP error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* TODO: detect ssl in configure.ac */
|
||||
#if HAVE_SSL
|
||||
else if (http_status == HTTP_UPGRADE_REQUIRED)
|
||||
{
|
||||
/* Flush any error message... */
|
||||
httpFlush (request->http);
|
||||
|
||||
/* Reconnect... */
|
||||
httpReconnect (request->http);
|
||||
|
||||
/* Upgrade with encryption... */
|
||||
httpEncryption(request->http, HTTP_ENCRYPT_REQUIRED);
|
||||
|
||||
request->attempts++;
|
||||
goto again;
|
||||
}
|
||||
#endif
|
||||
else if (http_status != HTTP_OK)
|
||||
{
|
||||
int http_errno;
|
||||
|
||||
http_errno = httpError (request->http);
|
||||
|
||||
if (http_errno == EPIPE)
|
||||
request->state = GTK_CUPS_POST_CONNECT;
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
gtk_cups_result_set_error (request->result, "HTTP Error in POST %s", strerror (http_errno));
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
httpFlush(request->http);
|
||||
return;
|
||||
}
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
httpFlush(request->http);
|
||||
|
||||
request->last_status = HTTP_CONTINUE;
|
||||
httpClose (request->http);
|
||||
request->http = NULL;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_POST_READ_RESPONSE;
|
||||
return;
|
||||
}
|
||||
|
||||
again:
|
||||
http_status = HTTP_CONTINUE;
|
||||
|
||||
if (httpCheck (request->http))
|
||||
http_status = httpUpdate (request->http);
|
||||
|
||||
request->last_status = http_status;
|
||||
}
|
||||
|
||||
static void
|
||||
_post_read_response (GtkCupsRequest *request)
|
||||
{
|
||||
ipp_state_t ipp_status;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
if (request->result->ipp_response == NULL)
|
||||
request->result->ipp_response = ippNew();
|
||||
|
||||
ipp_status = ippRead (request->http,
|
||||
request->result->ipp_response);
|
||||
|
||||
if (ipp_status == IPP_ERROR)
|
||||
{
|
||||
gtk_cups_result_set_error (request->result, "%s", ippErrorString (cupsLastError()));
|
||||
|
||||
ippDelete (request->result->ipp_response);
|
||||
request->result->ipp_response = NULL;
|
||||
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
}
|
||||
else if (ipp_status == IPP_DATA)
|
||||
{
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_get_send (GtkCupsRequest *request)
|
||||
{
|
||||
request->poll_state = GTK_CUPS_HTTP_WRITE;
|
||||
|
||||
if (request->data_fd == 0)
|
||||
{
|
||||
gtk_cups_result_set_error (request->result, "Get requires an open file descriptor");
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
httpClearFields(request->http);
|
||||
httpSetField(request->http, HTTP_FIELD_AUTHORIZATION, request->http->authstring);
|
||||
|
||||
if (httpGet(request->http, request->resource))
|
||||
{
|
||||
if (httpReconnect(request->http))
|
||||
{
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Failed Get");
|
||||
}
|
||||
|
||||
request->attempts++;
|
||||
return;
|
||||
}
|
||||
|
||||
request->attempts = 0;
|
||||
|
||||
request->state = GTK_CUPS_GET_CHECK;
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
request->ipp_request->state = IPP_IDLE;
|
||||
}
|
||||
|
||||
static void
|
||||
_get_check (GtkCupsRequest *request)
|
||||
{
|
||||
http_status_t http_status;
|
||||
|
||||
http_status = request->last_status;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
if (http_status == HTTP_CONTINUE)
|
||||
{
|
||||
goto again;
|
||||
}
|
||||
else if (http_status == HTTP_UNAUTHORIZED)
|
||||
{
|
||||
/* TODO: callout for auth */
|
||||
g_warning ("NOT IMPLEMENTED: We need to prompt for authorization in a non blocking manner");
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
gtk_cups_result_set_error (request->result, "Can't prompt for authorization");
|
||||
return;
|
||||
}
|
||||
/* TODO: detect ssl in configure.ac */
|
||||
#if HAVE_SSL
|
||||
else if (http_status == HTTP_UPGRADE_REQUIRED)
|
||||
{
|
||||
/* Flush any error message... */
|
||||
httpFlush (request->http);
|
||||
|
||||
/* Reconnect... */
|
||||
httpReconnect (request->http);
|
||||
|
||||
/* Upgrade with encryption... */
|
||||
httpEncryption(request->http, HTTP_ENCRYPT_REQUIRED);
|
||||
|
||||
request->attempts++;
|
||||
goto again;
|
||||
}
|
||||
#endif
|
||||
else if (http_status != HTTP_OK)
|
||||
{
|
||||
int http_errno;
|
||||
|
||||
http_errno = httpError (request->http);
|
||||
|
||||
if (http_errno == EPIPE)
|
||||
request->state = GTK_CUPS_GET_CONNECT;
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
gtk_cups_result_set_error (request->result, "HTTP Error in GET %s", strerror (http_errno));
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
httpFlush(request->http);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
httpFlush (request->http);
|
||||
httpClose (request->http);
|
||||
request->last_status = HTTP_CONTINUE;
|
||||
request->http = NULL;
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
request->state = GTK_CUPS_GET_READ_DATA;
|
||||
return;
|
||||
}
|
||||
|
||||
again:
|
||||
http_status = HTTP_CONTINUE;
|
||||
|
||||
if (httpCheck (request->http))
|
||||
http_status = httpUpdate (request->http);
|
||||
|
||||
request->last_status = http_status;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_get_read_data (GtkCupsRequest *request)
|
||||
{
|
||||
char buffer[_GTK_CUPS_MAX_CHUNK_SIZE];
|
||||
int bytes;
|
||||
|
||||
request->poll_state = GTK_CUPS_HTTP_READ;
|
||||
|
||||
bytes = httpRead(request->http, buffer, sizeof(buffer));
|
||||
|
||||
if (bytes == 0)
|
||||
{
|
||||
request->state = GTK_CUPS_GET_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (write (request->data_fd, buffer, bytes) == -1)
|
||||
{
|
||||
char *error_msg;
|
||||
|
||||
request->state = GTK_CUPS_POST_DONE;
|
||||
request->poll_state = GTK_CUPS_HTTP_IDLE;
|
||||
|
||||
error_msg = strerror (errno);
|
||||
gtk_cups_result_set_error (request->result, error_msg ? error_msg:"");
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_cups_request_is_done (GtkCupsRequest *request)
|
||||
{
|
||||
return (request->state == GTK_CUPS_REQUEST_DONE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_cups_result_is_error (GtkCupsResult *result)
|
||||
{
|
||||
return result->is_error;
|
||||
}
|
||||
|
||||
ipp_t *
|
||||
gtk_cups_result_get_response (GtkCupsResult *result)
|
||||
{
|
||||
return result->ipp_response;
|
||||
}
|
||||
|
||||
const char *
|
||||
gtk_cups_result_get_error_string (GtkCupsResult *result)
|
||||
{
|
||||
return result->error_msg;
|
||||
}
|
||||
|
125
modules/printbackends/cups/gtkcupsutils.h
Normal file
125
modules/printbackends/cups/gtkcupsutils.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* gtkcupsutils.h
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CUPS_UTILS_H__
|
||||
#define __GTK_CUPS_UTILS_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <cups/cups.h>
|
||||
#include <cups/language.h>
|
||||
#include <cups/http.h>
|
||||
#include <cups/ipp.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkCupsRequest GtkCupsRequest;
|
||||
typedef struct _GtkCupsResult GtkCupsResult;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_CUPS_POST,
|
||||
GTK_CUPS_GET
|
||||
} GtkCupsRequestType;
|
||||
|
||||
|
||||
/**
|
||||
* Direction we should be polling the http socket on.
|
||||
* We are either reading or writting at each state.
|
||||
* This makes it easy for mainloops to connect to poll.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GTK_CUPS_HTTP_IDLE,
|
||||
GTK_CUPS_HTTP_READ,
|
||||
GTK_CUPS_HTTP_WRITE
|
||||
} GtkCupsPollState;
|
||||
|
||||
|
||||
struct _GtkCupsRequest
|
||||
{
|
||||
GtkCupsRequestType type;
|
||||
|
||||
http_t *http;
|
||||
http_status_t last_status;
|
||||
ipp_t *ipp_request;
|
||||
|
||||
gchar *server;
|
||||
gchar *resource;
|
||||
gint data_fd;
|
||||
gint attempts;
|
||||
|
||||
GtkCupsResult *result;
|
||||
|
||||
gint state;
|
||||
GtkCupsPollState poll_state;
|
||||
|
||||
gint own_http : 1;
|
||||
};
|
||||
|
||||
#define GTK_CUPS_REQUEST_START 0
|
||||
#define GTK_CUPS_REQUEST_DONE 500
|
||||
|
||||
/* POST states */
|
||||
enum
|
||||
{
|
||||
GTK_CUPS_POST_CONNECT = GTK_CUPS_REQUEST_START,
|
||||
GTK_CUPS_POST_SEND,
|
||||
GTK_CUPS_POST_WRITE_REQUEST,
|
||||
GTK_CUPS_POST_WRITE_DATA,
|
||||
GTK_CUPS_POST_CHECK,
|
||||
GTK_CUPS_POST_READ_RESPONSE,
|
||||
GTK_CUPS_POST_DONE = GTK_CUPS_REQUEST_DONE
|
||||
};
|
||||
|
||||
/* GET states */
|
||||
enum
|
||||
{
|
||||
GTK_CUPS_GET_CONNECT = GTK_CUPS_REQUEST_START,
|
||||
GTK_CUPS_GET_SEND,
|
||||
GTK_CUPS_GET_CHECK,
|
||||
GTK_CUPS_GET_READ_DATA,
|
||||
GTK_CUPS_GET_DONE = GTK_CUPS_REQUEST_DONE
|
||||
};
|
||||
|
||||
GtkCupsRequest * gtk_cups_request_new (http_t *connection,
|
||||
GtkCupsRequestType req_type,
|
||||
gint operation_id,
|
||||
gint data_fd,
|
||||
const char *server,
|
||||
const char *resource);
|
||||
void gtk_cups_request_ipp_add_string (GtkCupsRequest *request,
|
||||
ipp_tag_t group,
|
||||
ipp_tag_t tag,
|
||||
const char *name,
|
||||
const char *charset,
|
||||
const char *value);
|
||||
gboolean gtk_cups_request_read_write (GtkCupsRequest *request);
|
||||
GtkCupsPollState gtk_cups_request_get_poll_state (GtkCupsRequest *request);
|
||||
void gtk_cups_request_free (GtkCupsRequest *request);
|
||||
GtkCupsResult * gtk_cups_request_get_result (GtkCupsRequest *request);
|
||||
gboolean gtk_cups_request_is_done (GtkCupsRequest *request);
|
||||
void gtk_cups_request_encode_option (GtkCupsRequest *request,
|
||||
const gchar *option,
|
||||
const gchar *value);
|
||||
gboolean gtk_cups_result_is_error (GtkCupsResult *result);
|
||||
ipp_t * gtk_cups_result_get_response (GtkCupsResult *result);
|
||||
const char * gtk_cups_result_get_error_string (GtkCupsResult *result);
|
||||
|
||||
G_END_DECLS
|
||||
#endif
|
2629
modules/printbackends/cups/gtkprintbackendcups.c
Normal file
2629
modules/printbackends/cups/gtkprintbackendcups.c
Normal file
File diff suppressed because it is too large
Load Diff
42
modules/printbackends/cups/gtkprintbackendcups.h
Normal file
42
modules/printbackends/cups/gtkprintbackendcups.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackendcups.h: Default implementation of GtkPrintBackend for the Common Unix Print System (CUPS)
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_BACKEND_CUPS_H__
|
||||
#define __GTK_PRINT_BACKEND_CUPS_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkprintbackend.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_BACKEND_CUPS (gtk_print_backend_cups_get_type ())
|
||||
#define GTK_PRINT_BACKEND_CUPS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND_CUPS, GtkPrintBackendCups))
|
||||
#define GTK_IS_PRINT_BACKEND_CUPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND_CUPS))
|
||||
|
||||
typedef struct _GtkPrintBackendCups GtkPrintBackendCups;
|
||||
|
||||
GtkPrintBackend *gtk_print_backend_cups_new (void);
|
||||
GType gtk_print_backend_cups_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_BACKEND_CUPS_H__ */
|
||||
|
||||
|
125
modules/printbackends/cups/gtkprintercups.c
Normal file
125
modules/printbackends/cups/gtkprintercups.c
Normal file
@ -0,0 +1,125 @@
|
||||
/* GtkPrinterCupsCups
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkprintercups.h"
|
||||
|
||||
static void gtk_printer_cups_init (GtkPrinterCups *printer);
|
||||
static void gtk_printer_cups_class_init (GtkPrinterCupsClass *class);
|
||||
static void gtk_printer_cups_finalize (GObject *object);
|
||||
|
||||
static GtkPrinterClass *gtk_printer_cups_parent_class;
|
||||
static GType gtk_printer_cups_type = 0;
|
||||
|
||||
void
|
||||
gtk_printer_cups_register_type (GTypeModule *module)
|
||||
{
|
||||
static const GTypeInfo object_info =
|
||||
{
|
||||
sizeof (GtkPrinterCupsClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gtk_printer_cups_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkPrinterCups),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_printer_cups_init,
|
||||
};
|
||||
|
||||
gtk_printer_cups_type = g_type_module_register_type (module,
|
||||
GTK_TYPE_PRINTER,
|
||||
"GtkPrinterCups",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
GType
|
||||
gtk_printer_cups_get_type (void)
|
||||
{
|
||||
return gtk_printer_cups_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_cups_class_init (GtkPrinterCupsClass *class)
|
||||
{
|
||||
GObjectClass *object_class = (GObjectClass *) class;
|
||||
|
||||
gtk_printer_cups_parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
object_class->finalize = gtk_printer_cups_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_cups_init (GtkPrinterCups *printer)
|
||||
{
|
||||
printer->device_uri = NULL;
|
||||
printer->printer_uri = NULL;
|
||||
printer->state = 0;
|
||||
printer->hostname = NULL;
|
||||
printer->port = 0;
|
||||
printer->ppd_file = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_printer_cups_finalize (GObject *object)
|
||||
{
|
||||
g_return_if_fail (object != NULL);
|
||||
|
||||
GtkPrinterCups *printer = GTK_PRINTER_CUPS (object);
|
||||
|
||||
g_free (printer->device_uri);
|
||||
g_free (printer->printer_uri);
|
||||
g_free (printer->hostname);
|
||||
|
||||
if (printer->ppd_file)
|
||||
ppdClose (printer->ppd_file);
|
||||
|
||||
if (G_OBJECT_CLASS (gtk_printer_cups_parent_class)->finalize)
|
||||
G_OBJECT_CLASS (gtk_printer_cups_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_printer_cups_new:
|
||||
*
|
||||
* Creates a new #GtkPrinterCups.
|
||||
*
|
||||
* Return value: a new #GtkPrinterCups
|
||||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
GtkPrinterCups *
|
||||
gtk_printer_cups_new (const char *name,
|
||||
GtkPrintBackend *backend)
|
||||
{
|
||||
GObject *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_PRINTER_CUPS,
|
||||
"name", name,
|
||||
"backend", backend,
|
||||
"is-virtual", FALSE,
|
||||
NULL);
|
||||
|
||||
return (GtkPrinterCups *) result;
|
||||
}
|
||||
|
||||
ppd_file_t *
|
||||
gtk_printer_cups_get_ppd (GtkPrinterCups *printer)
|
||||
{
|
||||
return printer->ppd_file;
|
||||
}
|
70
modules/printbackends/cups/gtkprintercups.h
Normal file
70
modules/printbackends/cups/gtkprintercups.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* GtkPrinterCups
|
||||
* Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GTK_PRINTER_CUPS_H__
|
||||
#define __GTK_PRINTER_CUPS_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <cups/cups.h>
|
||||
#include <cups/ppd.h>
|
||||
|
||||
#include "gtkprinter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINTER_CUPS (gtk_printer_cups_get_type ())
|
||||
#define GTK_PRINTER_CUPS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINTER_CUPS, GtkPrinterCups))
|
||||
#define GTK_PRINTER_CUPS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINTER_CUPS, GtkPrinterCupsClass))
|
||||
#define GTK_IS_PRINTER_CUPS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINTER_CUPS))
|
||||
#define GTK_IS_PRINTER_CUPS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINTER_CUPS))
|
||||
#define GTK_PRINTER_CUPS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINTER_CUPS, GtkPrinterCupsClass))
|
||||
|
||||
typedef struct _GtkPrinterCups GtkPrinterCups;
|
||||
typedef struct _GtkPrinterCupsClass GtkPrinterCupsClass;
|
||||
typedef struct _GtkPrinterCupsPrivate GtkPrinterCupsPrivate;
|
||||
|
||||
struct _GtkPrinterCups
|
||||
{
|
||||
GtkPrinter parent_instance;
|
||||
|
||||
gchar *device_uri;
|
||||
gchar *printer_uri;
|
||||
gchar *hostname;
|
||||
gint port;
|
||||
|
||||
ipp_pstate_t state;
|
||||
gboolean reading_ppd;
|
||||
ppd_file_t *ppd_file;
|
||||
};
|
||||
|
||||
struct _GtkPrinterCupsClass
|
||||
{
|
||||
GtkPrinterClass parent_class;
|
||||
|
||||
};
|
||||
|
||||
GType gtk_printer_cups_get_type (void) G_GNUC_CONST;
|
||||
void gtk_printer_cups_register_type (GTypeModule *module);
|
||||
GtkPrinterCups *gtk_printer_cups_new (const char *name,
|
||||
GtkPrintBackend *backend);
|
||||
ppd_file_t * gtk_printer_cups_get_ppd (GtkPrinterCups *printer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINTER_CUPS_H__ */
|
29
modules/printbackends/lpr/Makefile.am
Normal file
29
modules/printbackends/lpr/Makefile.am
Normal file
@ -0,0 +1,29 @@
|
||||
if OS_WIN32
|
||||
no_undefined = -no-undefined
|
||||
endif
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/gtk \
|
||||
-I$(top_builddir)/gtk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
|
||||
$(GTK_DEP_CFLAGS)
|
||||
|
||||
LDADDS = \
|
||||
$(GTK_DEP_LIBS) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
|
||||
backenddir = $(libdir)/gtk-2.0/$(GTK_BINARY_VERSION)/printbackends
|
||||
|
||||
backend_LTLIBRARIES = libprintbackend-lpr.la
|
||||
|
||||
libprintbackend_lpr_la_SOURCES = \
|
||||
gtkprintbackendlpr.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gtkprintbackendlpr.h
|
||||
|
||||
libprintbackend_lpr_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
||||
libprintbackend_lpr_la_LIBADD = $(LDADDS)
|
562
modules/printbackends/lpr/gtkprintbackendlpr.c
Normal file
562
modules/printbackends/lpr/gtkprintbackendlpr.c
Normal file
@ -0,0 +1,562 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackendlpr.c: Default implementation of GtkPrintBackend
|
||||
* for printing to lpr
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include <cairo.h>
|
||||
#include <cairo-ps.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "gtkprintoperation.h"
|
||||
|
||||
#include "gtkprintbackendlpr.h"
|
||||
|
||||
#include "gtkprinter.h"
|
||||
|
||||
typedef struct _GtkPrintBackendLprClass GtkPrintBackendLprClass;
|
||||
|
||||
#define GTK_PRINT_BACKEND_LPR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_BACKEND_LPR, GtkPrintBackendLprClass))
|
||||
#define GTK_IS_PRINT_BACKEND_LPR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_BACKEND_LPR))
|
||||
#define GTK_PRINT_BACKEND_LPR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_BACKEND_LPR, GtkPrintBackendLprClass))
|
||||
|
||||
#define _LPR_MAX_CHUNK_SIZE 8192
|
||||
|
||||
static GType print_backend_lpr_type = 0;
|
||||
|
||||
struct _GtkPrintBackendLprClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkPrintBackendLpr
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrinter *printer;
|
||||
|
||||
GHashTable *printers;
|
||||
};
|
||||
|
||||
static GObjectClass *backend_parent_class;
|
||||
|
||||
static void gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class);
|
||||
static void gtk_print_backend_lpr_iface_init (GtkPrintBackendIface *iface);
|
||||
static void gtk_print_backend_lpr_init (GtkPrintBackendLpr *impl);
|
||||
static void gtk_print_backend_lpr_finalize (GObject *object);
|
||||
static GList * lpr_request_printer_list (GtkPrintBackend *print_backend);
|
||||
static void lpr_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings);
|
||||
static gboolean lpr_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options);
|
||||
static GtkPrinterOptionSet *lpr_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
static void lpr_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
static void lpr_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right);
|
||||
static void lpr_printer_request_details (GtkPrinter *printer);
|
||||
static GList * lpr_printer_list_papers (GtkPrinter *printer);
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_register_type (GTypeModule *module)
|
||||
{
|
||||
if (!print_backend_lpr_type)
|
||||
{
|
||||
static const GTypeInfo print_backend_lpr_info =
|
||||
{
|
||||
sizeof (GtkPrintBackendLprClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gtk_print_backend_lpr_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkPrintBackendLpr),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_print_backend_lpr_init,
|
||||
};
|
||||
|
||||
static const GInterfaceInfo print_backend_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gtk_print_backend_lpr_iface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
|
||||
print_backend_lpr_type = g_type_module_register_type (module,
|
||||
G_TYPE_OBJECT,
|
||||
"GtkPrintBackendLpr",
|
||||
&print_backend_lpr_info, 0);
|
||||
g_type_module_add_interface (module,
|
||||
print_backend_lpr_type,
|
||||
GTK_TYPE_PRINT_BACKEND,
|
||||
&print_backend_info);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
pb_module_init (GTypeModule *module)
|
||||
{
|
||||
gtk_print_backend_lpr_register_type (module);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
pb_module_exit (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT GtkPrintBackend *
|
||||
pb_module_create (void)
|
||||
{
|
||||
return gtk_print_backend_lpr_new ();
|
||||
}
|
||||
|
||||
/*
|
||||
* GtkPrintBackendLpr
|
||||
*/
|
||||
GType
|
||||
gtk_print_backend_lpr_get_type (void)
|
||||
{
|
||||
return print_backend_lpr_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_backend_lpr_new:
|
||||
*
|
||||
* Creates a new #GtkPrintBackendLpr object. #GtkPrintBackendLpr
|
||||
* implements the #GtkPrintBackend interface with direct access to
|
||||
* the filesystem using Unix/Linux API calls
|
||||
*
|
||||
* Return value: the new #GtkPrintBackendLpr object
|
||||
**/
|
||||
GtkPrintBackend *
|
||||
gtk_print_backend_lpr_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_PRINT_BACKEND_LPR, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
backend_parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->finalize = gtk_print_backend_lpr_finalize;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_write (void *cache_fd_as_pointer,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
cairo_status_t result;
|
||||
gint cache_fd;
|
||||
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
|
||||
|
||||
result = CAIRO_STATUS_WRITE_ERROR;
|
||||
|
||||
/* write out the buffer */
|
||||
if (write (cache_fd, data, length) != -1)
|
||||
result = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static cairo_surface_t *
|
||||
lpr_printer_create_cairo_surface (GtkPrinter *printer,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
gint cache_fd)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_ps_surface_create_for_stream (_cairo_write, GINT_TO_POINTER (cache_fd), width, height);
|
||||
|
||||
/* TODO: DPI from settings object? */
|
||||
cairo_ps_surface_set_dpi (surface, 300, 300);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static GtkPrinter *
|
||||
gtk_print_backend_lpr_find_printer (GtkPrintBackend *print_backend,
|
||||
const gchar *printer_name)
|
||||
{
|
||||
GtkPrintBackendLpr *lpr_print_backend;
|
||||
GtkPrinter *printer;
|
||||
|
||||
lpr_print_backend = GTK_PRINT_BACKEND_LPR (print_backend);
|
||||
|
||||
printer = NULL;
|
||||
if (strcmp (gtk_printer_get_name (lpr_print_backend->printer), printer_name) == 0)
|
||||
printer = lpr_print_backend->printer;
|
||||
|
||||
return printer;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkPrintBackend *backend;
|
||||
GtkPrintJobCompleteFunc callback;
|
||||
GtkPrintJob *job;
|
||||
gpointer user_data;
|
||||
GDestroyNotify dnotify;
|
||||
|
||||
gint in;
|
||||
gint out;
|
||||
gint err;
|
||||
|
||||
} _PrintStreamData;
|
||||
|
||||
static void
|
||||
lpr_print_cb (GtkPrintBackendLpr *print_backend,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
_PrintStreamData *ps = (_PrintStreamData *) user_data;
|
||||
|
||||
if (ps->in > 0)
|
||||
close (ps->in);
|
||||
|
||||
if (ps->out > 0)
|
||||
close (ps->out);
|
||||
|
||||
if (ps->err > 0)
|
||||
close (ps->err);
|
||||
|
||||
if (ps->callback)
|
||||
ps->callback (ps->job, ps->user_data, error);
|
||||
|
||||
if (ps->dnotify)
|
||||
ps->dnotify (ps->user_data);
|
||||
|
||||
gtk_print_job_set_status (ps->job,
|
||||
(error != NULL)?GTK_PRINT_STATUS_FINISHED_ABORTED:GTK_PRINT_STATUS_FINISHED);
|
||||
|
||||
if (ps->job)
|
||||
g_object_unref (ps->job);
|
||||
|
||||
g_free (ps);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
lpr_write (GIOChannel *source,
|
||||
GIOCondition con,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar buf[_LPR_MAX_CHUNK_SIZE];
|
||||
gsize bytes_read;
|
||||
GError *error;
|
||||
_PrintStreamData *ps = (_PrintStreamData *) user_data;
|
||||
gint source_fd;
|
||||
|
||||
error = NULL;
|
||||
|
||||
source_fd = g_io_channel_unix_get_fd (source);
|
||||
|
||||
bytes_read = read (source_fd,
|
||||
buf,
|
||||
_LPR_MAX_CHUNK_SIZE);
|
||||
|
||||
if (bytes_read > 0)
|
||||
{
|
||||
if (write (ps->in, buf, bytes_read) == -1)
|
||||
{
|
||||
error = g_error_new (GTK_PRINT_ERROR,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
g_strerror (errno));
|
||||
}
|
||||
}
|
||||
else if (bytes_read == -1)
|
||||
{
|
||||
error = g_error_new (GTK_PRINT_ERROR,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
g_strerror (errno));
|
||||
}
|
||||
|
||||
if (bytes_read == 0 || error != NULL)
|
||||
{
|
||||
lpr_print_cb (GTK_PRINT_BACKEND_LPR (ps->backend), error, user_data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define LPR_COMMAND "lpr"
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_print_stream (GtkPrintBackend *print_backend,
|
||||
GtkPrintJob *job,
|
||||
gint data_fd,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify)
|
||||
{
|
||||
GError *error;
|
||||
GtkPrinter *printer;
|
||||
_PrintStreamData *ps;
|
||||
GtkPrintSettings *settings;
|
||||
GIOChannel *send_channel;
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
const char *cmd_line;
|
||||
|
||||
printer = gtk_print_job_get_printer (job);
|
||||
settings = gtk_print_job_get_settings (job);
|
||||
|
||||
error = NULL;
|
||||
|
||||
cmd_line = gtk_print_settings_get (settings, "lpr-commandline");
|
||||
if (cmd_line == NULL)
|
||||
cmd_line = LPR_COMMAND;
|
||||
|
||||
ps = g_new0 (_PrintStreamData, 1);
|
||||
ps->callback = callback;
|
||||
ps->user_data = user_data;
|
||||
ps->dnotify = dnotify;
|
||||
ps->job = g_object_ref (job);
|
||||
ps->in = 0;
|
||||
ps->out = 0;
|
||||
ps->err = 0;
|
||||
|
||||
/* spawn lpr with pipes and pipe ps file to lpr */
|
||||
if (!g_shell_parse_argv (cmd_line,
|
||||
&argc,
|
||||
&argv,
|
||||
&error))
|
||||
{
|
||||
lpr_print_cb (GTK_PRINT_BACKEND_LPR (print_backend),
|
||||
error, ps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_spawn_async_with_pipes (NULL,
|
||||
argv,
|
||||
NULL,
|
||||
G_SPAWN_SEARCH_PATH,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&ps->in,
|
||||
&ps->out,
|
||||
&ps->err,
|
||||
&error))
|
||||
{
|
||||
lpr_print_cb (GTK_PRINT_BACKEND_LPR (print_backend),
|
||||
error, ps);
|
||||
|
||||
goto out;
|
||||
|
||||
}
|
||||
|
||||
send_channel = g_io_channel_unix_new (data_fd);
|
||||
|
||||
g_io_add_watch (send_channel,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
(GIOFunc) lpr_write,
|
||||
ps);
|
||||
|
||||
out:
|
||||
g_strfreev (argv);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_iface_init (GtkPrintBackendIface *iface)
|
||||
{
|
||||
iface->get_printer_list = lpr_request_printer_list;
|
||||
iface->find_printer = gtk_print_backend_lpr_find_printer;
|
||||
iface->print_stream = gtk_print_backend_lpr_print_stream;
|
||||
iface->printer_request_details = lpr_printer_request_details;
|
||||
iface->printer_create_cairo_surface = lpr_printer_create_cairo_surface;
|
||||
iface->printer_get_options = lpr_printer_get_options;
|
||||
iface->printer_mark_conflicts = lpr_printer_mark_conflicts;
|
||||
iface->printer_get_settings_from_options = lpr_printer_get_settings_from_options;
|
||||
iface->printer_prepare_for_print = lpr_printer_prepare_for_print;
|
||||
iface->printer_list_papers = lpr_printer_list_papers;
|
||||
iface->printer_get_hard_margins = lpr_printer_get_hard_margins;
|
||||
}
|
||||
|
||||
static GList *
|
||||
lpr_request_printer_list (GtkPrintBackend *backend)
|
||||
{
|
||||
GList *l;
|
||||
GtkPrintBackendLpr *lpr_backend;
|
||||
|
||||
l = NULL;
|
||||
|
||||
lpr_backend = GTK_PRINT_BACKEND_LPR (backend);
|
||||
|
||||
if (lpr_backend->printer)
|
||||
l = g_list_append (l, lpr_backend->printer);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_init (GtkPrintBackendLpr *backend_lpr)
|
||||
{
|
||||
GtkPrinter *printer;
|
||||
|
||||
printer = gtk_printer_new (_("Print to LPR"),
|
||||
GTK_PRINT_BACKEND (backend_lpr),
|
||||
TRUE);
|
||||
gtk_printer_set_has_details (printer, TRUE);
|
||||
gtk_printer_set_icon_name (printer, "printer");
|
||||
gtk_printer_set_is_active (printer, TRUE);
|
||||
|
||||
backend_lpr->printer = printer;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_lpr_finalize (GObject *object)
|
||||
{
|
||||
GtkPrintBackendLpr *backend_lpr;
|
||||
|
||||
backend_lpr = GTK_PRINT_BACKEND_LPR (object);
|
||||
|
||||
g_object_unref (backend_lpr->printer);
|
||||
|
||||
backend_parent_class->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
lpr_printer_request_details (GtkPrinter *printer)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkPrinterOptionSet *
|
||||
lpr_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
GtkPrinterOptionSet *set;
|
||||
GtkPrinterOption *option;
|
||||
const char *command;
|
||||
char *n_up[] = {"1", "2", "4", "6", "9", "16" };
|
||||
|
||||
set = gtk_printer_option_set_new ();
|
||||
|
||||
option = gtk_printer_option_new ("gtk-n-up", _("Pages Per Sheet"), GTK_PRINTER_OPTION_TYPE_PICKONE);
|
||||
gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
|
||||
n_up, n_up);
|
||||
gtk_printer_option_set (option, "1");
|
||||
gtk_printer_option_set_add (set, option);
|
||||
g_object_unref (option);
|
||||
|
||||
option = gtk_printer_option_new ("gtk-main-page-custom-input", _("Command Line"), GTK_PRINTER_OPTION_TYPE_STRING);
|
||||
option->group = g_strdup ("GtkPrintDialogExtention");
|
||||
if (settings != NULL &&
|
||||
(command = gtk_print_settings_get (settings, "lpr-commandline"))!= NULL)
|
||||
gtk_printer_option_set (option, command);
|
||||
else
|
||||
gtk_printer_option_set (option, LPR_COMMAND);
|
||||
gtk_printer_option_set_add (set, option);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
lpr_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
lpr_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings)
|
||||
{
|
||||
GtkPrinterOption *option;
|
||||
|
||||
option = gtk_printer_option_set_lookup (options, "gtk-main-page-custom-input");
|
||||
gtk_print_settings_set (settings, "lpr-commandline", option->value);
|
||||
}
|
||||
|
||||
static void
|
||||
lpr_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
double scale;
|
||||
|
||||
print_job->print_pages = gtk_print_settings_get_print_pages (settings);
|
||||
print_job->page_ranges = NULL;
|
||||
print_job->num_page_ranges = 0;
|
||||
|
||||
if (print_job->print_pages == GTK_PRINT_PAGES_RANGES)
|
||||
print_job->page_ranges =
|
||||
gtk_print_settings_get_page_ranges (settings,
|
||||
&print_job->num_page_ranges);
|
||||
|
||||
print_job->collate = gtk_print_settings_get_collate (settings);
|
||||
print_job->reverse = gtk_print_settings_get_reverse (settings);
|
||||
print_job->num_copies = gtk_print_settings_get_num_copies (settings);
|
||||
|
||||
scale = gtk_print_settings_get_scale (settings);
|
||||
if (scale != 100.0)
|
||||
print_job->scale = scale/100.0;
|
||||
|
||||
print_job->page_set = gtk_print_settings_get_page_set (settings);
|
||||
print_job->rotate_to_orientation = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
lpr_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right)
|
||||
{
|
||||
*top = 0;
|
||||
*bottom = 0;
|
||||
*left = 0;
|
||||
*right = 0;
|
||||
}
|
||||
|
||||
static GList *
|
||||
lpr_printer_list_papers (GtkPrinter *printer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
43
modules/printbackends/lpr/gtkprintbackendlpr.h
Normal file
43
modules/printbackends/lpr/gtkprintbackendlpr.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackendlpr.h: Default implementation of GtkPrintBackend
|
||||
* for printing to lpr
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_BACKEND_LPR_H__
|
||||
#define __GTK_PRINT_BACKEND_LPR_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkprintbackend.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_BACKEND_LPR (gtk_print_backend_lpr_get_type ())
|
||||
#define GTK_PRINT_BACKEND_LPR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND_LPR, GtkPrintBackendLpr))
|
||||
#define GTK_IS_PRINT_BACKEND_LPR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND_LPR))
|
||||
|
||||
typedef struct _GtkPrintBackendLpr GtkPrintBackendLpr;
|
||||
|
||||
GtkPrintBackend *gtk_print_backend_lpr_new (void);
|
||||
GType gtk_print_backend_lpr_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_BACKEND_LPR_H__ */
|
||||
|
||||
|
29
modules/printbackends/pdf/Makefile.am
Normal file
29
modules/printbackends/pdf/Makefile.am
Normal file
@ -0,0 +1,29 @@
|
||||
if OS_WIN32
|
||||
no_undefined = -no-undefined
|
||||
endif
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/gtk \
|
||||
-I$(top_builddir)/gtk \
|
||||
-I$(top_srcdir)/gdk \
|
||||
-I$(top_builddir)/gdk \
|
||||
-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED \
|
||||
$(GTK_DEP_CFLAGS)
|
||||
|
||||
LDADDS = \
|
||||
$(GTK_DEP_LIBS) \
|
||||
$(top_builddir)/gtk/$(gtktargetlib)
|
||||
|
||||
backenddir = $(libdir)/gtk-2.0/$(GTK_BINARY_VERSION)/printbackends
|
||||
|
||||
backend_LTLIBRARIES = libprintbackend-pdf.la
|
||||
|
||||
libprintbackend_pdf_la_SOURCES = \
|
||||
gtkprintbackendpdf.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gtkprintbackendpdf.h
|
||||
|
||||
libprintbackend_pdf_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
||||
libprintbackend_pdf_la_LIBADD = $(LDADDS)
|
530
modules/printbackends/pdf/gtkprintbackendpdf.c
Normal file
530
modules/printbackends/pdf/gtkprintbackendpdf.c
Normal file
@ -0,0 +1,530 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackendpdf.c: Default implementation of GtkPrintBackend
|
||||
* for printing to PDF files
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <config.h>
|
||||
#include <errno.h>
|
||||
#include <cairo.h>
|
||||
#include <cairo-pdf.h>
|
||||
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
#include "gtkprintoperation.h"
|
||||
|
||||
#include "gtkprintbackend.h"
|
||||
#include "gtkprintbackendpdf.h"
|
||||
|
||||
#include "gtkprinter.h"
|
||||
|
||||
typedef struct _GtkPrintBackendPdfClass GtkPrintBackendPdfClass;
|
||||
|
||||
#define GTK_PRINT_BACKEND_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PRINT_BACKEND_PDF, GtkPrintBackendPdfClass))
|
||||
#define GTK_IS_PRINT_BACKEND_PDF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PRINT_BACKEND_PDF))
|
||||
#define GTK_PRINT_BACKEND_PDF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PRINT_BACKEND_PDF, GtkPrintBackendPdfClass))
|
||||
|
||||
#define _PDF_MAX_CHUNK_SIZE 8192
|
||||
|
||||
static GType print_backend_pdf_type = 0;
|
||||
|
||||
struct _GtkPrintBackendPdfClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct _GtkPrintBackendPdf
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GtkPrinter *printer;
|
||||
|
||||
GHashTable *printers;
|
||||
};
|
||||
|
||||
static GObjectClass *backend_parent_class;
|
||||
|
||||
static void gtk_print_backend_pdf_class_init (GtkPrintBackendPdfClass *class);
|
||||
static void gtk_print_backend_pdf_iface_init (GtkPrintBackendIface *iface);
|
||||
static void gtk_print_backend_pdf_init (GtkPrintBackendPdf *impl);
|
||||
static void gtk_print_backend_pdf_finalize (GObject *object);
|
||||
static GList * pdf_request_printer_list (GtkPrintBackend *print_backend);
|
||||
static void pdf_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings);
|
||||
static gboolean pdf_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options);
|
||||
static GtkPrinterOptionSet *pdf_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
static void pdf_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup);
|
||||
static void pdf_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right);
|
||||
static void pdf_printer_request_details (GtkPrinter *printer);
|
||||
static GList * pdf_printer_list_papers (GtkPrinter *printer);
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_register_type (GTypeModule *module)
|
||||
{
|
||||
if (!print_backend_pdf_type)
|
||||
{
|
||||
static const GTypeInfo print_backend_pdf_info =
|
||||
{
|
||||
sizeof (GtkPrintBackendPdfClass),
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gtk_print_backend_pdf_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GtkPrintBackendPdf),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gtk_print_backend_pdf_init,
|
||||
};
|
||||
|
||||
static const GInterfaceInfo print_backend_info =
|
||||
{
|
||||
(GInterfaceInitFunc) gtk_print_backend_pdf_iface_init, /* interface_init */
|
||||
NULL, /* interface_finalize */
|
||||
NULL /* interface_data */
|
||||
};
|
||||
|
||||
print_backend_pdf_type = g_type_module_register_type (module,
|
||||
G_TYPE_OBJECT,
|
||||
"GtkPrintBackendPdf",
|
||||
&print_backend_pdf_info, 0);
|
||||
g_type_module_add_interface (module,
|
||||
print_backend_pdf_type,
|
||||
GTK_TYPE_PRINT_BACKEND,
|
||||
&print_backend_info);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
pb_module_init (GTypeModule *module)
|
||||
{
|
||||
gtk_print_backend_pdf_register_type (module);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
pb_module_exit (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT GtkPrintBackend *
|
||||
pb_module_create (void)
|
||||
{
|
||||
return gtk_print_backend_pdf_new ();
|
||||
}
|
||||
|
||||
/*
|
||||
* GtkPrintBackendPdf
|
||||
*/
|
||||
GType
|
||||
gtk_print_backend_pdf_get_type (void)
|
||||
{
|
||||
return print_backend_pdf_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_print_backend_pdf_new:
|
||||
*
|
||||
* Creates a new #GtkPrintBackendPdf object. #GtkPrintBackendPdf
|
||||
* implements the #GtkPrintBackend interface with direct access to
|
||||
* the filesystem using Unix/Linux API calls
|
||||
*
|
||||
* Return value: the new #GtkPrintBackendPdf object
|
||||
**/
|
||||
GtkPrintBackend *
|
||||
gtk_print_backend_pdf_new (void)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_PRINT_BACKEND_PDF, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_class_init (GtkPrintBackendPdfClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
|
||||
backend_parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->finalize = gtk_print_backend_pdf_finalize;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_write (void *cache_fd_as_pointer,
|
||||
const unsigned char *data,
|
||||
unsigned int length)
|
||||
{
|
||||
cairo_status_t result;
|
||||
gint cache_fd;
|
||||
cache_fd = GPOINTER_TO_INT (cache_fd_as_pointer);
|
||||
|
||||
result = CAIRO_STATUS_WRITE_ERROR;
|
||||
|
||||
/* write out the buffer */
|
||||
if (write (cache_fd, data, length) != -1)
|
||||
result = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static cairo_surface_t *
|
||||
pdf_printer_create_cairo_surface (GtkPrinter *printer,
|
||||
gdouble width,
|
||||
gdouble height,
|
||||
gint cache_fd)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
|
||||
surface = cairo_pdf_surface_create_for_stream (_cairo_write, GINT_TO_POINTER (cache_fd), width, height);
|
||||
|
||||
/* TODO: DPI from settings object? */
|
||||
cairo_pdf_surface_set_dpi (surface, 300, 300);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static GtkPrinter *
|
||||
gtk_print_backend_pdf_find_printer (GtkPrintBackend *print_backend,
|
||||
const gchar *printer_name)
|
||||
{
|
||||
GtkPrintBackendPdf *pdf_print_backend;
|
||||
GtkPrinter *printer;
|
||||
|
||||
pdf_print_backend = GTK_PRINT_BACKEND_PDF (print_backend);
|
||||
|
||||
printer = NULL;
|
||||
if (strcmp (gtk_printer_get_name (pdf_print_backend->printer), printer_name) == 0)
|
||||
printer = pdf_print_backend->printer;
|
||||
|
||||
return printer;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkPrintBackend *backend;
|
||||
GtkPrintJobCompleteFunc callback;
|
||||
GtkPrintJob *job;
|
||||
gint target_fd;
|
||||
gpointer user_data;
|
||||
GDestroyNotify dnotify;
|
||||
} _PrintStreamData;
|
||||
|
||||
static void
|
||||
pdf_print_cb (GtkPrintBackendPdf *print_backend,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
_PrintStreamData *ps = (_PrintStreamData *) user_data;
|
||||
|
||||
if (ps->target_fd > 0)
|
||||
close (ps->target_fd);
|
||||
|
||||
if (ps->callback)
|
||||
ps->callback (ps->job, ps->user_data, error);
|
||||
|
||||
if (ps->dnotify)
|
||||
ps->dnotify (ps->user_data);
|
||||
|
||||
gtk_print_job_set_status (ps->job,
|
||||
(error != NULL)?GTK_PRINT_STATUS_FINISHED_ABORTED:GTK_PRINT_STATUS_FINISHED);
|
||||
|
||||
if (ps->job)
|
||||
g_object_unref (ps->job);
|
||||
|
||||
g_free (ps);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pdf_write (GIOChannel *source,
|
||||
GIOCondition con,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar buf[_PDF_MAX_CHUNK_SIZE];
|
||||
gsize bytes_read;
|
||||
GError *error;
|
||||
_PrintStreamData *ps = (_PrintStreamData *) user_data;
|
||||
gint source_fd;
|
||||
|
||||
error = NULL;
|
||||
|
||||
source_fd = g_io_channel_unix_get_fd (source);
|
||||
|
||||
bytes_read = read (source_fd,
|
||||
buf,
|
||||
_PDF_MAX_CHUNK_SIZE);
|
||||
|
||||
|
||||
|
||||
if (bytes_read > 0)
|
||||
{
|
||||
if (write (ps->target_fd, buf, bytes_read) == -1)
|
||||
{
|
||||
error = g_error_new (GTK_PRINT_ERROR,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
g_strerror (errno));
|
||||
}
|
||||
}
|
||||
else if (bytes_read == -1)
|
||||
{
|
||||
error = g_error_new (GTK_PRINT_ERROR,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
g_strerror (errno));
|
||||
}
|
||||
|
||||
if (bytes_read == 0 || error != NULL)
|
||||
{
|
||||
pdf_print_cb (GTK_PRINT_BACKEND_PDF (ps->backend), error, user_data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_print_stream (GtkPrintBackend *print_backend,
|
||||
GtkPrintJob *job,
|
||||
gint data_fd,
|
||||
GtkPrintJobCompleteFunc callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify dnotify)
|
||||
{
|
||||
GError *error;
|
||||
GtkPrinter *printer;
|
||||
_PrintStreamData *ps;
|
||||
GtkPrintSettings *settings;
|
||||
GIOChannel *save_channel;
|
||||
const char *filename;
|
||||
|
||||
printer = gtk_print_job_get_printer (job);
|
||||
settings = gtk_print_job_get_settings (job);
|
||||
|
||||
error = NULL;
|
||||
|
||||
filename = gtk_print_settings_get (settings, "pdf-filename");
|
||||
if (filename == NULL)
|
||||
filename = "output.pdf";
|
||||
|
||||
ps = g_new0 (_PrintStreamData, 1);
|
||||
ps->callback = callback;
|
||||
ps->user_data = user_data;
|
||||
ps->job = g_object_ref (job);
|
||||
|
||||
ps->target_fd = creat (filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
|
||||
ps->backend = print_backend;
|
||||
|
||||
if (ps->target_fd == -1)
|
||||
{
|
||||
error = g_error_new (GTK_PRINT_ERROR,
|
||||
GTK_PRINT_ERROR_INTERNAL_ERROR,
|
||||
g_strerror (errno));
|
||||
|
||||
pdf_print_cb (GTK_PRINT_BACKEND_PDF (print_backend),
|
||||
error,
|
||||
ps);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
save_channel = g_io_channel_unix_new (data_fd);
|
||||
|
||||
g_io_add_watch (save_channel,
|
||||
G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
|
||||
(GIOFunc) pdf_write,
|
||||
ps);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_iface_init (GtkPrintBackendIface *iface)
|
||||
{
|
||||
iface->get_printer_list = pdf_request_printer_list;
|
||||
iface->find_printer = gtk_print_backend_pdf_find_printer;
|
||||
iface->print_stream = gtk_print_backend_pdf_print_stream;
|
||||
iface->printer_request_details = pdf_printer_request_details;
|
||||
iface->printer_create_cairo_surface = pdf_printer_create_cairo_surface;
|
||||
iface->printer_get_options = pdf_printer_get_options;
|
||||
iface->printer_mark_conflicts = pdf_printer_mark_conflicts;
|
||||
iface->printer_get_settings_from_options = pdf_printer_get_settings_from_options;
|
||||
iface->printer_prepare_for_print = pdf_printer_prepare_for_print;
|
||||
iface->printer_list_papers = pdf_printer_list_papers;
|
||||
iface->printer_get_hard_margins = pdf_printer_get_hard_margins;
|
||||
}
|
||||
|
||||
static GList *
|
||||
pdf_request_printer_list (GtkPrintBackend *backend)
|
||||
{
|
||||
GList *l;
|
||||
GtkPrintBackendPdf *pdf_backend;
|
||||
|
||||
l = NULL;
|
||||
|
||||
pdf_backend = GTK_PRINT_BACKEND_PDF (backend);
|
||||
|
||||
if (pdf_backend->printer)
|
||||
l = g_list_append (l, pdf_backend->printer);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_init (GtkPrintBackendPdf *backend_pdf)
|
||||
{
|
||||
GtkPrinter *printer;
|
||||
|
||||
backend_pdf->printer = gtk_printer_new (_("Print to PDF"),
|
||||
GTK_PRINT_BACKEND (backend_pdf),
|
||||
TRUE);
|
||||
|
||||
printer = backend_pdf->printer;
|
||||
gtk_printer_set_has_details (printer, TRUE);
|
||||
gtk_printer_set_icon_name (printer, "floppy");
|
||||
gtk_printer_set_is_active (printer, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_print_backend_pdf_finalize (GObject *object)
|
||||
{
|
||||
GtkPrintBackendPdf *backend_pdf;
|
||||
|
||||
backend_pdf = GTK_PRINT_BACKEND_PDF (object);
|
||||
|
||||
g_object_unref (backend_pdf->printer);
|
||||
|
||||
backend_parent_class->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
pdf_printer_request_details (GtkPrinter *printer)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkPrinterOptionSet *
|
||||
pdf_printer_get_options (GtkPrinter *printer,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
GtkPrinterOptionSet *set;
|
||||
GtkPrinterOption *option;
|
||||
const char *filename;
|
||||
char *n_up[] = {"1" };
|
||||
|
||||
set = gtk_printer_option_set_new ();
|
||||
|
||||
option = gtk_printer_option_new ("gtk-n-up", _("Pages Per Sheet"), GTK_PRINTER_OPTION_TYPE_PICKONE);
|
||||
gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
|
||||
n_up, n_up);
|
||||
gtk_printer_option_set (option, "1");
|
||||
gtk_printer_option_set_add (set, option);
|
||||
g_object_unref (option);
|
||||
|
||||
option = gtk_printer_option_new ("gtk-main-page-custom-input", _("File"), GTK_PRINTER_OPTION_TYPE_FILESAVE);
|
||||
gtk_printer_option_set (option, "output.pdf");
|
||||
option->group = g_strdup ("GtkPrintDialogExtention");
|
||||
gtk_printer_option_set_add (set, option);
|
||||
|
||||
if (settings != NULL &&
|
||||
(filename = gtk_print_settings_get (settings, "pdf-filename"))!= NULL)
|
||||
gtk_printer_option_set (option, filename);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
pdf_printer_mark_conflicts (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
pdf_printer_get_settings_from_options (GtkPrinter *printer,
|
||||
GtkPrinterOptionSet *options,
|
||||
GtkPrintSettings *settings)
|
||||
{
|
||||
GtkPrinterOption *option;
|
||||
|
||||
option = gtk_printer_option_set_lookup (options, "gtk-main-page-custom-input");
|
||||
gtk_print_settings_set (settings, "pdf-filename", option->value);
|
||||
}
|
||||
|
||||
static void
|
||||
pdf_printer_prepare_for_print (GtkPrinter *printer,
|
||||
GtkPrintJob *print_job,
|
||||
GtkPrintSettings *settings,
|
||||
GtkPageSetup *page_setup)
|
||||
{
|
||||
double scale;
|
||||
|
||||
print_job->print_pages = gtk_print_settings_get_print_pages (settings);
|
||||
print_job->page_ranges = NULL;
|
||||
print_job->num_page_ranges = 0;
|
||||
|
||||
if (print_job->print_pages == GTK_PRINT_PAGES_RANGES)
|
||||
print_job->page_ranges =
|
||||
gtk_print_settings_get_page_ranges (settings,
|
||||
&print_job->num_page_ranges);
|
||||
|
||||
print_job->collate = gtk_print_settings_get_collate (settings);
|
||||
print_job->reverse = gtk_print_settings_get_reverse (settings);
|
||||
print_job->num_copies = gtk_print_settings_get_num_copies (settings);
|
||||
|
||||
scale = gtk_print_settings_get_scale (settings);
|
||||
if (scale != 100.0)
|
||||
print_job->scale = scale/100.0;
|
||||
|
||||
print_job->page_set = gtk_print_settings_get_page_set (settings);
|
||||
print_job->rotate_to_orientation = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
pdf_printer_get_hard_margins (GtkPrinter *printer,
|
||||
double *top,
|
||||
double *bottom,
|
||||
double *left,
|
||||
double *right)
|
||||
{
|
||||
*top = 0;
|
||||
*bottom = 0;
|
||||
*left = 0;
|
||||
*right = 0;
|
||||
}
|
||||
|
||||
static GList *
|
||||
pdf_printer_list_papers (GtkPrinter *printer)
|
||||
{
|
||||
return NULL;
|
||||
}
|
43
modules/printbackends/pdf/gtkprintbackendpdf.h
Normal file
43
modules/printbackends/pdf/gtkprintbackendpdf.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* gtkprintbackendpdf.h: Default implementation of GtkPrintBackend
|
||||
* for printing to a PDF
|
||||
* Copyright (C) 2003, Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_PRINT_BACKEND_PDF_H__
|
||||
#define __GTK_PRINT_BACKEND_PDF_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include "gtkprintbackend.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_PRINT_BACKEND_PDF (gtk_print_backend_pdf_get_type ())
|
||||
#define GTK_PRINT_BACKEND_PDF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_BACKEND_PDF, GtkPrintBackendPdf))
|
||||
#define GTK_IS_PRINT_BACKEND_PDF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_BACKEND_PDF))
|
||||
|
||||
typedef struct _GtkPrintBackendPdf GtkPrintBackendPdf;
|
||||
|
||||
GtkPrintBackend *gtk_print_backend_pdf_new (void);
|
||||
GType gtk_print_backend_pdf_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_PRINT_BACKEND_PDF_H__ */
|
||||
|
||||
|
@ -58,3 +58,4 @@ testtreesort
|
||||
testtreeview
|
||||
testxinerama
|
||||
treestoretest
|
||||
print-editor
|
||||
|
@ -30,6 +30,7 @@ noinst_PROGRAMS = \
|
||||
autotestfilechooser \
|
||||
floatingtest \
|
||||
simple \
|
||||
print-editor \
|
||||
testaccel \
|
||||
testassistant \
|
||||
testcairo \
|
||||
@ -82,6 +83,7 @@ noinst_PROGRAMS = \
|
||||
autotestfilechooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
simple_DEPENDENCIES = $(TEST_DEPS)
|
||||
floatingtest_DEPENDENCIES = $(TEST_DEPS)
|
||||
print_editor_DEPENDENCIES = $(TEST_DEPS)
|
||||
testicontheme_DEPENDENCIES = $(TEST_DEPS)
|
||||
testiconview_DEPENDENCIES = $(TEST_DEPS)
|
||||
testaccel_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -128,6 +130,7 @@ testactions_DEPENDENCIES = $(TEST_DEPS)
|
||||
autotestfilechooser_LDADD = $(LDADDS)
|
||||
simple_LDADD = $(LDADDS)
|
||||
floatingtest_LDADD = $(LDADDS)
|
||||
print_editor_LDADD = $(LDADDS)
|
||||
testaccel_LDADD = $(LDADDS)
|
||||
testassistant_LDADD = $(LDADDS)
|
||||
testcairo_LDADD = $(LDADDS)
|
||||
|
682
tests/print-editor.c
Normal file
682
tests/print-editor.c
Normal file
@ -0,0 +1,682 @@
|
||||
#include <pango/pangocairo.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkprintoperation.h>
|
||||
|
||||
static GtkWidget *main_window;
|
||||
static char *filename = NULL;
|
||||
static GtkPageSetup *page_setup = NULL;
|
||||
static GtkPrintSettings *settings = NULL;
|
||||
static gboolean file_changed = FALSE;
|
||||
static GtkTextBuffer *buffer;
|
||||
static GtkWidget *statusbar;
|
||||
static GList *active_prints = NULL;
|
||||
|
||||
static void
|
||||
update_title (void)
|
||||
{
|
||||
char *basename;
|
||||
char *title;
|
||||
|
||||
if (filename == NULL)
|
||||
basename = g_strdup ("Untitled");
|
||||
else
|
||||
basename = g_path_get_basename (filename);
|
||||
|
||||
title = g_strdup_printf ("Simple Editor with printing - %s", basename);
|
||||
g_free (basename);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (main_window), title);
|
||||
g_free (title);
|
||||
}
|
||||
|
||||
static void
|
||||
update_statusbar (void)
|
||||
{
|
||||
gchar *msg;
|
||||
gint row, col;
|
||||
GtkTextIter iter;
|
||||
const char *print_str;
|
||||
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), 0);
|
||||
|
||||
gtk_text_buffer_get_iter_at_mark (buffer,
|
||||
&iter,
|
||||
gtk_text_buffer_get_insert (buffer));
|
||||
|
||||
row = gtk_text_iter_get_line (&iter);
|
||||
col = gtk_text_iter_get_line_offset (&iter);
|
||||
|
||||
print_str = "";
|
||||
if (active_prints)
|
||||
{
|
||||
GtkPrintOperation *op = active_prints->data;
|
||||
print_str = gtk_print_operation_get_status_string (op);
|
||||
}
|
||||
|
||||
msg = g_strdup_printf ("%d, %d%s %s",
|
||||
row, col,
|
||||
file_changed?" - Modified":"",
|
||||
print_str);
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (statusbar), 0, msg);
|
||||
|
||||
g_free (msg);
|
||||
}
|
||||
|
||||
static void
|
||||
update_ui (void)
|
||||
{
|
||||
update_title ();
|
||||
update_statusbar ();
|
||||
}
|
||||
|
||||
static char *
|
||||
get_text (void)
|
||||
{
|
||||
GtkTextIter start, end;
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||
return gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
set_text (const char *text, gsize len)
|
||||
{
|
||||
gtk_text_buffer_set_text (buffer, text, len);
|
||||
file_changed = FALSE;
|
||||
update_ui ();
|
||||
}
|
||||
|
||||
static void
|
||||
do_new (GtkAction *action)
|
||||
{
|
||||
g_free (filename);
|
||||
filename = NULL;
|
||||
set_text ("", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
load_file (const char *open_filename)
|
||||
{
|
||||
GtkWidget *error_dialog;
|
||||
char *contents;
|
||||
GError *error;
|
||||
gsize len;
|
||||
|
||||
error_dialog = NULL;
|
||||
error = NULL;
|
||||
if (g_file_get_contents (open_filename, &contents, &len, &error))
|
||||
{
|
||||
if (g_utf8_validate (contents, len, NULL))
|
||||
{
|
||||
filename = g_strdup (open_filename);
|
||||
set_text (contents, len);
|
||||
g_free (contents);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file %s:\n%s",
|
||||
open_filename,
|
||||
"Not valid utf8");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error loading file %s:\n%s",
|
||||
open_filename,
|
||||
error->message);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
if (error_dialog)
|
||||
{
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_open (GtkAction *action)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
gint response;
|
||||
char *open_filename;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Select file",
|
||||
GTK_WINDOW (main_window),
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
open_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||
load_file (open_filename);
|
||||
g_free (open_filename);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
save_file (const char *save_filename)
|
||||
{
|
||||
char *text = get_text ();
|
||||
GtkWidget *error_dialog;
|
||||
GError *error;
|
||||
|
||||
error = NULL;
|
||||
if (g_file_set_contents (save_filename,
|
||||
text, -1, &error))
|
||||
{
|
||||
if (save_filename != filename)
|
||||
{
|
||||
g_free (filename);
|
||||
filename = g_strdup (save_filename);
|
||||
}
|
||||
file_changed = FALSE;
|
||||
update_ui ();
|
||||
}
|
||||
else
|
||||
{
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error saving to file %s:\n%s",
|
||||
filename,
|
||||
error->message);
|
||||
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_save_as (GtkAction *action)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
gint response;
|
||||
char *save_filename;
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("Select file",
|
||||
GTK_WINDOW (main_window),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
||||
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
||||
NULL);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
{
|
||||
save_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
||||
save_file (save_filename);
|
||||
g_free (save_filename);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
do_save (GtkAction *action)
|
||||
{
|
||||
if (filename == NULL)
|
||||
do_save_as (action);
|
||||
else
|
||||
save_file (filename);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char *text;
|
||||
PangoLayout *layout;
|
||||
GList *page_breaks;
|
||||
} PrintData;
|
||||
|
||||
static void
|
||||
begin_print (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
PrintData *print_data)
|
||||
{
|
||||
PangoFontDescription *desc;
|
||||
PangoLayoutLine *layout_line;
|
||||
double width, height;
|
||||
double page_height;
|
||||
GList *page_breaks;
|
||||
int num_lines;
|
||||
int line;
|
||||
|
||||
width = gtk_print_context_get_width (context);
|
||||
height = gtk_print_context_get_height (context);
|
||||
|
||||
print_data->layout = gtk_print_context_create_layout (context);
|
||||
|
||||
desc = pango_font_description_from_string ("Sans 12");
|
||||
pango_layout_set_font_description (print_data->layout, desc);
|
||||
pango_font_description_free (desc);
|
||||
|
||||
pango_layout_set_width (print_data->layout, width * PANGO_SCALE);
|
||||
|
||||
pango_layout_set_text (print_data->layout, print_data->text, -1);
|
||||
|
||||
num_lines = pango_layout_get_line_count (print_data->layout);
|
||||
|
||||
page_breaks = NULL;
|
||||
page_height = 0;
|
||||
|
||||
for (line = 0; line < num_lines; line++)
|
||||
{
|
||||
PangoRectangle ink_rect, logical_rect;
|
||||
double line_height;
|
||||
|
||||
layout_line = pango_layout_get_line (print_data->layout, line);
|
||||
pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect);
|
||||
|
||||
line_height = logical_rect.height / 1024.0;
|
||||
|
||||
if (page_height + line_height > height)
|
||||
{
|
||||
page_breaks = g_list_prepend (page_breaks, GINT_TO_POINTER (line));
|
||||
page_height = 0;
|
||||
}
|
||||
|
||||
page_height += line_height;
|
||||
}
|
||||
|
||||
page_breaks = g_list_reverse (page_breaks);
|
||||
gtk_print_operation_set_nr_of_pages (operation, g_list_length (page_breaks) + 1);
|
||||
|
||||
print_data->page_breaks = page_breaks;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
draw_page (GtkPrintOperation *operation,
|
||||
GtkPrintContext *context,
|
||||
int page_nr,
|
||||
PrintData *print_data)
|
||||
{
|
||||
cairo_t *cr;
|
||||
GList *pagebreak;
|
||||
int start, end, i;
|
||||
PangoLayoutIter *iter;
|
||||
double start_pos;
|
||||
if (page_nr == 0)
|
||||
start = 0;
|
||||
else
|
||||
{
|
||||
pagebreak = g_list_nth (print_data->page_breaks, page_nr - 1);
|
||||
start = GPOINTER_TO_INT (pagebreak->data);
|
||||
}
|
||||
|
||||
pagebreak = g_list_nth (print_data->page_breaks, page_nr);
|
||||
if (pagebreak == NULL)
|
||||
end = pango_layout_get_line_count (print_data->layout);
|
||||
else
|
||||
end = GPOINTER_TO_INT (pagebreak->data);
|
||||
|
||||
cr = gtk_print_context_get_cairo (context);
|
||||
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
i = 0;
|
||||
start_pos = 0;
|
||||
iter = pango_layout_get_iter (print_data->layout);
|
||||
do
|
||||
{
|
||||
PangoRectangle logical_rect;
|
||||
PangoLayoutLine *line;
|
||||
int baseline;
|
||||
|
||||
if (i >= start)
|
||||
{
|
||||
line = pango_layout_iter_get_line (iter);
|
||||
|
||||
pango_layout_iter_get_line_extents (iter, NULL, &logical_rect);
|
||||
baseline = pango_layout_iter_get_baseline (iter);
|
||||
|
||||
if (i == start)
|
||||
start_pos = logical_rect.y / 1024.0;
|
||||
|
||||
cairo_move_to (cr, logical_rect.x / 1024.0, baseline / 1024.0 - start_pos);
|
||||
|
||||
pango_cairo_show_layout_line (cr, line);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
while (i < end &&
|
||||
pango_layout_iter_next_line (iter));
|
||||
}
|
||||
|
||||
static void
|
||||
do_page_setup (GtkAction *action)
|
||||
{
|
||||
GtkPageSetup *new_page_setup;
|
||||
|
||||
if (settings == NULL)
|
||||
settings = gtk_print_settings_new ();
|
||||
|
||||
new_page_setup = gtk_print_run_page_setup_dialog (GTK_WINDOW (main_window),
|
||||
page_setup, settings);
|
||||
|
||||
if (page_setup)
|
||||
g_object_unref (page_setup);
|
||||
|
||||
page_setup = new_page_setup;
|
||||
}
|
||||
|
||||
static void
|
||||
status_changed_cb (GtkPrintOperation *op,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (gtk_print_operation_is_finished (op))
|
||||
{
|
||||
active_prints = g_list_remove (active_prints, op);
|
||||
g_object_unref (op);
|
||||
}
|
||||
update_statusbar ();
|
||||
}
|
||||
|
||||
static void
|
||||
do_print (GtkAction *action)
|
||||
{
|
||||
GtkWidget *error_dialog;
|
||||
GtkPrintOperation *print;
|
||||
PrintData print_data;
|
||||
GtkPrintOperationResult res;
|
||||
GError *error;
|
||||
|
||||
print_data.text = get_text ();
|
||||
|
||||
print = gtk_print_operation_new ();
|
||||
|
||||
|
||||
if (settings != NULL)
|
||||
gtk_print_operation_set_print_settings (print, settings);
|
||||
|
||||
if (page_setup != NULL)
|
||||
gtk_print_operation_set_default_page_setup (print, page_setup);
|
||||
|
||||
g_signal_connect (print, "begin_print", G_CALLBACK (begin_print), &print_data);
|
||||
g_signal_connect (print, "draw_page", G_CALLBACK (draw_page), &print_data);
|
||||
|
||||
error = NULL;
|
||||
res = gtk_print_operation_run (print, GTK_WINDOW (main_window), &error);
|
||||
|
||||
if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
|
||||
{
|
||||
error_dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||
GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_CLOSE,
|
||||
"Error printing file:\n%s",
|
||||
error->message);
|
||||
g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_widget_show (error_dialog);
|
||||
g_error_free (error);
|
||||
}
|
||||
else if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
|
||||
{
|
||||
if (settings != NULL)
|
||||
g_object_unref (settings);
|
||||
settings = g_object_ref (gtk_print_operation_get_print_settings (print));
|
||||
}
|
||||
|
||||
if (!gtk_print_operation_is_finished (print))
|
||||
{
|
||||
g_object_ref (print);
|
||||
active_prints = g_list_append (active_prints, print);
|
||||
update_statusbar ();
|
||||
|
||||
/* This ref is unref:ed when we get the final state change */
|
||||
g_signal_connect (print, "status_changed",
|
||||
G_CALLBACK (status_changed_cb), NULL);
|
||||
}
|
||||
|
||||
g_object_unref (print);
|
||||
}
|
||||
|
||||
static void
|
||||
do_about (GtkAction *action)
|
||||
{
|
||||
const gchar *authors[] = {
|
||||
"Alexander Larsson",
|
||||
NULL
|
||||
};
|
||||
gtk_show_about_dialog (GTK_WINDOW (main_window),
|
||||
"name", "print test editor",
|
||||
"version", "0.1",
|
||||
"copyright", "(C) Red Hat, Inc",
|
||||
"comments", "Program to demonstrate GTK+ printing.",
|
||||
"authors", authors,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
do_quit (GtkAction *action)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static GtkActionEntry entries[] = {
|
||||
{ "FileMenu", NULL, "_File" }, /* name, stock id, label */
|
||||
{ "HelpMenu", NULL, "_Help" }, /* name, stock id, label */
|
||||
{ "New", GTK_STOCK_NEW, /* name, stock id */
|
||||
"_New", "<control>N", /* label, accelerator */
|
||||
"Create a new file", /* tooltip */
|
||||
G_CALLBACK (do_new) },
|
||||
{ "Open", GTK_STOCK_OPEN, /* name, stock id */
|
||||
"_Open","<control>O", /* label, accelerator */
|
||||
"Open a file", /* tooltip */
|
||||
G_CALLBACK (do_open) },
|
||||
{ "Save", GTK_STOCK_SAVE, /* name, stock id */
|
||||
"_Save","<control>S", /* label, accelerator */
|
||||
"Save current file", /* tooltip */
|
||||
G_CALLBACK (do_save) },
|
||||
{ "SaveAs", GTK_STOCK_SAVE, /* name, stock id */
|
||||
"Save _As...", NULL, /* label, accelerator */
|
||||
"Save to a file", /* tooltip */
|
||||
G_CALLBACK (do_save_as) },
|
||||
{ "Quit", GTK_STOCK_QUIT, /* name, stock id */
|
||||
"_Quit", "<control>Q", /* label, accelerator */
|
||||
"Quit", /* tooltip */
|
||||
G_CALLBACK (do_quit) },
|
||||
{ "About", NULL, /* name, stock id */
|
||||
"_About", "<control>A", /* label, accelerator */
|
||||
"About", /* tooltip */
|
||||
G_CALLBACK (do_about) },
|
||||
{ "PageSetup", NULL, /* name, stock id */
|
||||
"Page _Setup", NULL, /* label, accelerator */
|
||||
"Set up the page", /* tooltip */
|
||||
G_CALLBACK (do_page_setup) },
|
||||
{ "Print", GTK_STOCK_PRINT, /* name, stock id */
|
||||
NULL, NULL, /* label, accelerator */
|
||||
"Print the document", /* tooltip */
|
||||
G_CALLBACK (do_print) },
|
||||
};
|
||||
static guint n_entries = G_N_ELEMENTS (entries);
|
||||
|
||||
static const gchar *ui_info =
|
||||
"<ui>"
|
||||
" <menubar name='MenuBar'>"
|
||||
" <menu action='FileMenu'>"
|
||||
" <menuitem action='New'/>"
|
||||
" <menuitem action='Open'/>"
|
||||
" <menuitem action='Save'/>"
|
||||
" <menuitem action='SaveAs'/>"
|
||||
" <menuitem action='PageSetup'/>"
|
||||
" <menuitem action='Print'/>"
|
||||
" <separator/>"
|
||||
" <menuitem action='Quit'/>"
|
||||
" </menu>"
|
||||
" <menu action='HelpMenu'>"
|
||||
" <menuitem action='About'/>"
|
||||
" </menu>"
|
||||
" </menubar>"
|
||||
"</ui>";
|
||||
|
||||
static void
|
||||
buffer_changed_callback (GtkTextBuffer *buffer)
|
||||
{
|
||||
file_changed = TRUE;
|
||||
update_statusbar ();
|
||||
}
|
||||
|
||||
static void
|
||||
mark_set_callback (GtkTextBuffer *buffer,
|
||||
const GtkTextIter *new_location,
|
||||
GtkTextMark *mark,
|
||||
gpointer data)
|
||||
{
|
||||
update_statusbar ();
|
||||
}
|
||||
|
||||
static void
|
||||
update_resize_grip (GtkWidget *widget,
|
||||
GdkEventWindowState *event,
|
||||
GtkStatusbar *statusbar)
|
||||
{
|
||||
if (event->changed_mask & (GDK_WINDOW_STATE_MAXIMIZED |
|
||||
GDK_WINDOW_STATE_FULLSCREEN))
|
||||
{
|
||||
gboolean maximized;
|
||||
|
||||
maximized = event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED |
|
||||
GDK_WINDOW_STATE_FULLSCREEN);
|
||||
gtk_statusbar_set_has_resize_grip (statusbar, !maximized);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_window (void)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
GtkWidget *table;
|
||||
GtkWidget *contents;
|
||||
GtkUIManager *ui;
|
||||
GtkWidget *sw;
|
||||
GtkActionGroup *actions;
|
||||
GError *error;
|
||||
|
||||
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (main_window),
|
||||
400, 600);
|
||||
|
||||
g_signal_connect (main_window, "delete-event",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
actions = gtk_action_group_new ("Actions");
|
||||
gtk_action_group_add_actions (actions, entries, n_entries, NULL);
|
||||
|
||||
ui = gtk_ui_manager_new ();
|
||||
gtk_ui_manager_insert_action_group (ui, actions, 0);
|
||||
gtk_window_add_accel_group (GTK_WINDOW (main_window),
|
||||
gtk_ui_manager_get_accel_group (ui));
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_window), 0);
|
||||
|
||||
error = NULL;
|
||||
if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
|
||||
{
|
||||
g_message ("building menus failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
table = gtk_table_new (1, 3, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (main_window), table);
|
||||
|
||||
bar = gtk_ui_manager_get_widget (ui, "/MenuBar");
|
||||
gtk_widget_show (bar);
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
bar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Create document */
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
|
||||
GTK_SHADOW_IN);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
sw,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
0, 0);
|
||||
|
||||
contents = gtk_text_view_new ();
|
||||
gtk_widget_grab_focus (contents);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (sw),
|
||||
contents);
|
||||
|
||||
/* Create statusbar */
|
||||
|
||||
statusbar = gtk_statusbar_new ();
|
||||
gtk_table_attach (GTK_TABLE (table),
|
||||
statusbar,
|
||||
/* X direction */ /* Y direction */
|
||||
0, 1, 2, 3,
|
||||
GTK_EXPAND | GTK_FILL, 0,
|
||||
0, 0);
|
||||
|
||||
/* Show text widget info in the statusbar */
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents));
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"changed",
|
||||
G_CALLBACK (buffer_changed_callback),
|
||||
NULL,
|
||||
0);
|
||||
|
||||
g_signal_connect_object (buffer,
|
||||
"mark_set", /* cursor moved */
|
||||
G_CALLBACK (mark_set_callback),
|
||||
NULL,
|
||||
0);
|
||||
|
||||
g_signal_connect_object (main_window,
|
||||
"window_state_event",
|
||||
G_CALLBACK (update_resize_grip),
|
||||
statusbar,
|
||||
0);
|
||||
|
||||
update_ui ();
|
||||
|
||||
gtk_widget_show_all (main_window);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
create_window ();
|
||||
|
||||
if (argc == 2)
|
||||
load_file (argv[1]);
|
||||
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user