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/events | |
parent | 2785a691b958a79a1dd606c445188c71c3f58b3c (diff) |
Imported Upstream version 0.22.0upstream/0.22.0
Diffstat (limited to 'src/events')
-rw-r--r-- | src/events/Branch.vala | 77 | ||||
-rw-r--r-- | src/events/EventDirectoryItem.vala | 2 | ||||
-rw-r--r-- | src/events/EventPage.vala | 2 | ||||
-rw-r--r-- | src/events/Events.vala | 2 | ||||
-rw-r--r-- | src/events/EventsDirectoryPage.vala | 4 |
5 files changed, 39 insertions, 48 deletions
diff --git a/src/events/Branch.vala b/src/events/Branch.vala index e1b5221..1093411 100644 --- a/src/events/Branch.vala +++ b/src/events/Branch.vala @@ -1,15 +1,14 @@ -/* Copyright 2011-2014 Yorba Foundation +/* 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 Events.Branch : Sidebar.Branch { - internal static Icon open_icon; - internal static Icon closed_icon; - internal static Icon events_icon; - internal static Icon single_event_icon; - internal static Icon no_event_icon; + internal static string icon = Resources.ICON_FOLDER; + internal static string events_icon = Resources.ICON_EVENTS; + internal static string single_event_icon = Resources.ICON_ONE_EVENT; + internal static string no_event_icon = Resources.ICON_NO_EVENT; // NOTE: Because the comparators must be static methods (due to CompareFunc's stupid impl.) // and there's an assumption that only one Events.Branch is ever created, this is a static @@ -20,11 +19,14 @@ public class Events.Branch : Sidebar.Branch { Event, Events.EventEntry>(); private Events.UndatedDirectoryEntry undated_entry = new Events.UndatedDirectoryEntry(); private Events.NoEventEntry no_event_entry = new Events.NoEventEntry(); + private Events.MasterDirectoryEntry all_events_entry = new Events.MasterDirectoryEntry(); public Branch() { - base (new Events.MasterDirectoryEntry(), Sidebar.Branch.Options.STARTUP_EXPAND_TO_FIRST_CHILD, + base (new Sidebar.Header(_("Events")), Sidebar.Branch.Options.STARTUP_EXPAND_TO_FIRST_CHILD, event_year_comparator); + graft(get_root(), all_events_entry); + // seed the branch foreach (DataObject object in Event.global.get_all()) add_event((Event) object); @@ -49,25 +51,18 @@ public class Events.Branch : Sidebar.Branch { } internal static void init() { - open_icon = new ThemedIcon(Resources.ICON_FOLDER_OPEN); - closed_icon = new ThemedIcon(Resources.ICON_FOLDER_CLOSED); - events_icon = new ThemedIcon(Resources.ICON_EVENTS); - single_event_icon = new ThemedIcon(Resources.ICON_ONE_EVENT); - no_event_icon = new ThemedIcon(Resources.ICON_NO_EVENT); - sort_ascending = Config.Facade.get_instance().get_events_sort_ascending(); } internal static void terminate() { - open_icon = null; - closed_icon = null; - events_icon = null; - single_event_icon = null; - no_event_icon = null; + } + + public bool is_user_renameable() { + return true; } public Events.MasterDirectoryEntry get_master_entry() { - return (Events.MasterDirectoryEntry) get_root(); + return all_events_entry; } private static int event_year_comparator(Sidebar.Entry a, Sidebar.Entry b) { @@ -91,6 +86,12 @@ public class Events.Branch : Sidebar.Branch { else if (b is Events.NoEventEntry) return -1; + // The All events entry should always appear on top + if (a is Events.MasterDirectoryEntry) + return -1; + else if (b is Events.MasterDirectoryEntry) + return 1; + if (!sort_ascending) { Sidebar.Entry swap = a; a = b; @@ -312,7 +313,8 @@ public class Events.Branch : Sidebar.Branch { int event_year = event_tm.year + 1900; return find_first_child(get_root(), (entry) => { - if ((entry is Events.UndatedDirectoryEntry) || (entry is Events.NoEventEntry)) + if ((entry is Events.UndatedDirectoryEntry) || (entry is Events.NoEventEntry) || + entry is Events.MasterDirectoryEntry) return false; else return ((Events.YearDirectoryEntry) entry).get_year() == event_year; @@ -334,11 +336,11 @@ public class Events.Branch : Sidebar.Branch { } private void graft_event(Sidebar.Entry parent, Event event, - owned CompareDataFunc<Sidebar.Entry>? comparator = null) { + owned CompareFunc<Sidebar.Entry>? comparator = null) { Events.EventEntry entry = new Events.EventEntry(event); entry_map.set(event, entry); - graft(parent, entry, (owned) comparator); + graft(parent, entry, comparator); } private void reparent_event(Event event, Sidebar.Entry new_parent) { @@ -372,16 +374,8 @@ public abstract class Events.DirectoryEntry : Sidebar.SimplePageEntry, Sidebar.E public DirectoryEntry() { } - public override Icon? get_sidebar_icon() { - return null; - } - - public virtual Icon? get_sidebar_open_icon() { - return Events.Branch.open_icon; - } - - public virtual Icon? get_sidebar_closed_icon() { - return Events.Branch.closed_icon; + public override string? get_sidebar_icon() { + return Events.Branch.icon; } public bool expand_on_select() { @@ -397,15 +391,7 @@ public class Events.MasterDirectoryEntry : Events.DirectoryEntry { return MasterEventsDirectoryPage.NAME; } - public override Icon? get_sidebar_icon() { - return Events.Branch.events_icon; - } - - public override Icon? get_sidebar_open_icon() { - return Events.Branch.events_icon; - } - - public override Icon? get_sidebar_closed_icon() { + public override string? get_sidebar_icon() { return Events.Branch.events_icon; } @@ -492,7 +478,7 @@ public class Events.EventEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEntr return event.get_name(); } - public override Icon? get_sidebar_icon() { + public override string? get_sidebar_icon() { return Events.Branch.single_event_icon; } @@ -500,6 +486,10 @@ public class Events.EventEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEntr return new EventPage(event); } + public bool is_user_renameable() { + return true; + } + public void rename(string new_name) { string? prepped = Event.prep_event_name(new_name); if (prepped != null) @@ -523,6 +513,7 @@ public class Events.EventEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEntr } } + public class Events.NoEventEntry : Sidebar.SimplePageEntry { public NoEventEntry() { } @@ -531,7 +522,7 @@ public class Events.NoEventEntry : Sidebar.SimplePageEntry { return NoEventPage.NAME; } - public override Icon? get_sidebar_icon() { + public override string? get_sidebar_icon() { return Events.Branch.no_event_icon; } diff --git a/src/events/EventDirectoryItem.vala b/src/events/EventDirectoryItem.vala index 5b2026b..d3434c2 100644 --- a/src/events/EventDirectoryItem.vala +++ b/src/events/EventDirectoryItem.vala @@ -1,4 +1,4 @@ -/* Copyright 2011-2014 Yorba Foundation +/* 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. diff --git a/src/events/EventPage.vala b/src/events/EventPage.vala index 3d23f25..ed103a8 100644 --- a/src/events/EventPage.vala +++ b/src/events/EventPage.vala @@ -1,4 +1,4 @@ -/* Copyright 2009-2014 Yorba Foundation +/* Copyright 2009-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. diff --git a/src/events/Events.vala b/src/events/Events.vala index dc2b662..f93e33c 100644 --- a/src/events/Events.vala +++ b/src/events/Events.vala @@ -1,4 +1,4 @@ -/* Copyright 2011-2014 Yorba Foundation +/* 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. diff --git a/src/events/EventsDirectoryPage.vala b/src/events/EventsDirectoryPage.vala index 41a1ac6..99601a0 100644 --- a/src/events/EventsDirectoryPage.vala +++ b/src/events/EventsDirectoryPage.vala @@ -1,4 +1,4 @@ -/* Copyright 2009-2014 Yorba Foundation +/* Copyright 2009-2015 Yorba Foundation * * This software is licensed under the GNU LGPL (version 2.1 or later). * See the COPYING file in this distribution. @@ -227,7 +227,7 @@ public abstract class EventsDirectoryPage : CheckerboardPage { } public class MasterEventsDirectoryPage : EventsDirectoryPage { - public const string NAME = _("Events"); + public const string NAME = _("All Events"); public MasterEventsDirectoryPage() { base (NAME, new EventDirectoryManager(), (Gee.Collection<Event>) Event.global.get_all()); |