1 # ui-srclist.tcl --
2 #
3 # A toplevel window for displaying a list of the sources currently
4 # participating in the session.
5 #
6 # Copyright (c) 1993-2002 The Regents of the University of California.
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
11 #
12 # A. Redistributions of source code must retain the above copyright notice,
13 # this list of conditions and the following disclaimer.
14 # B. Redistributions in binary form must reproduce the above copyright notice,
15 # this list of conditions and the following disclaimer in the documentation
16 # and/or other materials provided with the distribution.
17 # C. Neither the names of the copyright holders nor the names of its
18 # contributors may be used to endorse or promote products derived from this
19 # software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
25 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32
33 #
34 # A toplevel window for displaying a list of the sources currently participating in the session.
35 #
36 Class UISrcListWindow -superclass TopLevelWindow
37
38 #
39 # Instantiate, but do not yet display or iconify, a dismissable,
40 # scrollable toplevel titled "Video Participants" using the provided
41 # widgetpath, <i>w</i>. To map this window, toggle it. In this window,
42 # list the sources currently participating in the session.
43 #FIXME allow all/or non-senders to be shown
44 #
45 UISrcListWindow public init {w videoAgent} {
46 $self instvar nSRCLIST_
47 set nSRCLIST_ 0
48 $self next $w\X$nSRCLIST_
49
50 #
51 # create at startup since we manipulate the
52 # tk windows on the fly
53 #
54 set win $w\X$nSRCLIST_
55 $self create-window $win "Video Participants"
56 wm geometry $win 300x320
57 wm minsize $win 0 0
58 new UISrcList $win $videoAgent
59
60 incr nSRCLIST_
61 }
62
63 #
64 # A display of a list of the sources currently participating in the session.
65 #
66 Class UISrcList -superclass {TkWindow Observer}
67
68 #
69 # Within the provided widget, <i>w</i>, create and pack a frame in that
70 # lists the sources currently participating in the session.
71 #
72 UISrcList public init {w videoAgent} {
73 $self instvar bottom_
74 set bottom_ 2
75
76 $self instvar srclist_
77 frame $w.b -borderwidth 2 -relief sunken
78 scrollbar $w.b.scroll -relief groove -borderwidth 2 \
79 -command "$w.b.list yview"
80 #
81 # Note that we make the canvas dimensions small so that
82 # if the user resizes the window, the dismiss button
83 # doesn't disappear. The default size is set by the
84 # wm geometry command above.
85 #
86 canvas $w.b.list -relief groove -borderwidth 0 \
87 -height 10 -width 10 -yscrollcommand "$w.b.scroll set"
88
89 set srclist_ $w.b.list
90
91 button $w.ok -text " Dismiss " -borderwidth 0 -relief raised \
92 -command "wm withdraw $w" -font [$self get_option medfont]
93
94 pack $w.b -fill both -expand 1
95 pack $w.b.scroll -side left -fill y
96 pack $w.b.list -side left -expand 1 -fill both
97 pack $w.ok -fill x
98
99 wm protocol $w WM_DELETE_WINDOW "wm withdraw $w"
100
101 # let this be an observer of the VideoAgent so it can catch "register" and
102 # "unregister"
103 $videoAgent attach $self
104 }
105
106 #
107 # Register a src in the src display. This happens for all the
108 # srcs participating in the conferencing (e.g., including
109 # those not actually sending video).
110 #
111 UISrcList instproc register src {
112 $self next
113 $self instvar nametag_ srclist_ bottom_ srcstate_
114 set srcstate_($src) 1
115 set f [$self get_option medfont]
116 set nametag_($src) [$srclist_ create text 5 $bottom_ \
117 -font $f -text [$src addr] -anchor nw ]
118 set bottom_ [lindex [$srclist_ bbox $nametag_($src)] 3]
119 incr bottom_ 2
120 $srclist_ config -scrollregion "0 0 2.5i $bottom_"
121 }
122
123 #
124 # Change the name of the source, <i>src</i> in the list if it exists.
125 #
126 UISrcList instproc change_name src {
127 $self instvar srclist_ nametag_
128 # change name in source list if it exists
129 if [info exists nametag_($src)] {
130 $srclist_ itemconfigure $nametag_($src) -text [$src getid]
131 }
132 }
133
134 #
135 #
136 #
137 UISrcList instproc adjustNames { thresh h } {
138 $self instvar nametag_ srclist_ bottom_
139 foreach s [array names nametag_] {
140 set y [lindex [$srclist_ coords $nametag_($s)] 1]
141 if { $y > $thresh } {
142 $srclist_ move $nametag_($s) 0 -$h
143 }
144 }
145 incr bottom_ -$h
146 $srclist_ config -scrollregion "0 0 2.5i $bottom_"
147 }
148
149 #
150 # Remove source, <i>src</i>, from the display. This happens when
151 # a party quits or has been dead for a sufficiently long time.
152 # We assume the source has already been deactivated.
153 #
154 UISrcList instproc unregister src {
155 $self instvar nametag_ srclist_
156 #FIXME
157 global name_line info_line
158
159 #FIXME
160 destroy_rtp_stats $src
161
162 #
163 # Delete name_line and info_line if they exist.
164 # They might not be created until the first NAME
165 # report (and they aren't used until a source is activated).
166 #
167 if [info exists name_line($src)] {
168 unset name_line($src)
169 unset info_line($src)
170 }
171
172 set thresh [lindex [$srclist_ coords $nametag_($src)] 1]
173 set bb [$srclist_ bbox $nametag_($src)]
174 set height [expr [lindex $bb 3] - [lindex $bb 1]]
175 incr height 2
176 $srclist_ delete $nametag_($src)
177 unset nametag_($src)
178 $self adjustNames $thresh $height
179 }
180
181 #
182 #
183 #
184 UISrcList instproc trigger_idle src {
185 $self instvar nametag_ srclist_ srcstate_
186 if [info exists nametag_($src)] {
187 if [$src lost] {
188 $srclist_ itemconfigure $nametag_($src) -stipple gray50
189 set srcstate_($src) 2
190 } else {
191 $srclist_ itemconfigure $nametag_($src) -stipple {}
192 set srcstate_($src) 1
193 }
194 }
195 }
196
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.