1 # ui-mb.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1998-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/applications/collaborator/ui-mb.tcl,v 1.4 2002/02/03 04:21:46 lim Exp $
32
33
34 #
35 UISource/Mb public build_widget { path } {
36 $self tkvar track_
37 $self instvar observer_
38 $path configure -command "tk_popup $path.menu \[winfo pointerx $path\]\
39 \[winfo pointery $path\]"
40
41 set track_ 0
42
43 menu $path.menu
44 $path.menu add checkbutton -label "Track this source" \
45 -variable [$self tkvarname track_] -command \
46 "$observer_ toggle_track_button $self"
47 }
48
49
50 UISource/Mb public toggle_track { } {
51 $self tkvar track_
52 if $track_ { set track_ 0 } else { set track_ 1 }
53 return $track_
54 }
55
56
57 #
58 Observer/Mb public init { sm srclist } {
59 $self next
60 $self instvar sm_ srclist_
61 set sm_ $sm
62 set srclist_ $srclist
63 $srclist attach_observer $self
64 }
65
66
67 Observer/Mb public toggle_track_button { uisrc } {
68 # toggle_track will make a callback to us and toggle uisrc once again
69 # to ensure that we end up in a sane state, we have to toggle ourselves
70 # explicitly here
71 $self instvar srclist_
72 $uisrc toggle_track
73 $srclist_ toggle_track [$uisrc src]
74 }
75
76
77 Observer/Mb public toggle_track { src } {
78 $self instvar msrcs_ currentTrack_
79 if ![info exists msrcs_($src)] return
80 set uisrc [$msrcs_($src) get_uisource mb $src]
81
82 if { [info exists currentTrack_] && $currentTrack_ != $uisrc } {
83 $currentTrack_ toggle_track
84 }
85
86 if ![$uisrc toggle_track] { unset currentTrack_ } \
87 else { set currentTrack_ $uisrc }
88 }
89
90
91 #
92 Observer/Mb private create_multi_source { src } {
93 $self instvar sm_ msrcs_
94
95 set sid [split [$src srcid] @]
96 # convert the address to x.x.x.x format
97 set addr [expr 0x[lindex $sid 1]]
98 set addr [binary format I $addr]
99 binary scan $addr cccc a1 a2 a3 a4
100 foreach a {a1 a2 a3 a4} {
101 # convert from signed to unsigned
102 set val [set $a]
103 set val [expr ($val + 0x100) % 0x100]
104 set $a $val
105 }
106
107 set cname "[expr 0x[lindex $sid 0]]@$a4.$a3.$a2.$a1"
108 set msrcs_($src) [$sm_ register mb $src $cname $self]
109 set uisrc [$msrcs_($src) get_uisource mb $src]
110 $src set mb_hack_cname_ $cname
111
112 $self update_src_info $src $cname
113 }
114
115
116 #
117 # Register a src in the src display. This happens for all the
118 # srcs participating in the conferencing (e.g., including
119 # those not actually sending data).
120 #
121 Observer/Mb public register { src } {
122 $self create_multi_source $src
123 }
124
125
126 #
127 # Remove a src from the src display. This happens when
128 # a party quits or has been dead for a sufficiently long time.
129 # We assume the src has already been deactivated.
130 #
131 Observer/Mb public unregister { src } {
132 }
133
134
135 #
136 # hilit the source
137 # - sets a timeout to unhilit the receiver and execute $command then
138 #
139 Observer/Mb public hilit {src} {
140 $self instvar msrcs_ id_
141 if [info exists id_($src)] {
142 after cancel $id_($src)
143 } else {
144 set uisrc [$msrcs_($src) get_uisource mb $src]
145 $uisrc highlight 1
146 }
147
148 set id_($src) [after 500 "$self unhilit $src"]
149 }
150
151
152 Observer/Mb public unhilit {src} {
153 $self instvar msrcs_ id_
154 if [info exists msrcs_($src)] {
155 set uisrc [$msrcs_($src) get_uisource mb $src]
156 $uisrc highlight 0
157 }
158 unset id_($src)
159 }
160
161
162 # change the name of a source
163 Observer/Mb public update_src_info {src name} {
164 $self instvar msrcs_
165 if { [info exists msrcs_($src)] && [$msrcs_($src) name] != $name } {
166 set uisrc [$msrcs_($src) get_uisource mb $src]
167 $msrcs_($src) change_name $uisrc $name
168 $src set mb_hack_name_ $name
169 }
170 }
171
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.