Permalink
Browse files

Increment badge on bell and on growl/NC notification

  • Loading branch information...
1 parent 78c4c0d commit ef4589f02404075760e5bec44d0ffa8fb0639265 @gnachman committed Dec 20, 2013
Showing with 39 additions and 3 deletions.
  1. +8 −0 PTYSession.m
  2. +2 −0 PseudoTerminal.h
  3. +21 −1 PseudoTerminal.m
  4. +5 −2 VT100Screen.m
  5. +3 −0 VT100ScreenDelegate.h
View
@@ -4670,6 +4670,14 @@ - (void)screenFlashImage:(FlashImage)image {
[TEXTVIEW beginFlash:image];
}
+- (void)screenIncrementBadge {
+ [[tab_ realParentWindow] incrementBadge];
+}
+
+- (void)screenRequestUserAttention:(BOOL)isCritical {
+ [NSApp requestUserAttention:isCritical ? NSCriticalRequest : NSInformationalRequest];
+}
+
- (void)screenSetCursorVisible:(BOOL)visible {
if (visible) {
[TEXTVIEW showCursor];
View
@@ -804,6 +804,8 @@ NSWindowDelegate,
- (void)changeTabColorToMenuAction:(id)sender;
- (void)moveSessionToWindow:(id)sender;
+- (void)incrementBadge;
+
@end
@interface PseudoTerminal (KeyValueCoding)
View
@@ -1667,6 +1667,8 @@ - (void)windowDidDeminiaturize:(NSNotification *)aNotification
NSLog(@"%s(%d):-[PseudoTerminal windowDidDeminiaturize:%@]",
__FILE__, __LINE__, aNotification);
#endif
+ [self.window.dockTile setBadgeLabel:@""];
+ [self.window.dockTile setShowsApplicationBadge:NO];
if ([[self currentTab] blur]) {
[self enableBlur:[[self currentTab] blurRadius]];
} else {
@@ -1804,7 +1806,8 @@ - (void)windowWillMiniaturize:(NSNotification *)aNotification
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
isOrderedOut_ = NO;
-
+ [[[NSApplication sharedApplication] dockTile] setBadgeLabel:@""];
+ [[[NSApplication sharedApplication] dockTile] setShowsApplicationBadge:NO];
#if DEBUG_METHOD_TRACE
NSLog(@"%s(%d):-[PseudoTerminal windowDidBecomeKey:%@]",
__FILE__, __LINE__, aNotification);
@@ -6021,6 +6024,23 @@ - (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel
return kValidModesForFontPanel;
}
+- (void)incrementBadge
+{
+ NSDockTile *dockTile;
+ if (self.window.isMiniaturized) {
+ dockTile = self.window.dockTile;
+ } else {
+ if ([[NSApplication sharedApplication] isActive]) {
+ return;
+ }
+ dockTile = [[NSApplication sharedApplication] dockTile];
+ }
+ int count = [[dockTile badgeLabel] intValue];
+ ++count;
+ [dockTile setBadgeLabel:[NSString stringWithFormat:@"%d", count]];
+ [self.window.dockTile setShowsApplicationBadge:YES];
+}
+
@end
View
@@ -888,7 +888,7 @@ - (void)cursorToX:(int)x
currentGrid_.cursorX = xPos;
DebugLog(@"cursorToX");
-
+
}
- (void)activateBell
@@ -912,6 +912,8 @@ - (void)activateBell
if (flashBell_) {
[delegate_ screenFlashImage:FlashBell];
}
+ [delegate_ screenIncrementBadge];
+ [delegate_ screenRequestUserAttention:NO];
}
- (void)setHistory:(NSArray *)history
@@ -1652,7 +1654,7 @@ - (void)requestUserAttentionWithMessage:(NSString *)message {
if (![self terminalPostGrowlNotification:message]) {
[self activateBell];
}
- [NSApp requestUserAttention:NSCriticalRequest];
+ [delegate_ screenRequestUserAttention:YES];
}
#pragma mark - VT100TerminalDelegate
@@ -2351,6 +2353,7 @@ - (void)terminalPopCurrentTitleForWindow:(BOOL)isWindow {
- (BOOL)terminalPostGrowlNotification:(NSString *)message {
if (postGrowlNotifications_) {
+ [delegate_ screenIncrementBadge];
NSString *description = [NSString stringWithFormat:@"Session %@ #%d: %@",
[delegate_ screenName],
[delegate_ screenNumber],
View
@@ -160,6 +160,9 @@
// An image should be flashed over the view.
- (void)screenFlashImage:(FlashImage)image;
+- (void)screenIncrementBadge;
+- (void)screenRequestUserAttention:(BOOL)isCritical;
+
// Show/hide the cursor.
- (void)screenSetCursorVisible:(BOOL)visible;

1 comment on commit ef4589f

broofa commented on ef4589f Dec 20, 2013

sweet, thx!

Please sign in to comment.