blob: 5ef8b3c553afcf913dc9db57f118933f309e4bf1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/* 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.TrashBranch : Sidebar.RootOnlyBranch {
public TrashBranch() {
base (new Library.TrashSidebarEntry());
}
}
public class Library.TrashSidebarEntry : Sidebar.SimplePageEntry, Sidebar.InternalDropTargetEntry {
private static Icon? full_icon = null;
private static Icon? empty_icon = null;
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() {
full_icon = new ThemedIcon(Resources.ICON_TRASH_FULL);
empty_icon = new ThemedIcon(Resources.ICON_TRASH_EMPTY);
}
internal static void terminate() {
full_icon = null;
empty_icon = null;
}
public override string get_sidebar_name() {
return TrashPage.NAME;
}
public override Icon? get_sidebar_icon() {
return get_current_icon();
}
private static Icon get_current_icon() {
foreach (MediaSourceCollection media_sources in MediaCollectionRegistry.get_instance().get_all()) {
if (media_sources.get_trashcan_count() > 0)
return full_icon;
}
return empty_icon;
}
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());
}
}
|