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.
This commit is contained in:
Matthias Clasen 2009-06-25 01:23:50 -04:00
parent 724ab58244
commit 99b42cf006

View File

@ -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 ();
@ -165,9 +167,18 @@ do_printing (GtkWidget *do_widget)
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)
{