Browse Source

Changes for redesigned menu bar icon.

v1.2.3
Abhishek Banthia 9 years ago
parent
commit
db25f6aaf9
  1. 29
      Clocker/MenubarController.m

29
Clocker/MenubarController.m

@ -19,23 +19,32 @@
// Install status item into the menu bar // Install status item into the menu bar
NSData *dataObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteTimezone"]; NSData *dataObject = [[NSUserDefaults standardUserDefaults] objectForKey:@"favouriteTimezone"];
NSString *menuTitle = [NSString new]; NSString *menuTitle = [NSString new];
NSStatusItem *statusItem;
NSTextField *textField;
if (dataObject) { if (dataObject) {
CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:dataObject]; CLTimezoneData *timezoneObject = [CLTimezoneData getCustomObject:dataObject];
menuTitle = [timezoneObject getMenuTitle]; menuTitle = [timezoneObject getMenuTitle];
}
NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, STATUS_ITEM_VIEW_WIDTH, 18)]; textField= [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, STATUS_ITEM_VIEW_WIDTH, 18)];
textField.backgroundColor = [NSColor whiteColor]; textField.backgroundColor = [NSColor whiteColor];
textField.bordered = NO; textField.bordered = NO;
textField.textColor = [NSColor blackColor]; textField.textColor = [NSColor blackColor];
textField.alignment = NSTextAlignmentCenter; textField.alignment = NSTextAlignmentCenter;
textField.stringValue = (menuTitle.length > 0) ? menuTitle : @"Icon"; textField.stringValue = (menuTitle.length > 0) ? menuTitle : @"Icon";
[textField sizeToFit]; [textField sizeToFit];
statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:textField.frame.size.width+3];
}
else
{
statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:STATUS_ITEM_VIEW_WIDTH];
}
NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:textField.frame.size.width+3];
_statusItemView = [[StatusItemView alloc] initWithStatusItem:statusItem]; _statusItemView = [[StatusItemView alloc] initWithStatusItem:statusItem];
_statusItemView.image = [self imageWithSubviewsWithTextField:textField]; _statusItemView.image = dataObject ? [self imageWithSubviewsWithTextField:textField] : [NSImage imageNamed:@"MenuIcon"];
_statusItemView.alternateImage = [NSImage imageNamed:@"StatusHighlighted"]; _statusItemView.alternateImage = [NSImage imageNamed:@"StatusHighlighted"];
_statusItemView.action = @selector(togglePanel:); _statusItemView.action = @selector(togglePanel:);
[NSTimer scheduledTimerWithTimeInterval:1.0 [NSTimer scheduledTimerWithTimeInterval:1.0

Loading…
Cancel
Save