diff options
author | Timothy Arceri <t_arceri@yahoo.com.au> | 2012-05-25 13:12:36 +1000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2012-08-25 17:47:55 -0400 |
commit | 2ab8e75319e98add0f8fa872677bd0e5c4cc8267 (patch) | |
tree | b2720be324ee7f45f9028b3efb34b67b788c2b78 /demos/gtk-demo | |
parent | 870c39fafea46c87ce5b8d6df4c9b9144562afad (diff) | |
download | gtk+-2ab8e75319e98add0f8fa872677bd0e5c4cc8267.tar.gz |
Use new printer setting to reduce code required by application
Updated demo to use new setting that allows an application to change the
output filename without the need to create the uri itself.
https://bugzilla.gnome.org/show_bug.cgi?id=676787
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r-- | demos/gtk-demo/printing.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c index 59835ea197..91637de133 100644 --- a/demos/gtk-demo/printing.c +++ b/demos/gtk-demo/printing.c @@ -149,8 +149,6 @@ do_printing (GtkWidget *do_widget) GtkPrintOperation *operation; GtkPrintSettings *settings; PrintData *data; - gchar *uri, *ext; - const gchar *dir; GError *error = NULL; operation = gtk_print_operation_new (); @@ -170,25 +168,14 @@ do_printing (GtkWidget *do_widget) gtk_print_operation_set_embed_page_setup (operation, TRUE); settings = gtk_print_settings_new (); - dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS); - if (dir == NULL) - dir = g_get_home_dir (); - if (g_strcmp0 (gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT), "ps") == 0) - ext = ".ps"; - else if (g_strcmp0 (gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT), "svg") == 0) - ext = ".svg"; - else - ext = ".pdf"; - - uri = g_strconcat ("file://", dir, "/", "gtk-demo", ext, NULL); - gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_URI, uri); + + gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, "gtk-demo"); 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) { |