/usr/share/amsn/plugins/chameleon/combobox.tcl is in amsn-data 0.98.9-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 182 183 184 185 186 187 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 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | namespace eval ::chameleon::combobox {
proc combobox_customParseConfArgs {w parsed_options args } {
variable combobox_commands
variable combobox_commandstates
variable combobox_editable
variable combobox_state
array set options $args
array set ttk_options $parsed_options
if { [info exists options(-editable)] } {
set combobox_editable($w) $options(-editable)
}
if { [info exists options(-state)] } {
set combobox_state($w) $options(-state)
}
if { [info exists combobox_editable($w)] } {
if { [info exists combobox_state($w)] } {
if {[set combobox_editable($w)]} {
set ttk_options(-state) [set combobox_state($w)]
} else {
if { [set combobox_state($w)] eq "normal" } {
set ttk_options(-state) readonly
} else {
set ttk_options(-state) disabled
}
}
} else {
if {![set combobox_editable($w)]} {
set ttk_options(-state) readonly
}
}
}
if { [info exists options(-state)] } {
if {[set options(-state)] eq "disabled"} {
set ttk_options(-state) "disabled"
} else {
if { ([info exists options(-editable)] &&
!$options(-editable)) ||
(![catch {$w cget -state} res] && $res eq "readonly") } {
set ttk_options(-state) "readonly"
} else {
set ttk_options(-state) "normal"
}
}
}
if { [info exists options(-command)] } {
set combobox_commands($w) $options(-command)
}
if { [info exists options(-commandstate)] } {
if {$options(-commandstate) ne "normal" && $options(-commandstate) ne "disabled"} {
set message "bad state value \"$options(-commandstate)\";"
append message " must be normal or disabled"
error $message
}
set combobox_commandstates($w) $options(-commandstate)
}
if { [info exists options(-value)] } {
catch { $w set $options(-value)}
}
return [array get ttk_options]
}
proc init_comboboxCustomOptions { } {
variable combobox_widgetCommands
variable combobox_widgetOptions
array set combobox_widgetOptions {
-background -styleOption
-bd -borderwidth
-bg -styleOption
-borderwidth -styleOption
-buttonbackground -styleOption
-command -toImplement
-commandstate -toImplement
-cursor -cursor
-disabledbackground -ignore
-disabledforeground -ignore
-dropdownwidth -ignore
-editable -toImplement
-elementborderwidth -ignore
-exportselection -exportselection
-fg -styleOption
-font -styleOption
-foreground -styleOption
-height -ignore
-highlightbackground -ignore
-highlightcolor -ignore
-highlightthickness -ignore
-image -ignore
-listvar -values
-maxheight -ignore
-opencommand -postcommand
-postcommand -postcommand
-relief -styleOption
-selectbackground -ignore
-selectborderwidth -ignore
-selectforeground -ignore
-state -toImplement
-takefocus -takefocus
-textvariable -textvariable
-value -value
-values -values
-width -width
-xscrollcommand -ignore
}
array set combobox_widgetCommands {
bbox {1 {$w bbox}}
close {2 {combobox_close $w}}
current {4 {$w current}}
curselection {4 {combobox_curselection $w}}
delete {1 {$w delete}}
get {1 {$w get}}
icursor {2 {$w icursor}}
identify {2 {$w identify}}
index {3 {$w index}}
insert {3 {$w insert}}
list {1 {combobox_list $w}}
open {1 {combobox_open $w}}
scan {2 {combobox_scan $w}}
select {5 {combobox_select $w}}
selection {6 {$w selection}}
set {3 {$w set}}
subwidget {2 {combobox_subwidget $w}}
toggle {1 {combobox_toggle $w}}
xview {1 {$w xview}}
}
::chameleon::addBinding <<WidgetCreated>> {::chameleon::combobox::combobox_widgetCreated}
::chameleon::addBinding <<WidgetDestroyed>> {::chameleon::combobox::combobox_widgetDestroyed}
}
proc combobox_customCget { w option } {
variable combobox_commands
variable combobox_commandstates
variable combobox_editable
variable combobox_state
if { $option eq "-editable" } {
if { [info exists combobox_editable($w)] } {
return [set combobox_editable($w)]
} else {
return 1
}
}
if { $option eq "-state" } {
if { [info exists combobox_state($w)] } {
return [set combobox_state($w)]
} else {
return "normal"
}
}
if { $option eq "-command" } {
if { [info exists combobox_commands($w)] } {
return [set combobox_commands($w)]
}
}
if { $option eq "-commandstate" } {
if { [info exists combobox_commandstates($w)] } {
return [set combobox_commandstates($w)]
}
}
if { $option eq "-value" } {
return [$w get]
}
return ""
}
proc combobox_widgetCreated { } {
set cb [::chameleon::getLastCreatedWidget ]
if {[string first "::chameleon::combobox::combobox" $cb] == 0 } {
#puts "combobx $cb is created"
bind $cb <<ComboboxSelected>> "::chameleon::combobox::combobox_selected $cb"
bind [::chameleon::getWidgetPath $cb] <<ComboboxSelected>> "::chameleon::combobox::combobox_selected $cb"
}
}
proc combobox_selected {w args} {
variable combobox_commands
variable combobox_commandstates
if { [info exists combobox_commands($w)] && $combobox_commands($w) ne ""} {
if {![info exists combobox_commandstates($w)] ||
([info exists combobox_commandstates($w)] &&
[set combobox_commandstates($w)] eq "normal")} {
eval [set combobox_commands($w)] [list [::chameleon::getWidgetPath $w]] [list [$w get]]
}
}
}
proc combobox_widgetDestroyed { } {
variable combobox_commands
variable combobox_commandstates
set cb [::chameleon::getLastDestroyedWidget ]
if {[string first "::chameleon::combobox::combobox" $cb] == 0 } {
#puts "Combobox $cb is destroyed"
array unset combobox_commands [::chameleon::getWidgetPath $cb]
array unset combobox_commandstates [::chameleon::getWidgetPath $cb]
}
}
proc combobox_select {w args} {
set values [$w cget -values]
if {[llength $args] == 1} {
if {[string is integer $args] && $args < [llength $values]} {
$w current $args
combobox_selected $w
}
} else {
error "Usage [::chameleon::getWidgetPath $w] select index"
}
}
proc combobox_curselection {w} {
set ret [$w current]
if {$ret == -1} {
return ""
} else {
return $ret
}
}
proc combobox_list {w command args} {
set values [$w cget -values]
switch -- $command {
delete {
if {[llength $args] == 1} {
set first [lindex $args 0]
set last $first
} else {
set first [lindex $args 0]
set last [lindex $args 1]
}
set values [lreplace $values $first $last]
$w configure -values $values
}
get {
if {[llength $args] == 1} {
return [eval lindex [list $values] $args]
} else {
return [eval lrange [list $values] $args]
}
}
index {
return [eval [list $w] index $args]
}
insert {
if {[llength $args] < 1} {
error "Usage : [::chameleon::getWidgetPath $w] list insert index ?element element ... ?"
} elseif {[llength $args] >= 2} {
set values [eval linsert [list $values] $args]
$w configure -values $values
}
}
size {
return [llength $values]
}
}
}
proc combobox_open {w} {
# TODO implement in some way...
}
proc combobox_close {w} {
# TODO implement in some way...
}
proc combobox_toggle {w} {
# TODO not quite right..
if {[winfo ismapped $w]} {
return [combobox_close $w]
} else {
return [combobox_open $w]
}
}
proc combobox_subwidget {w args} {
return ""
}
proc combobox_scan {w args} {
# TODO to implement in the same way as 'entry'.. although probably not necessary..
}
}
|