Merge lp:~jeremywootten/pantheon-files/fix-1512376-no-thumbnails-for-new-files into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Felipe Escoto
Approved revision: 2057
Merged at revision: 2100
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1512376-no-thumbnails-for-new-files
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 150 lines (+35/-22)
4 files modified
libcore/gof-directory-async.vala (+3/-2)
libcore/gof-file.c (+16/-11)
src/View/AbstractDirectoryView.vala (+6/-6)
src/marlin-thumbnailer.c (+10/-3)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1512376-no-thumbnails-for-new-files
Reviewer Review Type Date Requested Status
Felipe Escoto (community) Approve
Review via email: mp+290826@code.launchpad.net

Commit message

Ensure new files are thumbnailed

Description of the change

This branch addresses a regression whereby thumbnails for files that have not previously been generated are not automatically generated until "Reload" is pressed when first viewed.

To post a comment you must log in.
Revision history for this message
Felipe Escoto (philip.scott) wrote :

Works as intended! Good job :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libcore/gof-directory-async.vala'
2--- libcore/gof-directory-async.vala 2016-02-29 11:33:21 +0000
3+++ libcore/gof-directory-async.vala 2016-04-03 16:22:43 +0000
4@@ -999,8 +999,9 @@
5 if (cancellable.is_cancelled () || thumbs_stop)
6 break;
7
8- if (gof.info != null && gof.flags != GOF.File.ThumbState.UNKNOWN) {
9- gof.flags = GOF.File.ThumbState.READY;
10+ /* Only try to load pixbuf from thumbnail if one may exist.
11+ * Note: query_thumbnail_update () does not call the thumbnailer, only loads pixbuf from existing thumbnail file.*/
12+ if (gof.flags != GOF.File.ThumbState.NONE) {
13 gof.pix_size = icon_size;
14 gof.query_thumbnail_update ();
15 }
16
17=== modified file 'libcore/gof-file.c'
18--- libcore/gof-file.c 2016-02-26 15:21:37 +0000
19+++ libcore/gof-file.c 2016-04-03 16:22:43 +0000
20@@ -538,8 +538,9 @@
21 file->utf8_collation_key = g_utf8_collate_key_for_filename (gof_file_get_display_name (file), -1);
22 /* mark the thumb flags as state none, we'll load the thumbs once the directory
23 * would be loaded on a thread */
24- if (gof_file_get_thumbnail_path (file) != NULL)
25- file->flags = GOF_FILE_THUMB_STATE_NONE;
26+ if (gof_file_get_thumbnail_path (file) != NULL) {
27+ file->flags = GOF_FILE_THUMB_STATE_UNKNOWN; /* UNKNOWN means thumbnail not known to be unobtainable */
28+ }
29
30 /* formated type */
31 gof_file_update_formated_type (file);
32@@ -875,12 +876,13 @@
33 /* get the thumbnail path from md5 filename */
34 md5_hash = g_compute_checksum_for_string (G_CHECKSUM_MD5, file->uri, -1);
35 base_name = g_strdup_printf ("%s.png", md5_hash);
36- /* TODO Use $XDG_CACHE_HOME specified thumbnail directory instead of hard coding - when Tumbler does*/
37+
38+ /* Use $XDG_CACHE_HOME specified thumbnail directory instead of hard coding */
39 if (file->pix_size <= 128) {
40- file->thumbnail_path = g_build_filename (g_get_home_dir (), ".thumbnails",
41+ file->thumbnail_path = g_build_filename (g_get_user_cache_dir (), "thumbnails",
42 "normal", base_name, NULL);
43 } else {
44- file->thumbnail_path = g_build_filename (g_get_home_dir (), ".thumbnails",
45+ file->thumbnail_path = g_build_filename (g_get_user_cache_dir (), "thumbnails",
46 "large", base_name, NULL);
47 }
48 g_free (base_name);
49@@ -945,7 +947,7 @@
50 file->exists = TRUE;
51 file->is_connected = TRUE;
52
53- file->flags = 0;
54+ file->flags = GOF_FILE_THUMB_STATE_UNKNOWN;
55 file->pix_size = -1;
56
57 file->target_gof = NULL;
58@@ -2589,14 +2591,17 @@
59
60 if (thumbnail_path != NULL)
61 {
62- thumbnail_path_split = g_strsplit(thumbnail_path, ".thumbnails/normal", -1);
63- if(g_strv_length(thumbnail_path_split) == 2)
64+ /* Construct new path to large thumbnail based on $XDG_CACHE_HOME */
65+ thumbnail_path_split = g_strsplit(thumbnail_path, G_DIR_SEPARATOR_S, -1);
66+ uint l;
67+ l = g_strv_length(thumbnail_path_split);
68+ if(l > 2)
69 {
70- new_thumbnail_path = g_strjoin(".thumbnails/large", thumbnail_path_split[0], thumbnail_path_split[1], NULL);
71+ new_thumbnail_path = g_strjoin(G_DIR_SEPARATOR_S, g_get_user_cache_dir (), "thumbnails/large", thumbnail_path_split[l-1], NULL);
72+
73 if(!g_file_test(new_thumbnail_path, G_FILE_TEST_EXISTS))
74 {
75- g_free(new_thumbnail_path);
76- new_thumbnail_path = NULL;
77+ new_thumbnail_path = g_strdup(thumbnail_path);
78 }
79 }
80 else
81
82=== modified file 'src/View/AbstractDirectoryView.vala'
83--- src/View/AbstractDirectoryView.vala 2016-03-23 15:45:06 +0000
84+++ src/View/AbstractDirectoryView.vala 2016-04-03 16:22:43 +0000
85@@ -284,7 +284,6 @@
86
87 freeze_tree (); /* speed up loading of icon view. Thawed when directory loaded */
88 set_up_zoom_level ();
89- change_zoom_level ();
90
91 connect_directory_handlers (slot.directory);
92 }
93@@ -2363,10 +2362,10 @@
94 while (valid_iter) {
95 file = model.file_for_iter (iter);
96
97- /* Ask thumbnail if ThumbState UNKNOWN or NONE */
98- if (file != null && file.flags < 2)
99+ /* Ask thumbnailer only if ThumbState UNKNOWN */
100+ if (file != null && file.flags == GOF.File.ThumbState.UNKNOWN) {
101 visible_files.prepend (file);
102-
103+ }
104 /* check if we've reached the end of the visible range */
105 path = model.get_path (iter);
106
107@@ -2377,9 +2376,10 @@
108 }
109 }
110
111- if (visible_files != null)
112+ /* This is the only place that new thumbnail files are created */
113+ if (visible_files != null) {
114 thumbnailer.queue_files (visible_files, out thumbnail_request, large_thumbnails);
115-
116+ }
117 thumbnail_source_id = 0;
118 return false;
119 });
120
121=== modified file 'src/marlin-thumbnailer.c'
122--- src/marlin-thumbnailer.c 2015-06-21 10:02:48 +0000
123+++ src/marlin-thumbnailer.c 2016-04-03 16:22:43 +0000
124@@ -707,6 +707,8 @@
125 {
126 /* set thumbnail state to ready - we now have a thumbnail */
127 gof_file_set_thumb_state (file, GOF_FILE_THUMB_STATE_READY);
128+ /* ensure new thumbnail is displayed */
129+ gof_file_query_thumbnail_update (file);
130 }
131 g_object_unref (file);
132 }
133@@ -847,9 +849,14 @@
134 * processed (and awaiting to be refreshed) */
135 for (lp = g_list_last (files); lp != NULL; lp = lp->prev)
136 {
137- /* 1067061 - Do not thumbnail network files */
138- if (!gof_file_is_remote_uri_scheme(lp->data) && marlin_thumbnailer_file_is_supported (thumbnailer, lp->data))
139- supported_files = g_list_prepend (supported_files, lp->data);
140+ /* 1067061 - Do not thumbnail network files or unsupported files */
141+ if (!gof_file_is_remote_uri_scheme(lp->data) &&
142+ marlin_thumbnailer_file_is_supported (thumbnailer, lp->data)) {
143+
144+ supported_files = g_list_prepend (supported_files, lp->data);
145+ } else {
146+ gof_file_set_thumb_state (lp->data, GOF_FILE_THUMB_STATE_NONE);
147+ }
148 }
149
150 /* determine how many URIs are in the wait queue */

Subscribers

People subscribed via source and target branches

to all changes: