3
//GNOME Do is the legal property of its developers. Please refer to the
4
//COPYRIGHT file distributed with this
7
// This program is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
using System.Collections.Generic;
26
using System.Runtime.Serialization;
27
using System.Runtime.Serialization.Formatters.Binary;
33
public class ShelfItem : IItem
37
private List<IItem> items = new List<IItem> ();
39
public List<IItem> Items {
41
return items ?? items = new List<IItem> ();
45
public ShelfItem (string name)
50
public string ShelfName {
58
return name + " Shelf";
62
public string Description {
64
return "Your " + name + " Shelf Items";
70
return "folder-saved-search";
74
public void AddItem (IItem item)
76
if (Items.Contains (item)) return;
78
Items.Add (item); //temp items
81
public void RemoveItem (IItem item)
87
public class ShelfItemSource : IItemSource
90
static Dictionary<string,ShelfItem> shelf;
91
static string defaultName;
95
return "Shelf Item Source";
99
public string Description {
101
return "Your Shelf Items";
107
return "folder-saved-search";
111
public Type[] SupportedItemTypes {
119
public ICollection<IItem> Items {
121
List<IItem> items = new List<IItem> ();
123
foreach (IItem item in shelf.Values)
131
public ICollection<IItem> ChildrenOfItem (IItem item)
133
return (item as ShelfItem).Items;
136
static ShelfItemSource ()
138
shelf = new Dictionary<string,ShelfItem> ();
141
public ShelfItemSource ()
143
defaultName = "Default";
145
if (shelf.Count == 0) {
146
shelf.Add (defaultName, new ShelfItem (defaultName));
150
public void UpdateItems ()
154
static public void AddToDefault (IItem item)
156
shelf[defaultName].AddItem (item);
159
static public void RemoveFromDefault (IItem item)
161
shelf[defaultName].RemoveItem (item);