~colkitt/do/do-plugins-dr

« back to all changes in this revision

Viewing changes to Launchpad/src/LaunchpadBlueprintsItem.cs

  • Committer: Douglas Colkitt
  • Date: 2008-03-07 18:20:06 UTC
  • mfrom: (58.2.3 do-plugins)
  • Revision ID: colkitt@colkitt-laptop-20080307182006-e3gwfgci8ycuetn1
Merged changes with main branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LaunchpadBlueprintsItem.cs
 
2
 *
 
3
 * GNOME Do is the legal property of its developers. Please refer to the
 
4
 * COPYRIGHT file distributed with this source distribution.
 
5
 *
 
6
 * This program is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
using System;
 
20
using System.Text.RegularExpressions;
 
21
using Do.Universe;
 
22
 
 
23
using Do.Addins;
 
24
 
 
25
namespace Do.Launchpad
 
26
{
 
27
        public class LaunchpadBlueprintsItem : LaunchpadItem
 
28
        {
 
29
                public LaunchpadBlueprintsItem() { }
 
30
                public string Name { get { return "Project Blueprints"; } }
 
31
                public string Description { get { return "Show blueprints for specified project at Launchpad"; } }
 
32
 
 
33
                public string Icon
 
34
                { 
 
35
                        get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBlueprints.png"); }
 
36
                }
 
37
 
 
38
                public bool SupportsItems(IItem[] items)
 
39
                {
 
40
                        //Package name can't have a space
 
41
                        Regex numbers = new Regex(@"\s+");
 
42
                        return !numbers.IsMatch((items[0] as ITextItem).Text);
 
43
                }
 
44
 
 
45
                public void Perform (IItem item)
 
46
                {
 
47
                        Util.Environment.Open("https://blueprints.launchpad.net/" + (item as ITextItem).Text);
 
48
                }
 
49
        }
 
50
 
 
51
        public class LaunchpadBlueprintSearchItem : LaunchpadItem
 
52
        {
 
53
                public LaunchpadBlueprintSearchItem() { }
 
54
                public string Name { get { return "Blueprint Search"; } }
 
55
                public string Description { get { return "Search for blueprints at Launchpad"; } }
 
56
 
 
57
                public string Icon
 
58
                { 
 
59
                        get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBlueprints.png"); }
 
60
                }
 
61
 
 
62
                public bool SupportsItems(IItem[] items)
 
63
                {
 
64
                        return true;
 
65
                }
 
66
 
 
67
                public void Perform (IItem item)
 
68
                {
 
69
                        Regex spaces = new Regex(@"\s+");
 
70
                        string query = (item as ITextItem).Text;
 
71
                        string[] qwords = spaces.Split(query);
 
72
                        Util.Environment.Open("https://blueprints.launchpad.net/?searchtext=" + string.Join("+", qwords));
 
73
                }
 
74
        }
 
75
 
 
76
        public class LaunchpadBlueprintsRegisterItem : LaunchpadItem
 
77
        {
 
78
                public LaunchpadBlueprintsRegisterItem() { }
 
79
                public string Name { get { return "Register Blueprints"; } }
 
80
                public string Description { get { return "Register a blueprint at Launchpad"; } }
 
81
                public string Icon
 
82
                { 
 
83
                        get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBlueprints.png"); }
 
84
                }
 
85
 
 
86
                public bool SupportsItems(IItem[] items)
 
87
                {
 
88
                        return true;
 
89
                }
 
90
 
 
91
                public void Perform (IItem item)
 
92
                {
 
93
                        Util.Environment.Open("https://blueprints.launchpad.net/specs/+new");
 
94
                }
 
95
        }
 
96
}