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 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
|
# $Id: taskbar.tcl,v 1.11 2004/06/10 20:44:10 aleksey Exp $
if {![cequal $::interface tk]} return
namespace eval taskbar {
variable saved_state
variable balloon ""
# variable state ""
variable tray ""
variable icon ""
variable pos 0
variable s2p
array set s2p [list blank 0 \
available 1 \
away 2 \
chat 3 \
dnd 4 \
xa 5 \
unavailable 6 \
invisible 7 \
browser 8 \
group 9 \
browser32 10 \
group32 11 \
available32 12]
variable mouse
array set mouse [list 1down 0 \
3down 0 \
menu ""]
variable options
custom::defvar options(winico_blinks) 0 \
[::msgcat::mc "When you have unread messages the taskbar icon will start to blink."] \
-group IFace -type boolean
}
proc taskbar::load {} {
global curuserstatus
variable tray
variable icon
variable pos
variable s2p
variable mouse
variable saved_state [wm state .]
if {[catch { package require Winico }]} {
return
}
set icon [winico createfrom [pixmap docking tkabber.ico]]
winico taskbar add $icon -pos [set pos $s2p(unavailable)] \
-text [balloon_text] \
-callback "[namespace current]::callback %m %i %X %Y"
winico setwindow . $icon small $s2p(unavailable)
winico setwindow . $icon big $s2p(available32)
set m [set mouse(menu) .tray]
menu $m -tearoff $ifacetk::options(show_tearoffs) \
-postcommand "[namespace current]::post $m"
$m add command -label [::msgcat::mc "About"] \
-command ::ifacetk::about_window
$m add separator
$m add cascade -label [::msgcat::mc "Presence"] \
-menu [menu [set pm $m.presence] \
-tearoff $ifacetk::options(show_tearoffs)]
if {$ifacetk::options(show_tearoffs)} {
set i 1
} else {
set i 0
}
for {} {$i <= [[set p .presence.button.menu] index end]} {incr i} {
$pm add command -label [lindex [$p entryconfigure $i -label] 4] \
-command [lindex [$p entryconfigure $i -command] 4]
}
$m add command -label [::msgcat::mc "Log in..."] -command ifacetk::login_dialog
$m add command -label [::msgcat::mc "Log out"] -command logout
$m add command -label [::msgcat::mc "Log out with reason..."] -command show_logout_dialog
$m add separator
$m add command -label [::msgcat::mc "Hide Main Window"] -command "set [namespace current]::saved_state \[wm state .\]
wm state . withdrawn"
$m add command -label [::msgcat::mc "Show Main Window"] -command "wm state . \$[namespace current]::saved_state
wm deiconify ."
$m add separator
$m add command -label [::msgcat::mc "Quit"] -command quit
set tray ""
foreach var [list curuserstatus tabcolors] {
trace variable ::$var w [namespace current]::update
}
foreach p [list set_status clear_status] {
rename ::$p ::${p}_aux
rename [namespace current]::$p ::$p
}
bind Toplevel <Map> [list [namespace current]::win_icon_setup %W Toplevel]
foreach tag [list Chat JBrowser JDisco] {
bind $tag <Map> [list [namespace current]::win_icon_setup %W $tag]
}
hook::add quit_hook [namespace current]::quit
}
hook::add finload_hook [namespace current]::taskbar::load
proc taskbar::win_icon_setup {w tag} {
global usetabbar
variable icon
variable s2p
if {[winfo toplevel $w] != $w} {
return
}
switch -- $tag {
Chat {
set small group
set big group32
}
JBrowser -
JDisco {
set small browser
set big browser32
}
default {
set small available
set big available32
}
}
winico setwindow $w $icon small $s2p($small)
winico setwindow $w $icon big $s2p($big)
}
proc taskbar::quit {} {
variable icon
if {![cequal $icon ""]} {
winico taskbar delete $icon
}
}
proc taskbar::callback {event unused x y} {
variable saved_state
variable icon
variable pos
variable s2p
variable mouse
switch -- $event {
WM_MOUSEMOVE -
default {
set mouse(1down) 0
set mouse(3down) 0
#winico taskbar modify $icon -pos $pos -text [balloon_text]
}
WM_LBUTTONDOWN {
set mouse(1down) 1
}
WM_RBUTTONDOWN {
set mouse(3down) 1
}
WM_LBUTTONUP {
if {$mouse(1down)} {
switch -- [wm state .] {
zoomed -
normal {
set saved_state [wm state .]
wm state . withdrawn
}
default {
wm state . $saved_state
wm deiconify .
}
}
}
set mouse(1down) 0
}
WM_RBUTTONUP {
if {$mouse(3down)} {
tk_popup $mouse(menu) $x $y
}
set mouse(3down) 0
}
}
}
proc taskbar::balloon_text {} {
global userstatusdesc textstatus
if {![cequal $textstatus ""]} {
return $textstatus
}
return $userstatusdesc
}
proc taskbar::post {m} {
global curuserstatus
switch -- [wm state .] {
zoomed -
normal {
set state1 disabled
set state2 normal
}
default {
set state1 normal
set state2 disabled
}
}
if {$curuserstatus == "unavailable"} {
set state0 disabled
} else {
set state0 normal
}
$m entryconfigure [$m index [::msgcat::mc "Presence"]] -state $state0
$m entryconfigure [$m index [::msgcat::mc "Show Main Window"]] -state $state1
$m entryconfigure [$m index [::msgcat::mc "Hide Main Window"]] -state $state2
}
proc taskbar::update {name1 {name2 ""} {op ""}} {
global curuserstatus tabcolors
variable tray
variable icon
variable pos
variable s2p
switch -- [string trimleft $name1 :] {
curuserstatus {
if {[cequal $tray ""]} {
winico taskbar modify $icon \
-pos [set pos $s2p($curuserstatus)] \
-text [balloon_text]
winico setwindow . $icon small $s2p($curuserstatus)
}
}
tabcolors {
toggle 0 1
}
}
}
proc taskbar::toggle {ff {firstP 0}} {
global curuserstatus tabcolors
# variable state
variable tray
variable icon
variable pos
variable s2p
if {![cequal $tray ""]} {
after cancel $tray
set tray ""
}
set hitP 0
foreach {k v} [array get tabcolors] {
if {![winfo exists .nb.f$k]} {
continue
}
if {(![cequal $v ""]) && ($v > 0)} {
set hitP 1
break
}
}
if {!$hitP} {
#set state [wm state .]
update ::curuserstatus
return
}
# set state [wm state .]
# if {$firstP} {
# set state $state
# } elseif {(![cequal $state normal]) \
# && ([cequal $state normal])} {
# update ::curuserstatus
# return
# }
if {$ff} {
set pos $s2p($curuserstatus)
} else {
set pos $s2p(blank)
}
winico taskbar modify $icon -pos $pos -text [balloon_text]
variable options
if {$options(winico_blinks)} {
# make the taskbar icon blink
set tray \
[after 500 [list [namespace current]::toggle [expr ($ff+1)%2]]]
} else {
# change the taskbar icon to 'invisible'
winico taskbar modify $icon -pos [set pos $s2p(invisible)]
}
}
proc taskbar::set_status {text} \
"[namespace current]::taskbar::set_status_aux \$text"
proc taskbar::set_status_aux {text} {
variable balloon
switch -- [wm state .] {
zoomed -
normal {
::set_status_aux $text
}
default {
if {![cequal $balloon ""]} {
after cancel $balloon
}
balloon::set_text $text
balloon::show [winfo rootx .tray] [winfo rooty .tray]
set balloon [after 15000 balloon::destroy]
}
}
}
proc taskbar::clear_status {} \
"[namespace current]::taskbar::clear_status_aux"
proc taskbar::clear_status_aux {} {
variable balloon
if {![cequal $balloon ""]} {
after cancel $balloon
}
::clear_status_aux
balloon::destroy
}
|