[Tkabber-dev] r1571 - in trunk/tkabber-plugins: . floatingcontact floatingcontact/msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Oct 22 11:43:44 MSD 2008


Author: sergei
Date: 2008-10-22 11:43:43 +0400 (Wed, 22 Oct 2008)
New Revision: 1571

Added:
   trunk/tkabber-plugins/floatingcontact/
   trunk/tkabber-plugins/floatingcontact/README
   trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl
   trunk/tkabber-plugins/floatingcontact/msgs/
   trunk/tkabber-plugins/floatingcontact/msgs/ru.msg
Modified:
   trunk/tkabber-plugins/ChangeLog
Log:
	* floatingcontact/*: Added a new plugin which allows roster contacts
	  to float in separate small windows.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2008-10-21 14:08:21 UTC (rev 1570)
+++ trunk/tkabber-plugins/ChangeLog	2008-10-22 07:43:43 UTC (rev 1571)
@@ -1,3 +1,8 @@
+2008-10-22  Sergei Golovan <sgolovan at nes.ru>
+
+	* floatingcontact/*: Added a new plugin which allows roster contacts
+	  to float in separate small windows.
+
 2008-10-20  Sergei Golovan <sgolovan at nes.ru>
 
 	* floatinglog/floatinglog.tcl: Added messages about following

Added: trunk/tkabber-plugins/floatingcontact/README
===================================================================
--- trunk/tkabber-plugins/floatingcontact/README	                        (rev 0)
+++ trunk/tkabber-plugins/floatingcontact/README	2008-10-22 07:43:43 UTC (rev 1571)
@@ -0,0 +1,10 @@
+$Id$
+"Floating contact" - allows certain roster items to float in separate
+small windows.
+
+This plugin adds a new checkbox item in roster popup menu - "Floating
+contact". If it's checked then a small window appears with a copy
+of the contact from the roster. It is stayed on top and allows to
+follow the selected roster item presence even if Tkabber itself is
+hidden or covered by other windows.
+


Property changes on: trunk/tkabber-plugins/floatingcontact/README
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl
===================================================================
--- trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl	                        (rev 0)
+++ trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl	2008-10-22 07:43:43 UTC (rev 1571)
@@ -0,0 +1,213 @@
+###############################################################################
+# Floating Contact Plugin
+###############################################################################
+# $Id$
+
+package require msgcat
+
+namespace eval ::ifacetk::roster {
+    ::msgcat::mcload [file join [file dirname [info script]] msgs]
+
+    variable float_winid 0
+
+#   {jid1 {rjid1 1 x y rjid2 0 x y} jid2 {rjid3 0 x y rjid4 0 x y}}
+    custom::defvar floating_jids_list {} \
+		   [::msgcat::mc "Stored floating JIDs."] \
+		   -type string \
+		   -group Hidden
+}
+
+proc ::ifacetk::roster::load_float_list {xlib} {
+    variable floating_jids_list
+    variable float_is_float
+    variable float_x
+    variable float_y
+
+    array set fl $floating_jids_list
+    set bjid [connection_bare_jid $xlib]
+
+    if {![info exists fl($bjid)]} return
+
+    foreach {jid float x y} $fl($bjid) {
+	set float_is_float($xlib,$jid) $float
+	set float_x($xlib,$jid) $x
+	set float_y($xlib,$jid) $y
+	float_toggle $xlib $jid
+    }
+}
+
+hook::add connected_hook ::ifacetk::roster::load_float_list
+
+proc ::ifacetk::roster::save_float_list {xlib} {
+    variable floating_jids_list
+    variable float_is_float
+    variable float_x
+    variable float_y
+    variable float_floats
+
+    array set fl $floating_jids_list
+    set bjid [connection_bare_jid $xlib]
+
+    set fl($bjid) {}
+
+    foreach idx [array names float_is_float $xlib,*] {
+	set jid [string range $idx [string length $xlib,] end]
+	catch {destroy $float_floats($xlib,$jid)}
+	catch {unset float_floats($xlib,$jid)}
+	lappend fl($bjid) $jid \
+			  $float_is_float($xlib,$jid) \
+			  $float_x($xlib,$jid) \
+			  $float_y($xlib,$jid)
+    }
+
+    if {[llength $fl($bjid)] == 0} {
+	unset fl($bjid)
+    }
+
+    set floating_jids_list [array get fl]
+}
+
+hook::add predisconnected_hook ::ifacetk::roster::save_float_list
+
+
+###############################################################################
+
+proc ::ifacetk::roster::float_toggle {xlib jid} {
+    variable float_is_float
+    variable float_x
+    variable float_y
+    variable float_winid
+    variable float_floats
+    variable config
+    variable iroster
+
+    if {![info exists float_is_float($xlib,$jid)] || !$float_is_float($xlib,$jid)} {
+	catch {destroy $float_floats($xlib,$jid)}
+	catch {unset float_floats($xlib,$jid)}
+    } else {
+	set w [toplevel .float[incr float_winid] -relief flat -bd 1 -class Balloon]
+	$w configure -bg [option get $w foreground Balloon]
+	set float_floats($xlib,$jid) $w
+
+	wm withdraw $w
+	wm overrideredirect $w 1
+
+	catch {
+	    if {[lsearch -exact [wm attributes $w] -topmost] >= 0} {
+		wm attributes $w -topmost 1
+	    }
+	}
+
+	if {![info exists float_x($xlib,$jid)] || \
+		    ![info exists float_y($xlib,$jid)]} {
+	    set float_x($xlib,$jid) [expr {[winfo screenwidth $w] / 2}]
+	    set float_y($xlib,$jid) [expr {[winfo screenheight $w] / 2}]
+	}
+
+	wm geometry $w +$float_x($xlib,$jid)+$float_y($xlib,$jid)
+
+	canvas $w.canvas -bg $config(background) \
+			 -highlightthickness 0 \
+			 -scrollregion {0 0 0 0} \
+			 -width 0 -height 0
+	pack $w.canvas
+
+	set iroster($w,ypos) 1
+	set iroster($w,width) 0
+	set iroster($w,grouppopup) {}
+	set iroster($w,popup) [namespace current]::popup_menu
+	set iroster($w,singleclick) {}
+	set iroster($w,doubleclick) [namespace current]::jid_doubleclick
+
+	float_redraw $xlib
+
+	bind $w <ButtonPress-1> \
+		[list [namespace current]::float_start_drag $w %x %y]
+	bind $w <Button1-Motion> \
+		[list [namespace current]::float_motion_drag $w $xlib $jid %X %Y]
+
+	wm deiconify $w
+    }
+}
+
+###############################################################################
+
+proc ::ifacetk::roster::float_redraw {xlib} {
+    variable float_floats
+    variable config
+    variable iroster
+
+    foreach idx [array names float_floats $xlib,*] {
+	lassign [split $idx ,] xlib jid
+
+	set w $float_floats($idx)
+	if {![winfo exists $w]} continue
+
+	clear $w 0
+
+	set cjid [list $xlib $jid]
+	set jids [get_jids_of_user $xlib $jid]
+	set numjids [llength $jids]
+	addline $w jid [roster::get_label $xlib $jid] $cjid {} 0 $jids
+	changeicon $w $cjid [get_jid_icon $xlib $jid]
+	changeforeground $w $cjid [get_jid_foreground $xlib $jid]
+	if {$numjids > 1} {
+	    foreach subjid $jids {
+		set csubjid [list $xlib $subjid]
+		set subjid_resource [::xmpp::jid::resource $subjid]
+		if {$subjid_resource != ""} {
+		    addline $w jid2 $subjid_resource $csubjid {} 0 [list $subjid]
+		    changeicon $w $csubjid [get_jid_icon $xlib $subjid]
+		    changeforeground $w $csubjid [get_jid_foreground $xlib $subjid]
+		}
+	    }
+	}
+	$w.canvas configure \
+	    -width [expr {$iroster($w,width) + $config(jidindent)}] \
+	    -height $iroster($w,ypos)
+	update_scrollregion $w
+    }
+}
+
+###############################################################################
+
+proc ::ifacetk::roster::float_on_change_jid_presence {xlib jid type x args} {
+    after idle [list [namespace current]::float_redraw $xlib]
+}
+
+hook::add client_presence_hook ::ifacetk::roster::float_on_change_jid_presence 100
+
+###############################################################################
+proc ::ifacetk::roster::float_start_drag {w x y} {
+    variable float_savex $x
+    variable float_savey $y
+}
+
+proc ::ifacetk::roster::float_motion_drag {w xlib jid X Y} {
+    variable float_x
+    variable float_y
+    variable float_savex
+    variable float_savey
+    set float_x($xlib,$jid) [expr {$X-$float_savex}]
+    set float_y($xlib,$jid) [expr {$Y-$float_savey}]
+    wm geometry $w +$float_x($xlib,$jid)+$float_y($xlib,$jid)
+}
+
+###############################################################################
+
+proc ::ifacetk::roster::float_create_menu {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
+    if {$rjid == ""} {
+	set rjid [::xmpp::jid::stripResource $jid]
+    }
+
+    $m add checkbutton -label [::msgcat::mc "Floating contact"] \
+	   -variable [namespace current]::float_is_float($xlib,$rjid) \
+	   -command [list [namespace current]::float_toggle $xlib $rjid]
+}
+
+hook::add roster_service_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+hook::add roster_jid_popup_menu_hook ::ifacetk::roster::float_create_menu 80
+
+###############################################################################
+


Property changes on: trunk/tkabber-plugins/floatingcontact/floatingcontact.tcl
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: trunk/tkabber-plugins/floatingcontact/msgs/ru.msg
===================================================================
--- trunk/tkabber-plugins/floatingcontact/msgs/ru.msg	                        (rev 0)
+++ trunk/tkabber-plugins/floatingcontact/msgs/ru.msg	2008-10-22 07:43:43 UTC (rev 1571)
@@ -0,0 +1,2 @@
+# $Id$
+::msgcat::mcset ru "Floating contact" "Плавающий контакт"


Property changes on: trunk/tkabber-plugins/floatingcontact/msgs/ru.msg
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native



More information about the Tkabber-dev mailing list