/usr/share/xcrysden/Tcl/unmapWin.tcl is in xcrysden-data 1.5.53-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #############################################################################
# Author: #
# ------ #
# Anton Kokalj Email: Tone.Kokalj@ijs.si #
# Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 #
# Jozef Stefan Institute Fax: x 386 1 477 3811 #
# Jamova 39, SI-1000 Ljubljana #
# SLOVENIA #
# #
# Source: $XCRYSDEN_TOPDIR/Tcl/unmapWin.tcl
# ------ #
# Copyright (c) 1996-2003 by Anton Kokalj #
#############################################################################
#
# If one wants to hide toplevel with "Hide", then Toplevel must be
# registered with the following command
#
proc xcRegisterUnmapWindow {w bframe what {args {}}} {
global unmapWin
# w ........ unmap toplevel to register
# bframe ... button's frame, i.e. which frame will hold the button
# what ..... some kind of identifier
set image {}
set bitmap {}
set text {}
set textimage {}
set i 0
foreach option $args {
incr i
if { $i%2 } {
set tag $option
} else {
switch -- $tag {
"-image" {set image $option}
"-bitmap" {set bitmap $option}
"-text" {set text $option}
"-textimage" {set textimage $option}
default { tk_dialog .mb_error Error \
"ERROR: Bad xRegisterUnmapWindow's button configure option $tag" \
error 0 OK
return }
}
}
}
if { $i%2 } {
tk_dialog .mb_error1 Error "ERROR: You called xcMenuEntry with an odd number of args !" \
error 0 OK
return 0
}
lappend unmapWin($bframe,registered) $w
if ![info exists unmapWin($bframe,column)] {
set unmapWin($bframe,column) 0
set unmapWin($bframe,count) 0
} else {
incr unmapWin($bframe,column)
incr unmapWin($bframe,count)
}
if { $textimage == {} } {
set unmapWin(but,$w,$what) \
[button $bframe.unmap$unmapWin($bframe,count) -bd 1 \
-text $text -bitmap $bitmap -image $image \
-highlightthickness 0 \
-command [list xcUnmapWindow map $w $w $bframe $what]]
} else {
set text [lindex $textimage 0]
set image [lindex $textimage 1]
set unmapWin(but,$w,$what) \
[xcHideButton $bframe.unmap$unmapWin($bframe,count) \
$image right -text $text \
-command [list xcUnmapWindow map $w $w $bframe $what]]
}
set unmapWin($w,$what,column) $unmapWin($bframe,column)
# this should be changed:
set unmapWin($w,$what,row) 0
}
#
# the "Hide" toplevel window must be have special <Map> <Unmap> bindings;
# here is the procedure for bindings
#
proc xcUnmapWindow {event type w bframe what} {
global unmapWin
# event ..... what event (map/unmap)
# type, w ... to check if event was triggered by toplevel window
# bframe .... button's frame, i.e. which frame will hold the button
# what .... some kind of identifier
if { $type != $w } {
# event wasn't triggered by toplevel window
return
}
#xcDebug "Event:: $event $type"
#
# check if $w was registered
#
if ![info exists unmapWin($bframe,registered)] {
return
}
set registered 0
foreach win $unmapWin($bframe,registered) {
if { $win == $w } {
set registered 1
break
}
}
if !$registered {
return
}
if { $event == "unmap" } {
#xcDebug "Action: unmap"
if ![winfo ismapped $bframe] {
eval pack $bframe $unmapWin(packinfo,$bframe)
} elseif ![info exists unmapWin(packinfo,$bframe)] {
set unmapWin(packinfo,$bframe) [pack info $bframe]
}
grid configure $unmapWin(but,$w,$what) \
-column $unmapWin($w,$what,column) -row $unmapWin($w,$what,row)
} elseif { $event == "map" } {
#xcDebug "Action: map"
grid forget $unmapWin(but,$w,$what)
xcDebug "HowManyUnmapWin:::: [HowManyUnmapWin $bframe]; bframe=$bframe"
if { [HowManyUnmapWin $bframe] == 0 } {
pack forget $bframe
}
wm deiconify $w
}
}
#
# this is command that the "Hide" button calls
#
proc HideWin {t what} {
global unmapWin
wm withdraw $t
xcUnmapWindow unmap $t $t $unmapWin(frame,main) $what
}
#------------------------------------------------------------------------------
# from here on are procedures needed for Hide technology
#
proc HowManyUnmapWin bframe {
global unmapWin
set count 0
foreach elem [array names unmapWin but,*] {
if [winfo ismapped $unmapWin($elem)] { incr count }
}
return $count
}
proc UnmapCleanAll {} {
global unmapWin
foreach elem [array names unmapWin but,*] {
xcDebug "unmapWin Button::: $elem"
if [winfo exists $unmapWin($elem)] {
destroy $unmapWin($elem)
}
}
# unset all unmapWin elements, but the bframes and packinfo,*
foreach pattern {
*,registered
but,*
*,column
*,row
*,count
} {
foreach elem [array names unmapWin $pattern] {
unset unmapWin($elem)
}
}
}
|