Merge lp:~elementary-dev-community/pantheon-files/fix-1086929 into lp:~elementary-apps/pantheon-files/trunk

Proposed by Julián Unrrein
Status: Rejected
Rejected by: Cody Garver
Proposed branch: lp:~elementary-dev-community/pantheon-files/fix-1086929
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 2284 lines (+496/-373)
8 files modified
libcore/gof-directory-async.vala (+76/-46)
src/View/ViewContainer.vala (+2/-0)
src/fm-columns-view.c (+119/-119)
src/fm-directory-view.c (+132/-123)
src/fm-directory-view.h (+57/-57)
src/gof-window-slot.c (+101/-26)
src/gof-window-slot.h (+5/-2)
src/marlin-window-columns.c (+4/-0)
To merge this branch: bzr merge lp:~elementary-dev-community/pantheon-files/fix-1086929
Reviewer Review Type Date Requested Status
David Gomes (community) Needs Fixing
Review via email: mp+183370@code.launchpad.net

Commit message

Make columns automatically size themselves to fit the longest item contained. Fixes bug #1086929.

Description of the change

By Jeremy Wootten

Make columns automatically size themselves to fit the longest item contained. Fixes bug #1086929.

The first column can't be downsized, for now.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Special notes:

Manually merge this and use --author flag to give Jeremy credit.

A stable release of Files should be made RIGHT BEFORE this is merged

Revision history for this message
Cody Garver (codygarver) wrote :

Trunk is now prepared to receive this branch, pending David "Munchor" Gomes' code review.

Revision history for this message
David Gomes (davidgomes) wrote :

Diff line 116 - wrong brace opening style.
Add newline after diff line 135, 164.
Diff lines 983-985 - fix alignent, that is, the '"', the '_', the other '"' and 'N' should be in the same column.
Same thing for diff lines 1549 and after, 2022 and after, 2038 and after, 2121 and 2122.
Remove diff line 2151

review: Needs Fixing
Revision history for this message
Cody Garver (codygarver) wrote :

Rejected because it was submitted as a newer branch that did get merged.

Unmerged revisions

1270. By Jeremy Wootten

Correct some formatting and merge latest trunk

1269. By Jeremy Wootten

Allow manual shrinking of miller columns (except first)

1268. By Jeremy Wootten

escape markup text longest filename

1267. By Jeremy Wootten

Properly autosize cached directories and empty directories, remove unnecessary changes

1266. By Jeremy Wootten

Merged changes from trunk up to rev 1306

1265. By Jeremy Wootten

Check in Miller view before calling autosize_slot

1264. By Jeremy Wootten

Alternative fix 1086929 - for comment

1263. By Jeremy Wootten

Address issues raised in first review

1262. By Jeremy Wootten

Merge from trunk

1261. By Jeremy Wootten

track longest name as required

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libcore/gof-directory-async.vala'
--- libcore/gof-directory-async.vala 2013-06-30 15:49:02 +0000
+++ libcore/gof-directory-async.vala 2013-09-01 22:36:03 +0000
@@ -1,16 +1,16 @@
1/* 1/*
2 * Copyright (C) 2011 Marlin Developers2 * Copyright (C) 2011 Marlin Developers
3 * 3 *
4 * This program is free software: you can redistribute it and/or modify4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful,9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *16 *
@@ -29,7 +29,9 @@
29 /* we're looking for particular path keywords like *\/icons* .icons ... */29 /* we're looking for particular path keywords like *\/icons* .icons ... */
30 public bool uri_contain_keypath_icons;30 public bool uri_contain_keypath_icons;
31 public int uri_keypath_size = 0;31 public int uri_keypath_size = 0;
32 32 public string longest_file_name = ""; //for auto-sizing Miller columns
33 public bool track_longest_name;
34
33 public enum State {35 public enum State {
34 NOT_LOADED,36 NOT_LOADED,
35 LOADING,37 LOADING,
@@ -38,14 +40,14 @@
38 public State state = State.NOT_LOADED;40 public State state = State.NOT_LOADED;
3941
40 public HashTable<GLib.File,GOF.File> file_hash;42 public HashTable<GLib.File,GOF.File> file_hash;
41 43
42 public uint files_count = 0;44 public uint files_count = 0;
43 45
44 public bool permission_denied = false;46 public bool permission_denied = false;
4547
46 private Cancellable cancellable;48 private Cancellable cancellable;
47 private FileMonitor? monitor = null;49 private FileMonitor? monitor = null;
48 50
49 private List<GOF.File>? sorted_dirs = null;51 private List<GOF.File>? sorted_dirs = null;
5052
51 /* signals */53 /* signals */
@@ -77,7 +79,7 @@
77 file = GOF.File.get (location);79 file = GOF.File.get (location);
78 file.exists = true;80 file.exists = true;
79 cancellable = new Cancellable ();81 cancellable = new Cancellable ();
80 82 track_longest_name = false;
81 //query_info_async (file, file_info_available);83 //query_info_async (file, file_info_available);
82 if (file.info == null)84 if (file.info == null)
83 file.query_update ();85 file.query_update ();
@@ -110,8 +112,8 @@
110 if (is_last) {112 if (is_last) {
111 Async dir = (Async) object;113 Async dir = (Async) object;
112 debug ("Async toggle_ref_notify %s", dir.file.uri);114 debug ("Async toggle_ref_notify %s", dir.file.uri);
113 115
114 if (!dir.removed_from_cache) 116 if (!dir.removed_from_cache)
115 dir.remove_dir_from_cache ();117 dir.remove_dir_from_cache ();
116 dir.remove_toggle_ref ((ToggleNotify) toggle_ref_notify);118 dir.remove_toggle_ref ((ToggleNotify) toggle_ref_notify);
117 }119 }
@@ -145,9 +147,10 @@
145 public void load ()147 public void load ()
146 {148 {
147 cancellable.reset ();149 cancellable.reset ();
150 longest_file_name = "";
148 if (state != State.LOADED) {151 if (state != State.LOADED) {
149 /* clear directory info if it's not fully loaded */152 /* clear directory info if it's not fully loaded */
150 if (state == State.LOADING) 153 if (state == State.LOADING)
151 clear_directory_info ();154 clear_directory_info ();
152 if (!file.is_mounted) {155 if (!file.is_mounted) {
153 mount_mountable.begin ();156 mount_mountable.begin ();
@@ -160,7 +163,7 @@
160 list_directory.begin (location);163 list_directory.begin (location);
161 try {164 try {
162 monitor = location.monitor_directory (0);165 monitor = location.monitor_directory (0);
163 monitor.changed.connect (directory_changed); 166 monitor.changed.connect (directory_changed);
164 } catch (IOError e) {167 } catch (IOError e) {
165 if (!(e is IOError.NOT_MOUNTED)) {168 if (!(e is IOError.NOT_MOUNTED)) {
166 warning ("directory monitor failed: %s %s", e.message, file.uri);169 warning ("directory monitor failed: %s %s", e.message, file.uri);
@@ -173,32 +176,45 @@
173 /* send again the info_available signal for reused directories */176 /* send again the info_available signal for reused directories */
174 if (file.info != null)177 if (file.info != null)
175 file.info_available ();178 file.info_available ();
176 179
177 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;180 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;
178 foreach (GOF.File gof in file_hash.get_values ()) {181 foreach (GOF.File gof in file_hash.get_values ()) {
179 if (gof.info != null && (!gof.is_hidden || show_hidden))182 if (gof.info != null && (!gof.is_hidden || show_hidden)) {
183 if (track_longest_name)
184 update_longest_file_name (gof);
180 file_loaded (gof);185 file_loaded (gof);
186 }
181 }187 }
182 done_loading ();188 done_loading ();
183 }189 }
184 }190 }
185191
186 public void load_hiddens () 192 private void update_longest_file_name (GOF.File gof)
193 {
194 if (longest_file_name.length < gof.basename.length)
195 longest_file_name = gof.basename;
196 }
197
198 public void load_hiddens ()
187 {199 {
188 if (state != State.LOADED) {200 if (state != State.LOADED) {
189 load ();201 load ();
190 } else {202 } else {
191 foreach (GOF.File gof in file_hash.get_values ()) {203 foreach (GOF.File gof in file_hash.get_values ()) {
192 if (gof != null && gof.info != null && gof.is_hidden)204 if (gof != null && gof.info != null && gof.is_hidden) {
205 if (track_longest_name)
206 update_longest_file_name (gof);
193 file_loaded (gof);207 file_loaded (gof);
208 }
194 }209 }
195 }210 }
211 done_loading ();
196 }212 }
197213
198 public void update_desktop_files () 214 public void update_desktop_files ()
199 {215 {
200 foreach (GOF.File gof in file_hash.get_values ()) {216 foreach (GOF.File gof in file_hash.get_values ()) {
201 if (gof != null && gof.info != null 217 if (gof != null && gof.info != null
202 && (!gof.is_hidden || Preferences.get_default ().pref_show_hidden_files)218 && (!gof.is_hidden || Preferences.get_default ().pref_show_hidden_files)
203 && gof.is_desktop)219 && gof.is_desktop)
204 gof.update_desktop_file ();220 gof.update_desktop_file ();
@@ -242,6 +258,7 @@
242 if (files == null)258 if (files == null)
243 break;259 break;
244260
261 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;
245 foreach (var file_info in files)262 foreach (var file_info in files)
246 {263 {
247 GLib.File loc = location.get_child ((string) file_info.get_name());264 GLib.File loc = location.get_child ((string) file_info.get_name());
@@ -255,14 +272,18 @@
255 //debug ("file: %s", gof.name);272 //debug ("file: %s", gof.name);
256273
257 add_to_hash_cache (gof);274 add_to_hash_cache (gof);
258 if (!gof.is_hidden || Preferences.get_default ().pref_show_hidden_files)275
276 if (!gof.is_hidden || show_hidden) {
277 if (track_longest_name)
278 update_longest_file_name (gof);
259 file_loaded (gof);279 file_loaded (gof);
260280 }
261 //mutex.lock ();281 //mutex.lock ();
262 files_count++;282 files_count++;
263 //mutex.unlock ();283 //mutex.unlock ();
264 }284 }
265 }285 }
286
266 file.exists = true;287 file.exists = true;
267 state = State.LOADED;288 state = State.LOADED;
268 } catch (Error err) {289 } catch (Error err) {
@@ -294,8 +315,8 @@
294315
295 private async void query_info_async (GOF.File gof, func_query_info? f = null) {316 private async void query_info_async (GOF.File gof, func_query_info? f = null) {
296 try {317 try {
297 gof.info = yield gof.location.query_info_async (gio_attrs, 318 gof.info = yield gof.location.query_info_async (gio_attrs,
298 FileQueryInfoFlags.NONE, 319 FileQueryInfoFlags.NONE,
299 Priority.DEFAULT);320 Priority.DEFAULT);
300 if (f != null)321 if (f != null)
301 f (gof);322 f (gof);
@@ -329,8 +350,13 @@
329 /* add to sorted_dirs */350 /* add to sorted_dirs */
330 sorted_dirs.insert_sorted (gof, GOF.File.compare_by_display_name);351 sorted_dirs.insert_sorted (gof, GOF.File.compare_by_display_name);
331 }352 }
353
354 if (track_longest_name && gof.basename.length > longest_file_name.length) {
355 longest_file_name = gof.basename;
356 done_loading ();
357 }
332 }358 }
333 359
334 private void file_info_available (GOF.File gof) {360 private void file_info_available (GOF.File gof) {
335 gof.update ();361 gof.update ();
336 gof.info_available ();362 gof.info_available ();
@@ -353,6 +379,9 @@
353 sorted_dirs.remove (gof);379 sorted_dirs.remove (gof);
354 }380 }
355 gof.remove_from_caches ();381 gof.remove_from_caches ();
382 if (track_longest_name && gof.basename.length == longest_file_name.length) {
383 load ();
384 }
356 }385 }
357386
358 private struct fchanges {387 private struct fchanges {
@@ -362,7 +391,7 @@
362 private List <fchanges?> list_fchanges = null;391 private List <fchanges?> list_fchanges = null;
363 private uint list_fchanges_count = 0;392 private uint list_fchanges_count = 0;
364 /* number of monitored changes to store after that simply reload the dir */393 /* number of monitored changes to store after that simply reload the dir */
365 private const uint FCHANGES_MAX = 20; 394 private const uint FCHANGES_MAX = 20;
366395
367 private void directory_changed (GLib.File _file, GLib.File? other_file, FileMonitorEvent event)396 private void directory_changed (GLib.File _file, GLib.File? other_file, FileMonitorEvent event)
368 {397 {
@@ -393,7 +422,7 @@
393 //message ("file added %s", _file.get_uri ());422 //message ("file added %s", _file.get_uri ());
394 //notify_file_added (gof);423 //notify_file_added (gof);
395 MarlinFile.changes_queue_file_added (_file);424 MarlinFile.changes_queue_file_added (_file);
396 break; 425 break;
397 case FileMonitorEvent.DELETED:426 case FileMonitorEvent.DELETED:
398 //message ("file deleted %s", _file.get_uri ());427 //message ("file deleted %s", _file.get_uri ());
399 //notify_file_removed (gof);428 //notify_file_removed (gof);
@@ -424,7 +453,7 @@
424 foreach (var fchange in list_fchanges)453 foreach (var fchange in list_fchanges)
425 real_directory_changed (fchange.file, null, fchange.event);454 real_directory_changed (fchange.file, null, fchange.event);
426 }455 }
427 } 456 }
428 list_fchanges_count = 0;457 list_fchanges_count = 0;
429 list_fchanges = null;458 list_fchanges = null;
430 }459 }
@@ -435,8 +464,8 @@
435 foreach (var loc in files) {464 foreach (var loc in files) {
436 GOF.File gof = GOF.File.get (loc);465 GOF.File gof = GOF.File.get (loc);
437 Async? dir = cache_lookup (gof.directory);466 Async? dir = cache_lookup (gof.directory);
438 467
439 if (dir != null) 468 if (dir != null)
440 dir.notify_file_changed (gof);469 dir.notify_file_changed (gof);
441 }470 }
442 }471 }
@@ -446,8 +475,8 @@
446 foreach (var loc in files) {475 foreach (var loc in files) {
447 GOF.File gof = GOF.File.get (loc);476 GOF.File gof = GOF.File.get (loc);
448 Async? dir = cache_lookup (gof.directory);477 Async? dir = cache_lookup (gof.directory);
449 478
450 if (dir != null) 479 if (dir != null)
451 dir.notify_file_added (gof);480 dir.notify_file_added (gof);
452 }481 }
453 }482 }
@@ -457,7 +486,7 @@
457 foreach (var loc in files) {486 foreach (var loc in files) {
458 GOF.File gof = GOF.File.get (loc);487 GOF.File gof = GOF.File.get (loc);
459 Async? dir = cache_lookup (gof.directory);488 Async? dir = cache_lookup (gof.directory);
460 489
461 if (dir != null) {490 if (dir != null) {
462 //message ("notify removed %s", gof.uri);491 //message ("notify removed %s", gof.uri);
463 dir.notify_file_removed (gof);492 dir.notify_file_removed (gof);
@@ -480,7 +509,7 @@
480 {509 {
481 return from_gfile (gof.get_target_location ());510 return from_gfile (gof.get_target_location ());
482 }511 }
483 512
484 public static Async? cache_lookup (GLib.File *file)513 public static Async? cache_lookup (GLib.File *file)
485 {514 {
486 Async? cached_dir = null;515 Async? cached_dir = null;
@@ -488,7 +517,7 @@
488 if (directory_cache == null) {517 if (directory_cache == null) {
489 directory_cache = new HashTable<GLib.File,GOF.Directory.Async> (GLib.file_hash, GLib.file_equal);518 directory_cache = new HashTable<GLib.File,GOF.Directory.Async> (GLib.file_hash, GLib.file_equal);
490 }519 }
491 520
492 if (directory_cache != null)521 if (directory_cache != null)
493 cached_dir = directory_cache.lookup (file);522 cached_dir = directory_cache.lookup (file);
494 if (cached_dir != null) {523 if (cached_dir != null) {
@@ -513,14 +542,14 @@
513 {542 {
514 /* we got to increment the dir ref to remove the toggle_ref */543 /* we got to increment the dir ref to remove the toggle_ref */
515 this.ref ();544 this.ref ();
516 545
517 removed_from_cache = true;546 removed_from_cache = true;
518 return directory_cache.remove (location);547 return directory_cache.remove (location);
519 }548 }
520 549
521 public bool purge_dir_from_cache () {550 public bool purge_dir_from_cache () {
522 var removed = remove_dir_from_cache ();551 var removed = remove_dir_from_cache ();
523 552
524 /* We have to remove the dir's subfolders from cache too */553 /* We have to remove the dir's subfolders from cache too */
525 if (removed) {554 if (removed) {
526 foreach (var gfile in file_hash.get_keys ()) {555 foreach (var gfile in file_hash.get_keys ()) {
@@ -529,15 +558,15 @@
529 dir.remove_dir_from_cache ();558 dir.remove_dir_from_cache ();
530 }559 }
531 }560 }
532 561
533 return removed;562 return removed;
534 }563 }
535 564
536 public bool has_parent ()565 public bool has_parent ()
537 {566 {
538 return (file.directory != null);567 return (file.directory != null);
539 }568 }
540 569
541 public GLib.File get_parent ()570 public GLib.File get_parent ()
542 {571 {
543 return file.directory;572 return file.directory;
@@ -549,7 +578,7 @@
549578
550 if (file_hash != null)579 if (file_hash != null)
551 file_hash_count = file_hash.size ();580 file_hash_count = file_hash.size ();
552 581
553 //debug ("is_empty hash sizes file: %u", file_hash_count);582 //debug ("is_empty hash sizes file: %u", file_hash_count);
554 if (state == State.LOADED && file_hash_count == 0)583 if (state == State.LOADED && file_hash_count == 0)
555 return true;584 return true;
@@ -566,7 +595,7 @@
566595
567 foreach (var gof in file_hash.get_values()) {596 foreach (var gof in file_hash.get_values()) {
568 if (gof.info != null && !gof.is_hidden && gof.is_folder ())597 if (gof.info != null && !gof.is_hidden && gof.is_folder ())
569 sorted_dirs.prepend (gof); 598 sorted_dirs.prepend (gof);
570 }599 }
571 sorted_dirs.sort (GOF.File.compare_by_display_name);600 sorted_dirs.sort (GOF.File.compare_by_display_name);
572601
@@ -600,12 +629,13 @@
600 }629 }
601 thumbs_loaded ();630 thumbs_loaded ();
602 thumbs_thread_runing = false;631 thumbs_thread_runing = false;
603 632
604 this.unref ();633 this.unref ();
605 return null;634 return null;
606 }635 }
607636
608 private int icon_size;637 public int icon_size;
638
609 public void threaded_load_thumbnails (int size)639 public void threaded_load_thumbnails (int size)
610 {640 {
611 try {641 try {
@@ -641,7 +671,7 @@
641 timeout_thumbsq = Timeout.add (40, queue_thumbs_timeout_cb);671 timeout_thumbsq = Timeout.add (40, queue_thumbs_timeout_cb);
642 }672 }
643 }673 }
644 674
645 private Regex regex_num_size = null;675 private Regex regex_num_size = null;
646676
647 private void get_keypath_size ()677 private void get_keypath_size ()
648678
=== modified file 'src/View/ViewContainer.vala'
--- src/View/ViewContainer.vala 2013-06-14 23:37:29 +0000
+++ src/View/ViewContainer.vala 2013-09-01 22:36:03 +0000
@@ -204,8 +204,10 @@
204 select_childs.prepend (slot.directory.file.location);204 select_childs.prepend (slot.directory.file.location);
205 }205 }
206 }206 }
207
207 if (slot != null && slot.directory != null && slot.directory.file.exists) {208 if (slot != null && slot.directory != null && slot.directory.file.exists) {
208 slot.directory.cancel();209 slot.directory.cancel();
210 slot.directory.track_longest_name = false;
209 }211 }
210212
211 if (nview == ViewMode.MILLER) {213 if (nview == ViewMode.MILLER) {
212214
=== modified file 'src/fm-columns-view.c'
--- src/fm-columns-view.c 2013-08-01 21:24:46 +0000
+++ src/fm-columns-view.c 2013-09-01 22:36:03 +0000
@@ -73,17 +73,17 @@
73static gboolean fm_columns_view_draw(GtkWidget* view_, cairo_t* cr, FMColumnsView* view)73static gboolean fm_columns_view_draw(GtkWidget* view_, cairo_t* cr, FMColumnsView* view)
74{74{
75 g_return_val_if_fail(FM_IS_COLUMNS_VIEW(view), FALSE);75 g_return_val_if_fail(FM_IS_COLUMNS_VIEW(view), FALSE);
76 76
77 GOFDirectoryAsync *dir = fm_directory_view_get_current_directory (FM_DIRECTORY_VIEW (view));77 GOFDirectoryAsync *dir = fm_directory_view_get_current_directory (FM_DIRECTORY_VIEW (view));
7878
79 if (gof_directory_async_is_empty (dir))79 if (gof_directory_async_is_empty (dir))
80 {80 {
81 PangoLayout* layout = gtk_widget_create_pango_layout(GTK_WIDGET(view), NULL);81 PangoLayout* layout = gtk_widget_create_pango_layout(GTK_WIDGET(view), NULL);
82 gchar *str = g_strconcat("<span size='x-large'>", _("This folder is empty."), "</span>", NULL);82 //gchar *str = g_strconcat("<span size='x-large'>", _("This folder is empty."), "</span>", NULL);
83 pango_layout_set_markup (layout, str, -1);83 //const gchar *str = FM_DIRECTORY_VIEW (view)->empty_message;
8484 pango_layout_set_markup (layout, FM_DIRECTORY_VIEW (view)->empty_message, -1);
85 PangoRectangle extents;85 PangoRectangle extents;
86 /* Get hayout height and width */86 /* Get layout height and width */
87 pango_layout_get_extents(layout, NULL, &extents);87 pango_layout_get_extents(layout, NULL, &extents);
88 gdouble width = pango_units_to_double(extents.width);88 gdouble width = pango_units_to_double(extents.width);
89 gdouble height = pango_units_to_double(extents.height);89 gdouble height = pango_units_to_double(extents.height);
@@ -118,7 +118,7 @@
118 /* don't update column if we got a drag_begin started */118 /* don't update column if we got a drag_begin started */
119 if (fm_directory_view_is_drag_pending (FM_DIRECTORY_VIEW (view)))119 if (fm_directory_view_is_drag_pending (FM_DIRECTORY_VIEW (view)))
120 return;120 return;
121 121
122 /* setup the current active slot */122 /* setup the current active slot */
123 fm_directory_view_set_active_slot (FM_DIRECTORY_VIEW (view));123 fm_directory_view_set_active_slot (FM_DIRECTORY_VIEW (view));
124 fm_directory_view_notify_selection_changed (FM_DIRECTORY_VIEW (view));124 fm_directory_view_notify_selection_changed (FM_DIRECTORY_VIEW (view));
@@ -148,7 +148,7 @@
148static void148static void
149row_activated_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, FMColumnsView *view)149row_activated_callback (GtkTreeView *treeview, GtkTreeIter *iter, GtkTreePath *path, FMColumnsView *view)
150{150{
151 g_message ("%s\n", G_STRFUNC);151 g_debug ("%s\n", G_STRFUNC);
152 fm_directory_view_activate_selected_items (FM_DIRECTORY_VIEW (view), MARLIN_WINDOW_OPEN_FLAG_NEW_TAB);152 fm_directory_view_activate_selected_items (FM_DIRECTORY_VIEW (view), MARLIN_WINDOW_OPEN_FLAG_NEW_TAB);
153}153}
154154
@@ -156,18 +156,18 @@
156fm_columns_view_freeze_updates (FMColumnsView *view)156fm_columns_view_freeze_updates (FMColumnsView *view)
157{157{
158 /* Make filename-cells editable. */158 /* Make filename-cells editable. */
159 g_object_set (G_OBJECT (view->details->file_name_cell),159 g_object_set (G_OBJECT (view->details->file_name_cell),
160 "editable", TRUE, NULL);160 "editable", TRUE, NULL);
161 fm_directory_view_freeze_updates (FM_DIRECTORY_VIEW (view));161 fm_directory_view_freeze_updates (FM_DIRECTORY_VIEW (view));
162}162}
163163
164static void164static void
165fm_columns_view_unfreeze_updates (FMColumnsView *view)165fm_columns_view_unfreeze_updates (FMColumnsView *view)
166{166{
167 /*We're done editing - make the filename-cells readonly again.*/167 /*We're done editing - make the filename-cells readonly again.*/
168 g_object_set (G_OBJECT (view->details->file_name_cell),168 g_object_set (G_OBJECT (view->details->file_name_cell),
169 "editable", FALSE, NULL);169 "editable", FALSE, NULL);
170 fm_directory_view_unfreeze_updates (FM_DIRECTORY_VIEW (view));170 fm_directory_view_unfreeze_updates (FM_DIRECTORY_VIEW (view));
171}171}
172172
173static void173static void
@@ -176,32 +176,32 @@
176 GError *error,176 GError *error,
177 gpointer callback_data)177 gpointer callback_data)
178{178{
179 FMColumnsView *view = FM_COLUMNS_VIEW (callback_data);179 FMColumnsView *view = FM_COLUMNS_VIEW (callback_data);
180180
181 printf ("%s\n", G_STRFUNC);181 printf ("%s\n", G_STRFUNC);
182 if (view->details->renaming_file) {182 if (view->details->renaming_file) {
183 view->details->rename_done = TRUE;183 view->details->rename_done = TRUE;
184 184
185 if (error != NULL) {185 if (error != NULL) {
186 marlin_dialogs_show_error (GTK_WIDGET (view), error, _("Failed to rename %s to %s"), g_file_info_get_name (file->info), view->details->original_name);186 marlin_dialogs_show_error (GTK_WIDGET (view), error, _("Failed to rename %s to %s"), g_file_info_get_name (file->info), view->details->original_name);
187 /* If the rename failed (or was cancelled), kill renaming_file.187 /* If the rename failed (or was cancelled), kill renaming_file.
188 * We won't get a change event for the rename, so otherwise188 * We won't get a change event for the rename, so otherwise
189 * it would stay around forever.189 * it would stay around forever.
190 */190 */
191 g_object_unref (view->details->renaming_file);191 g_object_unref (view->details->renaming_file);
192 }192 }
193 }193 }
194 194
195 g_object_unref (view);195 g_object_unref (view);
196}196}
197197
198static void198static void
199editable_focus_out_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)199editable_focus_out_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
200{200{
201 FMColumnsView *view = user_data;201 FMColumnsView *view = user_data;
202202
203 fm_columns_view_unfreeze_updates (view);203 fm_columns_view_unfreeze_updates (view);
204 view->details->editable_widget = NULL;204 view->details->editable_widget = NULL;
205}205}
206206
207static void207static void
@@ -210,17 +210,17 @@
210 const gchar *path_str,210 const gchar *path_str,
211 FMColumnsView *col_view)211 FMColumnsView *col_view)
212{212{
213 GtkEntry *entry;213 GtkEntry *entry;
214214
215 entry = GTK_ENTRY (editable);215 entry = GTK_ENTRY (editable);
216 col_view->details->editable_widget = editable;216 col_view->details->editable_widget = editable;
217217
218 /* Free a previously allocated original_name */218 /* Free a previously allocated original_name */
219 g_free (col_view->details->original_name);219 g_free (col_view->details->original_name);
220220
221 col_view->details->original_name = g_strdup (gtk_entry_get_text (entry));221 col_view->details->original_name = g_strdup (gtk_entry_get_text (entry));
222222
223 g_signal_connect (entry, "focus-out-event",223 g_signal_connect (entry, "focus-out-event",
224 G_CALLBACK (editable_focus_out_cb), col_view);224 G_CALLBACK (editable_focus_out_cb), col_view);
225}225}
226226
@@ -228,8 +228,8 @@
228cell_renderer_editing_canceled (GtkCellRendererText *cell,228cell_renderer_editing_canceled (GtkCellRendererText *cell,
229 FMColumnsView *view)229 FMColumnsView *view)
230{230{
231 view->details->editable_widget = NULL;231 view->details->editable_widget = NULL;
232 fm_columns_view_unfreeze_updates (view);232 fm_columns_view_unfreeze_updates (view);
233}233}
234234
235static void235static void
@@ -238,43 +238,43 @@
238 const char *new_text,238 const char *new_text,
239 FMColumnsView *view)239 FMColumnsView *view)
240{240{
241 GtkTreePath *path;241 GtkTreePath *path;
242 GOFFile *file;242 GOFFile *file;
243 GtkTreeIter iter;243 GtkTreeIter iter;
244244
245 printf ("%s\n", G_STRFUNC);245 printf ("%s\n", G_STRFUNC);
246 view->details->editable_widget = NULL;246 view->details->editable_widget = NULL;
247247
248 /* Don't allow a rename with an empty string. Revert to original 248 /* Don't allow a rename with an empty string. Revert to original
249 * without notifying the user.249 * without notifying the user.
250 */250 */
251 if (new_text[0] == '\0') {251 if (new_text[0] == '\0') {
252 fm_columns_view_unfreeze_updates (view);252 fm_columns_view_unfreeze_updates (view);
253 return;253 return;
254 }254 }
255 255
256 path = gtk_tree_path_new_from_string (path_str);256 path = gtk_tree_path_new_from_string (path_str);
257257
258 gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), &iter, path);258 gtk_tree_model_get_iter (GTK_TREE_MODEL (view->model), &iter, path);
259259
260 gtk_tree_path_free (path);260 gtk_tree_path_free (path);
261 261
262 gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter,262 gtk_tree_model_get (GTK_TREE_MODEL (view->model), &iter,
263 FM_LIST_MODEL_FILE_COLUMN, &file, -1);263 FM_LIST_MODEL_FILE_COLUMN, &file, -1);
264264
265 /* Only rename if name actually changed */265 /* Only rename if name actually changed */
266 if (strcmp (new_text, view->details->original_name) != 0) {266 if (strcmp (new_text, view->details->original_name) != 0) {
267 view->details->renaming_file = gof_file_ref (file);267 view->details->renaming_file = gof_file_ref (file);
268 view->details->rename_done = FALSE;268 view->details->rename_done = FALSE;
269 gof_file_rename (file, new_text, fm_columns_view_rename_callback, g_object_ref (view));269 gof_file_rename (file, new_text, fm_columns_view_rename_callback, g_object_ref (view));
270270
271 g_free (view->details->original_name);271 g_free (view->details->original_name);
272 view->details->original_name = g_strdup (new_text);272 view->details->original_name = g_strdup (new_text);
273 }273 }
274 274
275 gof_file_unref (file);275 gof_file_unref (file);
276276
277 fm_columns_view_unfreeze_updates (view);277 fm_columns_view_unfreeze_updates (view);
278}278}
279279
280static void280static void
@@ -282,35 +282,35 @@
282 GOFFile *file,282 GOFFile *file,
283 gboolean select_all)283 gboolean select_all)
284{284{
285 FMColumnsView *col_view;285 FMColumnsView *col_view;
286 GtkTreeIter iter;286 GtkTreeIter iter;
287 GtkTreePath *path;287 GtkTreePath *path;
288 gint start_offset, end_offset;288 gint start_offset, end_offset;
289289
290 col_view = FM_COLUMNS_VIEW (view);290 col_view = FM_COLUMNS_VIEW (view);
291291
292 g_message ("%s", G_STRFUNC);292 g_debug ("%s", G_STRFUNC);
293 /* Select all if we are in renaming mode already */293 /* Select all if we are in renaming mode already */
294 if (col_view->details->file_name_column && col_view->details->editable_widget) {294 if (col_view->details->file_name_column && col_view->details->editable_widget) {
295 gtk_editable_select_region (GTK_EDITABLE (col_view->details->editable_widget),295 gtk_editable_select_region (GTK_EDITABLE (col_view->details->editable_widget),
296 0, -1);296 0, -1);
297 return;297 return;
298 }298 }
299299
300 if (!fm_list_model_get_first_iter_for_file (col_view->model, file, &iter)) {300 if (!fm_list_model_get_first_iter_for_file (col_view->model, file, &iter)) {
301 return;301 return;
302 }302 }
303303
304 /* Freeze updates to the view to prevent losing rename focus when the tree view updates */304 /* Freeze updates to the view to prevent losing rename focus when the tree view updates */
305 fm_columns_view_freeze_updates (col_view);305 fm_columns_view_freeze_updates (col_view);
306306
307 path = gtk_tree_model_get_path (GTK_TREE_MODEL (col_view->model), &iter);307 path = gtk_tree_model_get_path (GTK_TREE_MODEL (col_view->model), &iter);
308308
309 gtk_tree_view_scroll_to_cell (col_view->tree, NULL,309 gtk_tree_view_scroll_to_cell (col_view->tree, NULL,
310 col_view->details->file_name_column,310 col_view->details->file_name_column,
311 TRUE, 0.0, 0.0);311 TRUE, 0.0, 0.0);
312 /* set cursor also triggers editing-started, where we save the editable widget */312 /* set cursor also triggers editing-started, where we save the editable widget */
313 /*gtk_tree_view_set_cursor (col_view->tree, path,313 /*gtk_tree_view_set_cursor (col_view->tree, path,
314 col_view->details->file_name_column, TRUE);*/314 col_view->details->file_name_column, TRUE);*/
315 /* sound like set_cursor is not enought to trigger editing-started, we use cursor_on_cell instead */315 /* sound like set_cursor is not enought to trigger editing-started, we use cursor_on_cell instead */
316 gtk_tree_view_set_cursor_on_cell (col_view->tree, path,316 gtk_tree_view_set_cursor_on_cell (col_view->tree, path,
@@ -318,15 +318,15 @@
318 (GtkCellRenderer *) col_view->details->file_name_cell,318 (GtkCellRenderer *) col_view->details->file_name_cell,
319 TRUE);319 TRUE);
320320
321 if (col_view->details->editable_widget != NULL) {321 if (col_view->details->editable_widget != NULL) {
322 eel_filename_get_rename_region (col_view->details->original_name,322 eel_filename_get_rename_region (col_view->details->original_name,
323 &start_offset, &end_offset);323 &start_offset, &end_offset);
324324
325 gtk_editable_select_region (GTK_EDITABLE (col_view->details->editable_widget),325 gtk_editable_select_region (GTK_EDITABLE (col_view->details->editable_widget),
326 start_offset, end_offset);326 start_offset, end_offset);
327 }327 }
328328
329 gtk_tree_path_free (path);329 gtk_tree_path_free (path);
330}330}
331331
332static void fm_columns_view_select_all(FMDirectoryView *view)332static void fm_columns_view_select_all(FMDirectoryView *view)
@@ -460,17 +460,17 @@
460 GtkTreeSelection *selection;460 GtkTreeSelection *selection;
461 GtkTreePath *path;461 GtkTreePath *path;
462462
463 g_message ("%s", G_STRFUNC);463 g_debug ("%s", G_STRFUNC);
464 if (view->details->pressed_button == event->button && view->details->pressed_button != -1)464 if (view->details->pressed_button == event->button && view->details->pressed_button != -1)
465 {465 {
466 view->details->updates_frozen = FALSE;466 view->details->updates_frozen = FALSE;
467 selection = gtk_tree_view_get_selection (tree_view);467 selection = gtk_tree_view_get_selection (tree_view);
468 list_selection_changed_callback (selection, view);468 list_selection_changed_callback (selection, view);
469 469
470 /* reset the pressed_button state */470 /* reset the pressed_button state */
471 view->details->pressed_button = -1;471 view->details->pressed_button = -1;
472 }472 }
473 473
474474
475 return TRUE;475 return TRUE;
476}476}
@@ -684,7 +684,7 @@
684}684}
685685
686static void686static void
687fm_columns_view_set_cursor (FMDirectoryView *view, GtkTreePath *path, 687fm_columns_view_set_cursor (FMDirectoryView *view, GtkTreePath *path,
688 gboolean start_editing, gboolean select)688 gboolean start_editing, gboolean select)
689{689{
690 FMColumnsView *cols_view = FM_COLUMNS_VIEW (view);690 FMColumnsView *cols_view = FM_COLUMNS_VIEW (view);
@@ -692,12 +692,12 @@
692692
693 /* the treeview select the path by default. */693 /* the treeview select the path by default. */
694 g_signal_handlers_block_by_func (selection, list_selection_changed_callback, cols_view);694 g_signal_handlers_block_by_func (selection, list_selection_changed_callback, cols_view);
695 gtk_tree_view_set_cursor_on_cell (cols_view->tree, path, 695 gtk_tree_view_set_cursor_on_cell (cols_view->tree, path,
696 cols_view->details->file_name_column,696 cols_view->details->file_name_column,
697 (GtkCellRenderer *) cols_view->details->file_name_cell,697 (GtkCellRenderer *) cols_view->details->file_name_cell,
698 start_editing);698 start_editing);
699699
700 if (!select) 700 if (!select)
701 gtk_tree_selection_unselect_path (selection, path);701 gtk_tree_selection_unselect_path (selection, path);
702 g_signal_handlers_unblock_by_func (selection, list_selection_changed_callback, cols_view);702 g_signal_handlers_unblock_by_func (selection, list_selection_changed_callback, cols_view);
703}703}
@@ -724,7 +724,7 @@
724}724}
725725
726static gboolean726static gboolean
727fm_columns_view_get_visible_range (FMDirectoryView *view, 727fm_columns_view_get_visible_range (FMDirectoryView *view,
728 GtkTreePath **start_path,728 GtkTreePath **start_path,
729 GtkTreePath **end_path)729 GtkTreePath **end_path)
730730
@@ -738,7 +738,7 @@
738fm_columns_view_zoom_normal (FMDirectoryView *view)738fm_columns_view_zoom_normal (FMDirectoryView *view)
739{739{
740 MarlinZoomLevel zoom;740 MarlinZoomLevel zoom;
741 741
742 zoom = g_settings_get_enum (marlin_column_view_settings, "default-zoom-level");742 zoom = g_settings_get_enum (marlin_column_view_settings, "default-zoom-level");
743 g_settings_set_enum (marlin_column_view_settings, "zoom-level", zoom);743 g_settings_set_enum (marlin_column_view_settings, "zoom-level", zoom);
744}744}
@@ -755,7 +755,7 @@
755 gof_file_list_free (view->details->selection);755 gof_file_list_free (view->details->selection);
756756
757 g_free (view->details);757 g_free (view->details);
758 G_OBJECT_CLASS (fm_columns_view_parent_class)->finalize (object); 758 G_OBJECT_CLASS (fm_columns_view_parent_class)->finalize (object);
759}759}
760760
761static void761static void
@@ -767,8 +767,8 @@
767 create_and_set_up_tree_view (view);767 create_and_set_up_tree_view (view);
768768
769 //fm_columns_view_click_policy_changed (FM_DIRECTORY_VIEW (view));769 //fm_columns_view_click_policy_changed (FM_DIRECTORY_VIEW (view));
770 770
771 g_settings_bind (marlin_column_view_settings, "zoom-level", 771 g_settings_bind (marlin_column_view_settings, "zoom-level",
772 view, "zoom-level", 0);772 view, "zoom-level", 0);
773}773}
774774
@@ -780,7 +780,7 @@
780 gint xpad, ypad;780 gint xpad, ypad;
781781
782 gtk_cell_renderer_get_padding (view->icon_renderer, &xpad, &ypad);782 gtk_cell_renderer_get_padding (view->icon_renderer, &xpad, &ypad);
783 gtk_cell_renderer_set_fixed_size (view->icon_renderer, 783 gtk_cell_renderer_set_fixed_size (view->icon_renderer,
784 marlin_zoom_level_to_icon_size (view->zoom_level) + 2 * xpad,784 marlin_zoom_level_to_icon_size (view->zoom_level) + 2 * xpad,
785 marlin_zoom_level_to_icon_size (view->zoom_level) + 2 * ypad);785 marlin_zoom_level_to_icon_size (view->zoom_level) + 2 * ypad);
786 gtk_tree_view_columns_autosize (FM_COLUMNS_VIEW (view)->tree);786 gtk_tree_view_columns_autosize (FM_COLUMNS_VIEW (view)->tree);
@@ -801,7 +801,7 @@
801 default:801 default:
802 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);802 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
803 break;803 break;
804 } 804 }
805}805}
806806
807static void807static void
@@ -818,7 +818,7 @@
818 default:818 default:
819 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);819 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
820 break;820 break;
821 } 821 }
822}822}
823#endif823#endif
824824
@@ -835,7 +835,7 @@
835 fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (klass);835 fm_directory_view_class = FM_DIRECTORY_VIEW_CLASS (klass);
836836
837 fm_directory_view_class->sync_selection = fm_columns_view_sync_selection;837 fm_directory_view_class->sync_selection = fm_columns_view_sync_selection;
838 fm_directory_view_class->get_selection = fm_columns_view_get_selection; 838 fm_directory_view_class->get_selection = fm_columns_view_get_selection;
839 fm_directory_view_class->get_selection_for_file_transfer = fm_columns_view_get_selection_for_file_transfer;839 fm_directory_view_class->get_selection_for_file_transfer = fm_columns_view_get_selection_for_file_transfer;
840 fm_directory_view_class->get_selected_paths = fm_columns_view_get_selected_paths;840 fm_directory_view_class->get_selected_paths = fm_columns_view_get_selected_paths;
841 fm_directory_view_class->select_path = fm_columns_view_select_path;841 fm_directory_view_class->select_path = fm_columns_view_select_path;
842842
=== modified file 'src/fm-directory-view.c'
--- src/fm-directory-view.c 2013-08-01 21:24:46 +0000
+++ src/fm-directory-view.c 2013-09-01 22:36:03 +0000
@@ -118,7 +118,7 @@
118 guint thumbnail_source_id;118 guint thumbnail_source_id;
119 gboolean thumbnailing_scheduled;119 gboolean thumbnailing_scheduled;
120120
121 /* Tree path for restoring the selection after selecting and 121 /* Tree path for restoring the selection after selecting and
122 * deleting an item */122 * deleting an item */
123 GtkTreePath *selection_before_delete;123 GtkTreePath *selection_before_delete;
124 GOFFile *newly_folder_added;124 GOFFile *newly_folder_added;
@@ -229,15 +229,14 @@
229};229};
230230
231static gpointer _g_object_ref0 (gpointer self) {231static gpointer _g_object_ref0 (gpointer self) {
232 return self ? g_object_ref (self) : NULL;232 return self ? g_object_ref (self) : NULL;
233}233}
234234
235
236void fm_directory_view_colorize_selection (FMDirectoryView *view, int ncolor)235void fm_directory_view_colorize_selection (FMDirectoryView *view, int ncolor)
237{236{
238 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));237 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
239 g_return_if_fail (tags != NULL);238 g_return_if_fail (tags != NULL);
240 239
241 marlin_view_tags_set_color (tags, view, ncolor, NULL, NULL);240 marlin_view_tags_set_color (tags, view, ncolor, NULL, NULL);
242}241}
243242
@@ -266,7 +265,7 @@
266static void265static void
267file_changed_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)266file_changed_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)
268{267{
269 /*if (!file->exists) 268 /*if (!file->exists)
270 return;*/269 return;*/
271 g_return_if_fail (file != NULL);270 g_return_if_fail (file != NULL);
272 g_return_if_fail (file->exists);271 g_return_if_fail (file->exists);
@@ -280,7 +279,7 @@
280static void279static void
281file_deleted_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)280file_deleted_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)
282{281{
283 g_debug ("%s %s", G_STRFUNC, file->uri); 282 g_debug ("%s %s", G_STRFUNC, file->uri);
284 fm_list_model_remove_file (view->model, file, directory);283 fm_list_model_remove_file (view->model, file, directory);
285 /* Remove from gof-directory-async cache */284 /* Remove from gof-directory-async cache */
286 if (gof_file_is_folder (file)) {285 if (gof_file_is_folder (file)) {
@@ -291,7 +290,7 @@
291 g_debug ("Remove from gof-directory-async cache %s\n", file->uri);290 g_debug ("Remove from gof-directory-async cache %s\n", file->uri);
292 g_object_unref (dir);291 g_object_unref (dir);
293 }292 }
294 293
295 if (view->details->slot->mwcols) {294 if (view->details->slot->mwcols) {
296 /* if in miller view mode, remove any views of subdirectories of deleted directory */295 /* if in miller view mode, remove any views of subdirectories of deleted directory */
297 gtk_container_foreach (GTK_CONTAINER (view->details->slot->mwcols->active_slot->colpane), (GtkCallback) gtk_widget_destroy, NULL);296 gtk_container_foreach (GTK_CONTAINER (view->details->slot->mwcols->active_slot->colpane), (GtkCallback) gtk_widget_destroy, NULL);
@@ -312,12 +311,17 @@
312 }311 }
313 else312 else
314 dir_action_set_sensitive (view, "Select All", TRUE);313 dir_action_set_sensitive (view, "Select All", TRUE);
315 314
316 MarlinZoomLevel zoom;315 MarlinZoomLevel zoom;
317 g_object_get (view, "zoom-level", &zoom, NULL);316 g_object_get (view, "zoom-level", &zoom, NULL);
318 int size = marlin_zoom_level_to_icon_size (zoom);317 int size = marlin_zoom_level_to_icon_size (zoom);
319 gof_directory_async_threaded_load_thumbnails (view->details->slot->directory, size);318 gof_directory_async_threaded_load_thumbnails (view->details->slot->directory, size);
320 //g_signal_emit (view, signals[DIRECTORY_LOADED], 0, directory);319 //g_signal_emit (view, signals[DIRECTORY_LOADED], 0, directory);
320 /* If in Miller view, autosize the column */
321 if (view->details->slot->ready_to_autosize)
322 autosize_slot (view->details->slot);
323 else
324 view->details->slot->ready_to_autosize = TRUE;
321}325}
322326
323static void327static void
@@ -352,11 +356,11 @@
352 gof_directory_async_load_hiddens (directory);356 gof_directory_async_load_hiddens (directory);
353 g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);357 g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);
354 } else {358 } else {
355 /* while the model is cleared and re-loaded we do not want the view to update */ 359 /* while the model is cleared and re-loaded we do not want the view to update */
356 g_signal_handlers_block_by_func (view->model, fm_directory_view_row_deleted, view);360 g_signal_handlers_block_by_func (view->model, fm_directory_view_row_deleted, view);
357 g_signal_handlers_block_by_func (view->model, fm_directory_view_restore_selection, view);361 g_signal_handlers_block_by_func (view->model, fm_directory_view_restore_selection, view);
358 view->updates_frozen = TRUE;362 view->updates_frozen = TRUE;
359 363
360 /* clear the model */364 /* clear the model */
361 fm_list_model_clear (view->model);365 fm_list_model_clear (view->model);
362366
@@ -365,7 +369,7 @@
365 gof_directory_async_load (directory);369 gof_directory_async_load (directory);
366 g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);370 g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);
367371
368 /* re-instate signals and unfreeze view */ 372 /* re-instate signals and unfreeze view */
369 g_signal_handlers_unblock_by_func (view->model, fm_directory_view_row_deleted, view);373 g_signal_handlers_unblock_by_func (view->model, fm_directory_view_row_deleted, view);
370 g_signal_handlers_unblock_by_func (view->model, fm_directory_view_restore_selection, view);374 g_signal_handlers_unblock_by_func (view->model, fm_directory_view_restore_selection, view);
371 view->updates_frozen = FALSE;375 view->updates_frozen = FALSE;
@@ -384,24 +388,24 @@
384static void388static void
385fm_directory_view_connect_directory_handlers (FMDirectoryView *view, GOFDirectoryAsync *directory)389fm_directory_view_connect_directory_handlers (FMDirectoryView *view, GOFDirectoryAsync *directory)
386{390{
387 g_signal_connect (directory, "file_loaded", 391 g_signal_connect (directory, "file_loaded",
388 G_CALLBACK (file_loaded_callback), view);392 G_CALLBACK (file_loaded_callback), view);
389 g_signal_connect (directory, "file_added", 393 g_signal_connect (directory, "file_added",
390 G_CALLBACK (file_added_callback), view);394 G_CALLBACK (file_added_callback), view);
391 g_signal_connect (directory, "file_changed", 395 g_signal_connect (directory, "file_changed",
392 G_CALLBACK (file_changed_callback), view);396 G_CALLBACK (file_changed_callback), view);
393 g_signal_connect (directory, "file_deleted", 397 g_signal_connect (directory, "file_deleted",
394 G_CALLBACK (file_deleted_callback), view);398 G_CALLBACK (file_deleted_callback), view);
395 g_signal_connect (directory, "done_loading", 399 g_signal_connect (directory, "done_loading",
396 G_CALLBACK (directory_done_loading_callback), view);400 G_CALLBACK (directory_done_loading_callback), view);
397 g_signal_connect (directory, "thumbs_loaded", 401 g_signal_connect (directory, "thumbs_loaded",
398 G_CALLBACK (directory_thumbs_loaded_callback), view);402 G_CALLBACK (directory_thumbs_loaded_callback), view);
399 g_signal_connect (directory, "icon_changed", 403 g_signal_connect (directory, "icon_changed",
400 G_CALLBACK (icon_changed_callback), view);404 G_CALLBACK (icon_changed_callback), view);
401}405}
402406
403static void407static void
404fm_directory_view_disconnect_directory_handlers (FMDirectoryView *view, 408fm_directory_view_disconnect_directory_handlers (FMDirectoryView *view,
405 GOFDirectoryAsync *directory)409 GOFDirectoryAsync *directory)
406{410{
407 /*g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);*/411 /*g_signal_handlers_disconnect_by_func (directory, file_loaded_callback, view);*/
@@ -433,7 +437,7 @@
433437
434 if (!fm_directory_view_get_loading (view)) {438 if (!fm_directory_view_get_loading (view)) {
435 g_object_get (view, "zoom-level", &zoom, NULL);439 g_object_get (view, "zoom-level", &zoom, NULL);
436 gof_directory_async_queue_load_thumbnails (view->details->slot->directory, 440 gof_directory_async_queue_load_thumbnails (view->details->slot->directory,
437 marlin_zoom_level_to_icon_size (zoom));441 marlin_zoom_level_to_icon_size (zoom));
438 }442 }
439}443}
@@ -488,20 +492,25 @@
488 /* setup the list model */492 /* setup the list model */
489 g_signal_connect (view->model, "row-deleted", G_CALLBACK (fm_directory_view_row_deleted), view);493 g_signal_connect (view->model, "row-deleted", G_CALLBACK (fm_directory_view_row_deleted), view);
490 g_signal_connect_after (view->model, "row-deleted", G_CALLBACK (fm_directory_view_restore_selection), view);494 g_signal_connect_after (view->model, "row-deleted", G_CALLBACK (fm_directory_view_restore_selection), view);
491 495
492 g_signal_connect (view->model, "sort_column_changed", G_CALLBACK (sort_column_changed_callback), view);496 g_signal_connect (view->model, "sort_column_changed", G_CALLBACK (sort_column_changed_callback), view);
493497
494 /* connect to size allocation signals for generating thumbnail requests */498 /* connect to size allocation signals for generating thumbnail requests */
495 g_signal_connect_after (G_OBJECT (view), "size-allocate",499 g_signal_connect_after (G_OBJECT (view), "size-allocate",
496 G_CALLBACK (fm_directory_view_size_allocate), NULL);500 G_CALLBACK (fm_directory_view_size_allocate), NULL);
497501
498 g_signal_connect (G_OBJECT (view), "notify::zoom-level", 502 g_signal_connect (G_OBJECT (view), "notify::zoom-level",
499 G_CALLBACK (zoom_level_changed), NULL);503 G_CALLBACK (zoom_level_changed), NULL);
500504
501 view->details->dir_action_group = NULL;505 view->details->dir_action_group = NULL;
502 view->details->dir_merge_id = 0;506 view->details->dir_merge_id = 0;
503 view->details->open_with_action_group = NULL;507 view->details->open_with_action_group = NULL;
504 view->details->open_with_merge_id = 0;508 view->details->open_with_merge_id = 0;
509 view->empty_message = g_strconcat ("<span size='x-large'>",
510 _("This folder is empty."),
511 "</span>",
512 NULL);
513
505}514}
506515
507static GObject*516static GObject*
@@ -626,12 +635,12 @@
626 /* release the context menu references */635 /* release the context menu references */
627 if (view->details->menu_selection) {636 if (view->details->menu_selection) {
628 gpointer old_menuitems = g_object_get_data(G_OBJECT (view->details->menu_selection), "other_selection");637 gpointer old_menuitems = g_object_get_data(G_OBJECT (view->details->menu_selection), "other_selection");
629 g_list_free_full (old_menuitems, (GDestroyNotify) gtk_widget_destroy); 638 g_list_free_full (old_menuitems, (GDestroyNotify) gtk_widget_destroy);
630 g_object_set_data (G_OBJECT (view->details->menu_selection), "other_selection", NULL); 639 g_object_set_data (G_OBJECT (view->details->menu_selection), "other_selection", NULL);
631 }640 }
632641
633 g_free (view->details->previewer);642 g_free (view->details->previewer);
634 643
635 if (view->details->newly_folder_added)644 if (view->details->newly_folder_added)
636 g_object_unref (view->details->newly_folder_added);645 g_object_unref (view->details->newly_folder_added);
637646
@@ -672,12 +681,12 @@
672 g_signal_emit_by_name (slot->ctab, "path-changed", location);681 g_signal_emit_by_name (slot->ctab, "path-changed", location);
673}682}
674683
675/* TODO remove screen if we don't create any new windows 684/* TODO remove screen if we don't create any new windows
676** (check if we have to) */685** (check if we have to) */
677static void686static void
678fm_directory_view_activate_single_file (FMDirectoryView *view, 687fm_directory_view_activate_single_file (FMDirectoryView *view,
679 GOFFile *file, 688 GOFFile *file,
680 GdkScreen *screen, 689 GdkScreen *screen,
681 MarlinViewWindowOpenFlags flags)690 MarlinViewWindowOpenFlags flags)
682{691{
683 GFile *location;692 GFile *location;
@@ -686,7 +695,7 @@
686 location = gof_file_get_target_location (file);695 location = gof_file_get_target_location (file);
687696
688 //g_message ("%s %s %s", G_STRFUNC, file->uri, g_file_get_uri(location));697 //g_message ("%s %s %s", G_STRFUNC, file->uri, g_file_get_uri(location));
689 if (gof_file_is_folder (file)) 698 if (gof_file_is_folder (file))
690 {699 {
691 switch (flags) {700 switch (flags) {
692 case MARLIN_WINDOW_OPEN_FLAG_NEW_TAB:701 case MARLIN_WINDOW_OPEN_FLAG_NEW_TAB:
@@ -758,7 +767,7 @@
758 }767 }
759768
760 selection = fm_directory_view_get_selection (view);769 selection = fm_directory_view_get_selection (view);
761 /* FIXME only grab the first selection item as gloobus-preview is unable to handle 770 /* FIXME only grab the first selection item as gloobus-preview is unable to handle
762 multiple selection */771 multiple selection */
763 if (selection != NULL) {772 if (selection != NULL) {
764 file = selection->data;773 file = selection->data;
@@ -777,34 +786,34 @@
777 }786 }
778}787}
779788
780void 789void
781fm_directory_view_zoom_normal (FMDirectoryView *view)790fm_directory_view_zoom_normal (FMDirectoryView *view)
782{791{
783 (*FM_DIRECTORY_VIEW_GET_CLASS (view)->zoom_normal) (view);792 (*FM_DIRECTORY_VIEW_GET_CLASS (view)->zoom_normal) (view);
784}793}
785794
786void 795void
787fm_directory_view_zoom_in (FMDirectoryView *view)796fm_directory_view_zoom_in (FMDirectoryView *view)
788{797{
789 MarlinZoomLevel zoom;798 MarlinZoomLevel zoom;
790799
791 g_object_get (view, "zoom-level", &zoom, NULL);800 g_object_get (view, "zoom-level", &zoom, NULL);
792 zoom++;801 zoom++;
793 if (zoom >= MARLIN_ZOOM_LEVEL_SMALLEST 802 if (zoom >= MARLIN_ZOOM_LEVEL_SMALLEST
794 && zoom <= MARLIN_ZOOM_LEVEL_LARGEST)803 && zoom <= MARLIN_ZOOM_LEVEL_LARGEST)
795 {804 {
796 g_object_set (G_OBJECT (view), "zoom-level", zoom, NULL);805 g_object_set (G_OBJECT (view), "zoom-level", zoom, NULL);
797 }806 }
798}807}
799808
800void 809void
801fm_directory_view_zoom_out (FMDirectoryView *view)810fm_directory_view_zoom_out (FMDirectoryView *view)
802{811{
803 MarlinZoomLevel zoom;812 MarlinZoomLevel zoom;
804813
805 g_object_get (view, "zoom-level", &zoom, NULL);814 g_object_get (view, "zoom-level", &zoom, NULL);
806 zoom--;815 zoom--;
807 if (zoom >= MARLIN_ZOOM_LEVEL_SMALLEST 816 if (zoom >= MARLIN_ZOOM_LEVEL_SMALLEST
808 && zoom <= MARLIN_ZOOM_LEVEL_LARGEST)817 && zoom <= MARLIN_ZOOM_LEVEL_LARGEST)
809 {818 {
810 g_object_set (view, "zoom-level", zoom, NULL);819 g_object_set (view, "zoom-level", zoom, NULL);
@@ -816,7 +825,7 @@
816 GdkEventScroll *event)825 GdkEventScroll *event)
817{826{
818 gdouble total_delta_y = 0;827 gdouble total_delta_y = 0;
819 gdouble delta_x, delta_y;828 gdouble delta_x, delta_y;
820829
821 if (event->state & GDK_CONTROL_MASK) {830 if (event->state & GDK_CONTROL_MASK) {
822 switch (event->direction) {831 switch (event->direction) {
@@ -846,7 +855,7 @@
846 total_delta_y = 0;855 total_delta_y = 0;
847 /* emulate scroll up */856 /* emulate scroll up */
848 fm_directory_view_zoom_in (directory_view);857 fm_directory_view_zoom_in (directory_view);
849 return TRUE; 858 return TRUE;
850 } else {859 } else {
851 /* eat event */860 /* eat event */
852 return TRUE;861 return TRUE;
@@ -1013,7 +1022,7 @@
1013 //printf ("%s path %s\n", G_STRFUNC, gtk_tree_path_to_string (path));1022 //printf ("%s path %s\n", G_STRFUNC, gtk_tree_path_to_string (path));
1014 /* determine the file for the path */1023 /* determine the file for the path */
1015 file = fm_list_model_file_for_path (view->model, path);1024 file = fm_list_model_file_for_path (view->model, path);
1016 1025
1017 /* If file == NULL, it means that the path in question is a blank path,1026 /* If file == NULL, it means that the path in question is a blank path,
1018 * which can only exist under an expanded empty folder.1027 * which can only exist under an expanded empty folder.
1019 * In this case, we set the destination target to that folder. */1028 * In this case, we set the destination target to that folder. */
@@ -1143,13 +1152,13 @@
1143 /* determine the file for the drop position */1152 /* determine the file for the drop position */
1144 file = fm_directory_view_get_drop_file (view, x, y, NULL);1153 file = fm_directory_view_get_drop_file (view, x, y, NULL);
1145 g_debug ("%s XdndDirectSave0 %s", G_STRFUNC, file->uri);1154 g_debug ("%s XdndDirectSave0 %s", G_STRFUNC, file->uri);
1146 1155
1147 if (G_LIKELY (file != NULL))1156 if (G_LIKELY (file != NULL))
1148 {1157 {
1149 /* determine the file name from the DnD source window */1158 /* determine the file name from the DnD source window */
1150 if (gdk_property_get (gdk_drag_context_get_source_window (context), 1159 if (gdk_property_get (gdk_drag_context_get_source_window (context),
1151 gdk_atom_intern_static_string ("XdndDirectSave0"),1160 gdk_atom_intern_static_string ("XdndDirectSave0"),
1152 gdk_atom_intern_static_string ("text/plain"), 1161 gdk_atom_intern_static_string ("text/plain"),
1153 0, 1024, FALSE, NULL, NULL,1162 0, 1024, FALSE, NULL, NULL,
1154 &prop_len, &prop_text) && prop_text != NULL)1163 &prop_len, &prop_text) && prop_text != NULL)
1155 {1164 {
@@ -1191,7 +1200,7 @@
1191 /* release the file reference */1200 /* release the file reference */
1192 g_object_unref (G_OBJECT (file));1201 g_object_unref (G_OBJECT (file));
1193 }1202 }
1194 1203
1195 /* if uri == NULL, we didn't set the property */1204 /* if uri == NULL, we didn't set the property */
1196 if (G_UNLIKELY (uri == NULL))1205 if (G_UNLIKELY (uri == NULL))
1197 return FALSE;1206 return FALSE;
@@ -1650,7 +1659,7 @@
1650 return TRUE;1659 return TRUE;
1651}1660}
16521661
1653static gboolean 1662static gboolean
1654is_selection_contain_only_folders (GList *selection)1663is_selection_contain_only_folders (GList *selection)
1655{1664{
1656 GOFFile *file;1665 GOFFile *file;
@@ -1695,7 +1704,7 @@
1695}1704}
16961705
1697static void1706static void
1698dir_action_set_visible_sensitive (FMDirectoryView *view, const gchar *action_name, 1707dir_action_set_visible_sensitive (FMDirectoryView *view, const gchar *action_name,
1699 gboolean visible, gboolean sensitive)1708 gboolean visible, gboolean sensitive)
1700{1709{
1701 GtkAction *action;1710 GtkAction *action;
@@ -1802,7 +1811,7 @@
18021811
1803static void1812static void
1804add_application_to_open_with_menu (FMDirectoryView *view,1813add_application_to_open_with_menu (FMDirectoryView *view,
1805 GAppInfo *application, 1814 GAppInfo *application,
1806 GList *files,1815 GList *files,
1807 int index,1816 int index,
1808 const char *menu_placeholder,1817 const char *menu_placeholder,
@@ -1846,7 +1855,7 @@
18461855
1847 g_signal_connect_data (action, "activate",1856 g_signal_connect_data (action, "activate",
1848 G_CALLBACK (open_with_launch_application_callback),1857 G_CALLBACK (open_with_launch_application_callback),
1849 launch_parameters, 1858 launch_parameters,
1850 (GClosureNotify)application_launch_parameters_free, 0);1859 (GClosureNotify)application_launch_parameters_free, 0);
18511860
1852 gtk_action_group_add_action (view->details->open_with_action_group,1861 gtk_action_group_add_action (view->details->open_with_action_group,
@@ -1895,11 +1904,11 @@
1895 for (l=apps; l != NULL; l=l->next) {1904 for (l=apps; l != NULL; l=l->next) {
1896 app = (GAppInfo *) l->data;1905 app = (GAppInfo *) l->data;
1897 id1 = g_app_info_get_id (app);1906 id1 = g_app_info_get_id (app);
1898 if (id1 != NULL && id2 != NULL 1907 if (id1 != NULL && id2 != NULL
1899 && strcmp (id1, id2) == 0) 1908 && strcmp (id1, id2) == 0)
1900 {1909 {
1901 g_object_unref (app);1910 g_object_unref (app);
1902 apps = g_list_delete_link (apps, l); 1911 apps = g_list_delete_link (apps, l);
1903 }1912 }
1904 }1913 }
19051914
@@ -1925,7 +1934,7 @@
1925 selection = fm_directory_view_get_selection (view);1934 selection = fm_directory_view_get_selection (view);
1926 selection_count = g_list_length (selection);1935 selection_count = g_list_length (selection);
1927 file = GOF_FILE (selection->data);1936 file = GOF_FILE (selection->data);
1928 1937
1929 if (file == NULL) {1938 if (file == NULL) {
1930 update_menus_empty_selection (view);1939 update_menus_empty_selection (view);
1931 return;1940 return;
@@ -1988,7 +1997,7 @@
1988 /* Only force displaying the icon if it is an application icon */1997 /* Only force displaying the icon if it is an application icon */
1989 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), app_icon != NULL);1998 gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), app_icon != NULL);
19901999
1991 if (app_icon == NULL) 2000 if (app_icon == NULL)
1992 app_icon = g_themed_icon_new (GTK_STOCK_OPEN);2001 app_icon = g_themed_icon_new (GTK_STOCK_OPEN);
19932002
1994 gtk_action_set_gicon (action, app_icon);2003 gtk_action_set_gicon (action, app_icon);
@@ -2006,7 +2015,7 @@
2006 g_free (mnemonic);2015 g_free (mnemonic);
20072016
2008 /* OpenAlternate label update */2017 /* OpenAlternate label update */
2009 if (selection_count > 1) 2018 if (selection_count > 1)
2010 mnemonic = g_strdup_printf (_("Open in %'d New _Windows"), selection_count);2019 mnemonic = g_strdup_printf (_("Open in %'d New _Windows"), selection_count);
2011 else2020 else
2012 mnemonic = NULL;2021 mnemonic = NULL;
@@ -2022,8 +2031,8 @@
20222031
2023 /* if there s no default app then there s no common possible type to get other applications.2032 /* if there s no default app then there s no common possible type to get other applications.
2024 checking the first file is enought to determine if we have a full directory selection2033 checking the first file is enought to determine if we have a full directory selection
2025 as the only possible common type for a directory is a directory. 2034 as the only possible common type for a directory is a directory.
2026 We don't want File Managers applications list in the open with menu for a directory(ies) 2035 We don't want File Managers applications list in the open with menu for a directory(ies)
2027 selection */2036 selection */
2028 if (view->details->open_with_apps != NULL) {2037 if (view->details->open_with_apps != NULL) {
2029 g_list_free_full (view->details->open_with_apps, g_object_unref);2038 g_list_free_full (view->details->open_with_apps, g_object_unref);
@@ -2032,16 +2041,16 @@
2032 if (view->details->default_app != NULL && !gof_file_is_folder (file))2041 if (view->details->default_app != NULL && !gof_file_is_folder (file))
2033 view->details->open_with_apps = marlin_mime_get_applications_for_files (selection);2042 view->details->open_with_apps = marlin_mime_get_applications_for_files (selection);
2034 /* we need to remove the default app from open with menu */2043 /* we need to remove the default app from open with menu */
2035 if (view->details->default_app != NULL && !gof_file_is_executable (file)) 2044 if (view->details->default_app != NULL && !gof_file_is_executable (file))
2036 view->details->open_with_apps = filter_default_app (view->details->open_with_apps, view->details->default_app);2045 view->details->open_with_apps = filter_default_app (view->details->open_with_apps, view->details->default_app);
2037 for (l = view->details->open_with_apps, index=0; l != NULL && index <10; l=l->next, index++) {2046 for (l = view->details->open_with_apps, index=0; l != NULL && index <10; l=l->next, index++) {
2038 add_application_to_open_with_menu (view, 2047 add_application_to_open_with_menu (view,
2039 l->data, 2048 l->data,
2040 selection,2049 selection,
2041 index,2050 index,
2042 menu_path, popup_path);2051 menu_path, popup_path);
2043 }2052 }
2044 2053
2045 if (selection_count == 1 && !gof_file_is_folder (file))2054 if (selection_count == 1 && !gof_file_is_folder (file))
2046 dir_action_set_visible (view, "OtherApplication", TRUE);2055 dir_action_set_visible (view, "OtherApplication", TRUE);
2047}2056}
@@ -2203,7 +2212,7 @@
2203 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2212 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
2204 g_return_if_fail (view->model == model);2213 g_return_if_fail (view->model == model);
22052214
2206 g_message ("%s", G_STRFUNC);2215 g_debug ("%s", G_STRFUNC);
2207 /* Get tree paths of selected files */2216 /* Get tree paths of selected files */
2208 selected_paths = (*FM_DIRECTORY_VIEW_GET_CLASS (view)->get_selected_paths) (view);2217 selected_paths = (*FM_DIRECTORY_VIEW_GET_CLASS (view)->get_selected_paths) (view);
22092218
@@ -2220,7 +2229,7 @@
2220 /* Create a copy the path (we're not allowed to modify it in this handler) */2229 /* Create a copy the path (we're not allowed to modify it in this handler) */
2221 path_copy = gtk_tree_path_copy (path);2230 path_copy = gtk_tree_path_copy (path);
22222231
2223 /* Remember the selected path so that it can be restored after the row has 2232 /* Remember the selected path so that it can be restored after the row has
2224 * been removed. If the first row is removed, select the first row after the2233 * been removed. If the first row is removed, select the first row after the
2225 * removal, if any other row is removed, select the row before that one */2234 * removal, if any other row is removed, select the row before that one */
2226 gtk_tree_path_prev (path_copy);2235 gtk_tree_path_prev (path_copy);
@@ -2238,8 +2247,8 @@
2238 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2247 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
2239 g_return_if_fail (view->model == model);2248 g_return_if_fail (view->model == model);
22402249
2241 g_message ("%s", G_STRFUNC);2250 g_debug ("%s", G_STRFUNC);
2242 /* Check if there was only one file selected before the row was deleted. The 2251 /* Check if there was only one file selected before the row was deleted. The
2243 * path is set by thunar_standard_view_row_deleted() if this is the case */2252 * path is set by thunar_standard_view_row_deleted() if this is the case */
2244 if (G_LIKELY (view->details->selection_before_delete != NULL))2253 if (G_LIKELY (view->details->selection_before_delete != NULL))
2245 {2254 {
@@ -2257,11 +2266,11 @@
2257 }2266 }
2258}2267}
22592268
2260void 2269void
2261fm_directory_view_select_first_for_empty_selection (FMDirectoryView *view)2270fm_directory_view_select_first_for_empty_selection (FMDirectoryView *view)
2262{2271{
2263 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2272 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
2264 2273
2265 GList *selection = fm_directory_view_get_selection (view);2274 GList *selection = fm_directory_view_get_selection (view);
22662275
2267 if (!selection) {2276 if (!selection) {
@@ -2273,7 +2282,7 @@
2273}2282}
22742283
2275#if 02284#if 0
2276void 2285void
2277fm_directory_view_select_gof_file (FMDirectoryView *view, GOFFile *file)2286fm_directory_view_select_gof_file (FMDirectoryView *view, GOFFile *file)
2278{2287{
2279 GtkTreeIter iter;2288 GtkTreeIter iter;
@@ -2282,7 +2291,7 @@
2282 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2291 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
22832292
2284 if (!fm_list_model_get_first_iter_for_file (view->model, file, &iter))2293 if (!fm_list_model_get_first_iter_for_file (view->model, file, &iter))
2285 return;2294 return;
22862295
2287 path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->model), &iter);2296 path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->model), &iter);
2288 (*FM_DIRECTORY_VIEW_GET_CLASS (view)->set_cursor) (view, path, FALSE, TRUE);2297 (*FM_DIRECTORY_VIEW_GET_CLASS (view)->set_cursor) (view, path, FALSE, TRUE);
@@ -2290,7 +2299,7 @@
2290}2299}
2291#endif2300#endif
22922301
2293void 2302void
2294fm_directory_view_select_glib_files (FMDirectoryView *view, GList *files)2303fm_directory_view_select_glib_files (FMDirectoryView *view, GList *files)
2295{2304{
2296 GList *l;2305 GList *l;
@@ -2326,10 +2335,10 @@
2326 error = NULL;2335 error = NULL;
2327 res = g_file_set_attributes_finish (G_FILE (source_object), result, NULL, &error);2336 res = g_file_set_attributes_finish (G_FILE (source_object), result, NULL, &error);
23282337
2329 if (error != NULL) {2338 if (error != NULL) {
2330 g_critical ("%s error, %s", G_STRFUNC, error->message);2339 g_critical ("%s error, %s", G_STRFUNC, error->message);
2331 g_error_free (error);2340 g_error_free (error);
2332 }2341 }
2333}2342}
23342343
2335static void2344static void
@@ -2354,7 +2363,7 @@
2354 current_dir->file->sort_column_id = sort_column_id;2363 current_dir->file->sort_column_id = sort_column_id;
2355 current_dir->file->sort_order = sort_order;2364 current_dir->file->sort_order = sort_order;
2356 location = g_object_ref (current_dir->location);2365 location = g_object_ref (current_dir->location);
2357 g_file_set_attributes_async (location, info, 0, G_PRIORITY_DEFAULT, NULL, 2366 g_file_set_attributes_async (location, info, 0, G_PRIORITY_DEFAULT, NULL,
2358 set_metadata_callback, NULL);2367 set_metadata_callback, NULL);
2359 g_object_unref (location);2368 g_object_unref (location);
2360 g_object_unref (info);2369 g_object_unref (info);
@@ -2395,7 +2404,7 @@
2395 return view->details->slot->directory;2404 return view->details->slot->directory;
2396}2405}
23972406
2398static int 2407static int
2399fm_directory_view_get_uri_keypath_size (FMDirectoryView *view)2408fm_directory_view_get_uri_keypath_size (FMDirectoryView *view)
2400{2409{
2401 GOFDirectoryAsync *dir = fm_directory_view_get_current_directory (view);2410 GOFDirectoryAsync *dir = fm_directory_view_get_current_directory (view);
@@ -2436,8 +2445,8 @@
2436 fm_directory_view_cancel_thumbnailing (view);2445 fm_directory_view_cancel_thumbnailing (view);
24372446
2438 /* schedule the timeout handler */2447 /* schedule the timeout handler */
2439 view->details->thumbnail_source_id = 2448 view->details->thumbnail_source_id =
2440 g_timeout_add (175, (GSourceFunc) fm_directory_view_request_thumbnails, 2449 g_timeout_add (175, (GSourceFunc) fm_directory_view_request_thumbnails,
2441 view);2450 view);
2442}2451}
24432452
@@ -2481,7 +2490,7 @@
2481 /* only ask thumbnails once per file */2490 /* only ask thumbnails once per file */
2482 if (file->flags == 0) {2491 if (file->flags == 0) {
2483 files = g_list_prepend (files, g_object_ref (file));2492 files = g_list_prepend (files, g_object_ref (file));
2484 } 2493 }
24852494
2486 g_object_unref (file);2495 g_object_unref (file);
2487 }2496 }
@@ -2682,12 +2691,12 @@
26822691
2683 locations = g_list_reverse (locations);2692 locations = g_list_reverse (locations);
26842693
2685 if (locations != NULL) { 2694 if (locations != NULL) {
2686 marlin_file_operations_trash_or_delete (locations,2695 marlin_file_operations_trash_or_delete (locations,
2687 GTK_WINDOW (view->details->window),2696 GTK_WINDOW (view->details->window),
2688 (MarlinDeleteCallback) trash_or_delete_done_cb,2697 (MarlinDeleteCallback) trash_or_delete_done_cb,
2689 view);2698 view);
2690 } 2699 }
2691 else2700 else
2692 return;2701 return;
26932702
@@ -2709,8 +2718,8 @@
2709 trash_or_delete_files (view, selection, TRUE);2718 trash_or_delete_files (view, selection, TRUE);
2710 gof_file_list_free (selection);2719 gof_file_list_free (selection);
2711 view->details->selection_was_removed = TRUE;2720 view->details->selection_was_removed = TRUE;
2712 } 2721 }
2713 else 2722 else
2714 return;2723 return;
2715 }2724 }
2716}2725}
@@ -2829,13 +2838,13 @@
28292838
2830 slot = GOF_WINDOW_SLOT (g_value_get_object (value));2839 slot = GOF_WINDOW_SLOT (g_value_get_object (value));
2831 window = marlin_view_view_container_get_window (MARLIN_VIEW_VIEW_CONTAINER(slot->ctab));2840 window = marlin_view_view_container_get_window (MARLIN_VIEW_VIEW_CONTAINER(slot->ctab));
2832 2841
2833 view->details->slot = g_object_ref(slot);2842 view->details->slot = g_object_ref(slot);
2834 view->details->window = window;2843 view->details->window = window;
28352844
2836 g_signal_handlers_block_by_func (view->model, sort_column_changed_callback, view);2845 g_signal_handlers_block_by_func (view->model, sort_column_changed_callback, view);
2837 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->model), 2846 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (view->model),
2838 slot->directory->file->sort_column_id, 2847 slot->directory->file->sort_column_id,
2839 slot->directory->file->sort_order);2848 slot->directory->file->sort_order);
2840 g_signal_handlers_unblock_by_func (view->model, sort_column_changed_callback, view);2849 g_signal_handlers_unblock_by_func (view->model, sort_column_changed_callback, view);
28412850
@@ -2844,15 +2853,15 @@
2844 G_CALLBACK (show_hidden_files_changed), view, 0);2853 G_CALLBACK (show_hidden_files_changed), view, 0);
2845 g_signal_connect_object (gof_preferences_get_default (), "notify::interpret-desktop-files",2854 g_signal_connect_object (gof_preferences_get_default (), "notify::interpret-desktop-files",
2846 G_CALLBACK (show_desktop_files_changed), view, 0);2855 G_CALLBACK (show_desktop_files_changed), view, 0);
2847 2856
2848 2857
2849 fm_directory_view_connect_directory_handlers (view, slot->directory);2858 fm_directory_view_connect_directory_handlers (view, slot->directory);
2850 2859
2851 g_signal_connect_object (view->details->slot, "active", 2860 g_signal_connect_object (view->details->slot, "active",
2852 G_CALLBACK (slot_active), view, 0);2861 G_CALLBACK (slot_active), view, 0);
2853 g_signal_connect_object (view->details->slot, "inactive", 2862 g_signal_connect_object (view->details->slot, "inactive",
2854 G_CALLBACK (slot_inactive), view, 0);2863 G_CALLBACK (slot_inactive), view, 0);
2855 2864
28562865
2857 break;2866 break;
2858 case PROP_ZOOM_LEVEL:2867 case PROP_ZOOM_LEVEL:
@@ -2972,7 +2981,7 @@
2972GtkUIManager *2981GtkUIManager *
2973fm_directory_view_get_ui_manager (FMDirectoryView *view)2982fm_directory_view_get_ui_manager (FMDirectoryView *view)
2974{2983{
2975 if (view->details->window == NULL) 2984 if (view->details->window == NULL)
2976 return NULL;2985 return NULL;
29772986
2978 return MARLIN_VIEW_WINDOW (view->details->window)->ui;2987 return MARLIN_VIEW_WINDOW (view->details->window)->ui;
@@ -2998,14 +3007,14 @@
2998}3007}
29993008
3000void3009void
3001fm_directory_view_notify_item_hovered (FMDirectoryView *view, GtkTreePath *path) 3010fm_directory_view_notify_item_hovered (FMDirectoryView *view, GtkTreePath *path)
3002{3011{
3003 GOFFile *file = NULL;3012 GOFFile *file = NULL;
30043013
3005 if (path != NULL) 3014 if (path != NULL)
3006 file = fm_list_model_file_for_path (view->model, path);3015 file = fm_list_model_file_for_path (view->model, path);
3007 g_signal_emit_by_name (MARLIN_VIEW_WINDOW (view->details->window), "item_hovered", file);3016 g_signal_emit_by_name (MARLIN_VIEW_WINDOW (view->details->window), "item_hovered", file);
3008 if (file != NULL) 3017 if (file != NULL)
3009 g_object_unref (file);3018 g_object_unref (file);
3010}3019}
30113020
@@ -3018,12 +3027,12 @@
3018 view->details->selection_was_removed = FALSE;3027 view->details->selection_was_removed = FALSE;
3019 if (!gtk_widget_get_realized (GTK_WIDGET (view)))3028 if (!gtk_widget_get_realized (GTK_WIDGET (view)))
3020 return;3029 return;
3021 if (view->updates_frozen)3030 if (view->updates_frozen)
3022 return;3031 return;
3023 /* when we're in column view ignore selection changed from other slot than the active one */3032 /* when we're in column view ignore selection changed from other slot than the active one */
3024 if (view->details->slot->mwcols && 3033 if (view->details->slot->mwcols != NULL &&
3025 view->details->slot->mwcols->active_slot != view->details->slot)3034 view->details->slot->mwcols->active_slot != view->details->slot)
3026 return;3035 return;
30273036
3028 //g_message ("%s %s", G_STRFUNC, view->details->slot->directory->file->uri);3037 //g_message ("%s %s", G_STRFUNC, view->details->slot->directory->file->uri);
3029 selection = fm_directory_view_get_selection (view);3038 selection = fm_directory_view_get_selection (view);
@@ -3036,9 +3045,9 @@
3036{3045{
3037 fm_directory_view_notify_selection_changed (view);3046 fm_directory_view_notify_selection_changed (view);
30383047
3039 /* We could optimize this by redrawing only the old and the new 3048 /* We could optimize this by redrawing only the old and the new
3040 * clipboard selection by emitting row-changed on the model but the icon view3049 * clipboard selection by emitting row-changed on the model but the icon view
3041 * handle this situation very badly by recomputing all the layout. 3050 * handle this situation very badly by recomputing all the layout.
3042 */3051 */
3043 gtk_widget_queue_draw (GTK_WIDGET (view));3052 gtk_widget_queue_draw (GTK_WIDGET (view));
3044}3053}
@@ -3046,7 +3055,7 @@
3046void3055void
3047fm_directory_view_set_active_slot (FMDirectoryView *view)3056fm_directory_view_set_active_slot (FMDirectoryView *view)
3048{3057{
3049 g_warning ("%s %s %s", G_STRFUNC, 3058 g_warning ("%s %s %s", G_STRFUNC,
3050 view->details->slot->mwcols->active_slot->directory->file->uri,3059 view->details->slot->mwcols->active_slot->directory->file->uri,
3051 view->details->slot->directory->file->uri3060 view->details->slot->directory->file->uri
3052 );3061 );
@@ -3108,7 +3117,7 @@
3108 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));3117 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
31093118
3110 view->updates_frozen = TRUE;3119 view->updates_frozen = TRUE;
3111 3120
3112 /* disable clipboard actions */3121 /* disable clipboard actions */
3113 dir_action_set_sensitive (view, "Cut", FALSE);3122 dir_action_set_sensitive (view, "Cut", FALSE);
3114 dir_action_set_sensitive (view, "Copy", FALSE);3123 dir_action_set_sensitive (view, "Copy", FALSE);
@@ -3119,7 +3128,7 @@
3119 /* TODO remove this blocker */3128 /* TODO remove this blocker */
3120 /* block thumbnails request on size allocate */3129 /* block thumbnails request on size allocate */
3121 g_signal_handlers_block_by_func (view, fm_directory_view_size_allocate, NULL);3130 g_signal_handlers_block_by_func (view, fm_directory_view_size_allocate, NULL);
3122 3131
3123 /* block clipboard change trigerring update_menus */3132 /* block clipboard change trigerring update_menus */
3124 g_signal_handlers_block_by_func (view, fm_directory_view_clipboard_changed, NULL);3133 g_signal_handlers_block_by_func (view, fm_directory_view_clipboard_changed, NULL);
31253134
@@ -3139,7 +3148,7 @@
31393148
3140 /* unblock thumbnails request on size allocate */3149 /* unblock thumbnails request on size allocate */
3141 g_signal_handlers_unblock_by_func (view, fm_directory_view_size_allocate, NULL);3150 g_signal_handlers_unblock_by_func (view, fm_directory_view_size_allocate, NULL);
3142 3151
3143 /* unblock clipboard change trigerring update_menus */3152 /* unblock clipboard change trigerring update_menus */
3144 g_signal_handlers_unblock_by_func (view, fm_directory_view_clipboard_changed, NULL);3153 g_signal_handlers_unblock_by_func (view, fm_directory_view_clipboard_changed, NULL);
31453154
@@ -3255,7 +3264,7 @@
3255static void3264static void
3256check_newly_file_added_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)3265check_newly_file_added_callback (GOFDirectoryAsync *directory, GOFFile *file, FMDirectoryView *view)
3257{3266{
3258 if (file->is_directory && g_file_equal (file->location, view->details->newly_folder_added->location)) 3267 if (file->is_directory && g_file_equal (file->location, view->details->newly_folder_added->location))
3259 {3268 {
3260 g_signal_handlers_disconnect_by_func (directory,3269 g_signal_handlers_disconnect_by_func (directory,
3261 G_CALLBACK (check_newly_file_added_callback),3270 G_CALLBACK (check_newly_file_added_callback),
@@ -3267,7 +3276,7 @@
3267#endif3276#endif
32683277
3269static gboolean3278static gboolean
3270rename_file_callback (FMDirectoryView *view) 3279rename_file_callback (FMDirectoryView *view)
3271{3280{
3272 rename_file (view, view->details->newly_folder_added);3281 rename_file (view, view->details->newly_folder_added);
3273 g_object_unref (view->details->newly_folder_added);3282 g_object_unref (view->details->newly_folder_added);
@@ -3285,9 +3294,9 @@
3285 g_object_unref (view->details->newly_folder_added);3294 g_object_unref (view->details->newly_folder_added);
3286 view->details->newly_folder_added = gof_file_get (new_folder);3295 view->details->newly_folder_added = gof_file_get (new_folder);
32873296
3288 /*g_signal_connect_data (view->details->slot->directory, 3297 /*g_signal_connect_data (view->details->slot->directory,
3289 "file_added", 3298 "file_added",
3290 G_CALLBACK (check_newly_file_added_callback), 3299 G_CALLBACK (check_newly_file_added_callback),
3291 g_object_ref (view),3300 g_object_ref (view),
3292 (GClosureNotify)g_object_unref,3301 (GClosureNotify)g_object_unref,
3293 G_CONNECT_AFTER);*/3302 G_CONNECT_AFTER);*/
@@ -3326,7 +3335,7 @@
3326 GOFFile *source)3335 GOFFile *source)
3327{3336{
3328 //GdkPoint *pos;3337 //GdkPoint *pos;
3329 /*NewFolderData *data;3338 /*NewFolderData *data;
3330 char *source_uri;*/3339 char *source_uri;*/
3331 char *current_dir_uri;3340 char *current_dir_uri;
33323341
@@ -3351,10 +3360,10 @@
3351 g_return_if_fail (nautilus_file_is_local (source));3360 g_return_if_fail (nautilus_file_is_local (source));
3352g_return_if_fail (nautilus_file_is_local (source));3361g_return_if_fail (nautilus_file_is_local (source));
3353 //pos = context_menu_to_file_operation_position (directory_view);3362 //pos = context_menu_to_file_operation_position (directory_view);
3354 data = setup_new_folder_data (directory_view);3363 data = setup_new_folder_data (directory_view);
3355 source_uri = nautilus_file_get_uri (source);3364 source_uri = nautilus_file_get_uri (source);
33563365
3357 marlin_file_operations_new_file_from_template (GTK_WIDGET (directory_view),3366 marlin_file_operations_new_file_from_template (GTK_WIDGET (directory_view),
3358 pos,3367 pos,
3359 parent_uri != NULL ? parent_uri : container_uri,3368 parent_uri != NULL ? parent_uri : container_uri,
3360 NULL,3369 NULL,
@@ -3421,17 +3430,17 @@
3421 g_assert (selection != NULL);3430 g_assert (selection != NULL);
34223431
3423 file = GOF_FILE (selection->data);3432 file = GOF_FILE (selection->data);
3424 gof_file_ref (file);3433 gof_file_ref (file);
34253434
3426 dialog = gtk_app_chooser_dialog_new (GTK_WINDOW (view->details->window), 0, file->location);3435 dialog = gtk_app_chooser_dialog_new (GTK_WINDOW (view->details->window), 0, file->location);
3427 GtkWidget *check_default = gtk_check_button_new_with_label(_("Set as default"));3436 GtkWidget *check_default = gtk_check_button_new_with_label(_("Set as default"));
3428 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), check_default, FALSE, FALSE, 0);3437 gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), check_default, FALSE, FALSE, 0);
3429 gtk_widget_show_all (dialog);3438 gtk_widget_show_all (dialog);
34303439
3431 int response = gtk_dialog_run (GTK_DIALOG (dialog));3440 int response = gtk_dialog_run (GTK_DIALOG (dialog));
3432 if(response == GTK_RESPONSE_OK)3441 if(response == GTK_RESPONSE_OK)
3433 {3442 {
3434 app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (GTK_DIALOG (dialog)));3443 app = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (GTK_DIALOG (dialog)));
3435 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_default)))3444 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_default)))
3436 {3445 {
3437 GError* error = NULL;3446 GError* error = NULL;
@@ -3441,14 +3450,14 @@
3441 g_clear_error (&error);3450 g_clear_error (&error);
3442 }3451 }
3443 }3452 }
3444 3453
3445 gof_files_launch_with (selection,3454 gof_files_launch_with (selection,
3446 eel_gtk_widget_get_screen (GTK_WIDGET (view)),3455 eel_gtk_widget_get_screen (GTK_WIDGET (view)),
3447 app);3456 app);
3448 }3457 }
34493458
3450 gtk_widget_destroy (GTK_WIDGET (dialog));3459 gtk_widget_destroy (GTK_WIDGET (dialog));
3451 gof_file_unref (file);3460 gof_file_unref (file);
3452}3461}
34533462
3454static void3463static void
@@ -3457,7 +3466,7 @@
3457 g_assert (FM_IS_DIRECTORY_VIEW (view));3466 g_assert (FM_IS_DIRECTORY_VIEW (view));
34583467
3459 GList *selection = fm_directory_view_get_selection (view);3468 GList *selection = fm_directory_view_get_selection (view);
3460 3469
3461 if (selection != NULL) {3470 if (selection != NULL) {
3462 /* The reference counts of the selection list's members are incremented,3471 /* The reference counts of the selection list's members are incremented,
3463 * so that the members aren't freed by the properties window. */3472 * so that the members aren't freed by the properties window. */
@@ -3534,11 +3543,11 @@
3534 /* tooltip */ N_("Delete each selected item, without moving to the Trash"),3543 /* tooltip */ N_("Delete each selected item, without moving to the Trash"),
3535 G_CALLBACK (action_delete_callback) },3544 G_CALLBACK (action_delete_callback) },
3536 /* name, stock id */ { "Restore From Trash", NULL,3545 /* name, stock id */ { "Restore From Trash", NULL,
3537 /* label, accelerator */ N_("_Restore"), NULL, 3546 /* label, accelerator */ N_("_Restore"), NULL,
3538 NULL,3547 NULL,
3539 G_CALLBACK (action_restore_from_trash_callback) },3548 G_CALLBACK (action_restore_from_trash_callback) },
3540 /* name, stock id */ { "Select All", NULL,3549 /* name, stock id */ { "Select All", NULL,
3541 /* label, accelerator */ N_("Select All"), "<control>A", 3550 /* label, accelerator */ N_("Select All"), "<control>A",
3542 NULL,3551 NULL,
3543 G_CALLBACK (action_select_all) },3552 G_CALLBACK (action_select_all) },
3544 /* name, stock id */ { "Properties", GTK_STOCK_PROPERTIES,3553 /* name, stock id */ { "Properties", GTK_STOCK_PROPERTIES,
@@ -3554,7 +3563,7 @@
3554{3563{
3555 GtkUIManager *ui_manager;3564 GtkUIManager *ui_manager;
35563565
3557 if (view->details->window == NULL) 3566 if (view->details->window == NULL)
3558 return;3567 return;
3559 if (view->details->dir_action_group == NULL)3568 if (view->details->dir_action_group == NULL)
3560 return;3569 return;
@@ -3638,7 +3647,7 @@
3638 /* we have to make sure that we add our custom widget once in the menu */3647 /* we have to make sure that we add our custom widget once in the menu */
3639 static gboolean selection_menu_builded = FALSE;3648 static gboolean selection_menu_builded = FALSE;
36403649
3641 if (!selection_menu_builded) 3650 if (!selection_menu_builded)
3642 {3651 {
3643 GtkWidget *item;3652 GtkWidget *item;
36443653
36453654
=== modified file 'src/fm-directory-view.h'
--- src/fm-directory-view.h 2013-02-08 00:58:30 +0000
+++ src/fm-directory-view.h 2013-09-01 22:36:03 +0000
@@ -19,8 +19,8 @@
19 * Boston, MA 02111-1307, USA.19 * Boston, MA 02111-1307, USA.
20 *20 *
21 * Authors: Ettore Perazzoli21 * Authors: Ettore Perazzoli
22 * Darin Adler <darin@bentspoon.com>22 * Darin Adler <darin@bentspoon.com>
23 * John Sullivan <sullivan@eazel.com>23 * John Sullivan <sullivan@eazel.com>
24 * Pavel Cisler <pavel@eazel.com>24 * Pavel Cisler <pavel@eazel.com>
25 */25 */
2626
@@ -65,7 +65,7 @@
65 GtkCellRenderer *name_renderer;65 GtkCellRenderer *name_renderer;
66 MarlinZoomLevel zoom_level;66 MarlinZoomLevel zoom_level;
67 gboolean updates_frozen;67 gboolean updates_frozen;
6868 const gchar* empty_message;
69 FMDirectoryViewDetails *details;69 FMDirectoryViewDetails *details;
70};70};
7171
@@ -75,24 +75,24 @@
75 /* The 'clear' signal is emitted to empty the view of its contents.75 /* The 'clear' signal is emitted to empty the view of its contents.
76 * It must be replaced by each subclass.76 * It must be replaced by each subclass.
77 */77 */
78 // void (* clear) (FMDirectoryView *view);78 // void (* clear) (FMDirectoryView *view);
7979
80 /* The 'begin_file_changes' signal is emitted before a set of files80 /* The 'begin_file_changes' signal is emitted before a set of files
81 * are added to the view. It can be replaced by a subclass to do any 81 * are added to the view. It can be replaced by a subclass to do any
82 * necessary preparation for a set of new files. The default82 * necessary preparation for a set of new files. The default
83 * implementation does nothing.83 * implementation does nothing.
84 */84 */
85 //void (* begin_file_changes) (FMDirectoryView *view);85 //void (* begin_file_changes) (FMDirectoryView *view);
8686
87 /* The 'add_file' signal is emitted to add one file to the view.87 /* The 'add_file' signal is emitted to add one file to the view.
88 * It must be replaced by each subclass.88 * It must be replaced by each subclass.
89 */89 */
90 void (* add_file) (FMDirectoryView *view, 90 void (* add_file) (FMDirectoryView *view,
91 GOFFile *file,91 GOFFile *file,
92 GOFDirectoryAsync *directory);92 GOFDirectoryAsync *directory);
93 void (* directory_loaded) (FMDirectoryView *view, 93 void (* directory_loaded) (FMDirectoryView *view,
94 GOFDirectoryAsync *directory);94 GOFDirectoryAsync *directory);
95 void (* sync_selection) (FMDirectoryView *view);95 void (* sync_selection) (FMDirectoryView *view);
9696
9797
98#if 098#if 0
@@ -100,29 +100,29 @@
100 * including the file being removed.100 * including the file being removed.
101 * It must be replaced by each subclass.101 * It must be replaced by each subclass.
102 */102 */
103 void (* file_changed) (FMDirectoryView *view, 103 void (* file_changed) (FMDirectoryView *view,
104 GOFFile *file,104 GOFFile *file,
105 GOFDirectoryAsync *directory);105 GOFDirectoryAsync *directory);
106106
107 /* The 'end_file_changes' signal is emitted after a set of files107 /* The 'end_file_changes' signal is emitted after a set of files
108 * are added to the view. It can be replaced by a subclass to do any 108 * are added to the view. It can be replaced by a subclass to do any
109 * necessary cleanup (typically, cleanup for code in begin_file_changes).109 * necessary cleanup (typically, cleanup for code in begin_file_changes).
110 * The default implementation does nothing.110 * The default implementation does nothing.
111 */111 */
112 //void (* end_file_changes) (FMDirectoryView *view);112 //void (* end_file_changes) (FMDirectoryView *view);
113113
114 //void (* flush_added_files) (FMDirectoryView *view);114 //void (* flush_added_files) (FMDirectoryView *view);
115115
116 /* The 'begin_loading' signal is emitted before any of the contents116 /* The 'begin_loading' signal is emitted before any of the contents
117 * of a directory are added to the view. It can be replaced by a 117 * of a directory are added to the view. It can be replaced by a
118 * subclass to do any necessary preparation to start dealing with a118 * subclass to do any necessary preparation to start dealing with a
119 * new directory. The default implementation does nothing.119 * new directory. The default implementation does nothing.
120 */120 */
121 void (* begin_loading) (FMDirectoryView *view);121 void (* begin_loading) (FMDirectoryView *view);
122122
123 /* The 'end_loading' signal is emitted after all of the contents123 /* The 'end_loading' signal is emitted after all of the contents
124 * of a directory are added to the view. It can be replaced by a 124 * of a directory are added to the view. It can be replaced by a
125 * subclass to do any necessary clean-up. The default implementation 125 * subclass to do any necessary clean-up. The default implementation
126 * does nothing.126 * does nothing.
127 *127 *
128 * If all_files_seen is true, the handler may assume that128 * If all_files_seen is true, the handler may assume that
@@ -132,12 +132,12 @@
132 * Otherwise, end_loading was emitted due to cancellation,132 * Otherwise, end_loading was emitted due to cancellation,
133 * which usually means that not all files are available.133 * which usually means that not all files are available.
134 */134 */
135 void (* end_loading) (FMDirectoryView *view,135 void (* end_loading) (FMDirectoryView *view,
136 gboolean all_files_seen);136 gboolean all_files_seen);
137137
138 /* The 'load_error' signal is emitted when the directory model138 /* The 'load_error' signal is emitted when the directory model
139 * reports an error in the process of monitoring the directory's139 * reports an error in the process of monitoring the directory's
140 * contents. The load error indicates that the process of 140 * contents. The load error indicates that the process of
141 * loading the contents has ended, but the directory is still141 * loading the contents has ended, but the directory is still
142 * being monitored. The default implementation handles common142 * being monitored. The default implementation handles common
143 * load failures like ACCESS_DENIED.143 * load failures like ACCESS_DENIED.
@@ -147,11 +147,11 @@
147147
148 /* Function pointers that don't have corresponding signals */148 /* Function pointers that don't have corresponding signals */
149149
150 /* reset_to_defaults is a function pointer that subclasses must 150 /* reset_to_defaults is a function pointer that subclasses must
151 * override to set sort order, zoom level, etc to match default151 * override to set sort order, zoom level, etc to match default
152 * values. 152 * values.
153 */153 */
154 void (* reset_to_defaults) (FMDirectoryView *view);154 void (* reset_to_defaults) (FMDirectoryView *view);
155#endif155#endif
156156
157 /* get_selection is not a signal; it is just a function pointer for157 /* get_selection is not a signal; it is just a function pointer for
@@ -159,7 +159,7 @@
159 * with a function that returns a newly-allocated GList of159 * with a function that returns a newly-allocated GList of
160 * GOFFile pointers.160 * GOFFile pointers.
161 */161 */
162 GList * (* get_selection) (FMDirectoryView *view);162 GList * (* get_selection) (FMDirectoryView *view);
163163
164 /* get_selection_for_file_transfer is a function pointer for164 /* get_selection_for_file_transfer is a function pointer for
165 * subclasses to replace (override). Subclasses must replace it165 * subclasses to replace (override). Subclasses must replace it
@@ -168,11 +168,11 @@
168 * that any files in the selection that also has a parent folder168 * that any files in the selection that also has a parent folder
169 * in the selection is not included.169 * in the selection is not included.
170 */170 */
171 GList * (* get_selection_for_file_transfer)(FMDirectoryView *view);171 GList * (* get_selection_for_file_transfer)(FMDirectoryView *view);
172172
173 /* Returns the list of currently selected GtkTreePath's, where173 /* Returns the list of currently selected GtkTreePath's, where
174 * both the list and the items are owned by the caller. */174 * both the list and the items are owned by the caller. */
175 GList * (* get_selected_paths) (FMDirectoryView *view);175 GList * (* get_selected_paths) (FMDirectoryView *view);
176176
177 /* Selects the given item */177 /* Selects the given item */
178 void (*select_path) (FMDirectoryView *view, GtkTreePath *path);178 void (*select_path) (FMDirectoryView *view, GtkTreePath *path);
@@ -192,19 +192,19 @@
192#if 0192#if 0
193 /* select_all is a function pointer that subclasses must override to193 /* select_all is a function pointer that subclasses must override to
194 * select all of the items in the view */194 * select all of the items in the view */
195 void (* select_all) (FMDirectoryView *view);195 void (* select_all) (FMDirectoryView *view);
196196
197 /* set_selection is a function pointer that subclasses must197 /* set_selection is a function pointer that subclasses must
198 * override to select the specified items (and unselect all198 * override to select the specified items (and unselect all
199 * others). The argument is a list of GOFFiles. */199 * others). The argument is a list of GOFFiles. */
200200
201 void (* set_selection) (FMDirectoryView *view, 201 void (* set_selection) (FMDirectoryView *view,
202 GList *selection);202 GList *selection);
203 203
204 /* invert_selection is a function pointer that subclasses must204 /* invert_selection is a function pointer that subclasses must
205 * override to invert selection. */205 * override to invert selection. */
206206
207 void (* invert_selection) (FMDirectoryView *view); 207 void (* invert_selection) (FMDirectoryView *view);
208208
209 /* Return an array of locations of selected icons in their view. */209 /* Return an array of locations of selected icons in their view. */
210 //GArray * (* get_selected_icon_locations) (FMDirectoryView *view);210 //GArray * (* get_selected_icon_locations) (FMDirectoryView *view);
@@ -213,12 +213,12 @@
213213
214 /* bump_zoom_level is a function pointer that subclasses must override214 /* bump_zoom_level is a function pointer that subclasses must override
215 * to change the zoom level of an object. */215 * to change the zoom level of an object. */
216 /*void (* bump_zoom_level) (FMDirectoryView *view,216 /*void (* bump_zoom_level) (FMDirectoryView *view,
217 int zoom_increment);*/217 int zoom_increment);*/
218218
219 /* zoom_to_level is a function pointer that subclasses must override219 /* zoom_to_level is a function pointer that subclasses must override
220 * to set the zoom level of an object to the specified level. */220 * to set the zoom level of an object to the specified level. */
221 /*void (* zoom_to_level) (FMDirectoryView *view, 221 /*void (* zoom_to_level) (FMDirectoryView *view,
222 NautilusZoomLevel level);*/222 NautilusZoomLevel level);*/
223223
224 //NautilusZoomLevel (* get_zoom_level) (FMDirectoryView *view);224 //NautilusZoomLevel (* get_zoom_level) (FMDirectoryView *view);
@@ -229,39 +229,39 @@
229229
230 /* can_zoom_in is a function pointer that subclasses must override to230 /* can_zoom_in is a function pointer that subclasses must override to
231 * return whether the view is at maximum size (furthest-in zoom level) */231 * return whether the view is at maximum size (furthest-in zoom level) */
232 //gboolean (* can_zoom_in) (FMDirectoryView *view);232 //gboolean (* can_zoom_in) (FMDirectoryView *view);
233233
234 /* can_zoom_out is a function pointer that subclasses must override to234 /* can_zoom_out is a function pointer that subclasses must override to
235 * return whether the view is at minimum size (furthest-out zoom level) */235 * return whether the view is at minimum size (furthest-out zoom level) */
236 //gboolean (* can_zoom_out) (FMDirectoryView *view);236 //gboolean (* can_zoom_out) (FMDirectoryView *view);
237237
238 /* reveal_selection is a function pointer that subclasses may238 /* reveal_selection is a function pointer that subclasses may
239 * override to make sure the selected items are sufficiently239 * override to make sure the selected items are sufficiently
240 * apparent to the user (e.g., scrolled into view). By default,240 * apparent to the user (e.g., scrolled into view). By default,
241 * this does nothing.241 * this does nothing.
242 */242 */
243 void (* reveal_selection) (FMDirectoryView *view);243 void (* reveal_selection) (FMDirectoryView *view);
244244
245 /* get_background is a function pointer that subclasses must245 /* get_background is a function pointer that subclasses must
246 * override to return the EelBackground for this view.246 * override to return the EelBackground for this view.
247 */247 */
248 //GtkWidget * (* get_background_widget) (FMDirectoryView *view);248 //GtkWidget * (* get_background_widget) (FMDirectoryView *view);
249#endif249#endif
250250
251 /* merge_menus is a function pointer that subclasses can override to251 /* merge_menus is a function pointer that subclasses can override to
252 * add their own menu items to the window's menu bar.252 * add their own menu items to the window's menu bar.
253 * If overridden, subclasses must call parent class's function.253 * If overridden, subclasses must call parent class's function.
254 */254 */
255 void (* merge_menus) (FMDirectoryView *view);255 void (* merge_menus) (FMDirectoryView *view);
256 void (* unmerge_menus) (FMDirectoryView *view);256 void (* unmerge_menus) (FMDirectoryView *view);
257257
258#if 0258#if 0
259 /* update_menus is a function pointer that subclasses can override to259 /* update_menus is a function pointer that subclasses can override to
260 * update the sensitivity or wording of menu items in the menu bar.260 * update the sensitivity or wording of menu items in the menu bar.
261 * It is called (at least) whenever the selection changes. If overridden, 261 * It is called (at least) whenever the selection changes. If overridden,
262 * subclasses must call parent class's function.262 * subclasses must call parent class's function.
263 */263 */
264 //void (* update_menus) (FMDirectoryView *view);264 //void (* update_menus) (FMDirectoryView *view);
265265
266 /* sort_files is a function pointer that subclasses can override266 /* sort_files is a function pointer that subclasses can override
267 * to provide a sorting order to determine which files should be267 * to provide a sorting order to determine which files should be
@@ -276,7 +276,7 @@
276 * be displayed with each file. By default, all emblems returned by276 * be displayed with each file. By default, all emblems returned by
277 * GOFFile are displayed.277 * GOFFile are displayed.
278 */278 */
279 //char ** (* get_emblem_names_to_exclude) (FMDirectoryView *view);279 //char ** (* get_emblem_names_to_exclude) (FMDirectoryView *view);
280280
281 /* file_limit_reached is a function pointer that subclasses may281 /* file_limit_reached is a function pointer that subclasses may
282 * override to control what happens when a directory is loaded282 * override to control what happens when a directory is loaded
@@ -285,21 +285,21 @@
285 * display when the user explicitly tried to visit a location that285 * display when the user explicitly tried to visit a location that
286 * they would think of as a normal directory.286 * they would think of as a normal directory.
287 */287 */
288 //void (* file_limit_reached) (FMDirectoryView *view);288 //void (* file_limit_reached) (FMDirectoryView *view);
289289
290 /* supports_properties is a function pointer that subclasses may290 /* supports_properties is a function pointer that subclasses may
291 * override to control whether the "Show Properties" menu item291 * override to control whether the "Show Properties" menu item
292 * should be enabled for selected items. The default implementation 292 * should be enabled for selected items. The default implementation
293 * returns TRUE.293 * returns TRUE.
294 */294 */
295 //gboolean (* supports_properties) (FMDirectoryView *view);295 //gboolean (* supports_properties) (FMDirectoryView *view);
296296
297 /* supports_zooming is a function pointer that subclasses may297 /* supports_zooming is a function pointer that subclasses may
298 * override to control whether or not the zooming control and298 * override to control whether or not the zooming control and
299 * menu items should be enabled. The default implementation299 * menu items should be enabled. The default implementation
300 * returns TRUE.300 * returns TRUE.
301 */301 */
302 //gboolean (* supports_zooming) (FMDirectoryView *view);302 //gboolean (* supports_zooming) (FMDirectoryView *view);
303303
304 /* using_manual_layout is a function pointer that subclasses may304 /* using_manual_layout is a function pointer that subclasses may
305 * override to control whether or not items can be freely positioned305 * override to control whether or not items can be freely positioned
@@ -314,7 +314,7 @@
314 * default implementation checks the permissions of the314 * default implementation checks the permissions of the
315 * directory.315 * directory.
316 */316 */
317 gboolean (* is_read_only) (FMDirectoryView *view);317 gboolean (* is_read_only) (FMDirectoryView *view);
318318
319 /* is_empty is a function pointer that subclasses must319 /* is_empty is a function pointer that subclasses must
320 * override to report whether the view contains any items.320 * override to report whether the view contains any items.
@@ -327,13 +327,13 @@
327 * user has write permissions for the viewed directory, and whether327 * user has write permissions for the viewed directory, and whether
328 * the viewed directory is in the trash.328 * the viewed directory is in the trash.
329 */329 */
330 gboolean (* supports_creating_files) (FMDirectoryView *view);330 gboolean (* supports_creating_files) (FMDirectoryView *view);
331331
332 /* accepts_dragged_files is a function pointer that subclasses may332 /* accepts_dragged_files is a function pointer that subclasses may
333 * override to control whether or not files can be dropped in this333 * override to control whether or not files can be dropped in this
334 * location. The default implementation returns TRUE.334 * location. The default implementation returns TRUE.
335 */335 */
336 //gboolean (* accepts_dragged_files) (FMDirectoryView *view);336 //gboolean (* accepts_dragged_files) (FMDirectoryView *view);
337337
338 /*gboolean (* can_rename_file) (FMDirectoryView *view,338 /*gboolean (* can_rename_file) (FMDirectoryView *view,
339 GOFFile *file);*/339 GOFFile *file);*/
@@ -341,12 +341,12 @@
341 /* select_all specifies whether the whole filename should be selected341 /* select_all specifies whether the whole filename should be selected
342 * or only its basename (i.e. everything except the extension)342 * or only its basename (i.e. everything except the extension)
343 * */343 * */
344 void (* start_renaming_file) (FMDirectoryView *view,344 void (* start_renaming_file) (FMDirectoryView *view,
345 GOFFile *file,345 GOFFile *file,
346 gboolean select_all);346 gboolean select_all);
347#if 0347#if 0
348 /*gboolean (* file_still_belongs) (FMDirectoryView *view,348 /*gboolean (* file_still_belongs) (FMDirectoryView *view,
349 GOFFile *file,349 GOFFile *file,
350 GOFDirectoryAsync *directory);350 GOFDirectoryAsync *directory);
351 */351 */
352352
@@ -360,17 +360,17 @@
360 GdkPoint360 GdkPoint
361 *position);*/361 *position);*/
362362
363 /* Preference change callbacks, overriden by icon and list views. 363 /* Preference change callbacks, overriden by icon and list views.
364 * Icon and list views respond by synchronizing to the new preference364 * Icon and list views respond by synchronizing to the new preference
365 * values and forcing an update if appropriate.365 * values and forcing an update if appropriate.
366 */366 */
367 /*void (* text_attribute_names_changed) (FMDirectoryView *view);367 /*void (* text_attribute_names_changed) (FMDirectoryView *view);
368 void (* embedded_text_policy_changed) (FMDirectoryView *view);368 void (* embedded_text_policy_changed) (FMDirectoryView *view);
369 void (* image_display_policy_changed) (FMDirectoryView *view);369 void (* image_display_policy_changed) (FMDirectoryView *view);
370 void (* click_policy_changed) (FMDirectoryView *view);370 void (* click_policy_changed) (FMDirectoryView *view);
371 void (* sort_directories_first_changed) (FMDirectoryView *view);371 void (* sort_directories_first_changed) (FMDirectoryView *view);
372372
373 void (* emblems_changed) (FMDirectoryView *view);373 void (* emblems_changed) (FMDirectoryView *view);
374374
375 void (* set_is_active) (FMDirectoryView *view,375 void (* set_is_active) (FMDirectoryView *view,
376 gboolean376 gboolean
377377
=== modified file 'src/gof-window-slot.c'
--- src/gof-window-slot.c 2013-06-27 19:34:48 +0000
+++ src/gof-window-slot.c 2013-09-01 22:36:03 +0000
@@ -46,12 +46,13 @@
46{46{
47 slot->content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);47 slot->content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
48 slot->width = 0;48 slot->width = 0;
49 slot->ready_to_autosize = FALSE;
49 GOF_ABSTRACT_SLOT (slot)->extra_location_widgets = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);50 GOF_ABSTRACT_SLOT (slot)->extra_location_widgets = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
50 gtk_box_pack_start (GTK_BOX (slot->content_box), GOF_ABSTRACT_SLOT(slot)->extra_location_widgets, FALSE, FALSE, 0);51 gtk_box_pack_start (GTK_BOX (slot->content_box), GOF_ABSTRACT_SLOT(slot)->extra_location_widgets, FALSE, FALSE, 0);
51}52}
5253
53static void54static void
54real_active (GOFWindowSlot *slot) 55real_active (GOFWindowSlot *slot)
55{56{
56 marlin_view_view_container_refresh_slot_info (MARLIN_VIEW_VIEW_CONTAINER (slot->ctab));57 marlin_view_view_container_refresh_slot_info (MARLIN_VIEW_VIEW_CONTAINER (slot->ctab));
57}58}
@@ -60,22 +61,22 @@
60gof_window_slot_class_init (GOFWindowSlotClass *class)61gof_window_slot_class_init (GOFWindowSlotClass *class)
61{62{
62 signals[ACTIVE] =63 signals[ACTIVE] =
63 g_signal_new ("active",64 g_signal_new ("active",
64 G_TYPE_FROM_CLASS (class),65 G_TYPE_FROM_CLASS (class),
65 G_SIGNAL_RUN_LAST,66 G_SIGNAL_RUN_LAST,
66 G_STRUCT_OFFSET (GOFWindowSlotClass, active),67 G_STRUCT_OFFSET (GOFWindowSlotClass, active),
67 NULL, NULL,68 NULL, NULL,
68 g_cclosure_marshal_VOID__VOID,69 g_cclosure_marshal_VOID__VOID,
69 G_TYPE_NONE, 0);70 G_TYPE_NONE, 0);
7071
71 signals[INACTIVE] =72 signals[INACTIVE] =
72 g_signal_new ("inactive",73 g_signal_new ("inactive",
73 G_TYPE_FROM_CLASS (class),74 G_TYPE_FROM_CLASS (class),
74 G_SIGNAL_RUN_LAST,75 G_SIGNAL_RUN_LAST,
75 G_STRUCT_OFFSET (GOFWindowSlotClass, inactive),76 G_STRUCT_OFFSET (GOFWindowSlotClass, inactive),
76 NULL, NULL,77 NULL, NULL,
77 g_cclosure_marshal_VOID__VOID,78 g_cclosure_marshal_VOID__VOID,
78 G_TYPE_NONE, 0);79 G_TYPE_NONE, 0);
7980
80 G_OBJECT_CLASS (class)->finalize = gof_window_slot_finalize;81 G_OBJECT_CLASS (class)->finalize = gof_window_slot_finalize;
81 class->active = real_active;82 class->active = real_active;
@@ -87,10 +88,12 @@
87 GOFWindowSlot *slot = GOF_WINDOW_SLOT (object);88 GOFWindowSlot *slot = GOF_WINDOW_SLOT (object);
8889
89 //load_dir_async_cancel(slot->directory);90 //load_dir_async_cancel(slot->directory);
90 g_debug ("%s %s\n", G_STRFUNC, slot->directory->file->uri);91 g_debug ("%s %s finalizing\n", G_STRFUNC, slot->directory->file->uri);
91 //g_warning ("%s %s %u\n", G_STRFUNC, slot->directory->file->uri, G_OBJECT (slot->directory)->ref_count);92 //g_warning ("%s %s %u\n", G_STRFUNC, slot->directory->file->uri, G_OBJECT (slot->directory)->ref_count);
93 g_signal_handlers_disconnect_by_data (slot->directory, slot);
92 g_object_unref(slot->directory);94 g_object_unref(slot->directory);
93 g_object_unref(slot->location);95 g_object_unref(slot->location);
96
94 G_OBJECT_CLASS (parent_class)->finalize (object);97 G_OBJECT_CLASS (parent_class)->finalize (object);
95 /* avoid a warning in vala code: slot is freed in ViewContainer */98 /* avoid a warning in vala code: slot is freed in ViewContainer */
96 //slot = NULL;99 //slot = NULL;
@@ -100,7 +103,7 @@
100update_total_width (GtkWidget *widget, GtkAllocation *allocation, void *data)103update_total_width (GtkWidget *widget, GtkAllocation *allocation, void *data)
101{104{
102 GOFWindowSlot* slot = data;105 GOFWindowSlot* slot = data;
103 106
104 if (slot->mwcols->total_width != 0 && slot->width != allocation->width) {107 if (slot->mwcols->total_width != 0 && slot->width != allocation->width) {
105 slot->mwcols->total_width += allocation->width - slot->width;108 slot->mwcols->total_width += allocation->width - slot->width;
106 slot->width = allocation->width;109 slot->width = allocation->width;
@@ -114,11 +117,11 @@
114 GtkWidget *hpane = GTK_WIDGET (granite_widgets_thin_paned_new (GTK_ORIENTATION_HORIZONTAL));117 GtkWidget *hpane = GTK_WIDGET (granite_widgets_thin_paned_new (GTK_ORIENTATION_HORIZONTAL));
115 gtk_widget_set_hexpand(hpane, TRUE);118 gtk_widget_set_hexpand(hpane, TRUE);
116 gtk_widget_show (hpane);119 gtk_widget_show (hpane);
117 120
118 gtk_container_add(GTK_CONTAINER (slot->colpane), hpane);121 gtk_container_add(GTK_CONTAINER (slot->colpane), hpane);
119 gtk_widget_show_all(slot->colpane);122 gtk_widget_show_all(slot->colpane);
120 123
121 GtkWidget *box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); 124 GtkWidget *box1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
122 gtk_widget_show_all (box1);125 gtk_widget_show_all (box1);
123126
124 slot->colpane = box1;127 slot->colpane = box1;
@@ -131,6 +134,69 @@
131134
132 gtk_paned_pack1 (GTK_PANED (hpane), column, FALSE, FALSE);135 gtk_paned_pack1 (GTK_PANED (hpane), column, FALSE, FALSE);
133 gtk_paned_pack2 (GTK_PANED (hpane), box1, TRUE, FALSE);136 gtk_paned_pack2 (GTK_PANED (hpane), box1, TRUE, FALSE);
137
138 /* If the directory finished loading before slot was ready then autosize the slot now.
139 * Otherwise the slot will be autosized by the directory_done_loading callback
140 * This is necessary because the directory loads faster from the cache than from disk
141 * On first use the directory loads from disk and we reach here before the directory
142 * has finished loading.
143 * On subsequent uses, the directory loads from cache before the slot is ready.
144 * Whichever finishes first sets slot->ready_to_autosize = TRUE
145 * Whichever finds slot->ready_to_autosize = TRUE does the autosizing.
146 */
147
148 if (slot->ready_to_autosize)
149 autosize_slot (slot);
150 else {
151 slot->ready_to_autosize = TRUE;
152 }
153}
154
155void autosize_slot (GOFWindowSlot *slot)
156{
157 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));
158 g_return_if_fail (slot->view_box != NULL);
159 g_return_if_fail (GTK_IS_WIDGET (slot->view_box));
160 g_return_if_fail (GOF_DIRECTORY_IS_ASYNC (slot->directory));
161 g_return_if_fail (slot->mwcols != NULL);
162
163 PangoLayout* layout = gtk_widget_create_pango_layout (GTK_WIDGET (slot->view_box), NULL);
164
165 if (gof_directory_async_is_empty (slot->directory))
166 pango_layout_set_markup (layout, FM_DIRECTORY_VIEW (slot->view_box)->empty_message, -1);
167 else
168 pango_layout_set_markup (layout,
169 g_markup_escape_text (slot->directory->longest_file_name, -1),
170 -1);
171
172 PangoRectangle extents;
173 pango_layout_get_extents (layout, NULL, &extents);
174
175 gint column_width = (int) pango_units_to_double(extents.width)
176 + 2 * slot->directory->icon_size
177 + 2 * slot->mwcols->handle_size
178 + 12;
179
180 gint min_width = slot->mwcols->preferred_column_width / 2;
181
182 if (column_width < min_width)
183 column_width = min_width;
184 else {
185 //TODO make max_width a setting
186 gint max_width = 2 * slot->mwcols->preferred_column_width;
187 if (column_width > max_width)
188 column_width = max_width;
189 }
190
191 if (slot->slot_number == 0)
192 gtk_widget_set_size_request (gtk_paned_get_child1 (GTK_PANED (slot->hpane)), column_width, -1);
193 else
194 gtk_paned_set_position (GTK_PANED (slot->hpane), column_width);
195 slot->width = column_width;
196
197 gtk_widget_show_all (slot->mwcols->colpane);
198 gtk_widget_queue_draw (slot->mwcols->colpane);
199
134}200}
135201
136void202void
@@ -139,10 +205,10 @@
139 gint current_slot_position = 0;205 gint current_slot_position = 0;
140 gint i;206 gint i;
141 GList* list_slot = slot->mwcols->slot;207 GList* list_slot = slot->mwcols->slot;
142 208
143 g_return_if_fail (slot->colpane != NULL);209 g_return_if_fail (slot->colpane != NULL);
144 gtk_container_foreach (GTK_CONTAINER (slot->colpane), (GtkCallback)gtk_widget_destroy, NULL);210 gtk_container_foreach (GTK_CONTAINER (slot->colpane), (GtkCallback)gtk_widget_destroy, NULL);
145 211
146 current_slot_position = g_list_index(slot->mwcols->slot, slot);212 current_slot_position = g_list_index(slot->mwcols->slot, slot);
147 if(current_slot_position == -1) {213 if(current_slot_position == -1) {
148 g_warning ("Can't find the slot you are viewing, this should *not* happen.");214 g_warning ("Can't find the slot you are viewing, this should *not* happen.");
@@ -157,9 +223,11 @@
157 g_list_free (slot->mwcols->slot);223 g_list_free (slot->mwcols->slot);
158 slot->mwcols->slot = l;224 slot->mwcols->slot = l;
159 }225 }
160 slot->mwcols->total_width += slot->mwcols->preferred_column_width + 100;226
161 gtk_widget_set_size_request (slot->mwcols->colpane, slot->mwcols->total_width, -1);
162 marlin_window_columns_add (slot->mwcols, location);227 marlin_window_columns_add (slot->mwcols, location);
228
229 slot->mwcols->total_width += slot->width + 100;
230 gtk_widget_set_size_request (slot->mwcols->colpane, slot->mwcols->total_width, -1);
163}231}
164232
165GOFWindowSlot *233GOFWindowSlot *
@@ -191,8 +259,10 @@
191 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_ICON_VIEW,259 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_ICON_VIEW,
192 "window-slot", slot, NULL));260 "window-slot", slot, NULL));
193 gtk_box_pack_start(GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);261 gtk_box_pack_start(GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);
194 262
195 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);263 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);
264
265 slot->directory->track_longest_name = FALSE;
196 gof_directory_async_load (slot->directory);266 gof_directory_async_load (slot->directory);
197}267}
198268
@@ -207,6 +277,8 @@
207 "window-slot", slot, NULL));277 "window-slot", slot, NULL));
208 gtk_box_pack_start (GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);278 gtk_box_pack_start (GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);
209 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);279 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);
280
281 slot->directory->track_longest_name = FALSE;
210 gof_directory_async_load (slot->directory);282 gof_directory_async_load (slot->directory);
211}283}
212284
@@ -224,6 +296,7 @@
224{296{
225 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,297 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,
226 "window-slot", slot, NULL));298 "window-slot", slot, NULL));
299 slot->directory->track_longest_name = TRUE;
227 gof_directory_async_load (slot->directory);300 gof_directory_async_load (slot->directory);
228}301}
229302
@@ -233,8 +306,10 @@
233{306{
234 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));307 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));
235308
236 if (slot->mwcols)309 if (slot->mwcols != NULL) {
237 marlin_window_columns_active_slot (slot->mwcols, slot);310 marlin_window_columns_active_slot (slot->mwcols, slot);
311 autosize_slot (slot);
312 }
238}313}
239314
240void315void
241316
=== modified file 'src/gof-window-slot.h'
--- src/gof-window-slot.h 2013-06-27 19:34:48 +0000
+++ src/gof-window-slot.h 2013-09-01 22:36:03 +0000
@@ -25,9 +25,9 @@
25#include "marlincore.h"25#include "marlincore.h"
26#include "marlin-window-columns.h"26#include "marlin-window-columns.h"
2727
28#define GOF_TYPE_WINDOW_SLOT (gof_window_slot_get_type())28#define GOF_TYPE_WINDOW_SLOT (gof_window_slot_get_type())
29#define GOF_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GOF_TYPE_WINDOW_SLOT, GOFWindowSlotClass))29#define GOF_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GOF_TYPE_WINDOW_SLOT, GOFWindowSlotClass))
30#define GOF_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOF_TYPE_WINDOW_SLOT, GOFWindowSlot))30#define GOF_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOF_TYPE_WINDOW_SLOT, GOFWindowSlot))
31#define GOF_IS_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOF_TYPE_WINDOW_SLOT))31#define GOF_IS_WINDOW_SLOT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOF_TYPE_WINDOW_SLOT))
32#define GOF_IS_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GOF_TYPE_WINDOW_SLOT))32#define GOF_IS_WINDOW_SLOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GOF_TYPE_WINDOW_SLOT))
33#define GOF_WINDOW_SLOT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GOF_TYPE_WINDOW_SLOT, GOFWindowSlotClass))33#define GOF_WINDOW_SLOT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GOF_TYPE_WINDOW_SLOT, GOFWindowSlotClass))
@@ -55,6 +55,8 @@
5555
56 MarlinWindowColumns *mwcols;56 MarlinWindowColumns *mwcols;
57 guint width;57 guint width;
58 guint slot_number;
59 gboolean ready_to_autosize;
58};60};
5961
60struct GOFWindowSlotClass {62struct GOFWindowSlotClass {
@@ -81,5 +83,6 @@
8183
82void gof_window_slot_freeze_updates (GOFWindowSlot *slot);84void gof_window_slot_freeze_updates (GOFWindowSlot *slot);
83void gof_window_slot_unfreeze_updates (GOFWindowSlot *slot);85void gof_window_slot_unfreeze_updates (GOFWindowSlot *slot);
86void autosize_slot (GOFWindowSlot *slot);
8487
85#endif /* GOF_WINDOW_SLOT_H */88#endif /* GOF_WINDOW_SLOT_H */
8689
=== modified file 'src/marlin-window-columns.c'
--- src/marlin-window-columns.c 2013-07-05 18:20:51 +0000
+++ src/marlin-window-columns.c 2013-09-01 22:36:03 +0000
@@ -110,6 +110,7 @@
110 GOFWindowSlot *slot = mwcols->active_slot;110 GOFWindowSlot *slot = mwcols->active_slot;
111111
112 gof_window_slot_make_column_view (slot);112 gof_window_slot_make_column_view (slot);
113 slot->slot_number = 0;
113114
114 mwcols->colpane = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);115 mwcols->colpane = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
115 slot->colpane = mwcols->colpane;116 slot->colpane = mwcols->colpane;
@@ -133,6 +134,7 @@
133134
134 marlin_view_view_container_set_content ((MarlinViewViewContainer *) mwcols->ctab, mwcols->content_box);135 marlin_view_view_container_set_content ((MarlinViewViewContainer *) mwcols->ctab, mwcols->content_box);
135136
137
136 /* store pane handle size*/138 /* store pane handle size*/
137 gtk_widget_style_get (GTK_WIDGET (slot->hpane), "handle-size", &mwcols->handle_size, NULL);139 gtk_widget_style_get (GTK_WIDGET (slot->hpane), "handle-size", &mwcols->handle_size, NULL);
138140
@@ -156,7 +158,9 @@
156marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)158marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)
157{159{
158 GOFWindowSlot *slot = gof_window_slot_new (location, mwcols->ctab);160 GOFWindowSlot *slot = gof_window_slot_new (location, mwcols->ctab);
161 slot->width = mwcols->preferred_column_width;
159 gof_window_slot_make_column_view (slot);162 gof_window_slot_make_column_view (slot);
163 slot->slot_number = mwcols->active_slot->slot_number +1;
160 slot->mwcols = mwcols;164 slot->mwcols = mwcols;
161 slot->colpane = mwcols->active_slot->colpane;165 slot->colpane = mwcols->active_slot->colpane;
162 gof_window_column_add (slot, slot->view_box);166 gof_window_column_add (slot, slot->view_box);

Subscribers

People subscribed via source and target branches