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
|
#
#
#
#
proc icon:update_connect_label {label active disabled} {
global PPxPStatus
if {$PPxPStatus >= 4} {
$label configure -foreground $active
} else {
$label configure -foreground $disabled
}
}
proc icon:time {frame} {
label $frame -textvariable icon_connect_time
PPxP:UpdateInfoWidget $frame connect \
{set icon_connect_time [PPxP:ConnectTime]}
set active [option get $frame activeForeground {}]
set disabled [option get $frame disabledForeground {}]
PPxP:UpdateStatusWidget $frame \
[list icon:update_connect_label $frame $active $disabled]
return $frame
}
proc icon:ind {frame} {
global TKPPXPDIR IMAGEDIR
set in_image [image create bitmap \
-file [file join $IMAGEDIR in6x6.xbm] -foreground blue]
set out_image [image create bitmap \
-file [file join $IMAGEDIR out6x6.xbm] -foreground blue]
Indicator $frame $in_image $out_image 1
$in_image configure -foreground \
[option get $frame.inLabel foreground Foreground]
$out_image configure -foreground \
[option get $frame.outLabel foreground Foreground]
return $frame
}
set icon_idle_blink 0
proc icon:update_status_panel {blink_call} {
global PPxPStatus PPxPInfo icon_status_label_list
global icon_idle_blink
if [catch {
set idle $PPxPInfo(idle)
set mode $PPxPInfo(mode)
}] {
foreach i $icon_status_label_list {
[lindex $i 0] configure -foreground [lindex $i 3]
}
return
}
if {[PPxP:OnLine] && $idle <= 60 && $idle > 0} {
if {!($icon_idle_blink % 2)} {
set fg 5
} else {
set fg 3
}
foreach i $icon_status_label_list {
[lindex $i 0] configure -foreground [lindex $i $fg]
}
if {$idle <= 10} {
if !$blink_call {
set icon_idle_blink 0
} else {
incr icon_idle_blink
}
if {$icon_idle_blink < 3} {
after 250 icon:update_status_panel 1
}
} elseif {$idle <= 20} {
if !$blink_call {
set icon_idle_blink 0
after 500 icon:update_status_panel 1
} else {
set icon_idle_blink 1
}
} elseif {$idle <= 30} {
set icon_idle_blink [expr !$icon_idle_blink]
}
return
}
set icon_idle_blink 0
foreach i $icon_status_label_list {
if {$PPxPStatus >= [lindex $i 1]} {
set fg 2
} elseif {$mode == "auto"} {
set fg 4
} else {
set fg 3
}
[lindex $i 0] configure -foreground [lindex $i $fg]
}
}
proc icon:stat {frame} {
global icon_status_label_list
set f [frame $frame]
set status_level 1
foreach i {dialLabel chatLabel authLabel networkLabel} {
label $f.$i
set active [option get $f.$i activeColor {}]
set disabled [option get $f.$i disabledColor {}]
set auto [option get $f.$i autoColor {}]
set idle [option get $f.$i idleColor {}]
lappend icon_status_label_list \
[list $f.$i $status_level $active $disabled $auto $idle]
pack $f.$i -side left -fill x -expand yes
incr status_level
}
PPxP:UpdateStatusWidget $f {icon:update_status_panel 0}
PPxP:UpdateInfoWidget $f idle {icon:update_status_panel 0}
PPxP:UpdateInfoWidget $f mode {icon:update_status_panel 0}
return $f
}
proc icon:update_auto_menu {menu index} {
global PPxPInfo
if {$PPxPInfo(mode) == "auto"} {
set label "Auto OFF"
set cmd {$PPxP auto off}
} else {
set label "Auto ON"
set cmd {$PPxP auto on}
}
$menu entryconfigure $index -under 0 -label $label -command $cmd
}
proc icon:update_connect_menu {menu index} {
global PPxPStatus
if {$PPxPStatus > 0} {
set label "Disconnect"
set cmd {$PPxP disconnect}
} else {
set label "Connect"
set cmd {$PPxP connect}
}
$menu entryconfigure $index -under 0 -label $label -command $cmd
}
proc icon:select_load_conf {window} {
global PPxP
set file [Conf:SelectDialog $window.select conf]
if {$file != ""} {
$PPxP source $file
$PPxP env
}
}
proc icon:create_standard_popup {popup} {
Popup $popup
$popup add command -under 0 -label "Auto ON" \
-command {$PPxP auto on}
$popup add command -under 0 -label "Connect" \
-command {$PPxP connect}
$popup add command -under 0 -label "Load..." \
-command [list icon:select_load_conf [winfo parent $popup]]
$popup add command -under 0 -label "Bye" \
-command {Toplevel:Close .}
$popup add command -under 0 -label "Quit" \
-command {Toplevel:Quit .}
PPxP:UpdateInfoWidget [winfo parent $popup] mode \
[list icon:update_auto_menu $popup 0]
PPxP:UpdateStatusWidget [winfo parent $popup] \
[list icon:update_connect_menu $popup 1]
}
proc icon:toggle_main_window {} {
global icon_manage_window
if {[wm state $icon_manage_window] == "normal"} {
wm withdraw $icon_manage_window
} else {
wm deiconify $icon_manage_window
}
}
proc icon:bind_main_window_state {popup index} {
global icon_manage_window
bind $icon_manage_window <Map> \
[list icon:update_panel_menu $popup $index]
bind $icon_manage_window <Unmap> \
[list icon:update_panel_menu $popup $index]
}
proc icon:unbind_main_window_state {} {
global icon_manage_window
bind $icon_manage_window <Map> {}
bind $icon_manage_window <UnMap> {}
}
set icon_panel_menu_updating 0
proc icon:update_panel_menu {popup index} {
global icon_panel_menu_updating
if $icon_panel_menu_updating {
return
}
set icon_panel_menu_updating 1
icon:unbind_main_window_state
update
after idle icon:update_panel_menu_idle $popup $index
}
proc icon:update_panel_menu_idle {popup index} {
global icon_manage_window
set state [wm state $icon_manage_window]
if {$state == "normal"} {
set label "Hide Panel"
} else {
set label "Show Panel"
}
$popup entryconfigure $index -underline 5 -label $label
icon:bind_main_window_state $popup $index
global icon_panel_menu_updating
set icon_panel_menu_updating 0
}
proc icon:add_panel_menu {popup} {
$popup add separator
$popup add command -under 5 -label "Show Panel" \
-command icon:toggle_main_window
set index [$popup index "Show Panel"]
icon:bind_main_window_state $popup $index
}
proc icon:bindtags_all {w} {
bindtags $w {IconButton all}
set children [winfo children $w]
foreach c $children {
icon:bindtags_all $c
}
}
proc icon:start_window {w args} {
set toplevel [winfo toplevel $w]
set width [option get $w width {}]
set height [option get $w height {}]
if {$width == ""} {set width 48}
if {$height == ""} {set height 48}
wm geometry $toplevel ${width}x${height}
wm resizable $toplevel false false
set time [icon:time $w.timePanel]
set ind [icon:ind $w.indicatorPanel]
set stat [icon:stat $w.statusPanel]
icon:bindtags_all $w
icon:create_standard_popup $w.popup
icon:add_panel_menu $w.popup
bind IconButton <Button-1> icon:toggle_main_window
bind IconButton <Button-3> [list Popup:Post $w.popup %X %Y]
if {[info commands Cmd:CreateMenu] != ""} {
Popup $w.commandPopup
Cmd:CreateMenu $w.commandPopup
bind IconButton <Button-2> [list Popup:Post $w.commandPopup %X %Y]
}
pack $w.timePanel -side top
pack $w.indicatorPanel -side top -fill x
pack $w.statusPanel -side bottom -fill x
}
proc Icon:Start {main_flag manage_window} {
global icon_manage_window
set icon_manage_window $manage_window
Toplevel:Start .tkppxpIcon TkppxpIcon "tkPPxP" $main_flag \
icon:start_window {}
}
|