Hello.
So...
In CustomMessageBox.diff there is my diff to fix the problem when we have
more windows ask if we want to close all tabs, the current one, or nothing.
The adopted solution it has been already discussed in this thread.
In TopCW.diff:
I rewrite TopUpdate proc and now it shows, in top-cw, text with emoticons,
styles and colors.
I tested various case, for example: if we need to truncate the text, or not.
If we show also psm or only nick. if we show only email. if we show emoticon
in CL or not. I also tested the multichatting case: when an user join in a
convo or he leaves. Then when an user change his nick or psm. I didn't find
problem.
To truncate a list i write a new proc ( proc trunk_list ).
About style the text in topcw is always in bold, as it was before (but now
it can be also bold + underline, overstrike and italic)
About color the appropriate version of ColoredNicks is 0.3.1 (because there
was a problem with nicks with irc colors, it did color all text (email,
status etc...))-
Some code of TopUpdate is from guicontactlist.tcl, because the rendering is
the same.
In TopCW (simple text).txt there are TopUpdate and trunc_list procs without
showing the differenze with previous version.
Sorry for my English.
Thanks, bye :)
Square87
Index: chatwindow.tcl
===================================================================
--- chatwindow.tcl (revisione 9089)
+++ chatwindow.tcl (copia locale)
@@ -265,7 +265,7 @@
} elseif {[::config::isSet closeChatWindowWithTabs]} {
::ChatWindow::CloseTab $currenttab
} else {
- set result [::amsn::customMessageBox [trans closeall] yesnocancel question [trans title] $window 1 1]
+ set result [::amsn::customMessageBox [trans closeall] yesnocancel question [trans title] $window 1 1 "ContainerClose"]
set answer [lindex $result 0]
set rememberAnswer [lindex $result 1]
@@ -274,15 +274,18 @@
::config::setKey closeChatWindowWithTabs 1
} elseif {$answer == "no"} {
::config::setKey closeChatWindowWithTabs 0
+ } elseif {$answer == "duplicate"} {
+ ;#do nothing
}
}
if { $answer == "yes" } {
::ChatWindow::CloseAll $window
destroy $window
- }
- if { $answer == "no" } {
+ } elseif { $answer == "no" } {
::ChatWindow::CloseTab $currenttab
+ } elseif { $answer == "duplicate"} {
+ ;#do nothing
}
}
}
Index: gui.tcl
===================================================================
--- gui.tcl (revisione 9089)
+++ gui.tcl (copia locale)
@@ -708,14 +708,19 @@
#///////////////////////////////////////////////////////////////////////////////
#///////////////////////////////////////////////////////////////////////////////
- proc customMessageBox { message type {icon ""} {title ""} {parent ""} {askRememberAnswer 0} {modal 0}} {
+ proc customMessageBox { message type {icon ""} {title ""} {parent ""} {askRememberAnswer 0} {modal 0} {unique ""}} {
# This tracker is so we can TkWait. It needs to be global so that the buttons can modify it.
global customMessageBoxAnswerTracker
# This is the tracker for the checkbox.
# It needs to be an array because we may have more than one message box open (hence the unique index).
global customMessageBoxRememberTracker
- set unique [clock seconds]
+ if {$unique == ""} {
+ set unique [clock seconds]
+ } else {
+ if {[winfo exists ".messagebox_$unique"]} { return "duplicate" }
+ }
+
set w ".messagebox_$unique"
if { [winfo exists $w] } {
Index: chatwindow.tcl
===================================================================
--- chatwindow.tcl (revisione 9089)
+++ chatwindow.tcl (copia locale)
@@ -3029,43 +3032,40 @@
}
}
set win_name [::ChatWindow::For $chatid]
set top [::ChatWindow::GetTopFrame ${win_name}]
set scrolling [getScrolling [::ChatWindow::GetOutText ${win_name}]]
$top dchars text 0 end
-
- #remove the camicon(s)
- $top delete camicon
+ $top dchars text2 0 end
+ #remove the camicon(s) and default icons
+ $top delete camicon img2
set nroflines 0
set camicon [::skin::loadPixmap camicon]
+ set toX [::skin::getKey topbarpadx]
+
foreach user_login $user_list {
-
set shares_cam [::abook::getContactData $user_login webcam_shared]
if { [::config::getKey emailsincontactlist] == 1 } {
- set user_name ""
+ set user_name [list text ""]
+ set user_name_str ""
} else {
- set user_name [string map {"\n" " "} [::abook::getDisplayNick $user_login]]
+ set user_name [::abook::getDisplayNick $user_login 1]
+ set user_name_str [string map {"\n" " "} [::abook::removeStyles $user_name]]
}
- set state_code [::abook::getVolatileData $user_login state]
- set psmmedia [::abook::getpsmmedia $user_login]
-
if { [::config::getKey psmplace] == 0 } {
- set psmmedia ""
+ set psmmedia [list text ""]
+ } else {
+ set psmmedia [::abook::getpsmmedia $user_login 1]
}
- #Space added so it doesn't stick next to the status
- if { $psmmedia != "" } {
- append psmmedia " "
- }
-
+ set state_code [::abook::getVolatileData $user_login state]
if { $state_code == "" } {
set user_state ""
set state_code FLN
@@ -3073,8 +3073,6 @@
set user_state [::MSN::stateToDescription $state_code]
}
- set user_image [::MSN::stateToImage $state_code]
-
if {[::config::getKey truncatenames]} {
#Calculate maximum string width
@@ -3083,58 +3081,129 @@
incr maxw [expr { 0 - [image width $camicon] - 10 }]
}
if { "$user_state" != "" && "$user_state" != "online" } {
incr maxw [expr { 0 - [font measure sboldf -displayof $top " \([trans $user_state]\)"] } ]
}
-
incr maxw [expr { 0 - [font measure sboldf -displayof $top " <${user_login}>"] } ]
- if { [font measure sboldf -displayof $top "${user_name}"] > $maxw } {
- set nicktxt "[trunc ${user_name} ${win_name} $maxw sboldf] <${user_login}>"
+ set user_name_dim 0
+ foreach elt $user_name {
+ switch [lindex $elt 0] {
+ text {
+ incr user_name_dim [expr { 0 + [font measure sboldf -displayof $top [lindex $elt 1]]}]
+ }
+ smiley {
+ incr user_name_dim [expr { 0 + [image width [lindex $elt 1]]}]
+ }
+ newline {}
+ }
+ }
+
+ if { $user_name_dim > $maxw } {
+ set nicktxt "[trunc_list ${user_name} ${win_name} $maxw sboldf]"
+ lappend nicktxt [list text " <${user_login}>"]
} else {
- incr maxw [expr { 0 - [font measure sboldf -displayof $top " ${user_name}"] } ]
- set nicktxt "${user_name} <${user_login}> [trunc ${psmmedia} ${win_name} $maxw sboldf]"
+ incr maxw [expr { 0 - [font measure sboldf -displayof $top " "] } ]
+ incr maxw [expr { 0 - $user_name_dim}]
+ set nicktxt "${user_name}"
+ lappend nicktxt [list text " <${user_login}> "]
+ set nicktxt [concat $nicktxt [trunc_list ${psmmedia} ${win_name} $maxw sboldf]]
}
-
} else {
+ set nicktxt $user_name
+ lappend nicktxt [list text " <${user_login}> "]
+ set nicktxt [concat $nicktxt $psmmedia]
+ }
- set nicktxt "${user_name} <${user_login}> $psmmedia"
-
+ if { "$user_state" != "" && "$user_state" != "online" } {
+ #There is a free space before status name so it doesn't stick next to the psm
+ set statetxt " \([trans $user_state]\)"
+ lappend nicktxt [list text $statetxt]
}
+
+ set font [$top itemcget text -font]
+ if { $font != "" } {
+ set Ycoord [expr {[lindex [$top coords text] 1] + ([font metrics $font -displayof $top -linespace] * $nroflines)}]
+ } else {
+ set f [font create -family helvetica -size 12 -weight normal]
+ set Ycoord [expr {[lindex [$top coords text] 1] + ([font metrics $f -displayof $top -linespace] * $nroflines)}]
+ font delete $f
+ }
+ set usrsX [expr {$toX + [font measure bplainf "[trans to]:"] + 5}]
-
- $top insert text end $nicktxt
+ set defaultcolour #000000
+ set defaultfont sboldf
+ set colour $defaultcolour
+ set font_attr [font configure $defaultfont]
- if { $user_name != "" } {
- set title "${title}${user_name}, "
+ foreach unit $nicktxt {
+ switch [lindex $unit 0] {
+ "text" {
+ set textpart [lindex $unit 1]
+ $top create text $usrsX $Ycoord -text $textpart \
+ -anchor nw -fill $colour -font $font_attr -tags text2
+ set textwidth [font measure $font_attr $textpart]
+ incr usrsX $textwidth
+ }
+ "smiley" {
+ $top create image $usrsX $Ycoord -image [lindex $unit 1] -anchor nw -state normal -tags img2
+ set textwidth [image width [lindex $unit 1]]
+ incr usrsX $textwidth
+ }
+ "colour" {
+ switch -exact [lindex $unit 1] {
+ "reset" {
+ set colour $defaultcolour
+ }
+ default {
+ set colour [lindex $unit 1]
+ }
+ }
+ }
+ "font" {
+ if { [llength [lindex $unit 1]] == 1 } {
+ if { [lindex $unit 1] == "reset" } {
+ set font_attr [font configure $defaultfont]
+ } else {
+ set font_attr [font configure [lindex $unit 1]]
+ }
+ array set current_format $font_attr
+ } else {
+ array set current_format $font_attr
+ array set modifications [lindex $unit 1]
+ foreach key [array names modifications] {
+ set current_format($key) [set modifications($key)]
+ if { [set current_format($key)] == "reset" } {
+ set current_format($key) \
+ [font configure $defaultfont $key]
+ }
+ }
+ set font_attr [array get current_format]
+ }
+ }
+ "newline" {
+ }
+ default {
+ status_log "Unknown item in parsed nickname: $unit"
+ }
+ }
+ }
+
+ if { $user_name_str != "" } {
+ set title "${title}${user_name_str}, "
} else {
set title "${title}${user_login}, "
}
-
- if { "$user_state" != "" && "$user_state" != "online" } {
- set statetxt "\([trans $user_state]\)"
- $top insert text end $statetxt
- }
$top insert text end "\n"
incr nroflines
if { $shares_cam == 1 } {
#the image aligned-right to the text
set Xcoord [expr {[winfo width $top] - [image width $camicon]}]
-
- set font [$top itemcget text -font]
- if { $font != "" } {
- set Ycoord [expr {[lindex [$top coords text] 1] + ([font metrics $font -displayof $top -linespace] * ($nroflines-1))}]
- } else {
- set f [font create -family helvetica -size 12 -weight normal]
- set Ycoord [expr {[lindex [$top coords text] 1] + ([font metrics $f -displayof $top -linespace] * ($nroflines-1))}]
- font delete $f
-
- }
$top create image $Xcoord $Ycoord -anchor nw -image $camicon -tags [list camicon camicon_$user_login] -state normal
@@ -3187,11 +3256,9 @@
set evPar(user_list) "user_list"
::plugins::PostEvent TopUpdate evPar
-
update idletasks
after cancel [list ::ChatWindow::TopUpdate $chatid]
-
}
Index: gui.tcl
===================================================================
--- gui.tcl (revisione 9089)
+++ gui.tcl (copia locale)
@@ -5391,7 +5396,46 @@
return $str
}
+# The same as the previous one, but this proc works on a list.
+proc trunc_list {str {window ""} {maxw 0 } {font ""}} {
+ if { $window == "" || $font == "" || [::config::getKey truncatenames]!=1} {
+ return $str
+ }
+ set buffer [list ]
+ foreach elt $str {
+ switch [lindex $elt 0] {
+ text {
+ set txt [lindex $elt 1]
+ set slen [string length $txt]
+ for {set idx 0} { $idx <= $slen} {incr idx} {
+ if { [font measure $font -displayof $window "[string range $txt 0 $idx]..."] > $maxw } {
+ set txt "[string range $txt 0 $idx-1]"
+ lappend buffer [list text $txt] [list colour reset] [list font reset] [list text "..."]
+ return $buffer
+ }
+ }
+ set maxw [expr {$maxw - [font measure $font -displayof $window $txt]}]
+ lappend buffer $elt
+ }
+ smiley {
+ set maxw [expr {$maxw - [image width [lindex $elt 1]]}]
+ if {$maxw <= 0 } {
+ lappend buffer [list colour reset] [list font reset] [list text "..."]
+ return $buffer
+ }
+ lappend buffer $elt
+ }
+ #what should we do in that case ???
+ newline {}
+ default {
+ lappend buffer $elt
+ }
+ }
+ }
+ return $str
+}
+
------ chatwindow.tcl
proc TopUpdate { chatid } {
if { [::ChatWindow::For $chatid] == 0 } {
return 0
}
set title ""
set user_list [::MSN::usersInChat $chatid]
if {[llength $user_list] == 0} {
#return 0
#We have a chatwindow, but no SB for it.
#Check if the chatid is a valid user...
if { [lsearch [::abook::getAllContacts] $chatid] != -1
} {
set user_list $chatid
} else {
return 0
}
}
set win_name [::ChatWindow::For $chatid]
set top [::ChatWindow::GetTopFrame ${win_name}]
set scrolling [getScrolling [::ChatWindow::GetOutText
${win_name}]]
$top dchars text 0 end
$top dchars text2 0 end
#remove the camicon(s) and default icons
$top delete camicon img2
set nroflines 0
set camicon [::skin::loadPixmap camicon]
set toX [::skin::getKey topbarpadx]
foreach user_login $user_list {
set shares_cam [::abook::getContactData $user_login
webcam_shared]
if { [::config::getKey emailsincontactlist] == 1 } {
set user_name [list text ""]
set user_name_str ""
} else {
set user_name [::abook::getDisplayNick
$user_login 1]
set user_name_str [string map {"\n" " "}
[::abook::removeStyles $user_name]]
}
if { [::config::getKey psmplace] == 0 } {
set psmmedia [list text ""]
} else {
set psmmedia [::abook::getpsmmedia $user_login
1]
}
set state_code [::abook::getVolatileData $user_login
state]
if { $state_code == "" } {
set user_state ""
set state_code FLN
} else {
set user_state [::MSN::stateToDescription
$state_code]
}
if {[::config::getKey truncatenames]} {
#Calculate maximum string width
set maxw [expr {[winfo width $top] -
[::skin::getKey topbarpadx] - [expr {int([lindex [$top coords text] 0])} ] } ]
if { $shares_cam == 1} {
incr maxw [expr { 0 - [image width
$camicon] - 10 }]
}
if { "$user_state" != "" && "$user_state" !=
"online"} {
incr maxw [expr { 0 - [font measure
sboldf -displayof $top " \([trans $user_state]\)"] } ]
}
incr maxw [expr { 0 - [font measure sboldf
-displayof $top " <${user_login}>"] } ]
set user_name_dim 0
foreach elt $user_name {
switch [lindex $elt 0] {
text {
incr user_name_dim [expr { 0 +
[font measure sboldf -displayof $top [lindex $elt 1]]}]
}
smiley {
incr user_name_dim [expr { 0 +
[image width [lindex $elt 1]]}]
}
newline {}
}
}
if { $user_name_dim > $maxw } {
set nicktxt "[trunc_list ${user_name}
${win_name} $maxw sboldf]"
lappend nicktxt [list text "
<${user_login}>"]
} else {
incr maxw [expr { 0 - [font measure
sboldf -displayof $top " "] } ]
incr maxw [expr { 0 - $user_name_dim}]
set nicktxt "${user_name}"
lappend nicktxt [list text "
<${user_login}> "]
set nicktxt [concat $nicktxt
[trunc_list ${psmmedia} ${win_name} $maxw sboldf]]
}
} else {
set nicktxt $user_name
lappend nicktxt [list text " <${user_login}> "]
set nicktxt [concat $nicktxt $psmmedia]
}
if { "$user_state" != "" && "$user_state" != "online" }
{
#There is a free space before status name so it doesn't stick
next to the psm
set statetxt " \([trans $user_state]\)"
lappend nicktxt [list text $statetxt]
}
set font [$top itemcget text -font]
if { $font != "" } {
set Ycoord [expr {[lindex [$top coords text] 1]
+ ([font metrics $font -displayof $top -linespace] * $nroflines)}]
} else {
set f [font create -family helvetica -size 12
-weight normal]
set Ycoord [expr {[lindex [$top coords text] 1]
+ ([font metrics $f -displayof $top -linespace] * $nroflines)}]
font delete $f
}
set usrsX [expr {$toX + [font measure bplainf "[trans
to]:"] + 5}]
set defaultcolour #000000
set defaultfont sboldf
set colour $defaultcolour
set font_attr [font configure $defaultfont]
foreach unit $nicktxt {
switch [lindex $unit 0] {
"text" {
set textpart [lindex $unit 1]
$top create text $usrsX $Ycoord
-text $textpart \
-anchor nw -fill
$colour -font $font_attr -tags text2
set textwidth [font measure
$font_attr $textpart]
incr usrsX $textwidth
}
"smiley" {
$top create image $usrsX
$Ycoord -image [lindex $unit 1] -anchor nw -state normal -tags img2
set textwidth [image width
[lindex $unit 1]]
incr usrsX $textwidth
}
"colour" {
switch -exact [lindex $unit 1] {
"reset" {
set colour
$defaultcolour
}
default {
set colour
[lindex $unit 1]
}
}
}
"font" {
if { [llength [lindex $unit 1]]
== 1 } {
if { [lindex $unit 1]
== "reset" } {
set font_attr
[font configure $defaultfont]
} else {
set font_attr
[font configure [lindex $unit 1]]
}
array set
current_format $font_attr
} else {
array set
current_format $font_attr
array set modifications
[lindex $unit 1]
foreach key [array
names modifications] {
set
current_format($key) [set modifications($key)]
if { [set
current_format($key)] == "reset" } {
set
current_format($key) \
[font configure $defaultfont $key]
}
}
set font_attr [array
get current_format]
}
}
"newline" {
}
default {
status_log "Unknown item in
parsed nickname: $unit"
}
}
}
if { $user_name_str != "" } {
set title "${title}${user_name_str}, "
} else {
set title "${title}${user_login}, "
}
$top insert text end "\n"
incr nroflines
if { $shares_cam == 1 } {
#the image aligned-right to the text
set Xcoord [expr {[winfo width $top] - [image
width $camicon]}]
$top create image $Xcoord $Ycoord -anchor nw
-image $camicon -tags [list camicon camicon_$user_login] -state normal
#If clicked, invite the user to send webcam
$top bind camicon_$user_login <Button-1>
"::MSNCAM::AskWebcamQueue $user_login"
#add the balloon-binding
$top bind camicon <Enter> [list balloon_enter
%W %X %Y "[trans askwebcam]"]
$top bind camicon <Motion> [list balloon_motion
%W %X %Y "[trans askwebcam]"]
$top bind camicon <Leave> "set Bulle(first) 0;
kill_balloon"
#change the cursor
$top bind camicon <Enter> "+$top configure
-cursor hand2"
$top bind camicon <Leave> "+$top configure
-cursor left_ptr"
}
}
bind $top <Configure> [list ::ChatWindow::TopUpdate $chatid]
#Change color of top background by the status of the contact
ChangeColorState $user_list $user_state $state_code ${win_name}
set title [EscapeTitle [string replace $title end-1 end " -
[trans chat]"]]
#Calculate number of lines, and set top text size
set ::ChatWindow::titles(${win_name}) ${title}
# delete the last newline...
set last_char [$top index text end]
incr last_char -1
$top dchars text $last_char end
$top configure -height [expr {[MeasureTextCanvas $top "text"
"h"] + 2*[::skin::getKey topbarpady]}]
if { [GetContainerFromWindow $win_name] == "" } {
if { [info exists
::ChatWindow::new_message_on(${win_name})] &&
$::ChatWindow::new_message_on(${win_name}) == "asterisk" } {
wm title ${win_name} "*${title}"
} else {
wm title ${win_name} ${title}
}
} else {
NameTabButton $win_name $chatid
}
if { $scrolling } { catch {::ChatWindow::Scroll
[::ChatWindow::GetOutText ${win_name}]} }
#PostEvent 'TopUpdate'
set evPar(chatid) "chatid"
set evPar(win_name) "win_name"
set evPar(user_list) "user_list"
::plugins::PostEvent TopUpdate evPar
update idletasks
after cancel [list ::ChatWindow::TopUpdate $chatid]
}
------- gui.tcl
# The same as the previous one, but this proc works on a list.
proc trunc_list {str {window ""} {maxw 0 } {font ""}} {
if { $window == "" || $font == "" || [::config::getKey
truncatenames]!=1} {
return $str
}
set buffer [list ]
foreach elt $str {
switch [lindex $elt 0] {
text {
set txt [lindex $elt 1]
set slen [string length $txt]
for {set idx 0} { $idx <= $slen} {incr idx} {
if { [font measure $font -displayof
$window "[string range $txt 0 $idx]..."] > $maxw } {
set txt "[string range $txt 0
$idx-1]"
lappend buffer [list text $txt]
[list colour reset] [list font reset] [list text "..."]
return $buffer
}
}
set maxw [expr {$maxw - [font measure $font
-displayof $window $txt]}]
lappend buffer $elt
}
smiley {
set maxw [expr {$maxw - [image width [lindex
$elt 1]]}]
if {$maxw <= 0 } {
lappend buffer [list colour reset]
[list font reset] [list text "..."]
return $buffer
}
lappend buffer $elt
}
#what should we do in that case ???
newline {}
default {
lappend buffer $elt
}
}
}
return $str
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Amsn-devel mailing list
Amsn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amsn-devel