3
// GNOME Do is the legal property of its developers, whose names are too numerous
4
// to list here. Please refer to the COPYRIGHT file distributed with this
5
// source distribution.
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.
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.
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/>.
21
using System.Collections.Generic;
25
using System.Text.RegularExpressions;
32
namespace Do.Plugins.Pastebin
34
public class PastebinAction : AbstractAction
36
public override string Name
38
get { return Catalog.GetString ("Send to Pastebin"); }
41
public override string Description
43
get { return Catalog.GetString ("Sends the text to Pastebin."); }
46
public override string Icon
48
get { return "gtk-paste"; }
51
public override Type[] SupportedItemTypes
61
public override bool ModifierItemsOptional
66
public override Type[] SupportedModifierItemTypes
71
typeof (ITextSyntaxItem)
76
public override IItem[] DynamicModifierItemsForItem (IItem item)
80
Paste2 pastebinProvider = new Paste2 ();
81
List<IItem> items = new List<IItem> ();
83
foreach(IItem languageItem in pastebinProvider.SupportedLanguages)
84
items.Add (languageItem);
86
return items.ToArray ();
94
public override IItem[] Perform (IItem[] items, IItem[] modifierItems)
96
string text = string.Empty;
98
foreach (IItem item in items)
101
text += (item as ITextItem).Text;
104
Paste2 pastebinProvider = null;
106
if (modifierItems.Length > 0)
108
pastebinProvider = new Paste2 (text, (modifierItems[0] as ITextSyntaxItem).Syntax);
112
pastebinProvider = new Paste2 (text);
115
string url = Pastebin.PostUsing (pastebinProvider);
117
return new IItem[] { new TextItem (url) };