diff options
| author | joesis | 2017-09-12 22:37:40 +0800 |
|---|---|---|
| committer | GitHub | 2017-09-12 22:37:40 +0800 |
| commit | 060c06f22e631c46a2d738532bc81c37b0f31595 (patch) | |
| tree | 174769c64d8b1254d4f4203655b42b38f0c0c63e /systray_darwin.m | |
| parent | 66e6fad5eea92d7adda31abfae7a5a52070dfae5 (diff) | |
| parent | e00812af2c109a6cfa4c9a4774e4f805b6119290 (diff) | |
| download | systray-060c06f22e631c46a2d738532bc81c37b0f31595.tar.bz2 | |
Merge pull request #31 from getlantern/issue881
Add ability to show/hide menu items
Diffstat (limited to 'systray_darwin.m')
| -rw-r--r-- | systray_darwin.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/systray_darwin.m b/systray_darwin.m index 03a21ef..3a28c73 100644 --- a/systray_darwin.m +++ b/systray_darwin.m @@ -108,6 +108,28 @@ } } +- (void) hide_menu_item:(NSNumber*) menuId +{ + NSMenuItem* menuItem; + int existedMenuIndex = [menu indexOfItemWithRepresentedObject: menuId]; + if (existedMenuIndex == -1) { + return; + } + menuItem = [menu itemAtIndex: existedMenuIndex]; + [menuItem setHidden:TRUE]; +} + +- (void) show_menu_item:(NSNumber*) menuId +{ + NSMenuItem* menuItem; + int existedMenuIndex = [menu indexOfItemWithRepresentedObject: menuId]; + if (existedMenuIndex == -1) { + return; + } + menuItem = [menu itemAtIndex: existedMenuIndex]; + [menuItem setHidden:FALSE]; +} + - (void) quit { [NSApp terminate:self]; @@ -156,6 +178,16 @@ void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disab runInMainThread(@selector(add_or_update_menu_item:), (id)item); } +void hide_menu_item(int menuId) { + NSNumber *mId = [NSNumber numberWithInt:menuId]; + runInMainThread(@selector(hide_menu_item:), (id)mId); +} + +void show_menu_item(int menuId) { + NSNumber *mId = [NSNumber numberWithInt:menuId]; + runInMainThread(@selector(show_menu_item:), (id)mId); +} + void quit() { runInMainThread(@selector(quit), nil); } |
