Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved: Code formatting.

  • Loading branch information...
commit 219370f1d16a5840db5f1cb3b21e81207d21acb5 1 parent 926464d
Vadim Shpakovski authored
2  Popup/ApplicationDelegate.m
View
@@ -41,7 +41,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
- // Remove the icon from the menu bar
+ // Explicitly remove the icon from the menu bar
self.menubarController = nil;
return NSTerminateNow;
2  Popup/BackgroundView.m
View
@@ -8,6 +8,8 @@
#define SEARCH_INSET 10
+#pragma mark -
+
@implementation BackgroundView
@synthesize arrowX = _arrowX;
6 Popup/MenubarController.m
View
@@ -9,7 +9,8 @@ @implementation MenubarController
- (id)init
{
- if ((self = [super init]))
+ self = [super init];
+ if (self != nil)
{
// Install status item into the menu bar
NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:STATUS_ITEM_VIEW_WIDTH];
@@ -33,8 +34,7 @@ - (void)dealloc
- (NSStatusItem *)statusItem
{
- NSStatusItem *item = self.statusItemView.statusItem;
- return item;
+ return self.statusItemView.statusItem;
}
#pragma mark -
7 Popup/Panel.m
View
@@ -4,12 +4,7 @@ @implementation Panel
- (BOOL)canBecomeKeyWindow;
{
- return YES;
-}
-
-- (void)flagsChanged:(NSEvent *)theEvent;
-{
- [[self contentView] setNeedsDisplay:YES];
+ return YES; // Allow Search field to become the first responder
}
@end
1  Popup/PanelController.h
View
@@ -34,6 +34,5 @@
- (void)openPanel;
- (void)closePanel;
- (NSRect)statusRectForWindow:(NSWindow *)window;
-- (void)resetPanelHeight;
@end
16 Popup/PanelController.m
View
@@ -26,7 +26,7 @@ @implementation PanelController
- (id)initWithDelegate:(id<PanelControllerDelegate>)delegate
{
self = [super initWithWindowNibName:@"Panel"];
- if (self)
+ if (self != nil)
{
_delegate = delegate;
}
@@ -53,9 +53,12 @@ - (void)awakeFromNib
[panel setOpaque:NO];
[panel setBackgroundColor:[NSColor clearColor]];
- [self resetPanelHeight];
+ // Resize panel
+ NSRect panelRect = [[self window] frame];
+ panelRect.size.height = POPUP_HEIGHT;
+ [[self window] setFrame:panelRect display:NO];
- // Track search results
+ // Follow search string
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(runSearch) name:NSControlTextDidChangeNotification object:self.searchField];
}
@@ -247,11 +250,4 @@ - (void)closePanel
});
}
-- (void)resetPanelHeight
-{
- NSRect panelRect = [[self window] frame];
- panelRect.size.height = POPUP_HEIGHT;
- [[self window] setFrame:panelRect display:NO];
-}
-
@end
2  Popup/Popup-Info.plist
View
@@ -25,7 +25,7 @@
<key>CFBundleURLTypes</key>
<array/>
<key>CFBundleVersion</key>
- <string>3</string>
+ <string>4</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
10 Popup/StatusItemView.m
View
@@ -16,7 +16,9 @@ - (id)initWithStatusItem:(NSStatusItem *)statusItem
CGFloat itemWidth = [statusItem length];
CGFloat itemHeight = [[NSStatusBar systemStatusBar] thickness];
NSRect itemRect = NSMakeRect(0.0, 0.0, itemWidth, itemHeight);
- if ((self = [super initWithFrame:itemRect]))
+ self = [super initWithFrame:itemRect];
+
+ if (self != nil)
{
_statusItem = [statusItem retain];
_statusItem.view = self;
@@ -29,6 +31,7 @@ - (void)dealloc
[_statusItem release];
[_image release];
[_alternateImage release];
+
[super dealloc];
}
@@ -37,6 +40,7 @@ - (void)dealloc
- (void)drawRect:(NSRect)dirtyRect
{
[self.statusItem drawStatusBarBackgroundInRect:dirtyRect withHighlight:self.isHighlighted];
+
NSImage *icon = self.isHighlighted ? self.alternateImage : self.image;
NSSize iconSize = [icon size];
NSRect bounds = self.bounds;
@@ -64,6 +68,8 @@ - (void)setHighlighted:(BOOL)newFlag
[self setNeedsDisplay:YES];
}
+#pragma mark -
+
- (void)setImage:(NSImage *)newImage
{
[newImage retain];
@@ -81,6 +87,8 @@ - (void)setAlternateImage:(NSImage *)newImage
[self setNeedsDisplay:YES];
}
+#pragma mark -
+
- (NSRect)globalRect
{
NSRect frame = [self frame];
Please sign in to comment.
Something went wrong with that request. Please try again.