~cszikszoy/do-plugins/fix-confluence

« back to all changes in this revision

Viewing changes to DiskMounter/DriveItemSource.cs

  • Committer: Guillaume Beland
  • Date: 2008-04-08 14:58:27 UTC
  • Revision ID: guillaume@inspiron-20080408145827-2eccz89bbu0335sg
Added DiksMounter plugin

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
                        UpdateItems ();
 
39
                }
 
40
                
 
41
                public string Name {
 
42
                        get { return "Drive Item"; }
 
43
                }
 
44
                
 
45
                public string Description {
 
46
                        get { return ""; }
 
47
                }
 
48
                
 
49
                public string Icon {
 
50
                        get { return "harddrive"; }
 
51
                }
 
52
                
 
53
                public Type[] SupportedItemTypes {
 
54
                        get {
 
55
                        return new Type[] {
 
56
                                        typeof (MountedDriveItem),
 
57
                                        typeof (UnmountedDriveItem),
 
58
                                };
 
59
                        }
 
60
                }
 
61
 
 
62
                public ICollection<IItem> Items {
 
63
                        get { return items; }
 
64
                }
 
65
                
 
66
                public ICollection<IItem> ChildrenOfItem (IItem item)
 
67
                {
 
68
                        return null;
 
69
                }
 
70
                
 
71
                public void UpdateItems ()
 
72
                {
 
73
 
 
74
                        Gnome.Vfs.Drive[] drives;
 
75
                        
 
76
                        try {                       
 
77
                                drives = monitor.ConnectedDrives;
 
78
                                items.Clear();
 
79
                      
 
80
                                foreach (Drive drive in drives){
 
81
                                        if (drive.IsMounted)
 
82
                                                items.Add (new MountedDriveItem(drive));
 
83
                                        else
 
84
                                                items.Add (new UnmountedDriveItem(drive));                 
 
85
                                }
 
86
                        
 
87
                        } catch (Exception e) {
 
88
                                Console.Error.WriteLine ("Something went wrong while updating DriveItemSource :  {0}" , e.Message);
 
89
                        }
 
90
 
 
91
                }  
 
92
                
 
93
        }
 
94
}
 
 
b'\\ No newline at end of file'