-@interface StatusSettingsController :
NSWindowController<StatusMenuItemControllerProtocol> {
+@interface StatusSettingsController : NSWindowController {
IBOutlet NSTableView *statusTable_;
IBOutlet NSButton *removeSourceButton_;
IBOutlet NSArrayController *statusesController_;
+ IBOutlet NSPopUpButton *variablesPopup_;
+
AppDelegate *delegate_;
}
- (id)initWithDelegate:(AppDelegate*)delegate;
- (IBAction)editSelectedStatusName:(id)sender;
-- (IBAction)ok:(id)sender;
-- (IBAction)editSource:(id)sender;
-- (IBAction)customAvailableMessage:(id)sender;
-- (IBAction)customAwayMessage:(id)sender;
-- (IBAction)statusMenuItemSelected:(id)sender;
-- (IBAction)editSelectedStatusSource:(id)sender;
@end
Index: StatusSettingsController.m
===================================================================
--- StatusSettingsController.m (revision 12)
+++ StatusSettingsController.m (working copy)
@@ -57,8 +57,6 @@
- (void)windowDidLoad {
[super windowDidLoad];
[statusTable_ selectRow:1 byExtendingSelection:NO];
- [statusTable_ setTarget:self];
- [statusTable_ setDoubleAction:@selector(editSelectedStatusSource:)];
[statusTable_ setIntercellSpacing:NSMakeSize(3.0, 5.0)];
[[self window] setBackgroundColor:[NSColor whiteColor]];
@@ -74,7 +72,9 @@
if (![[self window] setFrameUsingName:kStatusSettingsNibName]) {
[[self window] center];
}
+ [[variablesPopup_ menu] setDelegate:self];
}
+
- (IBAction)showWindow:(id)sender {
NSRect screenRect = [[NSScreen mainScreen] frame];
NSRect visibleScreenRect = [[NSScreen mainScreen] visibleFrame];
@@ -140,38 +140,6 @@
return handled;
}
-- (void)tableView:(NSTableView *)tableView
- willDisplayCell:(id)cell
- forTableColumn:(NSTableColumn *)tableColumn
- row:(int)row {
- if ([[tableColumn identifier] isEqualToString:@"enabled"]) {
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- [cell setTransparent:![source isKindOfClass:[StatzSink class]]];
- }
- if ([[tableColumn identifier] isEqualToString:@"name"]) {
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- [cell setObjectValue:[source displayNameAndStatus]];
- }
-}
-
-- (id)tableView:(NSTableView *)tableView
- objectValueForTableColumn:(NSTableColumn *)tableColumn
- row:(int)row {
- id value = nil;
- if ([[tableColumn identifier] isEqualToString:@"value"]) {
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- if ([source isKindOfClass:[StatzSource class]]) {
- Status *current = [source currentStatus];
- NSPopUpButtonCell *cell = [tableColumn dataCellForRow:row];
- int index = [[cell menu]
indexOfItemWithRepresentedObject:current];
- value = [NSNumber numberWithInt:index];
- }
- }
- return value;
-}
- (BOOL)tableView:(NSTableView *)tableView
shouldEditTableColumn:(NSTableColumn *)tableColumn
@@ -192,7 +160,7 @@
row:(int)row
mouseLocation:(NSPoint)mouseLocation {
NSString *toolTip = nil;
- if ([[column identifier] isEqualToString:@"value"]) {
+ if ([[column identifier] isEqualToString:@"name"]) {
NSArray *sources = [statusesController_ arrangedObjects];
StatzSource *source = [sources objectAtIndex:row];
if ([source isKindOfClass:[StatzSource class]]) {
@@ -202,55 +170,6 @@
return toolTip;
}
-- (id)tableColumn:(NSTableColumn*)column dataCellForRow:(int)row {
- id value = nil;
- NSTableView *tableview = [column tableView];
- if (tableview == statusTable_) {
- if ([[column identifier] isEqualToString:@"value"]) {
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- if ([source isKindOfClass:[StatzSource class]]) {
- NSTableView *view = [column tableView];
- int selection = [view selectedRow];
- NSPopUpButtonCell *cell = [[[NSPopUpButtonCell alloc]
initTextCell:@""
-
pullsDown:NO] autorelease];
- [cell setBezeled:YES];
- [cell setBordered:NO];
- [cell setHighlighted:(selection == row)];
- [cell removeAllItems];
- [cell setFont:[NSFont systemFontOfSize:[NSFont
smallSystemFontSize]]];
- NSMenu *menu = [cell menu];
- [menu setAutoenablesItems:NO];
- NSArray *menuItems = [source statusMenuItemsWithTarget:self];
- id<NSMenuItem> item;
- NSEnumerator *menuItemEnum = [menuItems objectEnumerator];
- while ((item = [menuItemEnum nextObject])) {
- [menu addItem:item];
- }
- if ([source isKindOfClass:[StatzSink class]]) {
- NSObject<StatzSinkPlugin> *plugin = [(StatzSink*)source
plugin];
- if ([plugin hasPreferences]) {
- [menu addItem:[NSMenuItem separatorItem]];
- NSString *pluginEditItem = NSLocalizedString(@"%@
Settings...",
- @"Plugin
edit settings menu item");
- pluginEditItem = [NSString
stringWithFormat:pluginEditItem, [plugin name]];
- NSMenuItem *item = [menu addItemWithTitle:pluginEditItem
-
action:@selector(showAccountPreferences)
- keyEquivalent:@""];
- [item setTarget:plugin];
- }
- }
- value = cell;
- }
- }
- }
- if (!value) {
- NSCell *cell = [[[NSCell alloc] initTextCell:@""] autorelease];
- value = cell;
- }
- return value;
-}
-
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row {
NSArray *sources = [statusesController_ arrangedObjects];
return ![[sources objectAtIndex:row] isKindOfClass:
[StatusSettingsTitleItem class]];
@@ -264,76 +183,34 @@
[removeSourceButton_ setEnabled:![source isKindOfClass:[StatzSink
class]]];
}
-- (IBAction)editSelectedStatusSource:(id)sender {
- int row = [statusTable_ selectedRow];
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- EditSourceWindowController *controller =
[[EditSourceWindowController alloc] initWithStatzSource:source];
- [controller setStatus:[source currentStatus]];
- NSWindow *window = [controller window];
- [NSApp beginSheet:window
- modalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:controller];
-}
-
- (IBAction)editSelectedStatusName:(id)sender {
int row = [statusTable_ selectedRow];
int column = [statusTable_ columnWithIdentifier:@"name"];
[statusTable_ editColumn:column row:row withEvent:nil select:YES];
}
-- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode
contextInfo:(void *)contextInfo {
- [sheet orderOut:self];
- NSWindowController *controller = (NSWindowController*)contextInfo;
- [controller release];
- [statusTable_ reloadData];
-}
-
-- (IBAction)editAccounts:(id)sender {
- AccountSettingsWindowController *controller =
[[AccountSettingsWindowController alloc] initWithDelegate:delegate_];
- NSWindow *window = [controller window];
- [NSApp beginSheet:window
- modalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:controller];
-}
-
-- (IBAction)ok:(id)sender {
- [delegate_ applyStatuses:sender];
- [[self window] orderOut:sender];
-}
+- (void)menuNeedsUpdate:(NSMenu*)menu {
+ NSMenu *variableMenu = [variablesPopup_ menu];
+ if (menu != variableMenu) return;
-- (IBAction)editSource:(id)sender {
- [self editSelectedStatusSource:sender];
-}
-
-- (IBAction)customAvailableMessage:(id)sender {
- [self customMessage:sender state:kStatzStateAvailable];
-}
-
-- (IBAction)customAwayMessage:(id)sender {
- [self customMessage:sender state:kStatzStateAway];
-}
-
-- (void)customMessage:(id)sender state:(StatzState)state {
- int row = [statusTable_ selectedRow];
- NSArray *sources = [statusesController_ arrangedObjects];
- StatzSource *source = [sources objectAtIndex:row];
- CustomMessageWindowController *controller =
[[CustomMessageWindowController alloc] initWithStatzSource:source
- state:state
- applyStatusOnOK:NO
];
- NSWindow *window = [controller window];
- [NSApp beginSheet:window
- modalForWindow:[self window]
- modalDelegate:self
- didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
- contextInfo:controller];
+ // Remove old items
+ for (int i = 1, lastItem = [variableMenu numberOfItems];
+ i < lastItem; ++i) {
+ [menu removeItemAtIndex:1];
+ }
+
+ // Repopulate
+ NSArray *variables = [delegate_ statusVariables];
+ NSEnumerator *variableEnum = [variables objectEnumerator];
+ StatzSource *source;
+ while ((source = [variableEnum nextObject])) {
+ NSAttributedString *token = [source nameToken];
+ id<NSMenuItem> item = [variableMenu addItemWithTitle:@""
action:@selector(insertVariable:) keyEquivalent:@""];
+ [item setAttributedTitle:token];
+ [item setRepresentedObject:source];
+ [item setTarget:self];
+ }
}
-- (IBAction)statusMenuItemSelected:(id)sender {
-}
@end
Index: English.lproj/StatusSettings.nib/info.nib
===================================================================
--- English.lproj/StatusSettings.nib/info.nib (revision 12)
+++ English.lproj/StatusSettings.nib/info.nib (working copy)
@@ -9,7 +9,9 @@
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
- <array/>
+ <array>
+ <integer>8</integer>
+ </array>
<key>IBSystem Version</key>
<string>9B18</string>
<key>targetFramework</key>
Index: English.lproj/StatusSettings.nib/keyedobjects.nib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: English.lproj/StatusSettings.nib/classes.nib
===================================================================
--- English.lproj/StatusSettings.nib/classes.nib (revision 12)
+++ English.lproj/StatusSettings.nib/classes.nib (working copy)
@@ -19,11 +19,11 @@
</dict>
<dict>
<key>CLASS</key>
- <string>StatzSettingsWindow</string>
+ <string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
- <string>NSPanel</string>
+ <string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
@@ -55,36 +55,25 @@
<string>NSTableView</string>
<key>statusesController_</key>
<string>NSArrayController</string>
+ <key>variablesPopup_</key>
+ <string>NSPopUpButton</string>
</dict>
<key>SUPERCLASS</key>
<string>NSWindowController</string>
</dict>
<dict>
<key>CLASS</key>
- <string>FirstResponder</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- <dict>
- <key>CLASS</key>
<string>NSObject</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
<dict>
<key>CLASS</key>
- <string>DelegatingTableColumn</string>
+ <string>AttributedTextFieldCell</string>
<key>LANGUAGE</key>
<string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>delegate_</key>
- <string>id</string>
- </dict>
<key>SUPERCLASS</key>
- <string>NSTableColumn</string>
+ <string>NSTextFieldCell</string>
</dict>
<dict>
<key>CLASS</key>
Index: English.lproj/EditSource.nib/keyedobjects.nib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream