[virt-tools-list] [virt-viewer 1/3] Set a default dir/name for screenshots

Christophe Fergeau cfergeau at redhat.com
Tue Nov 13 12:06:37 UTC 2012


It makes sense for the screenshots to be saved in ~/Images,
especially as otherwise the filechooser will display
'recent documents' to which we cannot save. This commit also sets
the default screenshot name to 'Screenshot'.
---
 src/virt-viewer-window.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 2aafe94..9ca2cf7 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -768,6 +768,7 @@ virt_viewer_window_menu_file_screenshot(GtkWidget *menu G_GNUC_UNUSED,
 {
     GtkWidget *dialog;
     VirtViewerWindowPrivate *priv = self->priv;
+    const char *image_dir;
 
     g_return_if_fail(priv->display != NULL);
 
@@ -780,9 +781,10 @@ virt_viewer_window_menu_file_screenshot(GtkWidget *menu G_GNUC_UNUSED,
     gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER (dialog), TRUE);
     gtk_window_set_transient_for(GTK_WINDOW(dialog),
                                  GTK_WINDOW(self->priv->window));
-
-    //gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), default_folder_for_saving);
-    //gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Screenshot");
+    image_dir = g_get_user_special_dir(G_USER_DIRECTORY_PICTURES);
+    if (image_dir != NULL)
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), image_dir);
+    gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER (dialog), _("Screenshot"));
 
     if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
         char *filename;
-- 
1.8.0




More information about the virt-tools-list mailing list