REVIEW: Get statuses actually working again

1 view
Skip to first unread message

Dave MacLachlan

unread,
Nov 20, 2007, 10:13:46 PM11/20/07
to statz-d...@groups.google.com
Index: StatzSource.m
===================================================================
--- StatzSource.m (revision 15)
+++ StatzSource.m (working copy)
@@ -84,12 +84,14 @@
return [[currentStatus retain] autorelease];
}

-- (void)setCurrentStatus:(Status*)value {
- [self setCurrentStatusIndex:[[self statuses] indexOfObject:value]];
+- (NSIndexSet*)currentStatusIndex {
+ return [NSIndexSet indexSetWithIndex:currentStatus_];
}

-- (void)setCurrentStatusIndex:(int)value {
- currentStatus_ = value;
+- (void)setCurrentStatusIndex:(NSIndexSet*)value {
+ if ([value count]) {
+ currentStatus_ = [value firstIndex];
+ }
}

- (int)statusIndex:(Status*)value {
@@ -165,14 +167,14 @@
return [[statuses_ retain] autorelease];
}

-- (void)addStatus:(Status*)statuz {
- if (![statuses_ containsObject:statuz]) {
- [statuses_ addObject:statuz];
+- (void)addStatus:(Status*)status {
+ if (![statuses_ containsObject:status]) {
+ [statuses_ addObject:status];
}
}

-- (void)removeStatus:(Status*)statuz {
- [statuses_ removeObject:statuz];
+- (void)removeStatus:(Status*)status {
+ [statuses_ removeObject:status];
}

- (BOOL)isValid {
Index: CustomMessageWindowController.m
===================================================================
--- CustomMessageWindowController.m (revision 15)
+++ CustomMessageWindowController.m (working copy)
@@ -92,9 +92,9 @@
Status *status = [[[Status alloc] initWithStatus:[messageField_
attributedStringValue]
state:[statePopUp_
selectedTag]] autorelease];
[source_ addStatus:status];
- [source_ setCurrentStatus:status];
+ //[source_ setCurrentStatus:status];
if (applyStatusOnOK_) {
- [[NSApp delegate] applyStatuses:sender];
+ //[[NSApp delegate] applyStatuses:nil];
}
[self cancel:sender];
}
Index: English.lproj/StatusSettings.nib/info.nib
===================================================================
--- English.lproj/StatusSettings.nib/info.nib (revision 15)
+++ English.lproj/StatusSettings.nib/info.nib (working copy)
@@ -10,7 +10,7 @@
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
- <integer>8</integer>
+ <integer>533</integer>
</array>
<key>IBSystem Version</key>
<string>9B18</string>
Index: English.lproj/StatusSettings.nib/keyedobjects.nib
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: AppDelegate.h
===================================================================
--- AppDelegate.h (revision 15)
+++ AppDelegate.h (working copy)
@@ -35,12 +35,10 @@
}
- (void)handleFirstLaunch;
- (IBAction)showPreferences:(id)sender;
-- (IBAction)setStatus:(id)sender;
- (NSArray*)statusSources;
- (NSArray*)statusSourcesWithoutSinks;
- (NSArray*)statusSinks;
- (NSArray*)enabledStatusSinks;
- (NSArray*)statusVariables;
-- (IBAction)applyStatuses:(id)sender;
- (StatzSource*)defaultStatusSource;
@end
Index: AppDelegate.m
===================================================================
--- AppDelegate.m (revision 15)
+++ AppDelegate.m (working copy)
@@ -42,7 +42,7 @@
@end

@interface AppDelegate (AppDelegatePrivate)
-- (void)statusSelected:(NSNotification*)n;
+- (void)applyStatuses:(NSNotification*)sender;
@end


@@ -180,6 +180,10 @@
- (IBAction)showPreferences:(id)sender {
if (!statusSettingsController_) {
statusSettingsController_ = [[StatusSettingsController alloc]
initWithDelegate:self];
+ NSWindow *window = [statusSettingsController_ window];
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:self selector:@selector(applyStatuses:)
+ name:NSWindowDidResignKeyNotification object:window];
}

if ([[statusSettingsController_ window] isKeyWindow]) {
@@ -260,18 +264,8 @@
return [[statusSources_ retain] autorelease];
}

-- (IBAction)setStatus:(id)sender {
- if (!statusSettingsController_) {
- statusSettingsController_ = [[StatusSettingsController alloc]
initWithDelegate:self];
- }
-
- [statusSettingsController_ showWindow:sender];
- [NSApp activateIgnoringOtherApps:YES];
-
-}
-
-- (IBAction)applyStatuses:(id)sender {
- NSArray *statusSinks = [[NSApp delegate] statusSinks];
+- (void)applyStatuses:(NSNotification *)notification {
+ NSArray *statusSinks = [self statusSinks];
NSEnumerator *sinkEnumerator = [statusSinks objectEnumerator];
StatzSink<StatzSinkPlugin> *sink;
NSArray *runningApps = [[NSWorkspace sharedWorkspace]
launchedApplications];
@@ -294,14 +288,6 @@
}
}

-- (void)statusSelected:(NSNotification*)n {
- id<NSMenuItem> menuitem = [[n userInfo] objectForKey:@"MenuItem"];
- id object = [menuitem representedObject];
- if (object && [object isKindOfClass:[Status class]]) {
- [self applyStatuses:menuitem];
- }
-}
-
- (NSString *)description {
return [NSString stringWithFormat:@"AppDelegate sources: %@
\nEnabled Sinks:%@\nAll Sinks:%@", [self statusSourcesWithoutSinks],
[self enabledStatusSinks], [self statusSinks]];
}
Index: StatzSource.h
===================================================================
--- StatzSource.h (revision 15)
+++ StatzSource.h (working copy)
@@ -41,14 +41,14 @@
- (NSImage*)image;
- (NSAttributedString*)nameToken;
- (Status*)currentStatus;
-- (void)setCurrentStatus:(Status*)value;
-- (void)setCurrentStatusIndex:(int)value;
+- (NSIndexSet*)currentStatusIndex;
+- (void)setCurrentStatusIndex:(NSIndexSet*)value;
- (int)statusIndex:(Status*)value;
- (Status*)statusAtIndex:(int)index;
- (int)statusCount;
- (NSArray*)statuses;
-- (void)addStatus:(Status*)statuz;
-- (void)removeStatus:(Status*)statuz;
+- (void)addStatus:(Status*)status;
+- (void)removeStatus:(Status*)status;
- (BOOL)isValid;
- (void)addSourceDependenciesTo:(NSMutableArray*)array;
- (BOOL)isEnabled;

Reply all
Reply to author
Forward
0 new messages