forked from ccjensen/expandrive-nl-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SKAction.h
176 lines (146 loc) · 5.06 KB
/
SKAction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
//
// SKAction.h
// Sidekick
//
// Created by Chris Farber on 2/7/07.
// Copyright 2007-2011 Oomph. All rights reserved.
//
#import <Cocoa/Cocoa.h>
enum {
SKPluginCategoryPlugin = 0,
SKPluginCategorySystem = 1,
SKPluginCategoryApplication = 2
};
typedef NSUInteger SKPluginCategory;
extern NSString * SKPluginCategoryName(SKPluginCategory category);
@class SKPlugin, SKOptionSheetController;
/**
* Every action must be a subclass of SKAction.
* Methods you will need to implement:
* +actionID, +category, +title, -performAction, -cleanupAction
* Usually, you will also want to override:
* -title, -optionDefaults, +icon, -icon
*/
__attribute__((visibility("default")))
@interface SKAction : NSObject {
@private
SKPlugin * plugin;
NSMutableDictionary * plist;
}
/**
* Returns the ID of the action.
* The ID must be a string, and must be unique within your plugin. If your action
* has options, then the ID is also assumed to be the filename of the nib containing
* your options. MUST BE OVERRIDEN.
* @see optionSheetController
*/
+ (NSString *) actionID;
/**
* Returns the name of the category the action will appear under.
* You shouldn't override this without good reason; the default implementation
* returns SKPluginCategoryPlugin
*/
+ (SKPluginCategory) category;
/**
* Returns the description the user will see when adding an action.
* MUST BE OVERRIDEN.
* Example: "Change the volume"
*/
+ (NSString *) title;
/**
* If your action should logically only have one instance per location (for
* example, you are modifying a system setting that there is no reason to set
* twice), then override this method to return NO. The default implementation
* returns YES.
*/
+ (BOOL) allowsMultipleInstances;
/**
* If your action should only be addable by the user if certain conditions
* have been met, you may use this method to hide it. This method is invoked
* frequently, so it must be efficient. The default implementation returns NO.
*/
+ (BOOL) invisible;
/**
* Let Sidekick know if this action should be included in new new locations
* that are created as a snapshot of the user machine's current state.
* The default implementation returns NO.
*/
+ (BOOL) snapshotable;
/**
* Returns an icon that will be displayed to the user in the list of available
* actions. The default is [NSImage imageNamed: @"NSAdvanced"]
*/
+ (NSImage *) icon;
+ (id)actionWithPlist: (NSMutableDictionary *)entry;
- (id)initWithPlist: (NSMutableDictionary *)entry;
- (NSMutableDictionary *) plist;
/**
* Gets the NSMutableDictionary of options
*/
- (NSMutableDictionary *) options;
- (NSNumber *) enabled;
- (void) setEnabled: (NSNumber *)enabled;
/**
* Returns the parent instance of SKPlugin.
*/
- (SKPlugin *) plugin;
- (NSString * )pluginID;
- (void) triggerTitleUpdate;
/**
* Let Sidekick know if this action has options.
* The default implementation searches for a nib file matching the action's ID,
* and returns an NSNumber containing YES if found. You only need to override this
* method if your nib's filename does not match +(NSString *)actionID
* @see actionID
*/
- (NSNumber *) hasOptions;
/**
* In special cases, when bindings prove inadequate, you will need
* to provide controller code for your option interface. To do this, you should
* subclass OptionSheetController and override this method to return your subclass's
* class. The default implementation of this method returns the class
* OptionSheetController. The class returned by this method is instantiated and used
* as the nib's owner.
*/
- (Class) optionSheetControllerClass;
/**
* Instantiate and return an OptionSheetController. The default implementation of this
* method uses the class returned by optionSheetControllerClass and instantiates it
* using +(NSString)actionID as the nib name.
* @see optionSheetControllerClass
* @see actionID
*/
- (SKOptionSheetController *) optionSheetController;
/**
* Return an NSDictionary containing default options. When the action is instantiated
* as a new action, this method is invoked to get the defaults
*/
- (NSDictionary *) optionDefaults;
/**
* This method returns a string describing the action for the user. It is displayed
* in the list of actions in a location in the preferences. The default implementation
* simply invokes +title
*/
- (NSString *) title;
/**
* Returns an NSImage containing an icon to display to the user in the list of
* actions for a location. If possible, this should be more specific than the
* icon returned by +icon; for example, an action that opens a URL may want to
* fetch the site's favicon and return it.
*/
- (NSImage *) icon;
/**
* performAction is invoked by Sidekick when it wants the action to do its
* stuff.
* MUST BE OVERRIDEN.
*/
- (void) performAction;
/**
* cleanupAction is invoked by Sidekick when it wants the action to clean up
* after itself. In other words, if you want to undo anything done by your action,
* such as set the system volume back to the value it was before performAction
* changed it, this is the place to do it.
* MUST BE OVERRIDEN.
*/
- (void) cleanupAction;
@end