[totem] Suggest filename when capturing a gallery



commit 3e3de882d4643662b5a19e4e046944f9d8dca729
Author: Robin Stocker <robin nibor org>
Date:   Mon Nov 23 12:38:17 2009 +0000

    Suggest filename when capturing a gallery
    
    https://bugzilla.gnome.org/show_bug.cgi?id=595760

 src/plugins/screenshot/totem-gallery.c           |   11 ++++++++++-
 src/plugins/screenshot/totem-screenshot-plugin.c |    5 ++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/screenshot/totem-gallery.c b/src/plugins/screenshot/totem-gallery.c
index fba428c..5e353a6 100644
--- a/src/plugins/screenshot/totem-gallery.c
+++ b/src/plugins/screenshot/totem-gallery.c
@@ -68,7 +68,8 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
 	TotemGallery *gallery;
 	GtkWidget *container;
 	GtkBuilder *builder;
-	gchar *uri;
+	gchar *uri, *suggested_name;
+	GFile *file;
 
 	/* Create the gallery and its interface */
 	gallery = g_object_new (TOTEM_TYPE_GALLERY, NULL);
@@ -106,8 +107,16 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
 
 	/* Translators: the argument is a screenshot number, used to prevent overwriting files. Just translate "Screenshot", and not the ".jpg". */
 	uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot%d.jpg"));
+	file = g_file_new_for_uri (uri);
+	/* We can use g_file_get_basename here and be sure that it's UTF-8
+	 * because we provided the name. */
+	suggested_name = g_file_get_basename (file);
+	g_object_unref (file);
+
 	gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (gallery), uri);
 	g_free (uri);
+	gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (gallery), suggested_name);
+	g_free (suggested_name);
 
 	gtk_widget_show_all (GTK_WIDGET (gallery));
 
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c b/src/plugins/screenshot/totem-screenshot-plugin.c
index b167d76..080d6f2 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -321,6 +321,7 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format)
 {
 	GConfClient *client;
 	char *path, *filename, *full, *uri;
+	GFile *file;
 
 	/* Set the default path */
 	client = gconf_client_get_default ();
@@ -343,8 +344,10 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format)
 	g_free (path);
 	g_free (filename);
 
-	uri = g_strconcat ("file://", full, NULL);
+	file = g_file_new_for_path (full);
+	uri = g_file_get_uri (file);
 	g_free (full);
+	g_object_unref (file);
 
 	return uri;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]