~iwarford/do-plugins/autofoo

« back to all changes in this revision

Viewing changes to NX/src/NXHosts.cs

  • Committer: Christopher Halse Rogers
  • Date: 2009-01-06 05:37:26 UTC
  • mfrom: (395.1.18 do-plugins)
  • Revision ID: raof@ubuntu.com-20090106053726-f21k3lsuypkcul4i
Merge again.  Stop it!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* SSHHosts.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * 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
 
 
21
using System;
 
22
using System.IO;
 
23
using System.Collections.Generic;
 
24
 
 
25
using Do.Universe;
 
26
 
 
27
using Mono.Unix;
 
28
 
 
29
namespace NX {
 
30
 
 
31
    public class NXHostItem : Item {
 
32
        string name;
 
33
        string path;
 
34
        
 
35
        public NXHostItem (string hostname, string configpath)
 
36
        {
 
37
            name = hostname;
 
38
            path = configpath;
 
39
        }
 
40
        
 
41
        public override string Name { 
 
42
                get { return name; } 
 
43
        }
 
44
                
 
45
        public override string Description { 
 
46
                get { return Catalog.GetString ("NX Host"); }
 
47
        }
 
48
        
 
49
        public override string Icon {
 
50
                get { return "gnome-globe"; } 
 
51
        }
 
52
 
 
53
                public string Path { 
 
54
                get { return path; } 
 
55
        }
 
56
    }
 
57
    
 
58
    public class NXHostItemSource : ItemSource {
 
59
        List<Item> items;
 
60
        
 
61
        public NXHostItemSource ()
 
62
        {
 
63
            items = new List<Item> ();
 
64
        }
 
65
        
 
66
        public override string Name { 
 
67
                get { return Catalog.GetString ("NX Hosts"); } 
 
68
        }
 
69
        
 
70
        public override string Description { 
 
71
                get { return Catalog.GetString ("Parses nx sessions"); } 
 
72
        }
 
73
        
 
74
        public override string Icon { 
 
75
                get { return "network-server"; } 
 
76
        }
 
77
        
 
78
        public override IEnumerable<Type> SupportedItemTypes {
 
79
            get { yield return typeof (NXHostItem); }
 
80
        }
 
81
        
 
82
        public override IEnumerable<Item> Items {
 
83
            get { return items; }
 
84
        }
 
85
        
 
86
        public override IEnumerable<Item> ChildrenOfItem (Item parent)
 
87
        {
 
88
            yield break;  
 
89
        }
 
90
        
 
91
        public override void UpdateItems ()
 
92
        {
 
93
                items.Clear ();
 
94
                
 
95
            string nxDir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".nx");
 
96
            nxDir = Path.Combine (nxDir, "config");
 
97
            DirectoryInfo dir = new DirectoryInfo (nxDir);
 
98
            foreach (FileInfo file in dir.GetFiles ("*.nxs"))
 
99
            {
 
100
                string name = file.Name.Replace (".nxs", "");
 
101
                items.Add (new NXHostItem (name, Path.Combine (nxDir, name)));
 
102
            }
 
103
        }
 
104
    }
 
105
}
 
106