-
Notifications
You must be signed in to change notification settings - Fork 5
/
windows_info.tcl
59 lines (58 loc) · 1.56 KB
/
windows_info.tcl
1
2
3
4
5
6
7
8
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
# $Id$
#
# Maintains the list of windows, and caches window class information.
# (the list is shared between windows_list and menus_list.)
#
object_class windows_info {
member windows {}
method clear {} {
foreach w $slot(windows) {
if [info exists slot($w.class)] {
unset slot($w.class)
}
}
set slot(windows) {}
}
method get_windows {} { return $slot(windows) }
method append_windows {target result_var parent} {
upvar $result_var result
set cmd "if {\[::info command ::winfo\] != {}} {\n\
::winfo children $parent\n\
}"
foreach w [send $target $cmd] {
lappend slot(windows) $w
$self append_windows $target result $w
}
}
method update {target} {
$self clear
set cmd [list if {[::info command winfo] != {}} {::winfo children .}]
if {[catch {set slot(windows) [send $target $cmd]}]} {
set slot(windows) {}
}
feedback .feedback -title "Getting Windows" \
-steps [llength $slot(windows)]
.feedback grab
foreach w $slot(windows) {
$self append_windows $target windows $w
.feedback step
update idletasks
}
destroy .feedback
}
method get_class {target w} {
if ![info exists slot($w.class)] {
if ![send $target [list winfo exists $w]] {
# the window no longer exists, so delete it from our list
set ndx [lsearch -exact $slot(windows) $w]
if {$ndx >= 0} {
set slot(windows) [lreplace $slot(windows) $ndx $ndx]
}
return ""
}
set slot($w.class) [send $target [list winfo class $w]]
}
return $slot($w.class)
}
}