[gtk+/gtk-2-22] Filechooser - In OPEN or SAVE mode, typing a plain folder name should switch to it



commit 00f174222550fb54d20fa4a1515037889c6a0a71
Author: Federico Mena Quintero <federico novell com>
Date:   Wed Oct 6 12:59:44 2010 -0500

    Filechooser - In OPEN or SAVE mode, typing a plain folder name should switch to it
    
    If you type 'subfolder/' and hit Enter, the file chooser will switch you to
    it.  But if you type just 'subfolder' without the trailing slash, apps would
    receive *that* filename (e.g. file:///foo/bar/subfolder) as the response, and
    they would likely print an error that they can't open that file (as it is
    a folder).  So, we change the file chooser's current folder to that subfolder
    in this case.
    
    Signed-off-by: Federico Mena Quintero <federico novell com>
    (cherry picked from commit 5350edbb2ce4ac7b6d7e05ab0914ae21c28c58d0)

 gtk/gtkfilechooserdefault.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 1a8b461..c49416f 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -8425,8 +8425,13 @@ file_exists_get_info_cb (GCancellable *cancellable,
 
   if (data->impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
     {
-      /* user typed a filename; we are done */
-      g_signal_emit_by_name (data->impl, "response-requested");
+      if (is_folder)
+	change_folder_and_display_error (data->impl, data->file, TRUE);
+      else
+	{
+	  /* user typed a filename; we are done */
+	  g_signal_emit_by_name (data->impl, "response-requested");
+	}
     }
   else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
     {
@@ -8462,7 +8467,10 @@ file_exists_get_info_cb (GCancellable *cancellable,
     }
   else if (data->impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
     {
-      needs_file_type_check = TRUE;
+      if (is_folder)
+	change_folder_and_display_error (data->impl, data->file, TRUE);
+      else
+	needs_file_type_check = TRUE;
     }
   else
     {



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