diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-03 13:14:53 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-04-03 13:14:53 +0200 |
commit | c43dfb815a4951b8248f4f0e98babe4f80204f03 (patch) | |
tree | 82745ed2353757c41ea1865bad9ac7a1b0a8a366 /src/library/TrashSidebarEntry.vala | |
parent | 2785a691b958a79a1dd606c445188c71c3f58b3c (diff) |
Imported Upstream version 0.22.0upstream/0.22.0
Diffstat (limited to 'src/library/TrashSidebarEntry.vala')
-rw-r--r-- | src/library/TrashSidebarEntry.vala | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/library/TrashSidebarEntry.vala b/src/library/TrashSidebarEntry.vala new file mode 100644 index 0000000..69412b7 --- /dev/null +++ b/src/library/TrashSidebarEntry.vala @@ -0,0 +1,61 @@ +/* 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.TrashSidebarEntry : Sidebar.SimplePageEntry, Sidebar.InternalDropTargetEntry { + + public TrashSidebarEntry() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.trashcan_contents_altered.connect(on_trashcan_contents_altered); + } + + ~TrashSidebarEntry() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) + media_sources.trashcan_contents_altered.disconnect(on_trashcan_contents_altered); + } + + internal static void init() { + } + + internal static void terminate() { + } + + public override string get_sidebar_name() { + return TrashPage.NAME; + } + + public override string? get_sidebar_icon() { + return get_current_icon(); + } + + private static string get_current_icon() { + foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) { + if (media_sources.get_trashcan_count() > 0) + return Resources.ICON_TRASH_FULL; + } + + return Resources.ICON_TRASH_EMPTY; + } + + public bool internal_drop_received(Gee.List<MediaSource> media) { + AppWindow.get_command_manager().execute(new TrashUntrashPhotosCommand(media, true)); + + return true; + } + + public bool internal_drop_received_arbitrary(Gtk.SelectionData data) { + return false; + } + + protected override Page create_page() { + return new TrashPage(); + } + + private void on_trashcan_contents_altered() { + sidebar_icon_changed(get_current_icon()); + } +} + + |