Tk Source Code

Changes On Branch bug-92ab429295
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-92ab429295 Excluding Merge-Ins

This is equivalent to a diff from 25ad8fff to 5ca69a34

2023-07-26
20:05
[92ab429295]: Add new subcommand [tk systray exists] to [tk systray]. Patch from Emiliano Gavilan. check-in: 1ed05a6d user: fvogel tags: trunk, main
19:23
Fix [95d2c41604]: Improvements on pure Tcl system notification window. Patch from Emiliano Gavilan. check-in: 9d7e04f0 user: fvogel tags: trunk, main
2023-07-24
20:30
merge trunk Closed-Leaf check-in: 5ca69a34 user: fvogel tags: bug-92ab429295
20:26
merge trunk (except systray.tcl and tkUnixSysnotify.c) check-in: 91d87c16 user: fvogel tags: patch-95d2c41604
20:18
Backout [8662aebe] (Improvements on pure Tcl system notification window. Patch from Emiliano Gavilan.) until we understand why it triggers errors at Github Actions. check-in: 25ad8fff user: fvogel tags: trunk, main
15:39
Merge 8.6 check-in: 2ab8ec68 user: jan.nijtmans tags: trunk, main
2023-07-23
16:15
Add documentation for [tk systray exists]. check-in: 6a840686 user: fvogel tags: bug-92ab429295
15:40
Fix [95d2c41604]: Improvements on pure Tcl system notification window. Patch from Emiliano Gavilan. check-in: 8662aebe user: fvogel tags: trunk, main

Changes to doc/systray.n.
9
10
11
12
13
14
15


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31



32
33
34
35
36
37
38
.so man.macros
.SH NAME
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 destroy\fR
.BE
.BE
.SH DESCRIPTION
.PP
The \fBtk systray create\fR command creates an icon in the platform-specific
tray. The widget is configured with a Tk image for the icon display, an
optional string for display in a tooltip, and optional callbacks that are
bound to <Button-1> and <Button-3>.
.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
option. When no option is given this command returns the list of all options and
their current value.



.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
supported; attempts to create additional icons will return an error. The
existing tray icon can be modified with different images and







>
>













|


>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.so man.macros
.SH NAME
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
.PP
The \fBtk systray create\fR command creates an icon in the platform-specific
tray. The widget is configured with a Tk image for the icon display, an
optional string for display in a tooltip, and optional callbacks that are
bound to <Button-1> and <Button-3>.
.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 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
supported; attempts to create additional icons will return an error. The
existing tray icon can be modified with different images and
Changes to library/systray.tcl.
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	    }
	    WM_RBUTTONDOWN - WM_RBUTTONDBLCLK {
		uplevel #0 [dict get $_current -button3]
	    }
	}
    }

    namespace export create configure destroy
    namespace ensemble create
}


# Pure-Tcl system notification window for use if native implementation not available.
namespace eval ::tk::sysnotify:: {








|







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
	    }
	    WM_RBUTTONDOWN - WM_RBUTTONDBLCLK {
		uplevel #0 [dict get $_current -button3]
	    }
	}
    }

    namespace export create configure destroy exists
    namespace ensemble create
}


# Pure-Tcl system notification window for use if native implementation not available.
namespace eval ::tk::sysnotify:: {

292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
	set _current $values
	return
    } 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

    if {!$_created} {







<







292
293
294
295
296
297
298

299
300
301
302
303
304
305
	set _current $values
	return
    } 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

    if {!$_created} {
318
319
320
321
322
323
324






325
326
327
328
329
330
331
	    _systray destroy
	}
    }
    set _created 0
    set _current {}
    return
}







# Check systray options
proc ::tk::systray::_check_options {argsList singleOk} {
    variable _options

    set len [llength $argsList]
    while {[llength $argsList] > 0} {







>
>
>
>
>
>







317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
	    _systray destroy
	}
    }
    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

    set len [llength $argsList]
    while {[llength $argsList] > 0} {
Changes to tests/systray.test.
188
189
190
191
192
193
194

















195
196
197
198
199
200
201
    image create bitmap cross -data $data1
} -body {
    tk systray create -image cross
} -cleanup {
    tk systray destroy
    image delete cross
} -result {}



















test sysnotify-1 {system notification popup} -setup {
    image create photo _book -data R0lGODlhDwAPAKIAAP//////AP8AAMDAwICAgAAAAAAAAAAAACwAAAAADwAPAAADSQhA2u5ksPeKABKSCaya29d4WKgERFF0l1IMQCAKatvBJ0OTdzzXI1xMB3TBZAvATtB6NSLKleXi3OBoLqrVgc0yv+DVSEUuFxIAOw==
    tk systray create -image _book -text "Systray sample"
} -body {
    tk sysnotify {Alert} {This is an alert}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    image create bitmap cross -data $data1
} -body {
    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"
} -body {
    tk sysnotify {Alert} {This is an alert}