diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2014-07-23 09:06:59 +0200 |
commit | 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d (patch) | |
tree | d2e54377d14d604356c86862a326f64ae64dadd6 /src/library/FlaggedBranch.vala |
Imported Upstream version 0.18.1upstream/0.18.1
Diffstat (limited to 'src/library/FlaggedBranch.vala')
-rw-r--r-- | src/library/FlaggedBranch.vala | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/library/FlaggedBranch.vala b/src/library/FlaggedBranch.vala new file mode 100644 index 0000000..472d999 --- /dev/null +++ b/src/library/FlaggedBranch.vala @@ -0,0 +1,61 @@ +/* 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.FlaggedBranch : Sidebar.RootOnlyBranch { + public FlaggedBranch() { + base (new Library.FlaggedSidebarEntry()); + + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.flagged_contents_altered.connect(on_flagged_contents_altered); + + set_show_branch(get_total_flagged() != 0); + } + + ~FlaggedBranch() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.flagged_contents_altered.disconnect(on_flagged_contents_altered); + } + + private void on_flagged_contents_altered() { + set_show_branch(get_total_flagged() != 0); + } + + private int get_total_flagged() { + int total = 0; + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + total += media_sources.get_flagged().size; + + return total; + } +} + +public class Library.FlaggedSidebarEntry : Sidebar.SimplePageEntry, Sidebar.InternalDropTargetEntry { + public FlaggedSidebarEntry() { + } + + public override string get_sidebar_name() { + return FlaggedPage.NAME; + } + + public override Icon? get_sidebar_icon() { + return new ThemedIcon(Resources.ICON_FLAGGED_PAGE); + } + + protected override Page create_page() { + return new FlaggedPage(); + } + + public bool internal_drop_received(Gee.List<MediaSource> media) { + AppWindow.get_command_manager().execute(new FlagUnflagCommand(media, true)); + + return true; + } + + public bool internal_drop_received_arbitrary(Gtk.SelectionData data) { + return false; + } +} + |