~alexlauni/do-plugins/jolicloud

« back to all changes in this revision

Viewing changes to RememberTheMilk/src/RTMNewNote.cs

  • Committer: Alex Launi
  • Date: 2009-06-24 13:17:29 UTC
  • mfrom: (618.1.17 do-plugins)
  • Revision ID: alex.launi@gmail.com-20090624131729-1l9g76ejqq4leka4
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// RTMNewNote.cs
 
2
// 
 
3
// Copyright (C) 2009 GNOME Do
 
4
// 
 
5
// This program is free software: you can redistribute it and/or modify
 
6
// it under the terms of the GNU General Public License as published by
 
7
// the Free Software Foundation, either version 3 of the License, or
 
8
// (at your option) any later version.
 
9
// 
 
10
// This program is distributed in the hope that it will be useful,
 
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
// GNU General Public License for more details.
 
14
// 
 
15
// You should have received a copy of the GNU General Public License
 
16
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
// 
 
18
 
 
19
using System;
 
20
using System.Linq;
 
21
using System.Collections.Generic;
 
22
using System.Text.RegularExpressions;
 
23
using Mono.Addins;
 
24
 
 
25
using Do.Universe;
 
26
using Do.Platform;
 
27
 
 
28
namespace RememberTheMilk
 
29
{
 
30
        /// <summary>
 
31
        /// Class for the "New Note" action
 
32
        /// </summary>
 
33
        public class RTMNewNote : Act
 
34
        {
 
35
                public override string Name {
 
36
                        get { return AddinManager.CurrentLocalizer.GetString ("New Note"); }
 
37
                }
 
38
                
 
39
                public override string Description {
 
40
                        get { return AddinManager.CurrentLocalizer.GetString ("Add a new note to a task."); }
 
41
                }
 
42
                        
 
43
                public override string Icon {
 
44
                        get { return "note-add.png@" + GetType ().Assembly.FullName; }
 
45
                }
 
46
                
 
47
                public override IEnumerable<Type> SupportedItemTypes {
 
48
                        get { yield return typeof (RTMTaskItem); }
 
49
                }
 
50
                
 
51
                public override IEnumerable<Type> SupportedModifierItemTypes {
 
52
                        get { yield return typeof (ITextItem); }
 
53
                }
 
54
        
 
55
                public override bool ModifierItemsOptional {
 
56
                        get { return false; }
 
57
                }
 
58
                
 
59
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems) 
 
60
                {
 
61
                        string note = String.Empty;
 
62
                        
 
63
                        if (modifierItems.FirstOrDefault() != null) {
 
64
                                note = ((modifierItems.FirstOrDefault() as ITextItem).Text);
 
65
                        }
 
66
                        
 
67
                        Services.Application.RunOnThread (() => {
 
68
                                RTM.NewNote ((items.First () as RTMTaskItem).ListId,
 
69
                                        (items.First () as RTMTaskItem).TaskSeriesId,
 
70
                                        (items.First () as RTMTaskItem).Id, note);
 
71
                        });
 
72
                        yield break;
 
73
                }
 
74
        }
 
75
}
 
 
b'\\ No newline at end of file'