Merge lp:~grabli66-r/pantheon-files/inline-progress into lp:~elementary-apps/pantheon-files/trunk

Proposed by Grabli66
Status: Work in progress
Proposed branch: lp:~grabli66-r/pantheon-files/inline-progress
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 797 lines (+269/-57)
17 files modified
.bzrignore (+1/-0)
libcore/fm-list-model.c (+29/-3)
libcore/fm-list-model.h (+5/-2)
libcore/marlin-file-operations.c (+25/-17)
libcore/marlin-progress-info.c (+29/-0)
libcore/marlin-progress-info.h (+9/-0)
libcore/pantheon-files-core-C.vapi (+10/-4)
src/Application.vala (+3/-4)
src/CMakeLists.txt (+1/-1)
src/ProgressUIHandler.vala (+15/-2)
src/TextRenderer.vala (+77/-14)
src/View/AbstractDirectoryView.vala (+35/-1)
src/View/AbstractTreeView.vala (+2/-1)
src/View/ColumnView.vala (+1/-1)
src/View/IconView.vala (+4/-3)
src/View/ListView.vala (+3/-4)
src/View/Window.vala (+20/-0)
To merge this branch: bzr merge lp:~grabli66-r/pantheon-files/inline-progress
Reviewer Review Type Date Requested Status
Jeremy Wootten appearance Needs Fixing
Adam Bieńkowski (community) code Needs Fixing
elementary Apps team Pending
Review via email: mp+295618@code.launchpad.net

Description of the change

Inline progress

To post a comment you must log in.
2170. By Grabli66

fix code style

2171. By Grabli66

removed unused code

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

There is at least one missing file - src/ProgressRenderCell.vala. Please add to bzr.

Note that this branch may be delayed for merging by Loki feature freeze.

Thanks for your contribution!

Revision history for this message
Grabli66 (grabli66-r) wrote :

Hi. I think i forgot remove that file from CMakeLists
I'll fix it

2016-05-25 12:25 GMT+03:00 Jeremy Wootten <email address hidden>:

> There is at least one missing file - src/ProgressRenderCell.vala. Please
> add to bzr.
>
> Note that this branch may be delayed for merging by Loki feature freeze.
>
> Thanks for your contribution!
> --
>
> https://code.launchpad.net/~grabli66-r/pantheon-files/inline-progress/+merge/295618
> You are the owner of lp:~grabli66-r/pantheon-files/inline-progress.
>

2172. By Grabli66

removed unused file from cmakelist

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Update the branch to the latest trunk.

review: Needs Fixing (code)
2173. By Grabli66

po files

2174. By Grabli66

fix merge

Revision history for this message
Grabli66 (grabli66-r) wrote :

Updated to current trunk

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

The branch compiles and runs but no inline progress bar appears now.

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

Further to last comment - the progress bar does not appear when copying to an frp server. It appears when copying to a usb stick.

2175. By grabli66 <email address hidden>

merge with trunc

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

A. Pasting large files into local directory from another partition
   - Progress bars show nicely but the progress is not shown in blue (but white on grey). The inline progress bar should be themed the same as the other progress bars in Files. Needs fixing.

B. Pasting onto a remote folder (smb, ftp, afp)
 - No inline progress - file does not appear until transfer complete. However, the progress window shows the correct state of the transfer. This might be tricky to fix and could be left for another branch.

C. Pasting onto USB stick
 - The file appears immediately and the Inline progress bar appears briefly and rapidly proceeds to 100% although the file has not been completely transferred to the stick. However, the progress window displays until the transfer is complete (although the progress appears stuck at about 90%). Needs fixing.

However, the branch does provide the basic infrastructure for an inline progressbar - thanks.

I checked that this branch is does not conflict with the current trunk (r2374)

review: Needs Fixing (appearance)
Revision history for this message
Grabli66 (grabli66-r) wrote :

As you can see, need to fix many issues in "Files" to implement
inline-progress.
Sorry, but i don't want see the code of "Files" anymore. It's real mess of
C and Vala code.
Fix that code is a real pain.
I don't want bounty anymore.
You can use branch "inline-progress" as you wish.
Good luck.

2016-11-08 21:41 GMT+03:00 Jeremy Wootten <email address hidden>:

> Review: Needs Fixing appearance
>
> A. Pasting large files into local directory from another partition
> - Progress bars show nicely but the progress is not shown in blue (but
> white on grey). The inline progress bar should be themed the same as the
> other progress bars in Files. Needs fixing.
>
> B. Pasting onto a remote folder (smb, ftp, afp)
> - No inline progress - file does not appear until transfer complete.
> However, the progress window shows the correct state of the transfer. This
> might be tricky to fix and could be left for another branch.
>
> C. Pasting onto USB stick
> - The file appears immediately and the Inline progress bar appears
> briefly and rapidly proceeds to 100% although the file has not been
> completely transferred to the stick. However, the progress window displays
> until the transfer is complete (although the progress appears stuck at
> about 90%). Needs fixing.
>
> However, the branch does provide the basic infrastructure for an inline
> progressbar - thanks.
>
> I checked that this branch is does not conflict with the current trunk
> (r2374)
> --
> https://code.launchpad.net/~grabli66-r/pantheon-files/
> inline-progress/+merge/295618
> You are the owner of lp:~grabli66-r/pantheon-files/inline-progress.
>

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

I understand that Files code is a PITA to work with. I'll discuss with the bounty backers what they are prepared to accept. It may be that just fixing the theming will be enough as your branch does work for local transfers.

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

On further investigation the colour of the inline progress bar is due to the focus being stolen from the view by the progress window. If you click on the view then the bar appears blue as required. It is likely that the progress window will be replaced in future by a header bar widget anyway.

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

Ignore the last comment - it is only true if you replace the custom progress bar with a Gtk.CellRendererProgress.

Unmerged revisions

2175. By grabli66 <email address hidden>

merge with trunc

2174. By Grabli66

fix merge

2173. By Grabli66

po files

2172. By Grabli66

removed unused file from cmakelist

2171. By Grabli66

removed unused code

2170. By Grabli66

fix code style

2169. By Grabli66

po file

2168. By Grabli66

fix progress bar for icon view

2167. By Grabli66

different text color then progress file

2166. By Grabli66

progress finished

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-10-05 11:01:10 +0000
3+++ .bzrignore 2016-09-12 18:13:21 +0000
4@@ -1,1 +1,2 @@
5
6+.vscode
7
8=== modified file 'libcore/fm-list-model.c'
9--- libcore/fm-list-model.c 2015-11-21 12:37:55 +0000
10+++ libcore/fm-list-model.c 2016-09-12 18:13:21 +0000
11@@ -85,6 +85,7 @@
12 GSequence *files;
13 GSequenceIter *ptr;
14 guint loaded : 1;
15+ guint progress;
16 };
17
18 G_DEFINE_TYPE_WITH_CODE (FMListModel, fm_list_model, G_TYPE_OBJECT,
19@@ -131,6 +132,8 @@
20 return GOF_TYPE_FILE;
21 case FM_LIST_MODEL_PIXBUF:
22 return GDK_TYPE_PIXBUF;
23+ case FM_LIST_MODEL_PROGRESS:
24+ return G_TYPE_UINT;
25 default:
26 if (index < FM_LIST_MODEL_NUM_COLUMNS) {
27 return G_TYPE_STRING;
28@@ -271,11 +274,16 @@
29 if (file != NULL) {
30 gof_file_update_icon (file, model->details->icon_size);
31 if (file->pix != NULL)
32- g_value_set_object(value, file->pix);
33+ g_value_set_object (value, file->pix);
34 }
35 break;
36-
37- }
38+
39+ case FM_LIST_MODEL_PROGRESS:
40+ g_value_init (value, G_TYPE_UINT);
41+ if (file != NULL)
42+ g_value_set_uint (value, file_entry->progress);
43+ break;
44+ }
45 }
46
47 static gboolean
48@@ -675,6 +683,7 @@
49 GtkTreeIter iter;
50 GtkTreePath *path;
51 dummy_file_entry = g_new0 (FileEntry, 1);
52+ dummy_file_entry->progress = 0;
53 dummy_file_entry->parent = parent_entry;
54 dummy_file_entry->ptr = g_sequence_insert_sorted (parent_entry->files, dummy_file_entry,
55 fm_list_model_file_entry_compare_func, model);
56@@ -715,6 +724,7 @@
57 }
58
59 file_entry = g_new0 (FileEntry, 1);
60+ file_entry->progress = 0;
61 file_entry->file = file; /* Does not increase reference count */
62 file_entry->parent = NULL;
63 file_entry->subdirectory = NULL;
64@@ -1331,3 +1341,19 @@
65
66 return GPOINTER_TO_INT (g_hash_table_lookup (hash, colstr));
67 }
68+
69+void
70+fm_list_model_set_progress (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, guint progress) {
71+ FMListModel *model;
72+ FileEntry *file_entry;
73+
74+ model = (FMListModel *)tree_model;
75+
76+ g_assert (model->details->stamp == iter->stamp);
77+ g_return_if_fail (!g_sequence_iter_is_end (iter->user_data));
78+
79+ file_entry = g_sequence_get (iter->user_data);
80+ file_entry->progress = progress;
81+
82+ gtk_tree_model_row_changed (tree_model, path, iter);
83+}
84\ No newline at end of file
85
86=== modified file 'libcore/fm-list-model.h'
87--- libcore/fm-list-model.h 2015-11-21 12:37:55 +0000
88+++ libcore/fm-list-model.h 2016-09-12 18:13:21 +0000
89@@ -49,11 +49,12 @@
90 FM_LIST_MODEL_FILE_COLUMN,
91 FM_LIST_MODEL_COLOR,
92 FM_LIST_MODEL_PIXBUF,
93- FM_LIST_MODEL_FILENAME,
94+ FM_LIST_MODEL_FILENAME,
95 FM_LIST_MODEL_SIZE,
96 FM_LIST_MODEL_TYPE,
97 FM_LIST_MODEL_MODIFIED,
98- FM_LIST_MODEL_NUM_COLUMNS
99+ FM_LIST_MODEL_NUM_COLUMNS,
100+ FM_LIST_MODEL_PROGRESS
101 };
102
103 typedef struct FMListModelDetails FMListModelDetails;
104@@ -97,4 +98,6 @@
105 const gchar *fm_list_model_get_string_from_column_id (gint id);
106 gint fm_list_model_get_column_id_from_string (const gchar *colstr);
107
108+void fm_list_model_set_progress (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, guint progress);
109+
110 #endif /* FM_LIST_MODEL_H */
111
112=== modified file 'libcore/marlin-file-operations.c'
113--- libcore/marlin-file-operations.c 2016-07-31 17:59:58 +0000
114+++ libcore/marlin-file-operations.c 2016-09-12 18:13:21 +0000
115@@ -92,14 +92,14 @@
116 typedef struct {
117 CommonJob common;
118 gboolean is_move;
119- GList *files;
120+ GList *files;
121 GFile *destination;
122 //GFile *desktop_location;
123 GdkPoint *icon_positions;
124 int n_icon_positions;
125 GHashTable *debuting_files;
126 MarlinCopyCallback done_callback;
127- gpointer done_callback_data;
128+ gpointer done_callback_data;
129 } CopyMoveJob;
130
131 typedef struct {
132@@ -3084,8 +3084,8 @@
133 guint64 now;
134 gchar *s = NULL;
135
136- job = (CommonJob *)copy_job;
137-
138+ job = (CommonJob *)copy_job;
139+
140 is_move = copy_job->is_move;
141
142 now = g_thread_gettime ();
143@@ -3114,10 +3114,10 @@
144 s = f (is_move ? _("Moving \"%B\" to \"%B\"") :
145 _("Copying \"%B\" to \"%B\""),
146 (GFile *)copy_job->files->data,
147- copy_job->destination);
148+ copy_job->destination);
149 } else {
150 s = f (_("Duplicating \"%B\""), (GFile *)copy_job->files->data);
151- }
152+ }
153 } else if (copy_job->files != NULL && copy_job->files->next == NULL) {
154 if (copy_job->destination != NULL) {
155 s = f (is_move ? ngettext ("Moving %'d file (in \"%B\") to \"%B\"",
156@@ -3135,7 +3135,7 @@
157 files_left),
158 files_left,
159 (GFile *)copy_job->files->data);
160- }
161+ }
162 } else {
163 if (copy_job->destination != NULL) {
164 s = f (is_move?
165@@ -3152,11 +3152,11 @@
166 "Duplicating %'d files",
167 files_left),
168 files_left);
169- }
170+ }
171 }
172- }
173+ }
174
175-#ifdef ENABLE_TASKVIEW
176+#ifdef ENABLE_TASKVIEW
177 g_object_set (job->tv_io,
178 "state", TASKVIEW_RUNNING,
179 "processed-items", (guint64) transfer_info->num_files,
180@@ -3171,7 +3171,7 @@
181 taskview_generic_set_description (TASKVIEW_GENERIC (job->tv_io), s);
182 g_free (s);
183 }
184-
185+
186 // FIXME: current-file?
187 if (copy_job->destination != NULL) {
188 gchar *current_item = g_file_get_uri (copy_job->destination);
189@@ -3180,7 +3180,7 @@
190 NULL);
191 g_free (current_item);
192 }
193-#else
194+#else
195 if (s != NULL)
196 {
197 marlin_progress_info_take_status (job->progress, s);
198@@ -3975,6 +3975,7 @@
199
200 typedef struct {
201 CopyMoveJob *job;
202+ GFile *current_file;
203 goffset last_size;
204 SourceInfo *source_info;
205 TransferInfo *transfer_info;
206@@ -3987,11 +3988,17 @@
207 {
208 ProgressData *pdata;
209 goffset new_size;
210+ CommonJob* job;
211+ uint progress;
212
213 pdata = user_data;
214
215 new_size = current_num_bytes - pdata->last_size;
216-
217+ progress = lround (((double)current_num_bytes / (double)total_num_bytes) * 100);
218+ job = (CommonJob *) pdata->job;
219+ marlin_progress_info_set_current_file (job->progress, pdata->current_file);
220+ marlin_progress_info_set_current_file_progress (job->progress, progress);
221+
222 if (new_size > 0) {
223 pdata->transfer_info->num_bytes += new_size;
224 pdata->last_size = current_num_bytes;
225@@ -4237,8 +4244,8 @@
226 int unique_name_nr;
227 gboolean handled_invalid_filename;
228
229- job = (CommonJob *)copy_job;
230-
231+ job = (CommonJob *)copy_job;
232+
233 if (should_skip_file (job, src)) {
234 *skipped_file = TRUE;
235 return;
236@@ -4337,11 +4344,12 @@
237 if (readonly_source_fs) {
238 flags |= G_FILE_COPY_TARGET_DEFAULT_PERMS;
239 }
240-
241+
242 pdata.job = copy_job;
243 pdata.last_size = 0;
244 pdata.source_info = source_info;
245 pdata.transfer_info = transfer_info;
246+ pdata.current_file = dest;
247
248 if (copy_job->is_move) {
249 res = g_file_move (src, dest,
250@@ -4662,7 +4670,7 @@
251 for (l = job->files;
252 l != NULL && !job_aborted (common);
253 l = l->next) {
254- src = l->data;
255+ src = l->data;
256
257 if (i < job->n_icon_positions) {
258 point = &job->icon_positions[i];
259
260=== modified file 'libcore/marlin-progress-info.c'
261--- libcore/marlin-progress-info.c 2016-06-24 18:59:29 +0000
262+++ libcore/marlin-progress-info.c 2016-09-12 18:13:21 +0000
263@@ -64,6 +64,9 @@
264 gboolean finish_at_idle;
265 gboolean changed_at_idle;
266 gboolean progress_at_idle;
267+
268+ GFile* current_file;
269+ uint current_file_progress;
270 };
271
272 struct _MarlinProgressInfoClass
273@@ -631,3 +634,29 @@
274
275 G_UNLOCK (progress_info);
276 }
277+
278+/*
279+* Sets current file
280+*/
281+void
282+marlin_progress_info_set_current_file (MarlinProgressInfo *info, GFile *current_file)
283+{
284+ info->current_file = current_file;
285+}
286+
287+/*
288+* Gets current file
289+*/
290+GFile *
291+marlin_progress_info_get_current_file (MarlinProgressInfo *info) {
292+ return info->current_file;
293+}
294+
295+void
296+marlin_progress_info_set_current_file_progress (MarlinProgressInfo *info, uint progress) {
297+ info->current_file_progress = progress;
298+}
299+
300+uint marlin_progress_info_get_current_file_progress (MarlinProgressInfo *info) {
301+ return info->current_file_progress;
302+}
303\ No newline at end of file
304
305=== modified file 'libcore/marlin-progress-info.h'
306--- libcore/marlin-progress-info.h 2016-06-24 18:59:29 +0000
307+++ libcore/marlin-progress-info.h 2016-09-12 18:13:21 +0000
308@@ -83,6 +83,15 @@
309 double total);
310 void marlin_progress_info_pulse_progress (MarlinProgressInfo *info);
311
312+void marlin_progress_info_set_current_file (MarlinProgressInfo *info,
313+ GFile *current_file);
314+
315+GFile * marlin_progress_info_get_current_file (MarlinProgressInfo *info);
316+
317+void marlin_progress_info_set_current_file_progress (MarlinProgressInfo *info, uint progress);
318+
319+uint marlin_progress_info_get_current_file_progress (MarlinProgressInfo *info);
320+
321
322
323 #endif /* MARLIN_PROGRESS_INFO_H */
324
325=== modified file 'libcore/pantheon-files-core-C.vapi'
326--- libcore/pantheon-files-core-C.vapi 2016-06-24 18:59:29 +0000
327+++ libcore/pantheon-files-core-C.vapi 2016-09-12 18:13:21 +0000
328@@ -23,12 +23,13 @@
329 SIZE,
330 TYPE,
331 MODIFIED,
332- NUM_COLUMNS
333+ NUM_COLUMNS,
334+ PROGRESS
335 }
336
337- public bool load_subdirectory(Gtk.TreePath path, out GOF.Directory.Async dir);
338- public bool unload_subdirectory(Gtk.TreeIter iter);
339- public void add_file(GOF.File file, GOF.Directory.Async dir);
340+ public bool load_subdirectory (Gtk.TreePath path, out GOF.Directory.Async dir);
341+ public bool unload_subdirectory (Gtk.TreeIter iter);
342+ public void add_file (GOF.File file, GOF.Directory.Async dir);
343 public bool remove_file (GOF.File file, GOF.Directory.Async dir);
344 public void file_changed (GOF.File file, GOF.Directory.Async dir);
345 public GOF.File? file_for_path (Gtk.TreePath path);
346@@ -39,6 +40,7 @@
347 public GOF.File file_for_iter (Gtk.TreeIter iter);
348 public void clear ();
349 public signal void subdirectory_unloaded (GOF.Directory.Async directory);
350+ public void set_progress (Gtk.TreePath path, Gtk.TreeIter iter, uint progress);
351 }
352 }
353
354@@ -205,6 +207,10 @@
355 public bool get_is_finished ();
356 public bool get_is_paused ();
357 public GLib.Cancellable get_cancellable ();
358+ public void set_current_file (GLib.File current_file);
359+ public unowned GLib.File get_current_file ();
360+ public void set_current_file_progress (uint progress);
361+ public uint get_current_file_progress ();
362 }
363
364 [CCode (cheader_filename = "marlin-progress-info-manager.h")]
365
366=== modified file 'src/Application.vala'
367--- src/Application.vala 2016-06-29 18:56:26 +0000
368+++ src/Application.vala 2016-09-12 18:13:21 +0000
369@@ -25,8 +25,7 @@
370
371 public class Marlin.Application : Granite.Application {
372
373- private VolumeMonitor volume_monitor;
374- private Marlin.Progress.UIHandler progress_handler;
375+ private VolumeMonitor volume_monitor;
376 private Marlin.ClipboardManager clipboard;
377 private Marlin.Thumbnailer thumbnailer;
378 private Gtk.RecentManager recent;
379@@ -35,6 +34,7 @@
380 private const uint MAX_WINDOWS = 25;
381
382 public int window_count { get; private set; }
383+ public Marlin.Progress.UIHandler progress_handler;
384
385 bool quitting = false;
386
387@@ -87,9 +87,8 @@
388 Gtk.IconTheme.get_default ().changed.connect (() => {
389 Marlin.IconInfo.clear_caches ();
390 });
391-
392+
393 progress_handler = new Marlin.Progress.UIHandler (this);
394-
395 this.clipboard = new Marlin.ClipboardManager.get_for_display (Gdk.Display.get_default ());
396 this.thumbnailer = Marlin.Thumbnailer.get ();
397 this.recent = new Gtk.RecentManager ();
398
399=== modified file 'src/CMakeLists.txt'
400--- src/CMakeLists.txt 2016-07-25 19:49:17 +0000
401+++ src/CMakeLists.txt 2016-09-12 18:13:21 +0000
402@@ -82,7 +82,7 @@
403 marlin-deep-count.vala
404 ProgressInfoWidget.vala
405 ProgressUIHandler.vala
406- TextRenderer.vala
407+ TextRenderer.vala
408 QuicklistHandler.vala
409 View/AbstractPropertiesDialog.vala
410 View/ColumnView.vala
411
412=== modified file 'src/ProgressUIHandler.vala'
413--- src/ProgressUIHandler.vala 2016-08-03 19:01:55 +0000
414+++ src/ProgressUIHandler.vala 2016-09-12 18:13:21 +0000
415@@ -26,7 +26,10 @@
416 * completion of the operation unless it was cancelled by the user.
417 ***/
418 public class Marlin.Progress.UIHandler : Object {
419-
420+
421+ public signal void progress_changed (GLib.File current_file, uint progress);
422+ public signal void progress_finished ();
423+
424 private Marlin.Progress.InfoManager manager = null;
425 #if HAVE_UNITY
426 private Marlin.QuicklistHandler quicklist_handler = null;
427@@ -50,8 +53,18 @@
428 this.manager = new Marlin.Progress.InfoManager ();
429 this.application = app;
430
431- manager.new_progress_info.connect ((info) => {
432+ manager.new_progress_info.connect ((info) => {
433 info.started.connect (progress_info_started_cb);
434+ info.progress_changed.connect (() => {
435+ var current_file = info.get_current_file ();
436+ var curren_progress = info.get_current_file_progress ();
437+ if (current_file != null) {
438+ progress_changed (current_file, curren_progress);
439+ }
440+ });
441+ info.finished.connect (() => {
442+ progress_finished ();
443+ });
444 });
445
446 var theme = Gtk.IconTheme.get_default ();
447
448=== modified file 'src/TextRenderer.vala'
449--- src/TextRenderer.vala 2016-05-06 10:36:16 +0000
450+++ src/TextRenderer.vala 2016-09-12 18:13:21 +0000
451@@ -18,7 +18,8 @@
452
453 namespace Marlin {
454 public class TextRenderer: Gtk.CellRendererText {
455-
456+ const string PROGRESS_TEXT_COLOR = "#777777";
457+ const string NORMAL_TEXT_COLOR = "#000000";
458 const int MAX_LINES = 5;
459 const uint BORDER_RADIUS = 6;
460
461@@ -28,6 +29,9 @@
462 public GOF.File? file {set; private get;}
463 public int text_width;
464 public int text_height;
465+
466+ // For progress bar
467+ public uint progress { set; private get; }
468
469 int char_width;
470 int char_height;
471@@ -35,9 +39,11 @@
472 Pango.Layout layout;
473 Gtk.Widget widget;
474 public Marlin.AbstractEditableLabel entry;
475+ Marlin.ViewMode viewmode;
476
477 public TextRenderer (Marlin.ViewMode viewmode) {
478 this.mode = Gtk.CellRendererMode.EDITABLE;
479+ this.viewmode = viewmode;
480
481 if (viewmode == Marlin.ViewMode.ICON)
482 entry = new Marlin.MultiLineEditableLabel ();
483@@ -55,17 +61,17 @@
484 Gdk.Rectangle cell_area,
485 Gtk.CellRendererState flags) {
486 set_widget (widget);
487- Gtk.StateFlags state = widget.get_state_flags ();
488-
489+ Gtk.StateFlags state = widget.get_state_flags ();
490+
491 if ((flags & Gtk.CellRendererState.SELECTED) == Gtk.CellRendererState.SELECTED)
492 state |= Gtk.StateFlags.SELECTED;
493 else if ((flags & Gtk.CellRendererState.PRELIT) == Gtk.CellRendererState.PRELIT)
494 state = Gtk.StateFlags.PRELIGHT;
495 else
496- state = widget.get_sensitive () ? Gtk.StateFlags.NORMAL : Gtk.StateFlags.INSENSITIVE;
497-
498- set_up_layout (text, cell_area);
499-
500+ state = widget.get_sensitive () ? Gtk.StateFlags.NORMAL : Gtk.StateFlags.INSENSITIVE;
501+
502+ set_up_layout (text, cell_area);
503+
504 var style_context = widget.get_parent ().get_style_context ();
505 style_context.save ();
506 style_context.set_state (state);
507@@ -84,13 +90,16 @@
508 x_offset += focus_border_width + 2 * (int)xpad;
509 y_offset += focus_border_width;
510 }
511-
512+
513 style_context.render_layout (cr,
514 cell_area.x + x_offset,
515 cell_area.y + y_offset,
516 layout);
517-
518- style_context.restore ();
519+
520+ // Draws progress bar
521+ draw_progress (cr, cell_area);
522+
523+ style_context.restore ();
524
525 /* The render call should always be preceded by a set_property call
526 from GTK. It should be safe to unreference or free the allocated
527@@ -99,9 +108,9 @@
528 }
529
530 public void set_up_layout (string? text, Gdk.Rectangle cell_area) {
531- /* render small/normal text depending on the zoom_level */
532+ /* render small/normal text depending on the zoom_level */
533 if (text == null)
534- text= " ";
535+ text= " ";
536
537 bool small = this.zoom_level < Marlin.ZoomLevel.NORMAL;
538 if (small)
539@@ -122,8 +131,12 @@
540
541 if (xalign == 0.5f)
542 layout.set_alignment (Pango.Alignment.CENTER);
543-
544- layout.set_text (text, -1);
545+
546+ if ((progress > 0) && (progress < 100)) {
547+ layout.set_markup ("<span foreground=\"" + PROGRESS_TEXT_COLOR + "\">" + text + "</span>", -1);
548+ } else {
549+ layout.set_markup ("<span foreground=\"" + NORMAL_TEXT_COLOR + "\">" + text + "</span>", -1);
550+ }
551
552 /* calculate the real text dimension */
553 int width, height;
554@@ -238,6 +251,56 @@
555 on_entry_editing_done ();
556 return false;
557 }
558+
559+ /*
560+ * Draws rounded path
561+ */
562+ private void draw_rounded_path(Cairo.Context ctx, double x, double y,
563+ double width, double height, double radius) {
564+
565+ double degrees = 3.14 / 180.0;
566+ ctx.new_sub_path ();
567+ ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
568+ ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
569+ ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
570+ ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
571+ ctx.close_path();
572+ }
573+
574+ /*
575+ * Draws progress bar
576+ */
577+ private void draw_progress (Cairo.Context cr, Gdk.Rectangle cell_area) {
578+ if (progress == 0 || progress >= 100) return;
579+
580+ var bar_height = 6;
581+ var bar_width = 70;
582+ var padd_right = 2;
583+
584+ long center_y = 0;
585+ long x = 0;
586+
587+ if (viewmode == Marlin.ViewMode.ICON) {
588+ center_y = Math.lround (cell_area.y + cell_area.height / 2.0f) - bar_height + ypad;
589+ x = Math.lround (cell_area.x + cell_area.width / 2.0f - bar_width / 2.0f - xpad);
590+ } else {
591+ center_y = Math.lround ((cell_area.y + cell_area.height / 2.0f)) - bar_height + ypad;
592+ x = cell_area.x + cell_area.width - bar_width - xpad - padd_right;
593+ }
594+
595+ var progress_size = Math.lround(bar_width / (100.0 / progress));
596+
597+ cr.set_source_rgb (0.65f, 0.65f, 0.65f);
598+ draw_rounded_path (cr, x, center_y, bar_width, bar_height, 3);
599+ cr.stroke();
600+ cr.set_source_rgb (0.83f, 0.83f, 0.83f);
601+ draw_rounded_path (cr, x, center_y, bar_width, bar_height, 3);
602+ cr.fill();
603+ cr.set_source_rgb (1, 1, 1);
604+ draw_rounded_path (cr, x, center_y, progress_size, bar_height, 3);
605+ cr.fill();
606+ }
607+
608
609 private void draw_focus (Cairo.Context cr,
610 Gdk.Rectangle cell_area,
611
612=== modified file 'src/View/AbstractDirectoryView.vala'
613--- src/View/AbstractDirectoryView.vala 2016-09-09 09:42:09 +0000
614+++ src/View/AbstractDirectoryView.vala 2016-09-12 18:13:21 +0000
615@@ -240,6 +240,9 @@
616 protected static Marlin.DndHandler dnd_handler = new Marlin.DndHandler ();
617
618 protected unowned Gtk.RecentManager recent;
619+
620+ // For inline progress, last changed file
621+ protected GOF.File last_current_file = null;
622
623 public signal void path_change_request (GLib.File location, int flag = 0, bool new_root = true);
624 public signal void item_hovered (GOF.File? file);
625@@ -881,7 +884,7 @@
626 }
627 }
628
629- private void add_file (GOF.File file, GOF.Directory.Async dir) {
630+ private void add_file (GOF.File file, GOF.Directory.Async dir) {
631 model.add_file (file, dir);
632
633 if (select_added_files)
634@@ -3510,6 +3513,7 @@
635 bool start_editing,
636 bool select,
637 bool scroll_to_top);
638+
639 protected abstract Gtk.Widget? create_view ();
640 protected abstract Marlin.ZoomLevel get_set_up_zoom_level ();
641 protected abstract Marlin.ZoomLevel get_normal_zoom_level ();
642@@ -3528,6 +3532,36 @@
643 protected abstract void thaw_tree ();
644 protected new abstract void freeze_child_notify ();
645 protected new abstract void thaw_child_notify ();
646+
647+ // Sets progress to file
648+ public virtual void process_progress(GLib.File current_file, uint progress) {
649+ if (current_file == null) return;
650+ var gof_file = GOF.File.@get(current_file);
651+
652+ // Resets last file progress
653+ if ((last_current_file != null) && (last_current_file.uri != gof_file.uri)) {
654+ reset_progress();
655+ }
656+
657+ Gtk.TreeIter iter;
658+ if (model.get_first_iter_for_file(gof_file, out iter)) {
659+ var path = model.get_path(iter);
660+ model.set_progress (path, iter, progress);
661+ }
662+
663+ last_current_file = gof_file;
664+ }
665+
666+ // Resets progress
667+ public virtual void reset_progress() {
668+ if (last_current_file != null) {
669+ Gtk.TreeIter iter;
670+ if (model.get_first_iter_for_file(last_current_file, out iter)) {
671+ var path = model.get_path(iter);
672+ model.set_progress (path, iter, 0);
673+ }
674+ }
675+ }
676
677 /** Unimplemented methods
678 * fm_directory_view_parent_set () - purpose unclear
679
680=== modified file 'src/View/AbstractTreeView.vala'
681--- src/View/AbstractTreeView.vala 2016-06-27 12:08:16 +0000
682+++ src/View/AbstractTreeView.vala 2016-09-12 18:13:21 +0000
683@@ -52,7 +52,8 @@
684 name_column.set_attributes (name_renderer,
685 "text", FM.ListModel.ColumnID.FILENAME,
686 "file", FM.ListModel.ColumnID.FILE_COLUMN,
687- "background", FM.ListModel.ColumnID.COLOR);
688+ "background", FM.ListModel.ColumnID.COLOR,
689+ "progress", FM.ListModel.ColumnID.PROGRESS);
690
691 tree.append_column (name_column);
692 }
693
694=== modified file 'src/View/ColumnView.vala'
695--- src/View/ColumnView.vala 2016-06-26 14:13:58 +0000
696+++ src/View/ColumnView.vala 2016-09-12 18:13:21 +0000
697@@ -168,6 +168,6 @@
698 public override void cancel () {
699 base.cancel ();
700 cancel_await_double_click ();
701- }
702+ }
703 }
704 }
705
706=== modified file 'src/View/IconView.vala'
707--- src/View/IconView.vala 2016-06-27 12:08:16 +0000
708+++ src/View/IconView.vala 2016-09-12 18:13:21 +0000
709@@ -18,8 +18,8 @@
710
711 namespace FM {
712 public class IconView : AbstractDirectoryView {
713- protected new Gtk.IconView tree;
714-
715+ protected new Gtk.IconView tree;
716+
717 public IconView (Marlin.View.Slot _slot) {
718 assert (_slot != null);
719 base (_slot);
720@@ -45,6 +45,7 @@
721 (tree as Gtk.CellLayout).add_attribute (name_renderer, "file", FM.ListModel.ColumnID.FILE_COLUMN);
722 (tree as Gtk.CellLayout).add_attribute (name_renderer, "background", FM.ListModel.ColumnID.COLOR);
723 (tree as Gtk.CellLayout).add_attribute (icon_renderer, "file", FM.ListModel.ColumnID.FILE_COLUMN);
724+ (tree as Gtk.CellLayout).add_attribute (name_renderer, "progress", FM.ListModel.ColumnID.PROGRESS);
725
726 connect_tree_signals ();
727 }
728@@ -448,6 +449,6 @@
729 path.next ();
730 }
731 return index;
732- }
733+ }
734 }
735 }
736
737=== modified file 'src/View/ListView.vala'
738--- src/View/ListView.vala 2016-06-09 08:48:35 +0000
739+++ src/View/ListView.vala 2016-09-12 18:13:21 +0000
740@@ -32,8 +32,8 @@
741 /* ListView manages the loading and unloading of subdirectories displayed */
742 private uint unload_file_timeout_id = 0;
743 private GLib.List<Gtk.TreeRowReference> subdirectories_to_unload = null;
744- private GLib.List<GOF.Directory.Async> loaded_subdirectories = null;
745-
746+ private GLib.List<GOF.Directory.Async> loaded_subdirectories = null;
747+
748 public ListView (Marlin.View.Slot _slot) {
749 base (_slot);
750 }
751@@ -185,7 +185,6 @@
752 tree.set_rubber_banding (true);
753 append_extra_tree_columns ();
754 connect_additional_signals ();
755-
756 return tree as Gtk.Widget;
757 }
758
759@@ -278,6 +277,6 @@
760 loaded_subdirectories.@foreach ((dir) => {
761 remove_subdirectory (dir);
762 });
763- }
764+ }
765 }
766 }
767
768=== modified file 'src/View/Window.vala'
769--- src/View/Window.vala 2016-08-23 18:52:01 +0000
770+++ src/View/Window.vala 2016-09-12 18:13:21 +0000
771@@ -339,6 +339,26 @@
772 sidebar.sync_needed.connect (() => {
773 loading_uri (current_tab.uri);
774 });
775+
776+ // Connects progress signals
777+ connect_progress_signals();
778+ }
779+
780+ // Connects progress signals
781+ private void connect_progress_signals() {
782+ var ui_handler = ((Marlin.Application) application).progress_handler;
783+ ui_handler.progress_changed.connect ((current_file, progress)=> {
784+ var dir_view = ((Slot)get_active_slot()).get_directory_view ();
785+ dir_view.process_progress (current_file, progress);
786+ });
787+
788+ ui_handler.progress_finished.connect (() => {
789+ foreach (var tab in tabs.tabs) {
790+ var view_container = (tab.page as ViewContainer);
791+ var dir_view = ((Slot)view_container.slot).get_directory_view ();
792+ dir_view.reset_progress ();
793+ }
794+ });
795 }
796
797 private void make_bindings () {

Subscribers

People subscribed via source and target branches

to all changes: