~bas-dotbas/do/win32-next

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.Universe/OpenCommand.cs

  • Committer: djsiegel at gmail
  • Date: 2007-10-13 21:55:22 UTC
  • Revision ID: djsiegel@gmail.com-20071013215522-n0vjgog0tyjfnpno
Restructured plugins library.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
 
 
3
using Do.Addins;
 
4
 
 
5
namespace Do.Universe
 
6
{
 
7
        
 
8
        public class OpenCommand : ICommand
 
9
        {
 
10
        
 
11
                public OpenCommand ()
 
12
                {
 
13
                }
 
14
                
 
15
                public string Name {
 
16
                        get { return "Open"; }
 
17
                }
 
18
                
 
19
                public string Description {
 
20
                        get { return "Opens many kinds of items."; }
 
21
                }
 
22
                
 
23
                public string Icon {
 
24
                        get { return "gtk-open"; }
 
25
                }
 
26
                
 
27
                public Type[] SupportedTypes {
 
28
                        get {
 
29
                                return new Type[] {
 
30
                                        typeof (IOpenableItem),
 
31
                                        typeof (IURIItem),
 
32
                                };
 
33
                        }
 
34
                }
 
35
                
 
36
                public Type[] SupportedModifierTypes {
 
37
                        get {
 
38
                                return null;
 
39
                        }
 
40
                }
 
41
 
 
42
                public bool SupportsItem (IItem item) {
 
43
                        return true;
 
44
                }
 
45
                
 
46
                public void Perform (IItem[] items, IItem[] modifierItems)
 
47
                {
 
48
                        string open_item;
 
49
                        string error_message;
 
50
                        
 
51
                        open_item = null;
 
52
                        foreach (IItem item in items) {
 
53
                                if (item is IOpenableItem) {
 
54
                                        (item as IOpenableItem).Open ();
 
55
                                        continue;
 
56
                                }
 
57
                                else if (item is IURIItem) {
 
58
                                        open_item = (item as IURIItem).URI;
 
59
                                }
 
60
                                Util.Desktop.Open (open_item, out error_message);
 
61
                        }
 
62
                }
 
63
                
 
64
        }
 
65
}