~cszikszoy/do-plugins/fix-confluence

« back to all changes in this revision

Viewing changes to Dropbox/src/DropboxWebInterfaceAction.cs

  • Committer: Chris S.
  • Date: 2009-06-10 17:32:56 UTC
  • mfrom: (599.3.32 Dropbox)
  • Revision ID: chris@szikszoy.com-20090610173256-ndhy3yztbqjc4zs0
merge Dropbox plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// DropboxWebInterfaceAction.cs
 
3
// 
 
4
// GNOME Do is the legal property of its developers. Please refer to the
 
5
// COPYRIGHT file distributed with this
 
6
// source distribution.
 
7
// 
 
8
// This program is free software: you can redistribute it and/or modify
 
9
// it under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation, either version 3 of the License, or
 
11
// (at your option) any later version.
 
12
// 
 
13
// This program is distributed in the hope that it will be useful,
 
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
// GNU General Public License for more details.
 
17
// 
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
// 
 
21
 
 
22
using System;
 
23
using System.IO;
 
24
using System.Linq;
 
25
using System.Collections.Generic;
 
26
 
 
27
using Mono.Unix;
 
28
 
 
29
using Do.Universe;
 
30
using Do.Platform;
 
31
 
 
32
namespace Dropbox
 
33
{
 
34
        
 
35
        public class DropboxWebInterfaceAction : Act
 
36
        {
 
37
                
 
38
                public override string Name {
 
39
                        get { return Catalog.GetString ("Dropbox web interface");  }
 
40
                }
 
41
                
 
42
                public override string Description {
 
43
                        get { return Catalog.GetString ("View folder in Dropbox web interface."); }
 
44
                }
 
45
                
 
46
                public override string Icon {
 
47
                        get { return "dropbox"; }
 
48
                }
 
49
                
 
50
                public override IEnumerable<Type> SupportedItemTypes {
 
51
                        get {
 
52
                                yield return typeof (IApplicationItem);
 
53
                                yield return typeof (IFileItem);
 
54
                        }
 
55
 
 
56
                }
 
57
                
 
58
                public override bool SupportsItem (Item item) 
 
59
                {
 
60
                        if (item is IApplicationItem) {
 
61
                                return item.Name == "Dropbox";
 
62
                        } else {
 
63
                                string path = (item as IFileItem).Path;
 
64
                                return path.StartsWith (Dropbox.BasePath) &&
 
65
                                        Directory.Exists (path);
 
66
                        }
 
67
                }
 
68
                
 
69
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
 
70
                {
 
71
                        string url, path;
 
72
                        Item item = items.First ();
 
73
                        
 
74
                        if (item is IApplicationItem) {
 
75
                                url = Dropbox.GetWebUrl ();
 
76
                        } else {
 
77
                                path = (item as IFileItem).Path;
 
78
                                url = Dropbox.GetWebUrl (path);
 
79
                        }
 
80
                        
 
81
                        Services.Environment.OpenUrl (url);
 
82
                        
 
83
                        yield break;
 
84
                }
 
85
        }
 
86
}