~do-win/do/test-paths

« back to all changes in this revision

Viewing changes to Do/src/Do.Universe/ItemSourceItemSource.cs

  • Committer: Hardeep S
  • Date: 2009-06-23 05:57:47 UTC
  • Revision ID: ootz0rz@gmail.com-20090623055747-3srobsuq3q8wbn81
initial adding of Do core stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  ItemSourceItemSource.cs
 
2
//
 
3
//  GNOME Do is the legal property of its developers, whose names are too numerous
 
4
//  to list here.  Please refer to the COPYRIGHT file distributed with this
 
5
//  source distribution.
 
6
//
 
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 3 of the License, or
 
10
//  (at your option) any later version.
 
11
//
 
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.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
using System;
 
21
using System.Linq;
 
22
using System.Collections.Generic;
 
23
 
 
24
using Do.Core;
 
25
using Mono.Unix;
 
26
 
 
27
namespace Do.Universe
 
28
{
 
29
        
 
30
        internal class ItemSourceItemSource : ItemSource
 
31
        {
 
32
 
 
33
                public class ItemSourceItem : Item {
 
34
 
 
35
                        public ItemSource Source { get; private set; }
 
36
 
 
37
                        public override string Name { get { return Source.Name; } }
 
38
                        public override string Description { get { return Source.Description; } }
 
39
                        public override string Icon { get { return Source.Icon; } }
 
40
 
 
41
                        public ItemSourceItem (ItemSource source)
 
42
                        {
 
43
                                Source = source;
 
44
                        }
 
45
                }
 
46
 
 
47
                IEnumerable<Item> items;
 
48
 
 
49
                public ItemSourceItemSource ()
 
50
                {
 
51
                        items = Enumerable.Empty<Item> ();
 
52
                }
 
53
                
 
54
                public override IEnumerable<Type> SupportedItemTypes
 
55
                {
 
56
                        get { yield return typeof (ItemSourceItem); }
 
57
                }
 
58
                
 
59
                public override string Name {
 
60
                        get { return Catalog.GetString ("GNOME Do Item Sources"); }
 
61
                }
 
62
                
 
63
                public override string Description {
 
64
                        get { return Catalog.GetString ("Item Sources providing all items GNOME Do knows about."); }
 
65
                }
 
66
                
 
67
                public override string Icon {
 
68
                        get { return "gnome-do"; }
 
69
                }
 
70
                
 
71
                public override IEnumerable<Item> Items {
 
72
                        get { return items; }
 
73
                }
 
74
 
 
75
                public override void UpdateItems ()
 
76
                {
 
77
                        items = PluginManager.ItemSources
 
78
                                .Select (source => new ItemSourceItem (source))
 
79
                                .Cast<Item> ();
 
80
                }
 
81
                
 
82
                public override IEnumerable<Item> ChildrenOfItem (Item item)
 
83
                {
 
84
                        return (item as ItemSourceItem).Source.Safe.Items;
 
85
                }
 
86
        }
 
87
}