1
/* Copyright 2011-2012 Yorba Foundation
3
* This software is licensed under the GNU Lesser General Public License
4
* (version 2.1 or later). See the COPYING file in this distribution.
7
// A folder of any type in the folder list.
8
public class FolderList.FolderEntry : Object, Sidebar.Entry, Sidebar.InternalDropTargetEntry,
9
Sidebar.SelectableEntry, Sidebar.EmphasizableEntry {
10
public Geary.Folder folder { get; private set; }
12
private int unread_count;
14
public FolderEntry(Geary.Folder folder) {
20
public virtual string get_sidebar_name() {
21
return (unread_count == 0 ? folder.get_display_name() :
22
/// This string gets the folder name and the unread messages count,
23
/// e.g. All Mail (5).
24
_("%s (%d)").printf(folder.get_display_name(), unread_count));
27
public string? get_sidebar_tooltip() {
28
return (unread_count == 0 ? null :
29
ngettext("%d unread message", "%d unread messages", unread_count).printf(unread_count));
32
public Icon? get_sidebar_icon() {
33
switch (folder.get_special_folder_type()) {
34
case Geary.SpecialFolderType.NONE:
35
return IconFactory.instance.get_custom_icon("tag", IconFactory.ICON_SIDEBAR);
37
case Geary.SpecialFolderType.INBOX:
38
return new ThemedIcon("mail-inbox");
40
case Geary.SpecialFolderType.DRAFTS:
41
return new ThemedIcon("accessories-text-editor");
43
case Geary.SpecialFolderType.SENT:
44
return new ThemedIcon("mail-sent");
46
case Geary.SpecialFolderType.FLAGGED:
47
return new ThemedIcon("starred");
49
case Geary.SpecialFolderType.IMPORTANT:
50
return new ThemedIcon("task-due");
52
case Geary.SpecialFolderType.ALL_MAIL:
53
return IconFactory.instance.get_custom_icon("mail-archive", IconFactory.ICON_SIDEBAR);
55
case Geary.SpecialFolderType.SPAM:
56
return new ThemedIcon("mail-mark-junk");
58
case Geary.SpecialFolderType.TRASH:
59
return new ThemedIcon("user-trash");
61
case Geary.SpecialFolderType.OUTBOX:
62
return new ThemedIcon("mail-outbox");
69
public virtual string to_string() {
70
return "FolderEntry: " + get_sidebar_name();
73
public bool is_emphasized() {
77
public void set_has_new(bool has_new) {
78
if (this.has_new == has_new)
81
this.has_new = has_new;
82
is_emphasized_changed(has_new);
85
public void set_unread_count(int unread_count) {
86
if (this.unread_count == unread_count)
89
this.unread_count = unread_count;
90
sidebar_name_changed(get_sidebar_name());
91
sidebar_tooltip_changed(get_sidebar_tooltip());
94
public bool internal_drop_received(Gdk.DragContext context, Gtk.SelectionData data) {
96
Gdk.ModifierType mask;
97
double[] axes = new double[2];
98
context.get_device().get_state(context.get_dest_window(), axes, out mask);
99
MainWindow main_window = GearyApplication.instance.get_main_window() as MainWindow;
100
if ((mask & Gdk.ModifierType.CONTROL_MASK) != 0) {
101
main_window.folder_list.copy_conversation(folder);
103
main_window.folder_list.move_conversation(folder);