~ubuntu-branches/debian/squeeze/gnome-do-plugins/squeeze

« back to all changes in this revision

Viewing changes to RememberTheMilk/src/RTMAddTags.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 16:11:49 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627161149-b74nc297di2842u1
* New upstream release
  + Pidgin plugin now supports initial text for messages (LP: #338608)
  + Pidgin plugin opens conversations on the correct IM network (LP: #370965)
* debian/rules:
  + Update get-orig-source target.  Upstream no longer ships gdata* binaries,
    so we no longer need to strip them
* debian/patches/00_use_system_gdata
  + Drop.  Upstream now builds against system libgdata.
* debian/patches/04_fix_pidgin_dbus_ints
* debian/patches/10_fix_rhythmbox_file
* debian/patches/15_twitter_api
* debian/patches/20_twitter_overflow:
  + Drop.  Included upstream.
* debian/patches/01_firefox_iceweasel_rename:
  + Refresh for new version
* debian/patches/02_fix_banshee_plugin:
  + Drop refernce to /usr/lib/banshee-1/Banshee.CollectionIndexer.dll.
    This is unnecessary, and causes errors when Banshee isn't installed.
* debian/patches/00_debian_default_plugins:
  + Enable a bunch of useful plugins that do not require configuration from 
    the "Official" plugin set by default.  Makes Do more useful out of the 
    box.
* debian/control:
  + Bump versioned build-dep on gnome-do to 0.8.2
  + Split out gnome-do-plugin-evolution package, now that this is possible.
    libevolution5.0-cil has an annoyingly large dependency stack.
    (LP: #351535) (Closes: #524993).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// RTMAddTags.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 Mono.Addins;
 
23
 
 
24
using Do.Universe;
 
25
using Do.Platform;
 
26
 
 
27
namespace RememberTheMilk
 
28
{
 
29
        /// <summary>
 
30
        /// Class to provide the "Add Tag(s)" action
 
31
        /// </summary>
 
32
        public class RTMAddTags : Act
 
33
        {
 
34
                public override string Name {
 
35
                        get { return AddinManager.CurrentLocalizer.GetString ("Add Tag(s)"); }
 
36
                }
 
37
                
 
38
                public override string Description {
 
39
                        get { return AddinManager.CurrentLocalizer.GetString ("Add one or more tags to a task."); }
 
40
                }
 
41
                        
 
42
                public override string Icon {
 
43
                        get { return "tag-add.png@" + GetType ().Assembly.FullName; }
 
44
                }
 
45
                
 
46
                public override IEnumerable<Type> SupportedItemTypes {
 
47
                        get {
 
48
                                yield return typeof (RTMTaskItem);
 
49
                                yield return typeof (RTMTaskAttributeItem);
 
50
                        }
 
51
                }
 
52
                
 
53
                public override IEnumerable<Type> SupportedModifierItemTypes {
 
54
                        get { 
 
55
                                yield return typeof (ITextItem);
 
56
                                yield return typeof (RTMTagItem);
 
57
                        }
 
58
                }
 
59
                
 
60
                public override bool SupportsItem (Item item) {
 
61
                        if (item is RTMTaskItem)
 
62
                                return true;
 
63
                        else if (item is RTMTaskAttributeItem)
 
64
                                return (item as RTMTaskAttributeItem).Description == "Tags";
 
65
                        else
 
66
                                return false;
 
67
                }
 
68
                
 
69
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems) 
 
70
                {
 
71
                        RTMTaskItem task = null;
 
72
                        List<string> temp_tags = new List<string> ();
 
73
                        string s = null;
 
74
                        
 
75
                        if (items.Any()) {
 
76
                                if (items.First () is RTMTaskItem)
 
77
                                        task = (items.First () as RTMTaskItem);
 
78
                                else if (items.First () is RTMTaskAttributeItem)
 
79
                                        task = (items.First () as RTMTaskAttributeItem).Parent;
 
80
                        }
 
81
                        
 
82
                        if (modifierItems.Any () && task != null) {
 
83
                                foreach (Item item in modifierItems) {
 
84
                                        s = GetText (item);
 
85
                                        if (!String.IsNullOrEmpty(s))
 
86
                                                temp_tags.Add (s);
 
87
                                }
 
88
                                
 
89
                                Services.Application.RunOnThread (() => {
 
90
                                        RTM.AddTags ((items.First () as RTMTaskItem).ListId, (items.First () as RTMTaskItem).TaskSeriesId,
 
91
                                                (items.First () as RTMTaskItem).Id, String.Join (",", temp_tags.ToArray ()));
 
92
                                });
 
93
                        }
 
94
                        yield break;
 
95
                }
 
96
                
 
97
                protected string GetText (Item item)
 
98
                {
 
99
                        if (item is ITextItem)
 
100
                                return (item as ITextItem).Text;
 
101
                        if (item is RTMTagItem)
 
102
                                return (item as RTMTagItem).Name;
 
103
                        throw new Exception ("Inappropriate Item type.");
 
104
                }
 
105
        }
 
106
}
 
 
b'\\ No newline at end of file'