diff options
| author | fffw | 2015-02-13 15:20:13 +0800 |
|---|---|---|
| committer | fffw | 2015-02-13 15:20:13 +0800 |
| commit | c00cfb38ee3aee8da409898fed17e80716095e89 (patch) | |
| tree | e6997d1ab53bfb8e1dfeafec7e239f8cfbc35838 /lib/systray_darwin.c | |
| parent | 85d3e528d5a1d1ef8b60dcafc901c633343b4a37 (diff) | |
| parent | 6a81309bde4a67b2d5d1cb57b2e89945ba63fde6 (diff) | |
| download | systray-issue-2143-lib.tar.bz2 | |
merge xcompileissue-2143-lib
Diffstat (limited to 'lib/systray_darwin.c')
| -rw-r--r-- | lib/systray_darwin.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/systray_darwin.c b/lib/systray_darwin.c index 50a37d8..fffc49e 100644 --- a/lib/systray_darwin.c +++ b/lib/systray_darwin.c @@ -4,27 +4,26 @@ @interface MenuItem : NSObject { @public - NSString* menuId; + NSNumber* menuId; NSString* title; NSString* tooltip; short disabled; short checked; } --(id) initWithId: (const char*)theMenuId +-(id) initWithId: (int)theMenuId withTitle: (const char*)theTitle withTooltip: (const char*)theTooltip withDisabled: (short)theDisabled withChecked: (short)theChecked; @end @implementation MenuItem - -(id) initWithId: (const char*)theMenuId + -(id) initWithId: (int)theMenuId withTitle: (const char*)theTitle withTooltip: (const char*)theTooltip withDisabled: (short)theDisabled withChecked: (short)theChecked { - menuId = [[NSString alloc] initWithCString:theMenuId - encoding:NSUTF8StringEncoding]; + menuId = [NSNumber numberWithInt:theMenuId]; title = [[NSString alloc] initWithCString:theTitle encoding:NSUTF8StringEncoding]; tooltip = [[NSString alloc] initWithCString:theTooltip @@ -80,8 +79,8 @@ - (IBAction)menuHandler:(id)sender { - NSString* menuId = [sender representedObject]; - systray_menu_item_selected((char*)[menuId cStringUsingEncoding: NSUTF8StringEncoding]); + NSNumber* menuId = [sender representedObject]; + systray_menu_item_selected(menuId.intValue); } - (void) add_or_update_menu_item:(MenuItem*) item @@ -152,9 +151,8 @@ void setTooltip(char* ctooltip) { runInMainThread(@selector(setTooltip:), (id)tooltip); } -void add_or_update_menu_item(char* menuId, char* title, char* tooltip, short disabled, short checked) { +void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disabled, short checked) { MenuItem* item = [[MenuItem alloc] initWithId: menuId withTitle: title withTooltip: tooltip withDisabled: disabled withChecked: checked]; - free(menuId); free(title); free(tooltip); runInMainThread(@selector(add_or_update_menu_item:), (id)item); |
