📄 alarm.tcl
字号:
########################################################## alarm.tcl v 1.0 2002/07/21 BurgerMan##########################################################::Alarms namespace. Everything related to alarms (alerts)namespace eval ::alarms { #Returns 1 if the user has an alarm enabled proc isEnabled { user } { return [getAlarmItem $user enabled] } #Set an alarm configuration item for the given user proc setAlarmItem { user item value} { #We convert the stored data (a list) into an array array set alarms [::abook::getContactData $user alarms] set alarms($item) $value ::abook::setContactData $user alarms [array get alarms] } #Return an alarm configuration item for the given user proc getAlarmItem { user item } { #We convert the stored data (a list) into an array array set alarms [::abook::getContactData $user alarms] if { [info exists alarms($item)] } { return $alarms($item) } else { return "" } } proc messageFailed {user msg} { set newmsg [::alarms::getAlarmItem $user msg] status_log "Alarm msg delivery failed! Reenabling\n" blue #Check if the user didn't change any settings if { $msg != $newmsg } { status_log "Alarm msg changd before reenabling." blue return } ::alarms::setAlarmItem $user msg_st 1 } proc InitMyAlarms {user} { global my_alarms set my_alarms(${user}_enabled) [getAlarmItem $user enabled] set my_alarms(${user}_sound) [getAlarmItem $user sound] if { $my_alarms(${user}_sound) == "" } { set my_alarms(${user}_sound) [::skin::GetSkinFile sounds alarm.wav] } set my_alarms(${user}_sound_st) [getAlarmItem $user sound_st] set my_alarms(${user}_pic) [getAlarmItem $user pic] if { $my_alarms(${user}_pic) == "" } { set my_alarms(${user}_pic) [::skin::GetSkinFile pixmaps alarm.gif] } set my_alarms(${user}_pic_st) [getAlarmItem $user pic_st] set my_alarms(${user}_msg) [getAlarmItem $user msg] set my_alarms(${user}_msg_st) [getAlarmItem $user msg_st] set my_alarms(${user}_loop) [getAlarmItem $user loop] set my_alarms(${user}_onconnect) [getAlarmItem $user onconnect] set my_alarms(${user}_onmsg) [getAlarmItem $user onmsg] set my_alarms(${user}_onstatus) [getAlarmItem $user onstatus] set my_alarms(${user}_ondisconnect) [getAlarmItem $user ondisconnect] set my_alarms(${user}_command) [getAlarmItem $user command] set my_alarms(${user}_oncommand) [getAlarmItem $user oncommand] set my_alarms(${user}_copied_pic) [getAlarmItem $user copied_pic] } #Function that displays the Alarm configuration for the given user proc configDialog { user {window ""} } { global my_alarms #Create window if not "embedded" mode if { $window == "" } { set w ".alarm_cfg_[::md5::md5 $user]" if { [ winfo exists $w ] } { catch { raise $w } catch { focus -force $w } return } toplevel $w wm title $w "[trans alarmpref] $user" wm iconname $w [trans alarmpref] } else { set w $window } InitMyAlarms $user #If window mode, set a title if { $window == "" } { label $w.title -text "[trans alarmpref]: $user" -font bboldf pack $w.title -side top -padx 15 -pady 15 } checkbutton $w.alarm -text "[trans alarmstatus]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_enabled) -font splainf Separator $w.sep1 -orient horizontal checkbutton $w.alarmonconnect -text "[trans alarmonconnect]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_onconnect) -font splainf checkbutton $w.alarmonmsg -text "[trans alarmonmsg]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_onmsg) -font splainf checkbutton $w.alarmonstatus -text "[trans alarmonstatus]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_onstatus) -font splainf checkbutton $w.alarmondisconnect -text "[trans alarmondisconnect]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_ondisconnect) -font splainf Separator $w.sep2 -orient horizontal pack $w.alarm -side top -anchor w -expand true -padx 30 pack $w.sep1 -side top -anchor w -expand true -fill x -padx 5 -pady 5 pack $w.alarmonconnect -side top -anchor w -expand true -padx 30 pack $w.alarmonmsg -side top -anchor w -expand true -padx 30 pack $w.alarmonstatus -side top -anchor w -expand true -padx 30 pack $w.alarmondisconnect -side top -anchor w -expand true -padx 30 pack $w.sep2 -side top -anchor w -expand true -fill x -padx 5 -pady 5 frame $w.sound1 LabelEntry $w.sound1.entry "[trans soundfile]" my_alarms(${user}_sound) 30 button $w.sound1.browse -text [trans browse] -command [list chooseFileDialog "" "" $w $w.sound1.entry.ent] pack $w.sound1.entry -side left -expand true -fill x pack $w.sound1.browse -side left pack $w.sound1 -side top -padx 10 -pady 2 -anchor w -fill x checkbutton $w.button -text "[trans soundstatus]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_sound_st) -font splainf checkbutton $w.button2 -text "[trans soundloop]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_loop) -font splainf Separator $w.sepsound -orient horizontal pack $w.button -side top -anchor w -expand true -padx 30 pack $w.button2 -side top -anchor w -expand true -padx 30 pack $w.sepsound -side top -anchor w -expand true -fill x -padx 5 -pady 5 frame $w.command1 LabelEntry $w.command1.entry "[trans command]" my_alarms(${user}_command) 30 menubutton $w.command1.help -font sboldf -text "<-" -menu $w.command1.help.menu menu $w.command1.help.menu -tearoff 0 $w.command1.help.menu add command -label [trans nick] -command "$w.command1.entry.ent insert insert \\\$nick" $w.command1.help.menu add command -label [trans email] -command "$w.command1.entry.ent insert insert \\\$user" $w.command1.help.menu add command -label [trans msg] -command "$w.command1.entry.ent insert insert \\\$msg" $w.command1.help.menu add separator $w.command1.help.menu add command -label [trans delete] -command "$w.command1.entry.ent delete 0 end" pack $w.command1.entry -side left -expand true -fill x pack $w.command1.help -side left pack $w.command1 -side top -padx 10 -pady 2 -anchor w -fill x checkbutton $w.buttoncomm -text "[trans commandstatus]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_oncommand) -font splainf Separator $w.sepcommand -orient horizontal pack $w.buttoncomm -side top -anchor w -expand true -padx 30 pack $w.sepcommand -side top -anchor w -expand true -fill x -padx 5 -pady 5 frame $w.pic1 LabelEntry $w.pic1.entry "[trans picfile]" my_alarms(${user}_pic) 30 button $w.pic1.browse -text [trans browse] -command [list chooseFileDialog "" "" $w $w.pic1.entry.ent] pack $w.pic1.entry -side left -expand true -fill x pack $w.pic1.browse -side left pack $w.pic1 -side top -padx 10 -pady 2 -anchor w -fill x checkbutton $w.buttonpic -text "[trans picstatus]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_pic_st) -font splainf pack $w.buttonpic -side top -anchor w -expand true -padx 30 Separator $w.seppic -orient horizontal pack $w.seppic -side top -anchor w -expand true -fill x -padx 5 -pady 5 frame $w.msg LabelEntry $w.msg.entry "[trans msg]" my_alarms(${user}_msg) 30 pack $w.msg.entry -side left -expand true -fill x pack $w.msg -side top -padx 10 -pady 2 -anchor w -fill x checkbutton $w.buttonmsg -text "[trans sendmsg]" -onvalue 1 -offvalue 0 -variable my_alarms(${user}_msg_st) -font splainf pack $w.buttonmsg -side top -anchor w -expand true -padx 30 if { $window == "" } { #Window mode frame $w.b -class Degt button $w.b.save -text [trans ok] -command [list ::alarms::OkPressed $user $w] button $w.b.cancel -text [trans close] -command "destroy $w; unset my_alarms" button $w.b.delete -text [trans delete] -command "::alarms::DeleteAlarm $user; destroy $w" pack $w.b.save $w.b.cancel $w.b.delete -side right -padx 10 pack $w.b -side top -padx 0 -pady 4 -anchor e -expand true -fill both } else { #Embedded mode Separator $w.sepbutton -orient horizontal pack $w.sepbutton -side top -anchor w -expand true -fill x -padx 5 -pady 5 button $w.delete -text [trans delete] -command "::alarms::DeleteAlarm $user" pack $w.delete -side top -anchor c } } proc OkPressed { user w} { if { [::alarms::SaveAlarm $user] == 0 } { destroy $w } } #Deletes variable settings for current user. proc DeleteAlarm { user } { global my_alarms #Delete pic file if it was copied if { [getAlarmItem $user copied_pic] == 1 } { catch {file delete [getAlarmItem $user pic]} } ::abook::setContactData $user alarms "" ::abook::saveToDisk InitMyAlarms $user cmsn_draw_online 0 2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -