summaryrefslogtreecommitdiff
path: root/src/library/Branch.vala
blob: dc05d60988503a818eb8b3bc9d97edf29e85981b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Copyright 2011-2014 Yorba Foundation
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

public class Library.Branch : Sidebar.RootOnlyBranch {
    public Branch() {
        base (new Library.SidebarEntry());
    }
    
    public Library.MainPage get_main_page() {
        return (Library.MainPage) ((Library.SidebarEntry) get_root()).get_page();
    }
}

public class Library.SidebarEntry : Sidebar.SimplePageEntry {
    private Icon icon = new ThemedIcon(Resources.ICON_PHOTOS);
    
    public SidebarEntry() {
    }
    
    public override string get_sidebar_name() {
        return Library.MainPage.NAME;
    }
    
    public override Icon? get_sidebar_icon() {
        return icon;
    }
    
    protected override Page create_page() {
        return new Library.MainPage();
    }
}

public class Library.MainPage : CollectionPage {
    public const string NAME = _("Library");
    
    public MainPage(ProgressMonitor? monitor = null) {
        base (NAME);
        
        foreach (MediaSourceCollection sources in MediaCollectionRegistry.get_instance().get_all())
            get_view().monitor_source_collection(sources, new CollectionViewManager(this), null, null, monitor);
    }
    
    protected override void get_config_photos_sort(out bool sort_order, out int sort_by) {
        Config.Facade.get_instance().get_library_photos_sort(out sort_order, out sort_by);
    }

    protected override void set_config_photos_sort(bool sort_order, int sort_by) {
        Config.Facade.get_instance().set_library_photos_sort(sort_order, sort_by);
    }
}