1
/* LaunchpadBugsItem.cs
3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this source distribution.
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.
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.
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/>.
20
using System.Text.RegularExpressions;
25
namespace Do.Launchpad
27
public class LaunchpadBugNumberItem : LaunchpadItem
29
public LaunchpadBugNumberItem() { }
30
public string Name { get { return "Bug Number"; } }
31
public string Description { get { return "Find bug by number"; } }
35
get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBugs.png"); }
38
public bool SupportsItems(IItem[] items)
41
Regex numbers = new Regex(@"^\d+$");
42
return numbers.IsMatch((items[0] as ITextItem).Text);
45
public void Perform (IItem item)
47
Util.Environment.Open(string.Format("https://bugs.launchpad.net/ubuntu/+bug/{0}", (item as ITextItem).Text));
51
public class LaunchpadBugReportItem : LaunchpadItem
53
public LaunchpadBugReportItem() { }
54
public string Name { get { return "Bug Report"; } }
55
public string Description { get { return "Report an Ubuntu bug at Launchpad"; } }
59
get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBugs.png"); }
62
public bool SupportsItems(IItem[] items)
67
public void Perform (IItem item)
69
Util.Environment.Open("https://launchpad.net/ubuntu/+filebug");
73
public class LaunchpadPackageBugsItem : LaunchpadItem
75
public LaunchpadPackageBugsItem() { }
76
public string Name { get { return "Project Bugs"; } }
77
public string Description { get { return "Show open bugs in a project at Launchpad"; } }
81
get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBugs.png"); }
84
public bool SupportsItems(IItem[] items)
86
//Package name can't have a space
87
Regex numbers = new Regex(@"\s+");
88
return !numbers.IsMatch((items[0] as ITextItem).Text);
91
public void Perform (IItem item)
93
Util.Environment.Open(string.Format("https://bugs.launchpad.net/{0}", (item as ITextItem).Text));
97
public class LaunchpadBugSearchItem : LaunchpadItem
99
public LaunchpadBugSearchItem() { }
100
public string Name { get { return "Ubuntu Bug Search"; } }
101
public string Description { get { return "Search for Ubuntu bugs at Launchpad"; } }
104
get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadBugs.png"); }
107
public bool SupportsItems(IItem[] items)
112
public void Perform (IItem item)
114
Regex spaces = new Regex(@"\s+");
115
string query = (item as ITextItem).Text;
116
string[] qwords = spaces.Split(query);
117
Util.Environment.Open("https://bugs.launchpad.net/ubuntu/+bugs?field.searchtext=" + string.Join("+", qwords));