[gtk+] Demo setting an output name for print to file
- From: Matthias Clasen <matthiasc src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+] Demo setting an output name for print to file
- Date: Thu, 25 Jun 2009 05:25:17 +0000 (UTC)
commit 99b42cf0062022dae9bed4abb8341758c48c5d28
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 25 01:23:50 2009 -0400
Demo setting an output name for print to file
It turns out that no application is doing this, since it is not
obvious. Adding a demo here is at least a start.
demos/gtk-demo/printing.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c
index 6d27ac0..76a7fed 100644
--- a/demos/gtk-demo/printing.c
+++ b/demos/gtk-demo/printing.c
@@ -147,7 +147,9 @@ GtkWidget *
do_printing (GtkWidget *do_widget)
{
GtkPrintOperation *operation;
+ GtkPrintSettings *settings;
PrintData *data;
+ gchar *uri;
GError *error = NULL;
operation = gtk_print_operation_new ();
@@ -155,19 +157,28 @@ do_printing (GtkWidget *do_widget)
data->filename = demo_find_file ("printing.c", NULL);
data->font_size = 12.0;
- g_signal_connect (G_OBJECT (operation), "begin-print",
+ g_signal_connect (G_OBJECT (operation), "begin-print",
G_CALLBACK (begin_print), data);
- g_signal_connect (G_OBJECT (operation), "draw-page",
+ g_signal_connect (G_OBJECT (operation), "draw-page",
G_CALLBACK (draw_page), data);
- g_signal_connect (G_OBJECT (operation), "end-print",
+ g_signal_connect (G_OBJECT (operation), "end-print",
G_CALLBACK (end_print), data);
gtk_print_operation_set_use_full_page (operation, FALSE);
gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);
+ settings = gtk_print_settings_new ();
+ uri = g_strconcat ("file://",
+ g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS),
+ "/gtk-demo-printing-example.pdf", NULL);
+ gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_URI, uri);
+ gtk_print_operation_set_print_settings (operation, settings);
+
gtk_print_operation_run (operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW (do_widget), &error);
g_object_unref (operation);
+ g_object_unref (settings);
+ g_free (uri);
if (error)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]