|
2023-07-26
| ||
| 20:14 | • Closed ticket [92ab429295]: Add new subcommand tk systray exists to tk systray plus 5 other changes artifact: 3060e06038 user: fvogel | |
| 20:05 | [92ab429295]: Add new subcommand [tk systray exists] to [tk systray]. Patch from Emiliano Gavilan. check-in: 1ed05a6d09 user: fvogel tags: trunk, main | |
|
2023-07-23
| ||
| 16:22 | • Ticket [92ab429295] Add new subcommand tk systray exists to tk systray status still Open with 4 other changes artifact: 90ba6fbf77 user: fvogel | |
| 16:02 | Fix [92ab429295]: Add new subcommand [tk systray exists] to [tk systray]. Patch from Emiliano Gavilan. check-in: 6401e6d9c1 user: fvogel tags: bug-92ab429295 | |
| 07:47 | • Ticket [92ab429295] Add new subcommand tk systray exists to tk systray status still Open with 4 other changes artifact: 71f167046c user: fvogel | |
|
2023-07-22
| ||
| 21:54 | • Ticket [92ab429295]: 3 changes artifact: ef995930af user: emiliano | |
| 06:54 | • Ticket [92ab429295]: 3 changes artifact: fb0f54a397 user: fvogel | |
|
2023-07-21
| ||
| 03:57 | • Add attachment tksystrayexists.diff to ticket [92ab429295] artifact: 706ada7403 user: emiliano | |
| 03:55 | • New ticket [92ab429295] Add new subcommand tk systray exists to tk systray. artifact: 717c100f9a user: emiliano | |
| Ticket UUID: | 92ab4292952a3fa10a15f414d59a4aa9984650ad | |||
| Title: | Add new subcommand [tk systray exists] to [tk systray] | |||
| Type: | RFE | Version: | 8.7 | |
| Submitter: | emiliano | Created on: | 2023-07-21 03:55:50 | |
| Subsystem: | -- New Commands | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2023-07-26 20:14:45 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2023-07-26 20:14:45 | |||
| Description: |
This RFE proposes extending the [tk systray] ensemble to include a [tk systray exists] subcommand. The [tk systray create] subcommand can be called only once. Calling it twice resuts in an error "only one system tray icon supported per interpeter". This forces the calling code to use [catch] to either destroy a previously exist ing tktray or to create a new one. Attached patch implements a [tk systray exists] subcommand. | |||
| User Comments: |
fvogel added on 2023-07-26 20:14:45:
Now all done as proposed below. Closing. fvogel added on 2023-07-23 16:22:10: I have committed your patch as the first commit in branch bug-92ab429295. On my side I have added tests and documentation. Suggestions? Please drop them here. Normally this would require a TIP. However in this specific case we can probably consider this as a bug fix (considering the use case you brought forward). Moreover the systray command didn't yet escape in an official (non-beta) release (so the user-visible interface to Tk is not changed). Finally I'm sure the vote for TIP #325 would have been the same with this small addition. I'll merge in a day or two, and add a post-vote note to TIP #325. If anyone has objections, please speak up now. fvogel added on 2023-07-23 07:47:24: Understood. I'll commit this soon and add a post-vote note to mention it to the adequate TIP that had introduced the systray command. Should be enough I think. emiliano added on 2023-07-22 21:54:05: I don't think unconditionally destroying any existing systray icon is a good idea.
The use case scenario I have in mind is:
* if there's no systray created, create one and proceed.
* if it was already created, instrospect its config (for example, whether button3 popups a menu), peraphs extending the menu.
Destroying any previously existing systray prevents this.
Nowadays the only viable approaches are:
* [catch {tk systray destroy}] if I want a clean slate.
* [if {[catch {tk systray create -image $img}]} {# systray already exists} else {...}] if I want to reuse the already existing one (or create it otherwise)
fvogel added on 2023-07-22 06:54:21: Why not. Another possibility would be [tk systray create] to automatically destroy any previously existing systray icon:
Index: library/systray.tcl
==================================================================
--- library/systray.tcl
+++ library/systray.tcl
@@ -202,11 +202,11 @@
variable _options
variable _current
variable _ico
if {$_created} {
- return -code error -errorcode {TK SYSTRAY CREATE} "only one system tray icon supported per interpeter"
+ ::tk::systray::destroy
}
_check_options $args 0
if {![dict exists $args -image]} {
return -code error -errorcode {TK SYSTRAY CREATE} "missing required option \"-image\""
}
And update the man page which says "attempts to create additional icons will return an error". Plus add one or two tests about this. What do you think? | |||
Attachments:
- tksystrayexists.diff [download] added by emiliano on 2023-07-21 03:57:11. [details]