Skip to content

Commit

Permalink
Added Dock Badge sample.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Aug 8, 2009
1 parent 2caafb3 commit fe7aff4
Show file tree
Hide file tree
Showing 13 changed files with 5,402 additions and 0 deletions.
Binary file added DockBadge.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions DockBadge/Application.h
@@ -0,0 +1,19 @@
//
// Application.h
// DockBadge
//
// Created by Nando Vieira on 8/8/09.
// Copyright 2009 Simples Ideias. All rights reserved.
//

#import <Cocoa/Cocoa.h>


@interface Application : NSObject {
NSDockTile *dock;
IBOutlet NSButton *button;
}

-(IBAction)toggleBadgeLabel:(id)sender;
- (void)bounceDockIcon:(NSTimer *)timer;
@end
46 changes: 46 additions & 0 deletions DockBadge/Application.m
@@ -0,0 +1,46 @@
//
// Application.m
// DockBadge
//
// Created by Nando Vieira on 8/8/09.
// Copyright 2009 Simples Ideias. All rights reserved.
//

#import "Application.h"


@implementation Application
- (void)awakeFromNib
{
dock = [[NSApplication sharedApplication] dockTile];
[self toggleBadgeLabel:nil];

// to test icon bouncing, "build and go" and focus another app
[NSTimer scheduledTimerWithTimeInterval:5.0
target:self
selector:@selector(bounceDockIcon:)
userInfo:nil
repeats:NO];
}

- (void)bounceDockIcon:(NSTimer *)timer
{
[NSApp requestUserAttention:NSCriticalRequest];
}

-(IBAction)toggleBadgeLabel:(id)sender
{
if (![dock badgeLabel] || [[dock badgeLabel] isEqualToString:@""]) {
[dock setBadgeLabel:@"10"];
[NSApp requestUserAttention:NSCriticalRequest];
} else {
[dock setBadgeLabel:@""];
}
}

- (void)dealloc
{
[dock release];
[super dealloc];
}
@end
Binary file added DockBadge/DockBadge.xcodeproj/TemplateIcon.icns
Binary file not shown.

0 comments on commit fe7aff4

Please sign in to comment.