summaryrefslogtreecommitdiff
path: root/src/library/OfflineSidebarEntry.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-04-03 13:15:00 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-04-03 13:15:00 +0200
commitbc53b714952ceb0afd02b591403cb2bc0cb1aab9 (patch)
tree8ff57ed1a1265b2c87f37e3c8fa19876faf80990 /src/library/OfflineSidebarEntry.vala
parentd4c476947425c12b1984fedea16f8a8c42a07ba3 (diff)
parentc43dfb815a4951b8248f4f0e98babe4f80204f03 (diff)
Merge tag 'upstream/0.22.0'
Upstream version 0.22.0
Diffstat (limited to 'src/library/OfflineSidebarEntry.vala')
-rw-r--r--src/library/OfflineSidebarEntry.vala45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/library/OfflineSidebarEntry.vala b/src/library/OfflineSidebarEntry.vala
new file mode 100644
index 0000000..34c09a0
--- /dev/null
+++ b/src/library/OfflineSidebarEntry.vala
@@ -0,0 +1,45 @@
+/* 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.OfflineSidebarEntry : Library.HideablePageEntry {
+ public OfflineSidebarEntry() {
+
+ foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())
+ media_sources.offline_contents_altered.connect(on_offline_contents_altered);
+
+ visible = (get_total_offline() != 0);
+ }
+
+ ~OfflineSidebarEntry() {
+ foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())
+ media_sources.trashcan_contents_altered.disconnect(on_offline_contents_altered);
+ }
+
+ private void on_offline_contents_altered() {
+ visible = (get_total_offline() != 0);
+ }
+
+ private int get_total_offline() {
+ int total = 0;
+ foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all())
+ total += media_sources.get_offline_bin_contents().size;
+
+ return total;
+ }
+
+ public override string get_sidebar_name() {
+ return OfflinePage.NAME;
+ }
+
+ public override string? get_sidebar_icon() {
+ return Resources.ICON_MISSING_FILES;
+ }
+
+ protected override Page create_page() {
+ return new OfflinePage();
+ }
+}
+