~cszikszoy/do-plugins/pastebin

100 by Alex Launi
Adding diskmounter plugin with manifest and .mdp
1
// OpenVolumeAction.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, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
//
17
//
18
19
using System;
20
using System.Diagnostics;
21
using System.Collections.Generic;
22
23
using Gnome.Vfs;
165.1.3 by Alex Launi
make many more plugins localizable
24
using Mono.Unix;
100 by Alex Launi
Adding diskmounter plugin with manifest and .mdp
25
26
using Do.Universe;
27
using Do.Addins;
28
29
namespace DiskMounter
30
{
31
	public class OpenVolume : AbstractAction
32
	{
33
	
34
		public OpenVolume ()
35
        {
36
        }
37
                
38
		public override string Name {
165.1.3 by Alex Launi
make many more plugins localizable
39
			get { return Catalog.GetString ("Open"); }
100 by Alex Launi
Adding diskmounter plugin with manifest and .mdp
40
		}
41
		
42
		public override string Description {
165.1.3 by Alex Launi
make many more plugins localizable
43
			get { return Catalog.GetString ("Open a removable volume"); }
100 by Alex Launi
Adding diskmounter plugin with manifest and .mdp
44
		}
45
		
46
		public override string Icon {
47
			get { return "gtk-open"; }
48
		}
49
		
50
		public override Type[] SupportedItemTypes {
51
			get {
52
				return new Type[] {
53
					typeof (DriveItem),
54
				};
55
			}
56
		}
57
                
58
		public override bool SupportsItem (IItem item) 
59
        {
60
			return true;
61
		}
62
                
63
        public override bool SupportsModifierItemForItems (IItem[] items, IItem modItem)
64
        {
65
			return false;
66
		}
67
		
68
		public override IItem[] Perform (IItem[] items, IItem[] modItems)
69
		{
70
			DriveItem drive = (DriveItem) items[0];
71
			try {
72
				if (!drive.IsMounted)
73
					drive.Mount ();
74
				Do.Addins.Util.Environment.Open(drive.Path);
75
			} catch (Exception e) {
76
				Console.WriteLine("Error opening {0} - {1}", (items[0] as DriveItem).Path, e.Message);
77
			}
78
			return null;
79
		}
80
	}
165.1.3 by Alex Launi
make many more plugins localizable
81
}