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

📄 trayicon.tcl

📁 Linux下的MSN聊天程序源码
💻 TCL
📖 第 1 页 / 共 2 页
字号:
				}			  }			  "BOSS" {   				#for bossmode				set pixmap "[::skin::GetSkinFile pixmaps dboss.png]"				set tooltip "[trans pass]"				if { [WinDock] } {					set trayicon [winico create [::skin::GetSkinFile winicons bossmode.ico]]				}			  }			  default {				set pixmap "null"				if { [WinDock] } {					set trayicon [winico create [::skin::GetSkinFile winicons msn.ico]]				}			  }			}			$iconmenu entryconfigure 0 -label "[::config::getKey login]"			if { [WinDock] } {				if { ![winfo exists .bossmode] || $status == "BOSS" } {					#skip if in bossmode and not setting to BOSS					winico taskbar delete $wintrayicon					set wintrayicon $trayicon					winico taskbar add $wintrayicon -text $tooltip -callback "taskbar_icon_handler %m %x %y"				}			} else {				if { $pixmap != "null"} {					configureti $statusicon -tooltip $tooltip					image create photo statustrayicon -file $pixmap					image create photo statustrayiconres					#if { [image width statustrayicon] > [winfo width $icon] || [image height statustrayicon] > [winfo height $icon]} {					#	::picture::ResizeWithRatio statustrayicon [winfo width $icon] [winfo height $icon]					#}				}			}		}	}}proc taskbar_mail_icon_handler { msg x y } {	global password	if { [winfo exists .bossmode] } {		if { $msg=="WM_LBUTTONDBLCLK" } {			wm state .bossmode normal			focus -force .bossmode		}		return	}	if { $msg=="WM_LBUTTONUP" } {		::hotmail::hotmail_login 	}}proc mailicon_proc {num} {	# Workaround for bug in the traydock-plugin - statusicon added - BEGIN	global systemtray_exist mailicon statusicon password winmailicon tcl_platform mailtrayicon defaultbackground	# Workaround for bug in the traydock-plugin - statusicon added - END	if { [::config::getKey showmailicon] == 0 } {		return	}	set icon .mi	if {$systemtray_exist == 1 && $mailicon == 0 && ([UnixDock] || [WinDock])  && $num >0} {		set pixmap "[::skin::GetSkinFile pixmaps unread_tray.gif]"		if { $num == 1 } {			set msg [trans onenewmail]		} elseif { $num == 2 } {			set msg [trans twonewmail 2]		} else {			set msg [trans newmail $num]		}		if { [WinDock] } {			set winmailicon [winico create [::skin::GetSkinFile winicons unread.ico]]			winico taskbar add $winmailicon -text $msg -callback "taskbar_mail_icon_handler %m %x %y"			set mailicon 1		} else {			image create photo mailtrayicon -file $pixmap			image create photo mailtrayiconres			set mailicon [newti $icon -tooltip offline -pixmap mailtrayiconres -command "::trayicon_callback mailtrayicon mailtrayiconres"]			bind $icon <Button-1> "::hotmail::hotmail_login"		}	} elseif {$systemtray_exist == 1 && $mailicon != 0 && $num == 0} {		if { $tcl_platform(platform) != "windows" } {			remove_icon $mailicon			destroy mailtrayicon			set mailicon 0		} else {			winico taskbar delete $winmailicon			set mailicon 0		}	} elseif {$systemtray_exist == 1 && $mailicon != 0 && ([UnixDock] || [WinDock])  && $num > 0} {		if { $num == 1 } {			set msg [trans onenewmail]		} elseif { $num == 2 } {			set msg [trans twonewmail 2]		} else {			set msg [trans newmail $num]		}		if { [WinDock] } {			winico taskbar modify $winmailicon -text $msg		} else {			configureti $mailicon -tooltip $msg		}	} }proc remove_icon {icon} {	global systemtray_exist	if {$systemtray_exist == 1 && $icon != 0} {		catch {removeti $icon}#                destroy $icon	}}proc restart_tray { } {    status_log "RESTARTING the traydock"    statusicon_proc "REMOVE"    statusicon_proc [::MSN::myStatusIs]    }		#Begin of a clean, platform independent trayicon API that could be made a plugin, maybe a snit object	#TODO: tooltips, windows testing, possibility to query the names of all tray-icons available######################################################################## loadTrayLib {}                                                      ##     This procedure tries to load the trayicon library, depending    ##     on the platform it is used on.  It returns 1 if it succeeded,   ##     0 on failure.  Errors are printed to stdout.                    ##     Depends on:                                                     ##       - OnWin / OnUnix / trans                                      ########################################################################proc loadTrayLib {} {		if { [OnWin] } {		# First try with the package winico (for the 0.6 version)		catch {package require Winico}		if {[isWinicoLoaded] } {			return 1		}		#set file name of the lib		set ext "[file join utils windows winico05.dll]"		#if the lib is not available, print an error on the console and return		if { ![file exists $ext] } {			status_log "[trans needwinico2]"			return 0		}		#if there is a problem loading the lib, print the error on the console and return		if { [catch {load $ext winico} errormsg] } {			status_log "$errormsg"			return 0		}	} elseif { [OnUnix] } {		#if there is a problem loading the lib, print the error on the console and return		if { [catch {package require libtray} errormsg] } {			status_log "[trans traynotcompiled] : $errormsg"			return 0		}			#check if a systemtray is available, ifnot, set the "lib loaded" state off so no icons will be made		if { ![systemtray_exist] } {			status_log "[trans nosystemtray]"			return 0		}			}	#no errors where encountered at this point, the library should be loaded and a tray available; return 1:	return 1	}######################################################################## addTrayIcon {name xiconpath winiconpath {tooltip ""}                ##                                    {winactionhandler "nohandler"}}  ##     This procedure tries to add an icon to the tray.                ##     Vars:                                                           ##       - name: the internal specific name of the icon (as widget)    ##       - xiconpath: the path to the pixmap for X11 systems           ##       - winiconpath: the path to the .ico-file for windows systems  ##       - tooltip:  text to show when hovered by the mousepointer     ##       - tooltip:  handler proc for communication on windows         ##     Depends on:                                                     ##       - loadTrayLib / OnWin / OnUnix / tray lib  /                  ##         balloon_enter / balloon_motion / kill_balloon               ########################################################################proc addTrayIcon {name xiconpath winiconpath {tooltip ""} {winactionhandler "nohandler"}} {	if {[loadTrayLib]} {		global defaultbackground		if { $name == "" } { set name "trayicon" }					#Windows specific code		if { [OnWin] && $winiconpath != ""} {			set ${name} [winico create $winiconpath]			#add the icon			winico taskbar add $name -text "$tooltip" -callback "$winactionhandler %m %x %y"			return 1		#X11/Freedesktop (linux) specific code		} elseif { [OnUnix] && $xiconpath != ""} {			if { [winfo exists .$name] } {				status_log "trayicon.tcl: won't add icon $name as it already exists"			} else {				if { [loadTrayLib] } {					#add the icon     !! name => .name					set name [newti .$name -pixmap [image create photo dest_$name] -command "::trayIcon_Configure [image create photo source_$name -file $xiconpath] dest_$name"]	#TODO: balloon bindings	#bind .$name <Motion> [list status_log "motion"]	status_log $name	bind $name <Enter> +[list balloon_enter %W %X %Y "Test!" [::skin::loadPixmap dbusy]]	bind $name <Motion> +[list balloon_motion %W %X %Y "Test!" [::skin::loadPixmap dbusy]]	bind $name <Leave> "+set Bulle(first) 0; kill_balloon"				}			}			return 1		} else {			status_log "Error creating trayicon."			return 0		}	} else {		return 0	}}######################################################################## addTrayIcon {name }                                                 ##     This procedure removes an existing icon from the tray.          ##     Vars:                                                           ##       - name: the internal specific name of the icon (as widget)    ##     Depends on:                                                     ##       - loadTrayLib / OnWin / OnUnix / tray lib                     ########################################################################proc rmTrayIcon {name} {	if {[loadTrayLib]} {		#Windows specific code		if { [OnWin] } {			winico taskbar delete $name		#X11/Freedesktop (linux) specific code		} elseif { [OnUnix] } {			if { [catch {removeti .$name} errormsg] } {				status_log "$errormsg\n"			}			if { [catch {destroy .$name} errormsg] } {				status_log "$errormsg\n"			}		}	}}proc confTrayIcon {name xiconpath winiconpath {tooltip ""} {winactionhandler "nohandler"}} {	if {[loadTrayLib]} {		#Windows specific code		if { [OnWin] } {			#remove the icon			winico taskbar delete $name			set ${name} [winico create $winiconpath]			#readd the icon			winico taskbar add $name -text "$tooltip" -callback "$winactionhandler %m %x %y"					#X11/Freedesktop (linux) specific code		} elseif { [OnUnix] } {			configureti .$name			image create photo source_$name -file $xiconpath			image create photo dest_$name						#TODO: Change tooltip		}	}}######################################################################## Aid procedures                                                      ##     These are no part of the API itself                             #########################################################################Linux only aid proc:proc trayIcon_Configure {imgSrc imgDst width height} {	$imgDst copy $imgSrc	if { [image width $imgSrc] > $width || [image height $imgSrc] > $height} {		::picture::ResizeWithRatio $imgDst $width $height	}}#Windows only aid proc:proc nohandler {win x y} {	status_log "Err: No icon handler given"}

⌨️ 快捷键说明

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