[Tkabber-dev] r916 - in trunk/tkabber-plugins: . whiteboard

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Feb 10 02:48:15 MSK 2007


Author: sergei
Date: 2007-02-10 02:48:13 +0300 (Sat, 10 Feb 2007)
New Revision: 916

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/whiteboard/svgrender.tcl
   trunk/tkabber-plugins/whiteboard/whiteboard.tcl
Log:
	* whiteboard/whiteboard.tcl, whiteboard/svgrender.tcl: Added
	  balloons, which show when the whiteboard item was created, and
	  who has drawn it.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-02-09 21:33:53 UTC (rev 915)
+++ trunk/tkabber-plugins/ChangeLog	2007-02-09 23:48:13 UTC (rev 916)
@@ -1,3 +1,9 @@
+2006-02-10  Sergei Golovan <sgolovan at nes.ru>
+
+	* whiteboard/whiteboard.tcl, whiteboard/svgrender.tcl: Added
+	  balloons, which show when the whiteboard item was created, and
+	  who has drawn it.
+
 2006-02-09  Sergei Golovan <sgolovan at nes.ru>
 
 	* iconsets/iconsets.tcl, iconsets/*: Moved borrowed iconsets to

Modified: trunk/tkabber-plugins/whiteboard/svgrender.tcl
===================================================================
--- trunk/tkabber-plugins/whiteboard/svgrender.tcl	2007-02-09 21:33:53 UTC (rev 915)
+++ trunk/tkabber-plugins/whiteboard/svgrender.tcl	2007-02-09 23:48:13 UTC (rev 916)
@@ -37,28 +37,31 @@
     set transform {}
     switch -- $tag {
 	rect {
-	    parse_rect $c $transform $vars $item
+	    return [parse_rect $c $transform $vars $item]
 	}
 	line {
-	    parse_line $c $transform {} $item
+	    return [parse_line $c $transform {} $item]
 	}
 	polyline {
-	    parse_polyline $c $transform $item
+	    return [parse_polyline $c $transform $item]
 	}
 	polygon {
-	    parse_polygon $c $transform $item
+	    return [parse_polygon $c $transform $item]
 	}
 	circle {
-	    parse_circle $c $transform $item
+	    return [parse_circle $c $transform $item]
 	}
 	text {
-	    parse_text $c $transform $item
+	    return [parse_text $c $transform $item]
 	}
 	g {
 	    parse_g $c $transform $vars $children
+	    # TODO
+	    return ""
 	}
 	default {
 	    #puts "Unknown svg tag '$tag'"
+	    return ""
 	}
     }
 }

Modified: trunk/tkabber-plugins/whiteboard/whiteboard.tcl
===================================================================
--- trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2007-02-09 21:33:53 UTC (rev 915)
+++ trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2007-02-09 23:48:13 UTC (rev 916)
@@ -158,6 +158,20 @@
 		      $w.tb.selcol $w.tb.color]
     pack $w.tb.selcol -side bottom -anchor w -fill x
 
+    variable balloon
+    set balloon($chatid) 1
+    checkbutton $w.tb.balloon -text [::msgcat::mc "Show balloons"] \
+			      -variable [namespace current]::balloon($chatid)
+    pack $w.tb.balloon -side bottom -anchor w -fill x
+
+
+    $c bind all <Any-Enter>  \
+	[list [namespace current]::balloon $chatid $c enter  %X %Y]
+    $c bind all <Any-Motion> \
+	[list [namespace current]::balloon $chatid $c motion %X %Y]
+    $c bind all <Any-Leave>  \
+	[list [namespace current]::balloon $chatid $c leave  %X %Y]
+
     trace variable [namespace current]::width($chatid) w \
 	[list [namespace current]::change_width \
 	     $w.tb.color [namespace current]::width($chatid)]
@@ -167,6 +181,27 @@
     line_bind $c $chatid
 }
 
+proc wb::balloon {chatid c action X Y} {
+    variable balloon
+
+    if {!$balloon($chatid)} return
+
+    set id [$c find withtag current]
+    set tags {}
+    foreach t [$c gettags $id] {
+	if {[llength $t] == 2} {
+	    lappend tags $t
+	}
+    }
+
+    set msgs {}
+    foreach t [lsort -index 0 -integer $tags] {
+	lappend msgs [lindex $t 1]
+    }
+
+    balloon::default_balloon $c:$id $action $X $Y -text [join $msgs "\n"]
+}
+
 proc wb::select_color {but col} {
     set color [SelectColor::menu $col.color [list below $but] \
 		   -color [$col cget -background]]
@@ -278,14 +313,29 @@
 }
 
 proc wb::handle_wb {chatid from type body x} {
+    set seconds [clock seconds]
+    set format $::plugins::options(timestamp_format)
+
+    set seconds1 [clock scan "-23 hours 59 minutes" -base $seconds]
     foreach xelem $x {
 	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+
+	if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:x:delay]} {
+	    set seconds [clock scan [jlib::wrapper:getattr $vars stamp] -gmt 1]
+	    if {$seconds <= $seconds1} {
+		set format $::plugins::options(delayed_timestamp_format)
+	    }
+	}
+    }
+
+    foreach xelem $x {
+	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
 	
 	if {[cequal [jlib::wrapper:getattr $vars xmlns] tkabber:whiteboard]} {
 	    open_wb [chat::get_connid $chatid] [chat::get_jid $chatid]
 	    set w [win_id whiteboard $chatid]
 	    foreach child $children {
-		parse_item $chatid $child
+		parse_item $chatid $from $seconds [clock format $seconds -format $format] $child
 	    }
 	    tab_set_updated $w 1 message
 
@@ -295,14 +345,17 @@
 }
 hook::add draw_message_hook [namespace current]::wb::handle_wb 1
 
-proc wb::parse_item {chatid item} {
+proc wb::parse_item {chatid from seconds time item} {
     set w [win_id whiteboard $chatid]
     jlib::wrapper:splitxml $item tag vars isempty chdata children
 
     switch -- $tag {
 	svg {
 	    foreach child $children {
-		svg::parse_svg_item $w.c $child
+		set id [svg::parse_svg_item $w.c $child]
+		if {$id != ""} {
+		    $w.c addtag [list $seconds "$time created: $from"] withtag $id
+		}
 	    }
 	}
 	move {
@@ -311,6 +364,7 @@
 	    set dy [jlib::wrapper:getattr $vars dy]
 	    if {![string is double $dx] || $dx == ""} {set dx 0}
 	    if {![string is double $dy] || $dy == ""} {set dy 0}
+	    $w.c addtag [list $seconds "$time moved: $from"] withtag id$id
 	    $w.c move id$id $dx $dy
 	}
 	remove {



More information about the Tkabber-dev mailing list