[Tkabber-dev] r1344 - in trunk/tkabber: . ifacetk

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sat Jan 5 17:02:34 MSK 2008


Author: sergei
Date: 2008-01-05 17:02:34 +0300 (Sat, 05 Jan 2008)
New Revision: 1344

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/ifacetk/iroster.tcl
Log:
	* iface.tcl, iroster.tcl: Added simple roster filter.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-01-03 20:45:11 UTC (rev 1343)
+++ trunk/tkabber/ChangeLog	2008-01-05 14:02:34 UTC (rev 1344)
@@ -1,3 +1,7 @@
+2008-01-05  Sergei Golovan  <sgolovan at nes.ru>
+
+	* iface.tcl, iroster.tcl: Added simple roster filter.
+
 2008-01-03  Sergei Golovan  <sgolovan at nes.ru>
 
 	* chats.tcl: Fixed raising tab in case when a user clicks on "Open new

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2008-01-03 20:45:11 UTC (rev 1343)
+++ trunk/tkabber/ifacetk/iface.tcl	2008-01-05 14:02:34 UTC (rev 1344)
@@ -341,6 +341,8 @@
 			 -variable [namespace current]::roster::show_only_online] \
 		    [list checkbutton [::msgcat::mc "Show own resources"] {} {} {} \
 			 -variable [namespace current]::roster::options(show_own_resources)] \
+		    [list checkbutton [::msgcat::mc "Use roster filter"] {} {} {} \
+			 -variable [namespace current]::roster::options(use_filter)] \
 		    [list cascad [::msgcat::mc "Export roster..."] \
 			 export_roster export_roster 0 {}] \
 		    [list cascad [::msgcat::mc "Import roster..."] \
@@ -733,6 +735,7 @@
     global use_tls
     global descmenu
     variable mf
+    variable rw
     variable rosterwidth
     variable ssl_ind
     variable main_window_title
@@ -852,7 +855,7 @@
 	    -doubleclick [namespace current]::roster::jid_doubleclick \
 	    -draginitcmd [namespace current]::roster::draginitcmd \
 	    -dropcmd [namespace current]::roster::dropcmd
-	pack .roster -expand yes -fill both -side left -in $rw
+	pack .roster -expand yes -fill both -side top -in $rw -anchor w
 
 	grid columnconfigure $nw 1 -weight 1
 	grid rowconfigure $nw 1 -weight 1

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2008-01-03 20:45:11 UTC (rev 1343)
+++ trunk/tkabber/ifacetk/iroster.tcl	2008-01-05 14:02:34 UTC (rev 1344)
@@ -86,6 +86,14 @@
 	[::msgcat::mc "Add chats group in roster."] \
 	-type boolean -group Roster \
 	-command [namespace current]::redraw_after_idle
+    custom::defvar options(use_filter) 0 \
+	[::msgcat::mc "Use roster filter."] \
+	-type boolean -group Roster \
+	-command [namespace current]::pack_filter_entry
+    custom::defvar options(match_jids) 0 \
+	[::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(free_drop) 1 \
 	[::msgcat::mc "Roster item may be dropped not only over group name\
 but also over any item in group."] \
@@ -105,6 +113,10 @@
     custom::defvar show_offline_group_list {} \
 	[::msgcat::mc "Stored show offline roster groups."] \
 	-type string -group Hidden
+    custom::defvar options(filter) "" \
+	[::msgcat::mc "Roster filter."] \
+	-type string -group Hidden \
+	-command [namespace current]::redraw_after_idle
 
     variable menu_item_idx 0
 
@@ -219,6 +231,43 @@
 hook::add roster_item_hook [namespace current]::roster::process_item 90
 hook::add roster_push_hook [namespace current]::roster::process_item 90
 
+proc roster::create_filter_entry {} {
+    entry .roster_filter -textvariable [namespace current]::options(filter) \
+			 -width 1
+    pack_filter_entry
+}
+
+hook::add finload_hook [namespace current]::roster::create_filter_entry
+
+proc roster::pack_filter_entry {args} {
+    global usetabbar
+    variable options
+
+    if {$options(use_filter)} {
+	if {$usetabbar} {
+	    pack .roster_filter -before .roster \
+				-anchor w \
+				-side bottom \
+				-fill x \
+				-expand no \
+				-in $::ifacetk::rw
+	} else {
+	    grid .roster_filter -row 2 \
+				-column 1 \
+				-sticky we \
+				-in [$::ifacetk::mf getframe]
+	}
+	focus .roster_filter
+    } else {
+	if {$usetabbar} {
+	    pack forget .roster_filter
+	} else {
+	    grid forget .roster_filter
+	}
+    }
+    redraw_after_idle
+}
+
 # TODO: get rid of roster::roster
 proc roster::redraw {} {
     upvar #0 roster::aliases aliases
@@ -318,6 +367,14 @@
 	array unset jidsundergroup
 	array unset groupsundergroup
 	foreach jid [::roster::get_jids $connid] {
+	    if {$options(use_filter) && $options(filter) != ""} {
+		if {[string first $options(filter) [::roster::get_label $connid $jid]] < 0} {
+		    if {!$options(match_jids) || \
+			    [string first $options(filter) $jid] < 0} {
+			continue
+		    }
+		}
+	    }
 	    if {[info exists ignore_jid($jid)]} continue
 	    set jid_groups [::roster::itemconfig $connid $jid -group]
 	    if {![lempty $jid_groups]} {



More information about the Tkabber-dev mailing list