⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 alarm.tcl

📁 Linux下的MSN聊天程序源码
💻 TCL
📖 第 1 页 / 共 2 页
字号:
	}	#Saves alarm settings for current user on OK press.	proc SaveAlarm { user } {		global my_alarms HOME			if { ($my_alarms(${user}_sound_st) == 1) && ([file exists "$my_alarms(${user}_sound)"] == 0) } {			msg_box [trans invalidsound]			return -1		}				#Check the picture file, and copy to our home directory,		#converting it if necessary		if { ($my_alarms(${user}_pic_st) == 1) } {			if { ([file exists "$my_alarms(${user}_pic)"] == 0) } {				msg_box [trans invalidpic]				return -1			} else {				if { [catch {image create photo joanna -file $my_alarms(${user}_pic) -format cximage}] } {					set file ""					catch {set file [::picture::Convert "$my_alarms(${user}_pic)" "[file join $HOME alarm_${user}.png]"]} res					if { $file == "" } {						msg_box $res						return -1					} else {						image create photo joanna -file $file -format cximage						if { ([image width joanna] >= 1024) || ([image height joanna] >= 768) } {							set my_alarms(${user}_copied_pic) 0							catch {file delete $file}							msg_box [trans invalidpicsize]							return -1						} else {							set my_alarms(${user}_pic) $file							set my_alarms(${user}_copied_pic) 1						}						image delete joanna					}				} elseif { ([image width joanna] >= 1024) || ([image height joanna] >= 768) } {					image delete joanna					msg_box [trans invalidpicsize]					return -1				} else {					image delete joanna										catch {file copy -force $my_alarms(${user}_pic) [file join $HOME alarm_${user}.png]}					set my_alarms(${user}_pic) [file join $HOME alarm_${user}.png]					set my_alarms(${user}_copied_pic) 1				}			}		}			set alarms(enabled) $my_alarms(${user}_enabled)		set alarms(loop) $my_alarms(${user}_loop)		set alarms(sound_st) $my_alarms(${user}_sound_st)		set alarms(pic_st) $my_alarms(${user}_pic_st)		set alarms(sound) $my_alarms(${user}_sound)		set alarms(pic) $my_alarms(${user}_pic)		set alarms(msg) $my_alarms(${user}_msg)		set alarms(msg_st) $my_alarms(${user}_msg_st)		set alarms(onconnect) $my_alarms(${user}_onconnect)		set alarms(onmsg) $my_alarms(${user}_onmsg)		set alarms(onstatus) $my_alarms(${user}_onstatus)		set alarms(ondisconnect) $my_alarms(${user}_ondisconnect)		set alarms(command) $my_alarms(${user}_command)		set alarms(oncommand) $my_alarms(${user}_oncommand)		set alarms(copied_pic) $my_alarms(${user}_copied_pic)				status_log "alarms: saving alarm for $user\n" blue			::abook::setContactData $user alarms [array get alarms]		::abook::saveToDisk				cmsn_draw_online 0 2		unset my_alarms				return 0	}		proc StopSnackAlarm {w snd} {			destroy $w		$snd stop		$snd destroy	}}#Runs the alarm (sound and pic)proc run_alarm {config_user user nick msg} {	global program_dir tcl_platform alarm_win_number		if { ![info exists alarm_win_number] } {		set alarm_win_number 0	}	incr alarm_win_number	set wind_name alarm_${alarm_win_number}	if { [::alarms::getAlarmItem ${config_user} pic_st] == 1 || [::alarms::getAlarmItem ${config_user} sound_st] == 1 } {		toplevel .${wind_name}		set myDate [ clock format [clock seconds] -format " - %d/%m/%y at %H:%M" ]		wm title .${wind_name} "[trans alarm] $user $myDate"			label .${wind_name}.txt -text "$msg"		pack .${wind_name}.txt	}		#Create picture	if { [::alarms::getAlarmItem ${config_user} pic_st] == 1 } {		if {[file readable [::alarms::getAlarmItem ${config_user} pic]]} {			image create photo joanna_$alarm_win_number -file [::alarms::getAlarmItem ${config_user} pic] -format cximage			if { ([image width joanna_$alarm_win_number] < 1024) && ([image height joanna_$alarm_win_number] < 768) } {				label .${wind_name}.jojo -image joanna_$alarm_win_number				pack .${wind_name}.jojo			}		}	}	#Play sound	if { [::alarms::getAlarmItem ${config_user} sound_st] == 1 } {			if { [::config::getKey usesnack] } {					#Ok, we're using Snack, do it the Snack way			snack::sound alarmsnd_${alarm_win_number} -load [::alarms::getAlarmItem ${config_user} sound]			snack_play_sound alarmsnd_${alarm_win_number} [::alarms::getAlarmItem ${config_user} loop]			button .${wind_name}.stopmusic -text [trans stopalarm] -command [list ::alarms::StopSnackAlarm .${wind_name} alarmsnd_${alarm_win_number}]			wm protocol .${wind_name} WM_DELETE_WINDOW [list ::alarms::StopSnackAlarm .${wind_name} alarmsnd_${alarm_win_number}]			pack .${wind_name}.stopmusic -padx 2					} else {					set sound [::alarms::getAlarmItem ${config_user} sound]			#Prepare the sound command for variable substitution			#set command [::config::getKey soundcommand]			#set command [string map {"\[" "\\\[" "\\" "\\\\" "\$" "\\\$" "\(" "\\\(" } $command]			#Now, let's unquote the variables we want to replace			#set command "[string map {"\\\$sound" "\${sound}" } $command]"						if { [::alarms::getAlarmItem ${config_user} loop] == 1 } {							button .${wind_name}.stopmusic -text [trans stopalarm] -command "destroy .${wind_name}; cancel_loop $wind_name"				wm protocol .${wind_name} WM_DELETE_WINDOW "destroy .${wind_name}; cancel_loop $wind_name"				pack .${wind_name}.stopmusic -padx 2				#Delay it a bit so window users can have the window painted				after 1000 [list play_loop $sound $wind_name]							} else {				button .${wind_name}.stopmusic -text [trans stopalarm] -command "destroy .${wind_name}"				wm protocol .${wind_name} WM_DELETE_WINDOW "destroy .${wind_name}"				pack .${wind_name}.stopmusic -padx 2				play_sound $sound 1 1			}					}			} elseif { [::alarms::getAlarmItem ${config_user} pic_st] == 1 } {		button .${wind_name}.stopmusic -text [trans stopalarm] -command "destroy .${wind_name}"		pack .${wind_name}.stopmusic -padx 2	}		#Send message and disable it after sending	if { [::alarms::getAlarmItem $config_user msg_st] == 1 } {		set msg [::alarms::getAlarmItem $config_user msg]		#This will reenable the message sending if delivery failed		set ackid [after 60000 [list ::alarms::messageFailed $config_user $msg]]		::alarms::setAlarmItem $config_user msg_st 0		::MSN::messageTo $user $msg $ackid				#Disable sending the message again	}		#Replace variables in command	if { [::alarms::getAlarmItem ${config_user} oncommand] == 1 } {		set the_command [::alarms::getAlarmItem ${config_user} command]		#By default, quote backslashes and variables		set the_command [string map {"\[" "\\\[" "\\" "\\\\" "\$" "\\\$" "\(" "\\\(" } $the_command]		#Now, let's unquote the variables we want to replace		set the_command "[string map {"\\\$nick" "\${nick}" "\\\$user" "\${user}" "\\\$msg" "\${msg}"} $the_command] &"		catch {eval exec $the_command} res	}	}# Switches alarm setting from ON/OFFproc switch_alarm { user tw icon} {	#We get the alarms configuration. It's stored as a list, but it's converted to an array	array set alarms [::abook::getContactData $user alarms]	if { [info exists alarms(enabled)] && $alarms(enabled) == 1 } {		set alarms(enabled) 0	} else {		set alarms(enabled) 1	}		#We set the alarms configuration. We can't store an array, so we convert it to a list	::abook::setContactData $user alarms [array get alarms]	redraw_alarm_icon $user $tw $icon}# Redraws the alarm icon for current user ONLY without redrawing full list of contactsproc redraw_alarm_icon { user tw icon } {	if { [::alarms::getAlarmItem $user enabled] == 1 } {		$tw image configure $icon -image [::skin::loadPixmap bell]	} else {		$tw image configure $icon -image [::skin::loadPixmap belloff]	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -