summaryrefslogtreecommitdiffstats
path: root/meta/packages/gtk+
diff options
context:
space:
mode:
authorRoss Burton <ross@openedhand.com>2007-06-04 11:49:05 +0000
committerRoss Burton <ross@openedhand.com>2007-06-04 11:49:05 +0000
commit16b9beebed639c7dab9629be2127c301a25d05b3 (patch)
treeabb5bb839b2de3e4356169d2bc978d020ae92c57 /meta/packages/gtk+
parent350603316e8af31443de1c0b44674935ac142798 (diff)
downloadpoky-16b9beebed639c7dab9629be2127c301a25d05b3.tar.gz
Merge interesting patches from GTK+ 2.6.8 to 2.6.10
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1855 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/gtk+')
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/filechooser-default.patch4980
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/filechooser-respect-style.patch77
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch182
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/help.patch158
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/menu-styling.patch22
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/single-click.patch54
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/small-gtkfilesel.patch267
-rw-r--r--meta/packages/gtk+/gtk+-2.6.10/spinbutton.patch128
-rw-r--r--meta/packages/gtk+/gtk+_2.6.10.bb11
9 files changed, 5243 insertions, 636 deletions
diff --git a/meta/packages/gtk+/gtk+-2.6.10/filechooser-default.patch b/meta/packages/gtk+/gtk+-2.6.10/filechooser-default.patch
new file mode 100644
index 0000000000..fa2dfb4843
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.10/filechooser-default.patch
@@ -0,0 +1,4980 @@
1--- gtk+-2.6.8/gtk/gtkfilechooserdefault.c.orig 2007-02-09 18:37:47.000000000 +0000
2+++ gtk+-2.6.8/gtk/gtkfilechooserdefault.c 2007-02-09 18:37:47.000000000 +0000
3@@ -31,7 +31,6 @@
4 #include "gtkcombobox.h"
5 #include "gtkentry.h"
6 #include "gtkeventbox.h"
7-#include "gtkexpander.h"
8 #include "gtkfilechooserdefault.h"
9 #include "gtkfilechooserembed.h"
10 #include "gtkfilechooserentry.h"
11@@ -50,7 +49,6 @@
12 #include "gtkmarshalers.h"
13 #include "gtkmenuitem.h"
14 #include "gtkmessagedialog.h"
15-#include "gtkpathbar.h"
16 #include "gtkprivate.h"
17 #include "gtkscrolledwindow.h"
18 #include "gtkseparatormenuitem.h"
19@@ -79,18 +77,23 @@
20 #include <string.h>
21 #include <time.h>
22
23+#define DEFAULT_SPACING 5
24+
25+#define GTK26
26 typedef struct _GtkFileChooserDefaultClass GtkFileChooserDefaultClass;
27
28 #define GTK_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
29 #define GTK_IS_FILE_CHOOSER_DEFAULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_CHOOSER_DEFAULT))
30 #define GTK_FILE_CHOOSER_DEFAULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_CHOOSER_DEFAULT, GtkFileChooserDefaultClass))
31
32+#ifdef GTK26
33 typedef enum {
34 LOAD_EMPTY, /* There is no model */
35 LOAD_PRELOAD, /* Model is loading and a timer is running; model isn't inserted into the tree yet */
36 LOAD_LOADING, /* Timeout expired, model is inserted into the tree, but not fully loaded yet */
37 LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
38 } LoadState;
39+#endif
40
41 #define MAX_LOADING_TIME 500
42
43@@ -109,63 +112,38 @@
44
45 /* Save mode widgets */
46 GtkWidget *save_widgets;
47-
48 GtkWidget *save_file_name_entry;
49- GtkWidget *save_folder_label;
50- GtkWidget *save_folder_combo;
51- GtkWidget *save_expander;
52
53 /* The file browsing widgets */
54 GtkWidget *browse_widgets;
55- GtkWidget *browse_shortcuts_tree_view;
56- GtkWidget *browse_shortcuts_add_button;
57- GtkWidget *browse_shortcuts_remove_button;
58 GtkWidget *browse_files_tree_view;
59- GtkWidget *browse_files_popup_menu;
60- GtkWidget *browse_files_popup_menu_add_shortcut_item;
61- GtkWidget *browse_files_popup_menu_hidden_files_item;
62 GtkWidget *browse_new_folder_button;
63- GtkWidget *browse_path_bar;
64-
65+ GtkWidget *bar;
66+ GtkWidget * up_button;
67+
68 GtkFileSystemModel *browse_files_model;
69
70- GtkWidget *filter_combo_hbox;
71 GtkWidget *filter_combo;
72- GtkWidget *preview_box;
73- GtkWidget *preview_label;
74- GtkWidget *preview_widget;
75- GtkWidget *extra_align;
76- GtkWidget *extra_widget;
77-
78- GtkListStore *shortcuts_model;
79- GtkTreeModel *shortcuts_filter_model;
80-
81+
82 GtkTreeModelSort *sort_model;
83
84 LoadState load_state;
85 guint load_timeout_id;
86
87 GSList *pending_select_paths;
88-
89+ GSList * path_history;
90+
91 GtkFileFilter *current_filter;
92 GSList *filters;
93
94 GtkTooltips *tooltips;
95
96- gboolean has_home;
97- gboolean has_desktop;
98-
99 int num_volumes;
100- int num_shortcuts;
101- int num_bookmarks;
102
103 gulong volumes_changed_id;
104- gulong bookmarks_changed_id;
105
106 GtkFilePath *current_volume_path;
107 GtkFilePath *current_folder;
108- GtkFilePath *preview_path;
109- char *preview_display_name;
110
111 GtkTreeViewColumn *list_name_column;
112 GtkCellRenderer *list_name_renderer;
113@@ -179,25 +157,15 @@
114 gulong toplevel_set_focus_id;
115 GtkWidget *toplevel_last_focus_widget;
116
117-#if 0
118- GdkDragContext *shortcuts_drag_context;
119- GSource *shortcuts_drag_outside_idle;
120-#endif
121-
122+ gchar * root_folder;
123+
124 /* Flags */
125
126 guint local_only : 1;
127- guint preview_widget_active : 1;
128- guint use_preview_label : 1;
129 guint select_multiple : 1;
130 guint show_hidden : 1;
131 guint list_sort_ascending : 1;
132 guint changing_folder : 1;
133- guint shortcuts_current_folder_active : 1;
134-
135-#if 0
136- guint shortcuts_drag_outside : 1;
137-#endif
138 };
139
140 /* Signal IDs */
141@@ -211,17 +179,6 @@
142
143 static guint signals[LAST_SIGNAL] = { 0 };
144
145-/* Column numbers for the shortcuts tree. Keep these in sync with shortcuts_model_create() */
146-enum {
147- SHORTCUTS_COL_PIXBUF,
148- SHORTCUTS_COL_NAME,
149- SHORTCUTS_COL_DATA,
150- SHORTCUTS_COL_IS_VOLUME,
151- SHORTCUTS_COL_REMOVABLE,
152- SHORTCUTS_COL_PIXBUF_VISIBLE,
153- SHORTCUTS_COL_NUM_COLUMNS
154-};
155-
156 /* Column numbers for the file list */
157 enum {
158 FILE_LIST_COL_NAME,
159@@ -236,23 +193,6 @@
160 TEXT_URI_LIST
161 };
162
163-/* Target types for dragging from the shortcuts list */
164-static const GtkTargetEntry shortcuts_source_targets[] = {
165- { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW }
166-};
167-
168-static const int num_shortcuts_source_targets = (sizeof (shortcuts_source_targets)
169- / sizeof (shortcuts_source_targets[0]));
170-
171-/* Target types for dropping into the shortcuts list */
172-static const GtkTargetEntry shortcuts_dest_targets[] = {
173- { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, GTK_TREE_MODEL_ROW },
174- { "text/uri-list", 0, TEXT_URI_LIST }
175-};
176-
177-static const int num_shortcuts_dest_targets = (sizeof (shortcuts_dest_targets)
178- / sizeof (shortcuts_dest_targets[0]));
179-
180 /* Target types for DnD from the file list */
181 static const GtkTargetEntry file_list_source_targets[] = {
182 { "text/uri-list", 0, TEXT_URI_LIST }
183@@ -261,22 +201,10 @@
184 static const int num_file_list_source_targets = (sizeof (file_list_source_targets)
185 / sizeof (file_list_source_targets[0]));
186
187-/* Interesting places in the shortcuts bar */
188-typedef enum {
189- SHORTCUTS_HOME,
190- SHORTCUTS_DESKTOP,
191- SHORTCUTS_VOLUMES,
192- SHORTCUTS_SHORTCUTS,
193- SHORTCUTS_BOOKMARKS_SEPARATOR,
194- SHORTCUTS_BOOKMARKS,
195- SHORTCUTS_CURRENT_FOLDER_SEPARATOR,
196- SHORTCUTS_CURRENT_FOLDER
197-} ShortcutsIndex;
198-
199 /* Icon size for if we can't get it from the theme */
200 #define FALLBACK_ICON_SIZE 16
201
202-#define PREVIEW_HBOX_SPACING 12
203+#define LIST_HBOX_SPACING DEFAULT_SPACING
204 #define NUM_LINES 40
205 #define NUM_CHARS 60
206
207@@ -335,7 +263,6 @@
208 const GtkFilePath *path,
209 GError **error);
210 static GSList * gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser);
211-
212 static void gtk_file_chooser_default_get_default_size (GtkFileChooserEmbed *chooser_embed,
213 gint *default_width,
214 gint *default_height);
215@@ -352,37 +279,11 @@
216 static void home_folder_handler (GtkFileChooserDefault *impl);
217 static void update_appearance (GtkFileChooserDefault *impl);
218
219-static void set_current_filter (GtkFileChooserDefault *impl,
220- GtkFileFilter *filter);
221-static void check_preview_change (GtkFileChooserDefault *impl);
222-
223 static void filter_combo_changed (GtkComboBox *combo_box,
224 GtkFileChooserDefault *impl);
225-static void shortcuts_row_activated_cb (GtkTreeView *tree_view,
226- GtkTreePath *path,
227- GtkTreeViewColumn *column,
228- GtkFileChooserDefault *impl);
229-
230-static gboolean shortcuts_key_press_event_cb (GtkWidget *widget,
231- GdkEventKey *event,
232- GtkFileChooserDefault *impl);
233-
234-static gboolean shortcuts_select_func (GtkTreeSelection *selection,
235- GtkTreeModel *model,
236- GtkTreePath *path,
237- gboolean path_currently_selected,
238- gpointer data);
239-static gboolean shortcuts_get_selected (GtkFileChooserDefault *impl,
240- GtkTreeIter *iter);
241-static void shortcuts_activate_iter (GtkFileChooserDefault *impl,
242- GtkTreeIter *iter);
243-static int shortcuts_get_index (GtkFileChooserDefault *impl,
244- ShortcutsIndex where);
245-static int shortcut_find_position (GtkFileChooserDefault *impl,
246- const GtkFilePath *path);
247-
248-static void bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl);
249
250+static void set_current_filter (GtkFileChooserDefault *impl,
251+ GtkFileFilter *filter);
252 static gboolean list_select_func (GtkTreeSelection *selection,
253 GtkTreeModel *model,
254 GtkTreePath *path,
255@@ -401,16 +302,6 @@
256 GtkTreeIter *iter,
257 gpointer user_data);
258
259-static void path_bar_clicked (GtkPathBar *path_bar,
260- GtkFilePath *file_path,
261- gboolean child_is_hidden,
262- GtkFileChooserDefault *impl);
263-
264-static void add_bookmark_button_clicked_cb (GtkButton *button,
265- GtkFileChooserDefault *impl);
266-static void remove_bookmark_button_clicked_cb (GtkButton *button,
267- GtkFileChooserDefault *impl);
268-
269 static void list_icon_data_func (GtkTreeViewColumn *tree_column,
270 GtkCellRenderer *cell,
271 GtkTreeModel *tree_model,
272@@ -441,36 +332,6 @@
273
274 static GObjectClass *parent_class;
275
276-
277-
278-/* Drag and drop interface declarations */
279-
280-typedef struct {
281- GtkTreeModelFilter parent;
282-
283- GtkFileChooserDefault *impl;
284-} ShortcutsModelFilter;
285-
286-typedef struct {
287- GtkTreeModelFilterClass parent_class;
288-} ShortcutsModelFilterClass;
289-
290-#define SHORTCUTS_MODEL_FILTER_TYPE (_shortcuts_model_filter_get_type ())
291-#define SHORTCUTS_MODEL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SHORTCUTS_MODEL_FILTER_TYPE, ShortcutsModelFilter))
292-
293-static void shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface);
294-
295-G_DEFINE_TYPE_WITH_CODE (ShortcutsModelFilter,
296- _shortcuts_model_filter,
297- GTK_TYPE_TREE_MODEL_FILTER,
298- G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_DRAG_SOURCE,
299- shortcuts_model_filter_drag_source_iface_init));
300-
301-static GtkTreeModel *shortcuts_model_filter_new (GtkFileChooserDefault *impl,
302- GtkTreeModel *child_model,
303- GtkTreePath *root);
304-
305-
306
307 GType
308 _gtk_file_chooser_default_get_type (void)
309@@ -520,6 +381,11 @@
310 return file_chooser_default_type;
311 }
312
313+enum
314+{
315+ GTK_FILE_CHOOSER_PROP_ROOT_FOLDER = GTK_FILE_CHOOSER_PROP_LAST + 1,
316+};
317+
318 static void
319 gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
320 {
321@@ -617,6 +483,14 @@
322 "home-folder",
323 0);
324
325+ g_object_class_install_property (gobject_class,
326+ GTK_FILE_CHOOSER_PROP_ROOT_FOLDER,
327+ g_param_spec_string ("root-folder",
328+ P_("File System Root"),
329+ P_("Root folder for the file system below which the user should not be able to switch"),
330+ NULL,
331+ G_PARAM_WRITABLE));
332+
333 _gtk_file_chooser_install_properties (gobject_class);
334
335 gtk_settings_install_property (g_param_spec_string ("gtk-file-chooser-backend",
336@@ -634,7 +508,6 @@
337 iface->select_all = gtk_file_chooser_default_select_all;
338 iface->unselect_all = gtk_file_chooser_default_unselect_all;
339 iface->get_paths = gtk_file_chooser_default_get_paths;
340- iface->get_preview_path = gtk_file_chooser_default_get_preview_path;
341 iface->get_file_system = gtk_file_chooser_default_get_file_system;
342 iface->set_current_folder = gtk_file_chooser_default_set_current_folder;
343 iface->get_current_folder = gtk_file_chooser_default_get_current_folder;
344@@ -642,9 +515,12 @@
345 iface->add_filter = gtk_file_chooser_default_add_filter;
346 iface->remove_filter = gtk_file_chooser_default_remove_filter;
347 iface->list_filters = gtk_file_chooser_default_list_filters;
348+
349+ /* these are only stubs */
350+ iface->get_preview_path = gtk_file_chooser_default_get_preview_path;
351 iface->add_shortcut_folder = gtk_file_chooser_default_add_shortcut_folder;
352 iface->remove_shortcut_folder = gtk_file_chooser_default_remove_shortcut_folder;
353- iface->list_shortcut_folders = gtk_file_chooser_default_list_shortcut_folders;
354+
355 }
356
357 static void
358@@ -659,71 +535,22 @@
359 gtk_file_chooser_default_init (GtkFileChooserDefault *impl)
360 {
361 impl->local_only = TRUE;
362- impl->preview_widget_active = TRUE;
363- impl->use_preview_label = TRUE;
364 impl->select_multiple = FALSE;
365 impl->show_hidden = FALSE;
366 impl->icon_size = FALLBACK_ICON_SIZE;
367 impl->load_state = LOAD_EMPTY;
368 impl->pending_select_paths = NULL;
369-
370+ impl->path_history = NULL;
371+
372 gtk_widget_set_redraw_on_allocate (GTK_WIDGET (impl), TRUE);
373- gtk_box_set_spacing (GTK_BOX (impl), 12);
374+ gtk_box_set_spacing (GTK_BOX (impl), DEFAULT_SPACING);
375
376 impl->tooltips = gtk_tooltips_new ();
377 g_object_ref (impl->tooltips);
378 gtk_object_sink (GTK_OBJECT (impl->tooltips));
379-}
380
381-/* Frees the data columns for the specified iter in the shortcuts model*/
382-static void
383-shortcuts_free_row_data (GtkFileChooserDefault *impl,
384- GtkTreeIter *iter)
385-{
386- gpointer col_data;
387- gboolean is_volume;
388-
389- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
390- SHORTCUTS_COL_DATA, &col_data,
391- SHORTCUTS_COL_IS_VOLUME, &is_volume,
392- -1);
393- if (!col_data)
394- return;
395-
396- if (is_volume)
397- {
398- GtkFileSystemVolume *volume;
399-
400- volume = col_data;
401- gtk_file_system_volume_free (impl->file_system, volume);
402- }
403- else
404- {
405- GtkFilePath *path;
406-
407- path = col_data;
408- gtk_file_path_free (path);
409- }
410-}
411-
412-/* Frees all the data columns in the shortcuts model */
413-static void
414-shortcuts_free (GtkFileChooserDefault *impl)
415-{
416- GtkTreeIter iter;
417-
418- if (!impl->shortcuts_model)
419- return;
420-
421- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
422- do
423- {
424- shortcuts_free_row_data (impl, &iter);
425- }
426- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter));
427-
428- g_object_unref (impl->shortcuts_model);
429- impl->shortcuts_model = NULL;
430+ if (!impl->root_folder)
431+ impl->root_folder = g_strdup ("/");
432 }
433
434 static void
435@@ -743,6 +570,7 @@
436 impl->pending_select_paths = NULL;
437 }
438
439+
440 static void
441 pending_select_paths_add (GtkFileChooserDefault *impl,
442 const GtkFilePath *path)
443@@ -782,20 +610,30 @@
444 }
445
446 static void
447-gtk_file_chooser_default_finalize (GObject *object)
448+path_history_free (GtkFileChooserDefault *impl)
449 {
450- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
451 GSList *l;
452
453- if (impl->shortcuts_filter_model)
454- g_object_unref (impl->shortcuts_filter_model);
455+ for (l = impl->path_history; l; l = l->next)
456+ {
457+ GtkFilePath *path;
458+
459+ path = l->data;
460+ gtk_file_path_free (path);
461+ }
462+
463+ g_slist_free (impl->path_history);
464+ impl->path_history = NULL;
465+}
466
467- shortcuts_free (impl);
468+static void
469+gtk_file_chooser_default_finalize (GObject *object)
470+{
471+ GSList *l;
472+ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (object);
473
474 g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
475 impl->volumes_changed_id = 0;
476- g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
477- impl->bookmarks_changed_id = 0;
478 g_object_unref (impl->file_system);
479
480 for (l = impl->filters; l; l = l->next)
481@@ -816,11 +654,9 @@
482 if (impl->current_folder)
483 gtk_file_path_free (impl->current_folder);
484
485- if (impl->preview_path)
486- gtk_file_path_free (impl->preview_path);
487-
488 pending_select_paths_free (impl);
489-
490+ path_history_free (impl);
491+
492 load_remove_timer (impl);
493
494 /* Free all the Models we have */
495@@ -830,12 +666,12 @@
496 if (impl->sort_model)
497 g_object_unref (impl->sort_model);
498
499- g_free (impl->preview_display_name);
500-
501 g_free (impl->edited_new_text);
502
503 g_object_unref (impl->tooltips);
504
505+ g_free (impl->root_folder);
506+
507 G_OBJECT_CLASS (parent_class)->finalize (object);
508 }
509
510@@ -916,28 +752,6 @@
511 path, error);
512 }
513
514-/* Shows an error dialog about not being able to add a bookmark */
515-static void
516-error_adding_bookmark_dialog (GtkFileChooserDefault *impl,
517- const GtkFilePath *path,
518- GError *error)
519-{
520- error_dialog (impl,
521- _("Could not add a bookmark"),
522- path, error);
523-}
524-
525-/* Shows an error dialog about not being able to remove a bookmark */
526-static void
527-error_removing_bookmark_dialog (GtkFileChooserDefault *impl,
528- const GtkFilePath *path,
529- GError *error)
530-{
531- error_dialog (impl,
532- _("Could not remove bookmark"),
533- path, error);
534-}
535-
536 /* Shows an error dialog about not being able to create a folder */
537 static void
538 error_creating_folder_dialog (GtkFileChooserDefault *impl,
539@@ -949,21 +763,6 @@
540 path, error);
541 }
542
543-/* Shows an error about not being able to create a folder because a file with
544- * the same name is already there.
545- */
546-static void
547-error_creating_folder_over_existing_file_dialog (GtkFileChooserDefault *impl,
548- const GtkFilePath *path,
549- GError *error)
550-{
551- error_dialog (impl,
552- _("The folder could not be created, as a file with the same name "
553- "already exists. Try using a different name for the folder, "
554- "or rename the file first."),
555- path, error);
556-}
557-
558 /* Shows an error dialog about not being able to create a filename */
559 static void
560 error_building_filename_dialog (GtkFileChooserDefault *impl,
561@@ -993,6 +792,7 @@
562 GError *error;
563 gboolean result;
564 GtkFilePath *path_copy;
565+ gchar * file_name;
566
567 /* We copy the path because of this case:
568 *
569@@ -1005,6 +805,29 @@
570
571 path_copy = gtk_file_path_copy (path);
572
573+ file_name = gtk_file_system_path_to_filename (impl->file_system, path_copy);
574+
575+ /* refuse to change below the root */
576+ if (file_name && impl->root_folder &&
577+ strcmp (file_name, impl->root_folder) &&
578+ !strncmp (file_name, impl->root_folder, strlen (file_name)))
579+ {
580+
581+ gtk_file_path_free (path_copy);
582+ g_free (file_name);
583+ return 0;
584+ }
585+ else if (file_name && impl->root_folder &&
586+ !strcmp (file_name, impl->root_folder))
587+ {
588+ gtk_widget_set_sensitive (impl->up_button, FALSE);
589+ }
590+ else
591+ {
592+ gtk_widget_set_sensitive (impl->up_button, TRUE);
593+ }
594+
595+
596 error = NULL;
597 result = _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), path_copy, &error);
598
599@@ -1012,2009 +835,245 @@
600 error_changing_folder_dialog (impl, path_copy, error);
601
602 gtk_file_path_free (path_copy);
603-
604+ g_free (file_name);
605+
606 return result;
607 }
608
609-static void
610-update_preview_widget_visibility (GtkFileChooserDefault *impl)
611-{
612- if (impl->use_preview_label)
613- {
614- if (!impl->preview_label)
615- {
616- impl->preview_label = gtk_label_new (impl->preview_display_name);
617- gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_label, FALSE, FALSE, 0);
618- gtk_box_reorder_child (GTK_BOX (impl->preview_box), impl->preview_label, 0);
619- gtk_label_set_ellipsize (GTK_LABEL (impl->preview_label), PANGO_ELLIPSIZE_MIDDLE);
620- gtk_widget_show (impl->preview_label);
621- }
622- }
623- else
624- {
625- if (impl->preview_label)
626- {
627- gtk_widget_destroy (impl->preview_label);
628- impl->preview_label = NULL;
629- }
630- }
631-
632- if (impl->preview_widget_active && impl->preview_widget)
633- gtk_widget_show (impl->preview_box);
634- else
635- gtk_widget_hide (impl->preview_box);
636-
637- g_signal_emit_by_name (impl, "default-size-changed");
638-}
639
640-static void
641-set_preview_widget (GtkFileChooserDefault *impl,
642- GtkWidget *preview_widget)
643+/* Returns whether a path is a folder */
644+static gboolean
645+check_is_folder (GtkFileSystem *file_system,
646+ const GtkFilePath *path,
647+ GError **error)
648 {
649- if (preview_widget == impl->preview_widget)
650- return;
651-
652- if (impl->preview_widget)
653- gtk_container_remove (GTK_CONTAINER (impl->preview_box),
654- impl->preview_widget);
655-
656- impl->preview_widget = preview_widget;
657- if (impl->preview_widget)
658- {
659- gtk_widget_show (impl->preview_widget);
660- gtk_box_pack_start (GTK_BOX (impl->preview_box), impl->preview_widget, TRUE, TRUE, 0);
661- gtk_box_reorder_child (GTK_BOX (impl->preview_box),
662- impl->preview_widget,
663- (impl->use_preview_label && impl->preview_label) ? 1 : 0);
664- }
665+ GtkFileFolder *folder;
666+#ifdef GTK26
667+ folder = gtk_file_system_get_folder (file_system, path, 0, error);
668+#else
669+ folder = gtk_file_system_get_folder (file_system, path, 0, NULL, NULL);
670+#endif
671+ if (!folder)
672+ return FALSE;
673
674- update_preview_widget_visibility (impl);
675+ g_object_unref (folder);
676+ return TRUE;
677 }
678
679-/* Re-reads all the icons for the shortcuts, used when the theme changes */
680+
681+/* Callback used when the "New Folder" button is clicked */
682 static void
683-shortcuts_reload_icons (GtkFileChooserDefault *impl)
684+new_folder_button_clicked (GtkButton *button,
685+ GtkFileChooserDefault *impl)
686 {
687 GtkTreeIter iter;
688+ GtkTreePath *path;
689
690- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
691- return;
692+ if (!impl->browse_files_model)
693+ return; /* FIXME: this sucks. Disable the New Folder button or something. */
694
695- do {
696- gpointer data;
697- gboolean is_volume;
698- gboolean pixbuf_visible;
699- GdkPixbuf *pixbuf;
700-
701- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
702- SHORTCUTS_COL_DATA, &data,
703- SHORTCUTS_COL_IS_VOLUME, &is_volume,
704- SHORTCUTS_COL_PIXBUF_VISIBLE, &pixbuf_visible,
705- -1);
706+ /* Prevent button from being clicked twice */
707+ gtk_widget_set_sensitive (impl->browse_new_folder_button, FALSE);
708
709- if (pixbuf_visible && data)
710- {
711- if (is_volume)
712- {
713- GtkFileSystemVolume *volume;
714+ _gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
715
716- volume = data;
717- pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
718- impl->icon_size, NULL);
719- }
720- else
721- {
722- const GtkFilePath *path;
723+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->browse_files_model), &iter);
724+ gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->browse_files_tree_view),
725+ path, impl->list_name_column,
726+ FALSE, 0.0, 0.0);
727
728- path = data;
729- pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
730- impl->icon_size, NULL);
731- }
732+ g_object_set (impl->list_name_renderer, "editable", TRUE, NULL);
733+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view),
734+ path,
735+ impl->list_name_column,
736+ TRUE);
737
738- gtk_list_store_set (impl->shortcuts_model, &iter,
739- SHORTCUTS_COL_PIXBUF, pixbuf,
740- -1);
741- if (pixbuf)
742- g_object_unref (pixbuf);
743- }
744- } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model),&iter));
745+ gtk_tree_path_free (path);
746 }
747
748-static void
749-shortcuts_find_folder (GtkFileChooserDefault *impl,
750- GtkFilePath *folder)
751+/* Idle handler for creating a new folder after editing its name cell, or for
752+ * canceling the editing.
753+ */
754+static gboolean
755+edited_idle_cb (GtkFileChooserDefault *impl)
756 {
757- GtkTreeSelection *selection;
758- int pos;
759- GtkTreePath *path;
760+ GDK_THREADS_ENTER ();
761+
762+ g_source_destroy (impl->edited_idle);
763+ impl->edited_idle = NULL;
764
765- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
766+ _gtk_file_system_model_remove_editable (impl->browse_files_model);
767+ g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
768+
769+ gtk_widget_set_sensitive (impl->browse_new_folder_button, TRUE);
770
771- g_assert (folder != NULL);
772- pos = shortcut_find_position (impl, folder);
773- if (pos == -1)
774+ if (impl->edited_new_text) /* not cancelled? */
775 {
776- gtk_tree_selection_unselect_all (selection);
777- return;
778+ GError *error;
779+ GtkFilePath *file_path;
780+
781+ error = NULL;
782+ file_path = gtk_file_system_make_path (impl->file_system, impl->current_folder, impl->edited_new_text,
783+ &error);
784+ if (file_path)
785+ {
786+ error = NULL;
787+#ifdef GTK26
788+ if (gtk_file_system_create_folder (impl->file_system, file_path, &error))
789+#else
790+ if (gtk_file_system_create_folder (impl->file_system, file_path, NULL, NULL))
791+#endif
792+ change_folder_and_display_error (impl, file_path);
793+ else
794+ error_creating_folder_dialog (impl, file_path, error);
795+
796+ gtk_file_path_free (file_path);
797+ }
798+ else
799+ error_creating_folder_dialog (impl, file_path, error);
800+
801+ g_free (impl->edited_new_text);
802+ impl->edited_new_text = NULL;
803 }
804
805- path = gtk_tree_path_new_from_indices (pos, -1);
806- gtk_tree_selection_select_path (selection, path);
807- gtk_tree_path_free (path);
808+ GDK_THREADS_LEAVE ();
809+
810+ return FALSE;
811 }
812
813-/* If a shortcut corresponds to the current folder, selects it */
814 static void
815-shortcuts_find_current_folder (GtkFileChooserDefault *impl)
816+queue_edited_idle (GtkFileChooserDefault *impl,
817+ const gchar *new_text)
818 {
819- shortcuts_find_folder (impl, impl->current_folder);
820-}
821+ /* We create the folder in an idle handler so that we don't modify the tree
822+ * just now.
823+ */
824
825-/* Convenience function to get the display name and icon info for a path */
826-static GtkFileInfo *
827-get_file_info (GtkFileSystem *file_system,
828- const GtkFilePath *path,
829- gboolean name_only,
830- GError **error)
831-{
832- GtkFilePath *parent_path;
833- GtkFileFolder *parent_folder;
834- GtkFileInfo *info;
835- GError *tmp = NULL;
836-
837- parent_path = NULL;
838- info = NULL;
839-
840- if (!gtk_file_system_get_parent (file_system, path, &parent_path, &tmp))
841- goto out;
842-
843- parent_folder = gtk_file_system_get_folder (file_system, parent_path ? parent_path : path,
844- GTK_FILE_INFO_DISPLAY_NAME
845- | (name_only ? 0 : GTK_FILE_INFO_IS_FOLDER),
846- &tmp);
847- if (!parent_folder)
848- goto out;
849-
850- info = gtk_file_folder_get_info (parent_folder, parent_path ? path : NULL, &tmp);
851- g_object_unref (parent_folder);
852-
853- out:
854- if (parent_path)
855- gtk_file_path_free (parent_path);
856+ g_assert (!impl->edited_idle);
857+ g_assert (!impl->edited_new_text);
858
859- if (tmp)
860- {
861- g_set_error (error,
862- GTK_FILE_CHOOSER_ERROR,
863- GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
864- _("Could not get information about '%s': %s"),
865- gtk_file_path_get_string (path),
866- tmp->message);
867- g_error_free (tmp);
868- }
869-
870- return info;
871-}
872-
873-/* Returns whether a path is a folder */
874-static gboolean
875-check_is_folder (GtkFileSystem *file_system,
876- const GtkFilePath *path,
877- GError **error)
878-{
879- GtkFileFolder *folder;
880-
881- folder = gtk_file_system_get_folder (file_system, path, 0, error);
882- if (!folder)
883- return FALSE;
884-
885- g_object_unref (folder);
886- return TRUE;
887-}
888-
889-/* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
890- * inserts a volume. A position of -1 indicates the end of the tree.
891- */
892-static gboolean
893-shortcuts_insert_path (GtkFileChooserDefault *impl,
894- int pos,
895- gboolean is_volume,
896- GtkFileSystemVolume *volume,
897- const GtkFilePath *path,
898- const char *label,
899- gboolean removable,
900- GError **error)
901-{
902- char *label_copy;
903- GdkPixbuf *pixbuf;
904- gpointer data;
905- GtkTreeIter iter;
906-
907- if (is_volume)
908- {
909- data = volume;
910- label_copy = gtk_file_system_volume_get_display_name (impl->file_system, volume);
911- pixbuf = gtk_file_system_volume_render_icon (impl->file_system, volume, GTK_WIDGET (impl),
912- impl->icon_size, NULL);
913- }
914- else
915- {
916- if (!check_is_folder (impl->file_system, path, error))
917- return FALSE;
918-
919- if (label)
920- label_copy = g_strdup (label);
921- else
922- {
923- GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
924-
925- if (!info)
926- return FALSE;
927-
928- label_copy = g_strdup (gtk_file_info_get_display_name (info));
929- gtk_file_info_free (info);
930- }
931-
932- data = gtk_file_path_copy (path);
933- pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
934- impl->icon_size, NULL);
935- }
936-
937- if (pos == -1)
938- gtk_list_store_append (impl->shortcuts_model, &iter);
939- else
940- gtk_list_store_insert (impl->shortcuts_model, &iter, pos);
941-
942- gtk_list_store_set (impl->shortcuts_model, &iter,
943- SHORTCUTS_COL_PIXBUF, pixbuf,
944- SHORTCUTS_COL_PIXBUF_VISIBLE, TRUE,
945- SHORTCUTS_COL_NAME, label_copy,
946- SHORTCUTS_COL_DATA, data,
947- SHORTCUTS_COL_IS_VOLUME, is_volume,
948- SHORTCUTS_COL_REMOVABLE, removable,
949- -1);
950-
951- g_free (label_copy);
952-
953- if (pixbuf)
954- g_object_unref (pixbuf);
955-
956- return TRUE;
957-}
958-
959-/* Appends an item for the user's home directory to the shortcuts model */
960-static void
961-shortcuts_append_home (GtkFileChooserDefault *impl)
962-{
963- const char *home;
964- GtkFilePath *home_path;
965- GError *error;
966-
967- home = g_get_home_dir ();
968- if (home == NULL)
969- return;
970-
971- home_path = gtk_file_system_filename_to_path (impl->file_system, home);
972-
973- error = NULL;
974- impl->has_home = shortcuts_insert_path (impl, -1, FALSE, NULL, home_path, _("Home"), FALSE, &error);
975- if (!impl->has_home)
976- error_getting_info_dialog (impl, home_path, error);
977-
978- gtk_file_path_free (home_path);
979-}
980-
981-/* Appends the ~/Desktop directory to the shortcuts model */
982-static void
983-shortcuts_append_desktop (GtkFileChooserDefault *impl)
984-{
985- char *name;
986- GtkFilePath *path;
987-
988-#ifdef G_OS_WIN32
989- name = _gtk_file_system_win32_get_desktop ();
990-#else
991- const char *home = g_get_home_dir ();
992- if (home == NULL)
993- return;
994-
995- name = g_build_filename (home, "Desktop", NULL);
996-#endif
997-
998- path = gtk_file_system_filename_to_path (impl->file_system, name);
999- g_free (name);
1000-
1001- impl->has_desktop = shortcuts_insert_path (impl, -1, FALSE, NULL, path, _("Desktop"), FALSE, NULL);
1002- /* We do not actually pop up an error dialog if there is no desktop directory
1003- * because some people may really not want to have one.
1004- */
1005-
1006- gtk_file_path_free (path);
1007-}
1008-
1009-/* Appends a list of GtkFilePath to the shortcuts model; returns how many were inserted */
1010-static int
1011-shortcuts_append_paths (GtkFileChooserDefault *impl,
1012- GSList *paths)
1013-{
1014- int start_row;
1015- int num_inserted;
1016-
1017- /* As there is no separator now, we want to start there.
1018- */
1019- start_row = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
1020- num_inserted = 0;
1021-
1022- for (; paths; paths = paths->next)
1023- {
1024- GtkFilePath *path;
1025- GError *error;
1026-
1027- path = paths->data;
1028- error = NULL;
1029-
1030- if (impl->local_only &&
1031- !gtk_file_system_path_is_local (impl->file_system, path))
1032- continue;
1033-
1034- /* NULL GError, but we don't really want to show error boxes here */
1035- if (shortcuts_insert_path (impl, start_row + num_inserted, FALSE, NULL, path, NULL, TRUE, NULL))
1036- num_inserted++;
1037- }
1038-
1039- return num_inserted;
1040-}
1041-
1042-/* Returns the index for the corresponding item in the shortcuts bar */
1043-static int
1044-shortcuts_get_index (GtkFileChooserDefault *impl,
1045- ShortcutsIndex where)
1046-{
1047- int n;
1048-
1049- n = 0;
1050-
1051- if (where == SHORTCUTS_HOME)
1052- goto out;
1053-
1054- n += impl->has_home ? 1 : 0;
1055-
1056- if (where == SHORTCUTS_DESKTOP)
1057- goto out;
1058-
1059- n += impl->has_desktop ? 1 : 0;
1060-
1061- if (where == SHORTCUTS_VOLUMES)
1062- goto out;
1063-
1064- n += impl->num_volumes;
1065-
1066- if (where == SHORTCUTS_SHORTCUTS)
1067- goto out;
1068-
1069- n += impl->num_shortcuts;
1070-
1071- if (where == SHORTCUTS_BOOKMARKS_SEPARATOR)
1072- goto out;
1073-
1074- /* If there are no bookmarks there won't be a separator */
1075- n += (impl->num_bookmarks > 0) ? 1 : 0;
1076-
1077- if (where == SHORTCUTS_BOOKMARKS)
1078- goto out;
1079-
1080- n += impl->num_bookmarks;
1081-
1082- if (where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR)
1083- goto out;
1084-
1085- n += 1;
1086-
1087- if (where == SHORTCUTS_CURRENT_FOLDER)
1088- goto out;
1089-
1090- g_assert_not_reached ();
1091-
1092- out:
1093-
1094- return n;
1095-}
1096-
1097-/* Removes the specified number of rows from the shortcuts list */
1098-static void
1099-shortcuts_remove_rows (GtkFileChooserDefault *impl,
1100- int start_row,
1101- int n_rows)
1102-{
1103- GtkTreePath *path;
1104-
1105- path = gtk_tree_path_new_from_indices (start_row, -1);
1106-
1107- for (; n_rows; n_rows--)
1108- {
1109- GtkTreeIter iter;
1110-
1111- if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->shortcuts_model), &iter, path))
1112- g_assert_not_reached ();
1113-
1114- shortcuts_free_row_data (impl, &iter);
1115- gtk_list_store_remove (impl->shortcuts_model, &iter);
1116- }
1117-
1118- gtk_tree_path_free (path);
1119-}
1120-
1121-/* Adds all the file system volumes to the shortcuts model */
1122-static void
1123-shortcuts_add_volumes (GtkFileChooserDefault *impl)
1124-{
1125- int start_row;
1126- GSList *list, *l;
1127- int n;
1128- gboolean old_changing_folders;
1129-
1130- old_changing_folders = impl->changing_folder;
1131- impl->changing_folder = TRUE;
1132-
1133- start_row = shortcuts_get_index (impl, SHORTCUTS_VOLUMES);
1134- shortcuts_remove_rows (impl, start_row, impl->num_volumes);
1135- impl->num_volumes = 0;
1136-
1137- list = gtk_file_system_list_volumes (impl->file_system);
1138-
1139- n = 0;
1140-
1141- for (l = list; l; l = l->next)
1142- {
1143- GtkFileSystemVolume *volume;
1144-
1145- volume = l->data;
1146-
1147- if (impl->local_only)
1148- {
1149- GtkFilePath *base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
1150- gboolean is_local = gtk_file_system_path_is_local (impl->file_system, base_path);
1151- gtk_file_path_free (base_path);
1152-
1153- if (!is_local)
1154- {
1155- gtk_file_system_volume_free (impl->file_system, volume);
1156- continue;
1157- }
1158- }
1159-
1160- if (shortcuts_insert_path (impl, start_row + n, TRUE, volume, NULL, NULL, FALSE, NULL))
1161- n++;
1162- else
1163- gtk_file_system_volume_free (impl->file_system, volume);
1164- }
1165-
1166- impl->num_volumes = n;
1167- g_slist_free (list);
1168-
1169- if (impl->shortcuts_filter_model)
1170- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
1171-
1172- impl->changing_folder = old_changing_folders;
1173-}
1174-
1175-/* Inserts a separator node in the shortcuts list */
1176-static void
1177-shortcuts_insert_separator (GtkFileChooserDefault *impl,
1178- ShortcutsIndex where)
1179-{
1180- GtkTreeIter iter;
1181-
1182- g_assert (where == SHORTCUTS_BOOKMARKS_SEPARATOR || where == SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
1183-
1184- gtk_list_store_insert (impl->shortcuts_model, &iter,
1185- shortcuts_get_index (impl, where));
1186- gtk_list_store_set (impl->shortcuts_model, &iter,
1187- SHORTCUTS_COL_PIXBUF, NULL,
1188- SHORTCUTS_COL_PIXBUF_VISIBLE, FALSE,
1189- SHORTCUTS_COL_NAME, NULL,
1190- SHORTCUTS_COL_DATA, NULL,
1191- -1);
1192-}
1193-
1194-/* Updates the list of bookmarks */
1195-static void
1196-shortcuts_add_bookmarks (GtkFileChooserDefault *impl)
1197-{
1198- GSList *bookmarks;
1199- gboolean old_changing_folders;
1200- GtkTreeIter iter;
1201- GtkFilePath *list_selected = NULL;
1202- GtkFilePath *combo_selected = NULL;
1203- gboolean is_volume;
1204- gpointer col_data;
1205-
1206- old_changing_folders = impl->changing_folder;
1207- impl->changing_folder = TRUE;
1208-
1209- if (shortcuts_get_selected (impl, &iter))
1210- {
1211- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model),
1212- &iter,
1213- SHORTCUTS_COL_DATA, &col_data,
1214- SHORTCUTS_COL_IS_VOLUME, &is_volume,
1215- -1);
1216-
1217- if (col_data && !is_volume)
1218- list_selected = gtk_file_path_copy (col_data);
1219- }
1220-
1221- if (impl->save_folder_combo &&
1222- gtk_combo_box_get_active_iter (GTK_COMBO_BOX (impl->save_folder_combo),
1223- &iter))
1224- {
1225- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model),
1226- &iter,
1227- SHORTCUTS_COL_DATA, &col_data,
1228- SHORTCUTS_COL_IS_VOLUME, &is_volume,
1229- -1);
1230-
1231- if (col_data && !is_volume)
1232- combo_selected = gtk_file_path_copy (col_data);
1233- }
1234-
1235- if (impl->num_bookmarks > 0)
1236- shortcuts_remove_rows (impl,
1237- shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR),
1238- impl->num_bookmarks + 1);
1239-
1240- bookmarks = gtk_file_system_list_bookmarks (impl->file_system);
1241- impl->num_bookmarks = shortcuts_append_paths (impl, bookmarks);
1242- gtk_file_paths_free (bookmarks);
1243-
1244- if (impl->num_bookmarks > 0)
1245- shortcuts_insert_separator (impl, SHORTCUTS_BOOKMARKS_SEPARATOR);
1246-
1247- if (impl->shortcuts_filter_model)
1248- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
1249-
1250- if (list_selected)
1251- {
1252- shortcuts_find_folder (impl, list_selected);
1253- gtk_file_path_free (list_selected);
1254- }
1255-
1256- if (combo_selected)
1257- {
1258- gint pos;
1259-
1260- pos = shortcut_find_position (impl, combo_selected);
1261- if (pos != -1)
1262- gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo),
1263- pos);
1264- gtk_file_path_free (combo_selected);
1265- }
1266-
1267- impl->changing_folder = old_changing_folders;
1268-}
1269-
1270-/* Appends a separator and a row to the shortcuts list for the current folder */
1271-static void
1272-shortcuts_add_current_folder (GtkFileChooserDefault *impl)
1273-{
1274- int pos;
1275- gboolean success;
1276-
1277- g_assert (!impl->shortcuts_current_folder_active);
1278-
1279- success = TRUE;
1280-
1281- g_assert (impl->current_folder != NULL);
1282-
1283- pos = shortcut_find_position (impl, impl->current_folder);
1284- if (pos == -1)
1285- {
1286- GtkFileSystemVolume *volume;
1287- GtkFilePath *base_path;
1288-
1289- /* Separator */
1290-
1291- shortcuts_insert_separator (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
1292-
1293- /* Item */
1294-
1295- pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER);
1296-
1297- volume = gtk_file_system_get_volume_for_path (impl->file_system, impl->current_folder);
1298- if (volume)
1299- base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
1300- else
1301- base_path = NULL;
1302-
1303- if (base_path &&
1304- strcmp (gtk_file_path_get_string (base_path), gtk_file_path_get_string (impl->current_folder)) == 0)
1305- {
1306- success = shortcuts_insert_path (impl, pos, TRUE, volume, NULL, NULL, FALSE, NULL);
1307- if (success)
1308- volume = NULL;
1309- }
1310- else
1311- success = shortcuts_insert_path (impl, pos, FALSE, NULL, impl->current_folder, NULL, FALSE, NULL);
1312-
1313- if (volume)
1314- gtk_file_system_volume_free (impl->file_system, volume);
1315-
1316- if (base_path)
1317- gtk_file_path_free (base_path);
1318-
1319- if (!success)
1320- shortcuts_remove_rows (impl, pos - 1, 1); /* remove the separator */
1321-
1322- impl->shortcuts_current_folder_active = success;
1323- }
1324-
1325- if (success)
1326- gtk_combo_box_set_active (GTK_COMBO_BOX (impl->save_folder_combo), pos);
1327-}
1328-
1329-/* Updates the current folder row in the shortcuts model */
1330-static void
1331-shortcuts_update_current_folder (GtkFileChooserDefault *impl)
1332-{
1333- int pos;
1334-
1335- pos = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
1336-
1337- if (impl->shortcuts_current_folder_active)
1338- {
1339- shortcuts_remove_rows (impl, pos, 2);
1340- impl->shortcuts_current_folder_active = FALSE;
1341- }
1342-
1343- shortcuts_add_current_folder (impl);
1344-}
1345-
1346-/* Filter function used for the shortcuts filter model */
1347-static gboolean
1348-shortcuts_filter_cb (GtkTreeModel *model,
1349- GtkTreeIter *iter,
1350- gpointer data)
1351-{
1352- GtkFileChooserDefault *impl;
1353- GtkTreePath *path;
1354- int pos;
1355-
1356- impl = GTK_FILE_CHOOSER_DEFAULT (data);
1357-
1358- path = gtk_tree_model_get_path (model, iter);
1359- if (!path)
1360- return FALSE;
1361-
1362- pos = *gtk_tree_path_get_indices (path);
1363- gtk_tree_path_free (path);
1364-
1365- return (pos < shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR));
1366-}
1367-
1368-/* Creates the list model for shortcuts */
1369-static void
1370-shortcuts_model_create (GtkFileChooserDefault *impl)
1371-{
1372- /* Keep this order in sync with the SHORCUTS_COL_* enum values */
1373- impl->shortcuts_model = gtk_list_store_new (SHORTCUTS_COL_NUM_COLUMNS,
1374- GDK_TYPE_PIXBUF, /* pixbuf */
1375- G_TYPE_STRING, /* name */
1376- G_TYPE_POINTER, /* path or volume */
1377- G_TYPE_BOOLEAN, /* is the previous column a volume? */
1378- G_TYPE_BOOLEAN, /* removable */
1379- G_TYPE_BOOLEAN); /* pixbuf cell visibility */
1380-
1381- if (impl->file_system)
1382- {
1383- shortcuts_append_home (impl);
1384- shortcuts_append_desktop (impl);
1385- shortcuts_add_volumes (impl);
1386- shortcuts_add_bookmarks (impl);
1387- }
1388-
1389- impl->shortcuts_filter_model = shortcuts_model_filter_new (impl,
1390- GTK_TREE_MODEL (impl->shortcuts_model),
1391- NULL);
1392-
1393- gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
1394- shortcuts_filter_cb,
1395- impl,
1396- NULL);
1397-}
1398-
1399-/* Callback used when the "New Folder" button is clicked */
1400-static void
1401-new_folder_button_clicked (GtkButton *button,
1402- GtkFileChooserDefault *impl)
1403-{
1404- GtkTreeIter iter;
1405- GtkTreePath *path;
1406-
1407- if (!impl->browse_files_model)
1408- return; /* FIXME: this sucks. Disable the New Folder button or something. */
1409-
1410- /* Prevent button from being clicked twice */
1411- gtk_widget_set_sensitive (impl->browse_new_folder_button, FALSE);
1412-
1413- _gtk_file_system_model_add_editable (impl->browse_files_model, &iter);
1414-
1415- path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->browse_files_model), &iter);
1416- gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (impl->browse_files_tree_view),
1417- path, impl->list_name_column,
1418- FALSE, 0.0, 0.0);
1419-
1420- g_object_set (impl->list_name_renderer, "editable", TRUE, NULL);
1421- gtk_tree_view_set_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view),
1422- path,
1423- impl->list_name_column,
1424- TRUE);
1425-
1426- gtk_tree_path_free (path);
1427-}
1428-
1429-/* Idle handler for creating a new folder after editing its name cell, or for
1430- * canceling the editing.
1431- */
1432-static gboolean
1433-edited_idle_cb (GtkFileChooserDefault *impl)
1434-{
1435- GDK_THREADS_ENTER ();
1436-
1437- g_source_destroy (impl->edited_idle);
1438- impl->edited_idle = NULL;
1439-
1440- _gtk_file_system_model_remove_editable (impl->browse_files_model);
1441- g_object_set (impl->list_name_renderer, "editable", FALSE, NULL);
1442-
1443- gtk_widget_set_sensitive (impl->browse_new_folder_button, TRUE);
1444-
1445- if (impl->edited_new_text) /* not cancelled? */
1446- {
1447- GError *error;
1448- GtkFilePath *file_path;
1449-
1450- error = NULL;
1451- file_path = gtk_file_system_make_path (impl->file_system, impl->current_folder, impl->edited_new_text,
1452- &error);
1453- if (file_path)
1454- {
1455- error = NULL;
1456- if (gtk_file_system_create_folder (impl->file_system, file_path, &error))
1457- change_folder_and_display_error (impl, file_path);
1458- else
1459- error_creating_folder_dialog (impl, file_path, error);
1460-
1461- gtk_file_path_free (file_path);
1462- }
1463- else
1464- error_creating_folder_dialog (impl, file_path, error);
1465-
1466- g_free (impl->edited_new_text);
1467- impl->edited_new_text = NULL;
1468- }
1469-
1470- GDK_THREADS_LEAVE ();
1471-
1472- return FALSE;
1473-}
1474-
1475-static void
1476-queue_edited_idle (GtkFileChooserDefault *impl,
1477- const gchar *new_text)
1478-{
1479- /* We create the folder in an idle handler so that we don't modify the tree
1480- * just now.
1481- */
1482-
1483- g_assert (!impl->edited_idle);
1484- g_assert (!impl->edited_new_text);
1485-
1486- impl->edited_idle = g_idle_source_new ();
1487- g_source_set_closure (impl->edited_idle,
1488- g_cclosure_new_object (G_CALLBACK (edited_idle_cb),
1489- G_OBJECT (impl)));
1490- g_source_attach (impl->edited_idle, NULL);
1491-
1492- if (new_text)
1493- impl->edited_new_text = g_strdup (new_text);
1494-}
1495-
1496-/* Callback used from the text cell renderer when the new folder is named */
1497-static void
1498-renderer_edited_cb (GtkCellRendererText *cell_renderer_text,
1499- const gchar *path,
1500- const gchar *new_text,
1501- GtkFileChooserDefault *impl)
1502-{
1503- /* work around bug #154921 */
1504- g_object_set (cell_renderer_text,
1505- "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
1506- queue_edited_idle (impl, new_text);
1507-}
1508-
1509-/* Callback used from the text cell renderer when the new folder edition gets
1510- * canceled.
1511- */
1512-static void
1513-renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
1514- GtkFileChooserDefault *impl)
1515-{
1516- /* work around bug #154921 */
1517- g_object_set (cell_renderer_text,
1518- "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
1519- queue_edited_idle (impl, NULL);
1520-}
1521-
1522-/* Creates the widgets for the filter combo box */
1523-static GtkWidget *
1524-filter_create (GtkFileChooserDefault *impl)
1525-{
1526- impl->filter_combo = gtk_combo_box_new_text ();
1527- gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (impl->filter_combo), FALSE);
1528-
1529- g_signal_connect (impl->filter_combo, "changed",
1530- G_CALLBACK (filter_combo_changed), impl);
1531-
1532- return impl->filter_combo;
1533-}
1534-
1535-static GtkWidget *
1536-button_new (GtkFileChooserDefault *impl,
1537- const char *text,
1538- const char *stock_id,
1539- gboolean sensitive,
1540- gboolean show,
1541- GCallback callback)
1542-{
1543- GtkWidget *button;
1544- GtkWidget *hbox;
1545- GtkWidget *widget;
1546- GtkWidget *align;
1547-
1548- button = gtk_button_new ();
1549- hbox = gtk_hbox_new (FALSE, 2);
1550- align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
1551-
1552- gtk_container_add (GTK_CONTAINER (button), align);
1553- gtk_container_add (GTK_CONTAINER (align), hbox);
1554- widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
1555-
1556- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1557-
1558- widget = gtk_label_new_with_mnemonic (text);
1559- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (button));
1560- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
1561-
1562- gtk_widget_set_sensitive (button, sensitive);
1563- g_signal_connect (button, "clicked", callback, impl);
1564-
1565- gtk_widget_show_all (align);
1566-
1567- if (show)
1568- gtk_widget_show (button);
1569-
1570- return button;
1571-}
1572-
1573-/* Looks for a path among the shortcuts; returns its index or -1 if it doesn't exist */
1574-static int
1575-shortcut_find_position (GtkFileChooserDefault *impl,
1576- const GtkFilePath *path)
1577-{
1578- GtkTreeIter iter;
1579- int i;
1580- int current_folder_separator_idx;
1581-
1582- if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
1583- return -1;
1584-
1585- current_folder_separator_idx = shortcuts_get_index (impl, SHORTCUTS_CURRENT_FOLDER_SEPARATOR);
1586-
1587- for (i = 0; i < current_folder_separator_idx; i++)
1588- {
1589- gpointer col_data;
1590- gboolean is_volume;
1591-
1592- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
1593- SHORTCUTS_COL_DATA, &col_data,
1594- SHORTCUTS_COL_IS_VOLUME, &is_volume,
1595- -1);
1596-
1597- if (col_data)
1598- {
1599- if (is_volume)
1600- {
1601- GtkFileSystemVolume *volume;
1602- GtkFilePath *base_path;
1603- gboolean exists;
1604-
1605- volume = col_data;
1606- base_path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
1607-
1608- exists = strcmp (gtk_file_path_get_string (path),
1609- gtk_file_path_get_string (base_path)) == 0;
1610- g_free (base_path);
1611-
1612- if (exists)
1613- return i;
1614- }
1615- else
1616- {
1617- GtkFilePath *model_path;
1618-
1619- model_path = col_data;
1620-
1621- if (model_path && gtk_file_path_compare (model_path, path) == 0)
1622- return i;
1623- }
1624- }
1625-
1626- gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
1627- }
1628-
1629- return -1;
1630-}
1631-
1632-/* Tries to add a bookmark from a path name */
1633-static gboolean
1634-shortcuts_add_bookmark_from_path (GtkFileChooserDefault *impl,
1635- const GtkFilePath *path,
1636- int pos)
1637-{
1638- GError *error;
1639-
1640- if (shortcut_find_position (impl, path) != -1)
1641- return FALSE;
1642-
1643- /* FIXME: this check really belongs in gtk_file_system_insert_bookmark. */
1644- error = NULL;
1645- if (!check_is_folder (impl->file_system, path, &error))
1646- {
1647- error_adding_bookmark_dialog (impl, path, error);
1648- return FALSE;
1649- }
1650-
1651- error = NULL;
1652- if (!gtk_file_system_insert_bookmark (impl->file_system, path, pos, &error))
1653- {
1654- error_adding_bookmark_dialog (impl, path, error);
1655- return FALSE;
1656- }
1657-
1658- return TRUE;
1659-}
1660-
1661-static void
1662-add_bookmark_foreach_cb (GtkTreeModel *model,
1663- GtkTreePath *path,
1664- GtkTreeIter *iter,
1665- gpointer data)
1666-{
1667- GtkFileChooserDefault *impl;
1668- GtkFileSystemModel *fs_model;
1669- GtkTreeIter child_iter;
1670- const GtkFilePath *file_path;
1671-
1672- impl = (GtkFileChooserDefault *) data;
1673-
1674- fs_model = impl->browse_files_model;
1675- gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, iter);
1676-
1677- file_path = _gtk_file_system_model_get_path (fs_model, &child_iter);
1678- shortcuts_add_bookmark_from_path (impl, file_path, -1);
1679-}
1680-
1681-/* Adds a bookmark from the currently selected item in the file list */
1682-static void
1683-bookmarks_add_selected_folder (GtkFileChooserDefault *impl)
1684-{
1685- GtkTreeSelection *selection;
1686-
1687- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
1688-
1689- if (gtk_tree_selection_count_selected_rows (selection) == 0)
1690- shortcuts_add_bookmark_from_path (impl, impl->current_folder, -1);
1691- else
1692- gtk_tree_selection_selected_foreach (selection,
1693- add_bookmark_foreach_cb,
1694- impl);
1695-}
1696-
1697-/* Callback used when the "Add bookmark" button is clicked */
1698-static void
1699-add_bookmark_button_clicked_cb (GtkButton *button,
1700- GtkFileChooserDefault *impl)
1701-{
1702- bookmarks_add_selected_folder (impl);
1703-}
1704-
1705-/* Returns TRUE plus an iter in the shortcuts_model if a row is selected;
1706- * returns FALSE if no shortcut is selected.
1707- */
1708-static gboolean
1709-shortcuts_get_selected (GtkFileChooserDefault *impl,
1710- GtkTreeIter *iter)
1711-{
1712- GtkTreeSelection *selection;
1713- GtkTreeIter parent_iter;
1714-
1715- if (!impl->browse_shortcuts_tree_view)
1716- return FALSE;
1717-
1718- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
1719-
1720- if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter))
1721- return FALSE;
1722-
1723- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
1724- iter,
1725- &parent_iter);
1726- return TRUE;
1727-}
1728-
1729-/* Removes the selected bookmarks */
1730-static void
1731-remove_selected_bookmarks (GtkFileChooserDefault *impl)
1732-{
1733- GtkTreeIter iter;
1734- gpointer col_data;
1735- GtkFilePath *path;
1736- gboolean removable;
1737- GError *error;
1738-
1739- if (!shortcuts_get_selected (impl, &iter))
1740- return;
1741-
1742- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
1743- SHORTCUTS_COL_DATA, &col_data,
1744- SHORTCUTS_COL_REMOVABLE, &removable,
1745- -1);
1746- g_assert (col_data != NULL);
1747-
1748- if (!removable)
1749- return;
1750-
1751- path = col_data;
1752-
1753- error = NULL;
1754- if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
1755- error_removing_bookmark_dialog (impl, path, error);
1756-}
1757-
1758-/* Callback used when the "Remove bookmark" button is clicked */
1759-static void
1760-remove_bookmark_button_clicked_cb (GtkButton *button,
1761- GtkFileChooserDefault *impl)
1762-{
1763- remove_selected_bookmarks (impl);
1764-}
1765-
1766-struct selection_check_closure {
1767- GtkFileChooserDefault *impl;
1768- int num_selected;
1769- gboolean all_files;
1770- gboolean all_folders;
1771-};
1772-
1773-/* Used from gtk_tree_selection_selected_foreach() */
1774-static void
1775-selection_check_foreach_cb (GtkTreeModel *model,
1776- GtkTreePath *path,
1777- GtkTreeIter *iter,
1778- gpointer data)
1779-{
1780- struct selection_check_closure *closure;
1781- GtkTreeIter child_iter;
1782- const GtkFileInfo *info;
1783- gboolean is_folder;
1784-
1785- closure = data;
1786- closure->num_selected++;
1787-
1788- gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
1789-
1790- info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
1791- is_folder = info ? gtk_file_info_get_is_folder (info) : FALSE;
1792-
1793- closure->all_folders = closure->all_folders && is_folder;
1794- closure->all_files = closure->all_files && !is_folder;
1795-}
1796-
1797-/* Checks whether the selected items in the file list are all files or all folders */
1798-static void
1799-selection_check (GtkFileChooserDefault *impl,
1800- gint *num_selected,
1801- gboolean *all_files,
1802- gboolean *all_folders)
1803-{
1804- struct selection_check_closure closure;
1805- GtkTreeSelection *selection;
1806-
1807- closure.impl = impl;
1808- closure.num_selected = 0;
1809- closure.all_files = TRUE;
1810- closure.all_folders = TRUE;
1811-
1812- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
1813- gtk_tree_selection_selected_foreach (selection,
1814- selection_check_foreach_cb,
1815- &closure);
1816-
1817- g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
1818-
1819- if (num_selected)
1820- *num_selected = closure.num_selected;
1821-
1822- if (all_files)
1823- *all_files = closure.all_files;
1824-
1825- if (all_folders)
1826- *all_folders = closure.all_folders;
1827-}
1828-
1829-struct get_selected_path_closure {
1830- GtkFileChooserDefault *impl;
1831- const GtkFilePath *path;
1832-};
1833-
1834-static void
1835-get_selected_path_foreach_cb (GtkTreeModel *model,
1836- GtkTreePath *path,
1837- GtkTreeIter *iter,
1838- gpointer data)
1839-{
1840- struct get_selected_path_closure *closure;
1841- GtkTreeIter child_iter;
1842-
1843- closure = data;
1844-
1845- gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
1846- closure->path = _gtk_file_system_model_get_path (closure->impl->browse_files_model, &child_iter);
1847-}
1848-
1849-/* Returns a selected path from the file list */
1850-static const GtkFilePath *
1851-get_selected_path (GtkFileChooserDefault *impl)
1852-{
1853- struct get_selected_path_closure closure;
1854- GtkTreeSelection *selection;
1855-
1856- closure.impl = impl;
1857- closure.path = NULL;
1858-
1859- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
1860- gtk_tree_selection_selected_foreach (selection,
1861- get_selected_path_foreach_cb,
1862- &closure);
1863-
1864- return closure.path;
1865-}
1866-
1867-typedef struct {
1868- GtkFileChooserDefault *impl;
1869- gchar *tip;
1870-} UpdateTooltipData;
1871-
1872-static void
1873-update_tooltip (GtkTreeModel *model,
1874- GtkTreePath *path,
1875- GtkTreeIter *iter,
1876- gpointer data)
1877-{
1878- UpdateTooltipData *udata = data;
1879- GtkTreeIter child_iter;
1880- const GtkFileInfo *info;
1881-
1882- if (udata->tip == NULL)
1883- {
1884- gtk_tree_model_sort_convert_iter_to_child_iter (udata->impl->sort_model,
1885- &child_iter,
1886- iter);
1887-
1888- info = _gtk_file_system_model_get_info (udata->impl->browse_files_model, &child_iter);
1889- udata->tip = g_strdup_printf (_("Add the folder '%s' to the bookmarks"),
1890- gtk_file_info_get_display_name (info));
1891- }
1892-}
1893-
1894-
1895-/* Sensitize the "add bookmark" button if all the selected items are folders, or
1896- * if there are no selected items *and* the current folder is not in the
1897- * bookmarks list. De-sensitize the button otherwise.
1898- */
1899-static void
1900-bookmarks_check_add_sensitivity (GtkFileChooserDefault *impl)
1901-{
1902- gint num_selected;
1903- gboolean all_folders;
1904- gboolean active;
1905- gchar *tip;
1906-
1907- selection_check (impl, &num_selected, NULL, &all_folders);
1908-
1909- if (num_selected == 0)
1910- active = (impl->current_folder != NULL) && (shortcut_find_position (impl, impl->current_folder) == -1);
1911- else if (num_selected == 1)
1912- {
1913- const GtkFilePath *path;
1914-
1915- path = get_selected_path (impl);
1916- active = all_folders && (shortcut_find_position (impl, path) == -1);
1917- }
1918- else
1919- active = all_folders;
1920-
1921- gtk_widget_set_sensitive (impl->browse_shortcuts_add_button, active);
1922-
1923- if (impl->browse_files_popup_menu_add_shortcut_item)
1924- gtk_widget_set_sensitive (impl->browse_files_popup_menu_add_shortcut_item,
1925- (num_selected == 0) ? FALSE : active);
1926-
1927- if (active)
1928- {
1929- if (num_selected == 0)
1930- tip = g_strdup_printf (_("Add the current folder to the bookmarks"));
1931- else if (num_selected > 1)
1932- tip = g_strdup_printf (_("Add the selected folders to the bookmarks"));
1933- else
1934- {
1935- GtkTreeSelection *selection;
1936- UpdateTooltipData data;
1937-
1938- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
1939- data.impl = impl;
1940- data.tip = NULL;
1941- gtk_tree_selection_selected_foreach (selection, update_tooltip, &data);
1942- tip = data.tip;
1943-
1944- }
1945- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button, tip, NULL);
1946- g_free (tip);
1947- }
1948-}
1949-
1950-/* Sets the sensitivity of the "remove bookmark" button depending on whether a
1951- * bookmark row is selected in the shortcuts tree.
1952- */
1953-static void
1954-bookmarks_check_remove_sensitivity (GtkFileChooserDefault *impl)
1955-{
1956- GtkTreeIter iter;
1957- gboolean removable = FALSE;
1958- gchar *name = NULL;
1959-
1960- if (shortcuts_get_selected (impl, &iter))
1961- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
1962- SHORTCUTS_COL_REMOVABLE, &removable,
1963- SHORTCUTS_COL_NAME, &name,
1964- -1);
1965-
1966- gtk_widget_set_sensitive (impl->browse_shortcuts_remove_button, removable);
1967-
1968- if (removable)
1969- {
1970- gchar *tip;
1971-
1972- tip = g_strdup_printf (_("Remove the bookmark '%s'"), name);
1973- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
1974- tip, NULL);
1975- g_free (tip);
1976- }
1977-
1978- g_free (name);
1979-}
1980-
1981-/* GtkWidget::drag-begin handler for the shortcuts list. */
1982-static void
1983-shortcuts_drag_begin_cb (GtkWidget *widget,
1984- GdkDragContext *context,
1985- GtkFileChooserDefault *impl)
1986-{
1987-#if 0
1988- impl->shortcuts_drag_context = g_object_ref (context);
1989-#endif
1990-}
1991-
1992-#if 0
1993-/* Removes the idle handler for outside drags */
1994-static void
1995-shortcuts_cancel_drag_outside_idle (GtkFileChooserDefault *impl)
1996-{
1997- if (!impl->shortcuts_drag_outside_idle)
1998- return;
1999-
2000- g_source_destroy (impl->shortcuts_drag_outside_idle);
2001- impl->shortcuts_drag_outside_idle = NULL;
2002-}
2003-#endif
2004-
2005-/* GtkWidget::drag-end handler for the shortcuts list. */
2006-static void
2007-shortcuts_drag_end_cb (GtkWidget *widget,
2008- GdkDragContext *context,
2009- GtkFileChooserDefault *impl)
2010-{
2011-#if 0
2012- g_object_unref (impl->shortcuts_drag_context);
2013-
2014- shortcuts_cancel_drag_outside_idle (impl);
2015-
2016- if (!impl->shortcuts_drag_outside)
2017- return;
2018-
2019- gtk_button_clicked (GTK_BUTTON (impl->browse_shortcuts_remove_button));
2020-
2021- impl->shortcuts_drag_outside = FALSE;
2022-#endif
2023-}
2024-
2025-/* GtkWidget::drag-data-delete handler for the shortcuts list. */
2026-static void
2027-shortcuts_drag_data_delete_cb (GtkWidget *widget,
2028- GdkDragContext *context,
2029- GtkFileChooserDefault *impl)
2030-{
2031- g_signal_stop_emission_by_name (widget, "drag-data-delete");
2032-}
2033-
2034-#if 0
2035-/* Creates a suitable drag cursor to indicate that the selected bookmark will be
2036- * deleted or not.
2037- */
2038-static void
2039-shortcuts_drag_set_delete_cursor (GtkFileChooserDefault *impl,
2040- gboolean delete)
2041-{
2042- GtkTreeView *tree_view;
2043- GtkTreeIter iter;
2044- GtkTreePath *path;
2045- GdkPixmap *row_pixmap;
2046- GdkBitmap *mask;
2047- int row_pixmap_y;
2048- int cell_y;
2049-
2050- tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
2051-
2052- /* Find the selected path and get its drag pixmap */
2053-
2054- if (!shortcuts_get_selected (impl, &iter))
2055- g_assert_not_reached ();
2056-
2057- path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
2058-
2059- row_pixmap = gtk_tree_view_create_row_drag_icon (tree_view, path);
2060- gtk_tree_path_free (path);
2061-
2062- mask = NULL;
2063- row_pixmap_y = 0;
2064-
2065- if (delete)
2066- {
2067- GdkPixbuf *pixbuf;
2068-
2069- pixbuf = gtk_widget_render_icon (impl->browse_shortcuts_tree_view,
2070- GTK_STOCK_DELETE,
2071- GTK_ICON_SIZE_DND,
2072- NULL);
2073- if (pixbuf)
2074- {
2075- GdkPixmap *composite;
2076- int row_pixmap_width, row_pixmap_height;
2077- int pixbuf_width, pixbuf_height;
2078- int composite_width, composite_height;
2079- int pixbuf_x, pixbuf_y;
2080- GdkGC *gc, *mask_gc;
2081- GdkColor color;
2082- GdkBitmap *pixbuf_mask;
2083-
2084- /* Create pixmap and mask for composite image */
2085-
2086- gdk_drawable_get_size (row_pixmap, &row_pixmap_width, &row_pixmap_height);
2087- pixbuf_width = gdk_pixbuf_get_width (pixbuf);
2088- pixbuf_height = gdk_pixbuf_get_height (pixbuf);
2089-
2090- composite_width = MAX (row_pixmap_width, pixbuf_width);
2091- composite_height = MAX (row_pixmap_height, pixbuf_height);
2092-
2093- row_pixmap_y = (composite_height - row_pixmap_height) / 2;
2094-
2095- if (gtk_widget_get_direction (impl->browse_shortcuts_tree_view) == GTK_TEXT_DIR_RTL)
2096- pixbuf_x = 0;
2097- else
2098- pixbuf_x = composite_width - pixbuf_width;
2099-
2100- pixbuf_y = (composite_height - pixbuf_height) / 2;
2101-
2102- composite = gdk_pixmap_new (row_pixmap, composite_width, composite_height, -1);
2103- gc = gdk_gc_new (composite);
2104-
2105- mask = gdk_pixmap_new (row_pixmap, composite_width, composite_height, 1);
2106- mask_gc = gdk_gc_new (mask);
2107- color.pixel = 0;
2108- gdk_gc_set_foreground (mask_gc, &color);
2109- gdk_draw_rectangle (mask, mask_gc, TRUE, 0, 0, composite_width, composite_height);
2110-
2111- color.red = 0xffff;
2112- color.green = 0xffff;
2113- color.blue = 0xffff;
2114- gdk_gc_set_rgb_fg_color (gc, &color);
2115- gdk_draw_rectangle (composite, gc, TRUE, 0, 0, composite_width, composite_height);
2116-
2117- /* Composite the row pixmap and the pixbuf */
2118-
2119- gdk_pixbuf_render_pixmap_and_mask_for_colormap
2120- (pixbuf,
2121- gtk_widget_get_colormap (impl->browse_shortcuts_tree_view),
2122- NULL, &pixbuf_mask, 128);
2123- gdk_draw_drawable (mask, mask_gc, pixbuf_mask,
2124- 0, 0,
2125- pixbuf_x, pixbuf_y,
2126- pixbuf_width, pixbuf_height);
2127- g_object_unref (pixbuf_mask);
2128-
2129- gdk_draw_drawable (composite, gc, row_pixmap,
2130- 0, 0,
2131- 0, row_pixmap_y,
2132- row_pixmap_width, row_pixmap_height);
2133- color.pixel = 1;
2134- gdk_gc_set_foreground (mask_gc, &color);
2135- gdk_draw_rectangle (mask, mask_gc, TRUE, 0, row_pixmap_y, row_pixmap_width, row_pixmap_height);
2136-
2137- gdk_draw_pixbuf (composite, gc, pixbuf,
2138- 0, 0,
2139- pixbuf_x, pixbuf_y,
2140- pixbuf_width, pixbuf_height,
2141- GDK_RGB_DITHER_MAX,
2142- 0, 0);
2143-
2144- g_object_unref (pixbuf);
2145- g_object_unref (row_pixmap);
2146-
2147- row_pixmap = composite;
2148- }
2149- }
2150-
2151- /* The hotspot offsets here are copied from gtk_tree_view_drag_begin(), ugh */
2152-
2153- gtk_tree_view_get_path_at_pos (tree_view,
2154- tree_view->priv->press_start_x,
2155- tree_view->priv->press_start_y,
2156- NULL,
2157- NULL,
2158- NULL,
2159- &cell_y);
2160-
2161- gtk_drag_set_icon_pixmap (impl->shortcuts_drag_context,
2162- gdk_drawable_get_colormap (row_pixmap),
2163- row_pixmap,
2164- mask,
2165- tree_view->priv->press_start_x + 1,
2166- row_pixmap_y + cell_y + 1);
2167-
2168- g_object_unref (row_pixmap);
2169- if (mask)
2170- g_object_unref (mask);
2171-}
2172-
2173-/* We set the delete cursor and the shortcuts_drag_outside flag in an idle
2174- * handler so that we can tell apart the drag_leave event that comes right
2175- * before a drag_drop, from a normal drag_leave. We don't want to set the
2176- * cursor nor the flag in the latter case.
2177- */
2178-static gboolean
2179-shortcuts_drag_outside_idle_cb (GtkFileChooserDefault *impl)
2180-{
2181- GDK_THREADS_ENTER ();
2182-
2183- shortcuts_drag_set_delete_cursor (impl, TRUE);
2184- impl->shortcuts_drag_outside = TRUE;
2185-
2186- shortcuts_cancel_drag_outside_idle (impl);
2187-
2188- GDK_THREADS_LEAVE ();
2189-
2190- return FALSE;
2191-}
2192-#endif
2193-
2194-/* GtkWidget::drag-leave handler for the shortcuts list. We unhighlight the
2195- * drop position.
2196- */
2197-static void
2198-shortcuts_drag_leave_cb (GtkWidget *widget,
2199- GdkDragContext *context,
2200- guint time_,
2201- GtkFileChooserDefault *impl)
2202-{
2203-#if 0
2204- if (gtk_drag_get_source_widget (context) == widget && !impl->shortcuts_drag_outside_idle)
2205- {
2206- impl->shortcuts_drag_outside_idle = g_idle_source_new ();
2207- g_source_set_closure (impl->shortcuts_drag_outside_idle,
2208- g_cclosure_new_object (G_CALLBACK (shortcuts_drag_outside_idle_cb),
2209- G_OBJECT (impl)));
2210- g_source_attach (impl->shortcuts_drag_outside_idle, NULL);
2211- }
2212-#endif
2213-
2214- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
2215- NULL,
2216- GTK_TREE_VIEW_DROP_BEFORE);
2217-
2218- g_signal_stop_emission_by_name (widget, "drag-leave");
2219-}
2220-
2221-/* Computes the appropriate row and position for dropping */
2222-static void
2223-shortcuts_compute_drop_position (GtkFileChooserDefault *impl,
2224- int x,
2225- int y,
2226- GtkTreePath **path,
2227- GtkTreeViewDropPosition *pos)
2228-{
2229- GtkTreeView *tree_view;
2230- GtkTreeViewColumn *column;
2231- int cell_y;
2232- GdkRectangle cell;
2233- int row;
2234- int bookmarks_index;
2235-
2236- tree_view = GTK_TREE_VIEW (impl->browse_shortcuts_tree_view);
2237-
2238- bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
2239-
2240- if (!gtk_tree_view_get_path_at_pos (tree_view,
2241- x,
2242- y - TREE_VIEW_HEADER_HEIGHT (tree_view),
2243- path,
2244- &column,
2245- NULL,
2246- &cell_y))
2247- {
2248- row = bookmarks_index + impl->num_bookmarks - 1;
2249- *path = gtk_tree_path_new_from_indices (row, -1);
2250- *pos = GTK_TREE_VIEW_DROP_AFTER;
2251- return;
2252- }
2253-
2254- row = *gtk_tree_path_get_indices (*path);
2255- gtk_tree_view_get_background_area (tree_view, *path, column, &cell);
2256- gtk_tree_path_free (*path);
2257-
2258- if (row < bookmarks_index)
2259- {
2260- row = bookmarks_index;
2261- *pos = GTK_TREE_VIEW_DROP_BEFORE;
2262- }
2263- else if (row > bookmarks_index + impl->num_bookmarks - 1)
2264- {
2265- row = bookmarks_index + impl->num_bookmarks - 1;
2266- *pos = GTK_TREE_VIEW_DROP_AFTER;
2267- }
2268- else
2269- {
2270- if (cell_y < cell.height / 2)
2271- *pos = GTK_TREE_VIEW_DROP_BEFORE;
2272- else
2273- *pos = GTK_TREE_VIEW_DROP_AFTER;
2274- }
2275-
2276- *path = gtk_tree_path_new_from_indices (row, -1);
2277-}
2278-
2279-/* GtkWidget::drag-motion handler for the shortcuts list. We basically
2280- * implement the destination side of DnD by hand, due to limitations in
2281- * GtkTreeView's DnD API.
2282- */
2283-static gboolean
2284-shortcuts_drag_motion_cb (GtkWidget *widget,
2285- GdkDragContext *context,
2286- gint x,
2287- gint y,
2288- guint time_,
2289- GtkFileChooserDefault *impl)
2290-{
2291- GtkTreePath *path;
2292- GtkTreeViewDropPosition pos;
2293- GdkDragAction action;
2294-
2295-#if 0
2296- if (gtk_drag_get_source_widget (context) == widget)
2297- {
2298- shortcuts_cancel_drag_outside_idle (impl);
2299-
2300- if (impl->shortcuts_drag_outside)
2301- {
2302- shortcuts_drag_set_delete_cursor (impl, FALSE);
2303- impl->shortcuts_drag_outside = FALSE;
2304- }
2305- }
2306-#endif
2307-
2308- if (context->suggested_action == GDK_ACTION_COPY || (context->actions & GDK_ACTION_COPY) != 0)
2309- action = GDK_ACTION_COPY;
2310- else if (context->suggested_action == GDK_ACTION_MOVE || (context->actions & GDK_ACTION_MOVE) != 0)
2311- action = GDK_ACTION_MOVE;
2312- else
2313- {
2314- action = 0;
2315- goto out;
2316- }
2317-
2318- shortcuts_compute_drop_position (impl, x, y, &path, &pos);
2319- gtk_tree_view_set_drag_dest_row (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), path, pos);
2320- gtk_tree_path_free (path);
2321-
2322- out:
2323-
2324- g_signal_stop_emission_by_name (widget, "drag-motion");
2325-
2326- if (action != 0)
2327- {
2328- gdk_drag_status (context, action, time_);
2329- return TRUE;
2330- }
2331- else
2332- return FALSE;
2333-}
2334-
2335-/* GtkWidget::drag-drop handler for the shortcuts list. */
2336-static gboolean
2337-shortcuts_drag_drop_cb (GtkWidget *widget,
2338- GdkDragContext *context,
2339- gint x,
2340- gint y,
2341- guint time_,
2342- GtkFileChooserDefault *impl)
2343-{
2344-#if 0
2345- shortcuts_cancel_drag_outside_idle (impl);
2346-#endif
2347-
2348- g_signal_stop_emission_by_name (widget, "drag-drop");
2349- return TRUE;
2350-}
2351-
2352-/* Parses a "text/uri-list" string and inserts its URIs as bookmarks */
2353-static void
2354-shortcuts_drop_uris (GtkFileChooserDefault *impl,
2355- const char *data,
2356- int position)
2357-{
2358- gchar **uris;
2359- gint i;
2360-
2361- uris = g_uri_list_extract_uris (data);
2362-
2363- for (i = 0; uris[i]; i++)
2364- {
2365- char *uri;
2366- GtkFilePath *path;
2367-
2368- uri = uris[i];
2369- path = gtk_file_system_uri_to_path (impl->file_system, uri);
2370-
2371- if (path)
2372- {
2373- if (shortcuts_add_bookmark_from_path (impl, path, position))
2374- position++;
2375-
2376- gtk_file_path_free (path);
2377- }
2378- else
2379- {
2380- GError *error;
2381-
2382- g_set_error (&error,
2383- GTK_FILE_CHOOSER_ERROR,
2384- GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
2385- _("Could not add a bookmark for '%s' "
2386- "because it is an invalid path name."),
2387- uri);
2388- error_adding_bookmark_dialog (impl, path, error);
2389- }
2390- }
2391-
2392- g_strfreev (uris);
2393-}
2394-
2395-/* Reorders the selected bookmark to the specified position */
2396-static void
2397-shortcuts_reorder (GtkFileChooserDefault *impl,
2398- int new_position)
2399-{
2400- GtkTreeIter iter;
2401- gpointer col_data;
2402- gboolean is_volume;
2403- GtkTreePath *path;
2404- int old_position;
2405- int bookmarks_index;
2406- const GtkFilePath *file_path;
2407- GtkFilePath *file_path_copy;
2408- GError *error;
2409-
2410- /* Get the selected path */
2411-
2412- if (!shortcuts_get_selected (impl, &iter))
2413- g_assert_not_reached ();
2414-
2415- path = gtk_tree_model_get_path (GTK_TREE_MODEL (impl->shortcuts_model), &iter);
2416- old_position = *gtk_tree_path_get_indices (path);
2417- gtk_tree_path_free (path);
2418-
2419- bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
2420- old_position -= bookmarks_index;
2421- g_assert (old_position >= 0 && old_position < impl->num_bookmarks);
2422-
2423- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
2424- SHORTCUTS_COL_DATA, &col_data,
2425- SHORTCUTS_COL_IS_VOLUME, &is_volume,
2426- -1);
2427- g_assert (col_data != NULL);
2428- g_assert (!is_volume);
2429-
2430- file_path = col_data;
2431- file_path_copy = gtk_file_path_copy (file_path); /* removal below will free file_path, so we need a copy */
2432-
2433- /* Remove the path from the old position and insert it in the new one */
2434-
2435- if (new_position > old_position)
2436- new_position--;
2437-
2438- if (old_position == new_position)
2439- goto out;
2440-
2441- error = NULL;
2442- if (gtk_file_system_remove_bookmark (impl->file_system, file_path_copy, &error))
2443- shortcuts_add_bookmark_from_path (impl, file_path_copy, new_position);
2444- else
2445- error_adding_bookmark_dialog (impl, file_path_copy, error);
2446-
2447- out:
2448-
2449- gtk_file_path_free (file_path_copy);
2450-}
2451-
2452-/* Callback used when we get the drag data for the bookmarks list. We add the
2453- * received URIs as bookmarks if they are folders.
2454- */
2455-static void
2456-shortcuts_drag_data_received_cb (GtkWidget *widget,
2457- GdkDragContext *context,
2458- gint x,
2459- gint y,
2460- GtkSelectionData *selection_data,
2461- guint info,
2462- guint time_,
2463- gpointer data)
2464-{
2465- GtkFileChooserDefault *impl;
2466- GtkTreePath *tree_path;
2467- GtkTreeViewDropPosition tree_pos;
2468- int position;
2469- int bookmarks_index;
2470-
2471- impl = GTK_FILE_CHOOSER_DEFAULT (data);
2472-
2473- /* Compute position */
2474-
2475- bookmarks_index = shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS);
2476-
2477- shortcuts_compute_drop_position (impl, x, y, &tree_path, &tree_pos);
2478- position = *gtk_tree_path_get_indices (tree_path);
2479- gtk_tree_path_free (tree_path);
2480-
2481- if (tree_pos == GTK_TREE_VIEW_DROP_AFTER)
2482- position++;
2483-
2484- g_assert (position >= bookmarks_index);
2485- position -= bookmarks_index;
2486-
2487- if (selection_data->target == gdk_atom_intern ("text/uri-list", FALSE))
2488- shortcuts_drop_uris (impl, selection_data->data, position);
2489- else if (selection_data->target == gdk_atom_intern ("GTK_TREE_MODEL_ROW", FALSE))
2490- shortcuts_reorder (impl, position);
2491+ impl->edited_idle = g_idle_source_new ();
2492+ g_source_set_closure (impl->edited_idle,
2493+ g_cclosure_new_object (G_CALLBACK (edited_idle_cb),
2494+ G_OBJECT (impl)));
2495+ g_source_attach (impl->edited_idle, NULL);
2496
2497- g_signal_stop_emission_by_name (widget, "drag-data-received");
2498+ if (new_text)
2499+ impl->edited_new_text = g_strdup (new_text);
2500 }
2501
2502-/* Callback used when the selection in the shortcuts tree changes */
2503+/* Callback used from the text cell renderer when the new folder is named */
2504 static void
2505-shortcuts_selection_changed_cb (GtkTreeSelection *selection,
2506- GtkFileChooserDefault *impl)
2507-{
2508- bookmarks_check_remove_sensitivity (impl);
2509-}
2510-
2511-static gboolean
2512-shortcuts_row_separator_func (GtkTreeModel *model,
2513- GtkTreeIter *iter,
2514- gpointer data)
2515+renderer_edited_cb (GtkCellRendererText *cell_renderer_text,
2516+ const gchar *path,
2517+ const gchar *new_text,
2518+ GtkFileChooserDefault *impl)
2519 {
2520- gint column = GPOINTER_TO_INT (data);
2521- gchar *text;
2522-
2523- gtk_tree_model_get (model, iter, column, &text, -1);
2524-
2525- if (!text)
2526- return TRUE;
2527-
2528- g_free (text);
2529-
2530- return FALSE;
2531+ /* work around bug #154921 */
2532+ g_object_set (cell_renderer_text,
2533+ "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
2534+ queue_edited_idle (impl, new_text);
2535 }
2536
2537-/* Since GtkTreeView has a keybinding attached to '/', we need to catch
2538- * keypresses before the TreeView gets them.
2539+/* Callback used from the text cell renderer when the new folder edition gets
2540+ * canceled.
2541 */
2542-static gboolean
2543-tree_view_keybinding_cb (GtkWidget *tree_view,
2544- GdkEventKey *event,
2545- GtkFileChooserDefault *impl)
2546+static void
2547+renderer_editing_canceled_cb (GtkCellRendererText *cell_renderer_text,
2548+ GtkFileChooserDefault *impl)
2549 {
2550- if (event->keyval == GDK_slash &&
2551- ! (event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ())))
2552- {
2553- location_popup_handler (impl, "/");
2554- return TRUE;
2555- }
2556-
2557- return FALSE;
2558+ /* work around bug #154921 */
2559+ g_object_set (cell_renderer_text,
2560+ "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
2561+ queue_edited_idle (impl, NULL);
2562 }
2563
2564-
2565-/* Creates the widgets for the shortcuts and bookmarks tree */
2566+/* Creates the widgets for the filter combo box */
2567 static GtkWidget *
2568-shortcuts_list_create (GtkFileChooserDefault *impl)
2569+filter_create (GtkFileChooserDefault *impl)
2570 {
2571- GtkWidget *swin;
2572- GtkTreeSelection *selection;
2573- GtkTreeViewColumn *column;
2574- GtkCellRenderer *renderer;
2575-
2576- /* Scrolled window */
2577-
2578- swin = gtk_scrolled_window_new (NULL, NULL);
2579- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
2580- GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
2581- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swin),
2582- GTK_SHADOW_IN);
2583- gtk_widget_show (swin);
2584-
2585- /* Tree */
2586-
2587- impl->browse_shortcuts_tree_view = gtk_tree_view_new ();
2588- g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
2589- G_CALLBACK (tree_view_keybinding_cb), impl);
2590- atk_object_set_name (gtk_widget_get_accessible (impl->browse_shortcuts_tree_view), _("Shortcuts"));
2591- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), FALSE);
2592+ impl->filter_combo = gtk_combo_box_new_text ();
2593+ g_signal_connect (impl->filter_combo, "changed",
2594+ G_CALLBACK (filter_combo_changed), impl);
2595
2596- gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), impl->shortcuts_filter_model);
2597+ return impl->filter_combo;
2598+}
2599
2600- gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
2601- GDK_BUTTON1_MASK,
2602- shortcuts_source_targets,
2603- num_shortcuts_source_targets,
2604- GDK_ACTION_MOVE);
2605-
2606- gtk_drag_dest_set (impl->browse_shortcuts_tree_view,
2607- GTK_DEST_DEFAULT_ALL,
2608- shortcuts_dest_targets,
2609- num_shortcuts_dest_targets,
2610- GDK_ACTION_COPY | GDK_ACTION_MOVE);
2611+struct selection_check_closure {
2612+ GtkFileChooserDefault *impl;
2613+ int num_selected;
2614+ gboolean all_files;
2615+ gboolean all_folders;
2616+};
2617
2618- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
2619- gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
2620- gtk_tree_selection_set_select_function (selection,
2621- shortcuts_select_func,
2622- impl, NULL);
2623+/* Used from gtk_tree_selection_selected_foreach() */
2624+static void
2625+selection_check_foreach_cb (GtkTreeModel *model,
2626+ GtkTreePath *path,
2627+ GtkTreeIter *iter,
2628+ gpointer data)
2629+{
2630+ struct selection_check_closure *closure;
2631+ GtkTreeIter child_iter;
2632+ const GtkFileInfo *info;
2633+ gboolean is_folder;
2634
2635- g_signal_connect (selection, "changed",
2636- G_CALLBACK (shortcuts_selection_changed_cb), impl);
2637+ closure = data;
2638+ closure->num_selected++;
2639
2640- g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
2641- G_CALLBACK (shortcuts_row_activated_cb), impl);
2642+ gtk_tree_model_sort_convert_iter_to_child_iter (closure->impl->sort_model, &child_iter, iter);
2643
2644- g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
2645- G_CALLBACK (shortcuts_key_press_event_cb), impl);
2646+ info = _gtk_file_system_model_get_info (closure->impl->browse_files_model, &child_iter);
2647+ is_folder = info ? gtk_file_info_get_is_folder (info) : FALSE;
2648
2649- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin",
2650- G_CALLBACK (shortcuts_drag_begin_cb), impl);
2651- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end",
2652- G_CALLBACK (shortcuts_drag_end_cb), impl);
2653- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-delete",
2654- G_CALLBACK (shortcuts_drag_data_delete_cb), impl);
2655-
2656- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-leave",
2657- G_CALLBACK (shortcuts_drag_leave_cb), impl);
2658- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-motion",
2659- G_CALLBACK (shortcuts_drag_motion_cb), impl);
2660- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-drop",
2661- G_CALLBACK (shortcuts_drag_drop_cb), impl);
2662- g_signal_connect (impl->browse_shortcuts_tree_view, "drag-data-received",
2663- G_CALLBACK (shortcuts_drag_data_received_cb), impl);
2664+ closure->all_folders = closure->all_folders && is_folder;
2665+ closure->all_files = closure->all_files && !is_folder;
2666+}
2667
2668- gtk_container_add (GTK_CONTAINER (swin), impl->browse_shortcuts_tree_view);
2669- gtk_widget_show (impl->browse_shortcuts_tree_view);
2670+/* Checks whether the selected items in the file list are all files or all folders */
2671+static void
2672+selection_check (GtkFileChooserDefault *impl,
2673+ gint *num_selected,
2674+ gboolean *all_files,
2675+ gboolean *all_folders)
2676+{
2677+ struct selection_check_closure closure;
2678+ GtkTreeSelection *selection;
2679
2680- /* Column */
2681+ closure.impl = impl;
2682+ closure.num_selected = 0;
2683+ closure.all_files = TRUE;
2684+ closure.all_folders = TRUE;
2685
2686- column = gtk_tree_view_column_new ();
2687- gtk_tree_view_column_set_title (column, _("Folder"));
2688+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
2689+ gtk_tree_selection_selected_foreach (selection,
2690+ selection_check_foreach_cb,
2691+ &closure);
2692
2693- renderer = gtk_cell_renderer_pixbuf_new ();
2694- gtk_tree_view_column_pack_start (column, renderer, FALSE);
2695- gtk_tree_view_column_set_attributes (column, renderer,
2696- "pixbuf", SHORTCUTS_COL_PIXBUF,
2697- "visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
2698- NULL);
2699+ g_assert (closure.num_selected == 0 || !(closure.all_files && closure.all_folders));
2700
2701- renderer = gtk_cell_renderer_text_new ();
2702- gtk_tree_view_column_pack_start (column, renderer, TRUE);
2703- gtk_tree_view_column_set_attributes (column, renderer,
2704- "text", SHORTCUTS_COL_NAME,
2705- NULL);
2706-
2707- gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
2708- shortcuts_row_separator_func,
2709- GINT_TO_POINTER (SHORTCUTS_COL_NAME),
2710- NULL);
2711+ if (num_selected)
2712+ *num_selected = closure.num_selected;
2713
2714- gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), column);
2715+ if (all_files)
2716+ *all_files = closure.all_files;
2717
2718- return swin;
2719+ if (all_folders)
2720+ *all_folders = closure.all_folders;
2721 }
2722
2723-/* Creates the widgets for the shortcuts/bookmarks pane */
2724-static GtkWidget *
2725-shortcuts_pane_create (GtkFileChooserDefault *impl,
2726- GtkSizeGroup *size_group)
2727-{
2728- GtkWidget *vbox;
2729- GtkWidget *hbox;
2730- GtkWidget *widget;
2731-
2732- vbox = gtk_vbox_new (FALSE, 6);
2733- gtk_widget_show (vbox);
2734-
2735- /* Shortcuts tree */
2736-
2737- widget = shortcuts_list_create (impl);
2738- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
2739-
2740- /* Box for buttons */
2741-
2742- hbox = gtk_hbox_new (TRUE, 6);
2743- gtk_size_group_add_widget (size_group, hbox);
2744- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
2745- gtk_widget_show (hbox);
2746+struct get_selected_path_closure {
2747+ GtkFileChooserDefault *impl;
2748+ const GtkFilePath *path;
2749+};
2750
2751- /* Add bookmark button */
2752+/* Returns a selected path from the file list */
2753
2754- impl->browse_shortcuts_add_button = button_new (impl,
2755- _("_Add"),
2756- GTK_STOCK_ADD,
2757- FALSE,
2758- TRUE,
2759- G_CALLBACK (add_bookmark_button_clicked_cb));
2760- gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_add_button, TRUE, TRUE, 0);
2761- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_add_button,
2762- _("Add the selected folder to the bookmarks"), NULL);
2763-
2764- /* Remove bookmark button */
2765-
2766- impl->browse_shortcuts_remove_button = button_new (impl,
2767- _("_Remove"),
2768- GTK_STOCK_REMOVE,
2769- FALSE,
2770- TRUE,
2771- G_CALLBACK (remove_bookmark_button_clicked_cb));
2772- gtk_box_pack_start (GTK_BOX (hbox), impl->browse_shortcuts_remove_button, TRUE, TRUE, 0);
2773- gtk_tooltips_set_tip (impl->tooltips, impl->browse_shortcuts_remove_button,
2774- _("Remove the selected bookmark"), NULL);
2775+typedef struct {
2776+ GtkFileChooserDefault *impl;
2777+ gchar *tip;
2778+} UpdateTooltipData;
2779
2780- return vbox;
2781-}
2782
2783 /* Handles key press events on the file list, so that we can trap Enter to
2784 * activate the default button on our own. Also, checks to see if '/' has been
2785@@ -3026,14 +1085,11 @@
2786 gpointer data)
2787 {
2788 GtkFileChooserDefault *impl;
2789- int modifiers;
2790
2791 impl = (GtkFileChooserDefault *) data;
2792-
2793- modifiers = gtk_accelerator_get_default_mod_mask ();
2794
2795 if (event->keyval == GDK_slash &&
2796- ! (event->state & (~GDK_SHIFT_MASK & modifiers)))
2797+ ! (event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ())))
2798 {
2799 location_popup_handler (impl, "/");
2800 return TRUE;
2801@@ -3043,7 +1099,6 @@
2802 || event->keyval == GDK_ISO_Enter
2803 || event->keyval == GDK_KP_Enter
2804 || event->keyval == GDK_space)
2805- && ((event->state && modifiers) == 0)
2806 && !(impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
2807 impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
2808 {
2809@@ -3063,37 +1118,7 @@
2810 return FALSE;
2811 }
2812
2813-/* Callback used when the file list's popup menu is detached */
2814-static void
2815-popup_menu_detach_cb (GtkWidget *attach_widget,
2816- GtkMenu *menu)
2817-{
2818- GtkFileChooserDefault *impl;
2819-
2820- impl = g_object_get_data (G_OBJECT (attach_widget), "GtkFileChooserDefault");
2821- g_assert (GTK_IS_FILE_CHOOSER_DEFAULT (impl));
2822-
2823- impl->browse_files_popup_menu = NULL;
2824- impl->browse_files_popup_menu_add_shortcut_item = NULL;
2825- impl->browse_files_popup_menu_hidden_files_item = NULL;
2826-}
2827-
2828-/* Callback used when the "Add to Shortcuts" menu item is activated */
2829-static void
2830-add_to_shortcuts_cb (GtkMenuItem *item,
2831- GtkFileChooserDefault *impl)
2832-{
2833- bookmarks_add_selected_folder (impl);
2834-}
2835-
2836-/* Callback used when the "Open Location" menu item is activated */
2837-static void
2838-open_location_cb (GtkMenuItem *item,
2839- GtkFileChooserDefault *impl)
2840-{
2841- location_popup_handler (impl, "");
2842-}
2843-
2844+#if 0
2845 /* Callback used when the "Show Hidden Files" menu item is toggled */
2846 static void
2847 show_hidden_toggled_cb (GtkCheckMenuItem *item,
2848@@ -3103,145 +1128,7 @@
2849 "show-hidden", gtk_check_menu_item_get_active (item),
2850 NULL);
2851 }
2852-
2853-/* Constructs the popup menu for the file list if needed */
2854-static void
2855-file_list_build_popup_menu (GtkFileChooserDefault *impl)
2856-{
2857- GtkWidget *item;
2858-
2859- if (impl->browse_files_popup_menu)
2860- return;
2861-
2862- impl->browse_files_popup_menu = gtk_menu_new ();
2863- gtk_menu_attach_to_widget (GTK_MENU (impl->browse_files_popup_menu),
2864- impl->browse_files_tree_view,
2865- popup_menu_detach_cb);
2866-
2867- item = gtk_image_menu_item_new_with_mnemonic (_("_Add to Shortcuts"));
2868- impl->browse_files_popup_menu_add_shortcut_item = item;
2869- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
2870- gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
2871- gtk_widget_set_sensitive (item, FALSE);
2872- g_signal_connect (item, "activate",
2873- G_CALLBACK (add_to_shortcuts_cb), impl);
2874- gtk_widget_show (item);
2875- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
2876-
2877- item = gtk_image_menu_item_new_with_mnemonic (_("Open _Location"));
2878- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
2879- gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU));
2880- g_signal_connect (item, "activate",
2881- G_CALLBACK (open_location_cb), impl);
2882- gtk_widget_show (item);
2883- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
2884-
2885- item = gtk_separator_menu_item_new ();
2886- gtk_widget_show (item);
2887- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
2888-
2889- item = gtk_check_menu_item_new_with_mnemonic (_("Show _Hidden Files"));
2890- impl->browse_files_popup_menu_hidden_files_item = item;
2891- g_signal_connect (item, "toggled",
2892- G_CALLBACK (show_hidden_toggled_cb), impl);
2893- gtk_widget_show (item);
2894- gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
2895-}
2896-
2897-/* Updates the popup menu for the file list, creating it if necessary */
2898-static void
2899-file_list_update_popup_menu (GtkFileChooserDefault *impl)
2900-{
2901- file_list_build_popup_menu (impl);
2902-
2903- /* The sensitivity of the Add to Shortcuts item is set in
2904- * bookmarks_check_add_sensitivity()
2905- */
2906-
2907- g_signal_handlers_block_by_func (impl->browse_files_popup_menu_hidden_files_item,
2908- G_CALLBACK (show_hidden_toggled_cb), impl);
2909- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (impl->browse_files_popup_menu_hidden_files_item),
2910- impl->show_hidden);
2911- g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_hidden_files_item,
2912- G_CALLBACK (show_hidden_toggled_cb), impl);
2913-}
2914-
2915-static void
2916-popup_position_func (GtkMenu *menu,
2917- gint *x,
2918- gint *y,
2919- gboolean *push_in,
2920- gpointer user_data)
2921-{
2922- GtkWidget *widget = GTK_WIDGET (user_data);
2923- GdkScreen *screen = gtk_widget_get_screen (widget);
2924- GtkRequisition req;
2925- gint monitor_num;
2926- GdkRectangle monitor;
2927-
2928- g_return_if_fail (GTK_WIDGET_REALIZED (widget));
2929-
2930- gdk_window_get_origin (widget->window, x, y);
2931-
2932- gtk_widget_size_request (GTK_WIDGET (menu), &req);
2933-
2934- *x += (widget->allocation.width - req.width) / 2;
2935- *y += (widget->allocation.height - req.height) / 2;
2936-
2937- monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
2938- gtk_menu_set_monitor (menu, monitor_num);
2939- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
2940-
2941- *x = CLAMP (*x, monitor.x, monitor.x + MAX (0, monitor.width - req.width));
2942- *y = CLAMP (*y, monitor.y, monitor.y + MAX (0, monitor.height - req.height));
2943-
2944- *push_in = FALSE;
2945-}
2946-
2947-static void
2948-file_list_popup_menu (GtkFileChooserDefault *impl,
2949- GdkEventButton *event)
2950-{
2951- file_list_update_popup_menu (impl);
2952- if (event)
2953- gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
2954- NULL, NULL, NULL, NULL,
2955- event->button, event->time);
2956- else
2957- {
2958- gtk_menu_popup (GTK_MENU (impl->browse_files_popup_menu),
2959- NULL, NULL,
2960- popup_position_func, impl->browse_files_tree_view,
2961- 0, GDK_CURRENT_TIME);
2962- gtk_menu_shell_select_first (GTK_MENU_SHELL (impl->browse_files_popup_menu),
2963- FALSE);
2964- }
2965-
2966-}
2967-
2968-/* Callback used for the GtkWidget::popup-menu signal of the file list */
2969-static gboolean
2970-list_popup_menu_cb (GtkWidget *widget,
2971- GtkFileChooserDefault *impl)
2972-{
2973- file_list_popup_menu (impl, NULL);
2974- return TRUE;
2975-}
2976-
2977-/* Callback used when a button is pressed on the file list. We trap button 3 to
2978- * bring up a popup menu.
2979- */
2980-static gboolean
2981-list_button_press_event_cb (GtkWidget *widget,
2982- GdkEventButton *event,
2983- GtkFileChooserDefault *impl)
2984-{
2985- if (event->button != 3)
2986- return FALSE;
2987-
2988- file_list_popup_menu (impl, event);
2989- return TRUE;
2990-}
2991+#endif
2992
2993 /* Creates the widgets for the file list */
2994 static GtkWidget *
2995@@ -3272,11 +1159,7 @@
2996 G_CALLBACK (list_row_activated), impl);
2997 g_signal_connect (impl->browse_files_tree_view, "key-press-event",
2998 G_CALLBACK (trap_activate_cb), impl);
2999- g_signal_connect (impl->browse_files_tree_view, "popup-menu",
3000- G_CALLBACK (list_popup_menu_cb), impl);
3001- g_signal_connect (impl->browse_files_tree_view, "button-press-event",
3002- G_CALLBACK (list_button_press_event_cb), impl);
3003-
3004+
3005 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
3006 gtk_tree_selection_set_select_function (selection,
3007 list_select_func,
3008@@ -3346,70 +1229,163 @@
3009 return swin;
3010 }
3011
3012-static GtkWidget *
3013-create_path_bar (GtkFileChooserDefault *impl)
3014+static void
3015+up_button_clicked_cb (GtkButton *button, gpointer data)
3016 {
3017- GtkWidget *path_bar;
3018-
3019- path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
3020- _gtk_path_bar_set_file_system (GTK_PATH_BAR (path_bar), impl->file_system);
3021-
3022- return path_bar;
3023+ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
3024+ up_folder_handler (impl);
3025 }
3026
3027 static void
3028-set_filter_tooltip (GtkWidget *widget,
3029- gpointer data)
3030+volume_button_clicked_cb (GtkButton *button, gpointer data)
3031 {
3032- GtkTooltips *tooltips = (GtkTooltips *)data;
3033-
3034- if (GTK_IS_BUTTON (widget))
3035- gtk_tooltips_set_tip (tooltips, widget,
3036- _("Select which types of files are shown"),
3037- NULL);
3038+ GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (data);
3039+ GtkFilePath * path = g_object_get_data (G_OBJECT (button), "file-path");
3040+
3041+ change_folder_and_display_error (impl, path);
3042 }
3043
3044-static void
3045-realize_filter_combo (GtkWidget *combo,
3046- gpointer data)
3047+static GtkWidget *
3048+create_bar (GtkFileChooserDefault *impl)
3049 {
3050- GtkFileChooserDefault *impl = (GtkFileChooserDefault *)data;
3051+ GSList *list, *l;
3052+ int n;
3053+ GtkWidget *bar = gtk_hbox_new (FALSE, DEFAULT_SPACING);
3054+ GtkWidget *img;
3055+
3056+ /* first the Up button */
3057+ img = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON);
3058+ gtk_widget_show (img);
3059+
3060+ impl->up_button = gtk_button_new ();
3061+ gtk_container_add (GTK_CONTAINER (impl->up_button), img);
3062+ gtk_widget_show (impl->up_button);
3063+ gtk_widget_set_sensitive (impl->up_button, FALSE);
3064+ gtk_button_set_focus_on_click (GTK_BUTTON (impl->up_button), FALSE);
3065+
3066+ g_signal_connect (impl->up_button, "clicked",
3067+ G_CALLBACK (up_button_clicked_cb), impl);
3068+ gtk_box_pack_start (GTK_BOX(bar), impl->up_button, FALSE, FALSE, 0);
3069+
3070+ impl->num_volumes = 0;
3071+ list = gtk_file_system_list_volumes (impl->file_system);
3072+
3073+ n = 0;
3074+
3075+ for (l = list; l; l = l->next, n++)
3076+ {
3077+ GtkFileSystemVolume *volume;
3078+ GdkPixbuf *pixbuf;
3079+ GtkWidget *button;
3080+ GtkWidget *image;
3081+ GtkFilePath *base_path;
3082+ gchar * file_name = NULL;
3083+
3084+ volume = l->data;
3085+ base_path =
3086+ gtk_file_system_volume_get_base_path (impl->file_system, volume);
3087+
3088+ if (impl->local_only)
3089+ {
3090+ gboolean is_local =
3091+ gtk_file_system_path_is_local (impl->file_system, base_path);
3092+
3093+ if (!is_local)
3094+ {
3095+ gtk_file_path_free (base_path);
3096+ gtk_file_system_volume_free (impl->file_system, volume);
3097+ continue;
3098+ }
3099+ }
3100+
3101+#if 0
3102+ label_copy =
3103+ gtk_file_system_volume_get_display_name (impl->file_system, volume);
3104+#endif
3105+ pixbuf =
3106+ gtk_file_system_volume_render_icon (impl->file_system, volume,
3107+ GTK_WIDGET (impl),
3108+ impl->icon_size, NULL);
3109+
3110+ button = gtk_button_new ();
3111+ image = gtk_image_new_from_pixbuf (pixbuf);
3112+ g_object_unref (G_OBJECT (pixbuf));
3113+ gtk_container_add (GTK_CONTAINER (button), image);
3114+ gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
3115+
3116+ file_name =
3117+ gtk_file_system_path_to_filename (impl->file_system, base_path);
3118+
3119+ if (file_name && impl->root_folder &&
3120+ strcmp (file_name, impl->root_folder) &&
3121+ !strncmp (file_name, impl->root_folder, strlen (file_name)))
3122+ {
3123+ /* The base path is below the root folder; we replace it with
3124+ * the root folder
3125+ */
3126+ gtk_file_path_free (base_path);
3127+ base_path = gtk_file_system_filename_to_path (impl->file_system,
3128+ impl->root_folder);
3129+ }
3130+
3131+ g_free (file_name);
3132+
3133+ gtk_widget_show_all (button);
3134+
3135+ g_object_set_data (G_OBJECT (button), "file-path", base_path);
3136
3137- gtk_container_forall (GTK_CONTAINER (combo),
3138- set_filter_tooltip,
3139- impl->tooltips);
3140+ g_signal_connect (button, "clicked",
3141+ G_CALLBACK (volume_button_clicked_cb), impl);
3142+
3143+ gtk_box_pack_start (GTK_BOX(bar), button, FALSE, FALSE, 0);
3144+ }
3145+
3146+ impl->num_volumes = n;
3147+ g_slist_free (list);
3148+
3149+ gtk_widget_show (bar);
3150+
3151+ return bar;
3152 }
3153
3154 /* Creates the widgets for the files/folders pane */
3155 static GtkWidget *
3156-file_pane_create (GtkFileChooserDefault *impl,
3157- GtkSizeGroup *size_group)
3158+file_pane_create (GtkFileChooserDefault *impl)
3159 {
3160 GtkWidget *vbox;
3161 GtkWidget *hbox;
3162 GtkWidget *widget;
3163-
3164- vbox = gtk_vbox_new (FALSE, 6);
3165+ vbox = gtk_vbox_new (FALSE, DEFAULT_SPACING);
3166 gtk_widget_show (vbox);
3167
3168- /* The path bar and 'Create Folder' button */
3169- hbox = gtk_hbox_new (FALSE, 12);
3170+ /* The volume bar and 'Create Folder' button */
3171+ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
3172 gtk_widget_show (hbox);
3173- impl->browse_path_bar = create_path_bar (impl);
3174- g_signal_connect (impl->browse_path_bar, "path-clicked", G_CALLBACK (path_bar_clicked), impl);
3175- gtk_widget_show_all (impl->browse_path_bar);
3176- gtk_box_pack_start (GTK_BOX (hbox), impl->browse_path_bar, TRUE, TRUE, 0);
3177+ impl->bar = create_bar (impl);
3178+ gtk_widget_show_all (impl->bar);
3179+ gtk_box_pack_start (GTK_BOX (hbox), impl->bar, TRUE, TRUE, 0);
3180
3181 /* Create Folder */
3182- impl->browse_new_folder_button = gtk_button_new_with_mnemonic (_("Create Fo_lder"));
3183+ widget = gtk_image_new_from_icon_name ("folder-new", GTK_ICON_SIZE_BUTTON);
3184+ gtk_widget_show (widget);
3185+ impl->browse_new_folder_button = gtk_button_new ();
3186+ gtk_container_add (GTK_CONTAINER (impl->browse_new_folder_button), widget);
3187+ gtk_button_set_focus_on_click (GTK_BUTTON (impl->browse_new_folder_button),
3188+ FALSE);
3189+
3190 g_signal_connect (impl->browse_new_folder_button, "clicked",
3191 G_CALLBACK (new_folder_button_clicked), impl);
3192 gtk_box_pack_end (GTK_BOX (hbox), impl->browse_new_folder_button, FALSE, FALSE, 0);
3193+
3194+ widget = filter_create (impl);
3195+ gtk_widget_hide (widget);
3196+ gtk_box_pack_end (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
3197+
3198 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
3199
3200- /* Box for lists and preview */
3201+ /* Box for lists */
3202
3203- hbox = gtk_hbox_new (FALSE, PREVIEW_HBOX_SPACING);
3204+ hbox = gtk_hbox_new (FALSE, LIST_HBOX_SPACING);
3205 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
3206 gtk_widget_show (hbox);
3207
3208@@ -3418,157 +1394,37 @@
3209 widget = create_file_list (impl);
3210 gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
3211
3212- /* Preview */
3213-
3214- impl->preview_box = gtk_vbox_new (FALSE, 12);
3215- gtk_box_pack_start (GTK_BOX (hbox), impl->preview_box, FALSE, FALSE, 0);
3216- /* Don't show preview box initially */
3217-
3218- /* Filter combo */
3219-
3220- impl->filter_combo_hbox = gtk_hbox_new (FALSE, 12);
3221-
3222- widget = filter_create (impl);
3223-
3224- g_signal_connect (widget, "realize",
3225- G_CALLBACK (realize_filter_combo), impl);
3226-
3227- gtk_widget_show (widget);
3228- gtk_box_pack_end (GTK_BOX (impl->filter_combo_hbox), widget, FALSE, FALSE, 0);
3229-
3230- gtk_size_group_add_widget (size_group, impl->filter_combo_hbox);
3231- gtk_box_pack_end (GTK_BOX (vbox), impl->filter_combo_hbox, FALSE, FALSE, 0);
3232-
3233 return vbox;
3234 }
3235-/* Callback used when the "Browse for more folders" expander is toggled */
3236-static void
3237-expander_changed_cb (GtkExpander *expander,
3238- GParamSpec *pspec,
3239- GtkFileChooserDefault *impl)
3240-{
3241- update_appearance (impl);
3242-}
3243-
3244-/* Callback used when the selection changes in the save folder combo box */
3245-static void
3246-save_folder_combo_changed_cb (GtkComboBox *combo,
3247- GtkFileChooserDefault *impl)
3248-{
3249- GtkTreeIter iter;
3250-
3251- if (impl->changing_folder)
3252- return;
3253-
3254- if (gtk_combo_box_get_active_iter (combo, &iter))
3255- shortcuts_activate_iter (impl, &iter);
3256-}
3257-
3258-/* Creates the combo box with the save folders */
3259-static GtkWidget *
3260-save_folder_combo_create (GtkFileChooserDefault *impl)
3261-{
3262- GtkWidget *combo;
3263- GtkCellRenderer *cell;
3264-
3265- combo = g_object_new (GTK_TYPE_COMBO_BOX,
3266- "model", impl->shortcuts_model,
3267- "focus-on-click", FALSE,
3268- NULL);
3269- gtk_widget_show (combo);
3270-
3271- cell = gtk_cell_renderer_pixbuf_new ();
3272- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, FALSE);
3273- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
3274- "pixbuf", SHORTCUTS_COL_PIXBUF,
3275- "visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
3276- "sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
3277- NULL);
3278-
3279- cell = gtk_cell_renderer_text_new ();
3280- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
3281- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
3282- "text", SHORTCUTS_COL_NAME,
3283- "sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
3284- NULL);
3285-
3286- gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
3287- shortcuts_row_separator_func,
3288- GINT_TO_POINTER (SHORTCUTS_COL_NAME),
3289- NULL);
3290-
3291- g_signal_connect (combo, "changed",
3292- G_CALLBACK (save_folder_combo_changed_cb), impl);
3293-
3294- return combo;
3295-}
3296
3297 /* Creates the widgets specific to Save mode */
3298 static GtkWidget *
3299 save_widgets_create (GtkFileChooserDefault *impl)
3300 {
3301 GtkWidget *vbox;
3302- GtkWidget *table;
3303+ GtkWidget *hbox;
3304 GtkWidget *widget;
3305- GtkWidget *alignment;
3306
3307- vbox = gtk_vbox_new (FALSE, 12);
3308-
3309- table = gtk_table_new (2, 2, FALSE);
3310- gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
3311- gtk_widget_show (table);
3312- gtk_table_set_row_spacings (GTK_TABLE (table), 12);
3313- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
3314-
3315- /* Name entry */
3316-
3317- widget = gtk_label_new_with_mnemonic (_("_Name:"));
3318+ vbox = gtk_vbox_new (FALSE, 0);
3319+ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
3320+
3321+ widget = gtk_label_new (_("Name:"));
3322 gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
3323- gtk_table_attach (GTK_TABLE (table), widget,
3324- 0, 1, 0, 1,
3325- GTK_FILL, GTK_FILL,
3326- 0, 0);
3327+ gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
3328 gtk_widget_show (widget);
3329
3330 impl->save_file_name_entry = _gtk_file_chooser_entry_new (TRUE);
3331 _gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
3332 impl->file_system);
3333- gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45);
3334+/* gtk_entry_set_width_chars (GTK_ENTRY (impl->save_file_name_entry), 45); */
3335 gtk_entry_set_activates_default (GTK_ENTRY (impl->save_file_name_entry), TRUE);
3336- gtk_table_attach (GTK_TABLE (table), impl->save_file_name_entry,
3337- 1, 2, 0, 1,
3338- GTK_EXPAND | GTK_FILL, 0,
3339- 0, 0);
3340+ gtk_box_pack_start (GTK_BOX (hbox), impl->save_file_name_entry,
3341+ TRUE, TRUE, 0);
3342 gtk_widget_show (impl->save_file_name_entry);
3343- gtk_label_set_mnemonic_widget (GTK_LABEL (widget), impl->save_file_name_entry);
3344-
3345- /* Folder combo */
3346- impl->save_folder_label = gtk_label_new (NULL);
3347- gtk_misc_set_alignment (GTK_MISC (impl->save_folder_label), 0.0, 0.5);
3348- gtk_table_attach (GTK_TABLE (table), impl->save_folder_label,
3349- 0, 1, 1, 2,
3350- GTK_FILL, GTK_FILL,
3351- 0, 0);
3352- gtk_widget_show (impl->save_folder_label);
3353-
3354- impl->save_folder_combo = save_folder_combo_create (impl);
3355- gtk_table_attach (GTK_TABLE (table), impl->save_folder_combo,
3356- 1, 2, 1, 2,
3357- GTK_EXPAND | GTK_FILL, GTK_FILL,
3358- 0, 0);
3359- gtk_label_set_mnemonic_widget (GTK_LABEL (impl->save_folder_label), impl->save_folder_combo);
3360-
3361- /* Expander */
3362- alignment = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
3363- gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
3364-
3365- impl->save_expander = gtk_expander_new_with_mnemonic (_("_Browse for other folders"));
3366- gtk_container_add (GTK_CONTAINER (alignment), impl->save_expander);
3367- g_signal_connect (impl->save_expander, "notify::expanded",
3368- G_CALLBACK (expander_changed_cb),
3369- impl);
3370- gtk_widget_show_all (alignment);
3371
3372+ gtk_widget_show (hbox);
3373+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
3374+
3375 return vbox;
3376 }
3377
3378@@ -3576,29 +1432,11 @@
3379 static GtkWidget *
3380 browse_widgets_create (GtkFileChooserDefault *impl)
3381 {
3382- GtkWidget *vbox;
3383- GtkWidget *hpaned;
3384 GtkWidget *widget;
3385- GtkSizeGroup *size_group;
3386
3387- /* size group is used by the [+][-] buttons and the filter combo */
3388- size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
3389- vbox = gtk_vbox_new (FALSE, 12);
3390-
3391- /* Paned widget */
3392- hpaned = gtk_hpaned_new ();
3393- gtk_widget_show (hpaned);
3394- gtk_paned_set_position (GTK_PANED (hpaned), 200); /* FIXME: this sucks */
3395- gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0);
3396-
3397- widget = shortcuts_pane_create (impl, size_group);
3398- gtk_paned_pack1 (GTK_PANED (hpaned), widget, FALSE, FALSE);
3399- widget = file_pane_create (impl, size_group);
3400- gtk_paned_pack2 (GTK_PANED (hpaned), widget, TRUE, FALSE);
3401+ widget = file_pane_create (impl);
3402
3403- g_object_unref (size_group);
3404-
3405- return vbox;
3406+ return widget;
3407 }
3408
3409 static GObject*
3410@@ -3618,56 +1456,20 @@
3411
3412 gtk_widget_push_composite_child ();
3413
3414- /* Shortcuts model */
3415-
3416- shortcuts_model_create (impl);
3417-
3418- /* Widgets for Save mode */
3419- impl->save_widgets = save_widgets_create (impl);
3420- gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
3421-
3422 /* The browse widgets */
3423 impl->browse_widgets = browse_widgets_create (impl);
3424 gtk_box_pack_start (GTK_BOX (impl), impl->browse_widgets, TRUE, TRUE, 0);
3425
3426- /* Alignment to hold extra widget */
3427- impl->extra_align = gtk_alignment_new (0.0, 0.5, 1.0, 1.0);
3428- gtk_box_pack_start (GTK_BOX (impl), impl->extra_align, FALSE, FALSE, 0);
3429-
3430+ /* Widgets for Save mode */
3431+ impl->save_widgets = save_widgets_create (impl);
3432+ gtk_box_pack_start (GTK_BOX (impl), impl->save_widgets, FALSE, FALSE, 0);
3433+
3434 gtk_widget_pop_composite_child ();
3435 update_appearance (impl);
3436
3437 return object;
3438 }
3439
3440-/* Sets the extra_widget by packing it in the appropriate place */
3441-static void
3442-set_extra_widget (GtkFileChooserDefault *impl,
3443- GtkWidget *extra_widget)
3444-{
3445- if (extra_widget)
3446- {
3447- g_object_ref (extra_widget);
3448- /* FIXME: is this right ? */
3449- gtk_widget_show (extra_widget);
3450- }
3451-
3452- if (impl->extra_widget)
3453- {
3454- gtk_container_remove (GTK_CONTAINER (impl->extra_align), impl->extra_widget);
3455- g_object_unref (impl->extra_widget);
3456- }
3457-
3458- impl->extra_widget = extra_widget;
3459- if (impl->extra_widget)
3460- {
3461- gtk_container_add (GTK_CONTAINER (impl->extra_align), impl->extra_widget);
3462- gtk_widget_show (impl->extra_align);
3463- }
3464- else
3465- gtk_widget_hide (impl->extra_align);
3466-}
3467-
3468 static void
3469 set_local_only (GtkFileChooserDefault *impl,
3470 gboolean local_only)
3471@@ -3676,12 +1478,6 @@
3472 {
3473 impl->local_only = local_only;
3474
3475- if (impl->shortcuts_model && impl->file_system)
3476- {
3477- shortcuts_add_volumes (impl);
3478- shortcuts_add_bookmarks (impl);
3479- }
3480-
3481 if (local_only &&
3482 !gtk_file_system_path_is_local (impl->file_system, impl->current_folder))
3483 {
3484@@ -3708,18 +1504,7 @@
3485 volumes_changed_cb (GtkFileSystem *file_system,
3486 GtkFileChooserDefault *impl)
3487 {
3488- shortcuts_add_volumes (impl);
3489-}
3490-
3491-/* Callback used when the set of bookmarks changes in the file system */
3492-static void
3493-bookmarks_changed_cb (GtkFileSystem *file_system,
3494- GtkFileChooserDefault *impl)
3495-{
3496- shortcuts_add_bookmarks (impl);
3497-
3498- bookmarks_check_add_sensitivity (impl);
3499- bookmarks_check_remove_sensitivity (impl);
3500+ /* FIXME -- not needed */
3501 }
3502
3503 /* Sets the file chooser to multiple selection mode */
3504@@ -3741,8 +1526,6 @@
3505
3506 impl->select_multiple = select_multiple;
3507 g_object_notify (G_OBJECT (impl), "select-multiple");
3508-
3509- check_preview_change (impl);
3510 }
3511
3512 static void
3513@@ -3753,8 +1536,6 @@
3514 {
3515 g_signal_handler_disconnect (impl->file_system, impl->volumes_changed_id);
3516 impl->volumes_changed_id = 0;
3517- g_signal_handler_disconnect (impl->file_system, impl->bookmarks_changed_id);
3518- impl->bookmarks_changed_id = 0;
3519 g_object_unref (impl->file_system);
3520 }
3521
3522@@ -3790,9 +1571,6 @@
3523 impl->volumes_changed_id = g_signal_connect (impl->file_system, "volumes-changed",
3524 G_CALLBACK (volumes_changed_cb),
3525 impl);
3526- impl->bookmarks_changed_id = g_signal_connect (impl->file_system, "bookmarks-changed",
3527- G_CALLBACK (bookmarks_changed_cb),
3528- impl);
3529 }
3530 }
3531
3532@@ -3807,30 +1585,8 @@
3533 if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
3534 impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
3535 {
3536- const char *text;
3537-
3538 gtk_widget_show (impl->save_widgets);
3539-
3540- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
3541- text = _("Save in _folder:");
3542- else
3543- text = _("Create in _folder:");
3544-
3545- gtk_label_set_text_with_mnemonic (GTK_LABEL (impl->save_folder_label), text);
3546-
3547- if (gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
3548- {
3549- gtk_widget_set_sensitive (impl->save_folder_label, FALSE);
3550- gtk_widget_set_sensitive (impl->save_folder_combo, FALSE);
3551- gtk_widget_show (impl->browse_widgets);
3552- }
3553- else
3554- {
3555- gtk_widget_set_sensitive (impl->save_folder_label, TRUE);
3556- gtk_widget_set_sensitive (impl->save_folder_combo, TRUE);
3557- gtk_widget_hide (impl->browse_widgets);
3558- }
3559-
3560+ gtk_widget_show (impl->browse_widgets);
3561 gtk_widget_show (impl->browse_new_folder_button);
3562
3563 if (impl->select_multiple)
3564@@ -3844,6 +1600,7 @@
3565 impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
3566 {
3567 gtk_widget_hide (impl->save_widgets);
3568+ gtk_widget_hide (impl->browse_new_folder_button);
3569 gtk_widget_show (impl->browse_widgets);
3570 }
3571
3572@@ -3876,12 +1633,9 @@
3573 {
3574 gtk_file_chooser_default_unselect_all (GTK_FILE_CHOOSER (impl));
3575
3576- if ((action == GTK_FILE_CHOOSER_ACTION_SAVE || action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
3577- && impl->select_multiple)
3578+ if (action == GTK_FILE_CHOOSER_ACTION_SAVE && impl->select_multiple)
3579 {
3580- g_warning ("Tried to change the file chooser action to SAVE or CREATE_FOLDER, but "
3581- "this is not allowed in multiple selection mode. Resetting the file chooser "
3582- "to single selection mode.");
3583+ g_warning ("Multiple selection mode is not allowed in Save mode");
3584 set_select_multiple (impl, FALSE, TRUE);
3585 }
3586 impl->action = action;
3587@@ -3902,29 +1656,12 @@
3588 case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
3589 set_local_only (impl, g_value_get_boolean (value));
3590 break;
3591- case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
3592- set_preview_widget (impl, g_value_get_object (value));
3593- break;
3594- case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
3595- impl->preview_widget_active = g_value_get_boolean (value);
3596- update_preview_widget_visibility (impl);
3597- break;
3598- case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
3599- impl->use_preview_label = g_value_get_boolean (value);
3600- update_preview_widget_visibility (impl);
3601- break;
3602- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
3603- set_extra_widget (impl, g_value_get_object (value));
3604- break;
3605 case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
3606 {
3607 gboolean select_multiple = g_value_get_boolean (value);
3608- if ((impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
3609- && select_multiple)
3610+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE && select_multiple)
3611 {
3612- g_warning ("Tried to set the file chooser to multiple selection mode, but this is "
3613- "not allowed in SAVE or CREATE_FOLDER modes. Ignoring the change and "
3614- "leaving the file chooser in single selection mode.");
3615+ g_warning ("Multiple selection mode is not allowed in Save mode");
3616 return;
3617 }
3618
3619@@ -3943,6 +1680,19 @@
3620 }
3621 }
3622 break;
3623+ case GTK_FILE_CHOOSER_PROP_ROOT_FOLDER:
3624+ {
3625+ impl->root_folder = g_strdup (g_value_get_string (value));
3626+ }
3627+ break;
3628+
3629+ /* These are not supported */
3630+ case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
3631+ case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
3632+ case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
3633+ case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
3634+ break;
3635+
3636 default:
3637 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3638 break;
3639@@ -3968,24 +1718,30 @@
3640 case GTK_FILE_CHOOSER_PROP_LOCAL_ONLY:
3641 g_value_set_boolean (value, impl->local_only);
3642 break;
3643+ case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
3644+ g_value_set_boolean (value, impl->select_multiple);
3645+ break;
3646+ case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
3647+ g_value_set_boolean (value, impl->show_hidden);
3648+ break;
3649+ case GTK_FILE_CHOOSER_PROP_ROOT_FOLDER:
3650+ g_value_set_string (value, impl->root_folder);
3651+ break;
3652+
3653+ /* These are not supported */
3654 case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
3655- g_value_set_object (value, impl->preview_widget);
3656+ g_value_set_object (value, NULL);
3657 break;
3658 case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
3659- g_value_set_boolean (value, impl->preview_widget_active);
3660+ g_value_set_boolean (value, FALSE);
3661 break;
3662 case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
3663- g_value_set_boolean (value, impl->use_preview_label);
3664+ g_value_set_boolean (value, FALSE);
3665 break;
3666 case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
3667- g_value_set_object (value, impl->extra_widget);
3668- break;
3669- case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
3670- g_value_set_boolean (value, impl->select_multiple);
3671- break;
3672- case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
3673- g_value_set_boolean (value, impl->show_hidden);
3674+ g_value_set_object (value, NULL);
3675 break;
3676+
3677 default:
3678 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
3679 break;
3680@@ -4013,12 +1769,6 @@
3681 {
3682 GtkFileChooserDefault *impl = (GtkFileChooserDefault *) object;
3683
3684- if (impl->extra_widget)
3685- {
3686- g_object_unref (impl->extra_widget);
3687- impl->extra_widget = NULL;
3688- }
3689-
3690 remove_settings_signal (impl, gtk_widget_get_screen (GTK_WIDGET (impl)));
3691
3692 G_OBJECT_CLASS (parent_class)->dispose (object);
3693@@ -4031,12 +1781,7 @@
3694 static void
3695 gtk_file_chooser_default_show_all (GtkWidget *widget)
3696 {
3697- GtkFileChooserDefault *impl = (GtkFileChooserDefault *) widget;
3698-
3699 gtk_widget_show (widget);
3700-
3701- if (impl->extra_widget)
3702- gtk_widget_show_all (impl->extra_widget);
3703 }
3704
3705 /* Handler for GtkWindow::set-focus; this is where we save the last-focused
3706@@ -4095,7 +1840,6 @@
3707 else
3708 impl->icon_size = FALLBACK_ICON_SIZE;
3709
3710- shortcuts_reload_icons (impl);
3711 gtk_widget_queue_resize (impl->browse_files_tree_view);
3712 }
3713
3714@@ -4231,8 +1975,6 @@
3715 pending_select_paths_store_selection (impl);
3716 change_folder_and_display_error (impl, impl->current_folder);
3717 }
3718-
3719- bookmarks_changed_cb (impl->file_system, impl);
3720 }
3721
3722 static gboolean
3723@@ -4519,18 +2261,21 @@
3724 GtkFileFolder *folder;
3725 gboolean success;
3726 gboolean have_hidden;
3727- gboolean have_filtered;
3728
3729 if (!only_one_path && !paths)
3730 return TRUE;
3731
3732+#ifdef GTK26
3733 folder = gtk_file_system_get_folder (impl->file_system, parent_path, GTK_FILE_INFO_IS_HIDDEN, error);
3734+#else
3735+ folder = gtk_file_system_get_folder (impl->file_system, parent_path, GTK_FILE_INFO_IS_HIDDEN, NULL, NULL);
3736+#endif
3737+
3738 if (!folder)
3739 return FALSE;
3740
3741 success = FALSE;
3742 have_hidden = FALSE;
3743- have_filtered = FALSE;
3744
3745 if (only_one_path)
3746 {
3747@@ -4541,7 +2286,6 @@
3748 {
3749 success = TRUE;
3750 have_hidden = gtk_file_info_get_is_hidden (info);
3751- have_filtered = get_is_file_filtered (impl, only_one_path, info);
3752 gtk_file_info_free (info);
3753 }
3754 }
3755@@ -4563,12 +2307,9 @@
3756 if (!have_hidden)
3757 have_hidden = gtk_file_info_get_is_hidden (info);
3758
3759- if (!have_filtered)
3760- have_filtered = get_is_file_filtered (impl, path, info);
3761-
3762 gtk_file_info_free (info);
3763
3764- if (have_hidden && have_filtered)
3765+ if (have_hidden)
3766 break; /* we now have all the information we need */
3767 }
3768 }
3769@@ -4584,9 +2325,6 @@
3770 if (have_hidden)
3771 g_object_set (impl, "show-hidden", TRUE, NULL);
3772
3773- if (have_filtered)
3774- set_current_filter (impl, NULL);
3775-
3776 if (only_one_path)
3777 _gtk_file_system_model_path_do (impl->browse_files_model, only_one_path, select_func, impl);
3778 else
3779@@ -4629,13 +2367,11 @@
3780 * that case, the chooser's selection should be what the caller expects,
3781 * as the user can't see that something else got selected. See bug #165264.
3782 *
3783- * Also, we don't select the first file if we are not in OPEN mode. Doing
3784- * so would change the contents of the filename entry for SAVE or
3785- * CREATE_FOLDER, which is undesired; in SELECT_FOLDER, we don't want to
3786- * select a *different* folder from the one into which the user just
3787- * navigated.
3788+ * Also, we don't select the first file if we are in SAVE or CREATE_FOLDER
3789+ * modes. Doing so would change the contents of the filename entry.
3790 */
3791- if (GTK_WIDGET_MAPPED (impl) && impl->action == GTK_FILE_CHOOSER_ACTION_OPEN)
3792+ if (GTK_WIDGET_MAPPED (impl)
3793+ && !(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
3794 browse_files_select_first_row (impl);
3795 }
3796
3797@@ -4725,19 +2461,15 @@
3798 const GtkFileInfo *info;
3799 GtkTreeIter iter;
3800 GtkTreeIter child_iter;
3801- gboolean change_entry;
3802
3803- if (!(impl->action == GTK_FILE_CHOOSER_ACTION_SAVE || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER))
3804+ if (impl->action != GTK_FILE_CHOOSER_ACTION_SAVE)
3805 return;
3806
3807 g_assert (!impl->select_multiple);
3808 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
3809
3810 if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
3811- {
3812- _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), "");
3813- return;
3814- }
3815+ return;
3816
3817 gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
3818 &child_iter,
3819@@ -4745,12 +2477,7 @@
3820
3821 info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
3822
3823- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
3824- change_entry = !gtk_file_info_get_is_folder (info); /* We don't want the name to change when clicking on a folder... */
3825- else
3826- change_entry = TRUE; /* ... unless we are in CREATE_FOLDER mode */
3827-
3828- if (change_entry)
3829+ if (!gtk_file_info_get_is_folder (info))
3830 _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
3831 gtk_file_info_get_display_name (info));
3832 }
3833@@ -4780,9 +2507,6 @@
3834 if (!check_is_folder (impl->file_system, path, error))
3835 return FALSE;
3836
3837- if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, error))
3838- return FALSE;
3839-
3840 if (impl->current_folder != path)
3841 {
3842 if (impl->current_folder)
3843@@ -4791,17 +2515,6 @@
3844 impl->current_folder = gtk_file_path_copy (path);
3845 }
3846
3847- /* Update the widgets that may trigger a folder change themselves. */
3848-
3849- if (!impl->changing_folder)
3850- {
3851- impl->changing_folder = TRUE;
3852-
3853- shortcuts_update_current_folder (impl);
3854-
3855- impl->changing_folder = FALSE;
3856- }
3857-
3858 /* Set the folder on the save entry */
3859
3860 _gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry),
3861@@ -4815,13 +2528,7 @@
3862
3863 /* Refresh controls */
3864
3865- shortcuts_find_current_folder (impl);
3866-
3867 g_signal_emit_by_name (impl, "current-folder-changed", 0);
3868-
3869- check_preview_change (impl);
3870- bookmarks_check_add_sensitivity (impl);
3871-
3872 g_signal_emit_by_name (impl, "selection-changed", 0);
3873
3874 return result;
3875@@ -4844,7 +2551,6 @@
3876 g_return_if_fail (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
3877 || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
3878
3879- pending_select_paths_free (impl);
3880 _gtk_file_chooser_entry_set_file_part (GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry), name);
3881 }
3882
3883@@ -4983,24 +2689,13 @@
3884 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
3885
3886 gtk_tree_selection_unselect_all (selection);
3887- pending_select_paths_free (impl);
3888 }
3889
3890-/* Checks whether the filename entry for the Save modes contains a well-formed filename.
3891- *
3892- * is_well_formed_ret - whether what the user typed passes gkt_file_system_make_path()
3893- *
3894- * is_empty_ret - whether the file entry is totally empty
3895- *
3896- * is_file_part_empty_ret - whether the file part is empty (will be if user types "foobar/", and
3897- * the path will be "$cwd/foobar")
3898- */
3899-static void
3900+/* Checks whether the filename entry for the Save modes contains a valid filename */
3901+static GtkFilePath *
3902 check_save_entry (GtkFileChooserDefault *impl,
3903- GtkFilePath **path_ret,
3904- gboolean *is_well_formed_ret,
3905- gboolean *is_empty_ret,
3906- gboolean *is_file_part_empty_ret)
3907+ gboolean *is_valid,
3908+ gboolean *is_empty)
3909 {
3910 GtkFileChooserEntry *chooser_entry;
3911 const GtkFilePath *current_folder;
3912@@ -5013,31 +2708,17 @@
3913
3914 chooser_entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
3915
3916- if (strlen (gtk_entry_get_text (GTK_ENTRY (chooser_entry))) == 0)
3917- {
3918- *path_ret = NULL;
3919- *is_well_formed_ret = TRUE;
3920- *is_empty_ret = TRUE;
3921- *is_file_part_empty_ret = TRUE;
3922-
3923- return;
3924- }
3925-
3926- *is_empty_ret = FALSE;
3927-
3928 current_folder = _gtk_file_chooser_entry_get_current_folder (chooser_entry);
3929 file_part = _gtk_file_chooser_entry_get_file_part (chooser_entry);
3930
3931 if (!file_part || file_part[0] == '\0')
3932 {
3933- *path_ret = gtk_file_path_copy (current_folder);
3934- *is_well_formed_ret = TRUE;
3935- *is_file_part_empty_ret = TRUE;
3936-
3937- return;
3938+ *is_valid = FALSE;
3939+ *is_empty = TRUE;
3940+ return NULL;
3941 }
3942
3943- *is_file_part_empty_ret = FALSE;
3944+ *is_empty = FALSE;
3945
3946 error = NULL;
3947 path = gtk_file_system_make_path (impl->file_system, current_folder, file_part, &error);
3948@@ -5045,14 +2726,12 @@
3949 if (!path)
3950 {
3951 error_building_filename_dialog (impl, current_folder, file_part, error);
3952- *path_ret = NULL;
3953- *is_well_formed_ret = FALSE;
3954-
3955- return;
3956+ *is_valid = FALSE;
3957+ return NULL;
3958 }
3959
3960- *path_ret = path;
3961- *is_well_formed_ret = TRUE;
3962+ *is_valid = TRUE;
3963+ return path;
3964 }
3965
3966 struct get_paths_closure {
3967@@ -5098,21 +2777,11 @@
3968 if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
3969 || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
3970 {
3971- gboolean is_well_formed, is_empty, is_file_part_empty;
3972+ gboolean is_valid, is_empty;
3973
3974- check_save_entry (impl, &info.path_from_entry, &is_well_formed, &is_empty, &is_file_part_empty);
3975-
3976- if (!is_well_formed)
3977+ info.path_from_entry = check_save_entry (impl, &is_valid, &is_empty);
3978+ if (!is_valid && !is_empty)
3979 return NULL;
3980-
3981- if (!is_empty)
3982- {
3983- if (is_file_part_empty && impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
3984- {
3985- gtk_file_path_free (info.path_from_entry);
3986- return NULL;
3987- }
3988- }
3989 }
3990
3991 if (!info.path_from_entry || impl->select_multiple)
3992@@ -5137,17 +2806,6 @@
3993 return g_slist_reverse (info.result);
3994 }
3995
3996-static GtkFilePath *
3997-gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser)
3998-{
3999- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4000-
4001- if (impl->preview_path)
4002- return gtk_file_path_copy (impl->preview_path);
4003- else
4004- return NULL;
4005-}
4006-
4007 static GtkFileSystem *
4008 gtk_file_chooser_default_get_file_system (GtkFileChooser *chooser)
4009 {
4010@@ -5162,9 +2820,9 @@
4011 gboolean show)
4012 {
4013 if (show)
4014- gtk_widget_show (impl->filter_combo_hbox);
4015+ gtk_widget_show (impl->filter_combo);
4016 else
4017- gtk_widget_hide (impl->filter_combo_hbox);
4018+ gtk_widget_hide (impl->filter_combo);
4019 }
4020
4021 static void
4022@@ -5174,6 +2832,8 @@
4023 GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4024 const gchar *name;
4025
4026+ g_debug ("adding filter");
4027+
4028 if (g_slist_find (impl->filters, filter))
4029 {
4030 g_warning ("gtk_file_chooser_add_filter() called on filter already in list\n");
4031@@ -5215,165 +2875,31 @@
4032
4033 impl->filters = g_slist_remove (impl->filters, filter);
4034
4035- if (filter == impl->current_filter)
4036- {
4037- if (impl->filters)
4038- set_current_filter (impl, impl->filters->data);
4039- else
4040- set_current_filter (impl, NULL);
4041- }
4042-
4043- /* Remove row from the combo box */
4044- model = gtk_combo_box_get_model (GTK_COMBO_BOX (impl->filter_combo));
4045- gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_index);
4046- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
4047-
4048- g_object_unref (filter);
4049-
4050- if (!impl->filters)
4051- show_filters (impl, FALSE);
4052-}
4053-
4054-static GSList *
4055-gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
4056-{
4057- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4058-
4059- return g_slist_copy (impl->filters);
4060-}
4061-
4062-/* Returns the position in the shortcuts tree where the nth specified shortcut would appear */
4063-static int
4064-shortcuts_get_pos_for_shortcut_folder (GtkFileChooserDefault *impl,
4065- int pos)
4066-{
4067- return pos + shortcuts_get_index (impl, SHORTCUTS_SHORTCUTS);
4068-}
4069-
4070-static gboolean
4071-gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
4072- const GtkFilePath *path,
4073- GError **error)
4074-{
4075- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4076- gboolean result;
4077- int pos;
4078-
4079- /* Test validity of path here. */
4080- if (!check_is_folder (impl->file_system, path, error))
4081- return FALSE;
4082-
4083- pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
4084-
4085- result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);
4086-
4087- if (result)
4088- impl->num_shortcuts++;
4089-
4090- if (impl->shortcuts_filter_model)
4091- gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model));
4092-
4093- return result;
4094-}
4095-
4096-static gboolean
4097-gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
4098- const GtkFilePath *path,
4099- GError **error)
4100-{
4101- GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4102- int pos;
4103- GtkTreeIter iter;
4104- char *uri;
4105- int i;
4106-
4107- if (impl->num_shortcuts == 0)
4108- goto out;
4109-
4110- pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
4111- if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
4112- g_assert_not_reached ();
4113-
4114- for (i = 0; i < impl->num_shortcuts; i++)
4115- {
4116- gpointer col_data;
4117- gboolean is_volume;
4118- GtkFilePath *shortcut;
4119-
4120- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
4121- SHORTCUTS_COL_DATA, &col_data,
4122- SHORTCUTS_COL_IS_VOLUME, &is_volume,
4123- -1);
4124- g_assert (col_data != NULL);
4125- g_assert (!is_volume);
4126-
4127- shortcut = col_data;
4128- if (gtk_file_path_compare (shortcut, path) == 0)
4129- {
4130- shortcuts_remove_rows (impl, pos + i, 1);
4131- impl->num_shortcuts--;
4132- return TRUE;
4133- }
4134-
4135- if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
4136- g_assert_not_reached ();
4137+ if (filter == impl->current_filter)
4138+ {
4139+ if (impl->filters)
4140+ set_current_filter (impl, impl->filters->data);
4141+ else
4142+ set_current_filter (impl, NULL);
4143 }
4144
4145- out:
4146+ /* Remove row from the combo box */
4147+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (impl->filter_combo));
4148+ gtk_tree_model_iter_nth_child (model, &iter, NULL, filter_index);
4149+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
4150
4151- uri = gtk_file_system_path_to_uri (impl->file_system, path);
4152- g_set_error (error,
4153- GTK_FILE_CHOOSER_ERROR,
4154- GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
4155- _("Shortcut %s does not exist"),
4156- uri);
4157- g_free (uri);
4158+ g_object_unref (filter);
4159
4160- return FALSE;
4161+ if (!impl->filters)
4162+ show_filters (impl, FALSE);
4163 }
4164
4165 static GSList *
4166-gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
4167+gtk_file_chooser_default_list_filters (GtkFileChooser *chooser)
4168 {
4169 GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
4170- int pos;
4171- GtkTreeIter iter;
4172- int i;
4173- GSList *list;
4174
4175- if (impl->num_shortcuts == 0)
4176- return NULL;
4177-
4178- pos = shortcuts_get_pos_for_shortcut_folder (impl, 0);
4179- if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
4180- g_assert_not_reached ();
4181-
4182- list = NULL;
4183-
4184- for (i = 0; i < impl->num_shortcuts; i++)
4185- {
4186- gpointer col_data;
4187- gboolean is_volume;
4188- GtkFilePath *shortcut;
4189-
4190- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), &iter,
4191- SHORTCUTS_COL_DATA, &col_data,
4192- SHORTCUTS_COL_IS_VOLUME, &is_volume,
4193- -1);
4194- g_assert (col_data != NULL);
4195- g_assert (!is_volume);
4196-
4197- shortcut = col_data;
4198- list = g_slist_prepend (list, gtk_file_path_copy (shortcut));
4199-
4200- if (i != impl->num_shortcuts - 1)
4201- {
4202- if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (impl->shortcuts_model), &iter))
4203- g_assert_not_reached ();
4204- }
4205- }
4206-
4207- return g_slist_reverse (list);
4208+ return g_slist_copy (impl->filters);
4209 }
4210
4211 /* Guesses a size based upon font sizes */
4212@@ -5386,7 +2912,6 @@
4213 gint default_width, default_height;
4214 int font_size;
4215 GtkRequisition req;
4216- GtkRequisition preview_req;
4217
4218 g_assert (widget->style != NULL);
4219 impl = GTK_FILE_CHOOSER_DEFAULT (widget);
4220@@ -5400,12 +2925,7 @@
4221 /* Use at least the requisition size not including the preview widget */
4222 gtk_widget_size_request (widget, &req);
4223
4224- if (impl->preview_widget_active && impl->preview_widget)
4225- gtk_widget_size_request (impl->preview_box, &preview_req);
4226- else
4227- preview_req.width = 0;
4228-
4229- default_width = MAX (default_width, (req.width - (preview_req.width + PREVIEW_HBOX_SPACING)));
4230+ default_width = MAX (default_width, (req.width - (LIST_HBOX_SPACING)));
4231 default_height = MAX (default_height, req.height);
4232
4233 *width = default_width;
4234@@ -5423,8 +2943,6 @@
4235
4236 find_good_size_from_style (GTK_WIDGET (chooser_embed), default_width, default_height);
4237
4238- if (impl->preview_widget_active && impl->preview_widget)
4239- *default_width += impl->preview_box->requisition.width + PREVIEW_HBOX_SPACING;
4240 }
4241
4242 static void
4243@@ -5441,16 +2959,6 @@
4244
4245 *resize_horizontally = TRUE;
4246 *resize_vertically = TRUE;
4247-
4248- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
4249- impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
4250- {
4251- if (! gtk_expander_get_expanded (GTK_EXPANDER (impl->save_expander)))
4252- {
4253- *resize_horizontally = FALSE;
4254- *resize_vertically = FALSE;
4255- }
4256- }
4257 }
4258
4259 struct switch_folder_closure {
4260@@ -5517,84 +3025,49 @@
4261
4262 if (current_focus == impl->browse_files_tree_view)
4263 {
4264- /* The following array encodes what we do based on the impl->action and the
4265- * number of files selected.
4266- */
4267- typedef enum {
4268- NOOP, /* Do nothing (don't respond) */
4269- RESPOND, /* Respond immediately */
4270- RESPOND_OR_SWITCH, /* Respond immediately if the selected item is a file; switch to it if it is a folder */
4271- ALL_FILES, /* Respond only if everything selected is a file */
4272- ALL_FOLDERS, /* Respond only if everything selected is a folder */
4273- SAVE_ENTRY, /* Go to the code for handling the save entry */
4274- NOT_REACHED /* Sanity check */
4275- } ActionToTake;
4276- static const ActionToTake what_to_do[4][3] = {
4277- /* 0 selected 1 selected many selected */
4278- /* ACTION_OPEN */ { NOOP, RESPOND_OR_SWITCH, ALL_FILES },
4279- /* ACTION_SAVE */ { SAVE_ENTRY, RESPOND_OR_SWITCH, NOT_REACHED },
4280- /* ACTION_SELECT_FOLDER */ { RESPOND, ALL_FOLDERS, ALL_FOLDERS },
4281- /* ACTION_CREATE_FOLDER */ { SAVE_ENTRY, ALL_FOLDERS, NOT_REACHED }
4282- };
4283-
4284 int num_selected;
4285 gboolean all_files, all_folders;
4286- int k;
4287- ActionToTake action;
4288
4289 file_list:
4290
4291- g_assert (impl->action >= GTK_FILE_CHOOSER_ACTION_OPEN && impl->action <= GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
4292-
4293 selection_check (impl, &num_selected, &all_files, &all_folders);
4294
4295- if (num_selected > 2)
4296- k = 2;
4297- else
4298- k = num_selected;
4299-
4300- action = what_to_do [impl->action] [k];
4301-
4302- switch (action)
4303+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
4304 {
4305- case NOOP:
4306- return FALSE;
4307-
4308- case RESPOND:
4309- return TRUE;
4310-
4311- case RESPOND_OR_SWITCH:
4312- g_assert (num_selected == 1);
4313-
4314- if (all_folders)
4315+ if (num_selected != 1)
4316+ return TRUE; /* zero means current folder; more than one means use the whole selection */
4317+ else if (current_focus != impl->browse_files_tree_view)
4318 {
4319- switch_to_selected_folder (impl);
4320- return FALSE;
4321+ /* a single folder is selected and a button was clicked */
4322+ switch_to_selected_folder (impl);
4323+ return TRUE;
4324 }
4325- else
4326- return TRUE;
4327-
4328- case ALL_FILES:
4329- return all_files;
4330-
4331- case ALL_FOLDERS:
4332- return all_folders;
4333+ }
4334
4335- case SAVE_ENTRY:
4336- goto save_entry;
4337+ if (num_selected == 0)
4338+ {
4339+ if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE
4340+ || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
4341+ goto save_entry; /* it makes sense to use the typed name */
4342+ else
4343+ return FALSE;
4344+ }
4345
4346- default:
4347- g_assert_not_reached ();
4348+ if (num_selected == 1 && all_folders)
4349+ {
4350+ switch_to_selected_folder (impl);
4351+ return FALSE;
4352 }
4353+ else
4354+ return all_files;
4355 }
4356 else if (current_focus == impl->save_file_name_entry)
4357 {
4358 GtkFilePath *path;
4359- gboolean is_well_formed, is_empty, is_file_part_empty;
4360+ gboolean is_valid, is_empty;
4361 gboolean is_folder;
4362 gboolean retval;
4363- GtkFileChooserEntry *entry;
4364- GError *error;
4365+ GtkFileChooserEntry *entry;
4366
4367 save_entry:
4368
4369@@ -5602,103 +3075,39 @@
4370 || impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
4371
4372 entry = GTK_FILE_CHOOSER_ENTRY (impl->save_file_name_entry);
4373- check_save_entry (impl, &path, &is_well_formed, &is_empty, &is_file_part_empty);
4374+ path = check_save_entry (impl, &is_valid, &is_empty);
4375
4376- if (is_empty || !is_well_formed)
4377+ if (!is_empty && !is_valid)
4378 return FALSE;
4379
4380- g_assert (path != NULL);
4381-
4382- error = NULL;
4383- is_folder = check_is_folder (impl->file_system, path, &error);
4384+ if (is_empty)
4385+ path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
4386+
4387+ is_folder = check_is_folder (impl->file_system, path, NULL);
4388 if (is_folder)
4389 {
4390- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
4391- {
4392- _gtk_file_chooser_entry_set_file_part (entry, "");
4393- change_folder_and_display_error (impl, path);
4394- retval = FALSE;
4395- }
4396- else /* GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER */
4397- {
4398- /* The folder already exists, so we do not need to create it.
4399- * Just respond to terminate the dialog.
4400- */
4401- retval = TRUE;
4402- }
4403+ _gtk_file_chooser_entry_set_file_part (entry, "");
4404+ change_folder_and_display_error (impl, path);
4405+ retval = FALSE;
4406 }
4407 else
4408 {
4409- if (impl->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
4410- && g_error_matches (error, GTK_FILE_SYSTEM_ERROR, GTK_FILE_SYSTEM_ERROR_NOT_FOLDER))
4411+ /* check that everything up to the last component exists */
4412+ gtk_file_path_free (path);
4413+ path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
4414+ is_folder = check_is_folder (impl->file_system, path, NULL);
4415+ if (!is_folder)
4416 {
4417- /* Oops, the user typed the name of an existing path which is not a folder */
4418- error_creating_folder_over_existing_file_dialog (impl, path, error);
4419- error = NULL; /* as it will be freed below for the general case */
4420+ change_folder_and_display_error (impl, path);
4421 retval = FALSE;
4422 }
4423 else
4424- {
4425- GtkFilePath *parent_path;
4426-
4427- /* check that everything up to the last component exists */
4428-
4429- parent_path = gtk_file_path_copy (_gtk_file_chooser_entry_get_current_folder (entry));
4430- is_folder = check_is_folder (impl->file_system, parent_path, NULL);
4431- if (is_folder)
4432- {
4433- if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE)
4434- retval = TRUE;
4435- else /* GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER */
4436- {
4437- GError *create_error;
4438-
4439- create_error = NULL;
4440- if (gtk_file_system_create_folder (impl->file_system, path, &create_error))
4441- retval = TRUE;
4442- else
4443- {
4444- error_creating_folder_dialog (impl, path, create_error);
4445- retval = FALSE;
4446- }
4447- }
4448- }
4449- else
4450- {
4451- /* This will display an error, which is what we want */
4452- change_folder_and_display_error (impl, parent_path);
4453- retval = FALSE;
4454- }
4455-
4456- gtk_file_path_free (parent_path);
4457- }
4458-
4459- if (error != NULL)
4460- g_error_free (error);
4461+ retval = TRUE;
4462 }
4463
4464 gtk_file_path_free (path);
4465 return retval;
4466 }
4467- else if (impl->toplevel_last_focus_widget == impl->browse_shortcuts_tree_view)
4468- {
4469- /* The focus is on a dialog's action area button, *and* the widget that
4470- * was focused immediately before it is the shortcuts list. Switch to the
4471- * selected shortcut and tell the caller not to respond.
4472- */
4473- GtkTreeIter iter;
4474-
4475- if (shortcuts_get_selected (impl, &iter))
4476- {
4477- shortcuts_activate_iter (impl, &iter);
4478-
4479- gtk_widget_grab_focus (impl->browse_files_tree_view);
4480- }
4481- else
4482- goto file_list;
4483-
4484- return FALSE;
4485- }
4486 else if (impl->toplevel_last_focus_widget == impl->browse_files_tree_view)
4487 {
4488 /* The focus is on a dialog's action area button, *and* the widget that
4489@@ -5786,199 +3195,6 @@
4490 set_current_filter (impl, new_filter);
4491 }
4492
4493-static void
4494-check_preview_change (GtkFileChooserDefault *impl)
4495-{
4496- GtkTreePath *cursor_path;
4497- const GtkFilePath *new_path;
4498- const GtkFileInfo *new_info;
4499-
4500- gtk_tree_view_get_cursor (GTK_TREE_VIEW (impl->browse_files_tree_view), &cursor_path, NULL);
4501- if (cursor_path && impl->sort_model)
4502- {
4503- GtkTreeIter iter;
4504- GtkTreeIter child_iter;
4505-
4506- gtk_tree_model_get_iter (GTK_TREE_MODEL (impl->sort_model), &iter, cursor_path);
4507- gtk_tree_path_free (cursor_path);
4508-
4509- gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model, &child_iter, &iter);
4510-
4511- new_path = _gtk_file_system_model_get_path (impl->browse_files_model, &child_iter);
4512- new_info = _gtk_file_system_model_get_info (impl->browse_files_model, &child_iter);
4513- }
4514- else
4515- {
4516- new_path = NULL;
4517- new_info = NULL;
4518- }
4519-
4520- if (new_path != impl->preview_path &&
4521- !(new_path && impl->preview_path &&
4522- gtk_file_path_compare (new_path, impl->preview_path) == 0))
4523- {
4524- if (impl->preview_path)
4525- {
4526- gtk_file_path_free (impl->preview_path);
4527- g_free (impl->preview_display_name);
4528- }
4529-
4530- if (new_path)
4531- {
4532- impl->preview_path = gtk_file_path_copy (new_path);
4533- impl->preview_display_name = g_strdup (gtk_file_info_get_display_name (new_info));
4534- }
4535- else
4536- {
4537- impl->preview_path = NULL;
4538- impl->preview_display_name = NULL;
4539- }
4540-
4541- if (impl->use_preview_label && impl->preview_label)
4542- gtk_label_set_text (GTK_LABEL (impl->preview_label), impl->preview_display_name);
4543-
4544- g_signal_emit_by_name (impl, "update-preview");
4545- }
4546-}
4547-
4548-/* Activates a volume by mounting it if necessary and then switching to its
4549- * base path.
4550- */
4551-static void
4552-shortcuts_activate_volume (GtkFileChooserDefault *impl,
4553- GtkFileSystemVolume *volume)
4554-{
4555- GtkFilePath *path;
4556-
4557- /* We ref the file chooser since volume_mount() may run a main loop, and the
4558- * user could close the file chooser window in the meantime.
4559- */
4560- g_object_ref (impl);
4561-
4562- if (!gtk_file_system_volume_get_is_mounted (impl->file_system, volume))
4563- {
4564- GError *error;
4565- gboolean result;
4566-
4567- set_busy_cursor (impl, TRUE);
4568-
4569- error = NULL;
4570- result = gtk_file_system_volume_mount (impl->file_system, volume, &error);
4571-
4572- if (!result)
4573- {
4574- char *msg;
4575-
4576- msg = g_strdup_printf (_("Could not mount %s"),
4577- gtk_file_system_volume_get_display_name (impl->file_system, volume));
4578- error_message (impl, msg, error->message);
4579- g_free (msg);
4580- g_error_free (error);
4581- }
4582-
4583- set_busy_cursor (impl, FALSE);
4584-
4585- if (!result)
4586- goto out;
4587- }
4588-
4589- path = gtk_file_system_volume_get_base_path (impl->file_system, volume);
4590- change_folder_and_display_error (impl, path);
4591- gtk_file_path_free (path);
4592-
4593- out:
4594-
4595- g_object_unref (impl);
4596-}
4597-
4598-/* Opens the folder or volume at the specified iter in the shortcuts model */
4599-static void
4600-shortcuts_activate_iter (GtkFileChooserDefault *impl,
4601- GtkTreeIter *iter)
4602-{
4603- gpointer col_data;
4604- gboolean is_volume;
4605-
4606- gtk_tree_model_get (GTK_TREE_MODEL (impl->shortcuts_model), iter,
4607- SHORTCUTS_COL_DATA, &col_data,
4608- SHORTCUTS_COL_IS_VOLUME, &is_volume,
4609- -1);
4610-
4611- if (!col_data)
4612- return; /* We are on a separator */
4613-
4614- if (is_volume)
4615- {
4616- GtkFileSystemVolume *volume;
4617-
4618- volume = col_data;
4619-
4620- shortcuts_activate_volume (impl, volume);
4621- }
4622- else
4623- {
4624- const GtkFilePath *file_path;
4625-
4626- file_path = col_data;
4627- change_folder_and_display_error (impl, file_path);
4628- }
4629-}
4630-
4631-/* Callback used when a row in the shortcuts list is activated */
4632-static void
4633-shortcuts_row_activated_cb (GtkTreeView *tree_view,
4634- GtkTreePath *path,
4635- GtkTreeViewColumn *column,
4636- GtkFileChooserDefault *impl)
4637-{
4638- GtkTreeIter iter;
4639- GtkTreeIter child_iter;
4640-
4641- if (!gtk_tree_model_get_iter (impl->shortcuts_filter_model, &iter, path))
4642- return;
4643-
4644- gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (impl->shortcuts_filter_model),
4645- &child_iter,
4646- &iter);
4647- shortcuts_activate_iter (impl, &child_iter);
4648-
4649- gtk_widget_grab_focus (impl->browse_files_tree_view);
4650-}
4651-
4652-/* Handler for GtkWidget::key-press-event on the shortcuts list */
4653-static gboolean
4654-shortcuts_key_press_event_cb (GtkWidget *widget,
4655- GdkEventKey *event,
4656- GtkFileChooserDefault *impl)
4657-{
4658- guint modifiers;
4659-
4660- modifiers = gtk_accelerator_get_default_mod_mask ();
4661-
4662- if ((event->keyval == GDK_BackSpace
4663- || event->keyval == GDK_Delete
4664- || event->keyval == GDK_KP_Delete)
4665- && (event->state & modifiers) == 0)
4666- {
4667- remove_selected_bookmarks (impl);
4668- return TRUE;
4669- }
4670-
4671- return FALSE;
4672-}
4673-
4674-static gboolean
4675-shortcuts_select_func (GtkTreeSelection *selection,
4676- GtkTreeModel *model,
4677- GtkTreePath *path,
4678- gboolean path_currently_selected,
4679- gpointer data)
4680-{
4681- GtkFileChooserDefault *impl = data;
4682-
4683- return (*gtk_tree_path_get_indices (path) != shortcuts_get_index (impl, SHORTCUTS_BOOKMARKS_SEPARATOR));
4684-}
4685-
4686 static gboolean
4687 list_select_func (GtkTreeSelection *selection,
4688 GtkTreeModel *model,
4689@@ -6022,7 +3238,7 @@
4690 g_assert (!impl->select_multiple);
4691 selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_files_tree_view));
4692 if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
4693- goto out; /* normal processing */
4694+ return;
4695
4696 gtk_tree_model_sort_convert_iter_to_child_iter (impl->sort_model,
4697 &child_iter,
4698@@ -6033,11 +3249,7 @@
4699 return; /* We are on the editable row for New Folder */
4700 }
4701
4702- out:
4703-
4704 update_chooser_entry (impl);
4705- check_preview_change (impl);
4706- bookmarks_check_add_sensitivity (impl);
4707
4708 g_signal_emit_by_name (impl, "selection-changed", 0);
4709 }
4710@@ -6074,23 +3286,6 @@
4711 g_signal_emit_by_name (impl, "file-activated");
4712 }
4713
4714-static void
4715-path_bar_clicked (GtkPathBar *path_bar,
4716- GtkFilePath *file_path,
4717- gboolean child_is_hidden,
4718- GtkFileChooserDefault *impl)
4719-{
4720- if (!change_folder_and_display_error (impl, file_path))
4721- return;
4722-
4723- /* Say we have "/foo/bar/[.baz]" and the user clicks on "bar". We should then
4724- * show hidden files so that ".baz" appears in the file list, as it will still
4725- * be shown in the path bar: "/foo/[bar]/.baz"
4726- */
4727- if (child_is_hidden)
4728- g_object_set (impl, "show-hidden", TRUE, NULL);
4729-}
4730-
4731 static const GtkFileInfo *
4732 get_list_file_info (GtkFileChooserDefault *impl,
4733 GtkTreeIter *iter)
4734@@ -6257,33 +3452,31 @@
4735
4736 time_mtime = gtk_file_info_get_modification_time (info);
4737
4738- if (time_mtime == 0)
4739- strcpy (buf, _("Unknown"));
4740- else
4741- {
4742- g_date_set_time (&mtime, (GTime) time_mtime);
4743+#ifdef GTK26
4744+ g_date_set_time (&mtime, (GTime) time_mtime);
4745+#else
4746+ g_date_set_time_t (&mtime, time_mtime);
4747+#endif
4748+ time_now = (GTime ) time (NULL);
4749+ g_date_set_time (&now, (GTime) time_now);
4750
4751- time_now = (GTime ) time (NULL);
4752- g_date_set_time (&now, (GTime) time_now);
4753+ days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
4754
4755- days_diff = g_date_get_julian (&now) - g_date_get_julian (&mtime);
4756+ if (days_diff == 0)
4757+ strcpy (buf, _("Today"));
4758+ else if (days_diff == 1)
4759+ strcpy (buf, _("Yesterday"));
4760+ else
4761+ {
4762+ char *format;
4763
4764- if (days_diff == 0)
4765- strcpy (buf, _("Today"));
4766- else if (days_diff == 1)
4767- strcpy (buf, _("Yesterday"));
4768+ if (days_diff > 1 && days_diff < 7)
4769+ format = "%A"; /* Days from last week */
4770 else
4771- {
4772- char *format;
4773+ format = "%x"; /* Any other date */
4774
4775- if (days_diff > 1 && days_diff < 7)
4776- format = "%A"; /* Days from last week */
4777- else
4778- format = "%x"; /* Any other date */
4779-
4780- if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
4781- strcpy (buf, _("Unknown"));
4782- }
4783+ if (g_date_strftime (buf, sizeof (buf), format, &mtime) == 0)
4784+ strcpy (buf, _("Unknown"));
4785 }
4786
4787 if (impl->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ||
4788@@ -6376,8 +3569,11 @@
4789 */
4790
4791 error = NULL;
4792+#ifdef GTK26
4793 folder = gtk_file_system_get_folder (impl->file_system, folder_path, GTK_FILE_INFO_IS_FOLDER, &error);
4794-
4795+#else
4796+ folder = gtk_file_system_get_folder (impl->file_system, folder_path, GTK_FILE_INFO_IS_FOLDER, NULL, NULL);
4797+#endif
4798 if (!folder)
4799 {
4800 error_getting_info_dialog (impl, folder_path, error);
4801@@ -6487,8 +3683,8 @@
4802 accept_stock, GTK_RESPONSE_ACCEPT,
4803 NULL);
4804 gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1);
4805- gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
4806- gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
4807+ gtk_container_set_border_width (GTK_CONTAINER (dialog), DEFAULT_SPACING);
4808+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), DEFAULT_SPACING);
4809 gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
4810
4811 gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
4812@@ -6496,17 +3692,16 @@
4813 GTK_RESPONSE_CANCEL,
4814 -1);
4815
4816- hbox = gtk_hbox_new (FALSE, 12);
4817+ hbox = gtk_hbox_new (FALSE, DEFAULT_SPACING);
4818 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
4819 gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
4820
4821- label = gtk_label_new_with_mnemonic (_("_Location:"));
4822+ label = gtk_label_new (_("Location:"));
4823 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
4824
4825 entry = location_entry_create (impl, path);
4826
4827 gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
4828- gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
4829
4830 /* Run */
4831
4832@@ -6555,115 +3750,68 @@
4833 static void
4834 up_folder_handler (GtkFileChooserDefault *impl)
4835 {
4836+ GtkFilePath * parent;
4837 pending_select_paths_add (impl, impl->current_folder);
4838- _gtk_path_bar_up (GTK_PATH_BAR (impl->browse_path_bar));
4839+
4840+ if (gtk_file_system_get_parent (impl->file_system, impl->current_folder,
4841+ &parent, NULL) && parent)
4842+ {
4843+ impl->path_history = g_slist_prepend (impl->path_history,
4844+ gtk_file_path_copy (impl->current_folder));
4845+
4846+ change_folder_and_display_error (impl, parent);
4847+ gtk_file_path_free (parent);
4848+ }
4849 }
4850
4851 /* Handler for the "down-folder" keybinding signal */
4852 static void
4853 down_folder_handler (GtkFileChooserDefault *impl)
4854 {
4855- _gtk_path_bar_down (GTK_PATH_BAR (impl->browse_path_bar));
4856+ if (impl->path_history)
4857+ {
4858+ const GtkFilePath * path = impl->path_history->data;
4859+
4860+ change_folder_and_display_error (impl, path);
4861+ impl->path_history = g_slist_remove (impl->path_history, path);
4862+ gtk_file_path_free (path);
4863+ }
4864 }
4865
4866 /* Handler for the "home-folder" keybinding signal */
4867 static void
4868 home_folder_handler (GtkFileChooserDefault *impl)
4869 {
4870- int pos;
4871- GtkTreeIter iter;
4872-
4873- if (!impl->has_home)
4874- return; /* Should we put up an error dialog? */
4875-
4876- pos = shortcuts_get_index (impl, SHORTCUTS_HOME);
4877- if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (impl->shortcuts_model), &iter, NULL, pos))
4878- g_assert_not_reached ();
4879-
4880- shortcuts_activate_iter (impl, &iter);
4881-}
4882-
4883-
4884-
4885-/* Drag and drop interfaces */
4886-
4887-static void
4888-_shortcuts_model_filter_class_init (ShortcutsModelFilterClass *class)
4889-{
4890 }
4891
4892-static void
4893-_shortcuts_model_filter_init (ShortcutsModelFilter *model)
4894+static GtkFilePath *
4895+gtk_file_chooser_default_get_preview_path (GtkFileChooser *chooser)
4896 {
4897- model->impl = NULL;
4898+ return NULL;
4899 }
4900
4901-/* GtkTreeDragSource::row_draggable implementation for the shortcuts filter model */
4902 static gboolean
4903-shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source,
4904- GtkTreePath *path)
4905+gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser *chooser,
4906+ const GtkFilePath *path,
4907+ GError **error)
4908 {
4909- ShortcutsModelFilter *model;
4910- int pos;
4911- int bookmarks_pos;
4912-
4913- model = SHORTCUTS_MODEL_FILTER (drag_source);
4914-
4915- pos = *gtk_tree_path_get_indices (path);
4916- bookmarks_pos = shortcuts_get_index (model->impl, SHORTCUTS_BOOKMARKS);
4917-
4918- return (pos >= bookmarks_pos && pos < bookmarks_pos + model->impl->num_bookmarks);
4919+ return FALSE;
4920 }
4921
4922-/* GtkTreeDragSource::drag_data_get implementation for the shortcuts filter model */
4923 static gboolean
4924-shortcuts_model_filter_drag_data_get (GtkTreeDragSource *drag_source,
4925- GtkTreePath *path,
4926- GtkSelectionData *selection_data)
4927-{
4928- ShortcutsModelFilter *model;
4929-
4930- model = SHORTCUTS_MODEL_FILTER (drag_source);
4931-
4932- /* FIXME */
4933-
4934- return FALSE;
4935-}
4936-
4937-/* Fill the GtkTreeDragSourceIface vtable */
4938-static void
4939-shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface)
4940+gtk_file_chooser_default_remove_shortcut_folder (GtkFileChooser *chooser,
4941+ const GtkFilePath *path,
4942+ GError **error)
4943 {
4944- iface->row_draggable = shortcuts_model_filter_row_draggable;
4945- iface->drag_data_get = shortcuts_model_filter_drag_data_get;
4946+ return TRUE;
4947 }
4948
4949-#if 0
4950-/* Fill the GtkTreeDragDestIface vtable */
4951-static void
4952-shortcuts_model_filter_drag_dest_iface_init (GtkTreeDragDestIface *iface)
4953+static GSList *
4954+gtk_file_chooser_default_list_shortcut_folders (GtkFileChooser *chooser)
4955 {
4956- iface->drag_data_received = shortcuts_model_filter_drag_data_received;
4957- iface->row_drop_possible = shortcuts_model_filter_row_drop_possible;
4958+ return NULL;
4959 }
4960-#endif
4961
4962-static GtkTreeModel *
4963-shortcuts_model_filter_new (GtkFileChooserDefault *impl,
4964- GtkTreeModel *child_model,
4965- GtkTreePath *root)
4966-{
4967- ShortcutsModelFilter *model;
4968-
4969- model = g_object_new (SHORTCUTS_MODEL_FILTER_TYPE,
4970- "child_model", child_model,
4971- "virtual_root", root,
4972- NULL);
4973-
4974- model->impl = impl;
4975-
4976- return GTK_TREE_MODEL (model);
4977-}
4978
4979 #define __GTK_FILE_CHOOSER_DEFAULT_C__
4980 #include "gtkaliasdef.c"
diff --git a/meta/packages/gtk+/gtk+-2.6.10/filechooser-respect-style.patch b/meta/packages/gtk+/gtk+-2.6.10/filechooser-respect-style.patch
new file mode 100644
index 0000000000..76c66a7d2a
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.10/filechooser-respect-style.patch
@@ -0,0 +1,77 @@
1--- gtk+-2.6.8/gtk/gtkfilechooserdialog.c.orig 2007-02-09 12:18:25.000000000 +0000
2+++ gtk+-2.6.8/gtk/gtkfilechooserdialog.c 2007-02-09 12:18:25.000000000 +0000
3@@ -62,8 +62,6 @@
4
5 static void gtk_file_chooser_dialog_map (GtkWidget *widget);
6 static void gtk_file_chooser_dialog_unmap (GtkWidget *widget);
7-static void gtk_file_chooser_dialog_style_set (GtkWidget *widget,
8- GtkStyle *previous_style);
9
10 static void response_cb (GtkDialog *dialog,
11 gint response_id);
12@@ -122,7 +120,6 @@
13
14 widget_class->map = gtk_file_chooser_dialog_map;
15 widget_class->unmap = gtk_file_chooser_dialog_unmap;
16- widget_class->style_set = gtk_file_chooser_dialog_style_set;
17
18 _gtk_file_chooser_install_properties (gobject_class);
19
20@@ -135,13 +132,19 @@
21 GtkFileChooserDialogPrivate *priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog,
22 GTK_TYPE_FILE_CHOOSER_DIALOG,
23 GtkFileChooserDialogPrivate);
24+
25+ GtkDialog *fc_dialog = GTK_DIALOG (dialog);
26+
27 dialog->priv = priv;
28 dialog->priv->default_width = -1;
29 dialog->priv->default_height = -1;
30 dialog->priv->resize_horizontally = TRUE;
31 dialog->priv->resize_vertically = TRUE;
32
33- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
34+ gtk_dialog_set_has_separator (fc_dialog, FALSE);
35+ gtk_container_set_border_width (GTK_CONTAINER (fc_dialog), 5);
36+ gtk_box_set_spacing (GTK_BOX (fc_dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
37+ gtk_container_set_border_width (GTK_CONTAINER (fc_dialog->action_area), 5);
38
39 /* We do a signal connection here rather than overriding the method in
40 * class_init because GtkDialog::response is a RUN_LAST signal. We want *our*
41@@ -394,6 +397,7 @@
42 g_signal_connect (priv->widget, "default-size-changed",
43 G_CALLBACK (file_chooser_widget_default_size_changed), object);
44
45+ gtk_container_set_border_width (GTK_CONTAINER (priv->widget), 5);
46 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), priv->widget, TRUE, TRUE, 0);
47
48 gtk_widget_show (priv->widget);
49@@ -522,28 +526,6 @@
50 gtk_widget_unmap (priv->widget);
51 }
52
53-static void
54-gtk_file_chooser_dialog_style_set (GtkWidget *widget,
55- GtkStyle *previous_style)
56-{
57- GtkDialog *dialog;
58-
59- if (GTK_WIDGET_CLASS (parent_class)->style_set)
60- GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
61-
62- dialog = GTK_DIALOG (widget);
63-
64- /* Override the style properties with HIG-compliant spacings. Ugh.
65- * http://developer.gnome.org/projects/gup/hig/1.0/layout.html#layout-dialogs
66- * http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-spacing
67- */
68-
69- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 12);
70- gtk_box_set_spacing (GTK_BOX (dialog->vbox), 24);
71-
72- gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
73- gtk_box_set_spacing (GTK_BOX (dialog->action_area), 6);
74-}
75
76 /* GtkDialog::response handler */
77 static void
diff --git a/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch b/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch
new file mode 100644
index 0000000000..4386d83ee9
--- /dev/null
+++ b/meta/packages/gtk+/gtk+-2.6.10/filesystem-volumes.patch
@@ -0,0 +1,182 @@
1--- gtk+-2.6.8/gtk/gtkfilesystemunix.c.orig 2007-02-08 12:01:19.000000000 +0000
2+++ gtk+-2.6.8/gtk/gtkfilesystemunix.c 2007-02-08 12:01:19.000000000 +0000
3@@ -33,6 +33,7 @@
4 #include <errno.h>
5 #include <string.h>
6 #include <sys/stat.h>
7+#include <sys/statvfs.h>
8 #include <sys/types.h>
9 #include <pwd.h>
10 #ifdef HAVE_UNISTD_H
11@@ -358,7 +359,49 @@
12 static GSList *
13 gtk_file_system_unix_list_volumes (GtkFileSystem *file_system)
14 {
15- return g_slist_append (NULL, get_root_volume ());
16+ struct statvfs stv;
17+ struct stat st;
18+ GSList * l = g_slist_append (NULL, get_root_volume ());
19+
20+ if (!statvfs ("/.", &stv))
21+ {
22+ fsblkcnt_t root_blocks = stv.f_blocks;
23+ fsfilcnt_t root_files = stv.f_files;
24+
25+ GDir * dir;
26+ if ((dir = g_dir_open ("/media", 0, NULL)) != NULL)
27+ {
28+ const gchar * name;
29+ while ((name = g_dir_read_name (dir)) != NULL)
30+ {
31+ gchar * abs_name = g_strconcat ("/media/", name, NULL);
32+
33+ if (!stat (abs_name, &st) && S_ISDIR (st.st_mode))
34+ {
35+ gchar * dot = g_strconcat (abs_name, "/.", NULL);
36+ if (!statvfs (dot, &stv) &&
37+ (stv.f_blocks != root_blocks ||
38+ stv.f_files != root_files))
39+ {
40+ GtkFilePath * path =
41+ gtk_file_system_filename_to_path (file_system,
42+ abs_name);
43+
44+ if (path)
45+ l = g_slist_append (l, path);
46+ }
47+
48+ g_free (dot);
49+ }
50+
51+ g_free (abs_name);
52+ }
53+
54+ g_dir_close (dir);
55+ }
56+ }
57+
58+ return l;
59 }
60
61 static GtkFileSystemVolume *
62@@ -375,10 +418,15 @@
63
64 len = strlen (filename);
65
66- if (len > 1 && filename[len - 1] == '/')
67- return g_strndup (filename, len - 1);
68- else
69- return g_memdup (filename, len + 1);
70+ if (len > 1)
71+ {
72+ gchar *c = g_utf8_prev_char (filename + len);
73+
74+ if (c && *c == '/')
75+ return g_strndup (filename, len - 1);
76+ }
77+
78+ return g_memdup (filename, len + 1);
79 }
80
81 static GtkFileFolder *
82@@ -590,7 +638,7 @@
83 gtk_file_system_unix_volume_get_base_path (GtkFileSystem *file_system,
84 GtkFileSystemVolume *volume)
85 {
86- return gtk_file_path_new_dup ("/");
87+ return gtk_file_path_copy ((GtkFilePath*)volume);
88 }
89
90 static gboolean
91@@ -616,7 +664,32 @@
92 gtk_file_system_unix_volume_get_display_name (GtkFileSystem *file_system,
93 GtkFileSystemVolume *volume)
94 {
95- return g_strdup (_("Filesystem")); /* Same as Nautilus */
96+ gchar * slash;
97+ gchar * path;
98+ gchar * c;
99+
100+ g_return_val_if_fail (file_system && volume, NULL);
101+
102+ path = gtk_file_system_path_to_filename (file_system, (GtkFilePath*) volume);
103+
104+ g_return_val_if_fail (path && *path, NULL);
105+
106+ if (path[0] == '/' && !path[1])
107+ return g_strdup (_("Filesystem")); /* Same as Nautilus */
108+
109+ /* Now the media volumes */
110+ /* strip trailing / if any */
111+ c = g_utf8_prev_char (path + strlen(path));
112+
113+ if (*c == '/')
114+ *c = 0;
115+
116+ slash = g_utf8_strrchr (path, -1, '/');
117+
118+ if (!slash)
119+ return g_strdup (path);
120+
121+ return g_strdup (slash + 1);
122 }
123
124 static IconType
125@@ -787,11 +860,54 @@
126 GError **error)
127 {
128 GdkPixbuf *pixbuf;
129+ gchar * slash;
130+ gchar * path;
131+ gchar * c;
132+ const gchar * id = NULL;
133+
134+ g_return_val_if_fail (file_system && volume, NULL);
135+
136+ path = gtk_file_system_path_to_filename (file_system, (GtkFilePath*) volume);
137
138- pixbuf = get_cached_icon (widget, "gnome-fs-blockdev", pixel_size);
139- if (pixbuf)
140- return pixbuf;
141+ g_return_val_if_fail (path && *path, NULL);
142+
143+ if (path[0] == '/' && !path[1])
144+ id = "gnome-fs-blockdev";
145+ else
146+ {
147+ /* Now the media volumes */
148+ /* strip trailing / if any */
149+ c = g_utf8_prev_char (path + strlen(path));
150+
151+ if (*c == '/')
152+ *c = 0;
153+
154+ slash = g_utf8_strrchr (path, -1, '/');
155
156+ if (slash)
157+ {
158+ slash++;
159+
160+ if (!strcmp (slash, "card"))
161+ id = "gnome-dev-media-sdmmc";
162+ else if (!strcmp (slash, "cf"))
163+ id = "gnome-dev-media-cf";
164+ else if (!strncmp (slash, "mmc", 3))
165+ id = "gnome-dev-media-sdmmc";
166+ else if (!strcmp (slash, "usbhdd"))
167+ id = "gnome-dev-removable-usb";
168+ else
169+ id = "gnome-dev-removable";
170+ }
171+ }
172+
173+ if (id)
174+ {
175+ pixbuf = get_cached_icon (widget, id, pixel_size);
176+ if (pixbuf)
177+ return pixbuf;
178+ }
179+
180 pixbuf = get_fallback_icon (widget, ICON_BLOCK_DEVICE, error);
181 g_assert (pixbuf != NULL);
182
diff --git a/meta/packages/gtk+/gtk+-2.6.10/help.patch b/meta/packages/gtk+/gtk+-2.6.10/help.patch
deleted file mode 100644
index 268b3dd9e2..0000000000
--- a/meta/packages/gtk+/gtk+-2.6.10/help.patch
+++ /dev/null
@@ -1,158 +0,0 @@
1diff -NaurBb gtk+-2.6.10.old/gtk/Makefile.am gtk+-2.6.10/gtk/Makefile.am
2--- gtk+-2.6.10.old/gtk/Makefile.am 2005-08-18 16:10:56.000000000 +0200
3+++ gtk+-2.6.10/gtk/Makefile.am 2005-12-29 01:23:52.000000000 +0100
4@@ -520,6 +520,7 @@
5 gtkwidget.c \
6 gtkwindow-decorate.c \
7 gtkwindow.c \
8+ gpe-what.c \
9 xembed.h
10
11 if OS_UNIX
12diff -NaurBb gtk+-2.6.10.old/gtk/gpe-what.c gtk+-2.6.10/gtk/gpe-what.c
13--- gtk+-2.6.10.old/gtk/gpe-what.c 1970-01-01 01:00:00.000000000 +0100
14+++ gtk+-2.6.10/gtk/gpe-what.c 2005-12-29 00:59:26.000000000 +0100
15@@ -0,0 +1,130 @@
16+/*
17+ * Copyright (C) 2002, 2003 Philip Blundell <philb@gnu.org>
18+ *
19+ * This library is free software; you can redistribute it and/or
20+ * modify it under the terms of the GNU Lesser General Public
21+ * License as published by the Free Software Foundation; either
22+ * version 2 of the License, or (at your option) any later version.
23+ *
24+ * This library is distributed in the hope that it will be useful,
25+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
26+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27+ * Lesser General Public License for more details.
28+ *
29+ * You should have received a copy of the GNU Lesser General Public
30+ * License along with this library; if not, write to the
31+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
32+ * Boston, MA 02111-1307, USA.
33+ */
34+
35+#include <stdio.h>
36+#include <string.h>
37+#include <stdlib.h>
38+
39+#include <X11/Xlib.h>
40+#include <X11/Xatom.h>
41+
42+#ifdef GDK_WINDOWING_X11
43+#error X11 required
44+#endif
45+
46+#include "gtkwidget.h"
47+#include "gtktooltips.h"
48+#include "x11/gdkx.h"
49+#include "config.h"
50+
51+#include <libintl.h>
52+
53+#define _(x) dgettext(GETTEXT_PACKAGE, x)
54+
55+static GdkAtom help_atom;
56+static gboolean gpe_what_initialised;
57+
58+static GSList *widgets;
59+
60+static void
61+send_text (Display *dpy, Window w, char *text)
62+{
63+ Atom help_xatom = gdk_x11_atom_to_xatom (help_atom);
64+
65+ gdk_error_trap_push ();
66+
67+ XChangeProperty (dpy, w, help_xatom, XA_STRING, 8, PropModeReplace, text, strlen (text));
68+
69+ XFlush (dpy);
70+
71+ gdk_error_trap_pop ();
72+}
73+
74+static GdkFilterReturn
75+filter_func (GdkXEvent *xev, GdkEvent *ev, gpointer p)
76+{
77+ XClientMessageEvent *xc = (XClientMessageEvent *)xev;
78+ GSList *list;
79+ Window sender = xc->data.l[0];
80+
81+ for (list = widgets; list; list = list->next)
82+ {
83+ GtkWidget *widget = GTK_WIDGET (list->data);
84+ int x = xc->data.l[1], y = xc->data.l[2];
85+ int ax, ay;
86+
87+ if (!GTK_WIDGET_DRAWABLE (widget)) continue;
88+
89+ if (GTK_WIDGET_NO_WINDOW (widget))
90+ {
91+ ax = widget->allocation.x;
92+ ay = widget->allocation.y;
93+ }
94+ else
95+ {
96+ ax = 0;
97+ ay = 0;
98+ }
99+
100+ if (widget->window == ev->any.window
101+ && x >= ax && x < ax + widget->allocation.width
102+ && y >= ay && y < ay + widget->allocation.height)
103+ {
104+ GtkTooltipsData *data = gtk_tooltips_data_get (widget);
105+ if (data)
106+ {
107+ send_text (GDK_WINDOW_XDISPLAY (widget->window), sender,
108+ data->tip_private ? data->tip_private : data->tip_text);
109+ return GDK_FILTER_CONTINUE;
110+ }
111+ }
112+ }
113+
114+ send_text (GDK_WINDOW_XDISPLAY (ev->any.window), sender, _("No help available."));
115+
116+ return GDK_FILTER_CONTINUE;
117+}
118+
119+void
120+gpe_what_mark_widget (GtkWidget *widget)
121+{
122+ if (!gpe_what_initialised)
123+ {
124+ help_atom = gdk_atom_intern ("_GPE_INTERACTIVE_HELP", FALSE);
125+
126+ gdk_add_client_message_filter (help_atom, filter_func, NULL);
127+
128+ gpe_what_initialised = TRUE;
129+ }
130+
131+ if (widget->window)
132+ {
133+ widgets = g_slist_prepend (widgets, widget);
134+
135+ gdk_property_change (widget->window,
136+ help_atom,
137+ help_atom,
138+ 8,
139+ GDK_PROP_MODE_REPLACE,
140+ NULL,
141+ 0);
142+ }
143+ else
144+ abort ();
145+}
146diff -NaurBb gtk+-2.6.10.old/gtk/gtkwidget.c gtk+-2.6.10/gtk/gtkwidget.c
147--- gtk+-2.6.10.old/gtk/gtkwidget.c 2005-08-18 16:10:59.000000000 +0200
148+++ gtk+-2.6.10/gtk/gtkwidget.c 2005-12-29 00:59:26.000000000 +0100
149@@ -2285,6 +2285,9 @@
150
151 g_signal_emit (widget, widget_signals[REALIZE], 0);
152
153+ extern void gpe_what_mark_widget (GtkWidget *widget);
154+ gpe_what_mark_widget (widget);
155+
156 if (GTK_WIDGET_HAS_SHAPE_MASK (widget))
157 {
158 shape_info = g_object_get_qdata (G_OBJECT (widget), quark_shape_info);
diff --git a/meta/packages/gtk+/gtk+-2.6.10/menu-styling.patch b/meta/packages/gtk+/gtk+-2.6.10/menu-styling.patch
deleted file mode 100644
index 8f792df190..0000000000
--- a/meta/packages/gtk+/gtk+-2.6.10/menu-styling.patch
+++ /dev/null
@@ -1,22 +0,0 @@
1#
2# This patch improves menu styling (based on version in 2.7.0
3# which features a background pixmap for the menu). ---Mickey.
4#
5--- gtk+-2.6.10/gtk/gtkmenu.c 2005-08-18 16:10:58.000000000 +0200
6+++ gtk+-2.7.0/gtk/gtkmenu.c 2005-04-07 21:56:57.000000000 +0200
7@@ -2490,6 +2495,15 @@
8 arrow_size, arrow_size);
9 }
10 }
11+ else if (event->window == menu->bin_window)
12+ {
13+ gtk_paint_box (widget->style,
14+ menu->bin_window,
15+ GTK_STATE_NORMAL,
16+ GTK_SHADOW_OUT,
17+ NULL, widget, "menu",
18+ -border_x, -border_y, width, height);
19+ }
20 }
21
22 static gboolean
diff --git a/meta/packages/gtk+/gtk+-2.6.10/single-click.patch b/meta/packages/gtk+/gtk+-2.6.10/single-click.patch
deleted file mode 100644
index 3bb208d4d6..0000000000
--- a/meta/packages/gtk+/gtk+-2.6.10/single-click.patch
+++ /dev/null
@@ -1,54 +0,0 @@
1diff -urNd ../gtk+-2.6.3-r0.old/gtk+-2.6.3/gtk/gtkcalendar.c gtk+-2.6.3/gtk/gtkcalendar.c
2--- ../gtk+-2.6.3-r0.old/gtk+-2.6.3/gtk/gtkcalendar.c 2005-04-06 16:57:04 +01:00
3+++ gtk+-2.6.3/gtk/gtkcalendar.c 2005-04-06 20:05:18 +01:00
4@@ -1023,9 +1023,11 @@
5 }
6
7 gtk_calendar_select_and_focus_day (calendar, day);
8- }
9+
10+ // This change causes the calendar to disappear after choosing a day
11+/* }
12 else if (event->type == GDK_2BUTTON_PRESS)
13- {
14+ {*/
15 private_data->in_drag = 0;
16 if (day_month == MONTH_CURRENT)
17 g_signal_emit (calendar,
18diff -urNd ../gtk+-2.6.3-r0.old/gtk+-2.6.3/gtk/gtkfilesel.c gtk+-2.6.3/gtk/gtkfilesel.c
19--- ../gtk+-2.6.3-r0.old/gtk+-2.6.3/gtk/gtkfilesel.c 2005-04-06 16:57:07 +01:00
20+++ gtk+-2.6.3/gtk/gtkfilesel.c 2005-04-07 13:40:32 +01:00
21@@ -2468,6 +2468,33 @@
22 if (fs->last_selected != NULL)
23 g_free (fs->last_selected);
24
25+ // Single-click directory entry
26+ if (new_names->len == 1)
27+ {
28+ GtkTreeView *tree_view;
29+ GtkTreeModel *model;
30+ GtkTreePath *path;
31+ GtkTreeIter iter;
32+ gboolean is_file;
33+
34+ tree_view = gtk_tree_selection_get_tree_view (selection);
35+
36+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
37+ {
38+ path = gtk_tree_model_get_path (model, &iter);
39+ gtk_tree_model_get (model, &iter, ISFILE_COLUMN, &is_file, -1);
40+
41+ if (!is_file)
42+ {
43+ gtk_file_selection_dir_activate (tree_view, path,
44+ gtk_tree_view_get_column (tree_view, DIR_COLUMN),
45+ user_data);
46+ }
47+
48+ gtk_tree_path_free (path);
49+ }
50+ }
51+
52 fs->last_selected = g_strdup (g_ptr_array_index (new_names, index));
53 filename = get_real_filename (fs->last_selected, FALSE);
54
diff --git a/meta/packages/gtk+/gtk+-2.6.10/small-gtkfilesel.patch b/meta/packages/gtk+/gtk+-2.6.10/small-gtkfilesel.patch
deleted file mode 100644
index 20bf4cf366..0000000000
--- a/meta/packages/gtk+/gtk+-2.6.10/small-gtkfilesel.patch
+++ /dev/null
@@ -1,267 +0,0 @@
1diff -urNd ../gtk+-2.4.4-r5/gtk+-2.4.4/gtk/gtkfilesel.c gtk+-2.4.4/gtk/gtkfilesel.c
2--- ../gtk+-2.4.4-r5/gtk+-2.4.4/gtk/gtkfilesel.c 2004-07-10 05:02:10.000000000 +0100
3+++ gtk+-2.4.4/gtk/gtkfilesel.c 2004-09-13 13:40:09.000000000 +0100
4@@ -68,6 +68,7 @@
5 #include "gtkprivate.h"
6 #include "gtkscrolledwindow.h"
7 #include "gtkstock.h"
8+#include "gtksignal.h"
9 #include "gtktreeselection.h"
10 #include "gtktreeview.h"
11 #include "gtkvbox.h"
12@@ -77,6 +78,7 @@
13 #include "gtkmessagedialog.h"
14 #include "gtkdnd.h"
15 #include "gtkeventbox.h"
16+#include "gtkimage.h"
17
18 #undef GTK_DISABLE_DEPRECATED
19 #include "gtkoptionmenu.h"
20@@ -245,7 +247,8 @@
21 };
22
23 enum {
24- DIR_COLUMN
25+ DIR_COLUMN,
26+ ISFILE_COLUMN
27 };
28
29 enum {
30@@ -400,6 +403,12 @@
31 GtkTreePath *path,
32 GtkTreeViewColumn *column,
33 gpointer user_data);
34+
35+static void gtk_file_selection_activate (GtkTreeView *tree_view,
36+ GtkTreePath *path,
37+ GtkTreeViewColumn *column,
38+ gpointer user_data);
39+
40 static void gtk_file_selection_file_changed (GtkTreeSelection *selection,
41 gpointer user_data);
42 static void gtk_file_selection_dir_activate (GtkTreeView *tree_view,
43@@ -419,6 +428,7 @@
44 static void gtk_file_selection_create_dir (GtkWidget *widget, gpointer data);
45 static void gtk_file_selection_delete_file (GtkWidget *widget, gpointer data);
46 static void gtk_file_selection_rename_file (GtkWidget *widget, gpointer data);
47+static void gtk_file_selection_style_set (GtkWidget *widget, GtkStyle *prev_style);
48
49 static void free_selected_names (GPtrArray *names);
50
51@@ -578,6 +588,23 @@
52 G_PARAM_WRITABLE));
53 object_class->destroy = gtk_file_selection_destroy;
54 widget_class->map = gtk_file_selection_map;
55+ widget_class->style_set = gtk_file_selection_style_set;
56+
57+ gtk_widget_class_install_style_property (widget_class,
58+ g_param_spec_boolean ("show_fileops_default",
59+ _("Show fileop buttons by default"),
60+ _("Whether file operation buttons are shown by default"),
61+ TRUE,
62+ G_PARAM_READABLE));
63+
64+ gtk_widget_class_install_style_property (widget_class,
65+ g_param_spec_int ("border_width",
66+ _("Border width"),
67+ _("Width of border around the main dialog area"),
68+ 0,
69+ G_MAXINT,
70+ 10,
71+ G_PARAM_READABLE));
72 }
73
74 static void gtk_file_selection_set_property (GObject *object,
75@@ -649,7 +676,29 @@
76 gtk_widget_grab_default (widget);
77 return FALSE;
78 }
79-
80+
81+static void
82+gtk_file_selection_style_set (GtkWidget *filesel,
83+ GtkStyle *prev_style)
84+{
85+ gboolean show_fileops;
86+ gint border_width;
87+
88+ gtk_widget_style_get (filesel,
89+ "show_fileops_default",
90+ &show_fileops,
91+ "border_width",
92+ &border_width,
93+ NULL);
94+
95+ gtk_container_set_border_width (GTK_CONTAINER (filesel), border_width);
96+
97+ if (show_fileops)
98+ gtk_file_selection_show_fileop_buttons (GTK_FILE_SELECTION (filesel));
99+ else
100+ gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (filesel));
101+}
102+
103 static void
104 gtk_file_selection_init (GtkFileSelection *filesel)
105 {
106@@ -674,17 +723,15 @@
107
108 /* The dialog-sized vertical box */
109 filesel->main_vbox = dialog->vbox;
110- gtk_container_set_border_width (GTK_CONTAINER (filesel), 10);
111
112 /* The horizontal box containing create, rename etc. buttons */
113 filesel->button_area = gtk_hbutton_box_new ();
114 gtk_button_box_set_layout (GTK_BUTTON_BOX (filesel->button_area), GTK_BUTTONBOX_START);
115- gtk_box_set_spacing (GTK_BOX (filesel->button_area), 0);
116 gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->button_area,
117 FALSE, FALSE, 0);
118 gtk_widget_show (filesel->button_area);
119
120- gtk_file_selection_show_fileop_buttons (filesel);
121+ gtk_file_selection_style_set (GTK_WIDGET (filesel), NULL);
122
123 /* hbox for pulldown menu */
124 pulldown_hbox = gtk_hbox_new (TRUE, 5);
125@@ -723,25 +770,32 @@
126
127 /* The directories list */
128
129- model = gtk_list_store_new (1, G_TYPE_STRING);
130+ model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN); /* MA */
131 filesel->dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
132 g_object_unref (model);
133
134- column = gtk_tree_view_column_new_with_attributes (_("Folders"),
135+ column = gtk_tree_view_column_new_with_attributes (/*_("Folders")*/ NULL,
136 gtk_cell_renderer_text_new (),
137 "text", DIR_COLUMN,
138 NULL);
139 label = gtk_label_new_with_mnemonic (_("Fol_ders"));
140 gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->dir_list);
141 gtk_widget_show (label);
142- gtk_tree_view_column_set_widget (column, label);
143+
144+ /* gtk_tree_view_column_set_widget (column, label); */
145+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (filesel->dir_list), FALSE);
146+
147 gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
148 gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->dir_list), column);
149
150 gtk_widget_set_size_request (filesel->dir_list,
151 DIR_LIST_WIDTH, DIR_LIST_HEIGHT);
152 g_signal_connect (filesel->dir_list, "row_activated",
153- G_CALLBACK (gtk_file_selection_dir_activate), filesel);
154+ G_CALLBACK (gtk_file_selection_activate), filesel);
155+
156+ g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->dir_list)), "changed",
157+ G_CALLBACK (gtk_file_selection_file_changed), filesel);
158+
159
160 /* gtk_clist_column_titles_passive (GTK_CLIST (filesel->dir_list)); */
161
162@@ -758,41 +812,6 @@
163 gtk_widget_show (filesel->dir_list);
164 gtk_widget_show (scrolled_win);
165
166- /* The files list */
167- model = gtk_list_store_new (1, G_TYPE_STRING);
168- filesel->file_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
169- g_object_unref (model);
170-
171- column = gtk_tree_view_column_new_with_attributes (_("Files"),
172- gtk_cell_renderer_text_new (),
173- "text", FILE_COLUMN,
174- NULL);
175- label = gtk_label_new_with_mnemonic (_("_Files"));
176- gtk_label_set_mnemonic_widget (GTK_LABEL (label), filesel->file_list);
177- gtk_widget_show (label);
178- gtk_tree_view_column_set_widget (column, label);
179- gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
180- gtk_tree_view_append_column (GTK_TREE_VIEW (filesel->file_list), column);
181-
182- gtk_widget_set_size_request (filesel->file_list,
183- FILE_LIST_WIDTH, FILE_LIST_HEIGHT);
184- g_signal_connect (filesel->file_list, "row_activated",
185- G_CALLBACK (gtk_file_selection_file_activate), filesel);
186- g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (filesel->file_list)), "changed",
187- G_CALLBACK (gtk_file_selection_file_changed), filesel);
188-
189- /* gtk_clist_column_titles_passive (GTK_CLIST (filesel->file_list)); */
190-
191- scrolled_win = gtk_scrolled_window_new (NULL, NULL);
192- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win), GTK_SHADOW_IN);
193- gtk_container_add (GTK_CONTAINER (scrolled_win), filesel->file_list);
194- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
195- GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
196- gtk_container_set_border_width (GTK_CONTAINER (scrolled_win), 0);
197- gtk_container_add (GTK_CONTAINER (list_container), scrolled_win);
198- gtk_widget_show (filesel->file_list);
199- gtk_widget_show (scrolled_win);
200-
201 /* action area for packing buttons into. */
202 filesel->action_area = gtk_hbox_new (TRUE, 0);
203 gtk_box_pack_start (GTK_BOX (filesel->main_vbox), filesel->action_area,
204@@ -2008,6 +2027,23 @@
205 }
206
207 static void
208+gtk_file_selection_activate (GtkTreeView *tree_view,
209+ GtkTreePath *path,
210+ GtkTreeViewColumn *column,
211+ gpointer user_data)
212+{
213+ GtkTreeModel *model = gtk_tree_view_get_model (tree_view);
214+ GtkTreeIter iter;
215+ gboolean is_file;
216+
217+ gtk_tree_model_get_iter (model, &iter, path);
218+ gtk_tree_model_get (model, &iter, ISFILE_COLUMN, &is_file, -1);
219+
220+ if (! is_file)
221+ gtk_file_selection_dir_activate (tree_view, path, column, user_data);
222+}
223+
224+static void
225 gtk_file_selection_file_activate (GtkTreeView *tree_view,
226 GtkTreePath *path,
227 GtkTreeViewColumn *column,
228@@ -2103,7 +2139,6 @@
229 PossibleCompletion* poss;
230 GtkTreeIter iter;
231 GtkListStore *dir_model;
232- GtkListStore *file_model;
233 gchar* filename;
234 gchar* rem_path = rel_path;
235 gchar* sel_text;
236@@ -2125,10 +2160,8 @@
237 g_assert (cmpl_state->reference_dir);
238
239 dir_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->dir_list)));
240- file_model = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fs->file_list)));
241
242 gtk_list_store_clear (dir_model);
243- gtk_list_store_clear (file_model);
244
245 /* Set the dir list to include ./ and ../ */
246 gtk_list_store_append (dir_model, &iter);
247@@ -2150,13 +2183,17 @@
248 strcmp (filename, ".." G_DIR_SEPARATOR_S) != 0)
249 {
250 gtk_list_store_append (dir_model, &iter);
251- gtk_list_store_set (dir_model, &iter, DIR_COLUMN, filename, -1);
252+ gtk_list_store_set (dir_model, &iter,
253+ DIR_COLUMN, filename,
254+ ISFILE_COLUMN, FALSE, -1);
255 }
256 }
257 else
258 {
259- gtk_list_store_append (file_model, &iter);
260- gtk_list_store_set (file_model, &iter, DIR_COLUMN, filename, -1);
261+ gtk_list_store_append (dir_model, &iter);
262+ gtk_list_store_set (dir_model, &iter,
263+ DIR_COLUMN, filename,
264+ ISFILE_COLUMN, TRUE, -1);
265 }
266 }
267
diff --git a/meta/packages/gtk+/gtk+-2.6.10/spinbutton.patch b/meta/packages/gtk+/gtk+-2.6.10/spinbutton.patch
deleted file mode 100644
index 8ad7507af0..0000000000
--- a/meta/packages/gtk+/gtk+-2.6.10/spinbutton.patch
+++ /dev/null
@@ -1,128 +0,0 @@
1--- gtk+-2.4.3/gtk/gtkspinbutton.c.old 2004-04-22 14:49:27.000000000 +0100
2+++ gtk+-2.4.3/gtk/gtkspinbutton.c 2004-06-30 21:48:18.000000000 +0100
3@@ -733,7 +733,7 @@
4
5 spin = GTK_SPIN_BUTTON (widget);
6 arrow_size = spin_button_get_arrow_size (spin);
7- panel_width = arrow_size + 2 * widget->style->xthickness;
8+ panel_width = (2 * arrow_size) + 4 * widget->style->xthickness;
9
10 widget->allocation = *allocation;
11
12@@ -866,19 +866,16 @@
13 {
14 width = spin_button_get_arrow_size (spin_button) + 2 * widget->style->xthickness;
15
16+ y = widget->style->ythickness;
17+ height = widget->requisition.height - (2 * y);
18+
19 if (arrow_type == GTK_ARROW_UP)
20 {
21 x = 0;
22- y = 0;
23-
24- height = widget->requisition.height / 2;
25 }
26 else
27 {
28- x = 0;
29- y = widget->requisition.height / 2;
30-
31- height = (widget->requisition.height + 1) / 2;
32+ x = width;
33 }
34
35 if (spin_button_at_limit (spin_button, arrow_type))
36@@ -908,32 +905,17 @@
37 shadow_type = GTK_SHADOW_OUT;
38 }
39 }
40-
41+
42 gtk_paint_box (widget->style, spin_button->panel,
43 state_type, shadow_type,
44 NULL, widget,
45- (arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down",
46+ NULL,
47 x, y, width, height);
48
49 height = widget->requisition.height;
50
51- if (arrow_type == GTK_ARROW_DOWN)
52- {
53- y = height / 2;
54- height = height - y - 2;
55- }
56- else
57- {
58- y = 2;
59- height = height / 2 - 2;
60- }
61-
62 width -= 3;
63-
64- if (widget && gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
65- x = 2;
66- else
67- x = 1;
68+ height -= 3;
69
70 w = width / 2;
71 w -= w % 2 - 1; /* force odd */
72@@ -1108,7 +1090,7 @@
73 if (GTK_ENTRY (widget)->editable)
74 gtk_spin_button_update (spin);
75
76- if (event->y <= widget->requisition.height / 2)
77+ if (event->x <= (spin_button_get_arrow_size (spin) + widget->style->xthickness))
78 {
79 if (event->button == 1)
80 start_spinning (spin, GTK_ARROW_UP, spin->adjustment->step_increment);
81@@ -1143,44 +1125,11 @@
82
83 arrow_size = spin_button_get_arrow_size (spin);
84
85- if (event->button == spin->button)
86- {
87- int click_child = spin->click_child;
88+ gtk_spin_button_stop_spinning (spin);
89
90- gtk_spin_button_stop_spinning (spin);
91-
92- if (event->button == 3)
93- {
94- if (event->y >= 0 && event->x >= 0 &&
95- event->y <= widget->requisition.height &&
96- event->x <= arrow_size + 2 * widget->style->xthickness)
97- {
98- if (click_child == GTK_ARROW_UP &&
99- event->y <= widget->requisition.height / 2)
100- {
101- gdouble diff;
102-
103- diff = spin->adjustment->upper - spin->adjustment->value;
104- if (diff > EPSILON)
105- gtk_spin_button_real_spin (spin, diff);
106- }
107- else if (click_child == GTK_ARROW_DOWN &&
108- event->y > widget->requisition.height / 2)
109- {
110- gdouble diff;
111-
112- diff = spin->adjustment->value - spin->adjustment->lower;
113- if (diff > EPSILON)
114- gtk_spin_button_real_spin (spin, -diff);
115- }
116- }
117- }
118- spin_button_redraw (spin);
119+ spin_button_redraw (spin);
120
121- return TRUE;
122- }
123- else
124- return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
125+ return TRUE;
126 }
127
128 static gint
diff --git a/meta/packages/gtk+/gtk+_2.6.10.bb b/meta/packages/gtk+/gtk+_2.6.10.bb
index 298e4c648d..bc47fa268c 100644
--- a/meta/packages/gtk+/gtk+_2.6.10.bb
+++ b/meta/packages/gtk+/gtk+_2.6.10.bb
@@ -8,22 +8,19 @@ DEPENDS = "glib-2.0 pango atk jpeg libpng libxext libxcursor gtk-doc libgcrypt"
8PR = "r5" 8PR = "r5"
9 9
10SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \ 10SRC_URI = "ftp://ftp.gtk.org/pub/gtk/v2.6/gtk+-${PV}.tar.bz2 \
11 file://help.patch;patch=1 \
12 file://no-demos.patch;patch=1 \ 11 file://no-demos.patch;patch=1 \
13 file://no-xwc.patch;patch=1 \ 12 file://no-xwc.patch;patch=1 \
14 file://automake-lossage.patch;patch=1 \ 13 file://automake-lossage.patch;patch=1 \
15 file://gtk+-handhelds.patch;patch=1 \ 14 file://gtk+-handhelds.patch;patch=1 \
16 file://spinbutton.patch;patch=1 \
17 file://hardcoded_libtool.patch;patch=1 \ 15 file://hardcoded_libtool.patch;patch=1 \
18 file://disable-tooltips.patch;patch=1 \ 16 file://disable-tooltips.patch;patch=1 \
19 file://gtklabel-resize-patch;patch=1 \ 17 file://gtklabel-resize-patch;patch=1 \
20 file://menu-deactivate.patch;patch=1 \ 18 file://menu-deactivate.patch;patch=1 \
21 file://xsettings.patch;patch=1 \
22 file://scroll-timings.patch;patch=1 \ 19 file://scroll-timings.patch;patch=1 \
23 file://small-gtkfilesel.patch;patch=1 \ 20 file://filesystem-volumes.patch;patch=1 \
24 file://migration.patch;patch=1;pnum=0 \ 21 file://filechooser-respect-style.patch;patch=1 \
25 file://single-click.patch;patch=1 \ 22 file://filechooser-default.patch;patch=1 \
26 file://menu-styling.patch;patch=1" 23 "
27 24
28inherit autotools pkgconfig 25inherit autotools pkgconfig
29 26