3
// This program is free software; you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation; either version 3 of the License, or
6
// (at your option) any later version.
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, see <http://www.gnu.org/licenses/> or
15
// write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
16
// Boston, MA 02111-1307 USA
20
using System.Collections;
21
using System.Collections.Generic;
27
using Tasque.Category.Item;
32
public class TasqueCreateTask : AbstractAction
35
public TasqueCreateTask ()
39
public override string Name {
40
get { return "Create a new task"; }
43
public override string Description {
44
get { return " Create a new task in Tasque"; }
47
public override string Icon {
48
get { return "tasque"; }
51
public override Type[] SupportedItemTypes {
59
public override bool SupportsItem (IItem item) {
63
public override Type[] SupportedModifierItemTypes {
66
typeof(TasqueCategoryItem),
71
public override IItem[] DynamicModifierItemsForItem (IItem item)
73
List<IItem> items = new List<IItem> ();
76
items = Tasque.GetCategoryItems ();
77
return items.ToArray();
84
public override bool ModifierItemsOptional {
88
public override IItem[] Perform ( IItem[] items, IItem[] modifierItems )
90
if ( modifierItems.Length > 0 )
91
TextItemPerform (items[0] as ITextItem, modifierItems[0] as TasqueCategoryItem);
93
TextItemPerform (items[0] as ITextItem, new TasqueCategoryItem (""));
98
protected IItem[] TextItemPerform (ITextItem item, TasqueCategoryItem category)
100
string defaultCategory;
102
ArrayList list = new ArrayList ();
103
GConf.Client conf = new GConf.Client ();
104
TasqueDBus tasque = new TasqueDBus ();
107
defaultCategory = conf.Get ("/apps/gnome-do/plugins/tasque/default_category") as string;
108
} catch (GConf.NoSuchKeyException) {
109
conf.Set ("/apps/gnome-do/plugins/tasque/default_category", "");
113
if (category.Name != "" ) {
114
tasque.CreateTask(category.Name, item.Text);
116
else if (defaultCategory == String.Empty) {
118
string[] split = item.Text.Split (':');
119
if (split.GetValue(0).ToString() == item.Text) {
120
list = tasque.GetCategoryNames ();
121
tasque.CreateTask (list[0].ToString(), item.Text);
124
tasque.CreateTask (split.GetValue(0).ToString(), split.GetValue(1).ToString());
129
string[] split = item.Text.Split (':');
131
if (split.GetValue(0).ToString() == item.Text)
132
tasque.CreateTask (defaultCategory, item.Text);
134
tasque.CreateTask (split.GetValue(0).ToString(), split.GetValue(1).ToString());