From 1f3cb00843fa25541fd06558bf5e2b7f87e5bce4 Mon Sep 17 00:00:00 2001 From: jefvel Date: Tue, 16 Oct 2018 10:29:20 +0200 Subject: [PATCH 1/2] Fixed Mac deprecations. Icon is placed correctly. --- systray_darwin.m | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/systray_darwin.m b/systray_darwin.m index a489bc47..3e5e2ff9 100644 --- a/systray_darwin.m +++ b/systray_darwin.m @@ -64,15 +64,16 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification } - (void)setIcon:(NSImage *)image { - [statusItem setImage:image]; + statusItem.button.image = image; + statusItem.button.imagePosition = NSImageLeft; } - (void)setTitle:(NSString *)title { - [statusItem setTitle:title]; + statusItem.button.title = title; } - (void)setTooltip:(NSString *)tooltip { - [statusItem setToolTip:tooltip]; + statusItem.button.toolTip = tooltip; } - (IBAction)menuHandler:(id)sender @@ -97,14 +98,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; } } From 8af35e2f6387334233ec627f136244c2c32af676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aksel=20Kornesj=C3=B6?= Date: Tue, 16 Oct 2018 13:29:12 +0200 Subject: [PATCH 2/2] Made statusItem imagePosition update based on if title and/or icon exists on mac --- systray_darwin.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/systray_darwin.m b/systray_darwin.m index 3e5e2ff9..e4669488 100644 --- a/systray_darwin.m +++ b/systray_darwin.m @@ -65,13 +65,27 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification - (void)setIcon:(NSImage *)image { statusItem.button.image = image; - statusItem.button.imagePosition = NSImageLeft; + [self updateTitleButtonStyle]; } - (void)setTitle:(NSString *)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.button.toolTip = tooltip; }