~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-09-14 10:09:40 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20080914100940-kyghudg7py14bu2z
Tags: upstream-0.6.0.0
ImportĀ upstreamĀ versionĀ 0.6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* OpenTerminalHereAction.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.Diagnostics;
23
 
 
24
 
using Mono.Unix;
25
 
 
26
 
using Do.Addins;
27
 
 
28
 
namespace Do.Universe
29
 
{
30
 
        public class OpenTerminalHereAction : AbstractAction
31
 
        {
32
 
                public OpenTerminalHereAction ()
33
 
                {
34
 
                }
35
 
                
36
 
                public override string Name
37
 
                {
38
 
                        get { return Catalog.GetString ("Open Terminal Here"); }
39
 
                }
40
 
                
41
 
                public override string Description
42
 
                {
43
 
                        get { return Catalog.GetString ("Opens a Terminal in a given location."); }
44
 
                }
45
 
                
46
 
                public override string Icon
47
 
                {
48
 
                        get { return "terminal"; }
49
 
                }
50
 
                
51
 
                public override Type[] SupportedItemTypes
52
 
                {
53
 
                        get {
54
 
                                return new Type[] {
55
 
                                        typeof (IFileItem),
56
 
                                };
57
 
                        }
58
 
                }
59
 
                
60
 
                public override IItem[] Perform (IItem[] items, IItem[] modifierItems)
61
 
                {
62
 
                        GConf.Client client;
63
 
                        Process term;
64
 
                        IFileItem fi;
65
 
                        string dir, exec;
66
 
 
67
 
                        client = new GConf.Client();
68
 
                        try {
69
 
                                exec = client.Get ("/desktop/gnome/applications/terminal/exec") as string;
70
 
                        } catch {
71
 
                                exec = "gnome-terminal";
72
 
                        }
73
 
                        
74
 
                        fi = items[0] as IFileItem;
75
 
                        dir = fi.Path;
76
 
                        if (!FileItem.IsDirectory (fi))
77
 
                                dir = System.IO.Path.GetDirectoryName (dir);
78
 
 
79
 
                        term = new Process ();
80
 
                        term.StartInfo.WorkingDirectory = dir;
81
 
                        term.StartInfo.FileName = exec;
82
 
                        term.Start ();
83
 
                        return null;
84
 
                }
85
 
        }
86
 
}