]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserdefault.c
Free volumes not actually put into the shortcut list.
[~andy/gtk] / gtk / gtkfilechooserdefault.c
index 7f1cd17fb1435576f1b1409caadfa1944dd5d3a0..8987297667fd8402043ffd0074b524b2b8bfa938 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#include <config.h>
 #include "gdk/gdkkeysyms.h"
 #include "gtkalignment.h"
 #include "gtkbindings.h"
 #include "gtkbutton.h"
+#include "gtkcelllayout.h"
 #include "gtkcellrendererpixbuf.h"
 #include "gtkcellrendererseptext.h"
 #include "gtkcellrenderertext.h"
@@ -29,6 +31,7 @@
 #include "gtkentry.h"
 #include "gtkexpander.h"
 #include "gtkfilechooserdefault.h"
+#include "gtkfilechooserembed.h"
 #include "gtkfilechooserentry.h"
 #include "gtkfilechooserutils.h"
 #include "gtkfilechooser.h"
@@ -36,6 +39,7 @@
 #include "gtkframe.h"
 #include "gtkhbox.h"
 #include "gtkhpaned.h"
+#include "gtkiconfactory.h"
 #include "gtkicontheme.h"
 #include "gtkimage.h"
 #include "gtkintl.h"
@@ -49,6 +53,8 @@
 #include "gtksizegroup.h"
 #include "gtkstock.h"
 #include "gtktable.h"
+#include "gtktreednd.h"
+#include "gtktreeprivate.h"
 #include "gtktreeview.h"
 #include "gtktreemodelsort.h"
 #include "gtktreeselection.h"
@@ -71,6 +77,7 @@ typedef struct _GtkFileChooserDefaultClass GtkFileChooserDefaultClass;
 #define GTK_IS_FILE_CHOOSER_DEFAULT_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT))
 #define GTK_FILE_CHOOSER_DEFAULT_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
 
+
 struct _GtkFileChooserDefaultClass
 {
   GtkVBoxClass parent_class;
@@ -84,13 +91,36 @@ struct _GtkFileChooserDefault
 
   GtkFileSystem *file_system;
 
-  /* Things common to Open and Save mode */
+  /* Save mode widgets */
+  GtkWidget *save_widgets;
 
-  GtkWidget *hpaned;
+  GtkWidget *save_file_name_entry;
+  GtkWidget *save_folder_label;
+  GtkWidget *save_folder_combo;
+  GtkWidget *save_extra_align;
+  GtkWidget *save_expander;
+
+  /* The file browsing widgets */
+  GtkWidget *browse_widgets;
+  GtkWidget *browse_shortcuts_tree_view;
+  GtkWidget *browse_shortcuts_add_button;
+  GtkWidget *browse_shortcuts_remove_button;
+  GtkWidget *browse_files_tree_view;
+  GtkWidget *browse_new_folder_button;
+  GtkWidget *browse_path_bar;
+  GtkWidget *browse_extra_align;
+
+  GtkFileSystemModel *browse_files_model;
+
+  GtkWidget *filter_combo;
+  GtkWidget *preview_box;
+  GtkWidget *preview_label;
+  GtkWidget *preview_widget;
+  GtkWidget *extra_widget;
 
-  GtkFileSystemModel *tree_model;
   GtkListStore *shortcuts_model;
-  GtkFileSystemModel *list_model;
+  GtkTreeModel *shortcuts_filter_model;
+
   GtkTreeModelSort *sort_model;
 
   GtkFileFilter *current_filter;
@@ -109,56 +139,48 @@ struct _GtkFileChooserDefault
   GtkFilePath *current_volume_path;
   GtkFilePath *current_folder;
   GtkFilePath *preview_path;
-
-  GtkWidget *new_folder_button;
-
-  GtkWidget *preview_frame;
-
-  GtkWidget *filter_combo;
-  GtkWidget *tree_scrollwin;
-  GtkWidget *tree;
-  GtkWidget *shortcuts_scrollwin;
-  GtkWidget *shortcuts_tree;
-  GtkWidget *add_bookmark_button;
-  GtkWidget *remove_bookmark_button;
-  GtkWidget *list_scrollwin;
-  GtkWidget *list;
-  GtkWidget *preview_widget;
-  GtkWidget *extra_widget;
-  GtkWidget *path_bar;
+  char *preview_display_name;
 
   GtkTreeViewColumn *list_name_column;
   GtkCellRenderer *list_name_renderer;
 
-  /* Things for Save mode */
-
-  GtkWidget *save_widgets;
+  guint settings_signal_id;
+  int icon_size;
 
-  GtkWidget *entry;
-  GtkWidget *save_folder_combo;
+#if 0
+  GdkDragContext *shortcuts_drag_context;
+  GSource *shortcuts_drag_outside_idle;
+#endif
 
   /* Flags */
 
-  guint folder_mode : 1;
   guint local_only : 1;
   guint preview_widget_active : 1;
+  guint use_preview_label : 1;
   guint select_multiple : 1;
   guint show_hidden : 1;
   guint list_sort_ascending : 1;
   guint changing_folder : 1;
+  guint shortcuts_current_folder_active : 1;
+  guint shortcuts_current_folder_is_volume : 1;
+
+#if 0
+  guint shortcuts_drag_outside : 1;
+#endif
 };
 
 /* Signal IDs */
 enum {
   LOCATION_POPUP,
   UP_FOLDER,
+  DOWN_FOLDER,
   HOME_FOLDER,
   LAST_SIGNAL
 };
 
 static guint signals[LAST_SIGNAL] = { 0 };
 
-/* Column numbers for the shortcuts tree.  Keep these in sync with create_shortcuts_model() */
+/* Column numbers for the shortcuts tree.  Keep these in sync with shortcuts_model_create() */
 enum {
   SHORTCUTS_COL_PIXBUF,
   SHORTCUTS_COL_NAME,
@@ -178,15 +200,34 @@ enum {
 
 /* Identifiers for target types */
 enum {
+  GTK_TREE_MODEL_ROW,
   TEXT_URI_LIST
 };
 
-/* Target types for DnD in the shortcuts list */
-static GtkTargetEntry shortcuts_targets[] = {
+/* Target types for dragging from the shortcuts list */
+static GtkTargetEntry shortcuts_source_targets[] = {
+  { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
+};
+
+static const int num_shortcuts_source_targets = (sizeof (shortcuts_source_targets)
+                                                / sizeof (shortcuts_source_targets[0]));
+
+/* Target types for dropping into the shortcuts list */
+static GtkTargetEntry shortcuts_dest_targets[] = {
+  { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW },
+  { "text/uri-list", 0, TEXT_URI_LIST }
+};
+
+static const int num_shortcuts_dest_targets = (sizeof (shortcuts_dest_targets)
+                                              / sizeof (shortcuts_dest_targets[0]));
+
+/* Target types for DnD from the file list */
+static GtkTargetEntry file_list_source_targets[] = {
   { "text/uri-list", 0, TEXT_URI_LIST }
 };
 
-static const int num_shortcuts_targets = sizeof (shortcuts_targets) / sizeof (shortcuts_targets[0]);
+static const int num_file_list_source_targets = (sizeof (file_list_source_targets)
+                                                / sizeof (file_list_source_targets[0]));
 
 /* Interesting places in the shortcuts bar */
 typedef enum {
@@ -194,17 +235,23 @@ typedef enum {
   SHORTCUTS_DESKTOP,
   SHORTCUTS_VOLUMES,
   SHORTCUTS_SHORTCUTS,
-  SHORTCUTS_SEPARATOR,
-  SHORTCUTS_BOOKMARKS
+  SHORTCUTS_BOOKMARKS_SEPARATOR,
+  SHORTCUTS_BOOKMARKS,
+  SHORTCUTS_CURRENT_FOLDER_SEPARATOR,
+  SHORTCUTS_CURRENT_FOLDER
 } ShortcutsIndex;
 
-/* Standard icon size */
-/* FIXME: maybe this should correspond to the font size in the tree views... */
-#define ICON_SIZE 20
+/* Icon size for if we can't get it from the theme */
+#define FALLBACK_ICON_SIZE 20
 
-static void gtk_file_chooser_default_class_init   (GtkFileChooserDefaultClass *class);
-static void gtk_file_chooser_default_iface_init   (GtkFileChooserIface        *iface);
-static void gtk_file_chooser_default_init         (GtkFileChooserDefault      *impl);
+#define PREVIEW_HBOX_SPACING 12
+#define NUM_LINES 40
+#define NUM_CHARS 60
+
+static void gtk_file_chooser_default_class_init       (GtkFileChooserDefaultClass *class);
+static void gtk_file_chooser_default_iface_init       (GtkFileChooserIface        *iface);
+static void gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface   *iface);
+static void gtk_file_chooser_default_init             (GtkFileChooserDefault      *impl);
 
 static GObject* gtk_file_chooser_default_constructor  (GType                  type,
                                                       guint                  n_construct_properties,
@@ -218,15 +265,22 @@ static void     gtk_file_chooser_default_get_property (GObject               *ob
                                                       guint                  prop_id,
                                                       GValue                *value,
                                                       GParamSpec            *pspec);
-static void     gtk_file_chooser_default_show_all     (GtkWidget             *widget);
-
-static void           gtk_file_chooser_default_set_current_folder         (GtkFileChooser    *chooser,
-                                                                           const GtkFilePath *path);
+static void     gtk_file_chooser_default_dispose      (GObject               *object);
+static void     gtk_file_chooser_default_show_all       (GtkWidget             *widget);
+static void     gtk_file_chooser_default_style_set      (GtkWidget             *widget,
+                                                        GtkStyle              *previous_style);
+static void     gtk_file_chooser_default_screen_changed (GtkWidget             *widget,
+                                                        GdkScreen             *previous_screen);
+
+static gboolean       gtk_file_chooser_default_set_current_folder         (GtkFileChooser    *chooser,
+                                                                           const GtkFilePath *path,
+                                                                           GError           **error);
 static GtkFilePath *  gtk_file_chooser_default_get_current_folder         (GtkFileChooser    *chooser);
 static void           gtk_file_chooser_default_set_current_name           (GtkFileChooser    *chooser,
                                                                            const gchar       *name);
-static void           gtk_file_chooser_default_select_path                (GtkFileChooser    *chooser,
-                                                                           const GtkFilePath *path);
+static gboolean       gtk_file_chooser_default_select_path                (GtkFileChooser    *chooser,
+                                                                           const GtkFilePath *path,
+                                                                           GError           **error);
 static void           gtk_file_chooser_default_unselect_path              (GtkFileChooser    *chooser,
                                                                            const GtkFilePath *path);
 static void           gtk_file_chooser_default_select_all                 (GtkFileChooser    *chooser);
@@ -247,9 +301,20 @@ static gboolean       gtk_file_chooser_default_remove_shortcut_folder (GtkFileCh
                                                                       GError           **error);
 static GSList *       gtk_file_chooser_default_list_shortcut_folders  (GtkFileChooser    *chooser);
 
+static void           gtk_file_chooser_default_get_default_size       (GtkFileChooserEmbed *chooser_embed,
+                                                                      gint                *default_width,
+                                                                      gint                *default_height);
+static void           gtk_file_chooser_default_get_resizable_hints    (GtkFileChooserEmbed *chooser_embed,
+                                                                      gboolean            *resize_horizontally,
+                                                                      gboolean            *resize_vertically);
+static gboolean       gtk_file_chooser_default_should_respond         (GtkFileChooserEmbed *chooser_embed);
+static void           gtk_file_chooser_default_initial_focus          (GtkFileChooserEmbed *chooser_embed);
+
 static void location_popup_handler (GtkFileChooserDefault *impl);
 static void up_folder_handler      (GtkFileChooserDefault *impl);
+static void down_folder_handler    (GtkFileChooserDefault *impl);
 static void home_folder_handler    (GtkFileChooserDefault *impl);
+static void update_appearance      (GtkFileChooserDefault *impl);
 
 static void set_current_filter   (GtkFileChooserDefault *impl,
                                  GtkFileFilter         *filter);
@@ -257,9 +322,6 @@ static void check_preview_change (GtkFileChooserDefault *impl);
 
 static void filter_combo_changed       (GtkComboBox           *combo_box,
                                        GtkFileChooserDefault *impl);
-static void tree_selection_changed     (GtkTreeSelection      *tree_selection,
-                                       GtkFileChooserDefault *impl);
-
 static void     shortcuts_row_activated_cb (GtkTreeView           *tree_view,
                                            GtkTreePath           *path,
                                            GtkTreeViewColumn     *column,
@@ -269,6 +331,12 @@ static gboolean shortcuts_select_func   (GtkTreeSelection      *selection,
                                         GtkTreePath           *path,
                                         gboolean               path_currently_selected,
                                         gpointer               data);
+static void shortcuts_activate_item (GtkFileChooserDefault *impl,
+                                    int                    item_num);
+static int shortcuts_get_index (GtkFileChooserDefault *impl,
+                               ShortcutsIndex         where);
+static int shortcut_find_position (GtkFileChooserDefault *impl,
+                                  const GtkFilePath     *path);
 
 static void list_selection_changed     (GtkTreeSelection      *tree_selection,
                                        GtkFileChooserDefault *impl);
@@ -286,11 +354,6 @@ static void add_bookmark_button_clicked_cb    (GtkButton             *button,
 static void remove_bookmark_button_clicked_cb (GtkButton             *button,
                                               GtkFileChooserDefault *impl);
 
-static void tree_name_data_func (GtkTreeViewColumn *tree_column,
-                                GtkCellRenderer   *cell,
-                                GtkTreeModel      *tree_model,
-                                GtkTreeIter       *iter,
-                                gpointer           data);
 static void list_icon_data_func (GtkTreeViewColumn *tree_column,
                                 GtkCellRenderer   *cell,
                                 GtkTreeModel      *tree_model,
@@ -316,6 +379,37 @@ static void list_mtime_data_func (GtkTreeViewColumn *tree_column,
 
 static GObjectClass *parent_class;
 
+\f
+
+/* Drag and drop interface declarations */
+
+typedef struct {
+  GtkTreeModelFilter parent;
+
+  GtkFileChooserDefault *impl;
+} ShortcutsModelFilter;
+
+typedef struct {
+  GtkTreeModelFilterClass parent_class;
+} ShortcutsModelFilterClass;
+
+#define SHORTCUTS_MODEL_FILTER_TYPE (shortcuts_model_filter_get_type ())
+#define SHORTCUTS_MODEL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHORTCUTS_MODEL_FILTER_TYPE, ShortcutsModelFilter))
+
+static void shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (ShortcutsModelFilter,
+                        shortcuts_model_filter,
+                        GTK_TYPE_TREE_MODEL_FILTER,
+                        G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
+                                               shortcuts_model_filter_drag_source_iface_init));
+
+static GtkTreeModel *shortcuts_model_filter_new (GtkFileChooserDefault *impl,
+                                                GtkTreeModel          *child_model,
+                                                GtkTreePath           *root);
+
+\f
+
 GType
 _gtk_file_chooser_default_get_type (void)
 {
@@ -343,11 +437,22 @@ _gtk_file_chooser_default_get_type (void)
        NULL                                                           /* interface_data */
       };
 
+      static const GInterfaceInfo file_chooser_embed_info =
+      {
+       (GInterfaceInitFunc) gtk_file_chooser_embed_default_iface_init, /* interface_init */
+       NULL,                                                          /* interface_finalize */
+       NULL                                                           /* interface_data */
+      };
+
       file_chooser_default_type = g_type_register_static (GTK_TYPE_VBOX, "GtkFileChooserDefault",
                                                         &file_chooser_default_info, 0);
+
       g_type_add_interface_static (file_chooser_default_type,
                                   GTK_TYPE_FILE_CHOOSER,
                                   &file_chooser_info);
+      g_type_add_interface_static (file_chooser_default_type,
+                                  GTK_TYPE_FILE_CHOOSER_EMBED,
+                                  &file_chooser_embed_info);
     }
 
   return file_chooser_default_type;
@@ -366,8 +471,11 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
   gobject_class->constructor = gtk_file_chooser_default_constructor;
   gobject_class->set_property = gtk_file_chooser_default_set_property;
   gobject_class->get_property = gtk_file_chooser_default_get_property;
+  gobject_class->dispose = gtk_file_chooser_default_dispose;
 
   widget_class->show_all = gtk_file_chooser_default_show_all;
+  widget_class->style_set = gtk_file_chooser_default_style_set;
+  widget_class->screen_changed = gtk_file_chooser_default_screen_changed;
 
   signals[LOCATION_POPUP] =
     _gtk_binding_signal_new ("location-popup",
@@ -385,6 +493,14 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
                             NULL, NULL,
                             _gtk_marshal_VOID__VOID,
                             G_TYPE_NONE, 0);
+  signals[DOWN_FOLDER] =
+    _gtk_binding_signal_new ("down-folder",
+                            G_OBJECT_CLASS_TYPE (class),
+                            G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                            G_CALLBACK (down_folder_handler),
+                            NULL, NULL,
+                            _gtk_marshal_VOID__VOID,
+                            G_TYPE_NONE, 0);
   signals[HOME_FOLDER] =
     _gtk_binding_signal_new ("home-folder",
                             G_OBJECT_CLASS_TYPE (class),
@@ -410,6 +526,15 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
                                "up-folder",
                                0);
 
+  gtk_binding_entry_add_signal (binding_set,
+                               GDK_Down, GDK_MOD1_MASK,
+                               "down-folder",
+                               0);
+  gtk_binding_entry_add_signal (binding_set,
+                               GDK_KP_Down, GDK_MOD1_MASK,
+                               "down-folder",
+                               0);
+
   gtk_binding_entry_add_signal (binding_set,
                                GDK_Home, GDK_MOD1_MASK,
                                "home-folder",
@@ -420,6 +545,12 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
                                0);
 
   _gtk_file_chooser_install_properties (gobject_class);
+
+  gtk_settings_install_property (g_param_spec_string ("gtk-file-chooser-backend",
+                                                     P_("Default file chooser backend"),
+                                                     P_("Name of the GtkFileChooser backend to use by default"),
+                                                     NULL,
+                                                     G_PARAM_READWRITE));
 }
 
 static void
@@ -443,15 +574,25 @@ gtk_file_chooser_default_iface_init (GtkFileChooserIface *iface)
   iface->list_shortcut_folders = gtk_file_chooser_default_list_shortcut_folders;
 }
 
+static void
+gtk_file_chooser_embed_default_iface_init (GtkFileChooserEmbedIface *iface)
+{
+  iface->get_default_size = gtk_file_chooser_default_get_default_size;
+  iface->get_resizable_hints = gtk_file_chooser_default_get_resizable_hints;
+  iface->should_respond = gtk_file_chooser_default_should_respond;
+  iface->initial_focus = gtk_file_chooser_default_initial_focus;
+}
 static void
 gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
 {
-  impl->folder_mode = FALSE;
   impl->local_only = TRUE;
   impl->preview_widget_active = TRUE;
+  impl->use_preview_label = TRUE;
   impl->select_multiple = FALSE;
   impl->show_hidden = FALSE;
+  impl->icon_size = FALLBACK_ICON_SIZE;
 
+  gtk_widget_set_redraw_on_allocate (GTK_WIDGET (impl), TRUE);
   gtk_box_set_spacing (GTK_BOX (impl), 12);
 }
 
@@ -488,6 +629,21 @@ gtk_file_chooser_default_finalize (GObject *object)
   if (impl->preview_path)
     gtk_file_path_free (impl->preview_path);
 
+  /* Free all the Models we have */
+  if (impl->browse_files_model)
+    g_object_unref (impl->browse_files_model);
+
+  if (impl->shortcuts_model)
+    g_object_unref (impl->shortcuts_model);
+
+  if (impl->shortcuts_filter_model)
+    g_object_unref (impl->shortcuts_filter_model);
+
+  if (impl->sort_model)
+    g_object_unref (impl->sort_model);
+
+  g_free (impl->preview_display_name);
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -501,7 +657,7 @@ error_message_with_parent (GtkWindow  *parent,
   dialog = gtk_message_dialog_new (parent,
                                   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                   GTK_MESSAGE_ERROR,
-                                  GTK_BUTTONS_CLOSE,
+                                  GTK_BUTTONS_OK,
                                   "%s",
                                   msg);
   gtk_dialog_run (GTK_DIALOG (dialog));
@@ -530,14 +686,19 @@ error_dialog (GtkFileChooserDefault *impl,
              const GtkFilePath     *path,
              GError                *error)
 {
-  char *text;
+  g_return_if_fail (path != NULL);
 
-  text = g_strdup_printf (msg,
-                         gtk_file_path_get_string (path),
-                         error->message);
-  error_message (impl, text);
-  g_free (text);
-  g_error_free (error);
+  if (error)
+    {
+      char *uri = gtk_file_system_path_to_uri (impl->file_system, path);
+      char *text = g_strdup_printf (msg,
+                                   uri,
+                                   error->message);
+      error_message (impl, text);
+      g_free (text);
+      g_free (uri);
+      g_error_free (error);
+    }
 }
 
 /* Displays an error message about not being able to get information for a file.
@@ -571,24 +732,76 @@ error_building_filename_dialog (GtkFileChooserDefault *impl,
                                const char            *file_part,
                                GError                *error)
 {
+  char *uri;
   char *msg;
 
+  uri = gtk_file_system_path_to_uri (impl->file_system, base_path);
   msg = g_strdup_printf (_("Could not build file name from '%s' and '%s':\n%s"),
-                        gtk_file_path_get_string (base_path),
-                        file_part,
+                        uri, file_part,
                         error->message);
   error_message (impl, msg);
+  g_free (uri);
   g_free (msg);
   g_error_free (error);
 }
 
+/* Shows an error dialog when we cannot switch to a folder */
+static void
+error_changing_folder_dialog (GtkFileChooserDefault *impl,
+                             const GtkFilePath     *path,
+                             GError                *error)
+{
+  error_dialog (impl,
+               _("Could not change the current folder to %s:\n%s"),
+               path,
+               error);
+}
+
+/* Changes folders, displaying an error dialog if this fails */
+static gboolean
+change_folder_and_display_error (GtkFileChooserDefault *impl,
+                                const GtkFilePath     *path)
+{
+  GError *error;
+  gboolean result;
+
+  error = NULL;
+  result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path, &error);
+
+  if (!result)
+    error_changing_folder_dialog (impl, path, error);
+
+  return result;
+}
+
 static void
 update_preview_widget_visibility (GtkFileChooserDefault *impl)
 {
+  if (impl->use_preview_label)
+    {
+      if (!impl->preview_label)
+       {
+         impl->preview_label = gtk_label_new (impl->preview_display_name);
+         gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_label, FALSE, FALSE, 0);
+         gtk_box_reorder_child (GTK_BOX (impl->preview_box), impl->preview_label, 0);
+         gtk_widget_show (impl->preview_label);
+       }
+    }
+  else
+    {
+      if (impl->preview_label)
+       {
+         gtk_widget_destroy (impl->preview_label);
+         impl->preview_label = NULL;
+       }
+    }
+
   if (impl->preview_widget_active && impl->preview_widget)
-    gtk_widget_show (impl->preview_frame);
+    gtk_widget_show (impl->preview_box);
   else
-    gtk_widget_hide (impl->preview_frame);
+    gtk_widget_hide (impl->preview_box);
+
+  g_signal_emit_by_name (impl, "default-size-changed");
 }
 
 static void
@@ -599,56 +812,144 @@ set_preview_widget (GtkFileChooserDefault *impl,
     return;
 
   if (impl->preview_widget)
-    gtk_container_remove (GTK_CONTAINER (impl->preview_frame),
+    gtk_container_remove (GTK_CONTAINER (impl->preview_box),
                          impl->preview_widget);
 
   impl->preview_widget = preview_widget;
   if (impl->preview_widget)
     {
-      gtk_widget_show_all (impl->preview_widget);
-      gtk_container_add (GTK_CONTAINER (impl->preview_frame),
-                        impl->preview_widget);
+      gtk_widget_show (impl->preview_widget);
+      gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_widget, TRUE, TRUE, 0);
+      gtk_box_reorder_child (GTK_BOX (impl->preview_box),
+                            impl->preview_widget,
+                            (impl->use_preview_label && impl->preview_label) ? 1 : 0);
     }
 
   update_preview_widget_visibility (impl);
 }
 
-/* Clears the selection in the shortcuts tree */
+/* Re-reads all the icons for the shortcuts, used when the theme changes */
+static void
+shortcuts_reload_icons (GtkFileChooserDefault *impl)
+{
+  GtkTreeIter iter;
+  int i;
+  int bookmarks_separator_idx;
+  int current_folder_separator_idx;
+  int volumes_idx;
+
+  if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+    return;
+
+  bookmarks_separator_idx = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
+  current_folder_separator_idx = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+  volumes_idx = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
+
+  i = 0;
+
+  do {
+    gpointer data;
+    gboolean pixbuf_visible;
+    GdkPixbuf *pixbuf;
+
+    gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+                       SHORTCUTS_COL_PATH, &data,
+                       SHORTCUTS_COL_PIXBUF_VISIBLE, &pixbuf_visible,
+                       -1);
+
+    if (!pixbuf_visible || !data)
+      goto next_iter;
+
+    if (i >= volumes_idx && i < volumes_idx + impl->num_volumes)
+      {
+       GtkFileSystemVolume *volume;
+
+       volume = data;
+       pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
+                                                    impl->icon_size, NULL);
+      }
+    else
+      {
+       const GtkFilePath *path;
+
+       path = data;
+       pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
+                                             impl->icon_size, NULL);
+      }
+
+    gtk_list_store_set (impl->shortcuts_model, &iter,
+                       SHORTCUTS_COL_PIXBUF, pixbuf,
+                       -1);
+
+  next_iter:
+    i++;
+  } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
+}
+
+/* If a shortcut corresponds to the current folder, selects it */
 static void
-shortcuts_unselect_all (GtkFileChooserDefault *impl)
+shortcuts_find_current_folder (GtkFileChooserDefault *impl)
 {
   GtkTreeSelection *selection;
+  int pos;
+  GtkTreePath *path;
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->shortcuts_tree));
-  gtk_tree_selection_unselect_all (selection);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
+
+  pos = shortcut_find_position (impl, impl->current_folder);
+  if (pos == -1)
+    {
+      gtk_tree_selection_unselect_all (selection);
+      return;
+    }
+
+  path = gtk_tree_path_new_from_indices (pos, -1);
+  gtk_tree_selection_select_path (selection, path);
+  gtk_tree_path_free (path);
+}
+
+/* Returns whether a path is a folder */
+static gboolean
+check_is_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
+{
+  GtkFileFolder *folder;
+
+  folder = gtk_file_system_get_folder (file_system, path,
+                                      GTK_FILE_INFO_DISPLAY_NAME,
+                                      error);
+  if (!folder)
+    return FALSE;
+
+  g_object_unref (folder);
+  return TRUE;
 }
 
 /* Convenience function to get the display name and icon info for a path */
 static GtkFileInfo *
-get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
+get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean name_only, GError **error)
 {
   GtkFilePath *parent_path;
   GtkFileFolder *parent_folder;
   GtkFileInfo *info;
 
+  info = NULL;
+
   if (!gtk_file_system_get_parent (file_system, path, &parent_path, error))
     return NULL;
 
-  parent_folder = gtk_file_system_get_folder (file_system, parent_path,
+  parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
                                              GTK_FILE_INFO_DISPLAY_NAME
-#if 0
-                                             | GTK_FILE_INFO_ICON
-#endif
-                                             | GTK_FILE_INFO_IS_FOLDER,
+                                             | (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
                                              error);
-  gtk_file_path_free (parent_path);
-
   if (!parent_folder)
-    return NULL;
+    goto out;
 
-  info = gtk_file_folder_get_info (parent_folder, path, error);
+  info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, error);
   g_object_unref (parent_folder);
 
+ out:
+
+  gtk_file_path_free (parent_path);
   return info;
 }
 
@@ -674,30 +975,30 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
     {
       data = volume;
       label_copy = gtk_file_system_volume_get_display_name (impl->file_system, volume);
-      pixbuf = gtk_file_system_volume_render_icon (impl->file_system,
-                                                  volume,
-                                                  GTK_WIDGET (impl),
-                                                  ICON_SIZE,
-                                                  NULL);
+      pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
+                                                  impl->icon_size, NULL);
     }
   else
     {
-      GtkFileInfo *info;
-
-      info = get_file_info (impl->file_system, path, error);
-      if (!info)
+      if (!check_is_folder (impl->file_system, path, error))
        return FALSE;
 
-      data = gtk_file_path_copy (path);
-
       if (label)
        label_copy = g_strdup (label);
       else
-       label_copy = g_strdup (gtk_file_info_get_display_name (info));
+       {
+         GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
+
+         if (!info)
+           return FALSE;
 
-      pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
+         label_copy = g_strdup (gtk_file_info_get_display_name (info));
+         gtk_file_info_free (info);
+       }
 
-      gtk_file_info_free (info);
+      data = gtk_file_path_copy (path);
+      pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
+                                           impl->icon_size, NULL);
     }
 
   if (pos == -1)
@@ -751,7 +1052,7 @@ shortcuts_append_desktop (GtkFileChooserDefault *impl)
   path = gtk_file_system_filename_to_path (impl->file_system, name);
   g_free (name);
 
-  impl->has_desktop = shortcuts_insert_path (impl, -1, FALSE, NULL, path, NULL, FALSE, NULL);
+  impl->has_desktop = shortcuts_insert_path (impl, -1, FALSE, NULL, path, _("Desktop"), FALSE, NULL);
   /* We do not actually pop up an error dialog if there is no desktop directory
    * because some people may really not want to have one.
    */
@@ -764,8 +1065,12 @@ static int
 shortcuts_append_paths (GtkFileChooserDefault *impl,
                        GSList                *paths)
 {
+  int start_row;
   int num_inserted;
 
+  /* As there is no separator now, we want to start there.
+   */
+  start_row = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
   num_inserted = 0;
 
   for (; paths; paths = paths->next)
@@ -776,9 +1081,12 @@ shortcuts_append_paths (GtkFileChooserDefault *impl,
       path = paths->data;
       error = NULL;
 
-      /* NULL GError, but we don't really want to show error boxes here */
+      if (impl->local_only &&
+         !gtk_file_system_path_is_local (impl->file_system, path))
+       continue;
 
-      if (shortcuts_insert_path (impl, -1, FALSE, NULL, path, NULL, TRUE, NULL))
+      /* NULL GError, but we don't really want to show error boxes here */
+      if (shortcuts_insert_path (impl, start_row + num_inserted, FALSE, NULL, path, NULL, TRUE, NULL))
        num_inserted++;
     }
 
@@ -814,14 +1122,25 @@ shortcuts_get_index (GtkFileChooserDefault *impl,
 
   n += impl->num_shortcuts;
 
-  if (where == SHORTCUTS_SEPARATOR)
+  if (where == SHORTCUTS_BOOKMARKS_SEPARATOR)
     goto out;
 
-  n += 1;
+  /* If there are no bookmarks there won't be a separator */
+  n += (impl->num_bookmarks > 0) ? 1 : 0;
 
   if (where == SHORTCUTS_BOOKMARKS)
     goto out;
 
+  n += impl->num_bookmarks;
+
+  if (where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR)
+    goto out;
+
+  n += 1;
+
+  if (where == SHORTCUTS_CURRENT_FOLDER)
+    goto out;
+
   g_assert_not_reached ();
 
  out:
@@ -862,7 +1181,7 @@ shortcuts_remove_rows (GtkFileChooserDefault *impl,
   gtk_tree_path_free (path);
 }
 
-/* Used from shortcuts_remove_rows() */
+/* Used from shortcuts_remove_rows() in shortcuts_add_volumes() */
 static void
 volume_remove_cb (GtkFileChooserDefault *impl, gpointer data)
 {
@@ -879,6 +1198,10 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
   int start_row;
   GSList *list, *l;
   int n;
+  gboolean old_changing_folders;
+
+  old_changing_folders = impl->changing_folder;
+  impl->changing_folder = TRUE;
 
   start_row = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
   shortcuts_remove_rows (impl, start_row, impl->num_volumes, volume_remove_cb);
@@ -894,13 +1217,32 @@ shortcuts_add_volumes (GtkFileChooserDefault *impl)
 
       volume = l->data;
 
-      shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL);
-      n++;
+      if (impl->local_only)
+       {
+         GtkFilePath *base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+         gboolean is_local = gtk_file_system_path_is_local (impl->file_system, base_path);
+         gtk_file_path_free (base_path);
+
+         if (!is_local)
+           {
+             gtk_file_system_volume_free (impl->file_system, volume);
+             continue;
+           }
+       }
+
+      if (shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL))
+       n++;
+      else
+       gtk_file_system_volume_free (impl->file_system, volume);
     }
 
   impl->num_volumes = n;
-
   g_slist_free (list);
+
+  if (impl->shortcuts_filter_model)
+    gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
+
+  impl->changing_folder = old_changing_folders;
 }
 
 /* Used from shortcuts_remove_rows() */
@@ -913,86 +1255,221 @@ remove_bookmark_cb (GtkFileChooserDefault *impl, gpointer data)
   gtk_file_path_free (path);
 }
 
-/* Updates the list of bookmarks */
-static void
-shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
-{
-  GSList *bookmarks;
-
-  shortcuts_remove_rows (impl,
-                        shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS),
-                        impl->num_bookmarks,
-                        remove_bookmark_cb);
-
-  bookmarks = gtk_file_system_list_bookmarks (impl->file_system);
-  impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks);
-  gtk_file_paths_free (bookmarks);
-}
-
-/* Appends the bookmarks separator node and the bookmarks from the file system. */
+/* Inserts a separator node in the shortcuts list */
 static void
-shortcuts_append_bookmarks (GtkFileChooserDefault *impl)
+shortcuts_insert_separator (GtkFileChooserDefault *impl,
+                           ShortcutsIndex where)
 {
   GtkTreeIter iter;
 
-  gtk_list_store_append (impl->shortcuts_model, &iter);
+  g_assert (where == SHORTCUTS_BOOKMARKS_SEPARATOR || where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+
+  gtk_list_store_insert (impl->shortcuts_model, &iter,
+                        shortcuts_get_index (impl, where));
   gtk_list_store_set (impl->shortcuts_model, &iter,
                      SHORTCUTS_COL_PIXBUF, NULL,
                      SHORTCUTS_COL_PIXBUF_VISIBLE, FALSE,
                      SHORTCUTS_COL_NAME, NULL,
                      SHORTCUTS_COL_PATH, NULL,
                      -1);
-  shortcuts_add_bookmarks (impl);
 }
 
-/* Creates the GtkTreeStore used as the shortcuts model */
+/* Updates the list of bookmarks */
 static void
-create_shortcuts_model (GtkFileChooserDefault *impl)
+shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
 {
-  if (impl->shortcuts_model)
-    g_object_unref (impl->shortcuts_model);
+  GSList *bookmarks;
+  gboolean old_changing_folders;
 
-  /* Keep this order in sync with the SHORCUTS_COL_* enum values */
-  impl->shortcuts_model = gtk_list_store_new (SHORTCUTS_COL_NUM_COLUMNS,
-                                             GDK_TYPE_PIXBUF,  /* pixbuf */
-                                             G_TYPE_STRING,    /* name */
-                                             G_TYPE_POINTER,   /* path or volume */
-                                             G_TYPE_BOOLEAN,   /* removable */
-                                             G_TYPE_BOOLEAN);  /* pixbuf cell visibility */
+  old_changing_folders = impl->changing_folder;
+  impl->changing_folder = TRUE;
 
-  if (impl->file_system)
+  if (impl->num_bookmarks > 0)
     {
-      shortcuts_append_home (impl);
-      shortcuts_append_desktop (impl);
-      shortcuts_add_volumes (impl);
-      shortcuts_append_bookmarks (impl);
+      shortcuts_remove_rows (impl,
+                            shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR),
+                            impl->num_bookmarks + 1,
+                            remove_bookmark_cb);
+
     }
 
-  gtk_tree_view_set_model (GTK_TREE_VIEW (impl->shortcuts_tree), GTK_TREE_MODEL (impl->shortcuts_model));
+  bookmarks = gtk_file_system_list_bookmarks (impl->file_system);
+  impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks);
+  gtk_file_paths_free (bookmarks);
+
+  if (impl->num_bookmarks > 0)
+    {
+      shortcuts_insert_separator (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
+    }
+  if (impl->shortcuts_filter_model)
+    gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
+
+  impl->changing_folder = old_changing_folders;
 }
 
-/* Callback used when the "New Folder" toolbar button is clicked */
+/* Appends a separator and a row to the shortcuts list for the current folder */
 static void
-new_folder_button_clicked (GtkButton             *button,
-                          GtkFileChooserDefault *impl)
+shortcuts_add_current_folder (GtkFileChooserDefault *impl)
 {
-  GtkTreeIter iter;
-  GtkTreePath *path;
+  int pos;
+  gboolean success;
 
-  /* FIXME: this doesn't work for folder mode, just for file mode */
+  g_assert (!impl->shortcuts_current_folder_active);
 
-  _gtk_file_system_model_add_editable (impl->list_model, &iter);
-  g_object_set (impl->list_name_renderer, "editable", TRUE, NULL);
+  success = TRUE;
 
-  path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->list_model), &iter);
-  gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->list),
-                           path,
-                           impl->list_name_column,
-                           TRUE);
-}
+  pos = shortcut_find_position (impl, impl->current_folder);
+  if (pos == -1)
+    {
+      GtkFileSystemVolume *volume;
+      GtkFilePath *base_path;
 
-/* Callback used from the text cell renderer when the new folder is named */
-static void
+      /* Separator */
+
+      shortcuts_insert_separator (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+
+      /* Item */
+
+      pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER);
+
+      volume = gtk_file_system_get_volume_for_path (impl->file_system, impl->current_folder);
+      if (volume)
+       base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+      else
+       base_path = NULL;
+
+      if (base_path &&
+         strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0)
+       {
+         success = shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, NULL);
+         impl->shortcuts_current_folder_is_volume = TRUE;
+       }
+      else
+       {
+         success = shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL);
+         impl->shortcuts_current_folder_is_volume = FALSE;
+       }
+
+      if (volume)
+       gtk_file_system_volume_free (impl->file_system, volume);
+      gtk_file_path_free (base_path);
+
+      if (!success)
+       shortcuts_remove_rows (impl, pos - 1, 1, NULL); /* remove the separator */
+
+      impl->shortcuts_current_folder_active = success;
+    }
+
+  if (success)
+    gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos);
+}
+
+/* Used from shortcuts_remove_rows() in shortcuts_update_current_folder() */
+static void
+remove_current_folder_cb (GtkFileChooserDefault *impl,
+                         gpointer               data)
+{
+  if (impl->shortcuts_current_folder_is_volume)
+    gtk_file_system_volume_free (impl->file_system, data);
+  else
+    gtk_file_path_free (data);
+}
+
+/* Updates the current folder row in the shortcuts model */
+static void
+shortcuts_update_current_folder (GtkFileChooserDefault *impl)
+{
+  int pos;
+
+  pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+
+  if (impl->shortcuts_current_folder_active)
+    {
+      shortcuts_remove_rows (impl, pos, 2, remove_current_folder_cb);
+      impl->shortcuts_current_folder_active = FALSE;
+    }
+
+  shortcuts_add_current_folder (impl);
+}
+
+/* Filter function used for the shortcuts filter model */
+static gboolean
+shortcuts_filter_cb (GtkTreeModel          *model,
+                    GtkTreeIter           *iter,
+                    gpointer               data)
+{
+  GtkFileChooserDefault *impl;
+  GtkTreePath *path;
+  int pos;
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (data);
+
+  path = gtk_tree_model_get_path (model, iter);
+  if (!path)
+    return FALSE;
+
+  pos = *gtk_tree_path_get_indices (path);
+  gtk_tree_path_free (path);
+
+  return (pos < shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR));
+}
+
+/* Creates the list model for shortcuts */
+static void
+shortcuts_model_create (GtkFileChooserDefault *impl)
+{
+  /* Keep this order in sync with the SHORCUTS_COL_* enum values */
+  impl->shortcuts_model = gtk_list_store_new (SHORTCUTS_COL_NUM_COLUMNS,
+                                             GDK_TYPE_PIXBUF,  /* pixbuf */
+                                             G_TYPE_STRING,    /* name */
+                                             G_TYPE_POINTER,   /* path or volume */
+                                             G_TYPE_BOOLEAN,   /* removable */
+                                             G_TYPE_BOOLEAN);  /* pixbuf cell visibility */
+
+  if (impl->file_system)
+    {
+      shortcuts_append_home (impl);
+      shortcuts_append_desktop (impl);
+      shortcuts_add_volumes (impl);
+      shortcuts_add_bookmarks (impl);
+    }
+
+  impl->shortcuts_filter_model = shortcuts_model_filter_new (impl,
+                                                            GTK_TREE_MODEL (impl->shortcuts_model),
+                                                            NULL);
+
+  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
+                                         shortcuts_filter_cb,
+                                         impl,
+                                         NULL);
+}
+
+/* Callback used when the "New Folder" toolbar button is clicked */
+static void
+new_folder_button_clicked (GtkButton             *button,
+                          GtkFileChooserDefault *impl)
+{
+  GtkTreeIter iter;
+  GtkTreePath *path;
+
+  /* FIXME: this doesn't work for folder mode, just for file mode */
+
+  _gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
+
+  path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->browse_files_model), &iter);
+  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->browse_files_tree_view),
+                               path, impl->list_name_column,
+                               FALSE, 0.0, 0.0);
+
+  g_object_set (impl->list_name_renderer, "editable", TRUE, NULL);
+  gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view),
+                           path,
+                           impl->list_name_column,
+                           TRUE);
+}
+
+/* Callback used from the text cell renderer when the new folder is named */
+static void
 renderer_edited_cb (GtkCellRendererText   *cell_renderer_text,
                    const gchar           *path,
                    const gchar           *new_text,
@@ -1001,7 +1478,7 @@ renderer_edited_cb (GtkCellRendererText   *cell_renderer_text,
   GError *error;
   GtkFilePath *file_path;
 
-  _gtk_file_system_model_remove_editable (impl->list_model);
+  _gtk_file_system_model_remove_editable (impl->browse_files_model);
   g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
 
   error = NULL;
@@ -1014,9 +1491,11 @@ renderer_edited_cb (GtkCellRendererText   *cell_renderer_text,
 
   error = NULL;
   if (!gtk_file_system_create_folder (impl->file_system, file_path, &error))
-    error_dialog (impl,
-                 _("Could not create folder %s:\n%s"),
-                 file_path, error);
+    {
+      error_dialog (impl,
+                   _("Could not create folder %s:\n%s"),
+                   file_path, error);
+    }
 
   gtk_file_path_free (file_path);
 
@@ -1030,7 +1509,7 @@ static void
 renderer_editing_canceled_cb (GtkCellRendererText   *cell_renderer_text,
                              GtkFileChooserDefault *impl)
 {
-  _gtk_file_system_model_remove_editable (impl->list_model);
+  _gtk_file_system_model_remove_editable (impl->browse_files_model);
   g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
 }
 
@@ -1083,141 +1562,98 @@ button_new (GtkFileChooserDefault *impl,
   return button;
 }
 
-/* Creates the widgets for the folder tree */
-static GtkWidget *
-create_folder_tree (GtkFileChooserDefault *impl)
-{
-  GtkTreeSelection *selection;
-
-  /* Scrolled window */
-
-  impl->tree_scrollwin = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (impl->tree_scrollwin),
-                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (impl->tree_scrollwin),
-                                      GTK_SHADOW_IN);
-  if (impl->folder_mode)
-    gtk_widget_show (impl->tree_scrollwin);
-
-  /* Tree */
-
-  impl->tree = gtk_tree_view_new ();
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->tree), FALSE);
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree));
-  g_signal_connect (selection, "changed",
-                   G_CALLBACK (tree_selection_changed), impl);
-
-  gtk_container_add (GTK_CONTAINER (impl->tree_scrollwin), impl->tree);
-  gtk_widget_show (impl->tree);
-
-  /* Column */
-
-  gtk_tree_view_insert_column_with_data_func (GTK_TREE_VIEW (impl->tree), 0,
-                                             _("File name"),
-                                             gtk_cell_renderer_text_new (),
-                                             tree_name_data_func, impl, NULL);
-  gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->tree),
-                                  GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME);
-
-  return impl->tree_scrollwin;
-}
-
-/* Returns whether a path is already present in the shortcuts list */
-static gboolean
-shortcut_exists (GtkFileChooserDefault *impl,
-                const GtkFilePath     *path)
+/* Looks for a path among the shortcuts; returns its index or -1 if it doesn't exist */
+static int
+shortcut_find_position (GtkFileChooserDefault *impl,
+                       const GtkFilePath     *path)
 {
-  gboolean exists;
   GtkTreeIter iter;
+  int i;
+  int bookmarks_separator_idx;
+  int current_folder_separator_idx;
   int volumes_idx;
-  int separator_idx;
 
-  exists = FALSE;
+  if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+    return -1;
 
-  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
-    {
-      int i;
-
-      separator_idx = shortcuts_get_index (impl, SHORTCUTS_SEPARATOR);
-      volumes_idx = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
+  bookmarks_separator_idx = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
+  current_folder_separator_idx = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+  volumes_idx = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
 
-      i = 0;
+  i = 0;
 
-      do
-       {
-         gpointer data;
+  for (i = 0; i < current_folder_separator_idx; i++)
+    {
+      gpointer data;
 
-         if (i == separator_idx)
-           continue;
+      if (i == bookmarks_separator_idx)
+       goto next_iter;
 
-         gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &data, -1);
+      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &data, -1);
 
-         if (i >= volumes_idx && i < volumes_idx + impl->num_volumes)
-           {
-             GtkFileSystemVolume *volume;
-             GtkFilePath *base_path;
+      if (i >= volumes_idx && i < volumes_idx + impl->num_volumes)
+       {
+         GtkFileSystemVolume *volume;
+         GtkFilePath *base_path;
+         gboolean exists;
 
-             volume = data;
-             base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+         volume = data;
+         base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
 
-             exists = strcmp (gtk_file_path_get_string (path),
-                              gtk_file_path_get_string (base_path)) == 0;
-             g_free (base_path);
+         exists = strcmp (gtk_file_path_get_string (path),
+                          gtk_file_path_get_string (base_path)) == 0;
+         g_free (base_path);
 
-             if (exists)
-               break;
-           }
-         else
-           {
-             GtkFilePath *model_path;
+         if (exists)
+           return i;
+       }
+      else
+       {
+         GtkFilePath *model_path;
 
-             model_path = data;
+         model_path = data;
 
-             if (model_path && gtk_file_path_compare (model_path, path) == 0)
-               {
-                 exists = TRUE;
-                 break;
-               }
-           }
+         if (model_path && gtk_file_path_compare (model_path, path) == 0)
+           return i;
        }
-      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter));
+
+    next_iter:
+      gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
     }
 
-  return exists;
+  return -1;
 }
 
 /* Tries to add a bookmark from a path name */
-static void
+static gboolean
 shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
-                                 const GtkFilePath     *path)
+                                 const GtkFilePath     *path,
+                                 int                    pos)
 {
-  GtkFileInfo *info;
   GError *error;
 
-  if (shortcut_exists (impl, path))
-    return;
+  if (shortcut_find_position (impl, path) != -1)
+    return FALSE;
 
+  /* FIXME: this check really belongs in gtk_file_system_insert_bookmark.  */
   error = NULL;
-  info = get_file_info (impl->file_system, path, &error);
-
-  if (!info)
-    error_getting_info_dialog (impl, path, error);
-  else if (!gtk_file_info_get_is_folder (info))
+  if (!check_is_folder (impl->file_system, path, &error))
     {
-      char *msg;
-
-      msg = g_strdup_printf (_("Could not add bookmark for %s because it is not a folder."),
-                            gtk_file_path_get_string (path));
-      error_message (impl, msg);
-      g_free (msg);
+      error_dialog (impl,
+                   _("Could not add bookmark for %s because it is not a folder."),
+                   path,
+                   error);
+      return FALSE;
     }
-  else
+
+  error = NULL;
+  if (!gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
     {
-      error = NULL;
-      if (!gtk_file_system_add_bookmark (impl->file_system, path, &error))
-       error_could_not_add_bookmark_dialog (impl, path, error);
+      error_could_not_add_bookmark_dialog (impl, path, error);
+      return FALSE;
     }
+
+  return TRUE;
 }
 
 static void
@@ -1231,21 +1667,13 @@ add_bookmark_foreach_cb (GtkTreeModel *model,
   GtkTreeIter child_iter;
   const GtkFilePath *file_path;
 
-  impl = GTK_FILE_CHOOSER_DEFAULT (data);
+  impl = (GtkFileChooserDefault *) data;
 
-  if (impl->folder_mode)
-    {
-      fs_model = impl->tree_model;
-      child_iter = *iter;
-    }
-  else
-    {
-      fs_model = impl->list_model;
-      gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, iter);
-    }
+  fs_model = impl->browse_files_model;
+  gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, iter);
 
-  file_path = _gtk_file_system_model_get_path (fs_model, &child_iter);
-  shortcuts_add_bookmark_from_path (impl, file_path);
+  file_path = _gtk_file_system_model_get_path (GTK_FILE_SYSTEM_MODEL (fs_model), &child_iter);
+  shortcuts_add_bookmark_from_path (impl, file_path, -1);
 }
 
 /* Callback used when the "Add bookmark" button is clicked */
@@ -1253,17 +1681,12 @@ static void
 add_bookmark_button_clicked_cb (GtkButton *button,
                                GtkFileChooserDefault *impl)
 {
-  GtkWidget *tree_view;
   GtkTreeSelection *selection;
 
-  if (impl->folder_mode)
-    tree_view = impl->tree;
-  else
-    tree_view = impl->list;
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
   if (gtk_tree_selection_count_selected_rows (selection) == 0)
-    shortcuts_add_bookmark_from_path (impl, impl->current_folder);
+    shortcuts_add_bookmark_from_path (impl, impl->current_folder, -1);
   else
     gtk_tree_selection_selected_foreach (selection,
                                         add_bookmark_foreach_cb,
@@ -1281,11 +1704,11 @@ remove_bookmark_button_clicked_cb (GtkButton *button,
   gboolean removable;
   GError *error;
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->shortcuts_tree));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
   if (gtk_tree_selection_get_selected (selection, NULL, &iter))
     {
-      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+      gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
                          SHORTCUTS_COL_PATH, &path,
                          SHORTCUTS_COL_REMOVABLE, &removable, -1);
       if (!removable)
@@ -1296,55 +1719,95 @@ remove_bookmark_button_clicked_cb (GtkButton *button,
 
       error = NULL;
       if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
-       error_dialog (impl,
-                     _("Could not remove bookmark for %s:\n%s"),
-                     path,
-                     error);
+       {
+         error_dialog (impl,
+                       _("Could not remove bookmark for %s:\n%s"),
+                       path,
+                       error);
+       }
     }
 }
 
-struct is_folders_foreach_closure {
+struct selection_check_closure {
   GtkFileChooserDefault *impl;
+  gboolean empty;
+  gboolean all_files;
   gboolean all_folders;
 };
 
 /* Used from gtk_tree_selection_selected_foreach() */
 static void
-is_folders_foreach_cb (GtkTreeModel *model,
-                      GtkTreePath  *path,
-                      GtkTreeIter  *iter,
-                      gpointer      data)
+selection_check_foreach_cb (GtkTreeModel *model,
+                           GtkTreePath  *path,
+                           GtkTreeIter  *iter,
+                           gpointer      data)
 {
-  struct is_folders_foreach_closure *closure;
+  struct selection_check_closure *closure;
   GtkTreeIter child_iter;
   const GtkFileInfo *info;
+  gboolean is_folder;
 
   closure = data;
+  closure->empty = FALSE;
 
   gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
 
-  info = _gtk_file_system_model_get_info (closure->impl->list_model, &child_iter);
-  closure->all_folders &= gtk_file_info_get_is_folder (info);
+  info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
+  is_folder = gtk_file_info_get_is_folder (info);
+
+  closure->all_folders &= is_folder;
+  closure->all_files &= !is_folder;
 }
 
-/* Returns whether the selected items in the file list are all folders */
-static gboolean
-selection_is_folders (GtkFileChooserDefault *impl)
+/* Checks whether the selected items in the file list are all files or all folders */
+static void
+selection_check (GtkFileChooserDefault *impl,
+                gboolean              *empty,
+                gboolean              *all_files,
+                gboolean              *all_folders)
 {
-  struct is_folders_foreach_closure closure;
+  struct selection_check_closure closure;
   GtkTreeSelection *selection;
 
-  g_assert (!impl->folder_mode);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
 
-  closure.impl = impl;
-  closure.all_folders = TRUE;
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
+      || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    {
+      if (gtk_tree_selection_count_selected_rows (selection) == 0)
+       closure.empty = TRUE;
+      else
+       {
+         closure.empty = FALSE;
+         closure.all_files = FALSE;
+         closure.all_folders = TRUE;
+       }
+    }
+  else
+    {
+      g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+               || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE);
+
+      closure.impl = impl;
+      closure.empty = TRUE;
+      closure.all_files = TRUE;
+      closure.all_folders = TRUE;
+
+      gtk_tree_selection_selected_foreach (selection,
+                                          selection_check_foreach_cb,
+                                          &closure);
+    }
+
+  g_assert (closure.empty || !(closure.all_files && closure.all_folders));
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
-  gtk_tree_selection_selected_foreach (selection,
-                                      is_folders_foreach_cb,
-                                      &closure);
+  if (empty)
+    *empty = closure.empty;
 
-  return closure.all_folders;
+  if (all_files)
+    *all_files = closure.all_files;
+
+  if (all_folders)
+    *all_folders = closure.all_folders;
 }
 
 /* Sensitize the "add bookmark" button if all the selected items are folders, or
@@ -1354,25 +1817,26 @@ selection_is_folders (GtkFileChooserDefault *impl)
 static void
 bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
 {
-  GtkWidget *tree_view;
   GtkTreeSelection *selection;
   gboolean active;
 
   /* Check selection */
 
-  if (impl->folder_mode)
-    tree_view = impl->tree;
-  else
-    tree_view = impl->list;
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
 
   if (gtk_tree_selection_count_selected_rows (selection) == 0)
-    active = !shortcut_exists (impl, impl->current_folder);
+    active = (shortcut_find_position (impl, impl->current_folder) == -1);
   else
-    active = (impl->folder_mode || selection_is_folders (impl));
+    {
+      gboolean all_folders;
+
+      selection_check (impl, NULL, NULL, &all_folders);
+      active = (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+               impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER ||
+               all_folders);
+    }
 
-  gtk_widget_set_sensitive (impl->add_bookmark_button, active);
+  gtk_widget_set_sensitive (impl->browse_shortcuts_add_button, active);
 }
 
 /* Sets the sensitivity of the "remove bookmark" button depending on whether a
@@ -1385,14 +1849,386 @@ bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
   GtkTreeIter iter;
   gboolean removable = FALSE;
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->shortcuts_tree));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
 
   if (gtk_tree_selection_get_selected (selection, NULL, &iter))
-    gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+    gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
                        SHORTCUTS_COL_REMOVABLE, &removable,
                        -1);
 
-  gtk_widget_set_sensitive (impl->remove_bookmark_button, removable);
+  gtk_widget_set_sensitive (impl->browse_shortcuts_remove_button, removable);
+}
+
+/* GtkWidget::drag-begin handler for the shortcuts list. */
+static void
+shortcuts_drag_begin_cb (GtkWidget             *widget,
+                        GdkDragContext        *context,
+                        GtkFileChooserDefault *impl)
+{
+#if 0
+  impl->shortcuts_drag_context = g_object_ref (context);
+#endif
+}
+
+#if 0
+/* Removes the idle handler for outside drags */
+static void
+shortcuts_cancel_drag_outside_idle (GtkFileChooserDefault *impl)
+{
+  if (!impl->shortcuts_drag_outside_idle)
+    return;
+
+  g_source_destroy (impl->shortcuts_drag_outside_idle);
+  impl->shortcuts_drag_outside_idle = NULL;
+}
+#endif
+
+/* GtkWidget::drag-end handler for the shortcuts list. */
+static void
+shortcuts_drag_end_cb (GtkWidget             *widget,
+                      GdkDragContext        *context,
+                      GtkFileChooserDefault *impl)
+{
+#if 0
+  g_object_unref (impl->shortcuts_drag_context);
+
+  shortcuts_cancel_drag_outside_idle (impl);
+
+  if (!impl->shortcuts_drag_outside)
+    return;
+
+  gtk_button_clicked (GTK_BUTTON (impl->browse_shortcuts_remove_button));
+
+  impl->shortcuts_drag_outside = FALSE;
+#endif
+}
+
+/* GtkWidget::drag-data-delete handler for the shortcuts list. */
+static void
+shortcuts_drag_data_delete_cb (GtkWidget             *widget,
+                              GdkDragContext        *context,
+                              GtkFileChooserDefault *impl)
+{
+  g_signal_stop_emission_by_name (widget, "drag-data-delete");
+}
+
+#if 0
+/* Creates a suitable drag cursor to indicate that the selected bookmark will be
+ * deleted or not.
+ */
+static void
+shortcuts_drag_set_delete_cursor (GtkFileChooserDefault *impl,
+                                 gboolean               delete)
+{
+  GtkTreeView *tree_view;
+  GtkTreeSelection *selection;
+  GtkTreeIter iter, child_iter;
+  GtkTreePath *path;
+  GdkPixmap *row_pixmap;
+  GdkBitmap *mask;
+  int row_pixmap_y;
+  int cell_y;
+
+  tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
+
+  /* Find the selected path and get its drag pixmap */
+
+  selection = gtk_tree_view_get_selection (tree_view);
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+    g_assert_not_reached ();
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
+                                                   &child_iter,
+                                                   &iter);
+
+  path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &child_iter);
+
+  row_pixmap = gtk_tree_view_create_row_drag_icon (tree_view, path);
+  gtk_tree_path_free (path);
+
+  mask = NULL;
+  row_pixmap_y = 0;
+
+  if (delete)
+    {
+      GdkPixbuf *pixbuf;
+
+      pixbuf = gtk_widget_render_icon (impl->browse_shortcuts_tree_view,
+                                      GTK_STOCK_DELETE,
+                                      GTK_ICON_SIZE_DND,
+                                      NULL);
+      if (pixbuf)
+       {
+         GdkPixmap *composite;
+         int row_pixmap_width, row_pixmap_height;
+         int pixbuf_width, pixbuf_height;
+         int composite_width, composite_height;
+         int pixbuf_x, pixbuf_y;
+         GdkGC *gc, *mask_gc;
+         GdkColor color;
+         GdkBitmap *pixbuf_mask;
+
+         /* Create pixmap and mask for composite image */
+
+         gdk_drawable_get_size (row_pixmap, &row_pixmap_width, &row_pixmap_height);
+         pixbuf_width = gdk_pixbuf_get_width (pixbuf);
+         pixbuf_height = gdk_pixbuf_get_height (pixbuf);
+
+         composite_width = MAX (row_pixmap_width, pixbuf_width);
+         composite_height = MAX (row_pixmap_height, pixbuf_height);
+
+         row_pixmap_y = (composite_height - row_pixmap_height) / 2;
+
+         if (gtk_widget_get_direction (impl->browse_shortcuts_tree_view) == GTK_TEXT_DIR_RTL)
+           pixbuf_x = 0;
+         else
+           pixbuf_x = composite_width - pixbuf_width;
+
+         pixbuf_y = (composite_height - pixbuf_height) / 2;
+
+         composite = gdk_pixmap_new (row_pixmap, composite_width, composite_height, -1);
+         gc = gdk_gc_new (composite);
+
+         mask = gdk_pixmap_new (row_pixmap, composite_width, composite_height, 1);
+         mask_gc = gdk_gc_new (mask);
+         color.pixel = 0;
+         gdk_gc_set_foreground (mask_gc, &color);
+         gdk_draw_rectangle (mask, mask_gc, TRUE, 0, 0, composite_width, composite_height);
+
+         color.red = 0xffff;
+         color.green = 0xffff;
+         color.blue = 0xffff;
+         gdk_gc_set_rgb_fg_color (gc, &color);
+         gdk_draw_rectangle (composite, gc, TRUE, 0, 0, composite_width, composite_height);
+
+         /* Composite the row pixmap and the pixbuf */
+
+         gdk_pixbuf_render_pixmap_and_mask_for_colormap
+           (pixbuf,
+            gtk_widget_get_colormap (impl->browse_shortcuts_tree_view),
+            NULL, &pixbuf_mask, 128);
+         gdk_draw_drawable (mask, mask_gc, pixbuf_mask,
+                            0, 0,
+                            pixbuf_x, pixbuf_y,
+                            pixbuf_width, pixbuf_height);
+         g_object_unref (pixbuf_mask);
+
+         gdk_draw_drawable (composite, gc, row_pixmap,
+                            0, 0,
+                            0, row_pixmap_y,
+                            row_pixmap_width, row_pixmap_height);
+         color.pixel = 1;
+         gdk_gc_set_foreground (mask_gc, &color);
+         gdk_draw_rectangle (mask, mask_gc, TRUE, 0, row_pixmap_y, row_pixmap_width, row_pixmap_height);
+
+         gdk_draw_pixbuf (composite, gc, pixbuf,
+                          0, 0,
+                          pixbuf_x, pixbuf_y,
+                          pixbuf_width, pixbuf_height,
+                          GDK_RGB_DITHER_MAX,
+                          0, 0);
+
+         g_object_unref (pixbuf);
+         g_object_unref (row_pixmap);
+
+         row_pixmap = composite;
+       }
+    }
+
+  /* The hotspot offsets here are copied from gtk_tree_view_drag_begin(), ugh */
+
+  gtk_tree_view_get_path_at_pos (tree_view,
+                                 tree_view->priv->press_start_x,
+                                 tree_view->priv->press_start_y,
+                                 NULL,
+                                 NULL,
+                                 NULL,
+                                 &cell_y);
+
+  gtk_drag_set_icon_pixmap (impl->shortcuts_drag_context,
+                           gdk_drawable_get_colormap (row_pixmap),
+                           row_pixmap,
+                           mask,
+                           tree_view->priv->press_start_x + 1,
+                           row_pixmap_y + cell_y + 1);
+
+  g_object_unref (row_pixmap);
+  if (mask)
+    g_object_unref (mask);
+}
+
+/* We set the delete cursor and the shortcuts_drag_outside flag in an idle
+ * handler so that we can tell apart the drag_leave event that comes right
+ * before a drag_drop, from a normal drag_leave.  We don't want to set the
+ * cursor nor the flag in the latter case.
+ */
+static gboolean
+shortcuts_drag_outside_idle_cb (GtkFileChooserDefault *impl)
+{
+  shortcuts_drag_set_delete_cursor (impl, TRUE);
+  impl->shortcuts_drag_outside = TRUE;
+
+  shortcuts_cancel_drag_outside_idle (impl);
+  return FALSE;
+}
+#endif
+
+/* GtkWidget::drag-leave handler for the shortcuts list.  We unhighlight the
+ * drop position.
+ */
+static void
+shortcuts_drag_leave_cb (GtkWidget             *widget,
+                        GdkDragContext        *context,
+                        guint                  time_,
+                        GtkFileChooserDefault *impl)
+{
+#if 0
+  if (gtk_drag_get_source_widget (context) == widget && !impl->shortcuts_drag_outside_idle)
+    {
+      impl->shortcuts_drag_outside_idle = g_idle_source_new ();
+      g_source_set_closure (impl->shortcuts_drag_outside_idle,
+                           g_cclosure_new_object (G_CALLBACK (shortcuts_drag_outside_idle_cb),
+                                                  G_OBJECT (impl)));
+      g_source_attach (impl->shortcuts_drag_outside_idle, NULL);
+    }
+#endif
+
+  gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
+                                  NULL,
+                                  GTK_TREE_VIEW_DROP_BEFORE);
+
+  g_signal_stop_emission_by_name (widget, "drag-leave");
+}
+
+/* Computes the appropriate row and position for dropping */
+static void
+shortcuts_compute_drop_position (GtkFileChooserDefault   *impl,
+                                int                      x,
+                                int                      y,
+                                GtkTreePath            **path,
+                                GtkTreeViewDropPosition *pos)
+{
+  GtkTreeView *tree_view;
+  GtkTreeViewColumn *column;
+  int cell_y;
+  GdkRectangle cell;
+  int row;
+  int bookmarks_index;
+
+  tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
+
+  bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
+
+  if (!gtk_tree_view_get_path_at_pos (tree_view,
+                                      x,
+                                     y - TREE_VIEW_HEADER_HEIGHT (tree_view),
+                                      path,
+                                      &column,
+                                      NULL,
+                                      &cell_y))
+    {
+      row = bookmarks_index + impl->num_bookmarks - 1;
+      *path = gtk_tree_path_new_from_indices (row, -1);
+      *pos = GTK_TREE_VIEW_DROP_AFTER;
+      return;
+    }
+
+  row = *gtk_tree_path_get_indices (*path);
+  gtk_tree_view_get_background_area (tree_view, *path, column, &cell);
+  gtk_tree_path_free (*path);
+
+  if (row < bookmarks_index)
+    {
+      row = bookmarks_index;
+      *pos = GTK_TREE_VIEW_DROP_BEFORE;
+    }
+  else if (row > bookmarks_index + impl->num_bookmarks - 1)
+    {
+      row = bookmarks_index + impl->num_bookmarks - 1;
+      *pos = GTK_TREE_VIEW_DROP_AFTER;
+    }
+  else
+    {
+      if (cell_y < cell.height / 2)
+       *pos = GTK_TREE_VIEW_DROP_BEFORE;
+      else
+       *pos = GTK_TREE_VIEW_DROP_AFTER;
+    }
+
+  *path = gtk_tree_path_new_from_indices (row, -1);
+}
+
+/* GtkWidget::drag-motion handler for the shortcuts list.  We basically
+ * implement the destination side of DnD by hand, due to limitations in
+ * GtkTreeView's DnD API.
+ */
+static gboolean
+shortcuts_drag_motion_cb (GtkWidget             *widget,
+                         GdkDragContext        *context,
+                         gint                   x,
+                         gint                   y,
+                         guint                  time_,
+                         GtkFileChooserDefault *impl)
+{
+  GtkTreePath *path;
+  GtkTreeViewDropPosition pos;
+  GdkDragAction action;
+
+#if 0
+  if (gtk_drag_get_source_widget (context) == widget)
+    {
+      shortcuts_cancel_drag_outside_idle (impl);
+
+      if (impl->shortcuts_drag_outside)
+       {
+         shortcuts_drag_set_delete_cursor (impl, FALSE);
+         impl->shortcuts_drag_outside = FALSE;
+       }
+    }
+#endif
+
+  if (context->suggested_action == GDK_ACTION_COPY || (context->actions & GDK_ACTION_COPY) != 0)
+    action = GDK_ACTION_COPY;
+  else if (context->suggested_action == GDK_ACTION_MOVE || (context->actions & GDK_ACTION_MOVE) != 0)
+    action = GDK_ACTION_MOVE;
+  else
+    {
+      action = 0;
+      goto out;
+    }
+
+  shortcuts_compute_drop_position (impl, x, y, &path, &pos);
+  gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), path, pos);
+  gtk_tree_path_free (path);
+
+ out:
+
+  g_signal_stop_emission_by_name (widget, "drag-motion");
+
+  if (action != 0)
+    {
+      gdk_drag_status (context, action, time_);
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
+
+/* GtkWidget::drag-drop handler for the shortcuts list. */
+static gboolean
+shortcuts_drag_drop_cb (GtkWidget             *widget,
+                       GdkDragContext        *context,
+                       gint                   x,
+                       gint                   y,
+                       guint                  time_,
+                       GtkFileChooserDefault *impl)
+{
+#if 0
+  shortcuts_cancel_drag_outside_idle (impl);
+#endif
+
+  g_signal_stop_emission_by_name (widget, "drag-drop");
+  return TRUE;
 }
 
 /* Converts raw selection data from text/uri-list to a list of strings */
@@ -1422,25 +2258,15 @@ split_uris (const char *data)
   return uris;
 }
 
-/* Callback used when we get the drag data for the bookmarks list.  We add the
- * received URIs as bookmarks if they are folders.
- */
+/* Parses a "text/uri-list" string and inserts its URIs as bookmarks */
 static void
-shortcuts_drag_data_received_cb (GtkWidget          *widget,
-                                GdkDragContext     *context,
-                                gint                x,
-                                gint                y,
-                                GtkSelectionData   *selection_data,
-                                guint               info,
-                                guint               time_,
-                                gpointer            data)
+shortcuts_drop_uris (GtkFileChooserDefault *impl,
+                    const char            *data,
+                    int                    position)
 {
-  GtkFileChooserDefault *impl;
   GSList *uris, *l;
 
-  impl = GTK_FILE_CHOOSER_DEFAULT (data);
-
-  uris = split_uris (selection_data->data);
+  uris = split_uris (data);
 
   for (l = uris; l; l = l->next)
     {
@@ -1452,7 +2278,9 @@ shortcuts_drag_data_received_cb (GtkWidget          *widget,
 
       if (path)
        {
-         shortcuts_add_bookmark_from_path (impl, path);
+         if (shortcuts_add_bookmark_from_path (impl, path, position))
+           position++;
+
          gtk_file_path_free (path);
        }
       else
@@ -1468,7 +2296,104 @@ shortcuts_drag_data_received_cb (GtkWidget          *widget,
       g_free (uri);
     }
 
-  g_slist_free (uris);
+  g_slist_free (uris);
+}
+
+/* Reorders the selected bookmark to the specified position */
+static void
+shortcuts_reorder (GtkFileChooserDefault *impl,
+                  int                    new_position)
+{
+  GtkTreeSelection *selection;
+  GtkTreeIter iter, child_iter;
+  GtkTreePath *path;
+  int old_position;
+  int bookmarks_index;
+  const GtkFilePath *file_path;
+  GtkFilePath *file_path_copy;
+  GError *error;
+
+  /* Get the selected path */
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+    g_assert_not_reached ();
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
+                                                   &child_iter,
+                                                   &iter);
+
+  path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &child_iter);
+  old_position = *gtk_tree_path_get_indices (path);
+  gtk_tree_path_free (path);
+
+  bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
+  old_position -= bookmarks_index;
+  g_assert (old_position >= 0 && old_position < impl->num_bookmarks);
+
+  gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &child_iter,
+                     SHORTCUTS_COL_PATH, &file_path,
+                     -1);
+  file_path_copy = gtk_file_path_copy (file_path); /* removal below will free file_path, so we need a copy */
+
+  /* Remove the path from the old position and insert it in the new one */
+
+  if (new_position > old_position)
+    new_position--;
+
+  if (old_position == new_position)
+    return;
+
+  error = NULL;
+  if (gtk_file_system_remove_bookmark (impl->file_system, file_path_copy, &error))
+    shortcuts_add_bookmark_from_path (impl, file_path_copy, new_position);
+  else
+    error_could_not_add_bookmark_dialog (impl, file_path_copy, error);
+
+  gtk_file_path_free (file_path_copy);
+}
+
+/* Callback used when we get the drag data for the bookmarks list.  We add the
+ * received URIs as bookmarks if they are folders.
+ */
+static void
+shortcuts_drag_data_received_cb (GtkWidget          *widget,
+                                GdkDragContext     *context,
+                                gint                x,
+                                gint                y,
+                                GtkSelectionData   *selection_data,
+                                guint               info,
+                                guint               time_,
+                                gpointer            data)
+{
+  GtkFileChooserDefault *impl;
+  GtkTreePath *tree_path;
+  GtkTreeViewDropPosition tree_pos;
+  int position;
+  int bookmarks_index;
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (data);
+
+  /* Compute position */
+
+  bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
+
+  shortcuts_compute_drop_position (impl, x, y, &tree_path, &tree_pos);
+  position = *gtk_tree_path_get_indices (tree_path);
+  gtk_tree_path_free (tree_path);
+
+  if (tree_pos == GTK_TREE_VIEW_DROP_AFTER)
+    position++;
+
+  g_assert (position >= bookmarks_index);
+  position -= bookmarks_index;
+
+  if (selection_data->target == gdk_atom_intern ("text/uri-list", FALSE))
+    shortcuts_drop_uris (impl, selection_data->data, position);
+  else if (selection_data->target == gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
+    shortcuts_reorder (impl, position);
+
+  g_signal_stop_emission_by_name (widget, "drag-data-received");
 }
 
 /* Callback used when the selection in the shortcuts tree changes */
@@ -1481,33 +2406,42 @@ shortcuts_selection_changed_cb (GtkTreeSelection      *selection,
 
 /* Creates the widgets for the shortcuts and bookmarks tree */
 static GtkWidget *
-shortcuts_tree_create (GtkFileChooserDefault *impl)
+shortcuts_list_create (GtkFileChooserDefault *impl)
 {
+  GtkWidget *swin;
   GtkTreeSelection *selection;
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
 
   /* Scrolled window */
 
-  impl->shortcuts_scrollwin = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (impl->shortcuts_scrollwin),
+  swin = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (impl->shortcuts_scrollwin),
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
                                       GTK_SHADOW_IN);
-  gtk_widget_show (impl->shortcuts_scrollwin);
+  gtk_widget_show (swin);
 
   /* Tree */
 
-  impl->shortcuts_tree = gtk_tree_view_new ();
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->shortcuts_tree), FALSE);
-  
-  gtk_drag_dest_set (impl->shortcuts_tree,
+  impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE);
+
+  gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), impl->shortcuts_filter_model);
+
+  gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
+                                         GDK_BUTTON1_MASK,
+                                         shortcuts_source_targets,
+                                         num_shortcuts_source_targets,
+                                         GDK_ACTION_MOVE);
+
+  gtk_drag_dest_set (impl->browse_shortcuts_tree_view,
                     GTK_DEST_DEFAULT_ALL,
-                    shortcuts_targets,
-                    num_shortcuts_targets,
-                    GDK_ACTION_COPY);
+                    shortcuts_dest_targets,
+                    num_shortcuts_dest_targets,
+                    GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->shortcuts_tree));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
   gtk_tree_selection_set_select_function (selection,
                                          shortcuts_select_func,
@@ -1516,18 +2450,27 @@ shortcuts_tree_create (GtkFileChooserDefault *impl)
   g_signal_connect (selection, "changed",
                    G_CALLBACK (shortcuts_selection_changed_cb), impl);
 
-  g_signal_connect (impl->shortcuts_tree, "row-activated",
+  g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
                    G_CALLBACK (shortcuts_row_activated_cb), impl);
 
-  g_signal_connect (impl->shortcuts_tree, "drag-data-received",
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin",
+                   G_CALLBACK (shortcuts_drag_begin_cb), impl);
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end",
+                   G_CALLBACK (shortcuts_drag_end_cb), impl);
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-delete",
+                   G_CALLBACK (shortcuts_drag_data_delete_cb), impl);
+
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-leave",
+                   G_CALLBACK (shortcuts_drag_leave_cb), impl);
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-motion",
+                   G_CALLBACK (shortcuts_drag_motion_cb), impl);
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-drop",
+                   G_CALLBACK (shortcuts_drag_drop_cb), impl);
+  g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-received",
                    G_CALLBACK (shortcuts_drag_data_received_cb), impl);
 
-  gtk_container_add (GTK_CONTAINER (impl->shortcuts_scrollwin), impl->shortcuts_tree);
-  gtk_widget_show (impl->shortcuts_tree);
-
-  /* Model */
-
-  create_shortcuts_model (impl);
+  gtk_container_add (GTK_CONTAINER (swin), impl->browse_shortcuts_tree_view);
+  gtk_widget_show (impl->browse_shortcuts_tree_view);
 
   /* Column */
 
@@ -1547,9 +2490,9 @@ shortcuts_tree_create (GtkFileChooserDefault *impl)
                                       "text", SHORTCUTS_COL_NAME,
                                       NULL);
 
-  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->shortcuts_tree), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), column);
 
-  return impl->shortcuts_scrollwin;
+  return swin;
 }
 
 /* Creates the widgets for the shortcuts/bookmarks pane */
@@ -1566,7 +2509,7 @@ shortcuts_pane_create (GtkFileChooserDefault *impl,
 
   /* Shortcuts tree */
 
-  widget = shortcuts_tree_create (impl);
+  widget = shortcuts_list_create (impl);
   gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
 
   /* Box for buttons */
@@ -1578,55 +2521,96 @@ shortcuts_pane_create (GtkFileChooserDefault *impl,
 
   /* Add bookmark button */
 
-  impl->add_bookmark_button = button_new (impl,
-                                         _("_Add"),
-                                         GTK_STOCK_ADD,
-                                         FALSE,
-                                         TRUE,
-                                         G_CALLBACK (add_bookmark_button_clicked_cb));
-  gtk_box_pack_start (GTK_BOX (hbox), impl->add_bookmark_button, TRUE, TRUE, 0);
+  impl->browse_shortcuts_add_button = button_new (impl,
+                                                 _("_Add"),
+                                                 GTK_STOCK_ADD,
+                                                 FALSE,
+                                                 TRUE,
+                                                 G_CALLBACK (add_bookmark_button_clicked_cb));
+  gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_add_button, TRUE, TRUE, 0);
 
   /* Remove bookmark button */
 
-  impl->remove_bookmark_button = button_new (impl,
-                                            _("_Remove"),
-                                            GTK_STOCK_REMOVE,
-                                            FALSE,
-                                            TRUE,
-                                            G_CALLBACK (remove_bookmark_button_clicked_cb));
-  gtk_box_pack_start (GTK_BOX (hbox), impl->remove_bookmark_button, TRUE, TRUE, 0);
+  impl->browse_shortcuts_remove_button = button_new (impl,
+                                                    _("_Remove"),
+                                                    GTK_STOCK_REMOVE,
+                                                    FALSE,
+                                                    TRUE,
+                                                    G_CALLBACK (remove_bookmark_button_clicked_cb));
+  gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_remove_button, TRUE, TRUE, 0);
 
   return vbox;
 }
 
+static gboolean
+trap_activate_cb (GtkWidget   *widget,
+                 GdkEventKey *event,
+                 gpointer     data)
+{
+  GtkFileChooserDefault *impl;
+
+  impl = (GtkFileChooserDefault *) data;
+
+  if (event->keyval == GDK_Return
+      || event->keyval == GDK_ISO_Enter
+      || event->keyval == GDK_KP_Enter
+      || event->keyval == GDK_space)
+    {
+      GtkWidget *toplevel;
+
+      toplevel = gtk_widget_get_toplevel (widget);
+      if (GTK_IS_WINDOW (toplevel))
+       {
+         GtkWindow *window;
+
+         window = GTK_WINDOW (toplevel);
+
+         if (window &&
+             widget != window->default_widget &&
+             !(widget == window->focus_widget &&
+               (!window->default_widget || !GTK_WIDGET_SENSITIVE (window->default_widget))))
+           gtk_window_activate_default (window);
+       }
+      return TRUE;
+    }
+  return FALSE;
+}
+
+
 /* Creates the widgets for the file list */
 static GtkWidget *
 create_file_list (GtkFileChooserDefault *impl)
 {
+  GtkWidget *swin;
   GtkTreeSelection *selection;
   GtkTreeViewColumn *column;
   GtkCellRenderer *renderer;
 
   /* Scrolled window */
 
-  impl->list_scrollwin = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (impl->list_scrollwin),
+  swin = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (impl->list_scrollwin),
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
                                       GTK_SHADOW_IN);
-  if (!impl->folder_mode)
-    gtk_widget_show (impl->list_scrollwin);
 
   /* Tree/list view */
 
-  impl->list = gtk_tree_view_new ();
-  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (impl->list), TRUE);
-  gtk_container_add (GTK_CONTAINER (impl->list_scrollwin), impl->list);
-  g_signal_connect (impl->list, "row_activated",
+  impl->browse_files_tree_view = gtk_tree_view_new ();
+  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (impl->browse_files_tree_view), TRUE);
+  gtk_container_add (GTK_CONTAINER (swin), impl->browse_files_tree_view);
+  g_signal_connect (impl->browse_files_tree_view, "row-activated",
                    G_CALLBACK (list_row_activated), impl);
-  gtk_widget_show (impl->list);
+  g_signal_connect (impl->browse_files_tree_view, "key-press-event",
+                   G_CALLBACK (trap_activate_cb), impl);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+  gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_files_tree_view),
+                                         GDK_BUTTON1_MASK,
+                                         file_list_source_targets,
+                                         num_file_list_source_targets,
+                                         GDK_ACTION_COPY);
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
   g_signal_connect (selection, "changed",
                    G_CALLBACK (list_selection_changed), impl);
 
@@ -1634,7 +2618,7 @@ create_file_list (GtkFileChooserDefault *impl)
 
   impl->list_name_column = gtk_tree_view_column_new ();
   gtk_tree_view_column_set_expand (impl->list_name_column, TRUE);
-  gtk_tree_view_column_set_title (impl->list_name_column, _("File name"));
+  gtk_tree_view_column_set_title (impl->list_name_column, _("Name"));
   gtk_tree_view_column_set_sort_column_id (impl->list_name_column, FILE_LIST_COL_NAME);
 
   renderer = gtk_cell_renderer_pixbuf_new ();
@@ -1651,7 +2635,7 @@ create_file_list (GtkFileChooserDefault *impl)
   gtk_tree_view_column_set_cell_data_func (impl->list_name_column, impl->list_name_renderer,
                                           list_name_data_func, impl, NULL);
 
-  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->list), impl->list_name_column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), impl->list_name_column);
 #if 0
   /* Size column */
 
@@ -1663,7 +2647,7 @@ create_file_list (GtkFileChooserDefault *impl)
   gtk_tree_view_column_set_cell_data_func (column, renderer,
                                           list_size_data_func, impl, NULL);
   gtk_tree_view_column_set_sort_column_id (column, FILE_LIST_COL_SIZE);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
 #endif
   /* Modification time column */
 
@@ -1675,9 +2659,10 @@ create_file_list (GtkFileChooserDefault *impl)
   gtk_tree_view_column_set_cell_data_func (column, renderer,
                                           list_mtime_data_func, impl, NULL);
   gtk_tree_view_column_set_sort_column_id (column, FILE_LIST_COL_MTIME);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->list), column);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_files_tree_view), column);
+  gtk_widget_show_all (swin);
 
-  return impl->list_scrollwin;
+  return swin;
 }
 
 static GtkWidget *
@@ -1697,6 +2682,17 @@ create_filename_entry_and_filter_combo (GtkFileChooserDefault *impl)
   return hbox;
 }
 
+static GtkWidget *
+create_path_bar (GtkFileChooserDefault *impl)
+{
+  GtkWidget *path_bar;
+
+  path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
+  _gtk_path_bar_set_file_system (GTK_PATH_BAR (path_bar), impl->file_system);
+
+  return path_bar;
+}
+
 /* Creates the widgets for the files/folders pane */
 static GtkWidget *
 file_pane_create (GtkFileChooserDefault *impl,
@@ -1712,33 +2708,24 @@ file_pane_create (GtkFileChooserDefault *impl,
   /* The path bar and 'Create Folder' button */
   hbox = gtk_hbox_new (FALSE, 12);
   gtk_widget_show (hbox);
-  impl->path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
-  g_signal_connect (impl->path_bar, "path_clicked", G_CALLBACK (path_bar_clicked), impl);
-  gtk_widget_show_all (impl->path_bar);
-  gtk_box_pack_start (GTK_BOX (hbox), impl->path_bar, TRUE, TRUE, 0);
+  impl->browse_path_bar = create_path_bar (impl);
+  g_signal_connect (impl->browse_path_bar, "path-clicked", G_CALLBACK (path_bar_clicked), impl);
+  gtk_widget_show_all (impl->browse_path_bar);
+  gtk_box_pack_start (GTK_BOX (hbox), impl->browse_path_bar, TRUE, TRUE, 0);
 
   /* Create Folder */
-  impl->new_folder_button = gtk_button_new_with_mnemonic (_("Create _Folder"));
-  g_signal_connect (impl->new_folder_button, "clicked",
+  impl->browse_new_folder_button = gtk_button_new_with_mnemonic (_("Create _Folder"));
+  g_signal_connect (impl->browse_new_folder_button, "clicked",
                    G_CALLBACK (new_folder_button_clicked), impl);
-  gtk_box_pack_end (GTK_BOX (hbox), impl->new_folder_button, FALSE, FALSE, 0);
-
-  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
-      impl->folder_mode)
-    gtk_widget_show (impl->new_folder_button);
+  gtk_box_pack_end (GTK_BOX (hbox), impl->browse_new_folder_button, FALSE, FALSE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
   /* Box for lists and preview */
 
-  hbox = gtk_hbox_new (FALSE, 12);
+  hbox = gtk_hbox_new (FALSE, PREVIEW_HBOX_SPACING);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
   gtk_widget_show (hbox);
 
-  /* Folder tree */
-
-  widget = create_folder_tree (impl);
-  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
-
   /* File list */
 
   widget = create_file_list (impl);
@@ -1746,9 +2733,9 @@ file_pane_create (GtkFileChooserDefault *impl,
 
   /* Preview */
 
-  impl->preview_frame = gtk_frame_new (_("Preview"));
-  gtk_box_pack_start (GTK_BOX (hbox), impl->preview_frame, FALSE, FALSE, 0);
-  /* Don't show preview frame initially */
+  impl->preview_box = gtk_vbox_new (FALSE, 12);
+  gtk_box_pack_start (GTK_BOX (hbox), impl->preview_box, FALSE, FALSE, 0);
+  /* Don't show preview box initially */
 
   /* Filename entry and filter combo */
   hbox = gtk_hbox_new (FALSE, 0);
@@ -1762,28 +2749,73 @@ file_pane_create (GtkFileChooserDefault *impl,
 }
 /* Callback used when the "Browse for more folders" expander is toggled */
 static void
-expander_activate_cb (GtkExpander           *expander,
-                     GtkFileChooserDefault *impl)
+expander_changed_cb (GtkExpander           *expander,
+                    GParamSpec            *pspec,
+                    GtkFileChooserDefault *impl)
 {
-  gboolean active;
+  update_appearance (impl);
+}
 
-  active = gtk_expander_get_expanded (expander);
+/* Callback used when the selection changes in the save folder combo box */
+static void
+save_folder_combo_changed_cb (GtkComboBox           *combo,
+                             GtkFileChooserDefault *impl)
+{
+  int active;
 
-  if (active)
-    gtk_widget_hide (impl->hpaned);
-  else
-    gtk_widget_show (impl->hpaned);
+  if (impl->changing_folder)
+    return;
+
+  active = gtk_combo_box_get_active (combo);
+  if (active == -1)
+    return;
+
+  shortcuts_activate_item (impl, active);
+}
+
+/* Creates the combo box with the save folders */
+static GtkWidget *
+save_folder_combo_create (GtkFileChooserDefault *impl)
+{
+  GtkWidget *combo;
+  GtkCellRenderer *cell;
+
+  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (impl->shortcuts_model));
+  gtk_widget_show (combo);
+
+  cell = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
+                                 "pixbuf", SHORTCUTS_COL_PIXBUF,
+                                 "visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
+                                 NULL);
+
+  cell = _gtk_cell_renderer_sep_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
+                                 "text", SHORTCUTS_COL_NAME,
+                                 NULL);
+
+  g_signal_connect (combo, "changed",
+                   G_CALLBACK (save_folder_combo_changed_cb), impl);
+
+  return combo;
 }
 
 /* Creates the widgets specific to Save mode */
 static GtkWidget *
 save_widgets_create (GtkFileChooserDefault *impl)
 {
+  GtkWidget *vbox;
   GtkWidget *table;
   GtkWidget *widget;
   GtkWidget *alignment;
 
-  table = gtk_table_new (3, 2, FALSE);
+  vbox = gtk_vbox_new (FALSE, 12);
+
+  table = gtk_table_new (2, 2, FALSE);
+  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+  gtk_widget_show (table);
   gtk_table_set_row_spacings (GTK_TABLE (table), 12);
   gtk_table_set_col_spacings (GTK_TABLE (table), 12);
 
@@ -1797,76 +2829,81 @@ save_widgets_create (GtkFileChooserDefault *impl)
                    0, 0);
   gtk_widget_show (widget);
 
-  impl->entry = _gtk_file_chooser_entry_new ();
-  gtk_entry_set_activates_default (GTK_ENTRY (impl->entry), TRUE);
-  _gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->entry), impl->file_system);
-  _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->entry), impl->current_folder);
-
-  gtk_table_attach (GTK_TABLE (table), impl->entry,
+  impl->save_file_name_entry = gtk_entry_new ();
+  gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45);
+  gtk_entry_set_activates_default (GTK_ENTRY (impl->save_file_name_entry), TRUE);
+  gtk_table_attach (GTK_TABLE (table), impl->save_file_name_entry,
                    1, 2, 0, 1,
                    GTK_EXPAND | GTK_FILL, 0,
                    0, 0);
-  gtk_widget_show (impl->entry);
-  gtk_label_set_mnemonic_widget (GTK_LABEL (widget), impl->entry);
+  gtk_widget_show (impl->save_file_name_entry);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (widget), impl->save_file_name_entry);
 
   /* Folder combo */
-
-  widget = gtk_label_new_with_mnemonic (_("Save in _Folder:"));
-  gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), widget,
+  impl->save_folder_label = gtk_label_new (NULL);
+  gtk_misc_set_alignment (GTK_MISC (impl->save_folder_label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), impl->save_folder_label,
                    0, 1, 1, 2,
                    GTK_FILL, GTK_FILL,
                    0, 0);
-  gtk_widget_show (widget);
+  gtk_widget_show (impl->save_folder_label);
 
-  /* FIXME: create the combo */
+  impl->save_folder_combo = save_folder_combo_create (impl);
+  gtk_table_attach (GTK_TABLE (table), impl->save_folder_combo,
+                   1, 2, 1, 2,
+                   GTK_EXPAND | GTK_FILL, GTK_FILL,
+                   0, 0);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (impl->save_folder_label), impl->save_folder_combo);
 
-  /* Expander */
+  /* custom widget */
+  impl->save_extra_align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
+  gtk_box_pack_start (GTK_BOX (vbox), impl->save_extra_align, FALSE, FALSE, 0);
 
+  /* Expander */
   alignment = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
-  gtk_table_attach (GTK_TABLE (table), alignment,
-                   0, 2, 2, 3,
-                   GTK_FILL, GTK_FILL,
-                   0, 0);
-  gtk_widget_show (alignment);
+  gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
 
-  widget = gtk_expander_new_with_mnemonic (_("_Browse for other folders"));
-  gtk_container_add (GTK_CONTAINER (alignment), widget);
-  gtk_widget_show (widget);
-  g_signal_connect (widget, "activate",
-                   G_CALLBACK (expander_activate_cb),
+  impl->save_expander = gtk_expander_new_with_mnemonic (_("_Browse for other folders"));
+  gtk_container_add (GTK_CONTAINER (alignment), impl->save_expander);
+  g_signal_connect (impl->save_expander, "notify::expanded",
+                   G_CALLBACK (expander_changed_cb),
                    impl);
+  gtk_widget_show_all (alignment);
 
-  return table;  
+  return vbox;
 }
 
 /* Creates the main hpaned with the widgets shared by Open and Save mode */
 static GtkWidget *
-main_paned_create (GtkFileChooserDefault *impl)
+browse_widgets_create (GtkFileChooserDefault *impl)
 {
+  GtkWidget *vbox;
   GtkWidget *hpaned;
   GtkWidget *widget;
   GtkSizeGroup *size_group;
 
-  /* size group is used by the [+][-] buttons, as well as the filter. */
+  /* size group is used by the [+][-] buttons and the filter combo */
   size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
+  vbox = gtk_vbox_new (FALSE, 12);
 
   /* Paned widget */
-
   hpaned = gtk_hpaned_new ();
+  gtk_widget_show (hpaned);
   gtk_paned_set_position (GTK_PANED (hpaned), 200); /* FIXME: this sucks */
-
-  /* Shortcuts pane */
+  gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
 
   widget = shortcuts_pane_create (impl, size_group);
   gtk_paned_pack1 (GTK_PANED (hpaned), widget, FALSE, FALSE);
-
-  /* File/folder pane */
-
   widget = file_pane_create (impl, size_group);
   gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
 
-  return hpaned;
+  g_object_unref (size_group);
+
+  /* Alignment to hold custom widget */
+  impl->browse_extra_align = gtk_alignment_new (0.0, .5, 1.0, 1.0);
+  gtk_box_pack_start (GTK_BOX (vbox), impl->browse_extra_align, FALSE, FALSE, 0);
+
+  return vbox;
 }
 
 static GObject*
@@ -1876,7 +2913,6 @@ gtk_file_chooser_default_constructor (GType                  type,
 {
   GtkFileChooserDefault *impl;
   GObject *object;
-  GtkWidget *show_widget;
 
   object = parent_class->constructor (type,
                                      n_construct_properties,
@@ -1887,24 +2923,20 @@ gtk_file_chooser_default_constructor (GType                  type,
 
   gtk_widget_push_composite_child ();
 
-  /* Widgets for Save mode */
+  /* Shortcuts model */
 
+  shortcuts_model_create (impl);
+
+  /* Widgets for Save mode */
   impl->save_widgets = save_widgets_create (impl);
   gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
 
-  /* Widgets for Open and Save mode */
-
-  impl->hpaned = main_paned_create (impl);
-  gtk_box_pack_start (GTK_BOX (impl), impl->hpaned, TRUE, TRUE, 0);
-
-  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
-    show_widget = impl->hpaned;
-  else
-    show_widget = impl->save_widgets;
-
-  gtk_widget_show (show_widget);
+  /* The browse widgets */
+  impl->browse_widgets = browse_widgets_create (impl);
+  gtk_box_pack_start (GTK_BOX (impl), impl->browse_widgets, TRUE, TRUE, 0);
 
   gtk_widget_pop_composite_child ();
+  update_appearance (impl);
 
   return object;
 }
@@ -1914,17 +2946,47 @@ static void
 set_extra_widget (GtkFileChooserDefault *impl,
                  GtkWidget             *extra_widget)
 {
-  if (extra_widget == impl->extra_widget)
-    return;
+  if (extra_widget)
+    {
+      g_object_ref (extra_widget);
+      /* FIXME: is this right ? */
+      gtk_widget_show (extra_widget);
+    }
 
   if (impl->extra_widget)
-    gtk_container_remove (GTK_CONTAINER (impl), impl->extra_widget);
+    g_object_unref (impl->extra_widget);
 
   impl->extra_widget = extra_widget;
-  if (impl->extra_widget)
+}
+
+static void
+set_local_only (GtkFileChooserDefault *impl,
+               gboolean               local_only)
+{
+  if (local_only != impl->local_only)
     {
-      gtk_widget_show_all (impl->extra_widget);
-      gtk_box_pack_end (GTK_BOX (impl), impl->extra_widget, FALSE, FALSE, 0);
+      impl->local_only = local_only;
+
+      if (impl->shortcuts_model && impl->file_system)
+       {
+         shortcuts_add_volumes (impl);
+         shortcuts_add_bookmarks (impl);
+       }
+
+      if (local_only &&
+         !gtk_file_system_path_is_local (impl->file_system, impl->current_folder))
+       {
+         /* If we are pointing to a non-local folder, make an effort to change
+          * back to a local folder, but it's really up to the app to not cause
+          * such a situation, so we ignore errors.
+          */
+         const gchar *home = g_get_home_dir ();
+         GtkFilePath *home_path = gtk_file_system_filename_to_path (impl->file_system, home);
+
+         _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), home_path, NULL);
+
+         gtk_file_path_free (home_path);
+       }
     }
 }
 
@@ -1958,16 +3020,12 @@ set_select_multiple (GtkFileChooserDefault *impl,
   if (select_multiple == impl->select_multiple)
     return;
 
-  impl->select_multiple = select_multiple;
-
   mode = select_multiple ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_BROWSE;
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree));
-  gtk_tree_selection_set_mode (selection, mode);
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
   gtk_tree_selection_set_mode (selection, mode);
 
+  impl->select_multiple = select_multiple;
   g_object_notify (G_OBJECT (impl), "select-multiple");
 
   /* FIXME #132255: See note in check_preview_change() */
@@ -1986,11 +3044,23 @@ set_file_system_backend (GtkFileChooserDefault *impl,
       impl->bookmarks_changed_id = 0;
       g_object_unref (impl->file_system);
     }
-  
+
   impl->file_system = NULL;
   if (backend)
     impl->file_system = _gtk_file_system_create (backend);
-  
+  else
+    {
+      GtkSettings *settings = gtk_settings_get_default ();
+      gchar *default_backend = NULL;
+
+      g_object_get (settings, "gtk-file-chooser-backend", &default_backend, NULL);
+      if (default_backend)
+       {
+         impl->file_system = _gtk_file_system_create (default_backend);
+         g_free (default_backend);
+       }
+    }
+
   if (!impl->file_system)
     {
 #if defined (G_OS_UNIX)
@@ -2001,7 +3071,7 @@ set_file_system_backend (GtkFileChooserDefault *impl,
 #error "No default filesystem implementation on the platform"
 #endif
     }
-  
+
   if (impl->file_system)
     {
       impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
@@ -2013,73 +3083,164 @@ set_file_system_backend (GtkFileChooserDefault *impl,
     }
 }
 
+/* This function is basically a do_all function.
+ *
+ * It sets the visibility on all the widgets based on the current state, and
+ * moves the custom_widget if needed.
+ */
 static void
-gtk_file_chooser_default_set_property (GObject      *object,
-                                      guint         prop_id,
-                                      const GValue *value,
-                                      GParamSpec   *pspec)
-
+update_appearance (GtkFileChooserDefault *impl)
 {
-  GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
+  GtkWidget *child;
 
-  switch (prop_id)
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+      impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
     {
-    case GTK_FILE_CHOOSER_PROP_ACTION:
-      impl->action = g_value_get_enum (value);
+      const char *text;
+
+      gtk_widget_show (impl->save_widgets);
+
       if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+       text = _("Save in _folder:");
+      else
+       text = _("Create in _folder:");
+
+      gtk_label_set_text_with_mnemonic (GTK_LABEL (impl->save_folder_label), text);
+
+      if (gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
+       {
+         gtk_widget_set_sensitive (impl->save_folder_label, FALSE);
+         gtk_widget_set_sensitive (impl->save_folder_combo, FALSE);
+         gtk_widget_show (impl->browse_widgets);
+       }
+      else
        {
-         gtk_widget_hide (impl->hpaned);
-         gtk_widget_show (impl->save_widgets);
-         gtk_widget_show (impl->new_folder_button);
+         gtk_widget_set_sensitive (impl->save_folder_label, TRUE);
+         gtk_widget_set_sensitive (impl->save_folder_combo, TRUE);
+         gtk_widget_hide (impl->browse_widgets);
+       }
 
-         if (impl->select_multiple)
-           {
-             g_warning ("Save mode cannot be set in conjunction with multiple selection mode.  "
-                        "Re-setting to single selection mode.");
-             set_select_multiple (impl, FALSE, TRUE);
-           }
+      gtk_widget_show (impl->browse_new_folder_button);
+
+      if (impl->select_multiple)
+       {
+         g_warning ("Save mode cannot be set in conjunction with multiple selection mode.  "
+                    "Re-setting to single selection mode.");
+         set_select_multiple (impl, FALSE, TRUE);
+       }
+    }
+  else if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+          impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+    {
+      gtk_widget_hide (impl->save_widgets);
+      gtk_widget_show (impl->browse_widgets);
+    }
+  /* FIXME: */
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+      impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    {
+      if (impl->browse_files_model)
+       _gtk_file_system_model_set_show_files (impl->browse_files_model, FALSE);
+    }
+  else
+    {
+      if (impl->browse_files_model)
+       _gtk_file_system_model_set_show_files (impl->browse_files_model, TRUE);
+    }
+
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
+    gtk_widget_hide (impl->browse_new_folder_button);
+  else
+    gtk_widget_show (impl->browse_new_folder_button);
+
+  if (impl->extra_widget)
+    {
+      GtkWidget *align;
+      GtkWidget *unused_align;
+
+      if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+         || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+       {
+         align = impl->save_extra_align;
+         unused_align = impl->browse_extra_align;
        }
       else
        {
-         gtk_widget_hide (impl->save_widgets);
-         gtk_widget_show (impl->hpaned);
+         align = impl->browse_extra_align;
+         unused_align = impl->save_extra_align;
+       }
 
-         if (impl->folder_mode)
-           gtk_widget_show (impl->new_folder_button);
-         else
-           gtk_widget_hide (impl->new_folder_button);
+      /* We own a ref on extra_widget, so it's safe to do this */
+      child = GTK_BIN (unused_align)->child;
+      if (child)
+       gtk_container_remove (GTK_CONTAINER (unused_align), child);
+
+      child = GTK_BIN (align)->child;
+      if (child && child != impl->extra_widget)
+       {
+         gtk_container_remove (GTK_CONTAINER (align), child);
+         gtk_container_add (GTK_CONTAINER (align), impl->extra_widget);
+       }
+      else if (child == NULL)
+       {
+         gtk_container_add (GTK_CONTAINER (align), impl->extra_widget);
        }
 
-      break;
-    case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
-      set_file_system_backend (impl, g_value_get_string (value));
-      break;
-    case GTK_FILE_CHOOSER_PROP_FILTER:
-      set_current_filter (impl, g_value_get_object (value));
-      break;
-    case GTK_FILE_CHOOSER_PROP_FOLDER_MODE:
+      gtk_widget_show (align);
+      gtk_widget_hide (unused_align);
+    }
+  else
+    {
+      child = GTK_BIN (impl->browse_extra_align)->child;
+      if (child)
+       gtk_container_remove (GTK_CONTAINER (impl->browse_extra_align), child);
+
+      child = GTK_BIN (impl->save_extra_align)->child;
+      if (child)
+       gtk_container_remove (GTK_CONTAINER (impl->save_extra_align), child);
+
+      gtk_widget_hide (impl->save_extra_align);
+      gtk_widget_hide (impl->browse_extra_align);
+    }
+
+  g_signal_emit_by_name (impl, "default-size-changed");
+}
+
+static void
+gtk_file_chooser_default_set_property (GObject      *object,
+                                      guint         prop_id,
+                                      const GValue *value,
+                                      GParamSpec   *pspec)
+
+{
+  GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
+
+  switch (prop_id)
+    {
+    case GTK_FILE_CHOOSER_PROP_ACTION:
       {
-       gboolean folder_mode = g_value_get_boolean (value);
-       if (folder_mode != impl->folder_mode)
+       GtkFileChooserAction action = g_value_get_enum (value);
+
+       if (action != impl->action)
          {
-           impl->folder_mode = folder_mode;
-           if (impl->folder_mode)
-             {
-               gtk_widget_hide (impl->list_scrollwin);
-               gtk_widget_show (impl->tree_scrollwin);
-               gtk_widget_show (impl->new_folder_button);
-             }
-           else
+           if (action == GTK_FILE_CHOOSER_ACTION_SAVE && impl->select_multiple)
              {
-               gtk_widget_hide (impl->tree_scrollwin);
-               gtk_widget_show (impl->list_scrollwin);
-               gtk_widget_hide (impl->new_folder_button);
+               g_warning ("Multiple selection mode is not allowed in Save mode");
+               set_select_multiple (impl, FALSE, TRUE);
              }
+           impl->action = action;
+           update_appearance (impl);
          }
       }
       break;
+    case GTK_FILE_CHOOSER_PROP_FILE_SYSTEM_BACKEND:
+      set_file_system_backend (impl, g_value_get_string (value));
+      break;
+    case GTK_FILE_CHOOSER_PROP_FILTER:
+      set_current_filter (impl, g_value_get_object (value));
+      break;
     case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
-      impl->local_only = g_value_get_boolean (value);
+      set_local_only (impl, g_value_get_boolean (value));
       break;
     case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
       set_preview_widget (impl, g_value_get_object (value));
@@ -2088,8 +3249,13 @@ gtk_file_chooser_default_set_property (GObject      *object,
       impl->preview_widget_active = g_value_get_boolean (value);
       update_preview_widget_visibility (impl);
       break;
+    case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
+      impl->use_preview_label = g_value_get_boolean (value);
+      update_preview_widget_visibility (impl);
+      break;
     case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
       set_extra_widget (impl, g_value_get_object (value));
+      update_appearance (impl);
       break;
     case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
       {
@@ -2109,8 +3275,8 @@ gtk_file_chooser_default_set_property (GObject      *object,
        if (show_hidden != impl->show_hidden)
          {
            impl->show_hidden = show_hidden;
-           _gtk_file_system_model_set_show_hidden (impl->tree_model, show_hidden);
-           _gtk_file_system_model_set_show_hidden (impl->list_model, show_hidden);
+           _gtk_file_system_model_set_show_hidden (GTK_FILE_SYSTEM_MODEL (impl->browse_files_model),
+                                                   show_hidden);
          }
       }
       break;
@@ -2136,9 +3302,6 @@ gtk_file_chooser_default_get_property (GObject    *object,
     case GTK_FILE_CHOOSER_PROP_FILTER:
       g_value_set_object (value, impl->current_filter);
       break;
-    case GTK_FILE_CHOOSER_PROP_FOLDER_MODE:
-      g_value_set_boolean (value, impl->folder_mode);
-      break;
     case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
       g_value_set_boolean (value, impl->local_only);
       break;
@@ -2148,6 +3311,9 @@ gtk_file_chooser_default_get_property (GObject    *object,
     case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
       g_value_set_boolean (value, impl->preview_widget_active);
       break;
+    case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
+      g_value_set_boolean (value, impl->use_preview_label);
+      break;
     case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
       g_value_set_object (value, impl->extra_widget);
       break;
@@ -2163,34 +3329,138 @@ gtk_file_chooser_default_get_property (GObject    *object,
     }
 }
 
-/* We override show-all since we have internal widgets that
- * shouldn't be shown when you call show_all(), like the filter
- * combo box.
- */
+/* Removes the settings signal handler.  It's safe to call multiple times */
+static void
+remove_settings_signal (GtkFileChooserDefault *impl,
+                       GdkScreen             *screen)
+{
+  if (impl->settings_signal_id)
+    {
+      GtkSettings *settings;
+
+      settings = gtk_settings_get_for_screen (screen);
+      g_signal_handler_disconnect (settings,
+                                  impl->settings_signal_id);
+      impl->settings_signal_id = 0;
+    }
+}
+
+static void
+gtk_file_chooser_default_dispose (GObject *object)
+{
+  GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object;
+
+  if (impl->extra_widget)
+    {
+      g_object_unref (impl->extra_widget);
+      impl->extra_widget = NULL;
+    }
+
+  remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl)));
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+/* We override show-all since we have internal widgets that
+ * shouldn't be shown when you call show_all(), like the filter
+ * combo box.
+ */
+static void
+gtk_file_chooser_default_show_all (GtkWidget *widget)
+{
+  GtkFileChooserDefault *impl = (GtkFileChooserDefault *) widget;
+
+  gtk_widget_show (widget);
+
+  if (impl->extra_widget)
+    gtk_widget_show_all (impl->extra_widget);
+}
+
+/* Changes the icons wherever it is needed */
+static void
+change_icon_theme (GtkFileChooserDefault *impl)
+{
+  GtkSettings *settings;
+  gint width, height;
+
+  settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
+
+  if (gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_SMALL_TOOLBAR, &width, &height))
+    impl->icon_size = MAX (width, height);
+  else
+    impl->icon_size = FALLBACK_ICON_SIZE;
+
+  shortcuts_reload_icons (impl);
+  gtk_widget_queue_resize (impl->browse_files_tree_view);
+}
+
+/* Callback used when a GtkSettings value changes */
+static void
+settings_notify_cb (GObject               *object,
+                   GParamSpec            *pspec,
+                   GtkFileChooserDefault *impl)
+{
+  const char *name;
+
+  name = g_param_spec_get_name (pspec);
+
+  if (strcmp (name, "gtk-icon-theme-name") == 0
+      || strcmp (name, "gtk-icon-sizes") == 0)
+    change_icon_theme (impl);
+}
+
+/* Installs a signal handler for GtkSettings so that we can monitor changes in
+ * the icon theme.
+ */
+static void
+check_icon_theme (GtkFileChooserDefault *impl)
+{
+  GtkSettings *settings;
+
+  if (impl->settings_signal_id)
+    return;
+
+  if (gtk_widget_has_screen (GTK_WIDGET (impl)))
+    {
+      settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
+      impl->settings_signal_id = g_signal_connect (settings, "notify",
+                                                  G_CALLBACK (settings_notify_cb), impl);
+
+      change_icon_theme (impl);
+    }
+}
+
 static void
-gtk_file_chooser_default_show_all (GtkWidget *widget)
+gtk_file_chooser_default_style_set      (GtkWidget *widget,
+                                        GtkStyle  *previous_style)
 {
-  gtk_widget_show (widget);
+  GtkFileChooserDefault *impl;
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (widget);
+
+  if (GTK_WIDGET_CLASS (parent_class)->style_set)
+    GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
+
+  check_icon_theme (impl);
+
+  g_signal_emit_by_name (widget, "default-size-changed");
 }
 
 static void
-expand_and_select_func (GtkFileSystemModel *model,
-                       GtkTreePath        *path,
-                       GtkTreeIter        *iter,
-                       gpointer            user_data)
+gtk_file_chooser_default_screen_changed (GtkWidget *widget,
+                                        GdkScreen *previous_screen)
 {
-  GtkFileChooserDefault *impl = user_data;
-  GtkTreeView *tree_view;
+  GtkFileChooserDefault *impl;
 
-  if (model == impl->tree_model)
-    tree_view = GTK_TREE_VIEW (impl->tree);
-  else
-    tree_view = GTK_TREE_VIEW (impl->list);
+  impl = GTK_FILE_CHOOSER_DEFAULT (widget);
+
+  if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
+    GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous_screen);
 
-  gtk_tree_view_expand_to_path (tree_view, path);
-  gtk_tree_view_expand_row (tree_view, path, FALSE);
-  gtk_tree_view_set_cursor (tree_view, path, NULL, FALSE);
-  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->tree), path, NULL, TRUE, 0.3, 0.5);
+  remove_settings_signal (impl, previous_screen);
+  check_icon_theme (impl);
+
+  g_signal_emit_by_name (widget, "default-size-changed");
 }
 
 static gboolean
@@ -2229,7 +3499,7 @@ list_model_filter_func (GtkFileSystemModel *model,
   if (needed & GTK_FILE_FILTER_URI)
     {
       filter_info.uri = gtk_file_system_path_to_uri (impl->file_system, path);
-      if (filter_info.filename)
+      if (filter_info.uri)
        filter_info.contains |= GTK_FILE_FILTER_URI;
     }
   else
@@ -2249,15 +3519,15 @@ static void
 install_list_model_filter (GtkFileChooserDefault *impl)
 {
   if (impl->current_filter)
-    _gtk_file_system_model_set_filter (impl->list_model,
+    _gtk_file_system_model_set_filter (impl->browse_files_model,
                                       list_model_filter_func,
                                       impl);
 }
 
 #define COMPARE_DIRECTORIES                                                                                   \
   GtkFileChooserDefault *impl = user_data;                                                                    \
-  const GtkFileInfo *info_a = _gtk_file_system_model_get_info (impl->list_model, a);                          \
-  const GtkFileInfo *info_b = _gtk_file_system_model_get_info (impl->list_model, b);                          \
+  const GtkFileInfo *info_a = _gtk_file_system_model_get_info (impl->browse_files_model, a);                          \
+  const GtkFileInfo *info_b = _gtk_file_system_model_get_info (impl->browse_files_model, b);                          \
   gboolean dir_a, dir_b;                                                                                      \
                                                                                                               \
   if (info_a)                                                                                                 \
@@ -2336,19 +3606,32 @@ list_sort_column_changed_cb (GtkTreeSortable       *sortable,
 static void
 set_list_model (GtkFileChooserDefault *impl)
 {
-  if (impl->list_model)
+  if (impl->browse_files_model)
     {
-      g_object_unref (impl->list_model);
+      g_object_unref (impl->browse_files_model);
       g_object_unref (impl->sort_model);
     }
 
-  impl->list_model = _gtk_file_system_model_new (impl->file_system,
-                                                impl->current_folder, 0,
-                                                GTK_FILE_INFO_ALL);
-  _gtk_file_system_model_set_show_hidden (impl->list_model, impl->show_hidden);
+  impl->browse_files_model = _gtk_file_system_model_new (impl->file_system,
+                                                        impl->current_folder, 0,
+                                                        GTK_FILE_INFO_ALL);
+  _gtk_file_system_model_set_show_hidden (impl->browse_files_model, impl->show_hidden);
+  switch (impl->action)
+    {
+    case GTK_FILE_CHOOSER_ACTION_OPEN:
+    case GTK_FILE_CHOOSER_ACTION_SAVE:
+      _gtk_file_system_model_set_show_files (impl->browse_files_model, TRUE);
+      break;
+    case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER:
+    case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:
+      _gtk_file_system_model_set_show_files (impl->browse_files_model, FALSE);
+      break;
+    default:
+      g_assert_not_reached ();
+    }
   install_list_model_filter (impl);
 
-  impl->sort_model = (GtkTreeModelSort *)gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (impl->list_model));
+  impl->sort_model = (GtkTreeModelSort *)gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (impl->browse_files_model));
   gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, name_sort_func, impl, NULL);
   gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_SIZE, size_sort_func, impl, NULL);
   gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_MTIME, mtime_sort_func, impl, NULL);
@@ -2356,69 +3639,16 @@ set_list_model (GtkFileChooserDefault *impl)
   gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, GTK_SORT_ASCENDING);
   impl->list_sort_ascending = TRUE;
 
-  g_signal_connect (impl->sort_model, "sort_column_changed",
+  g_signal_connect (impl->sort_model, "sort-column-changed",
                    G_CALLBACK (list_sort_column_changed_cb), impl);
 
-  gtk_tree_view_set_model (GTK_TREE_VIEW (impl->list),
+  gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view),
                           GTK_TREE_MODEL (impl->sort_model));
-  gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->list));
-  gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->list),
+  gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->browse_files_tree_view));
+  gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view),
                                   GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME);
 }
 
-/* Gets rid of the old folder tree model and creates a new one for the volume
- * corresponding to the specified path.
- */
-static void
-set_tree_model (GtkFileChooserDefault *impl, const GtkFilePath *path)
-{
-  GtkFileSystemVolume *volume;
-  GtkFilePath *base_path, *parent_path;
-
-  base_path = NULL;
-  
-  volume = gtk_file_system_get_volume_for_path (impl->file_system, path);
-  
-  if (volume)
-    base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
-  
-  if (base_path == NULL)
-    {
-      base_path = gtk_file_path_copy (path);
-      while (gtk_file_system_get_parent (impl->file_system,
-                                        base_path,
-                                        &parent_path,
-                                        NULL) &&
-            parent_path != NULL)
-       {
-         gtk_file_path_free (base_path);
-         base_path = parent_path;
-       }
-    }
-
-  if (impl->current_volume_path && gtk_file_path_compare (base_path, impl->current_volume_path) == 0)
-    goto out;
-
-  if (impl->tree_model)
-    g_object_unref (impl->tree_model);
-
-  impl->current_volume_path = gtk_file_path_copy (base_path);
-
-  impl->tree_model = _gtk_file_system_model_new (impl->file_system, impl->current_volume_path, -1,
-                                                GTK_FILE_INFO_DISPLAY_NAME);
-  _gtk_file_system_model_set_show_files (impl->tree_model, FALSE);
-  _gtk_file_system_model_set_show_hidden (impl->tree_model, impl->show_hidden);
-
-  gtk_tree_view_set_model (GTK_TREE_VIEW (impl->tree),
-                          GTK_TREE_MODEL (impl->tree_model));
-
- out:
-
-  gtk_file_path_free (base_path);
-  if (volume) 
-    gtk_file_system_volume_free (impl->file_system, volume);
-}
-
 static void
 update_chooser_entry (GtkFileChooserDefault *impl)
 {
@@ -2430,7 +3660,8 @@ update_chooser_entry (GtkFileChooserDefault *impl)
   if (impl->action != GTK_FILE_CHOOSER_ACTION_SAVE)
     return;
 
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+  g_assert (!impl->select_multiple);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
 
   if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
     return;
@@ -2439,56 +3670,72 @@ update_chooser_entry (GtkFileChooserDefault *impl)
                                                  &child_iter,
                                                  &iter);
 
-  info = _gtk_file_system_model_get_info (impl->list_model, &child_iter);
+  info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
 
   if (!gtk_file_info_get_is_folder (info))
-    _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->entry),
-                                          gtk_file_info_get_display_name (info));
+    gtk_entry_set_text (GTK_ENTRY (impl->save_file_name_entry),
+                       gtk_file_info_get_display_name (info));
 }
 
-static void
+static gboolean
 gtk_file_chooser_default_set_current_folder (GtkFileChooser    *chooser,
-                                            const GtkFilePath *path)
+                                            const GtkFilePath *path,
+                                            GError           **error)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
 
-  if (impl->current_folder)
-    gtk_file_path_free (impl->current_folder);
+  /* Test validity of path here.  */
+  if (!check_is_folder (impl->file_system, path, error))
+    return FALSE;
+
+  if (impl->local_only &&
+      !gtk_file_system_path_is_local (impl->file_system, path))
+    {
+      g_set_error (error,
+                  GTK_FILE_SYSTEM_ERROR,
+                  GTK_FILE_SYSTEM_ERROR_FAILED,
+                  _("Can't change to folder because it isn't local"));
+
+      return FALSE;
+    }
 
-  impl->current_folder = gtk_file_path_copy (path);
+  if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
+    return FALSE;
 
-  /* Change the current folder label */
-  gtk_path_bar_set_path (GTK_PATH_BAR (impl->path_bar), path, impl->file_system, NULL);
+  if (impl->current_folder != path)
+    {
+      if (impl->current_folder)
+       gtk_file_path_free (impl->current_folder);
+
+      impl->current_folder = gtk_file_path_copy (path);
+    }
 
-  /* Update the folder tree */
+  /* Update the widgets that may trigger a folder change themselves.  */
 
   if (!impl->changing_folder)
     {
       impl->changing_folder = TRUE;
-      set_tree_model (impl, impl->current_folder);
-      _gtk_file_system_model_path_do (impl->tree_model, path,
-                                     expand_and_select_func, impl);
-      impl->changing_folder = FALSE;
-    }
 
-  /* Notify the save entry */
+      shortcuts_update_current_folder (impl);
 
-  _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->entry), impl->current_folder);
+      impl->changing_folder = FALSE;
+    }
 
   /* Create a new list model */
   set_list_model (impl);
 
   /* Refresh controls */
 
-  shortcuts_unselect_all (impl);
+  shortcuts_find_current_folder (impl);
 
   g_signal_emit_by_name (impl, "current-folder-changed", 0);
 
-  update_chooser_entry (impl);
   check_preview_change (impl);
   bookmarks_check_add_sensitivity (impl);
 
   g_signal_emit_by_name (impl, "selection-changed", 0);
+
+  return TRUE;
 }
 
 static GtkFilePath *
@@ -2505,9 +3752,10 @@ gtk_file_chooser_default_set_current_name (GtkFileChooser *chooser,
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
 
-  g_return_if_fail (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE);
+  g_return_if_fail (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+                   || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
 
-  _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->entry), name);
+  gtk_entry_set_text (GTK_ENTRY (impl->save_file_name_entry), name);
 }
 
 static void
@@ -2517,41 +3765,40 @@ select_func (GtkFileSystemModel *model,
             gpointer            user_data)
 {
   GtkFileChooserDefault *impl = user_data;
-  GtkTreeView *tree_view = GTK_TREE_VIEW (impl->list);
+  GtkTreeView *tree_view = GTK_TREE_VIEW (impl->browse_files_tree_view);
   GtkTreePath *sorted_path;
 
   sorted_path = gtk_tree_model_sort_convert_child_path_to_path (impl->sort_model, path);
   gtk_tree_view_set_cursor (tree_view, sorted_path, NULL, FALSE);
-  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->tree), sorted_path, NULL, TRUE, 0.3, 0.0);
   gtk_tree_path_free (sorted_path);
 }
 
-static void
+static gboolean
 gtk_file_chooser_default_select_path (GtkFileChooser    *chooser,
-                                     const GtkFilePath *path)
+                                     const GtkFilePath *path,
+                                     GError           **error)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   GtkFilePath *parent_path;
-  GError *error;
 
-  error = NULL;
-  if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, &error))
-    {
-      error_getting_info_dialog (impl, path, error);
-      return;
-    }
+  if (!gtk_file_system_get_parent (impl->file_system, path, &parent_path, error))
+    return FALSE;
 
   if (!parent_path)
-    {
-      _gtk_file_chooser_set_current_folder_path (chooser, path);
-    }
+    return _gtk_file_chooser_set_current_folder_path (chooser, path, error);
   else
     {
-      _gtk_file_chooser_set_current_folder_path (chooser, parent_path);
+      gboolean result;
+
+      result = _gtk_file_chooser_set_current_folder_path (chooser, parent_path, error);
       gtk_file_path_free (parent_path);
-      _gtk_file_system_model_path_do (impl->list_model, path,
+      _gtk_file_system_model_path_do (impl->browse_files_model, path,
                                      select_func, impl);
+
+      return result;
     }
+
+  g_assert_not_reached ();
 }
 
 static void
@@ -2561,7 +3808,7 @@ unselect_func (GtkFileSystemModel *model,
               gpointer            user_data)
 {
   GtkFileChooserDefault *impl = user_data;
-  GtkTreeView *tree_view = GTK_TREE_VIEW (impl->list);
+  GtkTreeView *tree_view = GTK_TREE_VIEW (impl->browse_files_tree_view);
   GtkTreePath *sorted_path;
 
   sorted_path = gtk_tree_model_sort_convert_child_path_to_path (impl->sort_model,
@@ -2577,7 +3824,7 @@ gtk_file_chooser_default_unselect_path (GtkFileChooser    *chooser,
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
 
-  _gtk_file_system_model_path_do (impl->list_model, path,
+  _gtk_file_system_model_path_do (impl->browse_files_model, path,
                                 unselect_func, impl);
 }
 
@@ -2587,7 +3834,7 @@ gtk_file_chooser_default_select_all (GtkFileChooser *chooser)
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   if (impl->select_multiple)
     {
-      GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+      GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
       gtk_tree_selection_select_all (selection);
     }
 }
@@ -2596,11 +3843,49 @@ static void
 gtk_file_chooser_default_unselect_all (GtkFileChooser *chooser)
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
-  GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+  GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
 
   gtk_tree_selection_unselect_all (selection);
 }
 
+/* Checks whether the filename entry for the Save modes contains a valid filename */
+static GtkFilePath *
+check_save_entry (GtkFileChooserDefault *impl,
+                 gboolean              *is_valid,
+                 gboolean              *is_empty)
+{
+  const char *filename;
+  GtkFilePath *path;
+  GError *error;
+
+  g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+           || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+
+  filename = gtk_entry_get_text (GTK_ENTRY (impl->save_file_name_entry));
+
+  if (!filename || filename[0] == '\0')
+    {
+      *is_valid = FALSE;
+      *is_empty = TRUE;
+      return NULL;
+    }
+
+  *is_empty = FALSE;
+
+  error = NULL;
+  path = gtk_file_system_make_path (impl->file_system, impl->current_folder, filename, &error);
+
+  if (!path)
+    {
+      error_building_filename_dialog (impl, impl->current_folder, filename, error);
+      *is_valid = FALSE;
+      return NULL;
+    }
+
+  *is_valid = TRUE;
+  return path;
+}
+
 struct get_paths_closure {
   GtkFileChooserDefault *impl;
   GSList *result;
@@ -2619,19 +3904,12 @@ get_paths_foreach (GtkTreeModel *model,
   GtkTreeIter sel_iter;
 
   info = data;
+  fs_model = info->impl->browse_files_model;
+  gtk_tree_model_sort_convert_iter_to_child_iter (info->impl->sort_model, &sel_iter, iter);
 
-  if (info->impl->folder_mode)
-    {
-      fs_model = info->impl->tree_model;
-      sel_iter = *iter;
-    }
-  else
-    {
-      fs_model = info->impl->list_model;
-      gtk_tree_model_sort_convert_iter_to_child_iter (info->impl->sort_model, &sel_iter, iter);
-    }
-
-  file_path = _gtk_file_system_model_get_path (fs_model, &sel_iter);
+  file_path = _gtk_file_system_model_get_path (GTK_FILE_SYSTEM_MODEL (fs_model), &sel_iter);
+  if (!file_path)
+    return; /* We are on the editable row */
 
   if (!info->path_from_entry
       || gtk_file_path_compare (info->path_from_entry, file_path) != 0)
@@ -2648,57 +3926,35 @@ gtk_file_chooser_default_get_paths (GtkFileChooser *chooser)
   info.result = NULL;
   info.path_from_entry = NULL;
 
-  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+      || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
     {
-      GtkFileChooserEntry *chooser_entry;
-      const GtkFilePath *folder_path;
-      const gchar *file_part;
-
-      chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->entry);
-      folder_path = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
-      file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
-
-      if (file_part != NULL && file_part[0] != '\0')
-       {
-         GtkFilePath *selected;
-         GError *error = NULL;
-
-         selected = gtk_file_system_make_path (impl->file_system, folder_path, file_part, &error);
-
-         if (!selected)
-           {
-             error_building_filename_dialog (impl, folder_path, file_part, error);
-             return NULL;
-           }
+      gboolean is_valid, is_empty;
 
-         info.path_from_entry = selected;
-       }
+      info.path_from_entry = check_save_entry (impl, &is_valid, &is_empty);
+      if (!is_valid && !is_empty)
+       return NULL;
     }
 
   if (!info.path_from_entry || impl->select_multiple)
     {
       GtkTreeSelection *selection;
 
-      selection = NULL;
-
-      if (impl->folder_mode)
-       {
-         if (impl->tree_model)
-           selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->tree));
-       }
-      else
-       {
-         if (impl->sort_model)
-           selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
-       }
-
-      if (selection)
-       gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info);
+      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+      gtk_tree_selection_selected_foreach (selection, get_paths_foreach, &info);
     }
 
   if (info.path_from_entry)
     info.result = g_slist_prepend (info.result, info.path_from_entry);
 
+  /* If there's no folder selected, and we're in SELECT_FOLDER mode, then we
+   * fall back to the current directory */
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER &&
+      info.result == NULL)
+    {
+      info.result = g_slist_prepend (info.result, gtk_file_path_copy (impl->current_folder));
+    }
+
   return g_slist_reverse (info.result);
 }
 
@@ -2824,6 +4080,10 @@ gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser    *chooser,
   gboolean result;
   int pos;
 
+  /* Test validity of path here.  */
+  if (!check_is_folder (impl->file_system, path, error))
+    return FALSE;
+
   pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
 
   result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);
@@ -2831,6 +4091,9 @@ gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser    *chooser,
   if (result)
     impl->num_shortcuts++;
 
+  if (impl->shortcuts_filter_model)
+    gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
+
   return result;
 }
 
@@ -2842,6 +4105,7 @@ gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser    *chooser,
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   int pos;
   GtkTreeIter iter;
+  char *uri;
   int i;
 
   if (impl->num_shortcuts == 0)
@@ -2871,46 +4135,285 @@ gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser    *chooser,
        g_assert_not_reached ();
     }
 
- out:
+ out:
+
+  uri = gtk_file_system_path_to_uri (impl->file_system, path);
+  g_set_error (error,
+              GTK_FILE_CHOOSER_ERROR,
+              GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
+              _("shortcut %s does not exist"),
+              uri);
+  g_free (uri);
+
+  return FALSE;
+}
+
+static GSList *
+gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
+{
+  GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+  int pos;
+  GtkTreeIter iter;
+  int i;
+  GSList *list;
+
+  if (impl->num_shortcuts == 0)
+    return NULL;
+
+  pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
+  if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
+    g_assert_not_reached ();
+
+  list = NULL;
+
+  for (i = 0; i < impl->num_shortcuts; i++)
+    {
+      GtkFilePath *shortcut;
+
+      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &shortcut, -1);
+      g_assert (shortcut != NULL);
+
+      list = g_slist_prepend (list, gtk_file_path_copy (shortcut));
+
+      if (i != impl->num_shortcuts - 1)
+       {
+         if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+           g_assert_not_reached ();
+       }
+    }
+
+  return g_slist_reverse (list);
+}
+
+/* Guesses a size based upon font sizes */
+static void
+find_good_size_from_style (GtkWidget *widget,
+                          gint      *width,
+                          gint      *height)
+{
+  GtkFileChooserDefault *impl;
+  gint default_width, default_height;
+  int font_size;
+  GtkRequisition req;
+  GtkRequisition preview_req;
+
+  g_assert (widget->style != NULL);
+  impl = GTK_FILE_CHOOSER_DEFAULT (widget);
+
+  font_size = pango_font_description_get_size (widget->style->font_desc);
+  font_size = PANGO_PIXELS (font_size);
+
+  default_width = font_size * NUM_CHARS;
+  default_height = font_size * NUM_LINES;
+
+  /* Use at least the requisition size not including the preview widget */
+  gtk_widget_size_request (widget, &req);
+
+  if (impl->preview_widget_active && impl->preview_widget)
+    gtk_widget_size_request (impl->preview_box, &preview_req);
+  else
+    preview_req.width = 0;
+
+  default_width = MAX (default_width, (req.width - (preview_req.width + PREVIEW_HBOX_SPACING)));
+  default_height = MAX (default_height, req.height);
+
+  *width = default_width;
+  *height = default_height;
+}
+
+static void
+gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
+                                          gint                *default_width,
+                                          gint                *default_height)
+{
+  GtkFileChooserDefault *impl;
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
+
+  find_good_size_from_style (GTK_WIDGET (chooser_embed), default_width, default_height);
+
+  if (impl->preview_widget_active && impl->preview_widget)
+    *default_width += impl->preview_box->requisition.width + PREVIEW_HBOX_SPACING;
+}
+
+static void
+gtk_file_chooser_default_get_resizable_hints (GtkFileChooserEmbed *chooser_embed,
+                                             gboolean            *resize_horizontally,
+                                             gboolean            *resize_vertically)
+{
+  GtkFileChooserDefault *impl;
+
+  g_return_if_fail (resize_horizontally != NULL);
+  g_return_if_fail (resize_vertically != NULL);
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
+
+  *resize_horizontally = TRUE;
+  *resize_vertically = TRUE;
+
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+      impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    {
+      if (! gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
+       {
+         *resize_horizontally = FALSE;
+         *resize_vertically = FALSE;
+       }
+    }
+}
+
+struct switch_folder_closure {
+  GtkFileChooserDefault *impl;
+  const GtkFilePath *path;
+  int num_selected;
+};
+
+/* Used from gtk_tree_selection_selected_foreach() in switch_to_selected_folder() */
+static void
+switch_folder_foreach_cb (GtkTreeModel      *model,
+                         GtkTreePath       *path,
+                         GtkTreeIter       *iter,
+                         gpointer           data)
+{
+  struct switch_folder_closure *closure;
+  GtkTreeIter child_iter;
+
+  closure = data;
+
+  gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
+
+  closure->path = _gtk_file_system_model_get_path (closure->impl->browse_files_model, &child_iter);
+  closure->num_selected++;
+}
+
+/* Changes to the selected folder in the list view */
+static void
+switch_to_selected_folder (GtkFileChooserDefault *impl)
+{
+  GtkTreeSelection *selection;
+  struct switch_folder_closure closure;
+
+  g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+           || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE);
+
+  /* We do this with foreach() rather than get_selected() as we may be in
+   * multiple selection mode
+   */
+
+  closure.impl = impl;
+  closure.path = NULL;
+  closure.num_selected = 0;
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+  gtk_tree_selection_selected_foreach (selection, switch_folder_foreach_cb, &closure);
+
+  g_assert (closure.path && closure.num_selected == 1);
+
+  change_folder_and_display_error (impl, closure.path);
+}
+
+/* Implementation for GtkFileChooserEmbed::should_respond() */
+static gboolean
+gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed)
+{
+  GtkFileChooserDefault *impl;
+  GtkTreeSelection *selection;
+  int num_selected;
+
+  impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
+
+  /* First, check the save entry.  If it has a valid name, we are done */
+
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+      || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    {
+      GtkFilePath *path;
+      gboolean is_valid, is_empty;
+
+      path = check_save_entry (impl, &is_valid, &is_empty);
+
+      if (is_valid)
+       {
+         gtk_file_path_free (path);
+         return TRUE;
+       }
+      else if (!is_empty)
+       return FALSE;
+    }
+
+  /* Second, do we have an empty selection */
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+      || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+    {
+      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+      num_selected = gtk_tree_selection_count_selected_rows (selection);
+      if (num_selected == 0)
+       return FALSE;
+    }
+
+  /* Third, should we return file names or folder names? */
 
-  g_set_error (error,
-              GTK_FILE_CHOOSER_ERROR,
-              GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
-              _("shortcut %s does not exist"),
-              gtk_file_path_get_string (path));
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+      || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+    {
+      gboolean all_files, all_folders;
+
+      selection_check (impl, NULL, &all_files, &all_folders);
+
+      if (num_selected == 1)
+       {
+         if (all_folders)
+           {
+             switch_to_selected_folder (impl);
+             return FALSE;
+           }
+         else if (all_files)
+           return TRUE;
+       }
+      else
+       return all_files;
+    }
+  else if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
+          || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    /* There can be no files selected in folder mode since we don't show them,
+     * anyway.
+     */
+    return TRUE;
 
+  g_assert_not_reached ();
   return FALSE;
 }
 
-static GSList *
-gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
+/* Implementation for GtkFileChooserEmbed::initial_focus() */
+static void
+gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed)
 {
-  GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
-  int pos;
-  GtkTreeIter iter;
-  int i;
-  GSList *list;
-
-  pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
-  if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
-    g_assert_not_reached ();
+  GtkFileChooserDefault *impl;
+  GtkWidget *widget;
 
-  list = NULL;
+  impl = GTK_FILE_CHOOSER_DEFAULT (chooser_embed);
 
-  for (i = 0; i < impl->num_shortcuts; i++)
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+      || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
     {
-      GtkFilePath *shortcut;
-
-      gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &shortcut, -1);
-      g_assert (shortcut != NULL);
+      GtkTreePath *path;
 
-      list = g_slist_prepend (list, gtk_file_path_copy (shortcut));
+      path = gtk_tree_path_new_from_indices (0, -1);
+      gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), path, NULL, FALSE);
+      gtk_tree_path_free (path);
 
-      if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
-       g_assert_not_reached ();
+      widget = impl->browse_files_tree_view;
+    }
+  else if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+          || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+    widget = impl->save_file_name_entry;
+  else
+    {
+      g_assert_not_reached ();
+      widget = NULL;
     }
 
-  return g_slist_reverse (list);
+  gtk_widget_grab_focus (widget);
 }
 
 static void
@@ -2946,63 +4449,6 @@ set_current_filter (GtkFileChooserDefault *impl,
     }
 }
 
-static void
-open_and_close (GtkTreeView *tree_view,
-               GtkTreePath *target_path)
-{
-  GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
-  GtkTreeIter iter;
-  GtkTreePath *path;
-
-  path = gtk_tree_path_new ();
-  gtk_tree_path_append_index (path, 0);
-
-  gtk_tree_model_get_iter (model, &iter, path);
-
-  while (TRUE)
-    {
-      if (gtk_tree_path_is_ancestor (path, target_path) ||
-         gtk_tree_path_compare (path, target_path) == 0)
-       {
-         GtkTreeIter child_iter;
-         gtk_tree_view_expand_row (tree_view, path, FALSE);
-         if (gtk_tree_model_iter_children (model, &child_iter, &iter))
-           {
-             iter = child_iter;
-             gtk_tree_path_down (path);
-             goto next;
-           }
-       }
-      else
-       gtk_tree_view_collapse_row (tree_view, path);
-
-      while (TRUE)
-       {
-         GtkTreeIter parent_iter;
-         GtkTreeIter next_iter;
-
-         next_iter = iter;
-         if (gtk_tree_model_iter_next (model, &next_iter))
-           {
-             iter = next_iter;
-             gtk_tree_path_next (path);
-             goto next;
-           }
-
-         if (!gtk_tree_model_iter_parent (model, &parent_iter, &iter))
-           goto out;
-
-         iter = parent_iter;
-         gtk_tree_path_up (path);
-       }
-    next:
-      ;
-    }
-
- out:
-  gtk_tree_path_free (path);
-}
-
 static void
 filter_combo_changed (GtkComboBox           *combo_box,
                      GtkFileChooserDefault *impl)
@@ -3017,6 +4463,7 @@ static void
 check_preview_change (GtkFileChooserDefault *impl)
 {
   const GtkFilePath *new_path = NULL;
+  const GtkFileInfo *new_info = NULL;
 
   /* FIXME #132255: Fixing preview for multiple selection involves getting the
    * full selection and diffing to find out what the most recently selected file
@@ -3028,7 +4475,7 @@ check_preview_change (GtkFileChooserDefault *impl)
       GtkTreeSelection *selection;
       GtkTreeIter iter;
 
-      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
       if (gtk_tree_selection_get_selected (selection, NULL, &iter))
        {
          GtkTreeIter child_iter;
@@ -3036,7 +4483,8 @@ check_preview_change (GtkFileChooserDefault *impl)
          gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
                                                          &child_iter, &iter);
 
-         new_path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
+         new_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
+         new_info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
        }
     }
 
@@ -3045,49 +4493,29 @@ check_preview_change (GtkFileChooserDefault *impl)
        gtk_file_path_compare (new_path, impl->preview_path) == 0))
     {
       if (impl->preview_path)
-       gtk_file_path_free (impl->preview_path);
+       {
+         gtk_file_path_free (impl->preview_path);
+         g_free (impl->preview_display_name);
+       }
 
       if (new_path)
-       impl->preview_path = gtk_file_path_copy (new_path);
+       {
+         impl->preview_path = gtk_file_path_copy (new_path);
+         impl->preview_display_name = g_strdup (gtk_file_info_get_display_name (new_info));
+       }
       else
-       impl->preview_path = NULL;
+       {
+         impl->preview_path = NULL;
+         impl->preview_display_name = NULL;
+       }
+
+      if (impl->use_preview_label && impl->preview_label)
+       gtk_label_set_text (GTK_LABEL (impl->preview_label), impl->preview_display_name);
 
       g_signal_emit_by_name (impl, "update-preview");
     }
 }
 
-static void
-tree_selection_changed (GtkTreeSelection      *selection,
-                       GtkFileChooserDefault *impl)
-{
-  GtkTreeIter iter;
-  const GtkFilePath *file_path;
-  GtkTreePath *path;
-
-  /* FIXME #132255: Fixing this for multiple selection involves getting the full
-   * selection and diffing to find out what the most recently selected file is;
-   * there is logic in GtkFileSelection that probably can be copied;
-   * check_preview_change() is similar.
-   */
-  if (impl->select_multiple
-      || !gtk_tree_selection_get_selected (selection, NULL, &iter))
-    return;
-
-  file_path = _gtk_file_system_model_get_path (impl->tree_model, &iter);
-  if (impl->current_folder && gtk_file_path_compare (file_path, impl->current_folder) == 0)
-    return;
-
-  /* Close the tree up to only the parents of the newly selected
-   * node and it's immediate children are visible.
-   */
-  path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->tree_model), &iter);
-  open_and_close (GTK_TREE_VIEW (impl->tree), path);
-  gtk_tree_path_free (path);
-
-  if (!impl->changing_folder)
-    _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
-}
-
 /* Activates a volume by mounting it if necessary and then switching to its
  * base path.
  */
@@ -3118,33 +4546,37 @@ shortcuts_activate_volume (GtkFileChooserDefault *impl,
     }
 
   path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
-  _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path);
+  change_folder_and_display_error (impl, path);
   gtk_file_path_free (path);
 }
 
-/* Callback used when a row in the shortcuts list is activated */
+/* Opens the folder or volume at the specified index in the shortcuts list */
 static void
-shortcuts_row_activated_cb (GtkTreeView           *tree_view,
-                           GtkTreePath           *path,
-                           GtkTreeViewColumn     *column,
-                           GtkFileChooserDefault *impl)
+shortcuts_activate_item (GtkFileChooserDefault *impl,
+                        int                    item_num)
 {
+  GtkTreePath *path;
+  gboolean result;
   GtkTreeIter iter;
-  int selected, start_row;
   gpointer data;
+  int start_row;
 
-  if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->shortcuts_model), &iter, path))
+  if (item_num == shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR)
+      || item_num == shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR))
     return;
 
-  selected = *gtk_tree_path_get_indices (path);
+  path = gtk_tree_path_new_from_indices (item_num, -1);
+  result = gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->shortcuts_model), &iter, path);
+  gtk_tree_path_free (path);
 
-  if (selected == shortcuts_get_index (impl, SHORTCUTS_SEPARATOR))
+  if (!result)
     return;
 
   gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &data, -1);
 
   start_row = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
-  if (selected >= start_row && selected < start_row + impl->num_volumes)
+  if ((item_num >= start_row && item_num < start_row + impl->num_volumes)
+      || (item_num == shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER) && impl->shortcuts_current_folder_is_volume))
     {
       GtkFileSystemVolume *volume;
 
@@ -3153,13 +4585,41 @@ shortcuts_row_activated_cb (GtkTreeView           *tree_view,
     }
   else
     {
-      GtkFilePath *file_path;
+      const GtkFilePath *file_path;
 
       file_path = data;
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+      change_folder_and_display_error (impl, file_path);
     }
 }
 
+/* Callback used when a row in the shortcuts list is activated */
+static void
+shortcuts_row_activated_cb (GtkTreeView           *tree_view,
+                           GtkTreePath           *path,
+                           GtkTreeViewColumn     *column,
+                           GtkFileChooserDefault *impl)
+{
+  int selected;
+  GtkTreeIter iter;
+  GtkTreeIter child_iter;
+  GtkTreePath *child_path;
+
+  if (!gtk_tree_model_get_iter (impl->shortcuts_filter_model, &iter, path))
+    return;
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
+                                                   &child_iter,
+                                                   &iter);
+  child_path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &child_iter);
+  if (!child_path)
+    return;
+
+  selected = *gtk_tree_path_get_indices (child_path);
+  gtk_tree_path_free (child_path);
+
+  shortcuts_activate_item (impl, selected);
+}
+
 static gboolean
 shortcuts_select_func  (GtkTreeSelection  *selection,
                        GtkTreeModel      *model,
@@ -3169,7 +4629,7 @@ shortcuts_select_func  (GtkTreeSelection  *selection,
 {
   GtkFileChooserDefault *impl = data;
 
-  return (*gtk_tree_path_get_indices (path) != shortcuts_get_index (impl, SHORTCUTS_SEPARATOR));
+  return (*gtk_tree_path_get_indices (path) != shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR));
 }
 
 static void
@@ -3184,7 +4644,7 @@ list_selection_changed (GtkTreeSelection      *selection,
       const GtkFileInfo *info;
 
       g_assert (!impl->select_multiple);
-      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->list));
+      selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
       if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
        return;
 
@@ -3192,7 +4652,7 @@ list_selection_changed (GtkTreeSelection      *selection,
                                                      &child_iter,
                                                      &iter);
 
-      info = _gtk_file_system_model_get_info (impl->list_model, &child_iter);
+      info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
       if (!info)
        return; /* We are on the editable row for New Folder */
     }
@@ -3219,14 +4679,14 @@ list_row_activated (GtkTreeView           *tree_view,
 
   gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
 
-  info = _gtk_file_system_model_get_info (impl->list_model, &child_iter);
+  info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
 
   if (gtk_file_info_get_is_folder (info))
     {
       const GtkFilePath *file_path;
 
-      file_path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+      file_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
+      change_folder_and_display_error (impl, file_path);
 
       return;
     }
@@ -3239,7 +4699,7 @@ path_bar_clicked (GtkPathBar            *path_bar,
                  GtkFilePath           *file_path,
                  GtkFileChooserDefault *impl)
 {
-  _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
+  change_folder_and_display_error (impl, file_path);
 }
 
 static const GtkFileInfo *
@@ -3252,25 +4712,7 @@ get_list_file_info (GtkFileChooserDefault *impl,
                                                  &child_iter,
                                                  iter);
 
-  return _gtk_file_system_model_get_info (impl->list_model, &child_iter);
-}
-
-static void
-tree_name_data_func (GtkTreeViewColumn *tree_column,
-                    GtkCellRenderer   *cell,
-                    GtkTreeModel      *tree_model,
-                    GtkTreeIter       *iter,
-                    gpointer           data)
-{
-  GtkFileChooserDefault *impl = data;
-  const GtkFileInfo *info = _gtk_file_system_model_get_info (impl->tree_model, iter);
-
-  if (info)
-    {
-      g_object_set (cell,
-                   "text", gtk_file_info_get_display_name (info),
-                   NULL);
-    }
+  return _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
 }
 
 static void
@@ -3288,12 +4730,13 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
   gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
                                                  &child_iter,
                                                  iter);
-  path = _gtk_file_system_model_get_path (impl->list_model, &child_iter);
+  path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
   if (!path)
     return;
 
   /* FIXME: NULL GError */
-  pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl), ICON_SIZE, NULL);
+  pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
+                                       impl->icon_size, NULL);
   g_object_set (cell,
                "pixbuf", pixbuf,
                NULL);
@@ -3302,16 +4745,6 @@ list_icon_data_func (GtkTreeViewColumn *tree_column,
     g_object_unref (pixbuf);
 }
 
-/* Sets a cellrenderer's text, making it bold if the GtkFileInfo is a folder */
-static void
-set_cell_text_bold_if_folder (const GtkFileInfo *info, GtkCellRenderer *cell, const char *text)
-{
-  g_object_set (cell,
-               "text", text,
-               "weight", gtk_file_info_get_is_folder (info) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
-               NULL);
-}
-
 static void
 list_name_data_func (GtkTreeViewColumn *tree_column,
                     GtkCellRenderer   *cell,
@@ -3330,7 +4763,9 @@ list_name_data_func (GtkTreeViewColumn *tree_column,
       return;
     }
 
-  set_cell_text_bold_if_folder (info, cell, gtk_file_info_get_display_name (info));
+  g_object_set (cell,
+               "text", gtk_file_info_get_display_name (info),
+               NULL);
 }
 
 #if 0
@@ -3413,13 +4848,15 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
       if (days_diff > 1 && days_diff < 7)
        format = "%A"; /* Days from last week */
       else
-       format = _("%d/%b/%Y"); /* Any other date */
+       format = "%x"; /* Any other date */
 
       if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
        strcpy (buf, _("Unknown"));
     }
 
-  set_cell_text_bold_if_folder (info, cell, buf);
+  g_object_set (cell,
+               "text", buf,
+               NULL);
 }
 
 GtkWidget *
@@ -3436,6 +4873,8 @@ location_entry_create (GtkFileChooserDefault *impl)
   GtkWidget *entry;
 
   entry = _gtk_file_chooser_entry_new ();
+  /* Pick a good width for the entry */
+  gtk_entry_set_width_chars (GTK_ENTRY (entry), 30);
   gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
   _gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (entry), impl->file_system);
   _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (entry), impl->current_folder);
@@ -3443,7 +4882,7 @@ location_entry_create (GtkFileChooserDefault *impl)
   return GTK_WIDGET (entry);
 }
 
-static void
+static gboolean
 update_from_entry (GtkFileChooserDefault *impl,
                   GtkWindow             *parent,
                   GtkFileChooserEntry   *chooser_entry)
@@ -3458,20 +4897,20 @@ update_from_entry (GtkFileChooserDefault *impl,
     {
       error_message_with_parent (parent,
                                 _("Cannot change to the folder you specified as it is an invalid path."));
-      return;
+      return FALSE;
     }
 
   if (file_part[0] == '\0')
-    {
-      _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), folder_path);
-      return;
-    }
+    return change_folder_and_display_error (impl, folder_path);
   else
     {
       GtkFileFolder *folder = NULL;
       GtkFilePath *subfolder_path = NULL;
       GtkFileInfo *info = NULL;
       GError *error;
+      gboolean result;
+
+      result = FALSE;
 
       /* If the file part is non-empty, we need to figure out if it refers to a
        * folder within folder. We could optimize the case here where the folder
@@ -3484,7 +4923,7 @@ update_from_entry (GtkFileChooserDefault *impl,
       if (!folder)
        {
          error_getting_info_dialog (impl, folder_path, error);
-         return;
+         goto out;
        }
 
       error = NULL;
@@ -3493,15 +4932,16 @@ update_from_entry (GtkFileChooserDefault *impl,
       if (!subfolder_path)
        {
          char *msg;
+         char *uri;
 
+         uri = gtk_file_system_path_to_uri (impl->file_system, folder_path);
          msg = g_strdup_printf (_("Could not build file name from '%s' and '%s':\n%s"),
-                                gtk_file_path_get_string (folder_path),
-                                file_part,
+                                uri, file_part,
                                 error->message);
          error_message (impl, msg);
+         g_free (uri);
          g_free (msg);
-         g_object_unref (folder);
-         return;
+         goto out;
        }
 
       error = NULL;
@@ -3509,29 +4949,48 @@ update_from_entry (GtkFileChooserDefault *impl,
 
       if (!info)
        {
-#if 0
-         if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+         if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+             || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
            {
-             g_object_unref (folder);
-             gtk_file_path_free (subfolder_path);
-             return;
+             if (!change_folder_and_display_error (impl, folder_path))
+               goto out;
+
+             gtk_file_chooser_default_set_current_name (GTK_FILE_CHOOSER (impl), file_part);
            }
-#endif
-         error_getting_info_dialog (impl, subfolder_path, error);
-         g_object_unref (folder);
-         gtk_file_path_free (subfolder_path);
-         return;
+         else
+           error_getting_info_dialog (impl, subfolder_path, error);
+
+         goto out;
        }
 
       if (gtk_file_info_get_is_folder (info))
-       _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+       result = change_folder_and_display_error (impl, subfolder_path);
       else
-       _gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path);
+       {
+         GError *error;
+
+         error = NULL;
+         result = _gtk_file_chooser_select_path (GTK_FILE_CHOOSER (impl), subfolder_path, &error);
+         if (!result)
+           error_dialog (impl,
+                         _("Could not select %s:\n%s"),
+                         subfolder_path, error);
+       }
+
+    out:
+
+      if (folder)
+       g_object_unref (folder);
 
-      g_object_unref (folder);
       gtk_file_path_free (subfolder_path);
-      gtk_file_info_free (info);
+
+      if (info)
+       gtk_file_info_free (info);
+
+      return result;
     }
+
+  g_assert_not_reached ();
 }
 
 static void
@@ -3542,6 +5001,8 @@ location_popup_handler (GtkFileChooserDefault *impl)
   GtkWidget *hbox;
   GtkWidget *label;
   GtkWidget *entry;
+  gboolean refocus;
+  char *title;
 
   /* Create dialog */
 
@@ -3549,7 +5010,19 @@ location_popup_handler (GtkFileChooserDefault *impl)
   if (!GTK_WIDGET_TOPLEVEL (toplevel))
     toplevel = NULL;
 
-  dialog = gtk_dialog_new_with_buttons (_("Open Location"),
+  if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+      || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+    {
+      title = _("Open Location");
+    }
+  else
+    {
+      g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+               || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+      title = ""; /* FIXME: #137272, fix for 2.4.1 */
+    }
+
+  dialog = gtk_dialog_new_with_buttons (title,
                                        GTK_WINDOW (toplevel),
                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
                                        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -3574,8 +5047,36 @@ location_popup_handler (GtkFileChooserDefault *impl)
   /* Run */
 
   gtk_widget_show_all (dialog);
+
+  refocus = TRUE;
+
   if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
-    update_from_entry (impl, GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ENTRY (entry));
+    {
+      if (update_from_entry (impl, GTK_WINDOW (dialog), GTK_FILE_CHOOSER_ENTRY (entry)))
+       {
+         if (impl->action == GTK_FILE_CHOOSER_ACTION_OPEN
+             || impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+           {
+             gtk_widget_grab_focus (impl->browse_files_tree_view);
+           }
+         else
+           {
+             g_assert (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+                       || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+             gtk_widget_grab_focus (impl->save_file_name_entry);
+           }
+         refocus = FALSE;
+       }
+    }
+
+  if (refocus)
+    {
+      GtkWidget *toplevel;
+
+      toplevel = gtk_widget_get_toplevel (GTK_WIDGET (impl));
+      if (GTK_WIDGET_TOPLEVEL (toplevel) && GTK_WINDOW (toplevel)->focus_widget)
+       gtk_widget_grab_focus (GTK_WINDOW (toplevel)->focus_widget);
+    }
 
   gtk_widget_destroy (dialog);
 }
@@ -3584,35 +5085,115 @@ location_popup_handler (GtkFileChooserDefault *impl)
 static void
 up_folder_handler (GtkFileChooserDefault *impl)
 {
-  GtkFilePath *parent_path;
-  GError *error;
+  _gtk_path_bar_up (GTK_PATH_BAR (impl->browse_path_bar));
+}
 
-  error = NULL;
-  if (gtk_file_system_get_parent (impl->file_system, impl->current_folder, &parent_path, &error))
-    {
-      if (parent_path) /* If we were on a root, parent_path will be NULL */
-       {
-         _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), parent_path);
-         gtk_file_path_free (parent_path);
-       }
-    }
-  else
-    error_dialog (impl,
-                 _("Could not go to the parent folder of %s:\n%s"),
-                 impl->current_folder,
-                 error);
+/* Handler for the "down-folder" keybinding signal */
+static void
+down_folder_handler (GtkFileChooserDefault *impl)
+{
+  _gtk_path_bar_down (GTK_PATH_BAR (impl->browse_path_bar));
 }
 
 /* Handler for the "home-folder" keybinding signal */
 static void
 home_folder_handler (GtkFileChooserDefault *impl)
 {
-  const char *home;
+  int pos;
+  GtkTreeIter iter;
+  GtkFilePath *path;
 
-  /* Should we pull this information from impl->has_home and the shortcuts data
-   * instead?  Sounds like a bit of overkill...
-   */
+  if (!impl->has_home)
+    return; /* Should we put up an error dialog? */
 
-  home = g_get_home_dir ();
-  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (impl), home);
+  pos = shortcuts_get_index (impl, SHORTCUTS_HOME);
+  if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
+    g_assert_not_reached ();
+
+  gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter, SHORTCUTS_COL_PATH, &path, -1);
+  g_assert (path != NULL);
+
+  change_folder_and_display_error (impl, path);
+}
+
+\f
+
+/* Drag and drop interfaces */
+
+static void
+shortcuts_model_filter_class_init (ShortcutsModelFilterClass *class)
+{
+}
+
+static void
+shortcuts_model_filter_init (ShortcutsModelFilter *model)
+{
+  model->impl = NULL;
+}
+
+/* GtkTreeDragSource::row_draggable implementation for the shortcuts filter model */
+static gboolean
+shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source,
+                                     GtkTreePath       *path)
+{
+  ShortcutsModelFilter *model;
+  int pos;
+  int bookmarks_pos;
+
+  model = SHORTCUTS_MODEL_FILTER (drag_source);
+
+  pos = *gtk_tree_path_get_indices (path);
+  bookmarks_pos = shortcuts_get_index (model->impl, SHORTCUTS_BOOKMARKS);
+
+  return (pos >= bookmarks_pos && pos < bookmarks_pos + model->impl->num_bookmarks);
+}
+
+/* GtkTreeDragSource::drag_data_get implementation for the shortcuts filter model */
+static gboolean
+shortcuts_model_filter_drag_data_get (GtkTreeDragSource *drag_source,
+                                     GtkTreePath       *path,
+                                     GtkSelectionData  *selection_data)
+{
+  ShortcutsModelFilter *model;
+
+  model = SHORTCUTS_MODEL_FILTER (drag_source);
+
+  /* FIXME */
+
+  return FALSE;
+}
+
+/* Fill the GtkTreeDragSourceIface vtable */
+static void
+shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface)
+{
+  iface->row_draggable = shortcuts_model_filter_row_draggable;
+  iface->drag_data_get = shortcuts_model_filter_drag_data_get;
+}
+
+#if 0
+/* Fill the GtkTreeDragDestIface vtable */
+static void
+shortcuts_model_filter_drag_dest_iface_init (GtkTreeDragDestIface *iface)
+{
+  iface->drag_data_received = shortcuts_model_filter_drag_data_received;
+  iface->row_drop_possible = shortcuts_model_filter_row_drop_possible;
+}
+#endif
+
+static GtkTreeModel *
+shortcuts_model_filter_new (GtkFileChooserDefault *impl,
+                           GtkTreeModel          *child_model,
+                           GtkTreePath           *root)
+{
+  ShortcutsModelFilter *model;
+
+  model = g_object_new (SHORTCUTS_MODEL_FILTER_TYPE,
+                       "child_model", child_model,
+                       "virtual_root", root,
+                       NULL);
+
+  model->impl = impl;
+
+  return GTK_TREE_MODEL (model);
 }