Merge lp:~jeremywootten/pantheon-files/fix-1086929-remake into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1347
Merged at revision: 1373
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1086929-remake
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 457 lines (+154/-17)
9 files modified
libcore/gof-directory-async.vala (+55/-5)
libcore/gof-file.c (+1/-1)
src/View/ViewContainer.vala (+1/-0)
src/fm-columns-view.c (+1/-3)
src/fm-directory-view.c (+14/-4)
src/fm-directory-view.h (+1/-0)
src/gof-window-slot.c (+75/-4)
src/gof-window-slot.h (+3/-0)
src/marlin-window-columns.c (+3/-0)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1086929-remake
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
David Gomes (community) Needs Fixing
Review via email: mp+188004@code.launchpad.net

Commit message

Implement auto-sizing of columns in column view.

Description of the change

This is a remake of my previous branch to implement column auto-sizing in column view (currently owned by elementary Developer Community), which included a lot of extraneous formatting changes. In this branch, any changes to existing code have been minimised and it is based on a later revision of trunk. The functional code is the same as the previous branch.

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

Newline after diff line 58, 82.

167-169, align those correctly.

Good branch, I can confirm the core code is the same, so we can merge this. Plus, it's much much less code, which is good.

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

Newline after diff line 37 too.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

OK. So the rule is new line after one-line if statements unless followed
by a brace?

What is the preferred way of aligning 167-169? Align under "g_strconcat"
or the opening paren or elsewhere?

On 27 September 2013 10:52, David Gomes <email address hidden> wrote:

> Review: Needs Fixing
>
> Newline after diff line 58, 82.
>
> 167-169, align those correctly.
>
> Good branch, I can confirm the core code is the same, so we can merge
> this. Plus, it's much much less code, which is good.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/fix-1086929-remake/+merge/188004
> You are the owner of lp:~jeremywootten/pantheon-files/fix-1086929-remake.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Re aligning; looking again I guess you mean under the first quote (")?

On 27 September 2013 10:52, David Gomes <email address hidden> wrote:

> Review: Needs Fixing
>
> Newline after diff line 58, 82.
>
> 167-169, align those correctly.
>
> Good branch, I can confirm the core code is the same, so we can merge
> this. Plus, it's much much less code, which is good.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/fix-1086929-remake/+merge/188004
> You are the owner of lp:~jeremywootten/pantheon-files/fix-1086929-remake.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

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

Regarding aligning, yes I mean under the first quote.

The rule concerning new lines is after any if, for/while/foreach/function block, except if followed by another "}" (for example in the end of a class when you close the class and the namespace and the last function in the class). Be it one-line or multiple-ĺines.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

OK, fixed accordingly.

On 27 September 2013 11:50, David Gomes <email address hidden> wrote:

> Regarding aligning, yes I mean under the first quote.
>
> The rule concerning new lines is after any if, for/while/foreach/function
> block, except if followed by another "}" (for example in the end of a class
> when you close the class and the namespace and the last function in the
> class). Be it one-line or multiple-ĺines.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/fix-1086929-remake/+merge/188004
> You are the owner of lp:~jeremywootten/pantheon-files/fix-1086929-remake.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

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

I think I found a bug with this. When Trash has some amount of files in it (more than 1, or a certain size, but not sure how much), emptying causes pantheon-files to lock up.

I have experienced this twice, still trying to figure out how to reproduce.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Just emptied my trash of 1000+ files successfully but it was fairly slow.
 It could be that the longest filename (which detemines the column width)
is being updated after every deletion. I'll look into it.

On 2 October 2013 18:02, Cody Garver <email address hidden> wrote:

> I think I found a bug with this. When Trash has some amount of files in it
> (more than 1, or a certain size, but not sure how much), emptying causes
> pantheon-files to lock up.
>
> I have experienced this twice, still trying to figure out how to reproduce.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/fix-1086929-remake/+merge/188004
> You are the owner of lp:~jeremywootten/pantheon-files/fix-1086929-remake.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

1346. By Jeremy Wootten

Merge changes from trunk rev 1351

1347. By Jeremy Wootten

Only autosize after all changes to directory done

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Hello Cody, There does seem to be an issue with deleting or copying large
numbers of files (especially image) files - it can be slow and there is no
progress information so the application appears frozen. I have pushed
another revision to this branch that only autosizes the column after all
deletions are done rather than after each deletion. Please review this
revision, thanks.

There are some other efficiencies that can be made but they are not
connected to autosizing so I have not put them in this branch.

On 2 October 2013 18:02, Cody Garver <email address hidden> wrote:

> I think I found a bug with this. When Trash has some amount of files in it
> (more than 1, or a certain size, but not sure how much), emptying causes
> pantheon-files to lock up.
>
> I have experienced this twice, still trying to figure out how to reproduce.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-files/fix-1086929-remake/+merge/188004
> You are the owner of lp:~jeremywootten/pantheon-files/fix-1086929-remake.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

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

I gathered a big bunch of Trash to do delete tests with and found the problems I previously had with this branch are resolved.

I want to get lp:~jeremywootten/pantheon-files/fix-1178869 merged, do a point release, then merge this branch so it gets some time in trunk for extended testing.

review: Approve

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-09-11 19:36:05 +0000
+++ libcore/gof-directory-async.vala 2013-10-09 18:52:53 +0000
@@ -28,6 +28,8 @@
28 /* we're looking for particular path keywords like *\/icons* .icons ... */28 /* we're looking for particular path keywords like *\/icons* .icons ... */
29 public bool uri_contain_keypath_icons;29 public bool uri_contain_keypath_icons;
30 public int uri_keypath_size = 0;30 public int uri_keypath_size = 0;
31 public string longest_file_name = ""; //for auto-sizing Miller columns
32 public bool track_longest_name;
3133
32 public enum State {34 public enum State {
33 NOT_LOADED,35 NOT_LOADED,
@@ -75,7 +77,7 @@
75 file = GOF.File.get (location);77 file = GOF.File.get (location);
76 file.exists = true;78 file.exists = true;
77 cancellable = new Cancellable ();79 cancellable = new Cancellable ();
7880 track_longest_name = false;
79 //query_info_async (file, file_info_available);81 //query_info_async (file, file_info_available);
80 if (file.info == null)82 if (file.info == null)
81 file.query_update ();83 file.query_update ();
@@ -139,6 +141,7 @@
139141
140 public void load () {142 public void load () {
141 cancellable.reset ();143 cancellable.reset ();
144 longest_file_name = "";
142 if (state != State.LOADED) {145 if (state != State.LOADED) {
143 /* clear directory info if it's not fully loaded */146 /* clear directory info if it's not fully loaded */
144 if (state == State.LOADING)147 if (state == State.LOADING)
@@ -170,22 +173,36 @@
170173
171 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;174 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;
172 foreach (GOF.File gof in file_hash.get_values ()) {175 foreach (GOF.File gof in file_hash.get_values ()) {
173 if (gof.info != null && (!gof.is_hidden || show_hidden))176 if (gof.info != null && (!gof.is_hidden || show_hidden)) {
177 if (track_longest_name)
178 update_longest_file_name (gof);
179
174 file_loaded (gof);180 file_loaded (gof);
181 }
175 }182 }
176 done_loading ();183 done_loading ();
177 }184 }
178 }185 }
179186
187 private void update_longest_file_name (GOF.File gof) {
188 if (longest_file_name.length < gof.basename.length)
189 longest_file_name = gof.basename;
190 }
191
180 public void load_hiddens () {192 public void load_hiddens () {
181 if (state != State.LOADED) {193 if (state != State.LOADED) {
182 load ();194 load ();
183 } else {195 } else {
184 foreach (GOF.File gof in file_hash.get_values ()) {196 foreach (GOF.File gof in file_hash.get_values ()) {
185 if (gof != null && gof.info != null && gof.is_hidden)197 if (gof != null && gof.info != null && gof.is_hidden) {
198 if (track_longest_name)
199 update_longest_file_name (gof);
200
186 file_loaded (gof);201 file_loaded (gof);
202 }
187 }203 }
188 }204 }
205 done_loading ();
189 }206 }
190207
191 public void update_desktop_files () {208 public void update_desktop_files () {
@@ -232,6 +249,7 @@
232 if (files == null)249 if (files == null)
233 break;250 break;
234251
252 bool show_hidden = Preferences.get_default ().pref_show_hidden_files;
235 foreach (var file_info in files) {253 foreach (var file_info in files) {
236 GLib.File loc = location.get_child ((string) file_info.get_name ());254 GLib.File loc = location.get_child ((string) file_info.get_name ());
237 //GOF.File gof;255 //GOF.File gof;
@@ -244,8 +262,12 @@
244 //debug ("file: %s", gof.name);262 //debug ("file: %s", gof.name);
245263
246 add_to_hash_cache (gof);264 add_to_hash_cache (gof);
247 if (!gof.is_hidden || Preferences.get_default ().pref_show_hidden_files)265 if (!gof.is_hidden || show_hidden) {
266 if (track_longest_name)
267 update_longest_file_name (gof);
268
248 file_loaded (gof);269 file_loaded (gof);
270 }
249271
250 //mutex.lock ();272 //mutex.lock ();
251 files_count++;273 files_count++;
@@ -318,6 +340,11 @@
318 /* add to sorted_dirs */340 /* add to sorted_dirs */
319 sorted_dirs.insert_sorted (gof, GOF.File.compare_by_display_name);341 sorted_dirs.insert_sorted (gof, GOF.File.compare_by_display_name);
320 }342 }
343
344 if (track_longest_name && gof.basename.length > longest_file_name.length) {
345 longest_file_name = gof.basename;
346 done_loading ();
347 }
321 }348 }
322349
323 private void file_info_available (GOF.File gof) {350 private void file_info_available (GOF.File gof) {
@@ -408,8 +435,16 @@
408 need_reload ();435 need_reload ();
409 } else {436 } else {
410 list_fchanges.reverse ();437 list_fchanges.reverse ();
438 bool tln = track_longest_name;
439 /* do not autosize during multiple changes */
440 track_longest_name = false;
411 foreach (var fchange in list_fchanges)441 foreach (var fchange in list_fchanges)
412 real_directory_changed (fchange.file, null, fchange.event);442 real_directory_changed (fchange.file, null, fchange.event);
443
444 if (tln) {
445 track_longest_name = true;
446 load ();
447 }
413 }448 }
414 }449 }
415 list_fchanges_count = 0;450 list_fchanges_count = 0;
@@ -438,6 +473,9 @@
438 }473 }
439474
440 public static void notify_files_removed (List<GLib.File> files) {475 public static void notify_files_removed (List<GLib.File> files) {
476 List<Async> dirs = null;
477 bool found;
478
441 foreach (var loc in files) {479 foreach (var loc in files) {
442 GOF.File gof = GOF.File.get (loc);480 GOF.File gof = GOF.File.get (loc);
443 Async? dir = cache_lookup (gof.directory);481 Async? dir = cache_lookup (gof.directory);
@@ -445,8 +483,20 @@
445 if (dir != null) {483 if (dir != null) {
446 //message ("notify removed %s", gof.uri);484 //message ("notify removed %s", gof.uri);
447 dir.notify_file_removed (gof);485 dir.notify_file_removed (gof);
486 found = false;
487 foreach (var d in dirs) {
488 if (d == dir)
489 found = true;
490 }
491 if (!found)
492 dirs.append (dir);
448 }493 }
449 }494 }
495
496 foreach (var d in dirs) {
497 if (d.track_longest_name)
498 d.load();
499 }
450 }500 }
451501
452 public static Async from_gfile (GLib.File file) {502 public static Async from_gfile (GLib.File file) {
@@ -578,7 +628,7 @@
578 return null;628 return null;
579 }629 }
580630
581 private int icon_size;631 public int icon_size;
582 public void threaded_load_thumbnails (int size) {632 public void threaded_load_thumbnails (int size) {
583 try {633 try {
584 icon_size = size;634 icon_size = size;
585635
=== modified file 'libcore/gof-file.c'
--- libcore/gof-file.c 2013-08-10 20:20:23 +0000
+++ libcore/gof-file.c 2013-10-09 18:52:53 +0000
@@ -829,7 +829,7 @@
829 }829 }
830830
831 file->is_gone = TRUE;831 file->is_gone = TRUE;
832 g_warning ("end %s", G_STRFUNC);832 //g_warning ("end %s", G_STRFUNC);
833}833}
834834
835static void gof_file_init (GOFFile *file) {835static void gof_file_init (GOFFile *file) {
836836
=== modified file 'src/View/ViewContainer.vala'
--- src/View/ViewContainer.vala 2013-07-21 04:44:33 +0000
+++ src/View/ViewContainer.vala 2013-10-09 18:52:53 +0000
@@ -207,6 +207,7 @@
207 }207 }
208 if (slot != null && slot.directory != null && slot.directory.file.exists) {208 if (slot != null && slot.directory != null && slot.directory.file.exists) {
209 slot.directory.cancel ();209 slot.directory.cancel ();
210 slot.directory.track_longest_name = false;
210 }211 }
211212
212 if (nview == ViewMode.MILLER) {213 if (nview == ViewMode.MILLER) {
213214
=== modified file 'src/fm-columns-view.c'
--- src/fm-columns-view.c 2013-09-09 03:08:16 +0000
+++ src/fm-columns-view.c 2013-10-09 18:52:53 +0000
@@ -79,9 +79,7 @@
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 pango_layout_set_markup (layout, FM_DIRECTORY_VIEW (view)->empty_message, -1);
83 pango_layout_set_markup (layout, str, -1);
84
85 PangoRectangle extents;83 PangoRectangle extents;
86 /* Get hayout height and width */84 /* Get hayout height and width */
87 pango_layout_get_extents(layout, NULL, &extents);85 pango_layout_get_extents(layout, NULL, &extents);
8886
=== modified file 'src/fm-directory-view.c'
--- src/fm-directory-view.c 2013-09-29 17:01:20 +0000
+++ src/fm-directory-view.c 2013-10-09 18:52:53 +0000
@@ -316,6 +316,12 @@
316 g_object_get (view, "zoom-level", &zoom, NULL);316 g_object_get (view, "zoom-level", &zoom, NULL);
317 int size = marlin_zoom_level_to_icon_size (zoom);317 int size = marlin_zoom_level_to_icon_size (zoom);
318 gof_directory_async_threaded_load_thumbnails (view->details->slot->directory, size);318 gof_directory_async_threaded_load_thumbnails (view->details->slot->directory, size);
319 /* If in Miller view, autosize the column */
320 if (view->details->slot->ready_to_autosize)
321 autosize_slot (view->details->slot);
322 else
323 view->details->slot->ready_to_autosize = TRUE;
324
319 //g_signal_emit (view, signals[DIRECTORY_LOADED], 0, directory);325 //g_signal_emit (view, signals[DIRECTORY_LOADED], 0, directory);
320}326}
321327
@@ -501,6 +507,10 @@
501 view->details->dir_merge_id = 0;507 view->details->dir_merge_id = 0;
502 view->details->open_with_action_group = NULL;508 view->details->open_with_action_group = NULL;
503 view->details->open_with_merge_id = 0;509 view->details->open_with_merge_id = 0;
510 view->empty_message = g_strconcat ("<span size='x-large'>",
511 _("This folder is empty."),
512 "</span>",
513 NULL);
504}514}
505515
506static GObject*516static GObject*
@@ -2272,7 +2282,7 @@
2272 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2282 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
2273 g_return_if_fail (view->model == model);2283 g_return_if_fail (view->model == model);
22742284
2275 g_message ("%s", G_STRFUNC);2285 g_debug ("%s", G_STRFUNC);
2276 /* Get tree paths of selected files */2286 /* Get tree paths of selected files */
2277 selected_paths = (*FM_DIRECTORY_VIEW_GET_CLASS (view)->get_selected_paths) (view);2287 selected_paths = (*FM_DIRECTORY_VIEW_GET_CLASS (view)->get_selected_paths) (view);
22782288
@@ -2307,7 +2317,7 @@
2307 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));2317 g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
2308 g_return_if_fail (view->model == model);2318 g_return_if_fail (view->model == model);
23092319
2310 g_message ("%s", G_STRFUNC);2320 g_debug ("%s", G_STRFUNC);
2311 /* Check if there was only one file selected before the row was deleted. The2321 /* Check if there was only one file selected before the row was deleted. The
2312 * path is set by thunar_standard_view_row_deleted() if this is the case */2322 * path is set by thunar_standard_view_row_deleted() if this is the case */
2313 if (G_LIKELY (view->details->selection_before_delete != NULL))2323 if (G_LIKELY (view->details->selection_before_delete != NULL))
@@ -3115,7 +3125,7 @@
3115void3125void
3116fm_directory_view_set_active_slot (FMDirectoryView *view)3126fm_directory_view_set_active_slot (FMDirectoryView *view)
3117{3127{
3118 g_warning ("%s %s %s", G_STRFUNC,3128 g_debug ("%s %s %s", G_STRFUNC,
3119 view->details->slot->mwcols->active_slot->directory->file->uri,3129 view->details->slot->mwcols->active_slot->directory->file->uri,
3120 view->details->slot->directory->file->uri3130 view->details->slot->directory->file->uri
3121 );3131 );
@@ -3124,7 +3134,7 @@
3124 if (view->details->slot->mwcols->active_slot == view->details->slot)3134 if (view->details->slot->mwcols->active_slot == view->details->slot)
3125 return;3135 return;
31263136
3127 g_warning ("%s", G_STRFUNC);3137 //g_warning ("%s", G_STRFUNC);
3128 gof_window_slot_active (view->details->slot);3138 gof_window_slot_active (view->details->slot);
31293139
3130 /* make sure to grab focus as right click menus don't automaticly get it */3140 /* make sure to grab focus as right click menus don't automaticly get it */
31313141
=== modified file 'src/fm-directory-view.h'
--- src/fm-directory-view.h 2013-08-10 20:15:26 +0000
+++ src/fm-directory-view.h 2013-10-09 18:52:53 +0000
@@ -65,6 +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;
68 const gchar* empty_message;
6869
69 FMDirectoryViewDetails *details;70 FMDirectoryViewDetails *details;
70};71};
7172
=== modified file 'src/gof-window-slot.c'
--- src/gof-window-slot.c 2013-08-10 20:15:26 +0000
+++ src/gof-window-slot.c 2013-10-09 18:52:53 +0000
@@ -46,6 +46,7 @@
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}
@@ -89,6 +90,7 @@
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\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);
94 G_OBJECT_CLASS (parent_class)->finalize (object);96 G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -131,6 +133,68 @@
131133
132 gtk_paned_pack1 (GTK_PANED (hpane), column, FALSE, FALSE);134 gtk_paned_pack1 (GTK_PANED (hpane), column, FALSE, FALSE);
133 gtk_paned_pack2 (GTK_PANED (hpane), box1, TRUE, FALSE);135 gtk_paned_pack2 (GTK_PANED (hpane), box1, TRUE, FALSE);
136
137 /* If the directory finished loading before slot was ready then autosize the slot now.
138 * Otherwise the slot will be autosized by the directory_done_loading callback
139 * This is necessary because the directory loads faster from the cache than from disk
140 * On first use the directory loads from disk and we reach here before the directory
141 * has finished loading.
142 * On subsequent uses, the directory loads from cache before the slot is ready.
143 * Whichever finishes first sets slot->ready_to_autosize = TRUE
144 * Whichever finds slot->ready_to_autosize = TRUE does the autosizing.
145 */
146
147 if (slot->ready_to_autosize)
148 autosize_slot (slot);
149 else
150 slot->ready_to_autosize = TRUE;
151}
152
153void autosize_slot (GOFWindowSlot *slot)
154{
155 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));
156 g_return_if_fail (slot->view_box != NULL);
157 g_return_if_fail (GTK_IS_WIDGET (slot->view_box));
158 g_return_if_fail (GOF_DIRECTORY_IS_ASYNC (slot->directory));
159 g_return_if_fail (slot->mwcols != NULL);
160
161 PangoLayout* layout = gtk_widget_create_pango_layout (GTK_WIDGET (slot->view_box), NULL);
162
163 if (gof_directory_async_is_empty (slot->directory))
164 pango_layout_set_markup (layout, FM_DIRECTORY_VIEW (slot->view_box)->empty_message, -1);
165 else
166 pango_layout_set_markup (layout,
167 g_markup_escape_text (slot->directory->longest_file_name, -1),
168 -1);
169
170 PangoRectangle extents;
171 pango_layout_get_extents (layout, NULL, &extents);
172
173 gint column_width = (int) pango_units_to_double(extents.width)
174 + 2 * slot->directory->icon_size
175 + 2 * slot->mwcols->handle_size
176 + 12;
177
178 gint min_width = slot->mwcols->preferred_column_width / 2;
179
180 if (column_width < min_width)
181 column_width = min_width;
182 else {
183 //TODO make max_width a setting
184 gint max_width = 2 * slot->mwcols->preferred_column_width;
185 if (column_width > max_width)
186 column_width = max_width;
187 }
188
189 if (slot->slot_number == 0)
190 gtk_widget_set_size_request (gtk_paned_get_child1 (GTK_PANED (slot->hpane)), column_width, -1);
191 else
192 gtk_paned_set_position (GTK_PANED (slot->hpane), column_width);
193
194 slot->width = column_width;
195 gtk_widget_show_all (slot->mwcols->colpane);
196 gtk_widget_queue_draw (slot->mwcols->colpane);
197
134}198}
135199
136void200void
@@ -157,9 +221,11 @@
157 g_list_free (slot->mwcols->slot);221 g_list_free (slot->mwcols->slot);
158 slot->mwcols->slot = l;222 slot->mwcols->slot = l;
159 }223 }
160 slot->mwcols->total_width += slot->mwcols->preferred_column_width + 100;224
225 marlin_window_columns_add (slot->mwcols, location);
226
227 slot->mwcols->total_width += slot->width + 100;
161 gtk_widget_set_size_request (slot->mwcols->colpane, slot->mwcols->total_width, -1);228 gtk_widget_set_size_request (slot->mwcols->colpane, slot->mwcols->total_width, -1);
162 marlin_window_columns_add (slot->mwcols, location);
163}229}
164230
165GOFWindowSlot *231GOFWindowSlot *
@@ -193,6 +259,7 @@
193 gtk_box_pack_start(GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);259 gtk_box_pack_start(GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);
194260
195 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);261 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);
262 slot->directory->track_longest_name = FALSE;
196 gof_directory_async_load (slot->directory);263 gof_directory_async_load (slot->directory);
197}264}
198265
@@ -207,6 +274,7 @@
207 "window-slot", slot, NULL));274 "window-slot", slot, NULL));
208 gtk_box_pack_start (GTK_BOX (slot->content_box), slot->view_box, TRUE, TRUE, 0);275 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);276 marlin_view_view_container_set_content ((MarlinViewViewContainer *) slot->ctab, slot->content_box);
277 slot->directory->track_longest_name = FALSE;
210 gof_directory_async_load (slot->directory);278 gof_directory_async_load (slot->directory);
211}279}
212280
@@ -224,6 +292,7 @@
224{292{
225 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,293 slot->view_box = GTK_WIDGET (g_object_new (FM_TYPE_COLUMNS_VIEW,
226 "window-slot", slot, NULL));294 "window-slot", slot, NULL));
295 slot->directory->track_longest_name = TRUE;
227 gof_directory_async_load (slot->directory);296 gof_directory_async_load (slot->directory);
228}297}
229298
@@ -233,8 +302,10 @@
233{302{
234 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));303 g_return_if_fail (GOF_IS_WINDOW_SLOT (slot));
235304
236 if (slot->mwcols)305 if (slot->mwcols != NULL) {
237 marlin_window_columns_active_slot (slot->mwcols, slot);306 marlin_window_columns_active_slot (slot->mwcols, slot);
307 autosize_slot (slot);
308 }
238}309}
239310
240void311void
241312
=== 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-10-09 18:52:53 +0000
@@ -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-10-09 18:52:53 +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;
@@ -156,7 +157,9 @@
156marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)157marlin_window_columns_add (MarlinWindowColumns *mwcols, GFile *location)
157{158{
158 GOFWindowSlot *slot = gof_window_slot_new (location, mwcols->ctab);159 GOFWindowSlot *slot = gof_window_slot_new (location, mwcols->ctab);
160 slot->width = mwcols->preferred_column_width;
159 gof_window_slot_make_column_view (slot);161 gof_window_slot_make_column_view (slot);
162 slot->slot_number = mwcols->active_slot->slot_number + 1;
160 slot->mwcols = mwcols;163 slot->mwcols = mwcols;
161 slot->colpane = mwcols->active_slot->colpane;164 slot->colpane = mwcols->active_slot->colpane;
162 gof_window_column_add (slot, slot->view_box);165 gof_window_column_add (slot, slot->view_box);

Subscribers

People subscribed via source and target branches

to all changes: