~cszikszoy/do-plugins/pastebin

« back to all changes in this revision

Viewing changes to Pidgin/src/PidginSetStatusAction.cs

  • Committer: David Siegel
  • Date: 2008-06-02 16:09:11 UTC
  • Revision ID: dave@x-20080602160911-5bc56q3okv27pg7y
Added GNOME Terminal plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  PidginSetStatusAction.cs
 
2
//
 
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.
 
6
//
 
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.
 
11
//
 
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.
 
16
//
 
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/>.
 
19
 
 
20
using System;
 
21
using System.Collections.Generic;
 
22
 
 
23
using Do.Universe;
 
24
 
 
25
namespace Do.Addins.Pidgin
 
26
{
 
27
        public sealed class PidginSetStatusAction : IAction
 
28
        {
 
29
                private IItem [] pidginStatuses;
 
30
                
 
31
                public PidginSetStatusAction ()
 
32
                {
 
33
                        pidginStatuses = new IItem [] {new PidginStatusTypeItem (1), 
 
34
                                new PidginStatusTypeItem (2), new PidginStatusTypeItem (3),
 
35
                                new PidginStatusTypeItem (4), new PidginStatusTypeItem (5)};
 
36
                }
 
37
                
 
38
                public string Name { get { return "Set status"; } }
 
39
                public string Description { get { return "Set pidgin status message"; } }
 
40
                public string Icon { get { return "pidgin"; } }
 
41
                
 
42
                public Type [] SupportedItemTypes {
 
43
                        get {
 
44
                                return new Type [] {
 
45
                                        typeof (PidginSavedStatusItem),
 
46
                                        typeof (ITextItem),
 
47
                                };
 
48
                        }
 
49
                }
 
50
                
 
51
                public Type [] SupportedModifierItemTypes {
 
52
                        get {
 
53
                                return new Type [] {
 
54
                                        typeof (PidginStatusTypeItem),
 
55
                                };
 
56
                        }
 
57
                }
 
58
                
 
59
                public bool SupportsItem (IItem item)
 
60
                {
 
61
                        return true;
 
62
                }
 
63
                
 
64
                public bool ModifierItemsOptional {
 
65
                        get { return true; }
 
66
                }
 
67
                
 
68
                public bool SupportsModifierItemForItems (IItem [] items, IItem modItem)
 
69
                {
 
70
                        if (items [0] is ITextItem)
 
71
                                return true;
 
72
                        return false;
 
73
                }
 
74
                
 
75
                public IItem [] DynamicModifierItemsForItem (IItem item)
 
76
        {
 
77
            return pidginStatuses;
 
78
        }
 
79
                
 
80
                public IItem [] Perform (IItem [] items, IItem [] modItems)
 
81
                {
 
82
                        int status;
 
83
                        string message;
 
84
                                try {
 
85
                                Pidgin.IPurpleObject prpl = Pidgin.GetPurpleObject ();
 
86
                                
 
87
                                if (items [0] is PidginSavedStatusItem) {
 
88
                                        status = (items [0] as PidginSavedStatusItem).ID;
 
89
                                        prpl.PurpleSavedstatusActivate (status);
 
90
                                } else {
 
91
                                        message = (items [0] as ITextItem).Text;
 
92
                                        if (modItems.Length > 0)
 
93
                                                status = (int) (modItems [0] as PidginStatusTypeItem).Status;
 
94
                                        else
 
95
                                                status = prpl.PurpleSavedstatusGetType (prpl.PurpleSavedstatusGetCurrent ());
 
96
                                        Pidgin.PurpleSetAvailabilityStatus ((uint) status, message);
 
97
                                }
 
98
                        } catch { }
 
99
                        return null;
 
100
                }
 
101
        }
 
102
}
 
 
b'\\ No newline at end of file'