summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWm.c
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2021-09-07 02:44:06 (GMT)
committerKevin Walzer <kw@codebykevin.com>2021-09-07 02:44:06 (GMT)
commit6a38238e255ed7b75e1f77fbc134e33156b9cf86 (patch)
treebf69006d982335a9704b93f125ed8b6988d2a6cf /macosx/tkMacOSXWm.c
parent3236045c1ab01720ff6e93c4a2c4c06368f0c555 (diff)
downloadtk-6a38238e255ed7b75e1f77fbc134e33156b9cf86.zip
tk-6a38238e255ed7b75e1f77fbc134e33156b9cf86.tar.gz
tk-6a38238e255ed7b75e1f77fbc134e33156b9cf86.tar.bz2
wm test suite passes on macOS; other tweaks to Windows
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r--macosx/tkMacOSXWm.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 8f5b8f2..782bc9d 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -2374,15 +2374,40 @@ WmIconbadgeCmd(
Tcl_WrongNumArgs(interp, 2, objv,"window badge");
return TCL_ERROR;
}
-
+
label = [NSString stringWithUTF8String:Tcl_GetString(objv[3])];
+ int number = [label intValue];
+ NSDockTile *dockicon = [NSApp dockTile];
+
/*
- * Set the icon badge on the Dock icon.
+ * First, check that the label is not a decimal. If it is,
+ * return an error.
*/
- NSDockTile *dockicon = [NSApp dockTile];
- [dockicon setBadgeLabel: label];
+ if ([label containsString:@"."]) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use \"%s\" as icon badge", Tcl_GetString(objv[3])));
+ return TCL_ERROR;
+ }
+
+ /*
+ * Next, check that label is an int, empty string, or exclamation
+ * point. If so, set the icon badge on the Dock icon. Otherwise,
+ * return an error.
+ */
+
+ NSArray *array = @[@"", @"!"];
+ if ([array containsObject: label]) {
+ [dockicon setBadgeLabel: label];
+ } else if (number > 0) {
+ NSString *str = [@(number) stringValue];
+ [dockicon setBadgeLabel:str];
+ } else {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "can't use \"%s\" as icon badge", Tcl_GetString(objv[3])));
+ return TCL_ERROR;
+ }
return TCL_OK;
}