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

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Feb 10 15:27:07 MSK 2007


Author: sergei
Date: 2007-02-10 15:27:03 +0300 (Sat, 10 Feb 2007)
New Revision: 917

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/whiteboard/msgs/ru.msg
   trunk/tkabber-plugins/whiteboard/whiteboard.tcl
Log:
	* whiteboard/whiteboard.tcl, whiteboard/svgrender.tcl:
	  Also redone text input dialog.

	* whiteboard/msgs/ru.msg: Updated.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2007-02-09 23:48:13 UTC (rev 916)
+++ trunk/tkabber-plugins/ChangeLog	2007-02-10 12:27:03 UTC (rev 917)
@@ -2,8 +2,10 @@
 
 	* whiteboard/whiteboard.tcl, whiteboard/svgrender.tcl: Added
 	  balloons, which show when the whiteboard item was created, and
-	  who has drawn it.
+	  who has drawn it. Also redone text input dialog.
 
+	* whiteboard/msgs/ru.msg: Updated.
+
 2006-02-09  Sergei Golovan <sgolovan at nes.ru>
 
 	* iconsets/iconsets.tcl, iconsets/*: Moved borrowed iconsets to

Modified: trunk/tkabber-plugins/whiteboard/msgs/ru.msg
===================================================================
--- trunk/tkabber-plugins/whiteboard/msgs/ru.msg	2007-02-09 23:48:13 UTC (rev 916)
+++ trunk/tkabber-plugins/whiteboard/msgs/ru.msg	2007-02-10 12:27:03 UTC (rev 917)
@@ -3,6 +3,7 @@
 ::msgcat::mcset ru "Cancel" "Отменить"
 ::msgcat::mcset ru "Circle" "Окружность"
 ::msgcat::mcset ru "Clear" "Очистить"
+::msgcat::mcset ru "Enter text" "Введите текст"
 ::msgcat::mcset ru "Fill color" "Цвет заливки"
 ::msgcat::mcset ru "Fill" "Заливать"
 ::msgcat::mcset ru "FreeHand" "Кривая"
@@ -14,6 +15,9 @@
 ::msgcat::mcset ru "PolyLine" "Ломаная"
 ::msgcat::mcset ru "Remove" "Удалить"
 ::msgcat::mcset ru "Save..." "Сохранить..."
+::msgcat::mcset ru "Show balloons" "Показывать подск."
+::msgcat::mcset ru "%s created: %s" "%s создано: %s"
+::msgcat::mcset ru "%s moved: %s" "%s перемещено: %s"
 ::msgcat::mcset ru "%s whiteboard" "%s доска"
 ::msgcat::mcset ru "Text color" "Цвет текста"
 ::msgcat::mcset ru "Text font" "Шрифт текста"

Modified: trunk/tkabber-plugins/whiteboard/whiteboard.tcl
===================================================================
--- trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2007-02-09 23:48:13 UTC (rev 916)
+++ trunk/tkabber-plugins/whiteboard/whiteboard.tcl	2007-02-10 12:27:03 UTC (rev 917)
@@ -91,7 +91,8 @@
 		      -command [list [namespace current]::remove_bind \
 				    $c $chatid]]
 
-    pack $tbpolyline $tbfreehand $tbcircle $tbpolygon $tbtext $tbmove $tbremove -anchor w
+    pack $tbpolyline $tbfreehand $tbcircle $tbpolygon $tbtext $tbmove $tbremove \
+	 -anchor w
 
     button $w.tb.clear -text [::msgcat::mc "Clear"] \
 	-command [list [namespace current]::send_clear $chatid]
@@ -218,7 +219,8 @@
     if {[string length $font_desc] == 0} return
 
     if {![info exists app_font($font_desc)]} {
-        set app_font($font_desc) [eval font create [list $font_desc] [font actual $font_desc]]
+        set app_font($font_desc) \
+	    [eval font create [list $font_desc] [font actual $font_desc]]
     }
     $col configure -font $app_font($font_desc)
 }
@@ -314,17 +316,11 @@
 
 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)
-	    }
 	}
     }
 
@@ -335,7 +331,7 @@
 	    open_wb [chat::get_connid $chatid] [chat::get_jid $chatid]
 	    set w [win_id whiteboard $chatid]
 	    foreach child $children {
-		parse_item $chatid $from $seconds [clock format $seconds -format $format] $child
+		parse_item $chatid $from $seconds $child
 	    }
 	    tab_set_updated $w 1 message
 
@@ -345,7 +341,7 @@
 }
 hook::add draw_message_hook [namespace current]::wb::handle_wb 1
 
-proc wb::parse_item {chatid from seconds time item} {
+proc wb::parse_item {chatid from seconds item} {
     set w [win_id whiteboard $chatid]
     jlib::wrapper:splitxml $item tag vars isempty chdata children
 
@@ -354,7 +350,7 @@
 	    foreach child $children {
 		set id [svg::parse_svg_item $w.c $child]
 		if {$id != ""} {
-		    $w.c addtag [list $seconds "$time created: $from"] withtag $id
+		    $w.c addtag [time_tag created $from $seconds] withtag $id
 		}
 	    }
 	}
@@ -364,7 +360,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 addtag [time_tag moved $from $seconds] withtag id$id
 	    $w.c move id$id $dx $dy
 	}
 	remove {
@@ -377,6 +373,33 @@
 }
 
 ###############################################################################
+
+proc wb::time_tag {type jid {seconds ""}} {
+    set seconds_now [clock seconds]
+    set format $::plugins::options(timestamp_format)
+
+    set seconds_day_before [clock scan "-23 hours 59 minutes" -base $seconds_now]
+    if {$seconds == ""} {
+	set seconds $seconds_now
+    }
+    if {$seconds <= $seconds_day_before} {
+	set format $::plugins::options(delayed_timestamp_format)
+    }
+    set time [clock format $seconds -format $format]
+    switch -- $type {
+	created {
+	    return [list $seconds [::msgcat::mc "%s created: %s" $time $jid]]
+	}
+	moved {
+	    return [list $seconds [::msgcat::mc "%s moved: %s" $time $jid]]
+	}
+	default {
+	    return ""
+	}
+    }
+}
+
+###############################################################################
 # Line
 
 proc wb::line_bind {c jid} {
@@ -425,7 +448,7 @@
 }
 
 
-proc wb::line_b3 {c jid} {
+proc wb::line_b3 {c chatid} {
     variable line
 
     catch {
@@ -434,24 +457,26 @@
 	set id [create_id]
 	catch {$c delete $line(temp)}
 	set line(temp) [eval $c create line $line(coords) $line(options) \
-			   -tag id$id]
+				-tag id$id]
 
-	if {[chat::is_groupchat $jid]} {
+	if {[chat::is_groupchat $chatid]} {
 	    $c delete $line(temp)
+	} else {
+	    set jid [jlib::connection_jid [chat::get_connid $chatid]]
+	    $c addtag [time_tag created $jid] withtag $line(temp)
 	}
 
 	lappend vars points $line(coords)
-	if {[set color [get_color $jid]] != "#000000"} {
+	if {[set color [get_color $chatid]] != "#000000"} {
 	    lappend vars stroke $color
 	}
-	if {[set width [get_width $jid]] != 1} {
+	if {[set width [get_width $chatid]] != 1} {
 	    lappend vars stroke-width $width
 	}
 
 	lappend vars id $id
 
-	send_svg $jid [jlib::wrapper:createtag polyline \
-			   -vars $vars]
+	send_svg $chatid [jlib::wrapper:createtag polyline -vars $vars]
 
 	set line(coords) {}
 	set line(temp) {}
@@ -491,7 +516,9 @@
 	if {$dofill == 1} {
 	    set polygon(temp) [eval $c create polygon $polygon(coords) $polygon(options)]
 	} else {
-	    set polygon(temp) [eval $c create line $polygon(coords) [lindex $polygon(coords) 0] [lindex $polygon(coords) 1] $polygon(line_options)]
+	    set polygon(temp) [eval $c create line $polygon(coords) \
+				       [lindex $polygon(coords) 0] \
+				       [lindex $polygon(coords) 1] $polygon(line_options)]
 	}
     } else {
 	set polygon(drawed) 1
@@ -529,7 +556,7 @@
 }
 
 
-proc wb::polygon_b3 {c jid} {
+proc wb::polygon_b3 {c chatid} {
     variable polygon
     variable line1
     variable line2
@@ -544,30 +571,37 @@
 	catch {$c delete $polygon(temp)}
 	if {[llength $polygon(coords)] > 4} {
 	    if {$dofill == 1} {
-		set polygon(temp) [eval $c create polygon $polygon(coords) $polygon(options) \
-			   -tag id$id]
+		set polygon(temp) \
+		    [eval $c create polygon $polygon(coords) $polygon(options) \
+			     -tag id$id]
 	    } else {
-	    	set polygon(temp) [eval $c create line $polygon(coords) [lindex $polygon(coords) 0] [lindex $polygon(coords) 1] $polygon(line_options) \
-		                           -tag id$id]
+	    	set polygon(temp) \
+		    [eval $c create line $polygon(coords) \
+			     [lindex $polygon(coords) 0] \
+			     [lindex $polygon(coords) 1] \
+			     $polygon(line_options) \
+		             -tag id$id]
 	    }
 
-	    if {[chat::is_groupchat $jid]} {
+	    if {[chat::is_groupchat $chatid]} {
 		$c delete $polygon(temp)
+	    } else {
+		set jid [jlib::connection_jid [chat::get_connid $chatid]]
+		$c addtag [time_tag created $jid] withtag $polygon(temp)
 	    }
 
 	    lappend vars points $polygon(coords)
 	    if {$dofill == 1} {
-		lappend vars fill [get_fill_color $jid]
+		lappend vars fill [get_fill_color $chatid]
 	    }
-	    lappend vars stroke [get_color $jid]
-	    if {[set width [get_width $jid]] != 1} {
+	    lappend vars stroke [get_color $chatid]
+	    if {[set width [get_width $chatid]] != 1} {
 		lappend vars stroke-width $width
 	    }
 
 	    lappend vars id $id
 
-	    send_svg $jid [jlib::wrapper:createtag polygon \
-			   -vars $vars]
+	    send_svg $chatid [jlib::wrapper:createtag polygon -vars $vars]
 	}
 	set polygon(coords) {}
 	set polygon(temp) {}
@@ -606,7 +640,7 @@
     }
 }
 
-proc wb::circle_b1r {c jid x y} {
+proc wb::circle_b1r {c chatid x y} {
     variable circle
     global dofill
 
@@ -626,23 +660,31 @@
         lappend vars cx $cx
 	lappend vars cy $cy
 	lappend vars r $r
-        if {[set color [get_color $jid]] != "#000000"} {
+        if {[set color [get_color $chatid]] != "#000000"} {
 	   lappend vars stroke $color
 	}
 	if {$dofill == 1} {
-	   lappend vars fill [get_fill_color $jid]
+	   lappend vars fill [get_fill_color $chatid]
 	}
-	if {[set width [get_width $jid]] != 1} {
+	if {[set width [get_width $chatid]] != 1} {
 	   lappend vars stroke-width $width
 	}
 
         lappend vars id $id
 
         catch {$c delete $circle(temp)}
-        set circle(temp) [eval $c create oval $x1 $y1 $x2 $y2 $circle(options) -tag id$id]
-		send_svg $jid [jlib::wrapper:createtag circle \
-	                           -vars $vars]
+        set circle(temp) [eval $c create oval $x1 $y1 $x2 $y2 $circle(options) \
+				  -tag id$id]
+	    
+	if {[chat::is_groupchat $chatid]} {
+	    $c delete $circle(temp)
+	} else {
+	    set jid [jlib::connection_jid [chat::get_connid $chatid]]
+	    $c addtag [time_tag created $jid] withtag $circle(temp)
+	}
 
+	send_svg $chatid [jlib::wrapper:createtag circle -vars $vars]
+
         set circle(center) {}
         set circle(temp) {}
     }
@@ -722,7 +764,7 @@
 }
 
 
-proc wb::freehand_b1r {c jid} {
+proc wb::freehand_b1r {c chatid} {
     variable line
 
     catch {
@@ -733,21 +775,24 @@
 	set line(temp) [eval $c create line $line(coords) $line(options) \
 			    -tag id$id]
 
-	if {[chat::is_groupchat $jid]} {
+	if {[chat::is_groupchat $chatid]} {
 	    $c delete $line(temp)
+	} else {
+	    set jid [jlib::connection_jid [chat::get_connid $chatid]]
+	    $c addtag [time_tag created $jid] withtag $line(temp)
 	}
 
 	lappend vars points $line(coords)
-	if {[set color [get_color $jid]] != "#000000"} {
+	if {[set color [get_color $chatid]] != "#000000"} {
 	    lappend vars stroke $color
 	}
-	if {[set width [get_width $jid]] != 1} {
+	if {[set width [get_width $chatid]] != 1} {
 	    lappend vars stroke-width $width
 	}
 
 	lappend vars id $id
 
-	send_svg $jid [jlib::wrapper:createtag polyline \
+	send_svg $chatid [jlib::wrapper:createtag polyline \
 			   -vars $vars]
 
 	set line(coords) {}
@@ -871,6 +916,8 @@
 		[expr {$move(startx) - $x}] [expr {$move(starty) - $y}]
 	} else {
 	    set type chat
+	    set jid [jlib::connection_jid [chat::get_connid $chatid]]
+	    $c addtag [time_tag moved $jid] withtag id$id
 	}
 
 	set vars [list id $id \
@@ -893,84 +940,89 @@
 # Text
 
 proc wb::text_bind {c chatid} {
-	bind $c <ButtonPress-1> {}
-	bind $c <B1-Motion> {}
-	bind $c <ButtonRelease-1> \
-		[list [namespace current]::text_b1 [double% $c] [double% $chatid] %x %y]
-	bind $c <Button-3> {}
+    bind $c <ButtonPress-1> {}
+    bind $c <B1-Motion> {}
+    bind $c <ButtonRelease-1> \
+	    [list [namespace current]::text_b1 [double% $c] [double% $chatid] %x %y]
+    bind $c <Button-3> {}
 }
 
 proc wb::text_b1 {c chatid x y} {
-	variable text_info
-	set text_info(x) $x
-	set text_info(y) $y
-	set w [win_id whiteboard $chatid]
-	if {[winfo exists $w.text_dialog]} {
-		wm deiconify $w.text_dialog
-	} else {
-		toplevel $w.text_dialog
-		entry $w.text_dialog.text -width 80 \
-			-textvariable [namespace current]::text_entered($chatid)
-		pack $w.text_dialog.text -side top
-		button $w.text_dialog.okButton -text [::msgcat::mc "OK"] \
-			-command [list [namespace current]::text_ok $c $chatid]
-		button $w.text_dialog.cancelButton -text [::msgcat::mc "Cancel"] \
-			-command [list wm withdraw $w.text_dialog]
-		bind $w.text_dialog.text <Return> \
-			[list [namespace current]::text_ok $c $chatid]
-		pack $w.text_dialog.okButton -side left -anchor e
-		pack $w.text_dialog.cancelButton -anchor w
-	}
-	focus $w.text_dialog.text
+    variable text_info
+    set text_info(x) $x
+    set text_info(y) $y
+    set w [win_id whiteboard $chatid]
+    set wt $w.text_dialog
+    if {[winfo exists $wt]} {
+	wm deiconify $wt
+    } else {
+	Dialog $wt -anchor e \
+		   -separator yes \
+		   -title [::msgcat::mc "Enter text"] \
+		   -side bottom \
+		   -modal none \
+		   -default 0 \
+		   -cancel 1
+	$wt add -text [::msgcat::mc "OK"] \
+	    -command [list [namespace current]::text_ok $wt $c $chatid]
+	$wt add -text [::msgcat::mc "Cancel"] \
+	    -command [list wm withdraw $wt]
+
+	set en [entry $wt.text -width 80 \
+		    -textvariable [namespace current]::text_entered($chatid)]
+	pack $en -side top -in [$wt getframe]
+	$wt draw $en
+    }
 }
 
-proc wb::text_ok {c chatid} {
-	variable app_font
-	variable text_info
-	set id [create_id]
+proc wb::text_ok {wt c chatid} {
+    variable app_font
+    variable text_info
+    set id [create_id]
 
-	set text [set [namespace current]::text_entered($chatid)]
-	if {[chat::is_groupchat $chatid]} {
-		set type groupchat
-	} else {
-		set type chat
-		$c create text $text_info(x) $text_info(y) -tag id$id \
-			-text $text \
-			-fill [get_text_color $chatid]
-		set font [get_text_font $chatid]
-		if {[info exists app_font($font)]} {
-			$c itemconfigure id$id -font $font
-		}
-	}
-	set vars [list id $id x $text_info(x) y $text_info(y) \
-		fill [get_text_color $chatid]]
+    set text [set [namespace current]::text_entered($chatid)]
+    if {[chat::is_groupchat $chatid]} {
+	set type groupchat
+    } else {
+	set type chat
+	$c create text $text_info(x) $text_info(y) -tag id$id \
+	    -text $text \
+	    -fill [get_text_color $chatid]
 	set font [get_text_font $chatid]
 	if {[info exists app_font($font)]} {
-		array set font_opt [font configure $font]
-		lappend vars font-size $font_opt(-size) \
-			font-family $font_opt(-family)
-		if {$font_opt(-underline) || $font_opt(-overstrike)} {
-			set dec {}
-			if {$font_opt(-underline)} {
-				lappend dec underline
-			}
-			if {$font_opt(-overstrike)} {
-				lappend dec line-through
-			}
-			lappend vars text-decoration $dec
-		}
-		if {[string equal $font_opt(-slant) italic]} {
-			lappend vars font-style italic
-		}
-		if {[string equal $font_opt(-weight) bold]} {
-			lappend vars font-weight bold
-		}
-		unset font_opt
+	    $c itemconfigure id$id -font $font
 	}
-	send_svg $chatid [jlib::wrapper:createtag text \
-			   -vars $vars -chdata $text]
-	set w [win_id whiteboard $chatid]
-	wm withdraw $w.text_dialog
+	set jid [jlib::connection_jid [chat::get_connid $chatid]]
+	$c addtag [time_tag created $jid] withtag id$id
+    }
+    set vars [list id $id x $text_info(x) y $text_info(y) \
+		   fill [get_text_color $chatid]]
+    set font [get_text_font $chatid]
+    if {[info exists app_font($font)]} {
+	array set font_opt [font configure $font]
+	lappend vars font-size $font_opt(-size) \
+		     font-family $font_opt(-family)
+	if {$font_opt(-underline) || $font_opt(-overstrike)} {
+	    set dec {}
+	    if {$font_opt(-underline)} {
+		lappend dec underline
+	    }
+	    if {$font_opt(-overstrike)} {
+		lappend dec line-through
+	    }
+	    lappend vars text-decoration $dec
+	}
+	if {[string equal $font_opt(-slant) italic]} {
+	    lappend vars font-style italic
+	}
+	if {[string equal $font_opt(-weight) bold]} {
+	    lappend vars font-weight bold
+	}
+	unset font_opt
+    }
+
+    send_svg $chatid [jlib::wrapper:createtag text -vars $vars -chdata $text]
+    wm withdraw $wt
 }
 
 



More information about the Tkabber-dev mailing list