Index: doc/systray.n ================================================================== --- doc/systray.n +++ doc/systray.n @@ -11,10 +11,12 @@ systray \- Creates an icon display in the platform-specific system tray. .SH SYNOPSIS \fBtk systray create \fI-image image\fR \fI?-text text\fR? \fI?-button1 callback?\fR \fI?-button3 callback?\fR .sp \fBtk systray configure \fI?option? ?value option value ...?\fR +.sp +\fBtk systray exists\fR .sp \fBtk systray destroy\fR .BE .BE .SH DESCRIPTION @@ -24,13 +26,16 @@ optional string for display in a tooltip, and optional callbacks that are bound to and . .PP The \fBtk systray configure\fR command sets one or more options of the systray icon. Configurable options are the same as for the \fBcreate\fR subcommand. When -a single option name is given, the command returns the current valus of this +a single option name is given, the command returns the current value of this option. When no option is given this command returns the list of all options and their current value. +.PP +The \fBtk systray exists\fR command checks whether a systray icon was created. +It returns a boolean. .PP The \fBtk systray destroy\fR command removes the icon from display and deallocates it. .PP From a user-interface standpoint, only one icon per interpreter is Index: library/systray.tcl ================================================================== --- library/systray.tcl +++ library/systray.tcl @@ -108,11 +108,11 @@ uplevel #0 [dict get $_current -button3] } } } - namespace export create configure destroy + namespace export create configure destroy exists namespace ensemble create } # Pure-Tcl system notification window for use if native implementation not available. @@ -294,11 +294,10 @@ } on error {msg opts} { return -code error -errorcode [dict get $opts -errorcode] $msg } } - # Remove the systray icon. proc ::tk::systray::destroy {} { variable _created variable _current variable _ico @@ -320,10 +319,16 @@ } set _created 0 set _current {} return } + +# Check systray icon existence. +proc tk::systray::exists {} { + variable _created + return $_created +} # Check systray options proc ::tk::systray::_check_options {argsList singleOk} { variable _options Index: tests/systray.test ================================================================== --- tests/systray.test +++ tests/systray.test @@ -190,10 +190,27 @@ tk systray create -image cross } -cleanup { tk systray destroy image delete cross } -result {} + +test systray-17 {systray icon existence check} -setup { + catch {tk systray destroy} +} -body { + tk systray exists +} -result {0} + +test systray-18 {systray icon existence check} -setup { + catch {tk systray destroy} + image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw== +} -body { + tk systray create -image _book -text "Systray test" + tk systray exists +} -cleanup { + tk systray destroy + image delete _book +} -result {1} test sysnotify-1 {system notification popup} -setup { image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw== tk systray create -image _book -text "Systray sample"