diff options
author | Kevin Walzer <kw@codebykevin.com> | 2020-10-17 13:50:00 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2020-10-17 13:50:00 (GMT) |
commit | 488b38641381e64787b3ffbf5a88b31f8f9ce0a7 (patch) | |
tree | bffd35a45ddf9ea80eac425d86212c9def56441b /macosx/tkMacOSXSysTray.c | |
parent | f5e4e83d21d8ac7a28857e900e2e4e7b6837421a (diff) | |
download | tk-488b38641381e64787b3ffbf5a88b31f8f9ce0a7.zip tk-488b38641381e64787b3ffbf5a88b31f8f9ce0a7.tar.gz tk-488b38641381e64787b3ffbf5a88b31f8f9ce0a7.tar.bz2 |
Limit icon display to one instance per interpeter and add detail about this to man pge
Diffstat (limited to 'macosx/tkMacOSXSysTray.c')
-rw-r--r-- | macosx/tkMacOSXSysTray.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/macosx/tkMacOSXSysTray.c b/macosx/tkMacOSXSysTray.c index 923276e..63e9b6c 100644 --- a/macosx/tkMacOSXSysTray.c +++ b/macosx/tkMacOSXSysTray.c @@ -212,27 +212,30 @@ MacSystrayObjCmd( Tcl_Obj *const *objv) { Tk_Image tk_image; - TrayInfo *info = (TrayInfo *)clientData; - int result, idx; - static const char *options[] = - {"create", "modify", "destroy", NULL}; + TrayInfo *info = (TrayInfo *)clientData; + int result, idx; + static const char *options[] = + {"create", "modify", "destroy", NULL}; typedef enum {TRAY_CREATE, TRAY_MODIFY, TRAY_DESTROY} optionsEnum; static const char *modifyOptions[] = - {"image", "text", "callback", NULL}; + {"image", "text", "callback", NULL}; typedef enum {TRAY_IMAGE, TRAY_TEXT, TRAY_CALLBACK} modifyOptionsEnum; if (info->tk_item == NULL) { info->tk_item = [[TkStatusItem alloc] init: interp]; + } else { + Tcl_AppendResult(interp, "Only one system tray icon supported per interpeter", NULL); + return TCL_ERROR; } - if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "create | modify | destroy"); - return TCL_ERROR; - } + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "create | modify | destroy"); + return TCL_ERROR; + } - result = Tcl_GetIndexFromObjStruct(interp, objv[1], options, - sizeof(char *), "command", 0, &idx); + result = Tcl_GetIndexFromObjStruct(interp, objv[1], options, + sizeof(char *), "command", 0, &idx); if (result != TCL_OK) { return TCL_ERROR; @@ -287,7 +290,7 @@ MacSystrayObjCmd( [info->tk_item setCallback : objv[4]]; break; - } + } case TRAY_MODIFY: { if (objc < 4) { Tcl_WrongNumArgs(interp, 1, objv, "modify object item"); @@ -299,11 +302,11 @@ MacSystrayObjCmd( */ result = Tcl_GetIndexFromObjStruct(interp, objv[2], modifyOptions, - sizeof(char *), "option", 0, &idx); + sizeof(char *), "option", 0, &idx); - if (result != TCL_OK) { - return TCL_ERROR; - } + if (result != TCL_OK) { + return TCL_ERROR; + } switch ((modifyOptionsEnum)idx) { case TRAY_IMAGE: { Tk_Window tkwin = Tk_MainWindow(interp); @@ -325,14 +328,14 @@ MacSystrayObjCmd( [info->tk_item setImagewithImage: icon]; } Tk_FreeImage(tk_image); - break; + break; } - /* - * Modify the text for the tooltip. - */ + /* + * Modify the text for the tooltip. + */ - case TRAY_TEXT: { + case TRAY_TEXT: { NSString *tooltip = [NSString stringWithUTF8String:Tcl_GetString(objv[3])]; if (tooltip == nil) { Tcl_AppendResult(interp, "unable to set tooltip for systray icon", NULL); @@ -343,14 +346,14 @@ MacSystrayObjCmd( break; } - /* - * Modify the proc for the callback. - */ + /* + * Modify the proc for the callback. + */ case TRAY_CALLBACK: { [info->tk_item setCallback : objv[3]]; } - break; + break; } break; } |