Skip to content

Commit

Permalink
Merge pull request getlantern#66 from jefvel/fix-mac-deprecations
Browse files Browse the repository at this point in the history
Fix mac deprecations
  • Loading branch information
joesis authored Oct 17, 2018
2 parents 168f224 + 8af35e2 commit ff50ae6
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions systray_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,30 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
}

- (void)setIcon:(NSImage *)image {
[statusItem setImage:image];
statusItem.button.image = image;
[self updateTitleButtonStyle];
}

- (void)setTitle:(NSString *)title {
[statusItem setTitle:title];
statusItem.button.title = title;
[self updateTitleButtonStyle];
}

-(void)updateTitleButtonStyle {
if (statusItem.button.image != nil) {
if ([statusItem.button.title length] == 0) {
statusItem.button.imagePosition = NSImageOnly;
} else {
statusItem.button.imagePosition = NSImageLeft;
}
} else {
statusItem.button.imagePosition = NSNoImage;
}
}


- (void)setTooltip:(NSString *)tooltip {
[statusItem setToolTip:tooltip];
statusItem.button.toolTip = tooltip;
}

- (IBAction)menuHandler:(id)sender
Expand All @@ -97,14 +112,14 @@ - (void) add_or_update_menu_item:(MenuItem*) item
}
[menuItem setToolTip:item->tooltip];
if (item->disabled == 1) {
[menuItem setEnabled:FALSE];
menuItem.enabled = FALSE;
} else {
[menuItem setEnabled:TRUE];
menuItem.enabled = TRUE;
}
if (item->checked == 1) {
[menuItem setState:NSOnState];
menuItem.state = NSControlStateValueOn;
} else {
[menuItem setState:NSOffState];
menuItem.state = NSControlStateValueOff;
}
}

Expand Down

0 comments on commit ff50ae6

Please sign in to comment.