[Tkabber-dev] r1662 - in trunk/tkabber: . ifacetk msgs plugins/roster

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Feb 15 14:22:03 MSK 2009


Author: sergei
Date: 2009-02-15 14:22:02 +0300 (Sun, 15 Feb 2009)
New Revision: 1662

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/ifacetk/iroster.tcl
   trunk/tkabber/msgs/de.msg
   trunk/tkabber/plugins/roster/metacontacts.tcl
Log:
	* ifacetk/iroster.tcl: Made collapsing/expanding metacontacts or
	  multiple JID resources asynchronous if they appear in multiple
	  groups. Fixed storing info on showing offline users in roster groups.

	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).

	* ifacetk/iroster.tcl, ifacetk/iface.tcl,
	  plugins/roster/metacontacts.tcl: Added options to disable
	  metacontacts and to always show a fixed metacontact label.

	* plugins/roster/metacontacts.tcl: Fixed keyboard traversal of
	  metacontact window and started to implement items reordering.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2009-02-14 22:32:45 UTC (rev 1661)
+++ trunk/tkabber/ChangeLog	2009-02-15 11:22:02 UTC (rev 1662)
@@ -1,3 +1,18 @@
+2009-02-15  Sergei Golovan  <sgolovan at nes.ru>
+
+	* ifacetk/iroster.tcl: Made collapsing/expanding metacontacts or
+	  multiple JID resources asynchronous if they appear in multiple
+	  groups. Fixed storing info on showing offline users in roster groups.
+
+	* msgs/de.msg: Updated German translation (thanks to Roger Sondermann).
+
+	* ifacetk/iroster.tcl, ifacetk/iface.tcl,
+	  plugins/roster/metacontacts.tcl: Added options to disable
+	  metacontacts and to always show a fixed metacontact label.
+
+	* plugins/roster/metacontacts.tcl: Fixed keyboard traversal of
+	  metacontact window and started to implement items reordering.
+
 2009-02-14  Sergei Golovan  <sgolovan at nes.ru>
 
 	* chats.tcl, ifacetk/iroster.tcl: Adapted to a new syntax of roster

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2009-02-14 22:32:45 UTC (rev 1661)
+++ trunk/tkabber/ifacetk/iface.tcl	2009-02-15 11:22:02 UTC (rev 1662)
@@ -352,6 +352,8 @@
 			 -variable [namespace current]::roster::options(show_own_resources)] \
 		    [list checkbutton [::msgcat::mc "Use roster filter"] {} {} {} \
 			 -variable [namespace current]::roster::options(use_filter)] \
+		    [list checkbutton [::msgcat::mc "Enable metacontacts"] {} {} {} \
+			 -variable [namespace current]::roster::options(enable_metacontacts)] \
 		    [list cascad [::msgcat::mc "Export roster..."] \
 			 export_roster export_roster 0 {}] \
 		    [list cascad [::msgcat::mc "Import roster..."] \

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2009-02-14 22:32:45 UTC (rev 1661)
+++ trunk/tkabber/ifacetk/iroster.tcl	2009-02-15 11:22:02 UTC (rev 1662)
@@ -94,6 +94,14 @@
 	[::msgcat::mc "Match contact JIDs in addition to nicknames in roster filter."] \
 	-type boolean -group Roster \
 	-command [namespace current]::redraw_after_idle
+    custom::defvar options(enable_metacontacts) 1 \
+	[::msgcat::mc "Enable grouping contacts into a single metacontact in roster."] \
+	-type boolean -group Roster \
+	-command [namespace current]::redraw_after_idle
+    custom::defvar options(enable_metacontact_labels) 1 \
+	[::msgcat::mc "Always use main JID label for metacontact."] \
+	-type boolean -group Roster \
+	-command [namespace current]::redraw_after_idle
     custom::defvar options(free_drop) 1 \
 	[::msgcat::mc "Roster item may be dropped not only over group name\
 but also over any item in group."] \
@@ -152,7 +160,11 @@
 
     if {[info exists s($jid)]} {
 	foreach {group val} $s($jid) {
-	    set gid [list $xlib $group]
+	    if {$options(nested)} {
+		set gid [list $xlib [msplit $group $options(nested_delimiter)]]
+	    } else {
+		set gid [list $xlib [list $group]]
+	    }
 	    set roster(show_offline,$gid) $val
 	}
     }
@@ -314,7 +326,8 @@
 	array unset metagroups
 	array unset groups_from_meta
 	set metacontacted {}
-	if {[llength [info procs ::plugins::metacontacts::*]] > 0} {
+	if {$options(enable_metacontacts) && \
+		[llength [info procs ::plugins::metacontacts::*]] > 0} {
 	    foreach tag [::plugins::metacontacts::get_all_tags $xlib] {
 		set jids [::plugins::metacontacts::get_jids $xlib $tag]
 		set metagroups($tag) {}
@@ -657,7 +670,14 @@
 			    set jids [lsort -unique $jids]
 			    set numjids [llength $jids]
 
-			    if {$numjids > 1} {
+			    if {$options(enable_metacontact_labels)} {
+				set tag [lindex $metajids($jid) 0]
+				set mjid [lindex [::plugins::metacontacts::get_jids $xlib $tag] 0]
+				set label [::roster::get_label $xlib $mjid]
+			    }
+
+			    if {($options(enable_metacontact_labels) && $numjids > 0) || \
+				    $numjids > 1} {
 				# Draw as a metacontact
 				if {$config(subitemtype) & 1} {
 				    append label " ($numjids)"
@@ -667,7 +687,7 @@
 					        [get_jid_icon $xlib $jid] \
 					        [get_jid_foreground $xlib $jid]
 
-				if {!$roster(metacollapsed,[list $xlib $metajids($jid)])} {
+				if {!$roster(metacollapsed,$gid,[list $xlib $metajids($jid)])} {
 				    set subjid_labels {}
 				    foreach subjid $jids {
 					lappend subjid_labels \
@@ -721,7 +741,7 @@
 			[get_jid_icon $xlib $jid] \
 			[get_jid_foreground $xlib $jid]
 
-	if {!$roster(jidcollapsed,$cjid)} {
+	if {!$roster(jidcollapsed,$gid,$cjid)} {
 	    foreach subjid $jids {
 		set subjid_resource [::xmpp::jid::resource $subjid]
 		if {$subjid_resource != ""} {
@@ -1124,12 +1144,12 @@
 				  -anchor w \
 				  -tags [list jid$tag group$grouptag meta$metatag $type icon]
 
-	    if {[llength $jids] > 1} {
-		if {[info exists roster(metacollapsed,$metajids)] && \
-			!$roster(metacollapsed,$metajids)} {
+	    if {[llength $jids] > 0} {
+		if {[info exists roster(metacollapsed,$group,$metajids)] && \
+			!$roster(metacollapsed,$group,$metajids)} {
 		    set jid_state opened
 		} else {
-		    set roster(metacollapsed,$metajids) 1
+		    set roster(metacollapsed,$group,$metajids) 1
 		    set jid_state closed
 		}
 		if {$config(subitemtype) > 0 && ($config(subitemtype) & 2)} {
@@ -1140,7 +1160,7 @@
 					  -tags [list jid$tag group$grouptag meta$metatag $type group]
 		}
 	    } else {
-		set roster(metacollapsed,$metajids) 1
+		set roster(metacollapsed,$group,$metajids) 1
 	    }
 	}
 	jid {
@@ -1161,10 +1181,10 @@
 				  -tags [list jid$tag group$grouptag meta$metatag $type icon]
 
 	    if {[llength $jids] > 1} {
-		if {[info exists roster(jidcollapsed,$jid)] && !$roster(jidcollapsed,$jid)} {
+		if {[info exists roster(jidcollapsed,$group,$jid)] && !$roster(jidcollapsed,$group,$jid)} {
 		    set jid_state opened
 		} else {
-		    set roster(jidcollapsed,$jid) 1
+		    set roster(jidcollapsed,$group,$jid) 1
 		    set jid_state closed
 		}
 		if {$config(subitemtype) > 0 && ($config(subitemtype) & 2) && $isuser} {
@@ -1175,7 +1195,7 @@
 					  -tags [list jid$tag group$grouptag meta$metatag $type group]
 		}
 	    } else {
-		set roster(jidcollapsed,$jid) 1
+		set roster(jidcollapsed,$group,$jid) 1
 	    }
 	}
 	jid2 {
@@ -1662,22 +1682,27 @@
 ###############################################################################
 
 proc roster::user_singleclick {tags cjid jids} {
+    variable options
     variable roster
 
     lassign $cjid xlib jid
     set type [lindex $tags 3]
+    set cgroup [tag_to_jid [string range [lindex $tags 1] 5 end]]
     set cmeta [tag_to_jid [string range [lindex $tags 2] 4 end]]
 
     switch -- $type {
 	metajid {
-	    if {[llength $jids] > 1} {
-		set roster(metacollapsed,$cmeta) [expr {!$roster(metacollapsed,$cmeta)}]
+	    if {[llength $jids] > 1 || \
+		    ($options(enable_metacontact_labels) && [llength $jids] > 0)} {
+		set roster(metacollapsed,$cgroup,$cmeta) \
+		    [expr {!$roster(metacollapsed,$cgroup,$cmeta)}]
 		redraw_after_idle
 	    }
 	}
 	default {
 	    if {[roster::itemconfig $xlib $jid -isuser] && [llength $jids] > 1} {
-		set roster(jidcollapsed,$cjid) [expr {!$roster(jidcollapsed,$cjid)}]
+		set roster(jidcollapsed,$cgroup,$cjid) \
+		    [expr {!$roster(jidcollapsed,$cgroup,$cjid)}]
 		redraw_after_idle
 	    }
 	}
@@ -1791,10 +1816,12 @@
 	    cascade {
 		set label [$m1 entrycget $i -label]
 		set menu [$m1 entrycget $i -menu]
+		set state [$m1 entrycget $i -state]
 		set suffix2 [join [lrange [split $menu .] 2 end] .]
 		set suffix3 [lindex [split $menu .] end]
 		set m2 [menu $m.$suffix3 -tearoff 0]
-		$m add cascade -label $label -menu $m2
+		# TODO: Check if state is the same for all menus
+		$m add cascade -label $label -menu $m2 -state $state
 		add_menu_submenu $m2 $prefix .$suffix2 $jids
 	    }
 	    checkbutton {

Modified: trunk/tkabber/msgs/de.msg
===================================================================
--- trunk/tkabber/msgs/de.msg	2009-02-14 22:32:45 UTC (rev 1661)
+++ trunk/tkabber/msgs/de.msg	2009-02-15 11:22:02 UTC (rev 1662)
@@ -1,6 +1,6 @@
 
 # German messages file
-# Roger Sondermann 14.02.2009
+# Roger Sondermann 15.02.2009
 
 # .../chats.tcl
 ::msgcat::mcset de "%s has changed nick to %s."                             "%s hat seinen Nicknamen geändert in %s"
@@ -1603,14 +1603,14 @@
 ::msgcat::mcset de "Fetch nicknames of all users in group"                  "Nicknamen von allen Kontakten der Gruppe abrufen"
 
 # .../plugins/roster/metacontacts.tcl
-::msgcat::mcset de "Are you sure to delete this metacontact?"               "Soll dieser MetaContact wirklich gelöscht werden?"
-::msgcat::mcset de "Create metacontact"                                     "MetaContact erstellen"
-::msgcat::mcset de "Delete metacontact..."                                  "MetaContact löschen..."
-::msgcat::mcset de "Edit Metacontact"                                       "MetaContact ändern"
-::msgcat::mcset de "Edit metacontact"                                       "MetaContact ändern"
-::msgcat::mcset de "Metacontact"                                            "MetaContact"
-::msgcat::mcset de "Remove from metacontact"                                "Von MetaContact entfernen"
-::msgcat::mcset de "Storing roster metacontacts failed: %s"                 "Sichern der Roster-MetaContacte misslungen: %s"
+::msgcat::mcset de "Are you sure to delete this metacontact?"               "Soll dieser Meta-Kontakt wirklich gelöscht werden?"
+::msgcat::mcset de "Create metacontact"                                     "Meta-Kontakt erstellen"
+::msgcat::mcset de "Delete metacontact..."                                  "Meta-Kontakt löschen..."
+::msgcat::mcset de "Edit Metacontact"                                       "Meta-Kontakt ändern"
+::msgcat::mcset de "Edit metacontact"                                       "Meta-Kontakt ändern"
+::msgcat::mcset de "Metacontact"                                            "Meta-Kontakt"
+::msgcat::mcset de "Remove from metacontact"                                "Von Meta-Kontakt entfernen"
+::msgcat::mcset de "Storing roster metacontacts failed: %s"                 "Sichern der Roster-Meta-Kontakte misslungen: %s"
 
 # .../plugins/roster/rosterx.tcl
 ::msgcat::mcset de "Attached user:"                                         "Angehängter Kontakt:"

Modified: trunk/tkabber/plugins/roster/metacontacts.tcl
===================================================================
--- trunk/tkabber/plugins/roster/metacontacts.tcl	2009-02-14 22:32:45 UTC (rev 1661)
+++ trunk/tkabber/plugins/roster/metacontacts.tcl	2009-02-15 11:22:02 UTC (rev 1662)
@@ -209,7 +209,7 @@
     pack $tools -side bottom -fill x
     
     set sw [ScrolledWindow $w.sw]
-    set lf [listbox $w.fields]
+    set lf [listbox $w.fields -selectmode single]
     pack $sw -side top -expand yes -fill both -in $f -pady 1m -padx 1m
     $sw setwidget $lf
 
@@ -223,14 +223,23 @@
     pack $additem -side right -padx 1m
     pack $addentry -side left -padx 1m -fill x -expand yes
 
+    lower $lf $additem
+    lower $sw
+    lower $f
+
     if {[info exists contacts($xlib,jids,$tag)]} {
 	eval {$lf insert end} $contacts($xlib,jids,$tag)
     } elseif {$jid != ""} {
 	$lf insert end $jid
     }
 
+    focus $lf
+
     DropSite::register $lf -dropcmd [namespace code [list dropcmd]] \
 			   -droptypes {JID}
+
+    DragSite::register $lf -draginitcmd [namespace code [list draginitcmd]]
+
     $w draw
 }
 
@@ -250,6 +259,10 @@
     add_jid $target [lindex $data 1]
 }
 
+proc metacontacts::draginitcmd {target x y top} {
+    return {}
+}
+
 proc metacontacts::select_and_popup_menu {f x y} {
     set index [$f index @$x,$y]
     $f selection clear 0 end
@@ -326,7 +339,7 @@
     variable contacts
 
     set rjid [roster::find_jid $xlib $jid]
-    if {$rjid == ""} {
+    if {$rjid == "" || !$::ifacetk::roster::options(enable_metacontacts)} {
 	set tag ""
 	set state disabled
 	set state1 disabled



More information about the Tkabber-dev mailing list