Merge lp:~codygarver/pantheon-photos/fix-1360051 into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Cody Garver
Status: Merged
Approved by: Danielle Foré
Approved revision: 2601
Merged at revision: 2601
Proposed branch: lp:~codygarver/pantheon-photos/fix-1360051
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 395 lines (+3/-319)
7 files modified
src/folders/Branch.vala (+0/-204)
src/folders/Folders.vala (+0/-35)
src/folders/Page.vala (+0/-41)
src/folders/mk/folders.mk (+0/-31)
src/library/LibraryWindow.vala (+1/-4)
src/library/mk/library.mk (+1/-2)
units.mk (+1/-2)
To merge this branch: bzr merge lp:~codygarver/pantheon-photos/fix-1360051
Reviewer Review Type Date Requested Status
meese Abstain
Review via email: mp+232499@code.launchpad.net

Commit message

Drop "Folders" feature seen in sidebar (lp:1360051)

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

Works but I really don't think this is a good idea. Photos isn't a file browser but folder structure is an amazing filter to have for searching through large amounts of photos, think of it as an additional exif property you can use filtering?

review: Abstain
Revision history for this message
Danielle Foré (danrabbit) wrote :

If the code is good, I can approve for UX. We let Photos be a photo manager and Files can be a file manager :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'src/folders'
2=== removed file 'src/folders/Branch.vala'
3--- src/folders/Branch.vala 2014-08-08 21:13:09 +0000
4+++ src/folders/Branch.vala 1970-01-01 00:00:00 +0000
5@@ -1,204 +0,0 @@
6-/* Copyright 2012-2013 Yorba Foundation
7- *
8- * This software is licensed under the GNU Lesser General Public License
9- * (version 2.1 or later). See the COPYING file in this distribution.
10- */
11-
12-public class Folders.Branch : Sidebar.Branch {
13- private Gee.HashMap<File, Folders.SidebarEntry> entries =
14- new Gee.HashMap<File, Folders.SidebarEntry> (file_hash, file_equal);
15- private File home_dir;
16-
17- public class Branch () {
18- base (new Folders.Root (), Sidebar.Branch.Options.STARTUP_OPEN_GROUPING, comparator);
19-
20- home_dir = File.new_for_path (Environment.get_home_dir ());
21-
22- foreach (MediaSourceCollection sources in MediaCollectionRegistry.get_instance ().get_all ()) {
23- // seed
24- on_media_contents_altered (sources.get_all (), null);
25-
26- // monitor
27- sources.contents_altered.connect (on_media_contents_altered);
28- }
29- }
30-
31- ~Branch () {
32- foreach (MediaSourceCollection sources in MediaCollectionRegistry.get_instance ().get_all ())
33- sources.contents_altered.disconnect (on_media_contents_altered);
34- }
35-
36- private static int comparator (Sidebar.Entry a, Sidebar.Entry b) {
37- if (a == b)
38- return 0;
39-
40- int coll_key_equality = strcmp (((Folders.SidebarEntry) a).collation,
41- ((Folders.SidebarEntry) b).collation);
42-
43- if (coll_key_equality == 0) {
44- // Collation keys were the same, double-check that
45- // these really are the same string...
46- return strcmp (((Folders.SidebarEntry) a).get_sidebar_name (),
47- ((Folders.SidebarEntry) b).get_sidebar_name ());
48- }
49-
50- return coll_key_equality;
51- }
52-
53- private void on_master_source_replaced (MediaSource media_source, File old_file, File new_file) {
54- remove_entry (old_file);
55- add_entry (media_source);
56- }
57-
58- private void on_media_contents_altered (Gee.Iterable<DataObject>? added, Gee.Iterable<DataObject>? removed) {
59- if (added != null) {
60- foreach (DataObject object in added) {
61- add_entry ((MediaSource) object);
62- ((MediaSource) object).master_replaced.connect (on_master_source_replaced);
63- }
64- }
65-
66- if (removed != null) {
67- foreach (DataObject object in removed) {
68- remove_entry (((MediaSource) object).get_file ());
69- ((MediaSource) object).master_replaced.disconnect (on_master_source_replaced);
70- }
71- }
72- }
73-
74- void add_entry (MediaSource media) {
75- File file = media.get_file ();
76-
77- Gee.ArrayList<File> elements = new Gee.ArrayList<File> ();
78-
79- // add the path elements in reverse order up to home directory
80- File? parent = file.get_parent ();
81- while (parent != null) {
82- // don't process paths above the user's home directory
83- if (parent.equal (home_dir.get_parent ()))
84- break;
85-
86- elements.add (parent);
87-
88- parent = parent.get_parent ();
89- }
90-
91- // walk path elements in order from home directory down, building needed sidebar entries
92- // along the way
93- Folders.SidebarEntry? parent_entry = null;
94- for (int ctr = elements.size - 1; ctr >= 0; ctr--) {
95- File parent_dir = elements[ctr];
96-
97- // save current parent, needed if this entry needs to be grafted
98- Folders.SidebarEntry? old_parent_entry = parent_entry;
99-
100- parent_entry = entries.get (parent_dir);
101- if (parent_entry == null) {
102- parent_entry = new Folders.SidebarEntry (parent_dir);
103- entries.set (parent_dir, parent_entry);
104-
105- graft ((old_parent_entry == null) ? get_root () : old_parent_entry, parent_entry);
106- }
107-
108- // only increment entry's file count if File is going in this folder
109- if (ctr == 0)
110- parent_entry.count++;
111- }
112- }
113-
114- private void remove_entry (File file) {
115- Folders.SidebarEntry? folder_entry = entries.get (file.get_parent ());
116- if (folder_entry == null)
117- return;
118-
119- assert (folder_entry.count > 0);
120-
121- // decrement file count for folder of photo
122- if (--folder_entry.count > 0 || get_child_count (folder_entry) > 0)
123- return;
124-
125- // empty folder so prune tree
126- Folders.SidebarEntry? prune_point = folder_entry;
127- assert (prune_point != null);
128-
129- for (;;) {
130- bool removed = entries.unset (prune_point.dir);
131- assert (removed);
132-
133- Folders.SidebarEntry? parent = get_parent (prune_point) as Folders.SidebarEntry;
134- if (parent == null || parent.count != 0 || get_child_count (parent) > 1)
135- break;
136-
137- prune_point = parent;
138- }
139-
140- prune (prune_point);
141- }
142-}
143-
144-private class Folders.Root : Sidebar.Grouping {
145- public Root () {
146- base (_ ("Folders"), Folders.opened_icon, Folders.closed_icon);
147- }
148-}
149-
150-public class Folders.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.ExpandableEntry {
151- public File dir {
152- get;
153- private set;
154- }
155- public string collation {
156- get;
157- private set;
158- }
159-
160- private int _count = 0;
161- public int count {
162- get {
163- return _count;
164- }
165-
166- set {
167- int prev_count = _count;
168- _count = value;
169-
170- // when count change 0->1 and 1->0 may need refresh icon
171- if ((prev_count == 0 && _count == 1) || (prev_count == 1 && _count == 0))
172- sidebar_icon_changed (get_sidebar_icon ());
173-
174- }
175- }
176-
177- public SidebarEntry (File dir) {
178- this.dir = dir;
179- collation = g_utf8_collate_key_for_filename (dir.get_path ());
180- }
181-
182- public override string get_sidebar_name () {
183- return dir.get_basename ();
184- }
185-
186- public override Icon? get_sidebar_icon () {
187- return count == 0 ? closed_icon : have_photos_icon;
188- }
189-
190- public override string to_string () {
191- return dir.get_path ();
192- }
193-
194- public Icon? get_sidebar_open_icon () {
195- return count == 0 ? opened_icon : have_photos_icon;
196- }
197-
198- public Icon? get_sidebar_closed_icon () {
199- return count == 0 ? closed_icon : have_photos_icon;
200- }
201-
202- public bool expand_on_select () {
203- return true;
204- }
205-
206- protected override global::Page create_page () {
207- return new Folders.Page (dir);
208- }
209-}
210
211=== removed file 'src/folders/Folders.vala'
212--- src/folders/Folders.vala 2014-08-08 21:13:09 +0000
213+++ src/folders/Folders.vala 1970-01-01 00:00:00 +0000
214@@ -1,35 +0,0 @@
215-/* Copyright 2012-2013 Yorba Foundation
216- *
217- * This software is licensed under the GNU Lesser General Public License
218- * (version 2.1 or later). See the COPYING file in this distribution.
219- */
220-
221-/* This file is the master unit file for the Folders unit. It should be edited to include
222- * whatever code is deemed necessary.
223- *
224- * The init () and terminate () methods are mandatory.
225- *
226- * If the unit needs to be configured prior to initialization, add the proper parameters to
227- * the preconfigure () method, implement it, and ensure in init () that it's been called.
228- */
229-
230-namespace Folders {
231-
232-static Icon? opened_icon = null;
233-static Icon? closed_icon = null;
234-static Icon? have_photos_icon = null;
235-
236-public void init () throws Error {
237- opened_icon = new ThemedIcon (Resources.ICON_FOLDER_OPEN);
238- closed_icon = new ThemedIcon (Resources.ICON_FOLDER_CLOSED);
239- have_photos_icon = new ThemedIcon (Resources.ICON_FOLDER_DOCUMENTS);
240-}
241-
242-public void terminate () {
243- opened_icon = null;
244- closed_icon = null;
245- have_photos_icon = null;
246-}
247-
248-}
249-
250
251=== removed file 'src/folders/Page.vala'
252--- src/folders/Page.vala 2014-08-08 21:13:09 +0000
253+++ src/folders/Page.vala 1970-01-01 00:00:00 +0000
254@@ -1,41 +0,0 @@
255-/* Copyright 2012-2013 Yorba Foundation
256- *
257- * This software is licensed under the GNU Lesser General Public License
258- * (version 2.1 or later). See the COPYING file in this distribution.
259- */
260-
261-public class Folders.Page : CollectionPage {
262- private class FolderViewManager : CollectionViewManager {
263- public File dir;
264-
265- public FolderViewManager (Folders.Page owner, File dir) {
266- base (owner);
267-
268- this.dir = dir;
269- }
270-
271- public override bool include_in_view (DataSource source) {
272- return ((MediaSource) source).get_file ().has_prefix (dir);
273- }
274- }
275-
276- private FolderViewManager view_manager;
277-
278- public Page (File dir) {
279- base (dir.get_path ());
280-
281- view_manager = new FolderViewManager (this, dir);
282-
283- foreach (MediaSourceCollection sources in MediaCollectionRegistry.get_instance ().get_all ())
284- get_view ().monitor_source_collection (sources, view_manager, null);
285- }
286-
287- protected override void get_config_photos_sort (out bool sort_order, out int sort_by) {
288- Config.Facade.get_instance ().get_library_photos_sort (out sort_order, out sort_by);
289- }
290-
291- protected override void set_config_photos_sort (bool sort_order, int sort_by) {
292- Config.Facade.get_instance ().set_library_photos_sort (sort_order, sort_by);
293- }
294-}
295-
296
297=== removed directory 'src/folders/mk'
298=== removed file 'src/folders/mk/folders.mk'
299--- src/folders/mk/folders.mk 2013-01-12 00:20:39 +0000
300+++ src/folders/mk/folders.mk 1970-01-01 00:00:00 +0000
301@@ -1,31 +0,0 @@
302-
303-# UNIT_NAME is the Vala namespace. A file named UNIT_NAME.vala must be in this directory with
304-# a init() and terminate() function declared in the namespace.
305-UNIT_NAME := Folders
306-
307-# UNIT_DIR should match the subdirectory the files are located in. Generally UNIT_NAME in all
308-# lowercase. The name of this file should be UNIT_DIR.mk.
309-UNIT_DIR := folders
310-
311-# All Vala files in the unit should be listed here with no subdirectory prefix.
312-#
313-# NOTE: Do *not* include the unit's master file, i.e. UNIT_NAME.vala.
314-UNIT_FILES := \
315- Branch.vala \
316- Page.vala
317-
318-# Any unit this unit relies upon (and should be initialized before it's initialized) should
319-# be listed here using its Vala namespace.
320-#
321-# NOTE: All units are assumed to rely upon the unit-unit. Do not include that here.
322-UNIT_USES := \
323- Sidebar \
324- Photos
325-
326-# List any additional files that are used in the build process as a part of this unit that should
327-# be packaged in the tarball. File names should be relative to the unit's home directory.
328-UNIT_RC :=
329-
330-# unitize.mk must be called at the end of each UNIT_DIR.mk file.
331-include unitize.mk
332-
333
334=== modified file 'src/library/LibraryWindow.vala'
335--- src/library/LibraryWindow.vala 2014-08-24 01:29:08 +0000
336+++ src/library/LibraryWindow.vala 2014-08-28 03:41:49 +0000
337@@ -45,7 +45,6 @@
338 CAMERAS,
339 SAVED_SEARCH,
340 EVENTS,
341- FOLDERS,
342 TAGS,
343 }
344
345@@ -111,7 +110,6 @@
346 private Sidebar.Tree sidebar_tree;
347 private Library.Branch library_branch = new Library.Branch ();
348 private Tags.Branch tags_branch = new Tags.Branch ();
349- private Folders.Branch folders_branch = new Folders.Branch ();
350 private Events.Branch events_branch = new Events.Branch ();
351 private Camera.Branch camera_branch = new Camera.Branch ();
352 private Searches.Branch saved_search_branch = new Searches.Branch ();
353@@ -160,7 +158,6 @@
354
355 sidebar_tree.graft (library_branch, SidebarRootPosition.LIBRARY);
356 sidebar_tree.graft (tags_branch, SidebarRootPosition.TAGS);
357- sidebar_tree.graft (folders_branch, SidebarRootPosition.FOLDERS);
358 sidebar_tree.graft (events_branch, SidebarRootPosition.EVENTS);
359 sidebar_tree.graft (camera_branch, SidebarRootPosition.CAMERAS);
360 sidebar_tree.graft (saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
361@@ -1539,4 +1536,4 @@
362
363 return false;
364 }
365-}
366\ No newline at end of file
367+}
368
369=== modified file 'src/library/mk/library.mk'
370--- src/library/mk/library.mk 2014-06-09 02:31:50 +0000
371+++ src/library/mk/library.mk 2014-08-28 03:41:49 +0000
372@@ -42,8 +42,7 @@
373 Tags \
374 Camera \
375 Searches \
376- DataImports \
377- Folders
378+ DataImports
379
380 # List any additional files that are used in the build process as a part of this unit that should
381 # be packaged in the tarball. File names should be relative to the unit's home directory.
382
383=== modified file 'units.mk'
384--- units.mk 2013-01-12 00:20:39 +0000
385+++ units.mk 2014-08-28 03:41:49 +0000
386@@ -25,8 +25,7 @@
387 camera \
388 searches \
389 config \
390- data_imports \
391- folders
392+ data_imports
393
394 # Name(s) of units that represent application entry points. These units will have init and
395 # termination entry points generated: Name.unitize_init() and Name.unitize_terminate(). These

Subscribers

People subscribed via source and target branches

to all changes: