[gthumb] print: set a good default filename for the print-to-file operation
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] print: set a good default filename for the print-to-file operation
- Date: Sat, 18 Aug 2012 18:40:02 +0000 (UTC)
commit 76d87a6fe161446e00a4c579a5b25c9a2b30235f
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Aug 16 09:12:49 2012 +0200
print: set a good default filename for the print-to-file operation
extensions/image_print/gth-image-print-job.c | 37 +++++++++++++++++++++++++-
1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/extensions/image_print/gth-image-print-job.c b/extensions/image_print/gth-image-print-job.c
index 42f1ea3..8de4206 100644
--- a/extensions/image_print/gth-image-print-job.c
+++ b/extensions/image_print/gth-image-print-job.c
@@ -1834,6 +1834,39 @@ gth_image_print_job_new (GList *file_data_list,
static void
+_gth_image_print_job_set_output_uri (GthImagePrintJob *self,
+ GtkPrintSettings *settings)
+{
+ char *basename;
+ const char *default_dir;
+ const char *ext;
+ char *path;
+ char *uri;
+
+ if (self->priv->n_images == 1)
+ basename = _g_uri_remove_extension (g_file_info_get_name (self->priv->images[0]->file_data->info));
+ else
+ basename = g_strdup (g_file_info_get_edit_name (gth_browser_get_location_data (self->priv->browser)->info));
+ default_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+ if (default_dir == NULL)
+ default_dir = g_get_home_dir ();
+ ext = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT);
+ if (ext == NULL) {
+ gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "pdf");
+ ext = "pdf";
+ }
+ path = g_strconcat (default_dir, G_DIR_SEPARATOR_S, basename, ".", ext, NULL);
+ uri = g_filename_to_uri (path, NULL, NULL);
+ if (uri != NULL)
+ gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_URI, uri);
+
+ g_free (uri);
+ g_free (path);
+ g_free (basename);
+}
+
+
+static void
load_image_info_task_completed_cb (GthTask *task,
GError *error,
gpointer user_data)
@@ -1889,8 +1922,10 @@ load_image_info_task_completed_cb (GthTask *task,
file = gth_user_dir_get_file_for_read (GTH_DIR_CONFIG, GTHUMB_DIR, "print_settings", NULL);
filename = g_file_get_path (file);
settings = gtk_print_settings_new_from_file (filename, NULL);
- if (settings != NULL)
+ if (settings != NULL) {
+ _gth_image_print_job_set_output_uri (self, settings);
gtk_print_operation_set_print_settings (self->priv->print_operation, settings);
+ }
g_free (filename);
g_object_unref (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]