Commit 48f08391 authored by Jens Georg's avatar Jens Georg
parent fe9bdea9
public class ImportRoll.Branch : Sidebar.Branch {
private Gee.HashMap<int64?, ImportRoll.SidebarEntry> entries;
public class Branch() {
base (new ImportRoll.Root(),
Sidebar.Branch.Options.STARTUP_OPEN_GROUPING
| Sidebar.Branch.Options.HIDE_IF_EMPTY,
ImportRoll.Branch.comparator);
this.entries = new Gee.HashMap<int64?, ImportRoll.SidebarEntry>((Gee.HashDataFunc<int64?>)GLib.int64_hash,
(Gee.EqualDataFunc<int64?>)GLib.int64_equal);
foreach (var source in MediaCollectionRegistry.get_instance().get_all()) {
on_import_rolls_altered(source);
source.import_roll_altered.connect(on_import_rolls_altered);
}
}
private static int comparator(Sidebar.Entry a, Sidebar.Entry b) {
if (a == b)
return 0;
var entry_a = (ImportRoll.SidebarEntry) a;
var entry_b = (ImportRoll.SidebarEntry) b;
return -ImportID.compare_func(entry_a.get_id(), entry_b.get_id());
}
private void on_import_rolls_altered(MediaSourceCollection source) {
var ids = source.get_import_roll_ids();
foreach (var id in ids) {
if (!this.entries.has_key (id.id)) {
var entry = new ImportRoll.SidebarEntry(id);
entries.set(id.id, entry);
graft(get_root(), entry);
}
}
}
}
private class ImportRoll.Root : Sidebar.Header {
public Root() {
base (_("Imports"), _("Browse the library's import history"));
}
}
/* Copyright 2016 Software Freedom Conservancy Inc.
*
* 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 ImportRoll.SidebarEntry : Library.HideablePageEntry {
private ImportID id;
private string name;
public SidebarEntry(ImportID id) {
base();
this.id = id;
this.name = new DateTime.from_unix_local(id.id).format("%c");
}
public ImportID get_id() {
return id;
}
public override string get_sidebar_name() {
return this.name;
}
public override string? get_sidebar_icon() {
return Resources.ICON_LAST_IMPORT;
}
protected override Page create_page() {
return new LastImportPage.for_id(this.id);
}
}
......@@ -35,6 +35,20 @@ public class LastImportPage : CollectionPage {
// set up view manager for the last import roll
on_import_rolls_altered();
}
public LastImportPage.for_id(ImportID id) {
base(NAME);
this.last_import_id = id;
get_view().halt_all_monitoring();
get_view().clear();
foreach (MediaSourceCollection col in MediaCollectionRegistry.get_instance().get_all()) {
get_view().monitor_source_collection(col, new LastImportViewManager(this,
last_import_id), last_import_alteration);
}
}
~LastImportPage() {
foreach (MediaSourceCollection col in MediaCollectionRegistry.get_instance().get_all()) {
......
......@@ -44,6 +44,7 @@ public class LibraryWindow : AppWindow {
CAMERAS,
SAVED_SEARCH,
EVENTS,
IMPORT_ROLL,
FOLDERS,
TAGS
}
......@@ -112,6 +113,7 @@ public class LibraryWindow : AppWindow {
private Events.Branch events_branch = new Events.Branch();
private Camera.Branch camera_branch = new Camera.Branch();
private Searches.Branch saved_search_branch = new Searches.Branch();
private ImportRoll.Branch import_roll_branch = new ImportRoll.Branch();
private bool page_switching_enabled = true;
private Gee.HashMap<Page, Sidebar.Entry> page_map = new Gee.HashMap<Page, Sidebar.Entry>();
......@@ -166,6 +168,7 @@ public class LibraryWindow : AppWindow {
sidebar_tree.graft(events_branch, SidebarRootPosition.EVENTS);
sidebar_tree.graft(camera_branch, SidebarRootPosition.CAMERAS);
sidebar_tree.graft(saved_search_branch, SidebarRootPosition.SAVED_SEARCH);
sidebar_tree.graft(import_roll_branch, SidebarRootPosition.IMPORT_ROLL);
// create and connect extended properties window
extended_properties = new ExtendedPropertiesWindow(this);
......
......@@ -142,6 +142,8 @@ executable('shotwell',
'folders/Folders.vala',
'folders/FoldersBranch.vala',
'folders/FoldersPage.vala',
'import-roll/ImportRollBranch.vala',
'import-roll/ImportRollEntry.vala',
'main.vala',
'AppWindow.vala',
'CollectionPage.vala',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment