summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorTomas Frydrych <tf@openedhand.com>2007-02-09 13:16:38 +0000
committerTomas Frydrych <tf@openedhand.com>2007-02-09 13:16:38 +0000
commit19d07794eed15aad348bb6c8b4514936b49a421a (patch)
tree01197036b61759006f6dfefdbf4ec347bfb159d7 /meta
parent2f9b5a87f732dbe9cabab188596956e919638f47 (diff)
downloadopenembedded-core-19d07794eed15aad348bb6c8b4514936b49a421a.tar.gz
openembedded-core-19d07794eed15aad348bb6c8b4514936b49a421a.tar.bz2
openembedded-core-19d07794eed15aad348bb6c8b4514936b49a421a.tar.xz
openembedded-core-19d07794eed15aad348bb6c8b4514936b49a421a.zip
simplified filechooser dialog
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1266 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta')
-rw-r--r--meta/packages/gtk+/gtk+-2.6.8/filechooser-default.patch5152
-rw-r--r--meta/packages/gtk+/gtk+-2.6.8/filechooser-respect-style.patch77
-rw-r--r--meta/packages/gtk+/gtk+_2.6.8.bb6
3 files changed, 5233 insertions, 2 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.8/filechooser-default.patch b/meta/packages/gtk+/gtk+-2.6.8/filechooser-default.patch
new file mode 100644
index 000000000..d4534212a
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.8/filechooser-default.patch
@@ -0,0 +1,5152 @@
+--- gtk+-2.6.8/gtk/gtkfilechooserdefault.c.orig 2007-02-09 12:28:31.000000000 +0000
++++ gtk+-2.6.8/gtk/gtkfilechooserdefault.c 2007-02-09 12:28:31.000000000 +0000
+@@ -31,7 +31,6 @@
+ #include "gtkcombobox.h"
+ #include "gtkentry.h"
+ #include "gtkeventbox.h"
+-#include "gtkexpander.h"
+ #include "gtkfilechooserdefault.h"
+ #include "gtkfilechooserembed.h"
+ #include "gtkfilechooserentry.h"
+@@ -50,7 +49,6 @@
+ #include "gtkmarshalers.h"
+ #include "gtkmenuitem.h"
+ #include "gtkmessagedialog.h"
+-#include "gtkpathbar.h"
+ #include "gtkprivate.h"
+ #include "gtkscrolledwindow.h"
+ #include "gtkseparatormenuitem.h"
+@@ -79,18 +77,23 @@
+ #include <string.h>
+ #include <time.h>
+
++#define DEFAULT_SPACING 5
++
++#define GTK26
+ typedef struct _GtkFileChooserDefaultClass GtkFileChooserDefaultClass;
+
+ #define GTK_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT, 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))
+
++#ifdef GTK26
+ typedef enum {
+ LOAD_EMPTY, /* There is no model */
+ LOAD_PRELOAD, /* Model is loading and a timer is running; model isn't inserted into the tree yet */
+ LOAD_LOADING, /* Timeout expired, model is inserted into the tree, but not fully loaded yet */
+ LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
+ } LoadState;
++#endif
+
+ #define MAX_LOADING_TIME 500
+
+@@ -109,63 +112,33 @@
+
+ /* Save mode widgets */
+ GtkWidget *save_widgets;
+-
+ GtkWidget *save_file_name_entry;
+- GtkWidget *save_folder_label;
+- GtkWidget *save_folder_combo;
+- 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_files_popup_menu;
+- GtkWidget *browse_files_popup_menu_add_shortcut_item;
+- GtkWidget *browse_files_popup_menu_hidden_files_item;
+ GtkWidget *browse_new_folder_button;
+- GtkWidget *browse_path_bar;
+-
++ GtkWidget *bar;
++ GtkWidget * up_button;
++
+ GtkFileSystemModel *browse_files_model;
+
+- GtkWidget *filter_combo_hbox;
+- GtkWidget *filter_combo;
+- GtkWidget *preview_box;
+- GtkWidget *preview_label;
+- GtkWidget *preview_widget;
+- GtkWidget *extra_align;
+- GtkWidget *extra_widget;
+-
+- GtkListStore *shortcuts_model;
+- GtkTreeModel *shortcuts_filter_model;
+-
+ GtkTreeModelSort *sort_model;
+
+ LoadState load_state;
+ guint load_timeout_id;
+
+ GSList *pending_select_paths;
+-
+- GtkFileFilter *current_filter;
+- GSList *filters;
+-
++ GSList * path_history;
++
+ GtkTooltips *tooltips;
+
+- gboolean has_home;
+- gboolean has_desktop;
+-
+ int num_volumes;
+- int num_shortcuts;
+- int num_bookmarks;
+
+ gulong volumes_changed_id;
+- gulong bookmarks_changed_id;
+
+ GtkFilePath *current_volume_path;
+ GtkFilePath *current_folder;
+- GtkFilePath *preview_path;
+- char *preview_display_name;
+
+ GtkTreeViewColumn *list_name_column;
+ GtkCellRenderer *list_name_renderer;
+@@ -179,25 +152,15 @@
+ gulong toplevel_set_focus_id;
+ GtkWidget *toplevel_last_focus_widget;
+
+-#if 0
+- GdkDragContext *shortcuts_drag_context;
+- GSource *shortcuts_drag_outside_idle;
+-#endif
+-
++ gchar * root_folder;
++
+ /* Flags */
+
+ 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;
+-
+-#if 0
+- guint shortcuts_drag_outside : 1;
+-#endif
+ };
+
+ /* Signal IDs */
+@@ -211,17 +174,6 @@
+
+ static guint signals[LAST_SIGNAL] = { 0 };
+
+-/* Column numbers for the shortcuts tree. Keep these in sync with shortcuts_model_create() */
+-enum {
+- SHORTCUTS_COL_PIXBUF,
+- SHORTCUTS_COL_NAME,
+- SHORTCUTS_COL_DATA,
+- SHORTCUTS_COL_IS_VOLUME,
+- SHORTCUTS_COL_REMOVABLE,
+- SHORTCUTS_COL_PIXBUF_VISIBLE,
+- SHORTCUTS_COL_NUM_COLUMNS
+-};
+-
+ /* Column numbers for the file list */
+ enum {
+ FILE_LIST_COL_NAME,
+@@ -236,23 +188,6 @@
+ TEXT_URI_LIST
+ };
+
+-/* Target types for dragging from the shortcuts list */
+-static const 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 const 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 const GtkTargetEntry file_list_source_targets[] = {
+ { "text/uri-list", 0, TEXT_URI_LIST }
+@@ -261,22 +196,10 @@
+ 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 {
+- SHORTCUTS_HOME,
+- SHORTCUTS_DESKTOP,
+- SHORTCUTS_VOLUMES,
+- SHORTCUTS_SHORTCUTS,
+- SHORTCUTS_BOOKMARKS_SEPARATOR,
+- SHORTCUTS_BOOKMARKS,
+- SHORTCUTS_CURRENT_FOLDER_SEPARATOR,
+- SHORTCUTS_CURRENT_FOLDER
+-} ShortcutsIndex;
+-
+ /* Icon size for if we can't get it from the theme */
+ #define FALLBACK_ICON_SIZE 16
+
+-#define PREVIEW_HBOX_SPACING 12
++#define LIST_HBOX_SPACING DEFAULT_SPACING
+ #define NUM_LINES 40
+ #define NUM_CHARS 60
+
+@@ -335,7 +258,6 @@
+ const GtkFilePath *path,
+ 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);
+@@ -352,37 +274,6 @@
+ static void home_folder_handler (GtkFileChooserDefault *impl);
+ static void update_appearance (GtkFileChooserDefault *impl);
+
+-static void set_current_filter (GtkFileChooserDefault *impl,
+- GtkFileFilter *filter);
+-static void check_preview_change (GtkFileChooserDefault *impl);
+-
+-static void filter_combo_changed (GtkComboBox *combo_box,
+- GtkFileChooserDefault *impl);
+-static void shortcuts_row_activated_cb (GtkTreeView *tree_view,
+- GtkTreePath *path,
+- GtkTreeViewColumn *column,
+- GtkFileChooserDefault *impl);
+-
+-static gboolean shortcuts_key_press_event_cb (GtkWidget *widget,
+- GdkEventKey *event,
+- GtkFileChooserDefault *impl);
+-
+-static gboolean shortcuts_select_func (GtkTreeSelection *selection,
+- GtkTreeModel *model,
+- GtkTreePath *path,
+- gboolean path_currently_selected,
+- gpointer data);
+-static gboolean shortcuts_get_selected (GtkFileChooserDefault *impl,
+- GtkTreeIter *iter);
+-static void shortcuts_activate_iter (GtkFileChooserDefault *impl,
+- GtkTreeIter *iter);
+-static int shortcuts_get_index (GtkFileChooserDefault *impl,
+- ShortcutsIndex where);
+-static int shortcut_find_position (GtkFileChooserDefault *impl,
+- const GtkFilePath *path);
+-
+-static void bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl);
+-
+ static gboolean list_select_func (GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+@@ -401,16 +292,6 @@
+ GtkTreeIter *iter,
+ gpointer user_data);
+
+-static void path_bar_clicked (GtkPathBar *path_bar,
+- GtkFilePath *file_path,
+- gboolean child_is_hidden,
+- GtkFileChooserDefault *impl);
+-
+-static void add_bookmark_button_clicked_cb (GtkButton *button,
+- GtkFileChooserDefault *impl);
+-static void remove_bookmark_button_clicked_cb (GtkButton *button,
+- GtkFileChooserDefault *impl);
+-
+ static void list_icon_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+@@ -441,36 +322,6 @@
+
+ static GObjectClass *parent_class;
+
+-
+-
+-/* 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);
+-
+-
+
+ GType
+ _gtk_file_chooser_default_get_type (void)
+@@ -520,6 +371,11 @@
+ return file_chooser_default_type;
+ }
+
++enum
++{
++ GTK_FILE_CHOOSER_PROP_ROOT_FOLDER = GTK_FILE_CHOOSER_PROP_LAST + 1,
++};
++
+ static void
+ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
+ {
+@@ -617,6 +473,14 @@
+ "home-folder",
+ 0);
+
++ g_object_class_install_property (gobject_class,
++ GTK_FILE_CHOOSER_PROP_ROOT_FOLDER,
++ g_param_spec_string ("root-folder",
++ P_("File System Root"),
++ P_("Root folder for the file system below which the user should not be able to switch"),
++ NULL,
++ G_PARAM_WRITABLE));
++
+ _gtk_file_chooser_install_properties (gobject_class);
+
+ gtk_settings_install_property (g_param_spec_string ("gtk-file-chooser-backend",
+@@ -634,17 +498,19 @@
+ iface->select_all = gtk_file_chooser_default_select_all;
+ iface->unselect_all = gtk_file_chooser_default_unselect_all;
+ iface->get_paths = gtk_file_chooser_default_get_paths;
+- iface->get_preview_path = gtk_file_chooser_default_get_preview_path;
+ iface->get_file_system = gtk_file_chooser_default_get_file_system;
+ iface->set_current_folder = gtk_file_chooser_default_set_current_folder;
+ iface->get_current_folder = gtk_file_chooser_default_get_current_folder;
+ iface->set_current_name = gtk_file_chooser_default_set_current_name;
++
++ /* these are only stubs */
++ iface->get_preview_path = gtk_file_chooser_default_get_preview_path;
+ iface->add_filter = gtk_file_chooser_default_add_filter;
+ iface->remove_filter = gtk_file_chooser_default_remove_filter;
+ iface->list_filters = gtk_file_chooser_default_list_filters;
+ iface->add_shortcut_folder = gtk_file_chooser_default_add_shortcut_folder;
+ iface->remove_shortcut_folder = gtk_file_chooser_default_remove_shortcut_folder;
+- iface->list_shortcut_folders = gtk_file_chooser_default_list_shortcut_folders;
++
+ }
+
+ static void
+@@ -659,71 +525,22 @@
+ gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
+ {
+ 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;
+ impl->load_state = LOAD_EMPTY;
+ impl->pending_select_paths = NULL;
+-
++ impl->path_history = NULL;
++
+ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (impl), TRUE);
+- gtk_box_set_spacing (GTK_BOX (impl), 12);
++ gtk_box_set_spacing (GTK_BOX (impl), DEFAULT_SPACING);
+
+ impl->tooltips = gtk_tooltips_new ();
+ g_object_ref (impl->tooltips);
+ gtk_object_sink (GTK_OBJECT (impl->tooltips));
+-}
+-
+-/* Frees the data columns for the specified iter in the shortcuts model*/
+-static void
+-shortcuts_free_row_data (GtkFileChooserDefault *impl,
+- GtkTreeIter *iter)
+-{
+- gpointer col_data;
+- gboolean is_volume;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+- if (!col_data)
+- return;
+-
+- if (is_volume)
+- {
+- GtkFileSystemVolume *volume;
+-
+- volume = col_data;
+- gtk_file_system_volume_free (impl->file_system, volume);
+- }
+- else
+- {
+- GtkFilePath *path;
+-
+- path = col_data;
+- gtk_file_path_free (path);
+- }
+-}
+-
+-/* Frees all the data columns in the shortcuts model */
+-static void
+-shortcuts_free (GtkFileChooserDefault *impl)
+-{
+- GtkTreeIter iter;
+-
+- if (!impl->shortcuts_model)
+- return;
+-
+- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+- do
+- {
+- shortcuts_free_row_data (impl, &iter);
+- }
+- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter));
+
+- g_object_unref (impl->shortcuts_model);
+- impl->shortcuts_model = NULL;
++ if (!impl->root_folder)
++ impl->root_folder = g_strdup ("/");
+ }
+
+ static void
+@@ -743,6 +560,7 @@
+ impl->pending_select_paths = NULL;
+ }
+
++
+ static void
+ pending_select_paths_add (GtkFileChooserDefault *impl,
+ const GtkFilePath *path)
+@@ -782,45 +600,40 @@
+ }
+
+ static void
+-gtk_file_chooser_default_finalize (GObject *object)
++path_history_free (GtkFileChooserDefault *impl)
+ {
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
+ GSList *l;
+
+- if (impl->shortcuts_filter_model)
+- g_object_unref (impl->shortcuts_filter_model);
++ for (l = impl->path_history; l; l = l->next)
++ {
++ GtkFilePath *path;
++
++ path = l->data;
++ gtk_file_path_free (path);
++ }
++
++ g_slist_free (impl->path_history);
++ impl->path_history = NULL;
++}
+
+- shortcuts_free (impl);
++static void
++gtk_file_chooser_default_finalize (GObject *object)
++{
++ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
+
+ g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
+ impl->volumes_changed_id = 0;
+- g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
+- impl->bookmarks_changed_id = 0;
+ g_object_unref (impl->file_system);
+
+- for (l = impl->filters; l; l = l->next)
+- {
+- GtkFileFilter *filter;
+-
+- filter = GTK_FILE_FILTER (l->data);
+- g_object_unref (filter);
+- }
+- g_slist_free (impl->filters);
+-
+- if (impl->current_filter)
+- g_object_unref (impl->current_filter);
+-
+ if (impl->current_volume_path)
+ gtk_file_path_free (impl->current_volume_path);
+
+ if (impl->current_folder)
+ gtk_file_path_free (impl->current_folder);
+
+- if (impl->preview_path)
+- gtk_file_path_free (impl->preview_path);
+-
+ pending_select_paths_free (impl);
+-
++ path_history_free (impl);
++
+ load_remove_timer (impl);
+
+ /* Free all the Models we have */
+@@ -830,12 +643,12 @@
+ if (impl->sort_model)
+ g_object_unref (impl->sort_model);
+
+- g_free (impl->preview_display_name);
+-
+ g_free (impl->edited_new_text);
+
+ g_object_unref (impl->tooltips);
+
++ g_free (impl->root_folder);
++
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+ }
+
+@@ -916,28 +729,6 @@
+ path, error);
+ }
+
+-/* Shows an error dialog about not being able to add a bookmark */
+-static void
+-error_adding_bookmark_dialog (GtkFileChooserDefault *impl,
+- const GtkFilePath *path,
+- GError *error)
+-{
+- error_dialog (impl,
+- _("Could not add a bookmark"),
+- path, error);
+-}
+-
+-/* Shows an error dialog about not being able to remove a bookmark */
+-static void
+-error_removing_bookmark_dialog (GtkFileChooserDefault *impl,
+- const GtkFilePath *path,
+- GError *error)
+-{
+- error_dialog (impl,
+- _("Could not remove bookmark"),
+- path, error);
+-}
+-
+ /* Shows an error dialog about not being able to create a folder */
+ static void
+ error_creating_folder_dialog (GtkFileChooserDefault *impl,
+@@ -949,21 +740,6 @@
+ path, error);
+ }
+
+-/* Shows an error about not being able to create a folder because a file with
+- * the same name is already there.
+- */
+-static void
+-error_creating_folder_over_existing_file_dialog (GtkFileChooserDefault *impl,
+- const GtkFilePath *path,
+- GError *error)
+-{
+- error_dialog (impl,
+- _("The folder could not be created, as a file with the same name "
+- "already exists. Try using a different name for the folder, "
+- "or rename the file first."),
+- path, error);
+-}
+-
+ /* Shows an error dialog about not being able to create a filename */
+ static void
+ error_building_filename_dialog (GtkFileChooserDefault *impl,
+@@ -993,6 +769,7 @@
+ GError *error;
+ gboolean result;
+ GtkFilePath *path_copy;
++ gchar * file_name;
+
+ /* We copy the path because of this case:
+ *
+@@ -1005,6 +782,29 @@
+
+ path_copy = gtk_file_path_copy (path);
+
++ file_name = gtk_file_system_path_to_filename (impl->file_system, path_copy);
++
++ /* refuse to change below the root */
++ if (file_name && impl->root_folder &&
++ strcmp (file_name, impl->root_folder) &&
++ !strncmp (file_name, impl->root_folder, strlen (file_name)))
++ {
++
++ gtk_file_path_free (path_copy);
++ g_free (file_name);
++ return 0;
++ }
++ else if (file_name && impl->root_folder &&
++ !strcmp (file_name, impl->root_folder))
++ {
++ gtk_widget_set_sensitive (impl->up_button, FALSE);
++ }
++ else
++ {
++ gtk_widget_set_sensitive (impl->up_button, TRUE);
++ }
++
++
+ error = NULL;
+ result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path_copy, &error);
+
+@@ -1012,2009 +812,234 @@
+ error_changing_folder_dialog (impl, path_copy, error);
+
+ gtk_file_path_free (path_copy);
+-
++ g_free (file_name);
++
+ 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_label_set_ellipsize (GTK_LABEL (impl->preview_label), PANGO_ELLIPSIZE_MIDDLE);
+- 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_box);
+- else
+- gtk_widget_hide (impl->preview_box);
+-
+- g_signal_emit_by_name (impl, "default-size-changed");
+-}
+
+-static void
+-set_preview_widget (GtkFileChooserDefault *impl,
+- GtkWidget *preview_widget)
++/* Returns whether a path is a folder */
++static gboolean
++check_is_folder (GtkFileSystem *file_system,
++ const GtkFilePath *path,
++ GError **error)
+ {
+- if (preview_widget == impl->preview_widget)
+- return;
+-
+- if (impl->preview_widget)
+- gtk_container_remove (GTK_CONTAINER (impl->preview_box),
+- impl->preview_widget);
+-
+- impl->preview_widget = preview_widget;
+- if (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);
+- }
++ GtkFileFolder *folder;
++#ifdef GTK26
++ folder = gtk_file_system_get_folder (file_system, path, 0, error);
++#else
++ folder = gtk_file_system_get_folder (file_system, path, 0, NULL, NULL);
++#endif
++ if (!folder)
++ return FALSE;
+
+- update_preview_widget_visibility (impl);
++ g_object_unref (folder);
++ return TRUE;
+ }
+
+-/* Re-reads all the icons for the shortcuts, used when the theme changes */
++
++/* Callback used when the "New Folder" button is clicked */
+ static void
+-shortcuts_reload_icons (GtkFileChooserDefault *impl)
++new_folder_button_clicked (GtkButton *button,
++ GtkFileChooserDefault *impl)
+ {
+ GtkTreeIter iter;
++ GtkTreePath *path;
+
+- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+- return;
++ if (!impl->browse_files_model)
++ return; /* FIXME: this sucks. Disable the New Folder button or something. */
+
+- do {
+- gpointer data;
+- gboolean is_volume;
+- gboolean pixbuf_visible;
+- GdkPixbuf *pixbuf;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_DATA, &data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- SHORTCUTS_COL_PIXBUF_VISIBLE, &pixbuf_visible,
+- -1);
++ /* Prevent button from being clicked twice */
++ gtk_widget_set_sensitive (impl->browse_new_folder_button, FALSE);
+
+- if (pixbuf_visible && data)
+- {
+- if (is_volume)
+- {
+- GtkFileSystemVolume *volume;
++ _gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
+
+- 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 = 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);
+
+- path = data;
+- pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
+- impl->icon_size, NULL);
+- }
++ 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);
+
+- gtk_list_store_set (impl->shortcuts_model, &iter,
+- SHORTCUTS_COL_PIXBUF, pixbuf,
+- -1);
+- if (pixbuf)
+- g_object_unref (pixbuf);
+- }
+- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
++ gtk_tree_path_free (path);
+ }
+
+-static void
+-shortcuts_find_folder (GtkFileChooserDefault *impl,
+- GtkFilePath *folder)
++/* Idle handler for creating a new folder after editing its name cell, or for
++ * canceling the editing.
++ */
++static gboolean
++edited_idle_cb (GtkFileChooserDefault *impl)
+ {
+- GtkTreeSelection *selection;
+- int pos;
+- GtkTreePath *path;
++ GDK_THREADS_ENTER ();
++
++ g_source_destroy (impl->edited_idle);
++ impl->edited_idle = NULL;
++
++ _gtk_file_system_model_remove_editable (impl->browse_files_model);
++ g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
+
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
++ gtk_widget_set_sensitive (impl->browse_new_folder_button, TRUE);
+
+- g_assert (folder != NULL);
+- pos = shortcut_find_position (impl, folder);
+- if (pos == -1)
++ if (impl->edited_new_text) /* not cancelled? */
+ {
+- 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);
+-}
++ GError *error;
++ GtkFilePath *file_path;
+
+-/* If a shortcut corresponds to the current folder, selects it */
+-static void
+-shortcuts_find_current_folder (GtkFileChooserDefault *impl)
+-{
+- shortcuts_find_folder (impl, impl->current_folder);
+-}
++ error = NULL;
++ file_path = gtk_file_system_make_path (impl->file_system, impl->current_folder, impl->edited_new_text,
++ &error);
++ if (file_path)
++ {
++ error = NULL;
++#ifdef GTK26
++ if (gtk_file_system_create_folder (impl->file_system, file_path, &error))
++#else
++ if (gtk_file_system_create_folder (impl->file_system, file_path, NULL, NULL))
++#endif
++ change_folder_and_display_error (impl, file_path);
++ else
++ error_creating_folder_dialog (impl, file_path, error);
+
+-/* Convenience function to get the display name and icon info for a path */
+-static GtkFileInfo *
+-get_file_info (GtkFileSystem *file_system,
+- const GtkFilePath *path,
+- gboolean name_only,
+- GError **error)
+-{
+- GtkFilePath *parent_path;
+- GtkFileFolder *parent_folder;
+- GtkFileInfo *info;
+- GError *tmp = NULL;
+-
+- parent_path = NULL;
+- info = NULL;
+-
+- if (!gtk_file_system_get_parent (file_system, path, &parent_path, &tmp))
+- goto out;
+-
+- parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
+- GTK_FILE_INFO_DISPLAY_NAME
+- | (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
+- &tmp);
+- if (!parent_folder)
+- goto out;
+-
+- info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, &tmp);
+- g_object_unref (parent_folder);
+-
+- out:
+- if (parent_path)
+- gtk_file_path_free (parent_path);
++ gtk_file_path_free (file_path);
++ }
++ else
++ error_creating_folder_dialog (impl, file_path, error);
+
+- if (tmp)
+- {
+- g_set_error (error,
+- GTK_FILE_CHOOSER_ERROR,
+- GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
+- _("Could not get information about '%s': %s"),
+- gtk_file_path_get_string (path),
+- tmp->message);
+- g_error_free (tmp);
++ g_free (impl->edited_new_text);
++ impl->edited_new_text = NULL;
+ }
+
+- return info;
++ GDK_THREADS_LEAVE ();
++
++ return FALSE;
+ }
+
+-/* 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, 0, error);
+- if (!folder)
+- return FALSE;
+-
+- g_object_unref (folder);
+- return TRUE;
+-}
+-
+-/* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
+- * inserts a volume. A position of -1 indicates the end of the tree.
+- */
+-static gboolean
+-shortcuts_insert_path (GtkFileChooserDefault *impl,
+- int pos,
+- gboolean is_volume,
+- GtkFileSystemVolume *volume,
+- const GtkFilePath *path,
+- const char *label,
+- gboolean removable,
+- GError **error)
+-{
+- char *label_copy;
+- GdkPixbuf *pixbuf;
+- gpointer data;
+- GtkTreeIter iter;
+-
+- if (is_volume)
+- {
+- 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),
+- impl->icon_size, NULL);
+- }
+- else
+- {
+- if (!check_is_folder (impl->file_system, path, error))
+- return FALSE;
+-
+- if (label)
+- label_copy = g_strdup (label);
+- else
+- {
+- GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
+-
+- if (!info)
+- return FALSE;
+-
+- label_copy = g_strdup (gtk_file_info_get_display_name (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)
+- gtk_list_store_append (impl->shortcuts_model, &iter);
+- else
+- gtk_list_store_insert (impl->shortcuts_model, &iter, pos);
+-
+- gtk_list_store_set (impl->shortcuts_model, &iter,
+- SHORTCUTS_COL_PIXBUF, pixbuf,
+- SHORTCUTS_COL_PIXBUF_VISIBLE, TRUE,
+- SHORTCUTS_COL_NAME, label_copy,
+- SHORTCUTS_COL_DATA, data,
+- SHORTCUTS_COL_IS_VOLUME, is_volume,
+- SHORTCUTS_COL_REMOVABLE, removable,
+- -1);
+-
+- g_free (label_copy);
+-
+- if (pixbuf)
+- g_object_unref (pixbuf);
+-
+- return TRUE;
+-}
+-
+-/* Appends an item for the user's home directory to the shortcuts model */
+-static void
+-shortcuts_append_home (GtkFileChooserDefault *impl)
+-{
+- const char *home;
+- GtkFilePath *home_path;
+- GError *error;
+-
+- home = g_get_home_dir ();
+- if (home == NULL)
+- return;
+-
+- home_path = gtk_file_system_filename_to_path (impl->file_system, home);
+-
+- error = NULL;
+- impl->has_home = shortcuts_insert_path (impl, -1, FALSE, NULL, home_path, _("Home"), FALSE, &error);
+- if (!impl->has_home)
+- error_getting_info_dialog (impl, home_path, error);
+-
+- gtk_file_path_free (home_path);
+-}
+-
+-/* Appends the ~/Desktop directory to the shortcuts model */
+-static void
+-shortcuts_append_desktop (GtkFileChooserDefault *impl)
+-{
+- char *name;
+- GtkFilePath *path;
+-
+-#ifdef G_OS_WIN32
+- name = _gtk_file_system_win32_get_desktop ();
+-#else
+- const char *home = g_get_home_dir ();
+- if (home == NULL)
+- return;
+-
+- name = g_build_filename (home, "Desktop", NULL);
+-#endif
+-
+- 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, _("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.
+- */
+-
+- gtk_file_path_free (path);
+-}
+-
+-/* Appends a list of GtkFilePath to the shortcuts model; returns how many were inserted */
+-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)
+- {
+- GtkFilePath *path;
+- GError *error;
+-
+- path = paths->data;
+- error = NULL;
+-
+- if (impl->local_only &&
+- !gtk_file_system_path_is_local (impl->file_system, path))
+- continue;
+-
+- /* 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++;
+- }
+-
+- return num_inserted;
+-}
+-
+-/* Returns the index for the corresponding item in the shortcuts bar */
+-static int
+-shortcuts_get_index (GtkFileChooserDefault *impl,
+- ShortcutsIndex where)
+-{
+- int n;
+-
+- n = 0;
+-
+- if (where == SHORTCUTS_HOME)
+- goto out;
+-
+- n += impl->has_home ? 1 : 0;
+-
+- if (where == SHORTCUTS_DESKTOP)
+- goto out;
+-
+- n += impl->has_desktop ? 1 : 0;
+-
+- if (where == SHORTCUTS_VOLUMES)
+- goto out;
+-
+- n += impl->num_volumes;
+-
+- if (where == SHORTCUTS_SHORTCUTS)
+- goto out;
+-
+- n += impl->num_shortcuts;
+-
+- if (where == SHORTCUTS_BOOKMARKS_SEPARATOR)
+- goto out;
+-
+- /* 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:
+-
+- return n;
+-}
+-
+-/* Removes the specified number of rows from the shortcuts list */
+-static void
+-shortcuts_remove_rows (GtkFileChooserDefault *impl,
+- int start_row,
+- int n_rows)
+-{
+- GtkTreePath *path;
+-
+- path = gtk_tree_path_new_from_indices (start_row, -1);
+-
+- for (; n_rows; n_rows--)
+- {
+- GtkTreeIter iter;
+-
+- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->shortcuts_model), &iter, path))
+- g_assert_not_reached ();
+-
+- shortcuts_free_row_data (impl, &iter);
+- gtk_list_store_remove (impl->shortcuts_model, &iter);
+- }
+-
+- gtk_tree_path_free (path);
+-}
+-
+-/* Adds all the file system volumes to the shortcuts model */
+-static void
+-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);
+- impl->num_volumes = 0;
+-
+- list = gtk_file_system_list_volumes (impl->file_system);
+-
+- n = 0;
+-
+- for (l = list; l; l = l->next)
+- {
+- GtkFileSystemVolume *volume;
+-
+- volume = l->data;
+-
+- 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;
+-}
+-
+-/* Inserts a separator node in the shortcuts list */
+-static void
+-shortcuts_insert_separator (GtkFileChooserDefault *impl,
+- ShortcutsIndex where)
+-{
+- GtkTreeIter 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_DATA, NULL,
+- -1);
+-}
+-
+-/* Updates the list of bookmarks */
+-static void
+-shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
+-{
+- GSList *bookmarks;
+- gboolean old_changing_folders;
+- GtkTreeIter iter;
+- GtkFilePath *list_selected = NULL;
+- GtkFilePath *combo_selected = NULL;
+- gboolean is_volume;
+- gpointer col_data;
+-
+- old_changing_folders = impl->changing_folder;
+- impl->changing_folder = TRUE;
+-
+- if (shortcuts_get_selected (impl, &iter))
+- {
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model),
+- &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+-
+- if (col_data && !is_volume)
+- list_selected = gtk_file_path_copy (col_data);
+- }
+-
+- if (impl->save_folder_combo &&
+- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (impl->save_folder_combo),
+- &iter))
+- {
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model),
+- &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+-
+- if (col_data && !is_volume)
+- combo_selected = gtk_file_path_copy (col_data);
+- }
+-
+- if (impl->num_bookmarks > 0)
+- shortcuts_remove_rows (impl,
+- shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR),
+- impl->num_bookmarks + 1);
+-
+- 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));
+-
+- if (list_selected)
+- {
+- shortcuts_find_folder (impl, list_selected);
+- gtk_file_path_free (list_selected);
+- }
+-
+- if (combo_selected)
+- {
+- gint pos;
+-
+- pos = shortcut_find_position (impl, combo_selected);
+- if (pos != -1)
+- gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo),
+- pos);
+- gtk_file_path_free (combo_selected);
+- }
+-
+- impl->changing_folder = old_changing_folders;
+-}
+-
+-/* Appends a separator and a row to the shortcuts list for the current folder */
+-static void
+-shortcuts_add_current_folder (GtkFileChooserDefault *impl)
+-{
+- int pos;
+- gboolean success;
+-
+- g_assert (!impl->shortcuts_current_folder_active);
+-
+- success = TRUE;
+-
+- g_assert (impl->current_folder != NULL);
+-
+- pos = shortcut_find_position (impl, impl->current_folder);
+- if (pos == -1)
+- {
+- GtkFileSystemVolume *volume;
+- GtkFilePath *base_path;
+-
+- /* 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);
+- if (success)
+- volume = NULL;
+- }
+- else
+- success = shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL);
+-
+- if (volume)
+- gtk_file_system_volume_free (impl->file_system, volume);
+-
+- if (base_path)
+- gtk_file_path_free (base_path);
+-
+- if (!success)
+- shortcuts_remove_rows (impl, pos - 1, 1); /* remove the separator */
+-
+- impl->shortcuts_current_folder_active = success;
+- }
+-
+- if (success)
+- gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos);
+-}
+-
+-/* 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);
+- 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, /* is the previous column a 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" button is clicked */
+-static void
+-new_folder_button_clicked (GtkButton *button,
+- GtkFileChooserDefault *impl)
+-{
+- GtkTreeIter iter;
+- GtkTreePath *path;
+-
+- if (!impl->browse_files_model)
+- return; /* FIXME: this sucks. Disable the New Folder button or something. */
+-
+- /* Prevent button from being clicked twice */
+- gtk_widget_set_sensitive (impl->browse_new_folder_button, FALSE);
+-
+- _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);
+-
+- gtk_tree_path_free (path);
+-}
+-
+-/* Idle handler for creating a new folder after editing its name cell, or for
+- * canceling the editing.
+- */
+-static gboolean
+-edited_idle_cb (GtkFileChooserDefault *impl)
+-{
+- GDK_THREADS_ENTER ();
+-
+- g_source_destroy (impl->edited_idle);
+- impl->edited_idle = NULL;
+-
+- _gtk_file_system_model_remove_editable (impl->browse_files_model);
+- g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
+-
+- gtk_widget_set_sensitive (impl->browse_new_folder_button, TRUE);
+-
+- if (impl->edited_new_text) /* not cancelled? */
+- {
+- GError *error;
+- GtkFilePath *file_path;
+-
+- error = NULL;
+- file_path = gtk_file_system_make_path (impl->file_system, impl->current_folder, impl->edited_new_text,
+- &error);
+- if (file_path)
+- {
+- error = NULL;
+- if (gtk_file_system_create_folder (impl->file_system, file_path, &error))
+- change_folder_and_display_error (impl, file_path);
+- else
+- error_creating_folder_dialog (impl, file_path, error);
+-
+- gtk_file_path_free (file_path);
+- }
+- else
+- error_creating_folder_dialog (impl, file_path, error);
+-
+- g_free (impl->edited_new_text);
+- impl->edited_new_text = NULL;
+- }
+-
+- GDK_THREADS_LEAVE ();
+-
+- return FALSE;
+-}
+-
+-static void
+-queue_edited_idle (GtkFileChooserDefault *impl,
+- const gchar *new_text)
+-{
+- /* We create the folder in an idle handler so that we don't modify the tree
+- * just now.
+- */
+-
+- g_assert (!impl->edited_idle);
+- g_assert (!impl->edited_new_text);
+-
+- impl->edited_idle = g_idle_source_new ();
+- g_source_set_closure (impl->edited_idle,
+- g_cclosure_new_object (G_CALLBACK (edited_idle_cb),
+- G_OBJECT (impl)));
+- g_source_attach (impl->edited_idle, NULL);
+-
+- if (new_text)
+- impl->edited_new_text = g_strdup (new_text);
+-}
+-
+-/* 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,
+- GtkFileChooserDefault *impl)
+-{
+- /* work around bug #154921 */
+- g_object_set (cell_renderer_text,
+- "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
+- queue_edited_idle (impl, new_text);
+-}
+-
+-/* Callback used from the text cell renderer when the new folder edition gets
+- * canceled.
+- */
+-static void
+-renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
+- GtkFileChooserDefault *impl)
+-{
+- /* work around bug #154921 */
+- g_object_set (cell_renderer_text,
+- "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
+- queue_edited_idle (impl, NULL);
+-}
+-
+-/* Creates the widgets for the filter combo box */
+-static GtkWidget *
+-filter_create (GtkFileChooserDefault *impl)
+-{
+- impl->filter_combo = gtk_combo_box_new_text ();
+- gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (impl->filter_combo), FALSE);
+-
+- g_signal_connect (impl->filter_combo, "changed",
+- G_CALLBACK (filter_combo_changed), impl);
+-
+- return impl->filter_combo;
+-}
+-
+-static GtkWidget *
+-button_new (GtkFileChooserDefault *impl,
+- const char *text,
+- const char *stock_id,
+- gboolean sensitive,
+- gboolean show,
+- GCallback callback)
+-{
+- GtkWidget *button;
+- GtkWidget *hbox;
+- GtkWidget *widget;
+- GtkWidget *align;
+-
+- button = gtk_button_new ();
+- hbox = gtk_hbox_new (FALSE, 2);
+- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+-
+- gtk_container_add (GTK_CONTAINER (button), align);
+- gtk_container_add (GTK_CONTAINER (align), hbox);
+- widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
+-
+- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+-
+- widget = gtk_label_new_with_mnemonic (text);
+- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (button));
+- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+-
+- gtk_widget_set_sensitive (button, sensitive);
+- g_signal_connect (button, "clicked", callback, impl);
+-
+- gtk_widget_show_all (align);
+-
+- if (show)
+- gtk_widget_show (button);
+-
+- return button;
+-}
+-
+-/* 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)
+-{
+- GtkTreeIter iter;
+- int i;
+- int current_folder_separator_idx;
+-
+- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+- return -1;
+-
+- current_folder_separator_idx = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
+-
+- for (i = 0; i < current_folder_separator_idx; i++)
+- {
+- gpointer col_data;
+- gboolean is_volume;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+-
+- if (col_data)
+- {
+- if (is_volume)
+- {
+- GtkFileSystemVolume *volume;
+- GtkFilePath *base_path;
+- gboolean exists;
+-
+- volume = col_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);
+-
+- if (exists)
+- return i;
+- }
+- else
+- {
+- GtkFilePath *model_path;
+-
+- model_path = col_data;
+-
+- if (model_path && gtk_file_path_compare (model_path, path) == 0)
+- return i;
+- }
+- }
+-
+- gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
+- }
+-
+- return -1;
+-}
+-
+-/* Tries to add a bookmark from a path name */
+-static gboolean
+-shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
+- const GtkFilePath *path,
+- int pos)
+-{
+- GError *error;
+-
+- if (shortcut_find_position (impl, path) != -1)
+- return FALSE;
+-
+- /* FIXME: this check really belongs in gtk_file_system_insert_bookmark. */
+- error = NULL;
+- if (!check_is_folder (impl->file_system, path, &error))
+- {
+- error_adding_bookmark_dialog (impl, path, error);
+- return FALSE;
+- }
+-
+- error = NULL;
+- if (!gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
+- {
+- error_adding_bookmark_dialog (impl, path, error);
+- return FALSE;
+- }
+-
+- return TRUE;
+-}
+-
+-static void
+-add_bookmark_foreach_cb (GtkTreeModel *model,
+- GtkTreePath *path,
+- GtkTreeIter *iter,
+- gpointer data)
+-{
+- GtkFileChooserDefault *impl;
+- GtkFileSystemModel *fs_model;
+- GtkTreeIter child_iter;
+- const GtkFilePath *file_path;
+-
+- impl = (GtkFileChooserDefault *) data;
+-
+- 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, -1);
+-}
+-
+-/* Adds a bookmark from the currently selected item in the file list */
+-static void
+-bookmarks_add_selected_folder (GtkFileChooserDefault *impl)
+-{
+- GtkTreeSelection *selection;
+-
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+-
+- if (gtk_tree_selection_count_selected_rows (selection) == 0)
+- shortcuts_add_bookmark_from_path (impl, impl->current_folder, -1);
+- else
+- gtk_tree_selection_selected_foreach (selection,
+- add_bookmark_foreach_cb,
+- impl);
+-}
+-
+-/* Callback used when the "Add bookmark" button is clicked */
+-static void
+-add_bookmark_button_clicked_cb (GtkButton *button,
+- GtkFileChooserDefault *impl)
+-{
+- bookmarks_add_selected_folder (impl);
+-}
+-
+-/* Returns TRUE plus an iter in the shortcuts_model if a row is selected;
+- * returns FALSE if no shortcut is selected.
+- */
+-static gboolean
+-shortcuts_get_selected (GtkFileChooserDefault *impl,
+- GtkTreeIter *iter)
+-{
+- GtkTreeSelection *selection;
+- GtkTreeIter parent_iter;
+-
+- if (!impl->browse_shortcuts_tree_view)
+- return FALSE;
+-
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
+-
+- if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter))
+- return FALSE;
+-
+- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
+- iter,
+- &parent_iter);
+- return TRUE;
+-}
+-
+-/* Removes the selected bookmarks */
+-static void
+-remove_selected_bookmarks (GtkFileChooserDefault *impl)
+-{
+- GtkTreeIter iter;
+- gpointer col_data;
+- GtkFilePath *path;
+- gboolean removable;
+- GError *error;
+-
+- if (!shortcuts_get_selected (impl, &iter))
+- return;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_REMOVABLE, &removable,
+- -1);
+- g_assert (col_data != NULL);
+-
+- if (!removable)
+- return;
+-
+- path = col_data;
+-
+- error = NULL;
+- if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
+- error_removing_bookmark_dialog (impl, path, error);
+-}
+-
+-/* Callback used when the "Remove bookmark" button is clicked */
+-static void
+-remove_bookmark_button_clicked_cb (GtkButton *button,
+- GtkFileChooserDefault *impl)
+-{
+- remove_selected_bookmarks (impl);
+-}
+-
+-struct selection_check_closure {
+- GtkFileChooserDefault *impl;
+- int num_selected;
+- gboolean all_files;
+- gboolean all_folders;
+-};
+-
+-/* Used from gtk_tree_selection_selected_foreach() */
+-static void
+-selection_check_foreach_cb (GtkTreeModel *model,
+- GtkTreePath *path,
+- GtkTreeIter *iter,
+- gpointer data)
+-{
+- struct selection_check_closure *closure;
+- GtkTreeIter child_iter;
+- const GtkFileInfo *info;
+- gboolean is_folder;
+-
+- closure = data;
+- closure->num_selected++;
+-
+- 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->browse_files_model, &child_iter);
+- is_folder = info ? gtk_file_info_get_is_folder (info) : FALSE;
+-
+- closure->all_folders = closure->all_folders && is_folder;
+- closure->all_files = closure->all_files && !is_folder;
+-}
+-
+-/* Checks whether the selected items in the file list are all files or all folders */
+-static void
+-selection_check (GtkFileChooserDefault *impl,
+- gint *num_selected,
+- gboolean *all_files,
+- gboolean *all_folders)
+-{
+- struct selection_check_closure closure;
+- GtkTreeSelection *selection;
+-
+- closure.impl = impl;
+- closure.num_selected = 0;
+- closure.all_files = TRUE;
+- closure.all_folders = TRUE;
+-
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+- gtk_tree_selection_selected_foreach (selection,
+- selection_check_foreach_cb,
+- &closure);
+-
+- g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
+-
+- if (num_selected)
+- *num_selected = closure.num_selected;
+-
+- if (all_files)
+- *all_files = closure.all_files;
+-
+- if (all_folders)
+- *all_folders = closure.all_folders;
+-}
+-
+-struct get_selected_path_closure {
+- GtkFileChooserDefault *impl;
+- const GtkFilePath *path;
+-};
+-
+-static void
+-get_selected_path_foreach_cb (GtkTreeModel *model,
+- GtkTreePath *path,
+- GtkTreeIter *iter,
+- gpointer data)
+-{
+- struct get_selected_path_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);
+-}
+-
+-/* Returns a selected path from the file list */
+-static const GtkFilePath *
+-get_selected_path (GtkFileChooserDefault *impl)
+-{
+- struct get_selected_path_closure closure;
+- GtkTreeSelection *selection;
+-
+- closure.impl = impl;
+- closure.path = NULL;
+-
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+- gtk_tree_selection_selected_foreach (selection,
+- get_selected_path_foreach_cb,
+- &closure);
+-
+- return closure.path;
+-}
+-
+-typedef struct {
+- GtkFileChooserDefault *impl;
+- gchar *tip;
+-} UpdateTooltipData;
+-
+-static void
+-update_tooltip (GtkTreeModel *model,
+- GtkTreePath *path,
+- GtkTreeIter *iter,
+- gpointer data)
+-{
+- UpdateTooltipData *udata = data;
+- GtkTreeIter child_iter;
+- const GtkFileInfo *info;
+-
+- if (udata->tip == NULL)
+- {
+- gtk_tree_model_sort_convert_iter_to_child_iter (udata->impl->sort_model,
+- &child_iter,
+- iter);
+-
+- info = _gtk_file_system_model_get_info (udata->impl->browse_files_model, &child_iter);
+- udata->tip = g_strdup_printf (_("Add the folder '%s' to the bookmarks"),
+- gtk_file_info_get_display_name (info));
+- }
+-}
+-
+-
+-/* Sensitize the "add bookmark" button if all the selected items are folders, or
+- * if there are no selected items *and* the current folder is not in the
+- * bookmarks list. De-sensitize the button otherwise.
+- */
+-static void
+-bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
+-{
+- gint num_selected;
+- gboolean all_folders;
+- gboolean active;
+- gchar *tip;
+-
+- selection_check (impl, &num_selected, NULL, &all_folders);
+-
+- if (num_selected == 0)
+- active = (impl->current_folder != NULL) && (shortcut_find_position (impl, impl->current_folder) == -1);
+- else if (num_selected == 1)
+- {
+- const GtkFilePath *path;
+-
+- path = get_selected_path (impl);
+- active = all_folders && (shortcut_find_position (impl, path) == -1);
+- }
+- else
+- active = all_folders;
+-
+- gtk_widget_set_sensitive (impl->browse_shortcuts_add_button, active);
+-
+- if (impl->browse_files_popup_menu_add_shortcut_item)
+- gtk_widget_set_sensitive (impl->browse_files_popup_menu_add_shortcut_item,
+- (num_selected == 0) ? FALSE : active);
+-
+- if (active)
+- {
+- if (num_selected == 0)
+- tip = g_strdup_printf (_("Add the current folder to the bookmarks"));
+- else if (num_selected > 1)
+- tip = g_strdup_printf (_("Add the selected folders to the bookmarks"));
+- else
+- {
+- GtkTreeSelection *selection;
+- UpdateTooltipData data;
+-
+- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+- data.impl = impl;
+- data.tip = NULL;
+- gtk_tree_selection_selected_foreach (selection, update_tooltip, &data);
+- tip = data.tip;
+-
+- }
+- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button, tip, NULL);
+- g_free (tip);
+- }
+-}
+-
+-/* Sets the sensitivity of the "remove bookmark" button depending on whether a
+- * bookmark row is selected in the shortcuts tree.
+- */
+-static void
+-bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
+-{
+- GtkTreeIter iter;
+- gboolean removable = FALSE;
+- gchar *name = NULL;
+-
+- if (shortcuts_get_selected (impl, &iter))
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_REMOVABLE, &removable,
+- SHORTCUTS_COL_NAME, &name,
+- -1);
+-
+- gtk_widget_set_sensitive (impl->browse_shortcuts_remove_button, removable);
+-
+- if (removable)
+- {
+- gchar *tip;
+-
+- tip = g_strdup_printf (_("Remove the bookmark '%s'"), name);
+- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
+- tip, NULL);
+- g_free (tip);
+- }
+-
+- g_free (name);
+-}
+-
+-/* 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;
+- GtkTreeIter 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 */
+-
+- if (!shortcuts_get_selected (impl, &iter))
+- g_assert_not_reached ();
+-
+- path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &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)
++queue_edited_idle (GtkFileChooserDefault *impl,
++ const gchar *new_text)
+ {
+- GDK_THREADS_ENTER ();
+-
+- shortcuts_drag_set_delete_cursor (impl, TRUE);
+- impl->shortcuts_drag_outside = TRUE;
+-
+- shortcuts_cancel_drag_outside_idle (impl);
+-
+- GDK_THREADS_LEAVE ();
+-
+- return FALSE;
+-}
+-#endif
++ /* We create the folder in an idle handler so that we don't modify the tree
++ * just now.
++ */
+
+-/* 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
++ g_assert (!impl->edited_idle);
++ g_assert (!impl->edited_new_text);
+
+- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
+- NULL,
+- GTK_TREE_VIEW_DROP_BEFORE);
++ impl->edited_idle = g_idle_source_new ();
++ g_source_set_closure (impl->edited_idle,
++ g_cclosure_new_object (G_CALLBACK (edited_idle_cb),
++ G_OBJECT (impl)));
++ g_source_attach (impl->edited_idle, NULL);
+
+- g_signal_stop_emission_by_name (widget, "drag-leave");
++ if (new_text)
++ impl->edited_new_text = g_strdup (new_text);
+ }
+
+-/* Computes the appropriate row and position for dropping */
++/* Callback used from the text cell renderer when the new folder is named */
+ static void
+-shortcuts_compute_drop_position (GtkFileChooserDefault *impl,
+- int x,
+- int y,
+- GtkTreePath **path,
+- GtkTreeViewDropPosition *pos)
++renderer_edited_cb (GtkCellRendererText *cell_renderer_text,
++ const gchar *path,
++ const gchar *new_text,
++ GtkFileChooserDefault *impl)
+ {
+- 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);
++ /* work around bug #154921 */
++ g_object_set (cell_renderer_text,
++ "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
++ queue_edited_idle (impl, new_text);
+ }
+
+-/* 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.
++/* Callback used from the text cell renderer when the new folder edition gets
++ * canceled.
+ */
+-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;
+-}
+-
+-/* Parses a "text/uri-list" string and inserts its URIs as bookmarks */
+-static void
+-shortcuts_drop_uris (GtkFileChooserDefault *impl,
+- const char *data,
+- int position)
+-{
+- gchar **uris;
+- gint i;
+-
+- uris = g_uri_list_extract_uris (data);
+-
+- for (i = 0; uris[i]; i++)
+- {
+- char *uri;
+- GtkFilePath *path;
+-
+- uri = uris[i];
+- path = gtk_file_system_uri_to_path (impl->file_system, uri);
+-
+- if (path)
+- {
+- if (shortcuts_add_bookmark_from_path (impl, path, position))
+- position++;
+-
+- gtk_file_path_free (path);
+- }
+- else
+- {
+- GError *error;
+-
+- g_set_error (&error,
+- GTK_FILE_CHOOSER_ERROR,
+- GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
+- _("Could not add a bookmark for '%s' "
+- "because it is an invalid path name."),
+- uri);
+- error_adding_bookmark_dialog (impl, path, error);
+- }
+- }
+-
+- g_strfreev (uris);
+-}
+-
+-/* Reorders the selected bookmark to the specified position */
+ static void
+-shortcuts_reorder (GtkFileChooserDefault *impl,
+- int new_position)
++renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
++ GtkFileChooserDefault *impl)
+ {
+- GtkTreeIter iter;
+- gpointer col_data;
+- gboolean is_volume;
+- GtkTreePath *path;
+- int old_position;
+- int bookmarks_index;
+- const GtkFilePath *file_path;
+- GtkFilePath *file_path_copy;
+- GError *error;
+-
+- /* Get the selected path */
+-
+- if (!shortcuts_get_selected (impl, &iter))
+- g_assert_not_reached ();
+-
+- path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &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), &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+- g_assert (col_data != NULL);
+- g_assert (!is_volume);
+-
+- file_path = col_data;
+- 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)
+- goto out;
+-
+- 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_adding_bookmark_dialog (impl, file_path_copy, error);
+-
+- out:
+-
+- gtk_file_path_free (file_path_copy);
++ /* work around bug #154921 */
++ g_object_set (cell_renderer_text,
++ "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
++ queue_edited_idle (impl, NULL);
+ }
+
+-/* 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)
+-{
++struct selection_check_closure {
+ 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 */
+-static void
+-shortcuts_selection_changed_cb (GtkTreeSelection *selection,
+- GtkFileChooserDefault *impl)
+-{
+- bookmarks_check_remove_sensitivity (impl);
+-}
+-
+-static gboolean
+-shortcuts_row_separator_func (GtkTreeModel *model,
+- GtkTreeIter *iter,
+- gpointer data)
+-{
+- gint column = GPOINTER_TO_INT (data);
+- gchar *text;
+-
+- gtk_tree_model_get (model, iter, column, &text, -1);
+-
+- if (!text)
+- return TRUE;
+-
+- g_free (text);
+-
+- return FALSE;
+-}
+-
+-/* Since GtkTreeView has a keybinding attached to '/', we need to catch
+- * keypresses before the TreeView gets them.
+- */
+-static gboolean
+-tree_view_keybinding_cb (GtkWidget *tree_view,
+- GdkEventKey *event,
+- GtkFileChooserDefault *impl)
+-{
+- if (event->keyval == GDK_slash &&
+- ! (event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ())))
+- {
+- location_popup_handler (impl, "/");
+- return TRUE;
+- }
+-
+- return FALSE;
+-}
+-
+-
+-/* Creates the widgets for the shortcuts and bookmarks tree */
+-static GtkWidget *
+-shortcuts_list_create (GtkFileChooserDefault *impl)
+-{
+- GtkWidget *swin;
+- GtkTreeSelection *selection;
+- GtkTreeViewColumn *column;
+- GtkCellRenderer *renderer;
+-
+- /* Scrolled window */
+-
+- 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 (swin),
+- GTK_SHADOW_IN);
+- gtk_widget_show (swin);
+-
+- /* Tree */
+-
+- impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
+- g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
+- G_CALLBACK (tree_view_keybinding_cb), impl);
+- atk_object_set_name (gtk_widget_get_accessible (impl->browse_shortcuts_tree_view), _("Shortcuts"));
+- 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_dest_targets,
+- num_shortcuts_dest_targets,
+- GDK_ACTION_COPY | GDK_ACTION_MOVE);
+-
+- 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,
+- impl, NULL);
+-
+- g_signal_connect (selection, "changed",
+- G_CALLBACK (shortcuts_selection_changed_cb), impl);
+-
+- g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
+- G_CALLBACK (shortcuts_row_activated_cb), impl);
+-
+- g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
+- G_CALLBACK (shortcuts_key_press_event_cb), impl);
+-
+- 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 (swin), impl->browse_shortcuts_tree_view);
+- gtk_widget_show (impl->browse_shortcuts_tree_view);
+-
+- /* Column */
++ int num_selected;
++ gboolean all_files;
++ gboolean all_folders;
++};
+
+- column = gtk_tree_view_column_new ();
+- gtk_tree_view_column_set_title (column, _("Folder"));
++/* Used from gtk_tree_selection_selected_foreach() */
++static void
++selection_check_foreach_cb (GtkTreeModel *model,
++ GtkTreePath *path,
++ GtkTreeIter *iter,
++ gpointer data)
++{
++ struct selection_check_closure *closure;
++ GtkTreeIter child_iter;
++ const GtkFileInfo *info;
++ gboolean is_folder;
+
+- renderer = gtk_cell_renderer_pixbuf_new ();
+- gtk_tree_view_column_pack_start (column, renderer, FALSE);
+- gtk_tree_view_column_set_attributes (column, renderer,
+- "pixbuf", SHORTCUTS_COL_PIXBUF,
+- "visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
+- NULL);
++ closure = data;
++ closure->num_selected++;
+
+- renderer = gtk_cell_renderer_text_new ();
+- gtk_tree_view_column_pack_start (column, renderer, TRUE);
+- gtk_tree_view_column_set_attributes (column, renderer,
+- "text", SHORTCUTS_COL_NAME,
+- NULL);
+-
+- gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
+- shortcuts_row_separator_func,
+- GINT_TO_POINTER (SHORTCUTS_COL_NAME),
+- NULL);
++ gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
+
+- gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), column);
++ info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
++ is_folder = info ? gtk_file_info_get_is_folder (info) : FALSE;
+
+- return swin;
++ closure->all_folders = closure->all_folders && is_folder;
++ closure->all_files = closure->all_files && !is_folder;
+ }
+
+-/* Creates the widgets for the shortcuts/bookmarks pane */
+-static GtkWidget *
+-shortcuts_pane_create (GtkFileChooserDefault *impl,
+- GtkSizeGroup *size_group)
++/* Checks whether the selected items in the file list are all files or all folders */
++static void
++selection_check (GtkFileChooserDefault *impl,
++ gint *num_selected,
++ gboolean *all_files,
++ gboolean *all_folders)
+ {
+- GtkWidget *vbox;
+- GtkWidget *hbox;
+- GtkWidget *widget;
++ struct selection_check_closure closure;
++ GtkTreeSelection *selection;
+
+- vbox = gtk_vbox_new (FALSE, 6);
+- gtk_widget_show (vbox);
++ closure.impl = impl;
++ closure.num_selected = 0;
++ closure.all_files = TRUE;
++ closure.all_folders = TRUE;
++
++ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
++ gtk_tree_selection_selected_foreach (selection,
++ selection_check_foreach_cb,
++ &closure);
+
+- /* Shortcuts tree */
++ g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
+
+- widget = shortcuts_list_create (impl);
+- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
++ if (num_selected)
++ *num_selected = closure.num_selected;
+
+- /* Box for buttons */
++ if (all_files)
++ *all_files = closure.all_files;
+
+- hbox = gtk_hbox_new (TRUE, 6);
+- gtk_size_group_add_widget (size_group, hbox);
+- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+- gtk_widget_show (hbox);
++ if (all_folders)
++ *all_folders = closure.all_folders;
++}
+
+- /* Add bookmark button */
++struct get_selected_path_closure {
++ GtkFileChooserDefault *impl;
++ const GtkFilePath *path;
++};
+
+- 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);
+- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button,
+- _("Add the selected folder to the bookmarks"), NULL);
+-
+- /* Remove bookmark button */
+-
+- 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);
+- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
+- _("Remove the selected bookmark"), NULL);
++/* Returns a selected path from the file list */
++
++typedef struct {
++ GtkFileChooserDefault *impl;
++ gchar *tip;
++} UpdateTooltipData;
+
+- return vbox;
+-}
+
+ /* Handles key press events on the file list, so that we can trap Enter to
+ * activate the default button on our own. Also, checks to see if '/' has been
+@@ -3026,14 +1051,11 @@
+ gpointer data)
+ {
+ GtkFileChooserDefault *impl;
+- int modifiers;
+
+ impl = (GtkFileChooserDefault *) data;
+-
+- modifiers = gtk_accelerator_get_default_mod_mask ();
+
+ if (event->keyval == GDK_slash &&
+- ! (event->state & (~GDK_SHIFT_MASK & modifiers)))
++ ! (event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ())))
+ {
+ location_popup_handler (impl, "/");
+ return TRUE;
+@@ -3043,7 +1065,6 @@
+ || event->keyval == GDK_ISO_Enter
+ || event->keyval == GDK_KP_Enter
+ || event->keyval == GDK_space)
+- && ((event->state && modifiers) == 0)
+ && !(impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+ impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+ {
+@@ -3063,37 +1084,7 @@
+ return FALSE;
+ }
+
+-/* Callback used when the file list's popup menu is detached */
+-static void
+-popup_menu_detach_cb (GtkWidget *attach_widget,
+- GtkMenu *menu)
+-{
+- GtkFileChooserDefault *impl;
+-
+- impl = g_object_get_data (G_OBJECT (attach_widget), "GtkFileChooserDefault");
+- g_assert (GTK_IS_FILE_CHOOSER_DEFAULT (impl));
+-
+- impl->browse_files_popup_menu = NULL;
+- impl->browse_files_popup_menu_add_shortcut_item = NULL;
+- impl->browse_files_popup_menu_hidden_files_item = NULL;
+-}
+-
+-/* Callback used when the "Add to Shortcuts" menu item is activated */
+-static void
+-add_to_shortcuts_cb (GtkMenuItem *item,
+- GtkFileChooserDefault *impl)
+-{
+- bookmarks_add_selected_folder (impl);
+-}
+-
+-/* Callback used when the "Open Location" menu item is activated */
+-static void
+-open_location_cb (GtkMenuItem *item,
+- GtkFileChooserDefault *impl)
+-{
+- location_popup_handler (impl, "");
+-}
+-
++#if 0
+ /* Callback used when the "Show Hidden Files" menu item is toggled */
+ static void
+ show_hidden_toggled_cb (GtkCheckMenuItem *item,
+@@ -3103,145 +1094,7 @@
+ "show-hidden", gtk_check_menu_item_get_active (item),
+ NULL);
+ }
+-
+-/* Constructs the popup menu for the file list if needed */
+-static void
+-file_list_build_popup_menu (GtkFileChooserDefault *impl)
+-{
+- GtkWidget *item;
+-
+- if (impl->browse_files_popup_menu)
+- return;
+-
+- impl->browse_files_popup_menu = gtk_menu_new ();
+- gtk_menu_attach_to_widget (GTK_MENU (impl->browse_files_popup_menu),
+- impl->browse_files_tree_view,
+- popup_menu_detach_cb);
+-
+- item = gtk_image_menu_item_new_with_mnemonic (_("_Add to Shortcuts"));
+- impl->browse_files_popup_menu_add_shortcut_item = item;
+- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
+- gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
+- gtk_widget_set_sensitive (item, FALSE);
+- g_signal_connect (item, "activate",
+- G_CALLBACK (add_to_shortcuts_cb), impl);
+- gtk_widget_show (item);
+- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+-
+- item = gtk_image_menu_item_new_with_mnemonic (_("Open _Location"));
+- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
+- gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
+- g_signal_connect (item, "activate",
+- G_CALLBACK (open_location_cb), impl);
+- gtk_widget_show (item);
+- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+-
+- item = gtk_separator_menu_item_new ();
+- gtk_widget_show (item);
+- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+-
+- item = gtk_check_menu_item_new_with_mnemonic (_("Show _Hidden Files"));
+- impl->browse_files_popup_menu_hidden_files_item = item;
+- g_signal_connect (item, "toggled",
+- G_CALLBACK (show_hidden_toggled_cb), impl);
+- gtk_widget_show (item);
+- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
+-}
+-
+-/* Updates the popup menu for the file list, creating it if necessary */
+-static void
+-file_list_update_popup_menu (GtkFileChooserDefault *impl)
+-{
+- file_list_build_popup_menu (impl);
+-
+- /* The sensitivity of the Add to Shortcuts item is set in
+- * bookmarks_check_add_sensitivity()
+- */
+-
+- g_signal_handlers_block_by_func (impl->browse_files_popup_menu_hidden_files_item,
+- G_CALLBACK (show_hidden_toggled_cb), impl);
+- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_hidden_files_item),
+- impl->show_hidden);
+- g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_hidden_files_item,
+- G_CALLBACK (show_hidden_toggled_cb), impl);
+-}
+-
+-static void
+-popup_position_func (GtkMenu *menu,
+- gint *x,
+- gint *y,
+- gboolean *push_in,
+- gpointer user_data)
+-{
+- GtkWidget *widget = GTK_WIDGET (user_data);
+- GdkScreen *screen = gtk_widget_get_screen (widget);
+- GtkRequisition req;
+- gint monitor_num;
+- GdkRectangle monitor;
+-
+- g_return_if_fail (GTK_WIDGET_REALIZED (widget));
+-
+- gdk_window_get_origin (widget->window, x, y);
+-
+- gtk_widget_size_request (GTK_WIDGET (menu), &req);
+-
+- *x += (widget->allocation.width - req.width) / 2;
+- *y += (widget->allocation.height - req.height) / 2;
+-
+- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+- gtk_menu_set_monitor (menu, monitor_num);
+- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+-
+- *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
+- *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
+-
+- *push_in = FALSE;
+-}
+-
+-static void
+-file_list_popup_menu (GtkFileChooserDefault *impl,
+- GdkEventButton *event)
+-{
+- file_list_update_popup_menu (impl);
+- if (event)
+- gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
+- NULL, NULL, NULL, NULL,
+- event->button, event->time);
+- else
+- {
+- gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
+- NULL, NULL,
+- popup_position_func, impl->browse_files_tree_view,
+- 0, GDK_CURRENT_TIME);
+- gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
+- FALSE);
+- }
+-
+-}
+-
+-/* Callback used for the GtkWidget::popup-menu signal of the file list */
+-static gboolean
+-list_popup_menu_cb (GtkWidget *widget,
+- GtkFileChooserDefault *impl)
+-{
+- file_list_popup_menu (impl, NULL);
+- return TRUE;
+-}
+-
+-/* Callback used when a button is pressed on the file list. We trap button 3 to
+- * bring up a popup menu.
+- */
+-static gboolean
+-list_button_press_event_cb (GtkWidget *widget,
+- GdkEventButton *event,
+- GtkFileChooserDefault *impl)
+-{
+- if (event->button != 3)
+- return FALSE;
+-
+- file_list_popup_menu (impl, event);
+- return TRUE;
+-}
++#endif
+
+ /* Creates the widgets for the file list */
+ static GtkWidget *
+@@ -3272,11 +1125,7 @@
+ G_CALLBACK (list_row_activated), impl);
+ g_signal_connect (impl->browse_files_tree_view, "key-press-event",
+ G_CALLBACK (trap_activate_cb), impl);
+- g_signal_connect (impl->browse_files_tree_view, "popup-menu",
+- G_CALLBACK (list_popup_menu_cb), impl);
+- g_signal_connect (impl->browse_files_tree_view, "button-press-event",
+- G_CALLBACK (list_button_press_event_cb), impl);
+-
++
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+ gtk_tree_selection_set_select_function (selection,
+ list_select_func,
+@@ -3346,70 +1195,158 @@
+ return swin;
+ }
+
+-static GtkWidget *
+-create_path_bar (GtkFileChooserDefault *impl)
++static void
++up_button_clicked_cb (GtkButton *button, gpointer data)
+ {
+- 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;
++ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
++ up_folder_handler (impl);
+ }
+
+ static void
+-set_filter_tooltip (GtkWidget *widget,
+- gpointer data)
++volume_button_clicked_cb (GtkButton *button, gpointer data)
+ {
+- GtkTooltips *tooltips = (GtkTooltips *)data;
+-
+- if (GTK_IS_BUTTON (widget))
+- gtk_tooltips_set_tip (tooltips, widget,
+- _("Select which types of files are shown"),
+- NULL);
++ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
++ GtkFilePath * path = g_object_get_data (G_OBJECT (button), "file-path");
++
++ change_folder_and_display_error (impl, path);
+ }
+
+-static void
+-realize_filter_combo (GtkWidget *combo,
+- gpointer data)
++static GtkWidget *
++create_bar (GtkFileChooserDefault *impl)
+ {
+- GtkFileChooserDefault *impl = (GtkFileChooserDefault *)data;
++ GSList *list, *l;
++ int n;
++ GtkWidget *bar = gtk_hbox_new (FALSE, DEFAULT_SPACING);
++ GtkWidget *img;
++
++ /* first the Up button */
++ img = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON);
++ gtk_widget_show (img);
++
++ impl->up_button = gtk_button_new ();
++ gtk_container_add (GTK_CONTAINER (impl->up_button), img);
++ gtk_widget_show (impl->up_button);
++ gtk_widget_set_sensitive (impl->up_button, FALSE);
++ gtk_button_set_focus_on_click (GTK_BUTTON (impl->up_button), FALSE);
++
++ g_signal_connect (impl->up_button, "clicked",
++ G_CALLBACK (up_button_clicked_cb), impl);
++ gtk_box_pack_start (GTK_BOX(bar), impl->up_button, FALSE, FALSE, 0);
++
++ impl->num_volumes = 0;
++ list = gtk_file_system_list_volumes (impl->file_system);
++
++ n = 0;
++
++ for (l = list; l; l = l->next, n++)
++ {
++ GtkFileSystemVolume *volume;
++ GdkPixbuf *pixbuf;
++ GtkWidget *button;
++ GtkWidget *image;
++ GtkFilePath *base_path;
++ gchar * file_name = NULL;
++
++ volume = l->data;
++ base_path =
++ gtk_file_system_volume_get_base_path (impl->file_system, volume);
++
++ if (impl->local_only)
++ {
++ gboolean is_local =
++ gtk_file_system_path_is_local (impl->file_system, base_path);
++
++ if (!is_local)
++ {
++ gtk_file_path_free (base_path);
++ gtk_file_system_volume_free (impl->file_system, volume);
++ continue;
++ }
++ }
++
++#if 0
++ label_copy =
++ gtk_file_system_volume_get_display_name (impl->file_system, volume);
++#endif
++ pixbuf =
++ gtk_file_system_volume_render_icon (impl->file_system, volume,
++ GTK_WIDGET (impl),
++ impl->icon_size, NULL);
++
++ button = gtk_button_new ();
++ image = gtk_image_new_from_pixbuf (pixbuf);
++ g_object_unref (G_OBJECT (pixbuf));
++ gtk_container_add (GTK_CONTAINER (button), image);
++ gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
++
++ file_name =
++ gtk_file_system_path_to_filename (impl->file_system, base_path);
++
++ if (file_name && impl->root_folder &&
++ strcmp (file_name, impl->root_folder) &&
++ !strncmp (file_name, impl->root_folder, strlen (file_name)))
++ {
++ /* The base path is below the root folder; we replace it with
++ * the root folder
++ */
++ gtk_file_path_free (base_path);
++ base_path = gtk_file_system_filename_to_path (impl->file_system,
++ impl->root_folder);
++ }
++
++ g_free (file_name);
++
++ gtk_widget_show_all (button);
++
++ g_object_set_data (G_OBJECT (button), "file-path", base_path);
++
++ g_signal_connect (button, "clicked",
++ G_CALLBACK (volume_button_clicked_cb), impl);
++
++ gtk_box_pack_start (GTK_BOX(bar), button, FALSE, FALSE, 0);
++ }
+
+- gtk_container_forall (GTK_CONTAINER (combo),
+- set_filter_tooltip,
+- impl->tooltips);
++ impl->num_volumes = n;
++ g_slist_free (list);
++
++ gtk_widget_show (bar);
++
++ return bar;
+ }
+
+ /* Creates the widgets for the files/folders pane */
+ static GtkWidget *
+-file_pane_create (GtkFileChooserDefault *impl,
+- GtkSizeGroup *size_group)
++file_pane_create (GtkFileChooserDefault *impl)
+ {
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *widget;
+-
+- vbox = gtk_vbox_new (FALSE, 6);
++ vbox = gtk_vbox_new (FALSE, DEFAULT_SPACING);
+ gtk_widget_show (vbox);
+
+- /* The path bar and 'Create Folder' button */
+- hbox = gtk_hbox_new (FALSE, 12);
++ /* The volume bar and 'Create Folder' button */
++ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
+ gtk_widget_show (hbox);
+- 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);
++ impl->bar = create_bar (impl);
++ gtk_widget_show_all (impl->bar);
++ gtk_box_pack_start (GTK_BOX (hbox), impl->bar, TRUE, TRUE, 0);
+
+ /* Create Folder */
+- impl->browse_new_folder_button = gtk_button_new_with_mnemonic (_("Create Fo_lder"));
++ widget = gtk_image_new_from_icon_name ("folder-new", GTK_ICON_SIZE_BUTTON);
++ gtk_widget_show (widget);
++ impl->browse_new_folder_button = gtk_button_new ();
++ gtk_container_add (GTK_CONTAINER (impl->browse_new_folder_button), widget);
++ gtk_button_set_focus_on_click (GTK_BUTTON (impl->browse_new_folder_button),
++ FALSE);
++
+ g_signal_connect (impl->browse_new_folder_button, "clicked",
+ G_CALLBACK (new_folder_button_clicked), impl);
+ 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 */
++ /* Box for lists */
+
+- hbox = gtk_hbox_new (FALSE, PREVIEW_HBOX_SPACING);
++ hbox = gtk_hbox_new (FALSE, LIST_HBOX_SPACING);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
+
+@@ -3418,157 +1355,37 @@
+ widget = create_file_list (impl);
+ gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
+
+- /* Preview */
+-
+- 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 */
+-
+- /* Filter combo */
+-
+- impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
+-
+- widget = filter_create (impl);
+-
+- g_signal_connect (widget, "realize",
+- G_CALLBACK (realize_filter_combo), impl);
+-
+- gtk_widget_show (widget);
+- gtk_box_pack_end (GTK_BOX (impl->filter_combo_hbox), widget, FALSE, FALSE, 0);
+-
+- gtk_size_group_add_widget (size_group, impl->filter_combo_hbox);
+- gtk_box_pack_end (GTK_BOX (vbox), impl->filter_combo_hbox, FALSE, FALSE, 0);
+-
+ return vbox;
+ }
+-/* Callback used when the "Browse for more folders" expander is toggled */
+-static void
+-expander_changed_cb (GtkExpander *expander,
+- GParamSpec *pspec,
+- GtkFileChooserDefault *impl)
+-{
+- update_appearance (impl);
+-}
+-
+-/* Callback used when the selection changes in the save folder combo box */
+-static void
+-save_folder_combo_changed_cb (GtkComboBox *combo,
+- GtkFileChooserDefault *impl)
+-{
+- GtkTreeIter iter;
+-
+- if (impl->changing_folder)
+- return;
+-
+- if (gtk_combo_box_get_active_iter (combo, &iter))
+- shortcuts_activate_iter (impl, &iter);
+-}
+-
+-/* Creates the combo box with the save folders */
+-static GtkWidget *
+-save_folder_combo_create (GtkFileChooserDefault *impl)
+-{
+- GtkWidget *combo;
+- GtkCellRenderer *cell;
+-
+- combo = g_object_new (GTK_TYPE_COMBO_BOX,
+- "model", impl->shortcuts_model,
+- "focus-on-click", FALSE,
+- NULL);
+- 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,
+- "sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
+- NULL);
+-
+- cell = gtk_cell_renderer_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,
+- "sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
+- NULL);
+-
+- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
+- shortcuts_row_separator_func,
+- GINT_TO_POINTER (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 *hbox;
+ GtkWidget *widget;
+- GtkWidget *alignment;
+-
+- 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);
+-
+- /* Name entry */
+
+- widget = gtk_label_new_with_mnemonic (_("_Name:"));
++ vbox = gtk_vbox_new (FALSE, 0);
++ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
++
++ widget = gtk_label_new (_("Name:"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
+- gtk_table_attach (GTK_TABLE (table), widget,
+- 0, 1, 0, 1,
+- GTK_FILL, GTK_FILL,
+- 0, 0);
++ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ impl->save_file_name_entry = _gtk_file_chooser_entry_new (TRUE);
+ _gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
+ impl->file_system);
+- gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45);
++/* 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_box_pack_start (GTK_BOX (hbox), impl->save_file_name_entry,
++ TRUE, TRUE, 0);
+ gtk_widget_show (impl->save_file_name_entry);
+- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), impl->save_file_name_entry);
+-
+- /* Folder combo */
+- 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 (impl->save_folder_label);
+-
+- 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 */
+- alignment = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
+- gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
+-
+- 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);
+
++ gtk_widget_show (hbox);
++ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
++
+ return vbox;
+ }
+
+@@ -3576,29 +1393,11 @@
+ static GtkWidget *
+ browse_widgets_create (GtkFileChooserDefault *impl)
+ {
+- GtkWidget *vbox;
+- GtkWidget *hpaned;
+ GtkWidget *widget;
+- GtkSizeGroup *size_group;
+-
+- /* 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 */
+- 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);
+- widget = file_pane_create (impl, size_group);
+- gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
+
+- g_object_unref (size_group);
++ widget = file_pane_create (impl);
+
+- return vbox;
++ return widget;
+ }
+
+ static GObject*
+@@ -3618,54 +1417,18 @@
+
+ gtk_widget_push_composite_child ();
+
+- /* 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);
+-
+ /* The browse widgets */
+ impl->browse_widgets = browse_widgets_create (impl);
+ gtk_box_pack_start (GTK_BOX (impl), impl->browse_widgets, TRUE, TRUE, 0);
+
+- /* Alignment to hold extra widget */
+- impl->extra_align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
+- gtk_box_pack_start (GTK_BOX (impl), impl->extra_align, FALSE, FALSE, 0);
+-
+- gtk_widget_pop_composite_child ();
+- update_appearance (impl);
+-
+- return object;
+-}
+-
+-/* Sets the extra_widget by packing it in the appropriate place */
+-static void
+-set_extra_widget (GtkFileChooserDefault *impl,
+- GtkWidget *extra_widget)
+-{
+- 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->extra_align), impl->extra_widget);
+- g_object_unref (impl->extra_widget);
+- }
++ /* Widgets for Save mode */
++ impl->save_widgets = save_widgets_create (impl);
++ gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
++
++ gtk_widget_pop_composite_child ();
++ update_appearance (impl);
+
+- impl->extra_widget = extra_widget;
+- if (impl->extra_widget)
+- {
+- gtk_container_add (GTK_CONTAINER (impl->extra_align), impl->extra_widget);
+- gtk_widget_show (impl->extra_align);
+- }
+- else
+- gtk_widget_hide (impl->extra_align);
++ return object;
+ }
+
+ static void
+@@ -3676,12 +1439,6 @@
+ {
+ 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))
+ {
+@@ -3708,18 +1465,7 @@
+ volumes_changed_cb (GtkFileSystem *file_system,
+ GtkFileChooserDefault *impl)
+ {
+- shortcuts_add_volumes (impl);
+-}
+-
+-/* Callback used when the set of bookmarks changes in the file system */
+-static void
+-bookmarks_changed_cb (GtkFileSystem *file_system,
+- GtkFileChooserDefault *impl)
+-{
+- shortcuts_add_bookmarks (impl);
+-
+- bookmarks_check_add_sensitivity (impl);
+- bookmarks_check_remove_sensitivity (impl);
++ /* FIXME -- not needed */
+ }
+
+ /* Sets the file chooser to multiple selection mode */
+@@ -3741,8 +1487,6 @@
+
+ impl->select_multiple = select_multiple;
+ g_object_notify (G_OBJECT (impl), "select-multiple");
+-
+- check_preview_change (impl);
+ }
+
+ static void
+@@ -3753,8 +1497,6 @@
+ {
+ g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
+ impl->volumes_changed_id = 0;
+- g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
+- impl->bookmarks_changed_id = 0;
+ g_object_unref (impl->file_system);
+ }
+
+@@ -3790,9 +1532,6 @@
+ impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
+ G_CALLBACK (volumes_changed_cb),
+ impl);
+- impl->bookmarks_changed_id = g_signal_connect (impl->file_system, "bookmarks-changed",
+- G_CALLBACK (bookmarks_changed_cb),
+- impl);
+ }
+ }
+
+@@ -3807,30 +1546,8 @@
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+- 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_set_sensitive (impl->save_folder_label, TRUE);
+- gtk_widget_set_sensitive (impl->save_folder_combo, TRUE);
+- gtk_widget_hide (impl->browse_widgets);
+- }
+-
++ gtk_widget_show (impl->browse_widgets);
+ gtk_widget_show (impl->browse_new_folder_button);
+
+ if (impl->select_multiple)
+@@ -3844,6 +1561,7 @@
+ impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ {
+ gtk_widget_hide (impl->save_widgets);
++ gtk_widget_hide (impl->browse_new_folder_button);
+ gtk_widget_show (impl->browse_widgets);
+ }
+
+@@ -3876,12 +1594,9 @@
+ {
+ gtk_file_chooser_default_unselect_all (GTK_FILE_CHOOSER (impl));
+
+- if ((action == GTK_FILE_CHOOSER_ACTION_SAVE || action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+- && impl->select_multiple)
++ if (action == GTK_FILE_CHOOSER_ACTION_SAVE && impl->select_multiple)
+ {
+- g_warning ("Tried to change the file chooser action to SAVE or CREATE_FOLDER, but "
+- "this is not allowed in multiple selection mode. Resetting the file chooser "
+- "to single selection mode.");
++ g_warning ("Multiple selection mode is not allowed in Save mode");
+ set_select_multiple (impl, FALSE, TRUE);
+ }
+ impl->action = action;
+@@ -3896,35 +1611,15 @@
+ 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:
+ 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));
+- break;
+- case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
+- 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));
+- break;
+ case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
+ {
+ gboolean select_multiple = g_value_get_boolean (value);
+- if ((impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+- && select_multiple)
++ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE && select_multiple)
+ {
+- g_warning ("Tried to set the file chooser to multiple selection mode, but this is "
+- "not allowed in SAVE or CREATE_FOLDER modes. Ignoring the change and "
+- "leaving the file chooser in single selection mode.");
++ g_warning ("Multiple selection mode is not allowed in Save mode");
+ return;
+ }
+
+@@ -3943,6 +1638,11 @@
+ }
+ }
+ break;
++ case GTK_FILE_CHOOSER_PROP_ROOT_FOLDER:
++ {
++ impl->root_folder = g_strdup (g_value_get_string (value));
++ }
++ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+@@ -3962,30 +1662,18 @@
+ case GTK_FILE_CHOOSER_PROP_ACTION:
+ g_value_set_enum (value, impl->action);
+ break;
+- case GTK_FILE_CHOOSER_PROP_FILTER:
+- g_value_set_object (value, impl->current_filter);
+- break;
+ case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
+ g_value_set_boolean (value, impl->local_only);
+ break;
+- case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
+- g_value_set_object (value, impl->preview_widget);
+- break;
+- 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;
+ case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
+ g_value_set_boolean (value, impl->select_multiple);
+ break;
+ case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
+ g_value_set_boolean (value, impl->show_hidden);
+ break;
++ case GTK_FILE_CHOOSER_PROP_ROOT_FOLDER:
++ g_value_set_string (value, impl->root_folder);
++ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+@@ -4013,12 +1701,6 @@
+ {
+ 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);
+@@ -4031,12 +1713,7 @@
+ 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);
+ }
+
+ /* Handler for GtkWindow::set-focus; this is where we save the last-focused
+@@ -4095,7 +1772,6 @@
+ else
+ impl->icon_size = FALLBACK_ICON_SIZE;
+
+- shortcuts_reload_icons (impl);
+ gtk_widget_queue_resize (impl->browse_files_tree_view);
+ }
+
+@@ -4169,53 +1845,6 @@
+ g_signal_emit_by_name (widget, "default-size-changed");
+ }
+
+-static gboolean
+-get_is_file_filtered (GtkFileChooserDefault *impl,
+- const GtkFilePath *path,
+- GtkFileInfo *file_info)
+-{
+- GtkFileFilterInfo filter_info;
+- GtkFileFilterFlags needed;
+- gboolean result;
+-
+- if (!impl->current_filter)
+- return FALSE;
+-
+- filter_info.contains = GTK_FILE_FILTER_DISPLAY_NAME | GTK_FILE_FILTER_MIME_TYPE;
+-
+- needed = gtk_file_filter_get_needed (impl->current_filter);
+-
+- filter_info.display_name = gtk_file_info_get_display_name (file_info);
+- filter_info.mime_type = gtk_file_info_get_mime_type (file_info);
+-
+- if (needed & GTK_FILE_FILTER_FILENAME)
+- {
+- filter_info.filename = gtk_file_system_path_to_filename (impl->file_system, path);
+- if (filter_info.filename)
+- filter_info.contains |= GTK_FILE_FILTER_FILENAME;
+- }
+- else
+- filter_info.filename = NULL;
+-
+- if (needed & GTK_FILE_FILTER_URI)
+- {
+- filter_info.uri = gtk_file_system_path_to_uri (impl->file_system, path);
+- if (filter_info.uri)
+- filter_info.contains |= GTK_FILE_FILTER_URI;
+- }
+- else
+- filter_info.uri = NULL;
+-
+- result = gtk_file_filter_filter (impl->current_filter, &filter_info);
+-
+- if (filter_info.filename)
+- g_free ((gchar *)filter_info.filename);
+- if (filter_info.uri)
+- g_free ((gchar *)filter_info.uri);
+-
+- return !result;
+-}
+-
+ /* GtkWidget::map method */
+ static void
+ gtk_file_chooser_default_map (GtkWidget *widget)
+@@ -4231,50 +1860,8 @@
+ pending_select_paths_store_selection (impl);
+ change_folder_and_display_error (impl, impl->current_folder);
+ }
+-
+- bookmarks_changed_cb (impl->file_system, impl);
+-}
+-
+-static gboolean
+-list_model_filter_func (GtkFileSystemModel *model,
+- GtkFilePath *path,
+- const GtkFileInfo *file_info,
+- gpointer user_data)
+-{
+- GtkFileChooserDefault *impl = user_data;
+-
+- if (!impl->current_filter)
+- return TRUE;
+-
+- if (gtk_file_info_get_is_folder (file_info))
+- return TRUE;
+-
+- return !get_is_file_filtered (impl, path, (GtkFileInfo *) file_info);
+ }
+
+-static void
+-install_list_model_filter (GtkFileChooserDefault *impl)
+-{
+- GtkFileSystemModelFilter filter;
+- gpointer data;
+-
+- g_assert (impl->browse_files_model != NULL);
+-
+- if (impl->current_filter)
+- {
+- filter = list_model_filter_func;
+- data = impl;
+- }
+- else
+- {
+- filter = NULL;
+- data = NULL;
+- }
+-
+- _gtk_file_system_model_set_filter (impl->browse_files_model,
+- filter,
+- data);
+-}
+
+ #define COMPARE_DIRECTORIES \
+ GtkFileChooserDefault *impl = user_data; \
+@@ -4519,18 +2106,21 @@
+ GtkFileFolder *folder;
+ gboolean success;
+ gboolean have_hidden;
+- gboolean have_filtered;
+
+ if (!only_one_path && !paths)
+ return TRUE;
+
++#ifdef GTK26
+ folder = gtk_file_system_get_folder (impl->file_system, parent_path, GTK_FILE_INFO_IS_HIDDEN, error);
++#else
++ folder = gtk_file_system_get_folder (impl->file_system, parent_path, GTK_FILE_INFO_IS_HIDDEN, NULL, NULL);
++#endif
++
+ if (!folder)
+ return FALSE;
+
+ success = FALSE;
+ have_hidden = FALSE;
+- have_filtered = FALSE;
+
+ if (only_one_path)
+ {
+@@ -4541,7 +2131,6 @@
+ {
+ success = TRUE;
+ have_hidden = gtk_file_info_get_is_hidden (info);
+- have_filtered = get_is_file_filtered (impl, only_one_path, info);
+ gtk_file_info_free (info);
+ }
+ }
+@@ -4563,12 +2152,9 @@
+ if (!have_hidden)
+ have_hidden = gtk_file_info_get_is_hidden (info);
+
+- if (!have_filtered)
+- have_filtered = get_is_file_filtered (impl, path, info);
+-
+ gtk_file_info_free (info);
+
+- if (have_hidden && have_filtered)
++ if (have_hidden)
+ break; /* we now have all the information we need */
+ }
+ }
+@@ -4584,9 +2170,6 @@
+ if (have_hidden)
+ g_object_set (impl, "show-hidden", TRUE, NULL);
+
+- if (have_filtered)
+- set_current_filter (impl, NULL);
+-
+ if (only_one_path)
+ _gtk_file_system_model_path_do (impl->browse_files_model, only_one_path, select_func, impl);
+ else
+@@ -4629,13 +2212,11 @@
+ * that case, the chooser's selection should be what the caller expects,
+ * as the user can't see that something else got selected. See bug #165264.
+ *
+- * Also, we don't select the first file if we are not in OPEN mode. Doing
+- * so would change the contents of the filename entry for SAVE or
+- * CREATE_FOLDER, which is undesired; in SELECT_FOLDER, we don't want to
+- * select a *different* folder from the one into which the user just
+- * navigated.
++ * Also, we don't select the first file if we are in SAVE or CREATE_FOLDER
++ * modes. Doing so would change the contents of the filename entry.
+ */
+- if (GTK_WIDGET_MAPPED (impl) && impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
++ if (GTK_WIDGET_MAPPED (impl)
++ && !(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
+ browse_files_select_first_row (impl);
+ }
+
+@@ -4713,8 +2294,6 @@
+
+ _gtk_file_system_model_set_show_hidden (impl->browse_files_model, impl->show_hidden);
+
+- install_list_model_filter (impl);
+-
+ return TRUE;
+ }
+
+@@ -4725,19 +2304,15 @@
+ const GtkFileInfo *info;
+ GtkTreeIter iter;
+ GtkTreeIter child_iter;
+- gboolean change_entry;
+
+- if (!(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
++ if (impl->action != GTK_FILE_CHOOSER_ACTION_SAVE)
+ return;
+
+ 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))
+- {
+- _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), "");
+- return;
+- }
++ return;
+
+ gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
+ &child_iter,
+@@ -4745,12 +2320,7 @@
+
+ info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
+
+- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+- change_entry = !gtk_file_info_get_is_folder (info); /* We don't want the name to change when clicking on a folder... */
+- else
+- change_entry = TRUE; /* ... unless we are in CREATE_FOLDER mode */
+-
+- if (change_entry)
++ if (!gtk_file_info_get_is_folder (info))
+ _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
+ gtk_file_info_get_display_name (info));
+ }
+@@ -4780,9 +2350,6 @@
+ if (!check_is_folder (impl->file_system, path, error))
+ return FALSE;
+
+- if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
+- return FALSE;
+-
+ if (impl->current_folder != path)
+ {
+ if (impl->current_folder)
+@@ -4791,17 +2358,6 @@
+ impl->current_folder = gtk_file_path_copy (path);
+ }
+
+- /* Update the widgets that may trigger a folder change themselves. */
+-
+- if (!impl->changing_folder)
+- {
+- impl->changing_folder = TRUE;
+-
+- shortcuts_update_current_folder (impl);
+-
+- impl->changing_folder = FALSE;
+- }
+-
+ /* Set the folder on the save entry */
+
+ _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
+@@ -4815,13 +2371,7 @@
+
+ /* Refresh controls */
+
+- shortcuts_find_current_folder (impl);
+-
+ g_signal_emit_by_name (impl, "current-folder-changed", 0);
+-
+- check_preview_change (impl);
+- bookmarks_check_add_sensitivity (impl);
+-
+ g_signal_emit_by_name (impl, "selection-changed", 0);
+
+ return result;
+@@ -4844,7 +2394,6 @@
+ g_return_if_fail (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+
+- pending_select_paths_free (impl);
+ _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), name);
+ }
+
+@@ -4983,24 +2532,13 @@
+ GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
+
+ gtk_tree_selection_unselect_all (selection);
+- pending_select_paths_free (impl);
+ }
+
+-/* Checks whether the filename entry for the Save modes contains a well-formed filename.
+- *
+- * is_well_formed_ret - whether what the user typed passes gkt_file_system_make_path()
+- *
+- * is_empty_ret - whether the file entry is totally empty
+- *
+- * is_file_part_empty_ret - whether the file part is empty (will be if user types "foobar/", and
+- * the path will be "$cwd/foobar")
+- */
+-static void
++/* Checks whether the filename entry for the Save modes contains a valid filename */
++static GtkFilePath *
+ check_save_entry (GtkFileChooserDefault *impl,
+- GtkFilePath **path_ret,
+- gboolean *is_well_formed_ret,
+- gboolean *is_empty_ret,
+- gboolean *is_file_part_empty_ret)
++ gboolean *is_valid,
++ gboolean *is_empty)
+ {
+ GtkFileChooserEntry *chooser_entry;
+ const GtkFilePath *current_folder;
+@@ -5013,31 +2551,17 @@
+
+ chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
+
+- if (strlen (gtk_entry_get_text (GTK_ENTRY (chooser_entry))) == 0)
+- {
+- *path_ret = NULL;
+- *is_well_formed_ret = TRUE;
+- *is_empty_ret = TRUE;
+- *is_file_part_empty_ret = TRUE;
+-
+- return;
+- }
+-
+- *is_empty_ret = FALSE;
+-
+ current_folder = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
+ file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
+
+ if (!file_part || file_part[0] == '\0')
+ {
+- *path_ret = gtk_file_path_copy (current_folder);
+- *is_well_formed_ret = TRUE;
+- *is_file_part_empty_ret = TRUE;
+-
+- return;
++ *is_valid = FALSE;
++ *is_empty = TRUE;
++ return NULL;
+ }
+
+- *is_file_part_empty_ret = FALSE;
++ *is_empty = FALSE;
+
+ error = NULL;
+ path = gtk_file_system_make_path (impl->file_system, current_folder, file_part, &error);
+@@ -5045,14 +2569,12 @@
+ if (!path)
+ {
+ error_building_filename_dialog (impl, current_folder, file_part, error);
+- *path_ret = NULL;
+- *is_well_formed_ret = FALSE;
+-
+- return;
++ *is_valid = FALSE;
++ return NULL;
+ }
+
+- *path_ret = path;
+- *is_well_formed_ret = TRUE;
++ *is_valid = TRUE;
++ return path;
+ }
+
+ struct get_paths_closure {
+@@ -5098,21 +2620,11 @@
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+- gboolean is_well_formed, is_empty, is_file_part_empty;
+-
+- check_save_entry (impl, &info.path_from_entry, &is_well_formed, &is_empty, &is_file_part_empty);
++ gboolean is_valid, is_empty;
+
+- if (!is_well_formed)
++ info.path_from_entry = check_save_entry (impl, &is_valid, &is_empty);
++ if (!is_valid && !is_empty)
+ return NULL;
+-
+- if (!is_empty)
+- {
+- if (is_file_part_empty && impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+- {
+- gtk_file_path_free (info.path_from_entry);
+- return NULL;
+- }
+- }
+ }
+
+ if (!info.path_from_entry || impl->select_multiple)
+@@ -5137,243 +2649,12 @@
+ return g_slist_reverse (info.result);
+ }
+
+-static GtkFilePath *
+-gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+-
+- if (impl->preview_path)
+- return gtk_file_path_copy (impl->preview_path);
+- else
+- return NULL;
+-}
+-
+-static GtkFileSystem *
+-gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+-
+- return impl->file_system;
+-}
+-
+-/* Shows or hides the filter widgets */
+-static void
+-show_filters (GtkFileChooserDefault *impl,
+- gboolean show)
+-{
+- if (show)
+- gtk_widget_show (impl->filter_combo_hbox);
+- else
+- gtk_widget_hide (impl->filter_combo_hbox);
+-}
+-
+-static void
+-gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
+- GtkFileFilter *filter)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+- const gchar *name;
+-
+- if (g_slist_find (impl->filters, filter))
+- {
+- g_warning ("gtk_file_chooser_add_filter() called on filter already in list\n");
+- return;
+- }
+-
+- g_object_ref (filter);
+- gtk_object_sink (GTK_OBJECT (filter));
+- impl->filters = g_slist_append (impl->filters, filter);
+-
+- name = gtk_file_filter_get_name (filter);
+- if (!name)
+- name = "Untitled filter"; /* Place-holder, doesn't need to be marked for translation */
+-
+- gtk_combo_box_append_text (GTK_COMBO_BOX (impl->filter_combo), name);
+-
+- if (!g_slist_find (impl->filters, impl->current_filter))
+- set_current_filter (impl, filter);
+-
+- show_filters (impl, TRUE);
+-}
+-
+-static void
+-gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
+- GtkFileFilter *filter)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+- GtkTreeModel *model;
+- GtkTreeIter iter;
+- gint filter_index;
+-
+- filter_index = g_slist_index (impl->filters, filter);
+-
+- if (filter_index < 0)
+- {
+- g_warning ("gtk_file_chooser_remove_filter() called on filter not in list\n");
+- return;
+- }
+-
+- impl->filters = g_slist_remove (impl->filters, filter);
+-
+- if (filter == impl->current_filter)
+- {
+- if (impl->filters)
+- set_current_filter (impl, impl->filters->data);
+- else
+- set_current_filter (impl, NULL);
+- }
+-
+- /* Remove row from the combo box */
+- model = gtk_combo_box_get_model (GTK_COMBO_BOX (impl->filter_combo));
+- gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_index);
+- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+-
+- g_object_unref (filter);
+-
+- if (!impl->filters)
+- show_filters (impl, FALSE);
+-}
+-
+-static GSList *
+-gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+-
+- return g_slist_copy (impl->filters);
+-}
+-
+-/* Returns the position in the shortcuts tree where the nth specified shortcut would appear */
+-static int
+-shortcuts_get_pos_for_shortcut_folder (GtkFileChooserDefault *impl,
+- int pos)
+-{
+- return pos + shortcuts_get_index (impl, SHORTCUTS_SHORTCUTS);
+-}
+-
+-static gboolean
+-gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
+- const GtkFilePath *path,
+- GError **error)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (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);
+-
+- 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;
+-}
+-
+-static gboolean
+-gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
+- const GtkFilePath *path,
+- GError **error)
+-{
+- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+- int pos;
+- GtkTreeIter iter;
+- char *uri;
+- int i;
+-
+- if (impl->num_shortcuts == 0)
+- goto out;
+-
+- 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 ();
+-
+- for (i = 0; i < impl->num_shortcuts; i++)
+- {
+- gpointer col_data;
+- gboolean is_volume;
+- GtkFilePath *shortcut;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+- g_assert (col_data != NULL);
+- g_assert (!is_volume);
+-
+- shortcut = col_data;
+- if (gtk_file_path_compare (shortcut, path) == 0)
+- {
+- shortcuts_remove_rows (impl, pos + i, 1);
+- impl->num_shortcuts--;
+- return TRUE;
+- }
+-
+- if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
+- g_assert_not_reached ();
+- }
+-
+- 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++)
+- {
+- gpointer col_data;
+- gboolean is_volume;
+- GtkFilePath *shortcut;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+- g_assert (col_data != NULL);
+- g_assert (!is_volume);
+-
+- shortcut = col_data;
+- 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 ();
+- }
+- }
++static GtkFileSystem *
++gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser)
++{
++ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
+
+- return g_slist_reverse (list);
++ return impl->file_system;
+ }
+
+ /* Guesses a size based upon font sizes */
+@@ -5386,7 +2667,6 @@
+ gint default_width, default_height;
+ int font_size;
+ GtkRequisition req;
+- GtkRequisition preview_req;
+
+ g_assert (widget->style != NULL);
+ impl = GTK_FILE_CHOOSER_DEFAULT (widget);
+@@ -5400,12 +2680,7 @@
+ /* 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_width = MAX (default_width, (req.width - (LIST_HBOX_SPACING)));
+ default_height = MAX (default_height, req.height);
+
+ *width = default_width;
+@@ -5423,8 +2698,6 @@
+
+ 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
+@@ -5441,16 +2714,6 @@
+
+ *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 {
+@@ -5517,84 +2780,49 @@
+
+ if (current_focus == impl->browse_files_tree_view)
+ {
+- /* The following array encodes what we do based on the impl->action and the
+- * number of files selected.
+- */
+- typedef enum {
+- NOOP, /* Do nothing (don't respond) */
+- RESPOND, /* Respond immediately */
+- RESPOND_OR_SWITCH, /* Respond immediately if the selected item is a file; switch to it if it is a folder */
+- ALL_FILES, /* Respond only if everything selected is a file */
+- ALL_FOLDERS, /* Respond only if everything selected is a folder */
+- SAVE_ENTRY, /* Go to the code for handling the save entry */
+- NOT_REACHED /* Sanity check */
+- } ActionToTake;
+- static const ActionToTake what_to_do[4][3] = {
+- /* 0 selected 1 selected many selected */
+- /* ACTION_OPEN */ { NOOP, RESPOND_OR_SWITCH, ALL_FILES },
+- /* ACTION_SAVE */ { SAVE_ENTRY, RESPOND_OR_SWITCH, NOT_REACHED },
+- /* ACTION_SELECT_FOLDER */ { RESPOND, ALL_FOLDERS, ALL_FOLDERS },
+- /* ACTION_CREATE_FOLDER */ { SAVE_ENTRY, ALL_FOLDERS, NOT_REACHED }
+- };
+-
+ int num_selected;
+ gboolean all_files, all_folders;
+- int k;
+- ActionToTake action;
+
+ file_list:
+
+- g_assert (impl->action >= GTK_FILE_CHOOSER_ACTION_OPEN && impl->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+-
+ selection_check (impl, &num_selected, &all_files, &all_folders);
+
+- if (num_selected > 2)
+- k = 2;
+- else
+- k = num_selected;
+-
+- action = what_to_do [impl->action] [k];
+-
+- switch (action)
++ if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ {
+- case NOOP:
+- return FALSE;
+-
+- case RESPOND:
+- return TRUE;
+-
+- case RESPOND_OR_SWITCH:
+- g_assert (num_selected == 1);
+-
+- if (all_folders)
++ if (num_selected != 1)
++ return TRUE; /* zero means current folder; more than one means use the whole selection */
++ else if (current_focus != impl->browse_files_tree_view)
+ {
+- switch_to_selected_folder (impl);
+- return FALSE;
++ /* a single folder is selected and a button was clicked */
++ switch_to_selected_folder (impl);
++ return TRUE;
+ }
+- else
+- return TRUE;
+-
+- case ALL_FILES:
+- return all_files;
+-
+- case ALL_FOLDERS:
+- return all_folders;
++ }
+
+- case SAVE_ENTRY:
+- goto save_entry;
++ if (num_selected == 0)
++ {
++ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
++ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
++ goto save_entry; /* it makes sense to use the typed name */
++ else
++ return FALSE;
++ }
+
+- default:
+- g_assert_not_reached ();
++ if (num_selected == 1 && all_folders)
++ {
++ switch_to_selected_folder (impl);
++ return FALSE;
+ }
++ else
++ return all_files;
+ }
+ else if (current_focus == impl->save_file_name_entry)
+ {
+ GtkFilePath *path;
+- gboolean is_well_formed, is_empty, is_file_part_empty;
++ gboolean is_valid, is_empty;
+ gboolean is_folder;
+ gboolean retval;
+- GtkFileChooserEntry *entry;
+- GError *error;
++ GtkFileChooserEntry *entry;
+
+ save_entry:
+
+@@ -5602,103 +2830,39 @@
+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
+
+ entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
+- check_save_entry (impl, &path, &is_well_formed, &is_empty, &is_file_part_empty);
++ path = check_save_entry (impl, &is_valid, &is_empty);
+
+- if (is_empty || !is_well_formed)
++ if (!is_empty && !is_valid)
+ return FALSE;
+
+- g_assert (path != NULL);
+-
+- error = NULL;
+- is_folder = check_is_folder (impl->file_system, path, &error);
++ if (is_empty)
++ path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
++
++ is_folder = check_is_folder (impl->file_system, path, NULL);
+ if (is_folder)
+ {
+- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+- {
+- _gtk_file_chooser_entry_set_file_part (entry, "");
+- change_folder_and_display_error (impl, path);
+- retval = FALSE;
+- }
+- else /* GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER */
+- {
+- /* The folder already exists, so we do not need to create it.
+- * Just respond to terminate the dialog.
+- */
+- retval = TRUE;
+- }
++ _gtk_file_chooser_entry_set_file_part (entry, "");
++ change_folder_and_display_error (impl, path);
++ retval = FALSE;
+ }
+ else
+ {
+- if (impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
+- && g_error_matches (error, GTK_FILE_SYSTEM_ERROR, GTK_FILE_SYSTEM_ERROR_NOT_FOLDER))
++ /* check that everything up to the last component exists */
++ gtk_file_path_free (path);
++ path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
++ is_folder = check_is_folder (impl->file_system, path, NULL);
++ if (!is_folder)
+ {
+- /* Oops, the user typed the name of an existing path which is not a folder */
+- error_creating_folder_over_existing_file_dialog (impl, path, error);
+- error = NULL; /* as it will be freed below for the general case */
++ change_folder_and_display_error (impl, path);
+ retval = FALSE;
+ }
+ else
+- {
+- GtkFilePath *parent_path;
+-
+- /* check that everything up to the last component exists */
+-
+- parent_path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
+- is_folder = check_is_folder (impl->file_system, parent_path, NULL);
+- if (is_folder)
+- {
+- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
+- retval = TRUE;
+- else /* GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER */
+- {
+- GError *create_error;
+-
+- create_error = NULL;
+- if (gtk_file_system_create_folder (impl->file_system, path, &create_error))
+- retval = TRUE;
+- else
+- {
+- error_creating_folder_dialog (impl, path, create_error);
+- retval = FALSE;
+- }
+- }
+- }
+- else
+- {
+- /* This will display an error, which is what we want */
+- change_folder_and_display_error (impl, parent_path);
+- retval = FALSE;
+- }
+-
+- gtk_file_path_free (parent_path);
+- }
+-
+- if (error != NULL)
+- g_error_free (error);
++ retval = TRUE;
+ }
+
+ gtk_file_path_free (path);
+ return retval;
+ }
+- else if (impl->toplevel_last_focus_widget == impl->browse_shortcuts_tree_view)
+- {
+- /* The focus is on a dialog's action area button, *and* the widget that
+- * was focused immediately before it is the shortcuts list. Switch to the
+- * selected shortcut and tell the caller not to respond.
+- */
+- GtkTreeIter iter;
+-
+- if (shortcuts_get_selected (impl, &iter))
+- {
+- shortcuts_activate_iter (impl, &iter);
+-
+- gtk_widget_grab_focus (impl->browse_files_tree_view);
+- }
+- else
+- goto file_list;
+-
+- return FALSE;
+- }
+ else if (impl->toplevel_last_focus_widget == impl->browse_files_tree_view)
+ {
+ /* The focus is on a dialog's action area button, *and* the widget that
+@@ -5742,242 +2906,6 @@
+ gtk_widget_grab_focus (widget);
+ }
+
+-static void
+-set_current_filter (GtkFileChooserDefault *impl,
+- GtkFileFilter *filter)
+-{
+- if (impl->current_filter != filter)
+- {
+- int filter_index;
+-
+- /* NULL filters are allowed to reset to non-filtered status
+- */
+- filter_index = g_slist_index (impl->filters, filter);
+- if (impl->filters && filter && filter_index < 0)
+- return;
+-
+- if (impl->current_filter)
+- g_object_unref (impl->current_filter);
+- impl->current_filter = filter;
+- if (impl->current_filter)
+- {
+- g_object_ref (impl->current_filter);
+- gtk_object_sink (GTK_OBJECT (filter));
+- }
+-
+- if (impl->filters)
+- gtk_combo_box_set_active (GTK_COMBO_BOX (impl->filter_combo),
+- filter_index);
+-
+- if (impl->browse_files_model)
+- install_list_model_filter (impl);
+-
+- g_object_notify (G_OBJECT (impl), "filter");
+- }
+-}
+-
+-static void
+-filter_combo_changed (GtkComboBox *combo_box,
+- GtkFileChooserDefault *impl)
+-{
+- gint new_index = gtk_combo_box_get_active (combo_box);
+- GtkFileFilter *new_filter = g_slist_nth_data (impl->filters, new_index);
+-
+- set_current_filter (impl, new_filter);
+-}
+-
+-static void
+-check_preview_change (GtkFileChooserDefault *impl)
+-{
+- GtkTreePath *cursor_path;
+- const GtkFilePath *new_path;
+- const GtkFileInfo *new_info;
+-
+- gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
+- if (cursor_path && impl->sort_model)
+- {
+- GtkTreeIter iter;
+- GtkTreeIter child_iter;
+-
+- gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, cursor_path);
+- gtk_tree_path_free (cursor_path);
+-
+- gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &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);
+- }
+- else
+- {
+- new_path = NULL;
+- new_info = NULL;
+- }
+-
+- if (new_path != impl->preview_path &&
+- !(new_path && impl->preview_path &&
+- gtk_file_path_compare (new_path, impl->preview_path) == 0))
+- {
+- if (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_display_name = g_strdup (gtk_file_info_get_display_name (new_info));
+- }
+- else
+- {
+- 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");
+- }
+-}
+-
+-/* Activates a volume by mounting it if necessary and then switching to its
+- * base path.
+- */
+-static void
+-shortcuts_activate_volume (GtkFileChooserDefault *impl,
+- GtkFileSystemVolume *volume)
+-{
+- GtkFilePath *path;
+-
+- /* We ref the file chooser since volume_mount() may run a main loop, and the
+- * user could close the file chooser window in the meantime.
+- */
+- g_object_ref (impl);
+-
+- if (!gtk_file_system_volume_get_is_mounted (impl->file_system, volume))
+- {
+- GError *error;
+- gboolean result;
+-
+- set_busy_cursor (impl, TRUE);
+-
+- error = NULL;
+- result = gtk_file_system_volume_mount (impl->file_system, volume, &error);
+-
+- if (!result)
+- {
+- char *msg;
+-
+- msg = g_strdup_printf (_("Could not mount %s"),
+- gtk_file_system_volume_get_display_name (impl->file_system, volume));
+- error_message (impl, msg, error->message);
+- g_free (msg);
+- g_error_free (error);
+- }
+-
+- set_busy_cursor (impl, FALSE);
+-
+- if (!result)
+- goto out;
+- }
+-
+- path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
+- change_folder_and_display_error (impl, path);
+- gtk_file_path_free (path);
+-
+- out:
+-
+- g_object_unref (impl);
+-}
+-
+-/* Opens the folder or volume at the specified iter in the shortcuts model */
+-static void
+-shortcuts_activate_iter (GtkFileChooserDefault *impl,
+- GtkTreeIter *iter)
+-{
+- gpointer col_data;
+- gboolean is_volume;
+-
+- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
+- SHORTCUTS_COL_DATA, &col_data,
+- SHORTCUTS_COL_IS_VOLUME, &is_volume,
+- -1);
+-
+- if (!col_data)
+- return; /* We are on a separator */
+-
+- if (is_volume)
+- {
+- GtkFileSystemVolume *volume;
+-
+- volume = col_data;
+-
+- shortcuts_activate_volume (impl, volume);
+- }
+- else
+- {
+- const GtkFilePath *file_path;
+-
+- file_path = col_data;
+- 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)
+-{
+- GtkTreeIter iter;
+- GtkTreeIter child_iter;
+-
+- 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);
+- shortcuts_activate_iter (impl, &child_iter);
+-
+- gtk_widget_grab_focus (impl->browse_files_tree_view);
+-}
+-
+-/* Handler for GtkWidget::key-press-event on the shortcuts list */
+-static gboolean
+-shortcuts_key_press_event_cb (GtkWidget *widget,
+- GdkEventKey *event,
+- GtkFileChooserDefault *impl)
+-{
+- guint modifiers;
+-
+- modifiers = gtk_accelerator_get_default_mod_mask ();
+-
+- if ((event->keyval == GDK_BackSpace
+- || event->keyval == GDK_Delete
+- || event->keyval == GDK_KP_Delete)
+- && (event->state & modifiers) == 0)
+- {
+- remove_selected_bookmarks (impl);
+- return TRUE;
+- }
+-
+- return FALSE;
+-}
+-
+-static gboolean
+-shortcuts_select_func (GtkTreeSelection *selection,
+- GtkTreeModel *model,
+- GtkTreePath *path,
+- gboolean path_currently_selected,
+- gpointer data)
+-{
+- GtkFileChooserDefault *impl = data;
+-
+- return (*gtk_tree_path_get_indices (path) != shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR));
+-}
+
+ static gboolean
+ list_select_func (GtkTreeSelection *selection,
+@@ -6022,7 +2950,7 @@
+ 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))
+- goto out; /* normal processing */
++ return;
+
+ gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
+ &child_iter,
+@@ -6033,11 +2961,7 @@
+ return; /* We are on the editable row for New Folder */
+ }
+
+- out:
+-
+ update_chooser_entry (impl);
+- check_preview_change (impl);
+- bookmarks_check_add_sensitivity (impl);
+
+ g_signal_emit_by_name (impl, "selection-changed", 0);
+ }
+@@ -6074,23 +2998,6 @@
+ g_signal_emit_by_name (impl, "file-activated");
+ }
+
+-static void
+-path_bar_clicked (GtkPathBar *path_bar,
+- GtkFilePath *file_path,
+- gboolean child_is_hidden,
+- GtkFileChooserDefault *impl)
+-{
+- if (!change_folder_and_display_error (impl, file_path))
+- return;
+-
+- /* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then
+- * show hidden files so that ".baz" appears in the file list, as it will still
+- * be shown in the path bar: "/foo/[bar]/.baz"
+- */
+- if (child_is_hidden)
+- g_object_set (impl, "show-hidden", TRUE, NULL);
+-}
+-
+ static const GtkFileInfo *
+ get_list_file_info (GtkFileChooserDefault *impl,
+ GtkTreeIter *iter)
+@@ -6257,33 +3164,31 @@
+
+ time_mtime = gtk_file_info_get_modification_time (info);
+
+- if (time_mtime == 0)
+- strcpy (buf, _("Unknown"));
+- else
+- {
+- g_date_set_time (&mtime, (GTime) time_mtime);
++#ifdef GTK26
++ g_date_set_time (&mtime, (GTime) time_mtime);
++#else
++ g_date_set_time_t (&mtime, time_mtime);
++#endif
++ time_now = (GTime ) time (NULL);
++ g_date_set_time (&now, (GTime) time_now);
+
+- time_now = (GTime ) time (NULL);
+- g_date_set_time (&now, (GTime) time_now);
++ days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
+
+- days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
++ if (days_diff == 0)
++ strcpy (buf, _("Today"));
++ else if (days_diff == 1)
++ strcpy (buf, _("Yesterday"));
++ else
++ {
++ char *format;
+
+- if (days_diff == 0)
+- strcpy (buf, _("Today"));
+- else if (days_diff == 1)
+- strcpy (buf, _("Yesterday"));
++ if (days_diff > 1 && days_diff < 7)
++ format = "%A"; /* Days from last week */
+ else
+- {
+- char *format;
+-
+- if (days_diff > 1 && days_diff < 7)
+- format = "%A"; /* Days from last week */
+- else
+- format = "%x"; /* Any other date */
++ format = "%x"; /* Any other date */
+
+- if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
+- strcpy (buf, _("Unknown"));
+- }
++ if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
++ strcpy (buf, _("Unknown"));
+ }
+
+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
+@@ -6376,8 +3281,11 @@
+ */
+
+ error = NULL;
++#ifdef GTK26
+ folder = gtk_file_system_get_folder (impl->file_system, folder_path, GTK_FILE_INFO_IS_FOLDER, &error);
+-
++#else
++ folder = gtk_file_system_get_folder (impl->file_system, folder_path, GTK_FILE_INFO_IS_FOLDER, NULL, NULL);
++#endif
+ if (!folder)
+ {
+ error_getting_info_dialog (impl, folder_path, error);
+@@ -6487,8 +3395,8 @@
+ accept_stock, GTK_RESPONSE_ACCEPT,
+ NULL);
+ gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
+- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
++ gtk_container_set_border_width (GTK_CONTAINER (dialog), DEFAULT_SPACING);
++ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), DEFAULT_SPACING);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+
+ gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+@@ -6496,17 +3404,16 @@
+ GTK_RESPONSE_CANCEL,
+ -1);
+
+- hbox = gtk_hbox_new (FALSE, 12);
++ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+
+- label = gtk_label_new_with_mnemonic (_("_Location:"));
++ label = gtk_label_new (_("Location:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ entry = location_entry_create (impl, path);
+
+ gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
+- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+ /* Run */
+
+@@ -6555,115 +3462,86 @@
+ static void
+ up_folder_handler (GtkFileChooserDefault *impl)
+ {
++ GtkFilePath * parent;
+ pending_select_paths_add (impl, impl->current_folder);
+- _gtk_path_bar_up (GTK_PATH_BAR (impl->browse_path_bar));
++
++ if (gtk_file_system_get_parent (impl->file_system, impl->current_folder,
++ &parent, NULL) && parent)
++ {
++ impl->path_history = g_slist_prepend (impl->path_history,
++ gtk_file_path_copy (impl->current_folder));
++
++ change_folder_and_display_error (impl, parent);
++ gtk_file_path_free (parent);
++ }
+ }
+
+ /* 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));
++ if (impl->path_history)
++ {
++ const GtkFilePath * path = impl->path_history->data;
++
++ change_folder_and_display_error (impl, path);
++ impl->path_history = g_slist_remove (impl->path_history, path);
++ gtk_file_path_free (path);
++ }
+ }
+
+ /* Handler for the "home-folder" keybinding signal */
+ static void
+ home_folder_handler (GtkFileChooserDefault *impl)
+ {
+- int pos;
+- GtkTreeIter iter;
+-
+- if (!impl->has_home)
+- return; /* Should we put up an error dialog? */
+-
+- 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 ();
+-
+- shortcuts_activate_iter (impl, &iter);
+ }
+
+-
+-
+-/* Drag and drop interfaces */
++static GtkFilePath *
++gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser)
++{
++ return NULL;
++}
+
+ static void
+-_shortcuts_model_filter_class_init (ShortcutsModelFilterClass *class)
++gtk_file_chooser_default_add_filter (GtkFileChooser *chooser,
++ GtkFileFilter *filter)
+ {
+ }
+
+ static void
+-_shortcuts_model_filter_init (ShortcutsModelFilter *model)
++gtk_file_chooser_default_remove_filter (GtkFileChooser *chooser,
++ GtkFileFilter *filter)
+ {
+- model->impl = NULL;
+ }
+
+-/* GtkTreeDragSource::row_draggable implementation for the shortcuts filter model */
+-static gboolean
+-shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source,
+- GtkTreePath *path)
++static GSList *
++gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
+ {
+- 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);
++ return NULL;
+ }
+
+-/* 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)
++gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
++ const GtkFilePath *path,
++ GError **error)
+ {
+- ShortcutsModelFilter *model;
+-
+- model = SHORTCUTS_MODEL_FILTER (drag_source);
+-
+- /* FIXME */
+-
+- return FALSE;
++ return FALSE;
+ }
+
+-/* Fill the GtkTreeDragSourceIface vtable */
+-static void
+-shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface)
++static gboolean
++gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
++ const GtkFilePath *path,
++ GError **error)
+ {
+- iface->row_draggable = shortcuts_model_filter_row_draggable;
+- iface->drag_data_get = shortcuts_model_filter_drag_data_get;
++ return TRUE;
+ }
+
+-#if 0
+-/* Fill the GtkTreeDragDestIface vtable */
+-static void
+-shortcuts_model_filter_drag_dest_iface_init (GtkTreeDragDestIface *iface)
++static GSList *
++gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
+ {
+- iface->drag_data_received = shortcuts_model_filter_drag_data_received;
+- iface->row_drop_possible = shortcuts_model_filter_row_drop_possible;
++ return NULL;
+ }
+-#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);
+-}
+
+ #define __GTK_FILE_CHOOSER_DEFAULT_C__
+ #include "gtkaliasdef.c"
diff --git a/meta/packages/gtk+/gtk+-2.6.8/filechooser-respect-style.patch b/meta/packages/gtk+/gtk+-2.6.8/filechooser-respect-style.patch
new file mode 100644
index 000000000..76c66a7d2
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.8/filechooser-respect-style.patch
@@ -0,0 +1,77 @@
+--- gtk+-2.6.8/gtk/gtkfilechooserdialog.c.orig 2007-02-09 12:18:25.000000000 +0000
++++ gtk+-2.6.8/gtk/gtkfilechooserdialog.c 2007-02-09 12:18:25.000000000 +0000
+@@ -62,8 +62,6 @@
+
+ static void gtk_file_chooser_dialog_map (GtkWidget *widget);
+ static void gtk_file_chooser_dialog_unmap (GtkWidget *widget);
+-static void gtk_file_chooser_dialog_style_set (GtkWidget *widget,
+- GtkStyle *previous_style);
+
+ static void response_cb (GtkDialog *dialog,
+ gint response_id);
+@@ -122,7 +120,6 @@
+
+ widget_class->map = gtk_file_chooser_dialog_map;
+ widget_class->unmap = gtk_file_chooser_dialog_unmap;
+- widget_class->style_set = gtk_file_chooser_dialog_style_set;
+
+ _gtk_file_chooser_install_properties (gobject_class);
+
+@@ -135,13 +132,19 @@
+ GtkFileChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
+ GTK_TYPE_FILE_CHOOSER_DIALOG,
+ GtkFileChooserDialogPrivate);
++
++ GtkDialog *fc_dialog = GTK_DIALOG (dialog);
++
+ dialog->priv = priv;
+ dialog->priv->default_width = -1;
+ dialog->priv->default_height = -1;
+ dialog->priv->resize_horizontally = TRUE;
+ dialog->priv->resize_vertically = TRUE;
+
+- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
++ gtk_dialog_set_has_separator (fc_dialog, FALSE);
++ gtk_container_set_border_width (GTK_CONTAINER (fc_dialog), 5);
++ gtk_box_set_spacing (GTK_BOX (fc_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
++ gtk_container_set_border_width (GTK_CONTAINER (fc_dialog->action_area), 5);
+
+ /* We do a signal connection here rather than overriding the method in
+ * class_init because GtkDialog::response is a RUN_LAST signal. We want *our*
+@@ -394,6 +397,7 @@
+ g_signal_connect (priv->widget, "default-size-changed",
+ G_CALLBACK (file_chooser_widget_default_size_changed), object);
+
++ gtk_container_set_border_width (GTK_CONTAINER (priv->widget), 5);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), priv->widget, TRUE, TRUE, 0);
+
+ gtk_widget_show (priv->widget);
+@@ -522,28 +526,6 @@
+ gtk_widget_unmap (priv->widget);
+ }
+
+-static void
+-gtk_file_chooser_dialog_style_set (GtkWidget *widget,
+- GtkStyle *previous_style)
+-{
+- GtkDialog *dialog;
+-
+- if (GTK_WIDGET_CLASS (parent_class)->style_set)
+- GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
+-
+- dialog = GTK_DIALOG (widget);
+-
+- /* Override the style properties with HIG-compliant spacings. Ugh.
+- * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
+- * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
+- */
+-
+- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
+- gtk_box_set_spacing (GTK_BOX (dialog->vbox), 24);
+-
+- gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
+- gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
+-}
+
+ /* GtkDialog::response handler */
+ static void
diff --git a/meta/packages/gtk+/gtk+_2.6.8.bb b/meta/packages/gtk+/gtk+_2.6.8.bb
index 50990f14b..9fa6700a5 100644
--- a/meta/packages/gtk+/gtk+_2.6.8.bb
+++ b/meta/packages/gtk+/gtk+_2.6.8.bb
@@ -5,7 +5,7 @@ HOMEPAGE = "http://www.gtk.org"
SECTION = "libs"
PRIORITY = "optional"
DEPENDS = "glib-2.0 pango atk jpeg libpng libxext libxcursor gtk-doc libgcrypt"
-PR = "r3"
+PR = "r4"
SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
file://no-demos.patch;patch=1 \
@@ -19,7 +19,9 @@ SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
file://scroll-timings.patch;patch=1 \
file://no-deprecation.patch;patch=1 \
file://filesystem-volumes.patch;patch=1 \
- file://smaller-filechooser.patch;patch=1"
+ file://filechooser-respect-style.patch;patch=1 \
+ file://filechooser-default.patch;patch=1 \
+ "
inherit autotools pkgconfig