summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTimothy Arceri <t_arceri@yahoo.com.au>2012-03-06 21:15:01 +1100
committerMarek Kasik <mkasik@redhat.com>2012-05-14 14:26:53 +0200
commit8d1f32aaafedce6326b0dbd837dc5503e889a60e (patch)
tree1f02fb605ce44744a2e8634361cc052c8eddc157 /modules
parentf730f519f8b3729b97f9a8c777a001dd68fd8476 (diff)
downloadgtk+-8d1f32aaafedce6326b0dbd837dc5503e889a60e.tar.gz
GTK PrintToFile settings
To make setting output directory and filename simpler in the PrintToFile dialog two gtkprintsettings have been added GTK_PRINT_SETTINGS_OUTPUT_DIR and GTK_PRINT_SETTINGS_OUTPUT_BASENAME. This will reduce the code needed to implement a better name than "output.pdf" and actually makes more sense than the existing setting GTK_PRINT_SETTINGS_OUTPUT_URI which doesn't work seamlessly with GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT like the new settings do. https://bugzilla.gnome.org/show_bug.cgi?id=657322
Diffstat (limited to 'modules')
-rw-r--r--modules/printbackends/file/gtkprintbackendfile.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/modules/printbackends/file/gtkprintbackendfile.c b/modules/printbackends/file/gtkprintbackendfile.c
index 32ce8c5b10..3041d70606 100644
--- a/modules/printbackends/file/gtkprintbackendfile.c
+++ b/modules/printbackends/file/gtkprintbackendfile.c
@@ -213,13 +213,13 @@ output_file_from_settings (GtkPrintSettings *settings,
const gchar *default_format)
{
gchar *uri = NULL;
-
+
if (settings)
uri = g_strdup (gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_URI));
if (uri == NULL)
{
- const gchar *extension;
+ const gchar *extension, *basename, *output_dir;
gchar *name, *locale_name, *path;
if (default_format)
@@ -243,30 +243,43 @@ output_file_from_settings (GtkPrintSettings *settings,
break;
}
}
-
- /* default filename used for print-to-file */
- name = g_strdup_printf (_("output.%s"), extension);
+
+ basename = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME);
+ if (basename == NULL)
+ basename = _("output");
+
+ name = g_strconcat (basename, ".", extension, NULL);
+
locale_name = g_filename_from_utf8 (name, -1, NULL, NULL, NULL);
g_free (name);
if (locale_name != NULL)
- {
- const gchar *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
-
- if (document_dir == NULL)
+ {
+ output_dir = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_DIR);
+ if (output_dir == NULL)
{
- gchar *current_dir = g_get_current_dir ();
- path = g_build_filename (current_dir, locale_name, NULL);
- g_free (current_dir);
- }
+ const gchar *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+
+ if (document_dir == NULL)
+ {
+ gchar *current_dir = g_get_current_dir ();
+ path = g_build_filename (current_dir, locale_name, NULL);
+ g_free (current_dir);
+ }
+ else
+ path = g_build_filename (document_dir, locale_name, NULL);
+
+ uri = g_filename_to_uri (path, NULL, NULL);
+ }
else
- path = g_build_filename (document_dir, locale_name, NULL);
-
- uri = g_filename_to_uri (path, NULL, NULL);
+ {
+ path = g_build_filename (output_dir, locale_name, NULL);
+ uri = g_filename_to_uri (path, NULL, NULL);
+ }
+ g_free (path);
g_free (locale_name);
- g_free (path);
- }
+ }
}
return uri;