~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Launchpad/src/LaunchpadTranslationsItem.cs

  • Committer: Christopher James Halse Rogers
  • Date: 2008-02-11 23:34:16 UTC
  • Revision ID: chalserogers@gmail.com-20080211233416-8vtjulsmfhsvblgv
The Great Copyright Push continues
Add AUTHORS, COPYING & COPYRIGHT
Add license headers to Epiphany & EyeOfGNOME plugins
Add license headers to Template plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* LaunchpadTranslationsItem.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 LaunchpadTranslationSearchItem : LaunchpadItem
28
 
        {
29
 
                public LaunchpadTranslationSearchItem() { }
30
 
                public string Name { get { return "Translation Search"; } }
31
 
                public string Description { get { return "Search for Translations in Launchpad"; } }
32
 
 
33
 
                public string Icon
34
 
                { 
35
 
                        get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadTranslations.png"); }
36
 
                }
37
 
 
38
 
                public bool SupportsItems(IItem[] items)
39
 
                {
40
 
                        return true;
41
 
                }
42
 
 
43
 
                public void Perform (IItem item)
44
 
                {
45
 
                        Regex spaces = new Regex(@"\s+");
46
 
                        string query = (item as ITextItem).Text;
47
 
                        string[] qwords = spaces.Split(query);
48
 
 
49
 
                        Util.Environment.Open ("https://translations.launchpad.net/projects/?text=" + string.Join("+", qwords));        
50
 
                }
51
 
        }
52
 
 
53
 
        public class LaunchpadTranslationReleaseItem : LaunchpadItem
54
 
        {
55
 
                public LaunchpadTranslationReleaseItem() { }
56
 
                public string Name { get { return "Release Translations"; } }
57
 
                public string Description { get { return "Translations for Ubuntu Release Name"; } }
58
 
 
59
 
                public string Icon
60
 
                { 
61
 
                        get { return LaunchpadIcons.Instance.GetIconPath("LaunchpadTranslations.png"); }
62
 
                }
63
 
 
64
 
                public bool SupportsItems(IItem[] items)
65
 
                {
66
 
                        //Package name can't have a space
67
 
                        Regex numbers = new Regex(@"\s+");
68
 
                        return !numbers.IsMatch((items[0] as ITextItem).Text);
69
 
                }
70
 
 
71
 
                public void Perform (IItem item)
72
 
                {
73
 
                        Util.Environment.Open(string.Format(
74
 
                                                "https://translations.lauchpad.net/ubuntu/{0}/+translations",
75
 
                                                (item as ITextItem).Text));
76
 
                }
77
 
        }
78
 
}