[amsn] use tktray for trayicon instead of libtray
Sander Hoentjen
tjikkun at fedoraproject.org
Sat Aug 14 10:46:11 UTC 2010
commit a5c4981a5f917c9c10efd0809cf87e30e3b68991
Author: Sander Hoentjen <sander at hoentjen.eu>
Date: Sat Aug 14 12:44:26 2010 +0200
use tktray for trayicon instead of libtray
amsn-0.98.3-usetktray.patch | 230 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 230 insertions(+), 0 deletions(-)
---
diff --git a/amsn-0.98.3-usetktray.patch b/amsn-0.98.3-usetktray.patch
new file mode 100644
index 0000000..e1cd6cd
--- /dev/null
+++ b/amsn-0.98.3-usetktray.patch
@@ -0,0 +1,230 @@
+--- amsn/trayicon.tcl 2010-04-24 15:56:42.000000000 +0200
++++ amsn~/trayicon.tcl 2010-08-08 13:41:35.168584989 +0200
+@@ -1,14 +1,15 @@
+
+-::Version::setSubversionId {$Id: trayicon.tcl 11961 2010-03-05 02:43:03Z alexandernst $}
++::Version::setSubversionId {$Id: trayicon.tcl 12043 2010-05-27 18:55:10Z kakaroto $}
+
+ if { $initialize_amsn == 1 } {
+- global statusicon mailicon systemtray_exist iconmenu ishidden defaultbackground
++ global statusicon mailicon systemtray_exist iconmenu ishidden defaultbackground use_tktray
+
+ set statusicon 0
+ set mailicon 0
+ set systemtray_exist 0
+ set iconmenu 0
+ set ishidden 0
++ set use_tktray 0
+ }
+
+ proc iconify_proc {} {
+@@ -51,7 +52,7 @@
+
+ # Load the needed library (platform dependent) and create the context-menu
+ proc trayicon_init {} {
+- global systemtray_exist iconmenu wintrayicon statusicon
++ global systemtray_exist iconmenu wintrayicon statusicon use_tktray
+
+ if { [WinDock] } {
+ #added to stop creation of more than 1 icon
+@@ -87,14 +88,24 @@
+ set iconmenu .trayiconwin.immain
+
+ } elseif {[UnixDock]} {
++ if { [catch {package require tktray} res] } {
+ if { [catch {package require libtray} res] } {
+ set systemtray_exist 0
+ status_log "[trans traynotcompiled] : $res"
+ close_dock
+ return
++ } else {
++ set use_tktray 0
++ }
++ } else {
++ set use_tktray 1
+ }
+
++ if {$use_tktray} {
++ set systemtray_exist 1
++ } else {
+ set systemtray_exist [systemtray_exist]; #a system tray exist?
++ }
+
+ destroy .immain
+ set iconmenu .immain
+@@ -220,6 +231,19 @@
+ }
+ }
+
++proc trayicon_resize {w} {
++ catch {
++ set width [expr {[lindex [$w bbox] 2] - [lindex [$w bbox] 0] + 1}]
++ set height [expr {[lindex [$w bbox] 2] - [lindex [$w bbox] 0] + 1}]
++ puts "Resizing icon to $width x $height"
++
++ set img [$w cget -image]
++ if { [image width $img] != $width || [image height $img] != $height} {
++ ::picture::ResizeWithRatio $img $width $height
++ }
++ }
++}
++
+ proc statusicon_callback { action } {
+ global statusicon_callback_afterid
+
+@@ -241,7 +265,7 @@
+ }
+
+ proc statusicon_proc {status} {
+- global systemtray_exist statusicon list_states iconmenu wintrayicon defaultbackground
++ global systemtray_exist statusicon list_states iconmenu wintrayicon defaultbackground use_tktray
+ set cmdline ""
+
+ if { [::config::getKey use_tray] == 0 && $status != "REMOVE"} { return }
+@@ -251,12 +275,23 @@
+ if { $systemtray_exist == 1 && $statusicon == 0 && $status != "REMOVE" && [UnixDock]} {
+ set pixmap "[::skin::GetSkinFile pixmaps doffline.png]"
+ image create photo statustrayicon -file $pixmap
+- image create photo statustrayiconres
++ set statusicon .si
++
+ #add the icon
+- set statusicon [newti .si -tooltip "[trans offline]" -pixmap statustrayiconres -command "::trayicon_callback statustrayicon statustrayiconres"]
++ if {$use_tktray} {
++ tktray::icon .si -class "amsn-tray" -image statustrayicon
++ after 1000 { trayicon_resize .si}
++ bind $statusicon <<IconCreate>> {puts "tray created"}
++ bind $statusicon <Configure> {puts "tray configured2"}
++ bind $statusicon <<IconConfigure>> {puts "tray configured"; trayicon_resize .si}
++ bind $statusicon <<IconDestroy>> {puts "tray destroyed"}
++ } else {
++ image create photo statustrayiconres
++ set statusicon [newti .si -pixmap statustrayiconres -command "::trayicon_callback statustrayicon statustrayiconres"]
++ }
+
+- bind .si <<Button1>> iconify_proc
+- bind .si <<Button3>> "tk_popup $iconmenu %X %Y"
++ bind $statusicon <<Button1>> iconify_proc
++ bind $statusicon <<Button3>> "tk_popup $iconmenu %X %Y"
+ }
+ if { $systemtray_exist == 1 && $statusicon == 0 && $status != "REMOVE" && [MacDock]} {
+ set pixmap "[::skin::GetSkinFile pixmaps doffline.png]"
+@@ -281,10 +316,12 @@
+ if {[UnixDock] } {
+ catch {
+ image delete statustrayicon
++ if {!$use_tktray} {
+ image delete statustrayiconres
+ }
+ }
+ }
++ }
+ set statusicon 0
+ } elseif {$systemtray_exist == 1 && $statusicon != 0 && $status != "REMOVE"} {
+ if { $status != "" } {
+@@ -407,10 +444,11 @@
+
+ } elseif {[UnixDock] } {
+ if { $pixmap != "null"} {
+- configureti $statusicon -tooltip $tooltip
+ image create photo statustrayicon -file $pixmap
++ if {!$use_tktray} {
+ image create photo statustrayiconres
+ }
++ }
+ } elseif {[MacDock] } {
+ if { $pixmap == "null"} {
+ ::statusicon::setVisible $statusicon 0
+@@ -425,7 +463,7 @@
+ }
+
+ proc statusicon_blink_proc {status} {
+- global systemtray_exist statusicon iconmenu wintrayicon
++ global systemtray_exist statusicon iconmenu wintrayicon use_tktray
+
+ if { [::config::getKey use_tray] == 0 || $systemtray_exist == 0 || $statusicon == 0 } { return }
+
+@@ -534,10 +572,11 @@
+
+ } elseif {[UnixDock] } {
+ if { $pixmap != "null"} {
+- configureti $statusicon -tooltip $tooltip
+ image create photo statustrayicon -file $pixmap
++ if {!$use_tktray} {
+ image create photo statustrayiconres
+ }
++ }
+ } elseif {[MacDock] } {
+ if { $pixmap == "null"} {
+ ::statusicon::setVisible $statusicon 0
+@@ -564,7 +603,7 @@
+
+ proc mailicon_proc {num} {
+ # Workaround for bug in the traydock-plugin - statusicon added - BEGIN
+- global systemtray_exist mailicon statusicon winmailicon defaultbackground
++ global systemtray_exist mailicon statusicon winmailicon defaultbackground use_tktray
+ # Workaround for bug in the traydock-plugin - statusicon added - END
+
+ if { [::config::getKey showmailicon] == 0 } {
+@@ -587,8 +626,20 @@
+ set mailicon 1
+ } elseif {[UnixDock] } {
+ image create photo mailtrayicon -file $pixmap
++ if {$use_tktray} {
++ catch {destroy .mi}
++ set mailicon .mi
++ tktray::icon .mi -image mailtrayicon
++ after 1000 { trayicon_resize .mi}
++
++ bind .mi <<IconCreate>> {puts "mail tray created"}
++ bind .mi <Configure> {puts "mail tray configured2"}
++ bind .mi <<IconConfigure>> {puts "mail tray configured"; trayicon_resize .mi}
++ bind .mi <<IconDestroy>> {puts "mail tray destroyed"}
++ } else {
+ image create photo mailtrayiconres
+- set mailicon [newti .mi -tooltip offline -pixmap mailtrayiconres -command "::trayicon_callback mailtrayicon mailtrayiconres"]
++ set mailicon [newti .mi -pixmap mailtrayiconres -command "::trayicon_callback mailtrayicon mailtrayiconres"]
++ }
+
+ bind .mi <Button-1> "::hotmail::hotmail_login"
+ bind .mi <Enter> [list balloon_enter %W %X %Y $msg]
+@@ -609,10 +660,12 @@
+ if {[UnixDock] } {
+ catch {
+ image delete mailtrayicon
++ if {!$use_tktray} {
+ image delete mailtrayiconres
+ }
+ }
+ }
++ }
+ set mailicon 0
+ } elseif {$systemtray_exist == 1 && $mailicon != 0 && $num > 0} {
+ set froms [::hotmail::getFroms]
+@@ -631,7 +684,6 @@
+ if { [WinDock] } {
+ winico taskbar modify $winmailicon -text $msg
+ } elseif {[UnixDock] } {
+- configureti $mailicon -tooltip $msg
+ bind $mailicon <Enter> [list balloon_enter %W %X %Y $msg]
+ bind $mailicon <Motion> [list balloon_motion %W %X %Y $msg]
+ } elseif {[MacDock] } {
+@@ -641,13 +693,17 @@
+ }
+
+ proc remove_icon {icon} {
+- global systemtray_exist
++ global systemtray_exist use_tktray
+ if {$icon != 0} {
+ # Can't use UnixDock and MacDock because if we remove the icon
+ # it might be because the user disabled the 'use_tray' option
+ # so those functions would always return false...
+ if {[OnLinux] || [OnBSD]} {
++ if {$use_tktray} {
++ catch {destroy $icon}
++ } else {
+ catch {removeti $icon}
++ }
+ } elseif {[OnMac] } {
+ catch { ::statusicon::destroy $icon}
+ }
More information about the scm-commits
mailing list