Commit fad69ba0 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add gtkprintoperationpreview.[ch] Set default preview command. Hardcoded

2006-06-02  Alexander Larsson  <alexl@redhat.com>

	* gtk/Makefile.am:
	Add gtkprintoperationpreview.[ch]
	Set default preview command. Hardcoded for now.

	* gtk/gtkmarshalers.list:
	Add BOOLEAN:OBJECT,OBJECT,OBJECT

	* gtk/gtkprintbackend.c:
	Add preview command property.

	* gtk/gtkprintcontext.[ch]:
	Make less dependent on PrintOperation for output settings
	Externally set cairo_t and dpi. Resettable.
	Create fontmap without metrics hinting (so that print preview
	text layout doesn't depend on zoom level).

	* gtk/gtkprintoperation-private.h:
	* gtk/gtkprintoperation-unix.c:
	* gtk/gtkprintoperation.[ch]:
	Initial work on print preview API and default implementation
	using an external preview app.

	* gtk/gtkprintoperation-win32.c:
	Some needed updates. Not done, needs more work.

	* gtk/gtkprintoperationpreview.[ch]:
	New interface used in print preview api.

	* gtk/gtkprintunixdialog.c:
	Add print preview dialog.

	* tests/print-editor.c:
	Test using an custom print preview widget.
parent caf6c419
2006-06-02 Alexander Larsson <alexl@redhat.com>
* gtk/Makefile.am:
Add gtkprintoperationpreview.[ch]
Set default preview command. Hardcoded for now.
* gtk/gtkmarshalers.list:
Add BOOLEAN:OBJECT,OBJECT,OBJECT
* gtk/gtkprintbackend.c:
Add preview command property.
* gtk/gtkprintcontext.[ch]:
Make less dependent on PrintOperation for output settings
Externally set cairo_t and dpi. Resettable.
Create fontmap without metrics hinting (so that print preview
text layout doesn't depend on zoom level).
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.[ch]:
Initial work on print preview API and default implementation
using an external preview app.
* gtk/gtkprintoperation-win32.c:
Some needed updates. Not done, needs more work.
* gtk/gtkprintoperationpreview.[ch]:
New interface used in print preview api.
* gtk/gtkprintunixdialog.c:
Add print preview dialog.
* tests/print-editor.c:
Test using an custom print preview widget.
2006-06-02 Emmanuele Bassi <ebassi@gnome.org> 2006-06-02 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentmanager.c * gtk/gtkrecentmanager.c
......
2006-06-02 Alexander Larsson <alexl@redhat.com>
* gtk/Makefile.am:
Add gtkprintoperationpreview.[ch]
Set default preview command. Hardcoded for now.
* gtk/gtkmarshalers.list:
Add BOOLEAN:OBJECT,OBJECT,OBJECT
* gtk/gtkprintbackend.c:
Add preview command property.
* gtk/gtkprintcontext.[ch]:
Make less dependent on PrintOperation for output settings
Externally set cairo_t and dpi. Resettable.
Create fontmap without metrics hinting (so that print preview
text layout doesn't depend on zoom level).
* gtk/gtkprintoperation-private.h:
* gtk/gtkprintoperation-unix.c:
* gtk/gtkprintoperation.[ch]:
Initial work on print preview API and default implementation
using an external preview app.
* gtk/gtkprintoperation-win32.c:
Some needed updates. Not done, needs more work.
* gtk/gtkprintoperationpreview.[ch]:
New interface used in print preview api.
* gtk/gtkprintunixdialog.c:
Add print preview dialog.
* tests/print-editor.c:
Test using an custom print preview widget.
2006-06-02 Emmanuele Bassi <ebassi@gnome.org> 2006-06-02 Emmanuele Bassi <ebassi@gnome.org>
* gtk/gtkrecentmanager.c * gtk/gtkrecentmanager.c
......
...@@ -4,6 +4,7 @@ SUBDIRS=theme-bits ...@@ -4,6 +4,7 @@ SUBDIRS=theme-bits
if OS_UNIX if OS_UNIX
SUBDIRS += xdgmime SUBDIRS += xdgmime
GTK_PRINT_PREVIEW_COMMAND="evince %f"
endif endif
DIST_SUBDIRS=theme-bits xdgmime DIST_SUBDIRS=theme-bits xdgmime
...@@ -25,6 +26,7 @@ INCLUDES = \ ...@@ -25,6 +26,7 @@ INCLUDES = \
-DGTK_HOST=\"$(host)\" \ -DGTK_HOST=\"$(host)\" \
-DGTK_COMPILATION \ -DGTK_COMPILATION \
-DGTK_PRINT_BACKENDS=\"$(GTK_PRINT_BACKENDS)\" \ -DGTK_PRINT_BACKENDS=\"$(GTK_PRINT_BACKENDS)\" \
-DGTK_PRINT_PREVIEW_COMMAND=\"$(GTK_PRINT_PREVIEW_COMMAND)\" \
-I$(top_builddir)/gtk \ -I$(top_builddir)/gtk \
-I$(top_srcdir) -I../gdk \ -I$(top_srcdir) -I../gdk \
-I$(top_srcdir)/gdk \ -I$(top_srcdir)/gdk \
...@@ -231,6 +233,7 @@ gtk_public_h_sources = \ ...@@ -231,6 +233,7 @@ gtk_public_h_sources = \
gtkpreview.h \ gtkpreview.h \
gtkprintcontext.h \ gtkprintcontext.h \
gtkprintoperation.h \ gtkprintoperation.h \
gtkprintoperationpreview.h \
gtkprintsettings.h \ gtkprintsettings.h \
gtkprivate.h \ gtkprivate.h \
gtkprogress.h \ gtkprogress.h \
...@@ -487,6 +490,7 @@ gtk_c_sources = \ ...@@ -487,6 +490,7 @@ gtk_c_sources = \
gtkpreview.c \ gtkpreview.c \
gtkprintcontext.c \ gtkprintcontext.c \
gtkprintoperation.c \ gtkprintoperation.c \
gtkprintoperationpreview.c \
gtkprintsettings.c \ gtkprintsettings.c \
gtkprintutils.c \ gtkprintutils.c \
gtkprogress.c \ gtkprogress.c \
......
...@@ -32,6 +32,7 @@ BOOLEAN:OBJECT,INT,INT,UINT ...@@ -32,6 +32,7 @@ BOOLEAN:OBJECT,INT,INT,UINT
BOOLEAN:OBJECT,STRING,STRING,BOXED BOOLEAN:OBJECT,STRING,STRING,BOXED
BOOLEAN:OBJECT,BOXED BOOLEAN:OBJECT,BOXED
BOOLEAN:OBJECT,BOXED,BOXED BOOLEAN:OBJECT,BOXED,BOXED
BOOLEAN:OBJECT,OBJECT,OBJECT
BOOLEAN:OBJECT,STRING,STRING BOOLEAN:OBJECT,STRING,STRING
BOOLEAN:INT BOOLEAN:INT
BOOLEAN:INT,INT BOOLEAN:INT,INT
......
...@@ -191,7 +191,7 @@ _gtk_print_backend_module_create (GtkPrintBackendModule *pb_module) ...@@ -191,7 +191,7 @@ _gtk_print_backend_module_create (GtkPrintBackendModule *pb_module)
return NULL; return NULL;
} }
GtkPrintBackend * static GtkPrintBackend *
_gtk_print_backend_create (const char *backend_name) _gtk_print_backend_create (const char *backend_name)
{ {
GSList *l; GSList *l;
...@@ -200,7 +200,6 @@ _gtk_print_backend_create (const char *backend_name) ...@@ -200,7 +200,6 @@ _gtk_print_backend_create (const char *backend_name)
GtkPrintBackendModule *pb_module; GtkPrintBackendModule *pb_module;
GtkPrintBackend *pb; GtkPrintBackend *pb;
/* TODO: make module loading code work */
for (l = loaded_backends; l != NULL; l = l->next) for (l = loaded_backends; l != NULL; l = l->next)
{ {
pb_module = l->data; pb_module = l->data;
...@@ -255,6 +254,11 @@ gtk_print_backend_initialize (void) ...@@ -255,6 +254,11 @@ gtk_print_backend_initialize (void)
GTK_PRINT_BACKENDS, GTK_PRINT_BACKENDS,
GTK_PARAM_READWRITE)); GTK_PARAM_READWRITE));
gtk_settings_install_property (g_param_spec_string ("gtk-print-preview-command",
P_("Default command to run when displaying a print preview"),
P_("Command to run when displaying a print preview"),
GTK_PRINT_PREVIEW_COMMAND,
GTK_PARAM_READWRITE));
initialized = TRUE; initialized = TRUE;
} }
} }
......
...@@ -40,6 +40,9 @@ struct _GtkPrintContext ...@@ -40,6 +40,9 @@ struct _GtkPrintContext
GtkPageSetup *page_setup; GtkPageSetup *page_setup;
PangoFontMap *fontmap; PangoFontMap *fontmap;
gdouble surface_dpi_x;
gdouble surface_dpi_y;
gdouble pixels_per_unit_x; gdouble pixels_per_unit_x;
gdouble pixels_per_unit_y; gdouble pixels_per_unit_y;
}; };
...@@ -60,8 +63,8 @@ gtk_print_context_finalize (GObject *object) ...@@ -60,8 +63,8 @@ gtk_print_context_finalize (GObject *object)
if (context->page_setup) if (context->page_setup)
g_object_unref (context->page_setup); g_object_unref (context->page_setup);
cairo_destroy (context->cr); if (context->cr)
cairo_destroy (context->cr);
G_OBJECT_CLASS (gtk_print_context_parent_class)->finalize (object); G_OBJECT_CLASS (gtk_print_context_parent_class)->finalize (object);
} }
...@@ -83,15 +86,31 @@ gtk_print_context_class_init (GtkPrintContextClass *class) ...@@ -83,15 +86,31 @@ gtk_print_context_class_init (GtkPrintContextClass *class)
GtkPrintContext * GtkPrintContext *
_gtk_print_context_new (GtkPrintOperation *op) _gtk_print_context_new (GtkPrintOperation *op)
{ {
GtkPrintOperationPrivate *priv = op->priv;
GtkPrintContext *context; GtkPrintContext *context;
context = g_object_new (GTK_TYPE_PRINT_CONTEXT, NULL); context = g_object_new (GTK_TYPE_PRINT_CONTEXT, NULL);
context->op = op; context->op = op;
context->cr = cairo_create (priv->surface); context->cr = NULL;
context->fontmap = pango_cairo_font_map_new ();
return context;
}
void
gtk_print_context_set_cairo_context (GtkPrintContext *context,
cairo_t *cr,
double dpi_x,
double dpi_y)
{
if (context->cr)
cairo_destroy (context->cr);
context->cr = cairo_reference (cr);
context->surface_dpi_x = dpi_x;
context->surface_dpi_y = dpi_y;
switch (priv->unit) switch (context->op->priv->unit)
{ {
default: default:
case GTK_UNIT_PIXEL: case GTK_UNIT_PIXEL:
...@@ -100,34 +119,31 @@ _gtk_print_context_new (GtkPrintOperation *op) ...@@ -100,34 +119,31 @@ _gtk_print_context_new (GtkPrintOperation *op)
context->pixels_per_unit_y = 1.0; context->pixels_per_unit_y = 1.0;
break; break;
case GTK_UNIT_POINTS: case GTK_UNIT_POINTS:
context->pixels_per_unit_x = priv->dpi_x / POINTS_PER_INCH; context->pixels_per_unit_x = dpi_x / POINTS_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / POINTS_PER_INCH; context->pixels_per_unit_y = dpi_y / POINTS_PER_INCH;
break; break;
case GTK_UNIT_INCH: case GTK_UNIT_INCH:
context->pixels_per_unit_x = priv->dpi_x; context->pixels_per_unit_x = dpi_x;
context->pixels_per_unit_y = priv->dpi_y; context->pixels_per_unit_y = dpi_y;
break; break;
case GTK_UNIT_MM: case GTK_UNIT_MM:
context->pixels_per_unit_x = priv->dpi_x / MM_PER_INCH; context->pixels_per_unit_x = dpi_x / MM_PER_INCH;
context->pixels_per_unit_y = priv->dpi_y / MM_PER_INCH; context->pixels_per_unit_y = dpi_y / MM_PER_INCH;
break; break;
} }
cairo_scale (context->cr, cairo_scale (context->cr,
context->pixels_per_unit_x, context->pixels_per_unit_x,
context->pixels_per_unit_y); 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 */ /* 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), pango_cairo_font_map_set_resolution (PANGO_CAIRO_FONT_MAP (context->fontmap),
priv->dpi_y / context->pixels_per_unit_y); dpi_y / context->pixels_per_unit_y);
return context;
} }
void void
_gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context) _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
{ {
GtkPrintOperationPrivate *priv = context->op->priv;
cairo_t *cr = context->cr; cairo_t *cr = context->cr;
cairo_matrix_t matrix; cairo_matrix_t matrix;
GtkPaperSize *paper_size; GtkPaperSize *paper_size;
...@@ -136,9 +152,9 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context) ...@@ -136,9 +152,9 @@ _gtk_print_context_rotate_according_to_orientation (GtkPrintContext *context)
paper_size = gtk_page_setup_get_paper_size (context->page_setup); paper_size = gtk_page_setup_get_paper_size (context->page_setup);
width = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH); width = gtk_paper_size_get_width (paper_size, GTK_UNIT_INCH);
width = width * priv->dpi_x / context->pixels_per_unit_x; width = width * context->surface_dpi_x / context->pixels_per_unit_x;
height = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH); height = gtk_paper_size_get_height (paper_size, GTK_UNIT_INCH);
height = height * priv->dpi_y / context->pixels_per_unit_y; height = height * context->surface_dpi_y / context->pixels_per_unit_y;
switch (gtk_page_setup_get_orientation (context->page_setup)) switch (gtk_page_setup_get_orientation (context->page_setup))
{ {
...@@ -188,8 +204,8 @@ _gtk_print_context_translate_into_margin (GtkPrintContext *context) ...@@ -188,8 +204,8 @@ _gtk_print_context_translate_into_margin (GtkPrintContext *context)
top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH); top = gtk_page_setup_get_top_margin (context->page_setup, GTK_UNIT_INCH);
cairo_translate (context->cr, cairo_translate (context->cr,
left * priv->dpi_x / context->pixels_per_unit_x, left * context->surface_dpi_x / context->pixels_per_unit_x,
top * priv->dpi_y / context->pixels_per_unit_y); top * context->surface_dpi_y / context->pixels_per_unit_y);
} }
void void
...@@ -272,7 +288,7 @@ gtk_print_context_get_width (GtkPrintContext *context) ...@@ -272,7 +288,7 @@ gtk_print_context_get_width (GtkPrintContext *context)
width = gtk_page_setup_get_page_width (context->page_setup, GTK_UNIT_INCH); 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? */ /* Really dpi_x? What about landscape? what does dpi_x mean in that case? */
return width * priv->dpi_x / context->pixels_per_unit_x; return width * context->surface_dpi_x / context->pixels_per_unit_x;
} }
/** /**
...@@ -300,8 +316,8 @@ gtk_print_context_get_height (GtkPrintContext *context) ...@@ -300,8 +316,8 @@ gtk_print_context_get_height (GtkPrintContext *context)
else else
height = gtk_page_setup_get_page_height (context->page_setup, GTK_UNIT_INCH); 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? */ /* Really dpi_y? What about landscape? what does dpi_y mean in that case? */
return height * priv->dpi_y / context->pixels_per_unit_y; return height * context->surface_dpi_y / context->pixels_per_unit_y;
} }
/** /**
...@@ -320,7 +336,7 @@ gtk_print_context_get_dpi_x (GtkPrintContext *context) ...@@ -320,7 +336,7 @@ gtk_print_context_get_dpi_x (GtkPrintContext *context)
{ {
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0); g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
return context->op->priv->dpi_x; return context->surface_dpi_x;
} }
/** /**
...@@ -339,7 +355,7 @@ gtk_print_context_get_dpi_y (GtkPrintContext *context) ...@@ -339,7 +355,7 @@ gtk_print_context_get_dpi_y (GtkPrintContext *context)
{ {
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0); g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), 0);
return context->op->priv->dpi_y; return context->surface_dpi_y;
} }
/** /**
...@@ -376,10 +392,16 @@ PangoContext * ...@@ -376,10 +392,16 @@ PangoContext *
gtk_print_context_create_pango_context (GtkPrintContext *context) gtk_print_context_create_pango_context (GtkPrintContext *context)
{ {
PangoContext *pango_context; PangoContext *pango_context;
cairo_font_options_t *options;
g_return_val_if_fail (GTK_IS_PRINT_CONTEXT (context), NULL); 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)); pango_context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (context->fontmap));
options = cairo_font_options_create ();
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_OFF);
pango_cairo_context_set_font_options (pango_context, options);
cairo_font_options_destroy (options);
return pango_context; return pango_context;
} }
......
...@@ -51,6 +51,11 @@ PangoFontMap *gtk_print_context_get_pango_fontmap (GtkPrintContext *context); ...@@ -51,6 +51,11 @@ PangoFontMap *gtk_print_context_get_pango_fontmap (GtkPrintContext *context);
PangoContext *gtk_print_context_create_pango_context (GtkPrintContext *context); PangoContext *gtk_print_context_create_pango_context (GtkPrintContext *context);
PangoLayout *gtk_print_context_create_pango_layout (GtkPrintContext *context); PangoLayout *gtk_print_context_create_pango_layout (GtkPrintContext *context);
/* Needed for preview implementations */
void gtk_print_context_set_cairo_context (GtkPrintContext *context,
cairo_t *cr,
double dpi_x,
double dpi_y);
G_END_DECLS G_END_DECLS
......
...@@ -46,9 +46,11 @@ struct _GtkPrintOperationPrivate ...@@ -46,9 +46,11 @@ struct _GtkPrintOperationPrivate
guint print_pages_idle_id; guint print_pages_idle_id;
guint show_progress_timeout_id; guint show_progress_timeout_id;
GtkPrintContext *print_context;
/* Data for the print job: */ /* Data for the print job: */
cairo_surface_t *surface; /* cairo_surface_t *surface; */
gdouble dpi_x, dpi_y; /* gdouble dpi_x, dpi_y; */
GtkPrintPages print_pages; GtkPrintPages print_pages;
GtkPageRange *page_ranges; GtkPageRange *page_ranges;
...@@ -78,17 +80,29 @@ struct _GtkPrintOperationPrivate ...@@ -78,17 +80,29 @@ struct _GtkPrintOperationPrivate
gboolean cancelled); gboolean cancelled);
}; };
GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
GtkWindow *parent,
gboolean *do_print,
GError **error);
typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op, typedef void (* GtkPrintOperationPrintFunc) (GtkPrintOperation *op,
GtkWindow *parent); GtkWindow *parent,
gboolean is_preview);
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
GtkWindow *parent, GtkPrintOperationResult _gtk_print_operation_platform_backend_run_dialog (GtkPrintOperation *operation,
GtkPrintOperationPrintFunc print_cb); GtkWindow *parent,
gboolean *do_print,
GError **error);
void _gtk_print_operation_platform_backend_run_dialog_async (GtkPrintOperation *op,
GtkWindow *parent,
GtkPrintOperationPrintFunc print_cb);
void _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
GtkWindow *parent,
const char *filename);
cairo_surface_t * _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation *op,
GtkPageSetup *page_setup,
gdouble *dpi_x,
gdouble *dpi_y,
const gchar *target);
void _gtk_print_operation_platform_backend_resize_preview_surface (GtkPrintOperation *op,
GtkPageSetup *page_setup,
cairo_surface_t *surface);
void _gtk_print_operation_set_status (GtkPrintOperation *op, void _gtk_print_operation_set_status (GtkPrintOperation *op,
GtkPrintStatus status, GtkPrintStatus status,
......
This diff is collapsed.
...@@ -492,6 +492,7 @@ win32_end_run (GtkPrintOperation *op, ...@@ -492,6 +492,7 @@ win32_end_run (GtkPrintOperation *op,
GlobalFree(op_win32->devmode); GlobalFree(op_win32->devmode);
GlobalFree(op_win32->devnames); GlobalFree(op_win32->devnames);
cairo_surface_finish (op->priv->surface);
cairo_surface_destroy (op->priv->surface); cairo_surface_destroy (op->priv->surface);
op->priv->surface = NULL; op->priv->surface = NULL;
......
This diff is collapsed.
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "gtkpagesetup.h" #include "gtkpagesetup.h"
#include "gtkprintsettings.h" #include "gtkprintsettings.h"
#include "gtkprintcontext.h" #include "gtkprintcontext.h"
#include "gtkprintoperationpreview.h"
G_BEGIN_DECLS G_BEGIN_DECLS
...@@ -84,7 +85,13 @@ struct _GtkPrintOperationClass ...@@ -84,7 +85,13 @@ struct _GtkPrintOperationClass
GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation); GtkWidget *(*create_custom_widget) (GtkPrintOperation *operation);
void (*custom_widget_apply) (GtkPrintOperation *operation, void (*custom_widget_apply) (GtkPrintOperation *operation,
GtkWidget *widget); GtkWidget *widget);
gboolean (*preview) (GtkPrintOperation *operation,
GtkPrintOperationPreview *preview,
GtkPrintContext *context,
GtkWindow *parent);
/* Padding for future expansion */ /* Padding for future expansion */
void (*_gtk_reserved1) (void); void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void); void (*_gtk_reserved2) (void);
...@@ -98,7 +105,8 @@ struct _GtkPrintOperationClass ...@@ -98,7 +105,8 @@ struct _GtkPrintOperationClass
typedef enum { typedef enum {
GTK_PRINT_OPERATION_RESULT_ERROR, GTK_PRINT_OPERATION_RESULT_ERROR,
GTK_PRINT_OPERATION_RESULT_APPLY, GTK_PRINT_OPERATION_RESULT_APPLY,
GTK_PRINT_OPERATION_RESULT_CANCEL GTK_PRINT_OPERATION_RESULT_CANCEL,
GTK_PRINT_OPERATION_RESULT_PREVIEW
} GtkPrintOperationResult; } GtkPrintOperationResult;
#define GTK_PRINT_ERROR gtk_print_error_quark () #define GTK_PRINT_ERROR gtk_print_error_quark ()
......
/* GTK - The GIMP Toolkit
* gtkprintoperationpreview.c: Abstract print preview interface
* 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 "gtkprintoperationpreview.h"
#include "gtkmarshalers.h"
#include "gtkintl.h"
static void gtk_print_operation_preview_base_init (gpointer g_iface);
GType
gtk_print_operation_preview_get_type (void)
{
static GType print_operation_preview_type = 0;
if (!print_operation_preview_type)
{
static const GTypeInfo print_operation_preview_info =
{
sizeof (GtkPrintOperationPreviewIface), /* class_size */
gtk_print_operation_preview_base_init, /* base_init */
NULL, /* base_finalize */
NULL,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0, /* n_preallocs */
NULL
};
print_operation_preview_type =
g_type_register_static (G_TYPE_INTERFACE, I_("GtkPrintOperationPreview"),
&print_operation_preview_info, 0);
g_type_interface_add_prerequisite (print_operation_preview_type, G_TYPE_OBJECT);
}
return print_operation_preview_type;
}
static void
gtk_print_operation_preview_base_init (gpointer g_iface)
{
static gboolean initialized = FALSE;
if (!initialized)
{
g_signal_new (I_("ready"),
GTK_TYPE_PRINT_OPERATION_PREVIEW,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_OBJECT);
g_signal_new (I_("got-page-size"),
GTK_TYPE_PRINT_OPERATION_PREVIEW,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkPrintOperationPreviewIface, ready),
NULL, NULL,
_gtk_marshal_VOID__OBJECT_OBJECT,
G_TYPE_NONE, 2,
GTK_TYPE_PRINT_CONTEXT,
GTK_TYPE_PAGE_SETUP);
initialized = TRUE;
}
}
void
gtk_print_operation_preview_render_page (GtkPrintOperationPreview *preview,
gint page_nr)
{
g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->render_page (preview,
page_nr);
}
void
gtk_print_operation_preview_end_preview (GtkPrintOperationPreview *preview)
{
g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->end_preview (preview);
}
gboolean
gtk_print_operation_preview_is_selected (GtkPrintOperationPreview *preview,
gint page_nr)
{
g_return_if_fail (GTK_IS_PRINT_OPERATION_PREVIEW (preview));
return GTK_PRINT_OPERATION_PREVIEW_GET_IFACE (preview)->is_selected (preview, page_nr);
}
/* GTK - The GIMP Toolkit
* gtkprintoperationpreview.h: Abstract print preview interface
* 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_PREVIEW_H__
#define __GTK_PRINT_OPERATION_PREVIEW_H__
#include <glib-object.h>
#include <cairo.h>
#include "gtkprintcontext.h"
G_BEGIN_DECLS
#define GTK_TYPE_PRINT_OPERATION_PREVIEW (gtk_print_operation_preview_get_type ())
#define GTK_PRINT_OPERATION_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PRINT_OPERATION_PREVIEW, GtkPrintOperationPreview))
#define GTK_IS_PRINT_OPERATION_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PRINT_OPERATION_PREVIEW))
#define GTK_PRINT_OPERATION_PREVIEW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_PRINT_OPERATION_PREVIEW, GtkPrintOperationPreviewIface))
typedef struct _GtkPrintOperationPreview GtkPrintOperationPreview; /*dummy typedef */
typedef struct _GtkPrintOperationPreviewIface GtkPrintOperationPreviewIface;
struct _GtkPrintOperationPreviewIface
{
GTypeInterface g_iface;
/* signals */
void (*ready) (GtkPrintOperationPreview *preview,
GtkPrintContext *context);
void (*got_page_size) (GtkPrintOperationPreview *preview,
GtkPrintContext *context,
GtkPageSetup *page_setup);
/* methods */
void (*render_page) (GtkPrintOperationPreview *preview,
gint page_nr);
gboolean (*is_selected) (GtkPrintOperationPreview *preview,
gint page_nr);
void (*end_preview) (GtkPrintOperationPreview *preview);
/* Padding for future expansion */