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

📄 gui.tcl

📁 Linux下的MSN聊天程序源码
💻 TCL
📖 第 1 页 / 共 5 页
字号:
	#///////////////////////////////////////////////////////////////////////////////	# enterCustomStyle ()	# Dialog window to edit the custom chat style	proc enterCustomStyle {} {		set w .change_custom_style		if {[winfo exists $w]} {			raise $w			return 0		}		toplevel $w		wm group $w .		wm title $w "[trans customstyle]"		frame $w.fn		label $w.fn.label -font sboldf -text "[trans customstyle]:"		entry $w.fn.ent -width 40 -bg #FFFFFF -bd 1 -font splainf		menubutton $w.fn.help -font sboldf -text "<-" -menu $w.fn.help.menu		menu $w.fn.help.menu -tearoff 0		$w.fn.help.menu add command -label [trans nick] -command "$w.fn.ent insert insert \\\$nick"		$w.fn.help.menu add command -label [trans timestamp] -command "$w.fn.ent insert insert \\\$tstamp"		$w.fn.help.menu add command -label [trans newline] -command "$w.fn.ent insert insert \\\$newline"		$w.fn.help.menu add separator		$w.fn.help.menu add command -label [trans delete] -command "$w.fn.ent delete 0 end"		$w.fn.ent insert end [::config::getKey customchatstyle]		frame $w.fb		button $w.fb.ok -text [trans ok] -command [list ::amsn::enterCustomStyleOk $w]		button $w.fb.cancel -text [trans cancel] -command "destroy $w"		pack $w.fn.label $w.fn.ent $w.fn.help -side left -fill x -expand true		pack $w.fb.ok $w.fb.cancel -side right -padx 5		pack $w.fn $w.fb -side top -fill x -expand true -padx 5		bind $w.fn.ent <Return> [list ::amsn::enterCustomStyleOk $w]		catch {			raise $w			focus -force $w.fn.ent		}		moveinscreen $w 30	}	proc enterCustomStyleOk {w} {		::config::setKey customchatstyle [$w.fn.ent get]		destroy $w	}	#///////////////////////////////////////////////////////////////////////////////	# userJoins (chatid, user_name)	# called from the protocol layer when a user JOINS a chat	# It should be called after a JOI in the switchboard.	# If a window exists, it will show "user joins conversation" in the status bar	# - 'chatid' is the chat name	# - 'usr_name' is the user that joins email	proc userJoins { chatid usr_name {create_win 1} } {		set win_name [::ChatWindow::For $chatid]		if { $create_win && $win_name == 0 && [::config::getKey newchatwinstate]!=2 } {			set win_name [::ChatWindow::MakeFor $chatid "" $usr_name]			# PostEvent 'new_conversation' to notify plugins that the window was created			set evPar(chatid) $chatid			set evPar(usr_name) $usr_name			::plugins::PostEvent new_conversation evPar		}		if { $win_name != 0 } {			set statusmsg "[timestamp] [trans joins [::abook::getDisplayNick $usr_name]]\n"			::ChatWindow::Status [ ::ChatWindow::For $chatid ] $statusmsg minijoins			::ChatWindow::TopUpdate $chatid			if { [::config::getKey showdisplaypic] && $usr_name != ""} {				::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name]			} else {				::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name] nopack			}			if { [::config::getKey leavejoinsinchat] == 1 } {								SendMessageFIFO [list ::amsn::WinWriteJoin $chatid $usr_name] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)"			}		}		if { [::config::getKey keep_logs] } {			::log::JoinsConf $chatid $usr_name		}		#Postevent when user joins a chat		set evPar(usr_name) usr_name		set evPar(chatid) chatid		set evPar(win_name) win_name		::plugins::PostEvent user_joins_chat evPar	}	proc WinWriteJoin {chatid usr_name} {		::amsn::WinWrite $chatid "\n" green "" 0		::amsn::WinWriteIcon $chatid minijoins 5 0		::amsn::WinWrite $chatid "[timestamp] [trans joins [::abook::getDisplayNick $usr_name]]" green "" 0	}	#///////////////////////////////////////////////////////////////////////////////	#///////////////////////////////////////////////////////////////////////////////	# userLeaves (chatid, user_name)	# called from the protocol layer when a user LEAVES a chat.	# It will show the status message. No need to show it if the window is already	# closed, right?	# - 'chatid' is the chat name	# - 'usr_name' is the user email to show in the status message	proc userLeaves { chatid usr_name closed } {		global automsgsent		set win_name [::ChatWindow::For $chatid]		if { $win_name == 0} {			return 0		}		set username [::abook::getDisplayNick $usr_name]		if { $closed } {			set statusmsg "[timestamp] [trans leaves $username]\n"			set icon minileaves			if { [::config::getKey leavejoinsinchat] == 1 } {				SendMessageFIFO [list ::amsn::WinWriteLeave $chatid $username] "::amsn::messages_stack($chatid)" "::amsn::messages_flushing($chatid)"			}		} else {			set statusmsg "[timestamp] [trans closed $username]\n"			set icon minileaves		}		#Check if the image that is currently showing is		#from the user that left. Then, change it		set current_image ""		#Catch it, because the window might be closed		catch {set current_image [$win_name.f.bottom.pic.image cget -image]}		if { [string compare $current_image [::skin::getDisplayPicture $usr_name]]==0} {			set users_in_chat [::MSN::usersInChat $chatid]			set new_user [lindex $users_in_chat 0]			::amsn::ChangePicture $win_name [::skin::getDisplayPicture $new_user] [trans showuserpic $new_user] nopack		}		::ChatWindow::Status $win_name $statusmsg $icon		::ChatWindow::TopUpdate $chatid		if { [::config::getKey keep_logs] } {			::log::LeavesConf $chatid $usr_name		}		# Unset automsg if he leaves so that it sends again on next msg		if { [info exists automsgsent($usr_name)] } {			unset automsgsent($usr_name)		}		#Postevent when user leaves a chat		set evPar(usr_name) usr_name		set evPar(chatid) chatid		set evPar(win_name) win_name		::plugins::PostEvent user_leaves_chat evPar	}	proc WinWriteLeave {chatid username} {		::amsn::WinWrite $chatid "\n" green "" 0		::amsn::WinWriteIcon $chatid minileaves 5 0		::amsn::WinWrite $chatid "[timestamp] [trans leaves $username]" green "" 0	}	#///////////////////////////////////////////////////////////////////////////////	#///////////////////////////////////////////////////////////////////////////////	# updateTypers (chatid)	# Called from the protocol.	# Asks the protocol layer to get a list of typing users in the chat, and shows	# a message in the status bar.	# - 'chatid' is the name of the chat	proc updateTypers { chatid } {		if {[::ChatWindow::For $chatid] == 0} {			return 0		}		set typers_list [::MSN::typersInChat $chatid]		set typingusers ""		foreach login $typers_list {			set user_name [::abook::getDisplayNick $login]			set typingusers "${typingusers}${user_name}, "		}		set typingusers [string replace $typingusers end-1 end ""]		set statusmsg ""		set icon ""		if {[llength $typers_list] == 0} {			set lasttime [::MSN::lastMessageTime $chatid]			if { $lasttime != 0 } {				set statusmsg "[trans lastmsgtime $lasttime]"			}		} elseif {[llength $typers_list] == 1} {			set statusmsg " [trans istyping $typingusers]."			set icon typingimg		} else {			set statusmsg " [trans aretyping $typingusers]."			set icon typingimg		}		::ChatWindow::Status [::ChatWindow::For $chatid] $statusmsg $icon	}	#///////////////////////////////////////////////////////////////////////////////	if { $initialize_amsn == 1 } {		variable clipboard ""	}	proc ToggleShowPicture { win_name } {		upvar #0 ${win_name}_show_picture show_pic		if { [info exists show_pic] && $show_pic } {			set show_pic 0		} else {			set show_pic 1		}	}	proc ShowPicMenu { win x y } {		status_log "Show menu in window $win, position $x $y\n" blue		catch {menu $win.picmenu -tearoff 0}		$win.picmenu delete 0 end		#Make the picture menu appear on the conversation window instead of having it in the bottom of screen (and sometime lost it if the conversation window is in the bottom of the window)		global tcl_platform		if {![catch {tk windowingsystem} wsystem] && $wsystem == "aqua"} {			incr x -50			incr y -115		}		set chatid [::ChatWindow::Name $win]		set users [::MSN::usersInChat $chatid]		#Switch to "my picture" or "user picture"		$win.picmenu add command -label "[trans showmypic]" \			-command [list ::amsn::ChangePicture $win displaypicture_std_self [trans mypic]]		foreach user $users {			$win.picmenu add command -label "[trans showuserpic $user]" \				-command "::amsn::ChangePicture $win \[::skin::getDisplayPicture $user\] \[trans showuserpic $user\]"		}		#Load Change Display Picture window		$win.picmenu add separator		$win.picmenu add command -label "[trans changedisplaypic]..." -command pictureBrowser		set user [$win.f.bottom.pic.image cget -image]		if { $user != "displaypicture_std_none" && $user != "displaypicture_std_self" } {			#made easy for if we would change the image names			set user [string range $user [string length "displaypicture_std_"] end]			$win.picmenu add separator			#Sub-menu to change size			$win.picmenu add cascade -label "[trans changesize]" -menu $win.picmenu.size			catch {menu $win.picmenu.size -tearoff 0 -type normal}			$win.picmenu.size delete 0 end			#4 possible size (someone can add something to let the user choose his size)			$win.picmenu.size add command -label "[trans small]" -command "::skin::ConvertDPSize $user 64 64"			$win.picmenu.size add command -label "[trans default2]" -command "::skin::ConvertDPSize $user 96 96"			$win.picmenu.size add command -label "[trans large]" -command "::skin::ConvertDPSize $user 128 128"			$win.picmenu.size add command -label "[trans huge]" -command "::skin::ConvertDPSize $user 192 192"			#Get back to original picture			$win.picmenu.size add command -label "[trans original]" -command "::MSNP2P::loadUserPic $chatid $user 1"		}		tk_popup $win.picmenu $x $y	}	proc ChangePicture {win picture balloontext {nopack ""}} {		#pack $win.bottom.pic.image -side left -padx 2 -pady 2		upvar #0 ${win}_show_picture show_pic		set scrolling [::ChatWindow::getScrolling [::ChatWindow::GetOutText $win]]		#Get the path to the image		set pictureinner [$win.f.bottom.pic.image getinnerframe]		if { $balloontext != "" } {			#TODO: Improve this!!! Use some kind of abstraction!			change_balloon $pictureinner $balloontext			#change_balloon $win.f.bottom.pic.image $balloontext		}		if { [catch {$win.f.bottom.pic.image configure -image $picture}] } {			status_log "Failed to set picture, using displaypicture_std_none\n" red			$win.f.bottom.pic.image configure -image [::skin::getNoDisplayPicture]			#change_balloon $win.f.bottom.pic.image [trans nopic]			change_balloon $pictureinner [trans nopic]		} elseif { $nopack == "" } {			pack $win.f.bottom.pic.image -side left -padx 0 -pady 0 -anchor w			$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imghide]			bind $win.f.bottom.pic.showpic <Enter> "$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imghide_hover]"			bind $win.f.bottom.pic.showpic <Leave> "$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imghide]"			change_balloon $win.f.bottom.pic.showpic [trans hidedisplaypic]			set show_pic 1		}		if { $scrolling } {			update idletasks			::ChatWindow::Scroll [::ChatWindow::GetOutText $win]		}	}	proc HidePicture { win } {		global ${win}_show_picture		pack forget $win.f.bottom.pic.image		#grid $win.f.bottom.pic.showpic -row 0 -column 1 -padx 0 -pady 0 -rowspan 2		#Change here to change the icon, instead of text		$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imgshow]		bind $win.f.bottom.pic.showpic <Enter> "$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imgshow_hover]"		bind $win.f.bottom.pic.showpic <Leave> "$win.f.bottom.pic.showpic configure -image [::skin::loadPixmap imgshow]"		change_balloon $win.f.bottom.pic.showpic [trans showdisplaypic]		set ${win}_show_picture 0	}	proc ShowOrHidePicture { win } {		upvar #0 ${win}_show_picture value		if { $value == 1} {			::amsn::ChangePicture $win [$win.f.bottom.pic.image cget -image] ""		} else {			::amsn::HidePicture $win		}	}	#///////////////////////////////////////////////////////////////////////////////	proc ShowUserList {title command} {		#Replace for"::amsn::ChooseList \"[trans sendmsg]\" online ::amsn::chatUser 1 0"		set userlist [list]		foreach user_login [::MSN::sortedContactList] {			set user_state_code [::abook::getVolatileData $user_login state FLN]			if { $user_state_code == "NLN" } {				lappend userlist [list [::abook::getDisplayNick $user_login] $user_login]			} elseif { $user_state_code != "FLN" } {				lappend userlist [list "[::abook::getDisplayNick $user_login] ([trans [::MSN::stateToDescription $user_state_code]])" $user_login]			}		}		::amsn::listChoose $title $userlist $command 1 1	}	proc ShowAddList {title win_name command} {		set userlist [list]		set chatusers [::MSN::usersInChat [::ChatWindow::Name $

⌨️ 快捷键说明

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