~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to DiskMounter/DriveItemSource.cs

  • Committer: Alex Launi
  • Date: 2008-05-24 22:51:36 UTC
  • mfrom: (39.7.7 plugins-devel)
  • mto: This revision was merged to the branch mainline in revision 98.
  • Revision ID: alex@eriktorvaldsonn-20080524225136-ni1424yaozte846m
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// DriveItemSource.cs
 
2
//
 
3
// This program is free software; you can redistribute it and/or modify
 
4
// it under the terms of the GNU General Public License as published by
 
5
// the Free Software Foundation; either version 3 of the License, or
 
6
// (at your option) any later version.
 
7
//
 
8
// This program is distributed in the hope that it will be useful,
 
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
11
// GNU General Public License for more details.
 
12
// 
 
13
// You should have received a copy of the GNU General Public License
 
14
// along with this program; if not, see <http://www.gnu.org/licenses/> or 
 
15
// write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
16
// Boston, MA 02111-1307 USA
 
17
//
 
18
 
 
19
using System;
 
20
using System.Collections.Generic;
 
21
using Gnome.Vfs;
 
22
 
 
23
using Mount;
 
24
using Do.Universe;
 
25
 
 
26
namespace Mount {
 
27
 
 
28
        public class DriveItemSource : IItemSource {
 
29
 
 
30
                List<IItem> items;
 
31
                private static Gnome.Vfs.VolumeMonitor monitor;
 
32
 
 
33
                public DriveItemSource ()
 
34
                {
 
35
                        Vfs.Initialize ();
 
36
                        monitor = Gnome.Vfs.VolumeMonitor.Get ();
 
37
                        items = new List<IItem> ();
 
38
                }
 
39
 
 
40
                public string Name {
 
41
                        get { return "Drives"; }
 
42
                }
 
43
 
 
44
                public string Description {
 
45
                        get { return "Available mounted and unmounted drives."; }
 
46
                }
 
47
 
 
48
                public string Icon {
 
49
                        get { return "harddrive"; }
 
50
                }
 
51
 
 
52
                public Type[] SupportedItemTypes {
 
53
                        get {
 
54
                                return new Type[] {
 
55
                                        typeof (MountedDriveItem),
 
56
                                                   typeof (UnmountedDriveItem),
 
57
                                };
 
58
                        }
 
59
                }
 
60
 
 
61
                public ICollection<IItem> Items {
 
62
                        get { return items; }
 
63
                }
 
64
 
 
65
                public ICollection<IItem> ChildrenOfItem (IItem item)
 
66
                {
 
67
                        return null;
 
68
                }
 
69
 
 
70
                public void UpdateItems ()
 
71
                {
 
72
                        items.Clear ();
 
73
 
 
74
                        foreach (Drive drive in monitor.ConnectedDrives){
 
75
                                if (drive.IsMounted)
 
76
                                        items.Add (new MountedDriveItem (drive));
 
77
                                else
 
78
                                        items.Add (new UnmountedDriveItem (drive));                 
 
79
                        }
 
80
                }  
 
81
        }
 
82
}