From c43dfb815a4951b8248f4f0e98babe4f80204f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Fri, 3 Apr 2015 13:14:53 +0200 Subject: Imported Upstream version 0.22.0 --- src/library/FlaggedSidebarEntry.vala | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/library/FlaggedSidebarEntry.vala (limited to 'src/library/FlaggedSidebarEntry.vala') diff --git a/src/library/FlaggedSidebarEntry.vala b/src/library/FlaggedSidebarEntry.vala new file mode 100644 index 0000000..240aaf3 --- /dev/null +++ b/src/library/FlaggedSidebarEntry.vala @@ -0,0 +1,54 @@ +/* Copyright 2011-2015 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.FlaggedSidebarEntry : Library.HideablePageEntry, Sidebar.InternalDropTargetEntry { + public FlaggedSidebarEntry() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.flagged_contents_altered.connect(on_flagged_contents_altered); + + visible = (get_total_flagged() != 0); + } + + ~FlaggedSidebarEntry() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.flagged_contents_altered.disconnect(on_flagged_contents_altered); + } + + public override string get_sidebar_name() { + return FlaggedPage.NAME; + } + + public override string? get_sidebar_icon() { + return Resources.ICON_FLAGGED_PAGE; + } + + protected override Page create_page() { + return new FlaggedPage(); + } + + public bool internal_drop_received(Gee.List media) { + AppWindow.get_command_manager().execute(new FlagUnflagCommand(media, true)); + + return true; + } + + public bool internal_drop_received_arbitrary(Gtk.SelectionData data) { + return false; + } + + private void on_flagged_contents_altered() { + visible = (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; + } +} + -- cgit v1.2.3