~amsn-daily/amsn/amsn-packaging

3010 by yozko
Initial ChatWindow abstraction
1
#########################################
2
#    Chat Window code abstraction       #
3342 by lio_lion
pane resizing and minsizes, should be all good this time
3
#           By Alberto D�z            #
3010 by yozko
Initial ChatWindow abstraction
4
#########################################
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
5
6888 by lephilousophe
As version system is now working, I commit it to trunk...
6
::Version::setSubversionId {$Id$}
7
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
8
package require framec
4565 by lephilousophe
Added pixmap for the To field in chat window
9
package require scalable-bg
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
10
3010 by yozko
Initial ChatWindow abstraction
11
namespace eval ::ChatWindow {
12
13
	#///////////////////////////////////////////////////////////////////////////////
14
	# Namespace variables, relative to chat windows' data. In the code are accessible
15
	# through '::namespace::variable' syntax (to avoid local instances of the variable
4214 by lio_lion
better way to have a variable baloon, implemented for block/unblock button
16
	# and have the scope more clear).
3037 by yozko
Fixed the bug that caused setting $::ChatWindow::winid to 0 after executing reload_files so all the windows widgets management got messed. Also removed that bug's debug info from proc ::ChatWindow::MakeFor and ::ChatWindow::Open
17
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
18
	# As ::ChatWindow::winid is the index used in the
19
	# window widgets for chat windows, we only initialize
20
	# it at the first time, to avoid problems with proc
21
	# reload_files wich will cause some bugs related to
22
	# winid being 0 after some windows have been created.
9347 by billiob
oops
23
	if { $initialize_amsn == 1  } {
24
		variable chat_ids
25
		variable first_message
26
		variable msg_windows
27
		variable new_message_on
28
		variable recent_message
29
		variable titles
30
		variable windows [list]
31
		variable winid 0
32
		variable containers
33
		variable containerwindows
34
		variable tab2win
35
		variable win2tab
36
		variable containercurrent
37
		variable containerid 0
38
		variable scrolling
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
39
		variable macbouncewindows [list]
9805 by alexandernst
Now trayicon can blink on new unread messages
40
                variable trayblinkwindows [list]
9347 by billiob
oops
41
	}
3010 by yozko
Initial ChatWindow abstraction
42
	#///////////////////////////////////////////////////////////////////////////////
43
44
6178 by lephilousophe
Apply J's patch to Trunk too...
45
 	#///////////////////////////////////////////////////////////////////////////////
46
	# ::ChatWindow::rotext -- Read Only text widget via snit
47
	# Changes must be made by "ins" and "del", not "insert" and "delete".
48
	# Leave the window state as "normal" so cut and paste work on all platforms.
49
	# From example on http://wiki.tcl.tk/3963
50
	::snit::widgetadaptor rotext {
51
		constructor {args} {
52
			# Turn off the insert cursor
53
			#installhull using text $self -insertwidth 0
54
			# DDG the $self gaves an error at least with 0.97 onwards
55
			installhull using text -insertwidth 0
56
57
			# Apply an options passed at creation time.
58
			$self configurelist $args
59
		}
60
61
		# Disable the insert and delete methods, to make this readonly.
62
		method insert {args} {}
63
		method delete {args} {}
64
6183 by lephilousophe
Now we use roinsert and rodelete in place of ins and del
65
		# Enable roinsert and rodelete as synonyms, so the program can insert and
6178 by lephilousophe
Apply J's patch to Trunk too...
66
		# delete.
6183 by lephilousophe
Now we use roinsert and rodelete in place of ins and del
67
		delegate method roinsert to hull as insert
68
		delegate method rodelete to hull as delete
6178 by lephilousophe
Apply J's patch to Trunk too...
69
70
		# Pass all other methods and options to the real text widget, so
71
		# that the remaining behavior is as expected.
72
		delegate method * to hull
73
		delegate option * to hull
74
	}
75
	#///////////////////////////////////////////////////////////////////////////////
76
77
78
3010 by yozko
Initial ChatWindow abstraction
79
	#///////////////////////////////////////////////////////////////////////////////
80
	# ::ChatWindow::Change (chatid, newchatid)
81
	# This proc is called from the protocol layer when a private chat changes into a
82
	# conference, right after a JOI command comes from the SB. It means that the window
83
	# assigned to $chatid should now be related to $newchatid. ::ChatWindow::Change 
84
	# will return the new chatid if the change is OK (no other window for that name 
85
	# exists), or the old chatid if the change is not right
86
	# Arguments:
87
	# - chatid => Is the name of the chat that was a single private before.
88
	# - newchatid => Is the new id of the chat for the conference
89
	proc Change { chatid newchatid } {
90
		set win_name [::ChatWindow::For $chatid]
91
92
		if { $win_name == 0 } {
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
93
			# Old window window does not exists, so just accept the change, no worries
3010 by yozko
Initial ChatWindow abstraction
94
			status_log "::ChatWindow::Change: Window doesn't exist (probably invited to a conference)\n"
95
			return $newchatid
96
		}
97
98
		if { [::ChatWindow::For $newchatid] != 0} {
99
			#Old window existed, probably a conference, but new one exists too, so we can't
100
			#just allow that messages shown in old window now are shown in a different window,
101
			#that wouldn't be nice, so don't allow change
102
			status_log "conference wants to become private, but there's already a window\n"
103
			return $chatid
104
		}
105
106
		#So, we had an old window for chatid, but no window for newchatid, so the window will
107
		#change it's assigned chat
108
		::ChatWindow::UnsetFor $chatid $win_name
109
		::ChatWindow::SetFor $newchatid $win_name
110
111
		status_log "::ChatWindow::Change: changing $chatid into $newchatid\n"
112
113
		return $newchatid
114
	}
115
	#///////////////////////////////////////////////////////////////////////////////
116
117
118
	#///////////////////////////////////////////////////////////////////////////////
3450 by lio_lion
Create and use functions ::ChatWindow::GetTopFrame, GetTopText, GetTopToText, GetTopText and GetOutText for simpler updates when paths change
119
	# ::ChatWindow::GetTopFrame (window)
120
	# Returns the path to the top frame (containing "To: ...") for a given window 
121
	# Arguments:
122
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
123
	proc GetTopFrame { window } {
124
		return $window.top
125
	}
126
	#///////////////////////////////////////////////////////////////////////////////
127
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
128
	#///////////////////////////////////////////////////////////////////////////////
129
	# ::ChatWindow::GetOutFrame (window)
130
	# Returns the path to the output frame in a given window 
131
	# Arguments:
132
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
133
	proc GetOutFrame { window } {
134
		return $window.f.out
135
	}
136
	#///////////////////////////////////////////////////////////////////////////////
137
138
	#///////////////////////////////////////////////////////////////////////////////
139
	# ::ChatWindow::GetInFrame (window)
140
	# Returns the path to the input frame in a given window 
141
	# Arguments:
142
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
143
	proc GetInFrame { window } {
144
		return $window.f.bottom
145
	}
146
	#///////////////////////////////////////////////////////////////////////////////
3450 by lio_lion
Create and use functions ::ChatWindow::GetTopFrame, GetTopText, GetTopToText, GetTopText and GetOutText for simpler updates when paths change
147
148
	#///////////////////////////////////////////////////////////////////////////////
149
	# ::ChatWindow::GetOutText (window)
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
150
	# Returns the path to the output text widget in a given window
3314 by lio_lion
Further improvement on pane size saving
151
	# Arguments:
152
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
3450 by lio_lion
Create and use functions ::ChatWindow::GetTopFrame, GetTopText, GetTopToText, GetTopText and GetOutText for simpler updates when paths change
153
	proc GetOutText { window } {
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
154
		return [GetOutFrame $window].scroll.text
155
	}
156
	#///////////////////////////////////////////////////////////////////////////////
157
158
	#///////////////////////////////////////////////////////////////////////////////
159
	# ::ChatWindow::GetDisplayPicturesFrame (window)
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
160
	# Returns the path to the output DP frame in a given window
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
161
	# Arguments:
162
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
163
	proc GetOutDisplayPicturesFrame { window } {
9559 by kakaroto
Fix bug when you try to chat, or someone connects or whatever happens and you had changed your setting of 'old_dpframe' from true to false... while chatwindows were already opened
164
		# We check if the frame exists instead of checking the 'old_dpframe' option
165
		# is set because we might change the option and it will cause a bug for
166
		# existing chat windows
167
		if {[winfo exists [GetOutFrame $window].f.sw.sf] } {
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
168
			return [[GetOutFrame $window].f.sw.sf getframe]
169
		} else {
170
			return [GetOutFrame $window].f
171
		}
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
172
	}
173
	#///////////////////////////////////////////////////////////////////////////////
174
175
176
	#///////////////////////////////////////////////////////////////////////////////
177
	# ::ChatWindow::GetInputDP (window)
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
178
	# Returns the path to the input DP in a given window
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
179
	# Arguments:
180
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
181
	proc GetInDisplayPictureFrame { window } {
8964 by billiob
WIP: improve voip controls
182
		return [GetInFrame $window].f
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
183
	}
184
	#///////////////////////////////////////////////////////////////////////////////
3314 by lio_lion
Further improvement on pane size saving
185
186
	#///////////////////////////////////////////////////////////////////////////////
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
187
	# ::ChatWindow::GetInputText (window)
188
	# Returns the path to the input text widget in a given window 
189
	# Arguments:
190
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
191
	proc GetInputText { window } {
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
192
		return [[GetLeftFrame $window].in getinnerframe].text
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
193
	}
194
	#///////////////////////////////////////////////////////////////////////////////
195
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
196
	proc GetLeftFrame { window } {
197
		return [GetInFrame $window].left
198
	}
199
200
	proc GetButtonBarForWin { window } {
201
		return [GetLeftFrame $window].buttons
202
	}
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
203
204
	#///////////////////////////////////////////////////////////////////////////////
3453 by lio_lion
create procedures for statusbar as previous commits
205
	# ::ChatWindow::GetStatusText (window)
206
	# Returns the path to the statusbar text widget in a given window 
207
	# Arguments:
208
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
209
	proc GetStatusText { window } {
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
210
		return [$window.statusbar getinnerframe].status
3453 by lio_lion
create procedures for statusbar as previous commits
211
	}
212
	#///////////////////////////////////////////////////////////////////////////////
213
214
215
	#///////////////////////////////////////////////////////////////////////////////
216
	# ::ChatWindow::GetStatusCharsTypedText (window)
217
	# Returns the path to the statusbar text widget in a given window 
218
	# Arguments:
219
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
220
	proc GetStatusCharsTypedText { window } {
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
221
		return [$window.statusbar getinnerframe].charstyped
3453 by lio_lion
create procedures for statusbar as previous commits
222
	}
223
	#///////////////////////////////////////////////////////////////////////////////
224
225
226
	#///////////////////////////////////////////////////////////////////////////////
3010 by yozko
Initial ChatWindow abstraction
227
	# ::ChatWindow::Clear (window)
228
	# Deletes all the text in the chat window's input widget
229
	# Arguments:
230
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
231
	proc Clear { window } {
3607 by markitusfiber
now clear works fine with tabs
232
		set window [::ChatWindow::getCurrentTab $window]
6183 by lephilousophe
Now we use roinsert and rodelete in place of ins and del
233
		[::ChatWindow::GetOutText $window] rodelete 0.0 end
3010 by yozko
Initial ChatWindow abstraction
234
	}
235
	#///////////////////////////////////////////////////////////////////////////////
236
237
238
	#///////////////////////////////////////////////////////////////////////////////
239
	# ::ChatWindow::Close (window)
240
	# Called when a window is about to be closed, for example when we press ESC.
241
	# Arguments:
242
	#  - window => Is the window widget destroyed (.msg_n - Where n is an integer)
243
	proc Close { window } {
244
		if { $::ChatWindow::recent_message($window) == 1  && [::config::getKey recentmsg] == 1} {
245
			status_log "Recent message exists\n" white
246
			set ::ChatWindow::recent_message($window) 0
247
		} else {
248
			set idx [lsearch $::ChatWindow::windows $window]
249
			if { $idx != -1 } {
250
				set ::ChatWindow::windows [lreplace $::ChatWindow::windows $idx $idx]
251
			}
252
			destroy $window
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
253
		        ChatWindowDestroyed $window
254
3010 by yozko
Initial ChatWindow abstraction
255
		}
256
		
257
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
258
259
	proc ContainerClose { window } {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
260
		variable win2tab
9372 by kakaroto
ahh, that's the problem, we need to declare the namespace variable to use it... this should properly fix : http://www.amsn-project.net/forums/viewtopic.php?t=6824
261
		variable containerwindows
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
262
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
263
		set current [GetCurrentWindow $window]
3668 by markitusfiber
fixed the dialog when closing a container --- please improve the look&feel ;-D
264
		set currenttab [set win2tab($current)]
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
265
266
		if { [::ChatWindow::CountTabs $window] == 1 } {
267
			::ChatWindow::CloseTab $currenttab
268
			return
269
		}
9345 by billiob
fix closing CW container when on-going SIP call
270
		# Check for on-going SIP call
9369 by kakaroto
Fix bug when checking for in voip call chat windows as reported here : http://www.amsn-project.net/forums/viewtopic.php?t=6824
271
		foreach win [set containerwindows($window)] {
9345 by billiob
fix closing CW container when on-going SIP call
272
			if {[::amsn::SIPchatidExistsInList [Name $win]]} {
273
				status_log " we can't close, there's a sip call running ..." green
274
				if {[$::farsight IsVideo] } {
275
					::amsn::infoMsg [trans closeorcallvideo]
276
				} else {
277
					::amsn::infoMsg [trans closeorcall]
278
				}
279
				return
280
			}
281
		}
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
282
		
283
		if {[::config::getKey closeChatWindowWithTabs 0] == 1} {
284
			::ChatWindow::CloseAll $window
285
			destroy $window
9305 by kakaroto
Fix variable name issue that made the choice of closing all tabs (or not) when the container is closed not work. Thanks to temerucar for reporting : http://www.amsn-project.net/forums/viewtopic.php?t=6779
286
		} elseif {[::config::getKey closeChatWindowWithTabs 0] == 2} {
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
287
			::ChatWindow::CloseTab $currenttab
288
		} else {
7678 by billiob
289
			set result [::amsn::customMessageBox [trans closeall] yesnocancel question [trans title] $window 1 1 "ContainerClose"]
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
290
			set answer [lindex $result 0]
291
			set rememberAnswer [lindex $result 1]
7202 by tomhennigan
Changed the deleteUser proc to use the new customMessageBox procedure.
292
			
293
			if {$rememberAnswer == 1} {
7213 by tomhennigan
Make ::amsn::customMessageBox respond like ::amsn::messageBox (and exactly the same as tk_messageBox) by returning lowercase english names. (Before it returned the translated key for the button pressed).
294
				if {$answer == "yes"} {
7202 by tomhennigan
Changed the deleteUser proc to use the new customMessageBox procedure.
295
					::config::setKey closeChatWindowWithTabs 1
7213 by tomhennigan
Make ::amsn::customMessageBox respond like ::amsn::messageBox (and exactly the same as tk_messageBox) by returning lowercase english names. (Before it returned the translated key for the button pressed).
296
				} elseif {$answer == "no"} {
7202 by tomhennigan
Changed the deleteUser proc to use the new customMessageBox procedure.
297
					::config::setKey closeChatWindowWithTabs 0
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
298
				}
299
			}
300
			
7213 by tomhennigan
Make ::amsn::customMessageBox respond like ::amsn::messageBox (and exactly the same as tk_messageBox) by returning lowercase english names. (Before it returned the translated key for the button pressed).
301
			if { $answer == "yes" } {
7475 by kakaroto
Fixes an issue where we could have multiple windows for the CloseAll tabs of a chat window, so closing multiple times leaves multiple 'do you want to close all' windows, and once the CW is destroyed, clicking yes or no in that window will generate a bug report.
302
				::ChatWindow::CloseAll $window
303
				destroy $window
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
304
			}
7213 by tomhennigan
Make ::amsn::customMessageBox respond like ::amsn::messageBox (and exactly the same as tk_messageBox) by returning lowercase english names. (Before it returned the translated key for the button pressed).
305
			if { $answer == "no" } {
7475 by kakaroto
Fixes an issue where we could have multiple windows for the CloseAll tabs of a chat window, so closing multiple times leaves multiple 'do you want to close all' windows, and once the CW is destroyed, clicking yes or no in that window will generate a bug report.
306
				::ChatWindow::CloseTab $currenttab
7198 by tomhennigan
Added a proc ::amsn::customMessageBox which has the same syntax as ::amsn::messageBox, but allows a return of a list (Selected Button, Remember Answer) if the askRememberAnswer flag is set.
307
			}
308
		}
4308 by germinator2000
Hostname problem: Get back to the old changes (to fix the problem a lot of people are having on CVS), fix it permanantly later
309
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
310
311
	proc DetachAll { w } {
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
312
		variable containerwindows
313
		variable containers
314
		variable containercurrent
315
316
		if {![info exists containerwindows($w)] || [winfo toplevel $w] != $w} {
317
			return
318
		}
319
320
		status_log "detaching containerwindows $w\n" red
321
		foreach window [set containerwindows($w)] {
322
			status_log "destroy $window\n" red
323
			DetachTab [set ::ChatWindow::win2tab($window)]
324
		}
325
326
		status_log "unsetting containerwindow and containercurrent\n" red
327
		unset containerwindows($w)
328
		unset containercurrent($w)
329
330
		status_log "unsetting containers array...\n" red
331
		foreach { key value } [array get containers] {
332
			if { $value == $w } {
333
				status_log "found containers $key $value\n" red
334
				unset containers($key)
335
			}
336
		}
337
338
		destroy $w
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
339
	        ChatWindowDestroyed $w
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
340
		
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
341
	}
342
3668 by markitusfiber
fixed the dialog when closing a container --- please improve the look&feel ;-D
343
	proc CountTabs { w } {
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
344
		return [llength [set ::ChatWindow::containerwindows($w)]]
3668 by markitusfiber
fixed the dialog when closing a container --- please improve the look&feel ;-D
345
	}
346
7557 by baaazen
asks user before logout whether to close all chatwindows or not
347
	proc CloseAllWindows {{force 0}} {
7553 by baaazen
fix for closing all chatwindows after logout as this could be a vulnerability
348
		variable windows
349
		variable containerwindows
350
7557 by baaazen
asks user before logout whether to close all chatwindows or not
351
		# check if there are still conversations open
352
		set winopen 0
353
		foreach win $windows {
354
			if {[winfo exists $win]} {
355
				set winopen 1
356
				break
357
			}
358
		}
359
		
360
		if {$force == 0} {
361
			if {$winopen == 1} {
362
				# ask whether those windows should be closed or not
363
				if {[::config::getKey closeChatWindowsAfterLogout 0] == 2} {
364
					return 1
8225 by kakaroto
don't close all CW unless you're sure the user chose it.
365
				} elseif {[::config::getKey closeChatWindowsAfterLogout 0] != 1} {
7557 by baaazen
asks user before logout whether to close all chatwindows or not
366
					set result [::amsn::customMessageBox [trans closechatwindows] yesnocancel question [trans title] "" 1 1]
367
					set answer [lindex $result 0]
368
					set rememberAnswer [lindex $result 1]
369
370
					if {$rememberAnswer == 1} {
371
						if {$answer == "yes"} {
372
							::config::setKey closeChatWindowsAfterLogout 1
373
						} elseif {$answer == "no"} {
374
							::config::setKey closeChatWindowsAfterLogout 2
375
						}
376
					}
377
378
					if {$answer == "no"} {
379
						return 1
380
					} elseif {$answer == "cancel"} {
381
						return 0
382
					}
383
				}
384
			} else {
385
				return 1
386
			}
387
		}
388
7553 by baaazen
fix for closing all chatwindows after logout as this could be a vulnerability
389
		foreach win $windows {
390
			if {![winfo exists $win]} {
391
				continue
392
			}
393
			set upwin [winfo toplevel $win]
394
395
			if {[info exists containerwindows($upwin)]} {
396
				# this is a tabbed window, so closing all tabs does the trick
397
				CloseAll $upwin
398
				destroy $upwin
399
			} else {
400
				# this seems to be a normal window, so close the usual way
401
				Close $upwin
402
			}
403
		}
404
405
		set windows [list]
7557 by baaazen
asks user before logout whether to close all chatwindows or not
406
407
		return 1
7553 by baaazen
fix for closing all chatwindows after logout as this could be a vulnerability
408
	}
409
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
410
	proc CloseAll { w } {
411
		variable containerwindows
412
		variable containers
413
		variable containercurrent
414
415
		if {![info exists containerwindows($w)] || [winfo toplevel $w] != $w} {
416
			return
417
		}
418
419
		status_log "destroying containerwindows $w\n" red
420
		foreach window [set containerwindows($w)] {
421
			status_log "destroy $window\n" red
422
			destroy $window
423
		}
424
425
		status_log "unsetting containerwindow and containercurrent\n" red
426
		unset containerwindows($w)
427
		unset containercurrent($w)
428
429
		status_log "unsetting containers array...\n" red
430
		foreach { key value } [array get containers] {
431
			if { $value == $w } {
432
				status_log "found containers $key $value\n" red
433
				unset containers($key)
434
			}
435
		}
436
	}
437
3010 by yozko
Initial ChatWindow abstraction
438
	#///////////////////////////////////////////////////////////////////////////////
439
440
441
	#///////////////////////////////////////////////////////////////////////////////
442
	# ::ChatWindow::Closed (window, path)
443
	# Called when a window and its children are destroyed. When the main window is
444
	# destroyed ($window == $path) then it tells the protocol layer to leave the
445
	# chat related to $window, and unsets variables used for that window.
446
	# Arguments:
447
	#  - window => Is the window widget destroyed (.msg_n - Where n is an integer)
448
	#  - path => Is the parent widget of the destroyed childrens (the window)
449
	proc Closed { window path } {
6484 by billiob
add history support for OIMs
450
3010 by yozko
Initial ChatWindow abstraction
451
		#Only run when the parent window close event comes
452
		if { "$window" != "$path" } {
453
			return 0
454
		}
455
7868 by square87
code clean in proc: Closed
456
		set chatid [::ChatWindow::Name $window]
3010 by yozko
Initial ChatWindow abstraction
457
458
		if { $chatid == 0 } {
459
			status_log "VERY BAD ERROR in ::ChatWindow::Closed!!!\n" red
460
			return 0
461
		}
462
		if {[::config::getKey keep_logs]} {
7091 by billiob
Thanks to Square87:
463
			if { [::OIM_GUI::IsOIM $chatid] == 1} {
464
				::log::StopLog $chatid
465
			} else {
7868 by square87
code clean in proc: Closed
466
				foreach user_login [::MSN::usersInChat $chatid] {
7091 by billiob
Thanks to Square87:
467
					::log::StopLog $user_login
468
				}
3010 by yozko
Initial ChatWindow abstraction
469
			}
470
		}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
471
7911 by scapor
reverse commit 9371
472
		set evPar(chatid) chatid
7091 by billiob
Thanks to Square87:
473
		::plugins::PostEvent chatwindow_closed evPar
474
3010 by yozko
Initial ChatWindow abstraction
475
		::ChatWindow::UnsetFor $chatid $window
476
		unset ::ChatWindow::titles(${window})
477
		unset ::ChatWindow::first_message(${window})
478
		unset ::ChatWindow::recent_message(${window})
479
480
		#Delete images if not in use
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
481
		catch {destroy [GetInDisplayPictureFrame $window]}
4119 by airadier
Show display picture in contact list balloons.
482
		
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
483
		#Could be cleaner, but this works, destroying unused vars, saving mem
5688 by scapor
unsetting more unused variables .. NEEDS SERIOUS TESTING AS IM UNSURE
484
		catch {
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
485
			global [GetInputText ${window}]
486
			unset [GetInputText ${window}]
5688 by scapor
unsetting more unused variables .. NEEDS SERIOUS TESTING AS IM UNSURE
487
		}
488
		
5687 by scapor
unsetting more unused variables .. NEEDS SERIOUS TESTING AS IM UNSURE
489
		
3010 by yozko
Initial ChatWindow abstraction
490
		::MSN::leaveChat $chatid
8758 by square87
Added a new chat style: compact style
491
		
492
		catch { unset ::amsn::lastchatwith(${chatid}) }
9680 by kakaroto
stop the bouncing on mac if the window got closed.. also avoid a bug if the window to raise is invalid for some reason : http://www.amsn-project.net/forums/viewtopic.php?t=7466&highlight=
493
		if {[OnMac]} {
494
			MacBounceDone $window
495
		}
9805 by alexandernst
Now trayicon can blink on new unread messages
496
                TrayBlinkStop $window
3010 by yozko
Initial ChatWindow abstraction
497
	}
498
	#///////////////////////////////////////////////////////////////////////////////
499
500
501
	#///////////////////////////////////////////////////////////////////////////////
502
	# ::ChatWindow::Configured (window)
503
	# This proc is called when we resize the window, it stores the new size in config
504
	# Arguments:
505
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
506
	proc Configured { window } {
3315 by lio_lion
some minor improvements for the calls for saving sizes
507
		#only run this if the window is the outer window
508
		if { ![string equal $window [winfo toplevel $window]]} { return }
509
3010 by yozko
Initial ChatWindow abstraction
510
		set chatid [::ChatWindow::Name $window]
511
512
		if { $chatid != 0 } {
6883 by lephilousophe
Better like that : thanks YOuness to show me the light ;)
513
			after cancel [list ::ChatWindow::TopUpdate $chatid]
514
			after 200 [list ::ChatWindow::TopUpdate $chatid]
3010 by yozko
Initial ChatWindow abstraction
515
		}
516
517
		if { [::config::getKey savechatwinsize] } {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
518
			if { [wm state $window] == "zoomed" } {
519
				::config::setKey winmaximized 1
9087 by BaaaZen
should fix the problem with 0x0 sized chatwindows on windows, mentioned here: http://www.amsn-project.net/forums/viewtopic.php?t=5091
520
			} elseif { [wm state $window] == "normal" } {
521
				::config::setKey winmaximized 0
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
522
523
				set geometry [wm geometry $window]
524
				set pos_start [string first "+" $geometry]
525
526
				::config::setKey winchatsize  [string range $geometry 0 [expr {$pos_start-1}]]
527
			}
3010 by yozko
Initial ChatWindow abstraction
528
		}
529
	}
530
	#///////////////////////////////////////////////////////////////////////////////
531
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
532
	proc ContainerConfigured { window } {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
533
534
	
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
535
		#only run this if the window is the outer window
536
		if { ![string equal $window [winfo toplevel $window]]} { return }
537
538
		set chatid [::ChatWindow::Name $window]
539
540
		if { $chatid != 0 } {
6883 by lephilousophe
Better like that : thanks YOuness to show me the light ;)
541
			after cancel [list ::ChatWindow::TopUpdate $chatid]
542
			after 200 [list ::ChatWindow::TopUpdate $chatid]
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
543
		}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
544
3888 by germinator2000
Only call checkfortoomanytabs if we resize the chatwindow, not if we just move it
545
		set geometry [wm geometry $window]
546
		set pos_start [string first "+" $geometry]
547
		#Look if the window changed size with the configure
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
548
3888 by germinator2000
Only call checkfortoomanytabs if we resize the chatwindow, not if we just move it
549
		if {[::config::getKey wincontainersize] != "[string range $geometry 0 [expr {$pos_start-1}]]"} {
550
			set sizechanged 1
551
		} else {
552
			set sizechanged 0
553
		}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
554
3888 by germinator2000
Only call checkfortoomanytabs if we resize the chatwindow, not if we just move it
555
		#Save size of current container
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
556
		if { [::config::getKey savechatwinsize] } {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
557
			if { [wm state $window] == "zoomed" } {
8656 by vivia
Fixed issue where maximizing/unmaximizing did not show the correct number of tabs
558
				if { [::config::getKey winmaximized] != 1 } {
559
					::config::setKey winmaximized 1
560
					set sizechanged 1
561
				}
9087 by BaaaZen
should fix the problem with 0x0 sized chatwindows on windows, mentioned here: http://www.amsn-project.net/forums/viewtopic.php?t=5091
562
			} elseif { [wm state $window] == "normal" } {
563
				if { [::config::getKey winmaximized] != 0 } {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
564
					::config::setKey winmaximized 0
8656 by vivia
Fixed issue where maximizing/unmaximizing did not show the correct number of tabs
565
					set sizechanged 1
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
566
				}
567
568
				::config::setKey wincontainersize  [string range $geometry 0 [expr {$pos_start-1}]]
569
			}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
570
		}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
571
	
3888 by germinator2000
Only call checkfortoomanytabs if we resize the chatwindow, not if we just move it
572
		#If the window changed size use checkfortoomanytabs
9604 by kakaroto
Delay CheckForTooManyTabs call to 1 second after a resize, not only to 'idle' because on win7 (possible other OS) the CheckForTooManyTabs is called right after the *Configured calls and it seems to reset the size to the previous value! so if we have too many tabs and the <--> arrows appear, then it's impossible to resize the chat window...
573
		after cancel [list ::ChatWindow::CheckForTooManyTabs $window 0]
3888 by germinator2000
Only call checkfortoomanytabs if we resize the chatwindow, not if we just move it
574
		if { [winfo exists ${window}.bar] && $sizechanged} {
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
575
			after 100 [list ::ChatWindow::CheckForTooManyTabs $window 0]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
576
		}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
577
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
578
	}
3010 by yozko
Initial ChatWindow abstraction
579
9805 by alexandernst
Now trayicon can blink on new unread messages
580
        proc TrayBlinkStart { window } {
9822 by alexandernst
Remove trayblink feature for Windows systems until it's properly implemented.
581
            if { [OnWin] } { return }
9805 by alexandernst
Now trayicon can blink on new unread messages
582
            variable trayblinkwindows
583
            if { [::config::getKey blinktray] == 0 } {
9807 by kakaroto
avoid resetting the tray everytime if we disabled the option to blink tray.. also remove a small tk bug
584
		    if {[llength $trayblinkwindows] > 0} {
585
			    set trayblinkwindows [list]
586
			    after cancel ::ChatWindow::TrayBlink 0
587
			    after cancel ::ChatWindow::TrayBlink 1
588
			    statusicon_proc [::MSN::myStatusIs]
589
		    }
9805 by alexandernst
Now trayicon can blink on new unread messages
590
	        return
591
            }
592
            set idx [lsearch [set trayblinkwindows] $window]
593
            if {$idx == -1} {
594
                lappend trayblinkwindows $window
595
                after cancel ::ChatWindow::TrayBlink 0
596
                after cancel ::ChatWindow::TrayBlink 1
597
                ::ChatWindow::TrayBlink 1
598
            }
599
        }
600
601
        proc TrayBlinkStop { window } {
9822 by alexandernst
Remove trayblink feature for Windows systems until it's properly implemented.
602
            if { [OnWin] } { return }
9805 by alexandernst
Now trayicon can blink on new unread messages
603
            variable trayblinkwindows
604
            set idx [lsearch [set trayblinkwindows] $window]
605
            if {$idx >= 0} {
606
                set trayblinkwindows [lreplace [set trayblinkwindows] $idx $idx]
9819 by alexandernst
Fix a bug in TrayBlinkStop causing the trayicon to be changed after every tabchange, window open/close, etc...
607
                if { [llength $trayblinkwindows] == 0 } {
608
	            after cancel ::ChatWindow::TrayBlink 0
609
                    after cancel ::ChatWindow::TrayBlink 1
610
                    statusicon_proc [::MSN::myStatusIs]
611
                }
9805 by alexandernst
Now trayicon can blink on new unread messages
612
            }
613
        }
614
615
        proc TrayBlink { blink } {
9822 by alexandernst
Remove trayblink feature for Windows systems until it's properly implemented.
616
            if { [OnWin] } { return }
9807 by kakaroto
avoid resetting the tray everytime if we disabled the option to blink tray.. also remove a small tk bug
617
            variable trayblinkwindows
9805 by alexandernst
Now trayicon can blink on new unread messages
618
            if { [::config::getKey blinktray] == 0 } {
619
                return
620
            }
621
            if { $blink == 0 } {
622
                statusicon_proc [::MSN::myStatusIs]
9809 by kakaroto
Add skin options for the tray icon blinking and to enable a single image for the trayblink (TO BE TESTED)
623
                after [::skin::getKey trayblink_delay] ::ChatWindow::TrayBlink 1
9805 by alexandernst
Now trayicon can blink on new unread messages
624
            } else {
625
                statusicon_blink_proc [::MSN::myStatusIs]
9809 by kakaroto
Add skin options for the tray icon blinking and to enable a single image for the trayblink (TO BE TESTED)
626
                after [::skin::getKey trayblink_delay]  ::ChatWindow::TrayBlink 0
9805 by alexandernst
Now trayicon can blink on new unread messages
627
            }
628
            if { [llength $trayblinkwindows] == 0 } {
629
                after cancel ::ChatWindow::TrayBlink 0
630
                after cancel ::ChatWindow::TrayBlink 1
631
                statusicon_proc [::MSN::myStatusIs]
632
            }
633
        }
634
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
635
	proc MacKeepBouncing { } {
636
		if {[catch {::carbon::notification "" 1} res]} {
637
			status_log $res
638
		}
639
		after 2000 ::ChatWindow::MacKeepBouncing
640
	}
641
642
	proc MacBounce { } {
643
		if { [::config::getKey dockbounce] == "never" } {
644
			return
645
		}
646
647
		set found 0
648
		foreach after_id [after info] {
649
			set cmd [lindex [after info $after_id] 0]
650
			if {$cmd == "::ChatWindow::MacKeepBouncing" } {
651
				set found 1
652
				break
653
			}
654
		}
655
656
		if {$found == 0 } {
657
			MacKeepBouncing
658
		}
659
		if { [::config::getKey dockbounce] == "once" } {
660
			MacBounceStop
661
		}
662
	}
663
664
	proc MacBounceStop { } {
665
		after cancel ::ChatWindow::MacKeepBouncing
666
		catch {::carbon::endNotification}
667
	}
668
669
	proc MacBounceStart { window } {
670
		variable macbouncewindows
671
                set idx [lsearch [set macbouncewindows] $window]
672
                if {$idx == -1 } {
673
			lappend macbouncewindows $window
674
			MacBounce
675
		}
676
	}
677
678
	proc MacBounceDone { window } {
679
		variable macbouncewindows
680
                set idx [lsearch [set macbouncewindows] $window]
681
		if {$idx >= 0 } {
682
	                set macbouncewindows [lreplace [set macbouncewindows] $idx $idx]
683
		}
684
		if {[llength $macbouncewindows] > 0 } {
685
			MacBounce
686
		} else {
687
			MacBounceStop
688
		}
689
	}
690
691
9404 by kakaroto
Clicking the dock icon will now raise/focus on the chat window that caused it to bounce, when no chatwindow is flickering, then it will raise the contact list... as discussed in http://amsn-project.net/forums/viewtopic.php?p=39716
692
	proc MacRaiseWindows { } {
693
                variable macbouncewindows
694
695
		if {[llength $macbouncewindows] > 0 } {
696
			set win [lindex $macbouncewindows 0]
9680 by kakaroto
stop the bouncing on mac if the window got closed.. also avoid a bug if the window to raise is invalid for some reason : http://www.amsn-project.net/forums/viewtopic.php?t=7466&highlight=
697
			if {[catch {wm state $win normal}]} {
698
				MacBounceDone $win
699
				MacRaiseWindows
700
			} else {
701
				raise $win
702
			}
9404 by kakaroto
Clicking the dock icon will now raise/focus on the chat window that caused it to bounce, when no chatwindow is flickering, then it will raise the contact list... as discussed in http://amsn-project.net/forums/viewtopic.php?p=39716
703
			return 1
704
		} else {
705
			return 0
706
		}
707
	}
708
709
3010 by yozko
Initial ChatWindow abstraction
710
	#///////////////////////////////////////////////////////////////////////////////
3012 by yozko
Some minor beauty improvements on the code
711
	# ::ChatWindow::Flicker (chatid, [count])
712
	# Called when a window must flicker, and called by itself to produce the flickering
713
	# effect. It will flicker the window until it gets the focus.
714
	# Arguments:
715
	#  - chatid => Is the name of the chat to flicker (a passport login)
716
	#  - count => [NOT REQUIRED] Can be any number, it's just used in self calls
717
	proc Flicker {chatid {count 0}} {
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
718
	
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
719
		if { [::ChatWindow::For $chatid] != 0 } {
3012 by yozko
Some minor beauty improvements on the code
720
			set window [::ChatWindow::For $chatid]
721
		} else {
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
722
			if { [winfo exists $chatid] } { 
723
				set window $chatid
724
			} else {
725
				return 0
726
			}
3012 by yozko
Some minor beauty improvements on the code
727
		}
728
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
729
		set ::ChatWindow::titles($window) [EscapeTitle [set ::ChatWindow::titles($window)]] 
730
731
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
732
		set container [GetContainerFromWindow $window]
733
		if { $container != "" } {
734
			FlickerTab $window 
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
735
			Flicker $container
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
736
			return
737
		}
738
3012 by yozko
Some minor beauty improvements on the code
739
		if { [::config::getKey flicker] == 0 } {
740
			if { [string first $window [focus]] != 0 } {
741
				catch {wm title ${window} "*$::ChatWindow::titles($window)"} res
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
742
				set ::ChatWindow::new_message_on(${window}) "asterisk"
3012 by yozko
Some minor beauty improvements on the code
743
				bind ${window} <FocusIn> "::ChatWindow::GotFocus ${window}"
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
744
				if {[OnMac]} {
745
					MacBounceStart $window
746
				}
9805 by alexandernst
Now trayicon can blink on new unread messages
747
                                TrayBlinkStart $window
3012 by yozko
Some minor beauty improvements on the code
748
			}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
749
			return 0
3012 by yozko
Some minor beauty improvements on the code
750
		}
751
752
		after cancel ::ChatWindow::Flicker $chatid 0
753
		after cancel ::ChatWindow::Flicker $chatid 1
754
755
		if { [string first $window [focus]] != 0 } {
756
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
757
			# If user uses Windows, call winflash to flash the window, this is done by
758
			# calling the winflash proc that should be created by the flash.dll extension
759
			# so we do it in a catch statement, if it fails. Then load the extension before
760
			# calling winflash. If this one or the first one were successful, we add a bind
761
			# on FocusIn to call the winflash with the -state 0 option to disable it and we return.
9811 by alexandernst
Fix some remaining bugs. Now trayblink feature should be working fine.
762
                        TrayBlinkStart $window
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
763
			if { [OnWin] } {
7731 by kakaroto
Better flickering on windows..
764
				if { [catch {winflash $window -count 5} ] } {
3012 by yozko
Some minor beauty improvements on the code
765
					if { ![catch { 
5609 by tjikkun
winflash is a package now.. I think it should work, someone with windows should test
766
						package require winflash
7731 by kakaroto
Better flickering on windows..
767
						winflash $window -count 5
3012 by yozko
Some minor beauty improvements on the code
768
					} ] } {
9805 by alexandernst
Now trayicon can blink on new unread messages
769
						bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
3012 by yozko
Some minor beauty improvements on the code
770
						return
771
					}
772
				} else {
9805 by alexandernst
Now trayicon can blink on new unread messages
773
					bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
3012 by yozko
Some minor beauty improvements on the code
774
					return
775
				}
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
776
			} elseif { [OnLinux] } {
7542 by kakaroto
linflash/winflash typo for windows and fixed the issue of the urgency hint never being removed in case the WM doesn't support the demande_attention flag
777
				#if on the X window system
5582 by scapor
Wrong commit :$, reparations
778
				if { [catch {linflash $window}] } {
779
					if { ![catch { 
5606 by tjikkun
linflash is a package now, and gets installed with make install
780
						package require linflash
5582 by scapor
Wrong commit :$, reparations
781
						linflash $window
782
					} ] } {
9805 by alexandernst
Now trayicon can blink on new unread messages
783
						bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
5582 by scapor
Wrong commit :$, reparations
784
						return
7542 by kakaroto
linflash/winflash typo for windows and fixed the issue of the urgency hint never being removed in case the WM doesn't support the demande_attention flag
785
					} else {
786
						
787
						# in case it didn't work, but we were able to set the 'urgency'
788
						# hint, we must unset it even if it failed, 
789
						# but still fallback to the flickering of the title.
9805 by alexandernst
Now trayicon can blink on new unread messages
790
						bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
5582 by scapor
Wrong commit :$, reparations
791
					}
792
				} else {
9805 by alexandernst
Now trayicon can blink on new unread messages
793
					bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
5582 by scapor
Wrong commit :$, reparations
794
					return
795
				}
9358 by kakaroto
Bounce amsn when you need to flicker a window, and do it correctly, not only if the whole amsn isn't focused
796
			} elseif { [OnMac] } {
797
				#Dock Bouncing on Mac OS X
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
798
				MacBounceStart $window
799
3012 by yozko
Some minor beauty improvements on the code
800
			}
9358 by kakaroto
Bounce amsn when you need to flicker a window, and do it correctly, not only if the whole amsn isn't focused
801
		
3012 by yozko
Some minor beauty improvements on the code
802
803
			set count  [expr {( $count +1 ) % 2}]
804
805
			if {![catch {
806
				if { $count == 1 } {
807
					wm title ${window} "[trans newmsg]"
808
				} else {
809
					wm title ${window} "$::ChatWindow::titles($window)"
810
				}
811
			} res]} {
812
				after 300 ::ChatWindow::Flicker $chatid $count
813
			}
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
814
			set ::ChatWindow::new_message_on(${window}) "flicker"
815
			
3012 by yozko
Some minor beauty improvements on the code
816
		} else {
817
			catch {wm title ${window} "$::ChatWindow::titles($window)"} res
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
818
			catch {unset ::ChatWindow::new_message_on(${window})}
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
819
			if {[OnMac]} {
820
				MacBounceDone $window
821
			}
9805 by alexandernst
Now trayicon can blink on new unread messages
822
                        TrayBlinkStop $window
3012 by yozko
Some minor beauty improvements on the code
823
		}
824
	}
825
	#///////////////////////////////////////////////////////////////////////////////
826
827
828
	#///////////////////////////////////////////////////////////////////////////////
3010 by yozko
Initial ChatWindow abstraction
829
	# ::ChatWindow::For (chatid)
830
	# Returns the name of the window (.msg_n) that should show the messages and 
831
	# information related to the chat 'chatid'.
832
	# Arguments:
833
	#  - chatid => Is the chat id of the window, the passport account of the buddy
834
	proc For { chatid } {
835
		if { [info exists ::ChatWindow::msg_windows($chatid)]} {
836
			return $::ChatWindow::msg_windows($chatid)
837
		}
838
		return 0
839
	}
840
	#///////////////////////////////////////////////////////////////////////////////
841
842
843
	#///////////////////////////////////////////////////////////////////////////////
844
	# ::ChatWindow::GotFocus (window)
845
	# Called when a window with a new msg gets the focus and goes back to its title
846
	# Arguments:
847
	#  - window => Is the window widget focused (.msg_n - Where n is an integer)
848
	proc GotFocus { window } {
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
849
		if { [info exists ::ChatWindow::new_message_on(${window})] && \
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
850
			$::ChatWindow::new_message_on(${window}) == "asterisk" } {
3010 by yozko
Initial ChatWindow abstraction
851
			unset ::ChatWindow::new_message_on(${window})
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
852
			catch {wm title ${window} "[EscapeTitle $::ChatWindow::titles(${window})]"} res
3010 by yozko
Initial ChatWindow abstraction
853
			bind ${window} <FocusIn> ""
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
854
			if {[OnMac]} {
855
				MacBounceDone $window
856
			}
9805 by alexandernst
Now trayicon can blink on new unread messages
857
                        TrayBlinkStop $window
3010 by yozko
Initial ChatWindow abstraction
858
		}
859
	}
860
	#///////////////////////////////////////////////////////////////////////////////
861
9805 by alexandernst
Now trayicon can blink on new unread messages
862
        proc GotFocusUnflash { window } {
863
            bind ${window} <FocusIn> ""
864
            if {[OnUnix]} {
865
                catch { linunflash $window }
866
            } elseif {[OnWin]} {
9882 by kakaroto
Stupid windows! The documentation clearly says that if we do the flash STOP flag it will stop flashing...
867
		    #catch { winflash $window -state 0 }
9805 by alexandernst
Now trayicon can blink on new unread messages
868
            }
869
            TrayBlinkStop $window
870
        }
3010 by yozko
Initial ChatWindow abstraction
871
872
	#///////////////////////////////////////////////////////////////////////////////
3012 by yozko
Some minor beauty improvements on the code
873
	# ::ChatWindow::MacPosition
874
	# To place the ::ChatWindow::Open at the right place on Mac OS X, because the
875
	# window manager will put all the windows in bottom left after some time.
876
	# Arguments:
877
 	proc MacPosition { window } {
878
 		#To know where the window manager want to put the window in X and Y
3644 by germinator2000
Get chatcolorbg on background for tabbed window
879
 		set window [winfo toplevel $window]
7862 by thaven
improve ::ChatWindow::MacPosition.
880
 		set x_pos [winfo x $window]
881
 		set y_pos [winfo y $window]
882
 		
883
		#Determine the maximum place in Y to place a window
884
 		#Height of the screen - height of the window
885
 		set y_max [expr {[winfo vrootheight $window] - [winfo height $window]}]
886
 		#If the position of the window in y is greater than the maximum
887
 		#Then move the window upwards by the size of the window
888
 		if { $y_pos > $y_max } { 
889
			set y_pos [expr {$y_pos - [winfo height $window]}] 
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
890
		}
3012 by yozko
Some minor beauty improvements on the code
891
 		#If the result is smaller than 25 (on small screen) then use 25 
7862 by thaven
improve ::ChatWindow::MacPosition.
892
 		if { $y_pos < 25 } {
893
			set y_pos 25
894
		}
895
		
896
		#Determine the maximum place in X to place a window
897
		#Width of screen - width of window
898
		set x_max [expr {[winfo vrootwidth $window] - [winfo width $window]}]
899
 		#If the position of the window in x is greater than the maximum
900
 		#Then move the window to the left by the size of the window
901
		if { $x_pos > $x_max } {
902
			set x_pos [expr {$x_pos - [winfo width $window]}]
903
		}
9335 by kakaroto
On Mac, the algo to place the chatwindow was wrong, if the X was > screenwidth, then it moved it left by the width of the window.. but if the window's width is > half the width of the screen, then the x position becomes negative.. this was really annoying me, so it's fixed now :)
904
905
		if { $x_pos < 2 } {
906
			set x_pos 2
907
		}
7862 by thaven
improve ::ChatWindow::MacPosition.
908
						
3012 by yozko
Some minor beauty improvements on the code
909
 		#Replace the window to the new position on the screen 	
7862 by thaven
improve ::ChatWindow::MacPosition.
910
 		wm geometry $window +${x_pos}+${y_pos}
3012 by yozko
Some minor beauty improvements on the code
911
	}
912
	#///////////////////////////////////////////////////////////////////////////////
913
914
915
	#///////////////////////////////////////////////////////////////////////////////
3010 by yozko
Initial ChatWindow abstraction
916
	# ::ChatWindow::MakeFor (chatid, [msg ""], [usr_name ""])
917
	# Opens a window if it did not existed, and if it is the first message it adds
918
	# the message to a notify window (::amsn::notifyAdd), and plays sound if enabled
919
	# Arguments:
920
	#  - chatid => Is the chat id of the window, the passport account of the buddy
921
	#  - [msg ""] => [NOT REQUIRED] The message sent to us (first message)
922
	#  - [usr_name ""] => [NOT REQUIRED] Is the user who sends the message
923
	proc MakeFor { chatid {msg ""} {usr_name ""} } {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
924
		set lastfocus [focus]
3010 by yozko
Initial ChatWindow abstraction
925
		set win_name [::ChatWindow::For $chatid]
926
8071 by kakaroto
As per FreeMind's request (http://www.amsn-project.net/forums/viewtopic.php?p=28548#28548)
927
		set new_window 0
928
8914 by vivia
Might remove typing sounds when we write, thx Trappski for finding out
929
		if { [::MSN::usersInChat $chatid] == $chatid && $usr_name == "" } {
8892 by vivia
Even if $usr_name is null, ::ChatWindow::MakeFor should be able to display the DP if it is a conversation with one person only
930
			set usr_name $chatid
931
		}
932
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
933
		# If there wasn't a window created and assigned to $chatid, let's create one
934
		# through ::ChatWindow::Open and assign it to $chatid with ::ChatWindow::SetFor
3010 by yozko
Initial ChatWindow abstraction
935
		if { $win_name == 0 } {
8071 by kakaroto
As per FreeMind's request (http://www.amsn-project.net/forums/viewtopic.php?p=28548#28548)
936
			set new_window 1
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
937
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
938
			if { [UseContainer] == 0 } {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
939
3557 by tjikkun
Got annoyed by incoming chats not appearing in the tabbed window, now they do. I haven't tested with conference chat, it might not work.
940
				set win_name [::ChatWindow::Open]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
941
7556 by lephilousophe
Fix focus issues when not using Tabbed windows
942
				::ChatWindow::SetFor $chatid $win_name
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
943
3557 by tjikkun
Got annoyed by incoming chats not appearing in the tabbed window, now they do. I haven't tested with conference chat, it might not work.
944
			} else {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
945
3557 by tjikkun
Got annoyed by incoming chats not appearing in the tabbed window, now they do. I haven't tested with conference chat, it might not work.
946
				set container [::ChatWindow::GetContainerFor $chatid]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
947
3557 by tjikkun
Got annoyed by incoming chats not appearing in the tabbed window, now they do. I haven't tested with conference chat, it might not work.
948
				set win_name [::ChatWindow::Open $container]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
949
	
3567 by markitusfiber
tabs named with chatid (emails)
950
				::ChatWindow::SetFor $chatid $win_name
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
951
	
4546 by lephilousophe
Removed the proxy memory leak (needs testing)
952
				::ChatWindow::NameTabButton $win_name $chatid
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
953
4311 by germinator2000
Fix the bug of nickname staying the same in the tooltipis of chatwindow
954
				set_balloon $::ChatWindow::win2tab($win_name) "--command--::ChatWindow::SetNickText $chatid"
3880 by kakaroto
fixed the refreshs of the window with multiple tabs
955
				::ChatWindow::SwitchToTab $container [::ChatWindow::GetCurrentWindow $container]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
956
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
957
3557 by tjikkun
Got annoyed by incoming chats not appearing in the tabbed window, now they do. I haven't tested with conference chat, it might not work.
958
			}
3567 by markitusfiber
tabs named with chatid (emails)
959
			#update idletasks
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
960
3010 by yozko
Initial ChatWindow abstraction
961
			::ChatWindow::TopUpdate $chatid
962
8810 by billiob
oops, should fix Fenix-TX's bug
963
			if { [winfo exists [GetOutDisplayPicturesFrame $win_name].dps] } {
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
964
				::amsn::ShowOrHidePicture
965
				::amsn::ShowOrHideTopPicture
966
				::amsn::UpdatePictures $win_name
3010 by yozko
Initial ChatWindow abstraction
967
			} else {
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
968
				if { [::config::getKey showdisplaypic] && $usr_name != ""} {
969
					::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name]
970
				} else {
971
					::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name] nopack
972
				}
3010 by yozko
Initial ChatWindow abstraction
973
			}
974
		}
975
3591 by tjikkun
fixed windows not opening in non-tabbed mode
976
		set top_win [winfo toplevel $win_name]
977
3692 by gadget_boy
Post the event "new_conversation" when the first message arrives in a chatwindow (the event was not posted when we don't show when a contact opens a chat with us)
978
		# PostEvent 'new_conversation' to notify plugins that the window was created
979
		if { $::ChatWindow::first_message($win_name) == 1 } {
3693 by germinator2000
Small improvements to the gui of autoupdate plugins/lang, and fix the new postevent in chatwindow.tcl
980
			set evPar(chatid) chatid
981
			set evPar(usr_name) usr_name
3692 by gadget_boy
Post the event "new_conversation" when the first message arrives in a chatwindow (the event was not posted when we don't show when a contact opens a chat with us)
982
			::plugins::PostEvent new_conversation evPar
983
		}
984
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
985
		# If this is the first message, and no focus on window, then show notify
7556 by lephilousophe
Fix focus issues when not using Tabbed windows
986
		if { $::ChatWindow::first_message($win_name) == 1 && $msg != "" } {
3010 by yozko
Initial ChatWindow abstraction
987
			set ::ChatWindow::first_message($win_name) 0
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
988
	
989
990
		
991
			if { [::config::getKey newmsgwinstate] == 0 } {
992
				if { [winfo exists .bossmode] } {
993
					set ::BossMode(${win_name}) "normal"
994
					wm state ${top_win} withdraw
995
				} else {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
996
					if { [::config::getKey winmaximized 0] == 1 } {
997
						wm state ${top_win} zoomed
998
					} else {
999
						wm state ${top_win} normal
1000
					}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1001
				}
1002
1003
				wm deiconify ${top_win}
1004
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1005
				if { [OnMac] } {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1006
					::ChatWindow::MacPosition ${top_win}
1007
				} else {
1008
					raise ${top_win}
1009
				}
1010
				
4388 by elezeta
Notify windows will now show when chatwindow opens even if it opens in background
1011
			} else {
1012
				# Iconify the window unless it was raised by the user already.
1013
				if { [wm state $top_win] != "normal" && [wm state $top_win] != "zoomed" } {
1014
					if { [winfo exists .bossmode] } {
1015
						set ::BossMode(${top_win}) "iconic"
1016
						wm state ${top_win} withdraw
1017
					} else {
1018
						wm state ${top_win} iconic
1019
					}
1020
				}
1021
			}
3010 by yozko
Initial ChatWindow abstraction
1022
			if { [string first ${win_name} [focus]] != 0} {
1023
				if { ([::config::getKey notifymsg] == 1 && [::abook::getContactData $chatid notifymsg -1] != 0) ||
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1024
				[::abook::getContactData $chatid notifymsg -1] == 1 } {
7299 by lephilousophe
Added notifies pixmap for new message and new emails
1025
					::amsn::notifyAdd "$msg" "::amsn::chatUser $chatid" "" message
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1026
					#Regive focus on Mac OS X / TkAqua
1027
					if { [OnMac] } {
4181 by germinator2000
Temporary fix for a crash issue on Mac OS X
1028
						after 1000 "catch {focus -force $lastfocus}"
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1029
					}
3010 by yozko
Initial ChatWindow abstraction
1030
				}
1031
			}
8812 by kakaroto
Integrate the level windows inside the chat window, and fix the window getting minimized whenever MakeFor is used to make sure the window exists...
1032
		} elseif { $::ChatWindow::first_message($win_name) == 1 && $msg == "" } {
3010 by yozko
Initial ChatWindow abstraction
1033
			#If it's not a message event, then it's a window creation (user joins to chat)
1034
			if { [::config::getKey newchatwinstate] == 0 } {
1035
				if { [winfo exists .bossmode] } {
3591 by tjikkun
fixed windows not opening in non-tabbed mode
1036
					set ::BossMode(${top_win}) "normal"
1037
					wm state ${top_win} withdraw
3010 by yozko
Initial ChatWindow abstraction
1038
				} else {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
1039
					if { [::config::getKey winmaximized 0] == 1 } {
1040
						wm state ${top_win} zoomed
1041
					} else {
1042
						wm state ${top_win} normal
1043
					}
3010 by yozko
Initial ChatWindow abstraction
1044
				}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1045
3591 by tjikkun
fixed windows not opening in non-tabbed mode
1046
				wm deiconify ${top_win}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1047
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1048
				if { [OnMac] } {
3591 by tjikkun
fixed windows not opening in non-tabbed mode
1049
					::ChatWindow::MacPosition ${top_win}
3010 by yozko
Initial ChatWindow abstraction
1050
				} else {
3591 by tjikkun
fixed windows not opening in non-tabbed mode
1051
					raise ${top_win}
3010 by yozko
Initial ChatWindow abstraction
1052
				}
1053
			} else {
3622 by tuxontoast
Fixed tab container minimising when new user joins the container
1054
				#Container for tabs might be non-iconified
1055
				if { [wm state $top_win] != "normal" } {
1056
					if { [winfo exists .bossmode] } {
1057
						set ::BossMode(${top_win}) "iconic"
1058
						wm state ${top_win} withdraw
1059
					} else {
1060
						wm state ${top_win} iconic
1061
					}
3010 by yozko
Initial ChatWindow abstraction
1062
				}
1063
			}
1064
		}
1065
8071 by kakaroto
As per FreeMind's request (http://www.amsn-project.net/forums/viewtopic.php?p=28548#28548)
1066
		if { $new_window == 1 || [::config::getKey sound_on_first_message 0] == 0 } {
1067
			#If no focus, and it's a message event, do something to the window
1068
			if { (([::config::getKey soundactive] == "1" && $usr_name != [::config::getKey login]) || \
1069
				  [string first ${win_name} [focus]] != 0) && ($msg != "" || [::config::getKey sound_on_first_message 0] == 1)} {
1070
				play_sound type.wav
1071
			}
3010 by yozko
Initial ChatWindow abstraction
1072
		}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1073
3010 by yozko
Initial ChatWindow abstraction
1074
		return $win_name
1075
	}
1076
	#///////////////////////////////////////////////////////////////////////////////
1077
1078
1079
	#///////////////////////////////////////////////////////////////////////////////
1080
	# ::ChatWindow::Name (window)
1081
	# This proc returns the user login (chatid) of the buddy in that chat.
1082
	# Arguments:
1083
	#  - window => Is the chat window widget (.msg_n - Where n is an integer)
1084
	proc Name { window } {
1085
		if { [info exists ::ChatWindow::chat_ids($window)]} {
1086
			return $::ChatWindow::chat_ids($window)
1087
		}
1088
		return 0
1089
	}
1090
	#///////////////////////////////////////////////////////////////////////////////
1091
5662 by vivia
Added proc ::ChatWindow::getAllChatIds
1092
	# ::ChatWindow::getAllChatIds
1093
	# Returns a list of all chatids of all open windows
1094
1095
	proc getAllChatIds { } {
1096
1097
		set chatids ""
1098
		foreach win_name [array names ::ChatWindow::chat_ids] {
1099
			lappend chatids [::ChatWindow::Name $win_name]
1100
		}
1101
		return $chatids
1102
	}
1103
3010 by yozko
Initial ChatWindow abstraction
1104
1105
	#///////////////////////////////////////////////////////////////////////////////
1106
	# ::ChatWindow::Open () 
1107
	# Creates a new chat window and returns its name (.msg_n - Where n is winid)
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1108
	proc Open { {container ""} } {
1109
7433 by scapor
disable wm iconphoto for windows as it the image is corrupted and for tk < 8.4.8 where it's not supported. if this feature is not liked I will remove it
1110
		#calling procs check for [UseContainer] as they have to give the container's path]
1111
		if { $container == "" } {
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1112
			set w [CreateTopLevelWindow]
1113
	
1114
			set mainmenu [CreateMainMenu $w]
1115
			$w conf -menu $mainmenu
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
1116
7556 by lephilousophe
Fix focus issues when not using Tabbed windows
1117
			if { ![OnMac] } {
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
1118
			    # Bind, add new container to list of CWs and restore old setting for the show/hide CW menus
1119
			    bind $w <Control-m> "::ChatWindow::ShowHideChatWindowMenus $w 1"
1120
			    NewChatWindowCreated $w $mainmenu
1121
			    ShowHideChatWindowMenus $w 0
1122
			}
5779 by kakaroto
Added control-m binding for chatwindows too
1123
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1124
			#Send a postevent for the creation of menu
1125
			set evPar(window_name) "$w"
1126
			set evPar(menu_name) "$mainmenu"
1127
			::plugins::PostEvent chatmenu evPar
1128
1129
			#bind on configure for saving the window shape
1130
			bind $w <Configure> "::ChatWindow::Configured %W"
1131
1132
		} else {
1133
			set w [CreateTabbedWindow $container]
1134
		} 
1135
1136
		set copypastemenu [CreateCopyPasteMenu $w]
1137
		set copymenu [CreateCopyMenu $w]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1138
1139
1140
		# Create the window's elements
1141
		set top [CreateTopFrame $w]
1142
		set statusbar [CreateStatusBar $w]
1143
		set paned [CreatePanedWindow $w]
1144
1145
		# Pack them
1146
4796 by scapor
new key to not show the to:-frame in chatwins
1147
		if {[::skin::getKey chat_show_topframe]} {
1148
			pack $top -side top -expand false -fill x -padx [::skin::getKey chat_top_padx]\
1149
				 -pady [::skin::getKey chat_top_pady]
1150
		}
4795 by scapor
new key to not show the status-bar in chatwins
1151
1152
		if {[::skin::getKey chat_show_statusbarframe]} {
4796 by scapor
new key to not show the to:-frame in chatwins
1153
			pack $statusbar -side bottom -expand false -fill x\
1154
				-padx [::skin::getKey chat_status_padx] -pady [::skin::getKey chat_status_pady]
4795 by scapor
new key to not show the status-bar in chatwins
1155
		}
3414 by germinator2000
Remove some "if aqua" inside chatwindow.tcl
1156
		pack $paned -side top -expand true -fill both -padx [::skin::getKey chat_paned_padx]\
1157
		 -pady [::skin::getKey chat_paned_pady]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1158
7794 by kakaroto
Fixes focus issues with new windows being opened when having tabs.
1159
		focus [::ChatWindow::GetInputText $w]
1160
		
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1161
		# Sets the font size to the one stored in our configuration file
1162
		change_myfontsize [::config::getKey textsize] $w
1163
1164
1165
		# Set the properties of this chat window in our ::ChatWindow namespace
1166
		# variables to be accessible from other procs in the namespace
1167
		set ::ChatWindow::titles($w) ""
1168
		set ::ChatWindow::first_message($w) 1
1169
		set ::ChatWindow::recent_message($w) 0
1170
		lappend ::ChatWindow::windows "$w"
1171
3302 by lio_lion
now saves sizes of the pane in the panedwindow
1172
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1173
		# PostEvent 'new_chatwindow' to notify plugins that the window was created
1174
		set evPar(win) "$w"
1175
		::plugins::PostEvent new_chatwindow evPar
1176
7433 by scapor
disable wm iconphoto for windows as it the image is corrupted and for tk < 8.4.8 where it's not supported. if this feature is not liked I will remove it
1177
		if { $container != "" } {
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1178
			AddWindowToContainer $container $w
4681 by germinator2000
Remove some strange window behaviors issues on Mac OS X
1179
		} else {
6729 by kakaroto
sorry for my previous commit, now shuold finally fix the search in chatwindows. thx to ydossow and zaskar
1180
			searchdialog $w.search 
1181
		        $w.search hide 
1182
		        $w.search bindwindow $w 
1183
       		 	$w.search configure -searchin [::ChatWindow::GetOutText $w]
1184
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1185
			if { ![OnMac] } {
4681 by germinator2000
Remove some strange window behaviors issues on Mac OS X
1186
				::ChatWindow::MacPosition $w
1187
			}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1188
		}
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1189
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1190
		return "$w"
1191
	}
1192
	#///////////////////////////////////////////////////////////////////////////////
1193
3771 by airadier
Clean code in a binding a bit
1194
	
1195
	proc CloseTabInContainer { container } {
1196
		set win [::ChatWindow::GetCurrentWindow $container]
1197
		set tab [set ::ChatWindow::win2tab($win)]
1198
		::ChatWindow::CloseTab $tab
1199
		
1200
	}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1201
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1202
	proc CreateNewContainer { } { 
1203
		set container [CreateContainerWindow]
1204
		set mainmenu [CreateMainMenu $container]
3862 by tjikkun
some changes in incomming message handling
1205
		$container configure -menu $mainmenu
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
1206
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1207
		if { ![OnMac] } {
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
1208
		    # Bind, add new container to list of CWs and restore old setting for the show/hide CW menus
1209
		    bind $container <Control-m> "::ChatWindow::ShowHideChatWindowMenus $container 1"
1210
		    NewChatWindowCreated $container $mainmenu
1211
		    ShowHideChatWindowMenus $container 0
1212
		}
1213
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
1214
		#Change Close item menu because the behavior is not the same with tabs
1215
		$container.menu.msn delete "[trans close]"
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1216
		if { [OnMac] } {
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
1217
			$container.menu.msn add command -label "[trans close]" \
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
1218
				-command "::ChatWindow::CloseTabInContainer $container" -accelerator "Command-W"
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
1219
		} else {
1220
			$container.menu.msn add command -label "[trans close]" \
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
1221
				-command "::ChatWindow::CloseTabInContainer $container"
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
1222
		}
1223
		
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
1224
1225
		#we bind <Escape> to close the current tab
1226
		#set current [GetCurrentWindow $container]
1227
		#set currenttab [set win2tab($current)]
3771 by airadier
Clean code in a binding a bit
1228
		#bind $container <<Escape>> "::ChatWindow::CloseTab \[set ::ChatWindow::win2tab(\[::ChatWindow::GetCurrentWindow $container\])\]"
7654 by kakaroto
As requested by 'phantom' at http://www.amsn-project.net/forums/viewtopic.php?t=4180
1229
		if {[::config::getKey escape_close_cw 1] == 1} {
1230
			bind $container <<Escape>> [list ::ChatWindow::CloseTabInContainer $container]
1231
		}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1232
		
1233
		#Send a postevent for the creation of menu
1234
		set evPar(window_name) "$container"
1235
		set evPar(menu_name) "$mainmenu"
1236
		::plugins::PostEvent chatmenu evPar
1237
		
1238
		
1239
		#bind on configure for saving the window shape
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1240
		
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1241
		bind $container <Configure> "::ChatWindow::ContainerConfigured %W"
1242
1243
		set tabbar [CreateTabBar $container] 
1244
		pack $tabbar -side top -fill both -expand false
1245
1246
		return $container
1247
1248
	}
1249
1250
1251
	proc CreateTabBar { w } {
1252
		set bar $w.bar
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
1253
		set less ${bar}.less
1254
		set more ${bar}.more
1255
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1256
		::skin::setPixmap tab tab.gif
3925 by bluetit
tabs now drawn with canvas. x button included. new skin keys are tab_text_x tab_text_y tab_text_width tab_close_x tab_close_y
1257
		::skin::setPixmap tab_close tab_close.gif
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1258
3982 by bluetit
added x and y padding skin keys for tab bar. chat_tabbar_padx and chat_tabbar_pady
1259
		::skin::setPixmap tab_close_hover tab_close_hover.gif
1260
		::skin::setPixmap tab_hover tab_hover.gif
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1261
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
1262
		::skin::setPixmap tab_current tab_current.gif
1263
		::skin::setPixmap tab_flicker tab_flicker.gif
1264
		::skin::setPixmap moretabs moretabs.gif
1265
		::skin::setPixmap lesstabs lesstabs.gif
9063 by square87
The new topcw
1266
		
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
1267
		set less_w [image width [::skin::loadPixmap moretabs]] 
1268
		set more_w [image width [::skin::loadPixmap lesstabs]]
1269
3994 by netmask
Object "frame" does not support padx/pady on Tk 8.3
1270
		frame $bar -class Amsn -relief solid -bg [::skin::getKey tabbarbg] -bd 0
1271
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
1272
		label $less -image [::skin::loadPixmap lesstabs] \
1273
		    -width $less_w -bg [::skin::getKey tabbarbg] -bd 0 -relief flat \
1274
		    -activebackground [::skin::getKey tabbarbg] -highlightthickness 0 -pady 0 -padx 0
1275
		bind $less <<Button1>> "::ChatWindow::LessTabs $w $less $more"
1276
		label $more -image [::skin::loadPixmap moretabs] \
1277
		    -width $more_w -bg [::skin::getKey tabbarbg] -bd 0 -relief flat \
1278
		    -activebackground [::skin::getKey tabbarbg] -highlightthickness 0 -pady 0 -padx 0
1279
		bind $more <<Button1>> "::ChatWindow::MoreTabs $w $less $more"
1280
4207 by kakaroto
Fixed webcam issues with msn7 users.. I hope
1281
		if { $::tcl_version >= 8.4 } {
1282
			$bar configure  -padx [::skin::getKey chat_tabbar_padx] -pady [::skin::getKey chat_tabbar_pady]
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
1283
			$less configure -compound center
1284
			$more configure -compound center
4207 by kakaroto
Fixed webcam issues with msn7 users.. I hope
1285
		}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1286
1287
		return $bar
1288
	}
1289
1290
	###################################################
1291
	# CreateContainerWindow
1292
	# This proc should create the toplevel window for a chat window
1293
	# container and configure it and then return it's pathname
1294
	#
1295
	proc CreateContainerWindow { } {
1296
		set w ".container_$::ChatWindow::containerid"
1297
		incr ::ChatWindow::containerid
1298
			
3862 by tjikkun
some changes in incomming message handling
1299
		chatwindow $w -background [::skin::getKey chatwindowbg]	-borderwidth 0
3867 by tjikkun
bug on receiving chat when chatwindow is not open
1300
#		::Event::registerEvent messageReceived all $w
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1301
		
1302
		# If there isn't a configured size for Chat Windows, use the default one and store it.
1303
		if {[catch { wm geometry $w [::config::getKey wincontainersize] } res]} {
1304
			wm geometry $w 350x390
1305
			::config::setKey wincontainersize 350x390
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
1306
			::config::setKey winmaximized 0
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1307
			status_log "No config(winchatsize). Setting default size for chat window\n" red
1308
		}
1309
1310
		if { [winfo exists .bossmode] } {
1311
			set ::BossMode($w) "iconic"
1312
			wm state $w withdraw
1313
		} else {
1314
			wm state $w iconic
1315
		}
1316
1317
		wm title $w "[trans chat]"
1318
		wm group $w .
1319
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
1320
		# If the platform is NOT windows, set the windows' icon to our xbm
1321
		if { ![OnWin] && [version_vcompare [info patchlevel] 8.4.8] >= 0 } {
1322
			catch {wm iconbitmap $w @[::skin::GetSkinFile pixmaps amsn.xbm]}
1323
			catch {wm iconmask $w @[::skin::GetSkinFile pixmaps amsnmask.xbm]}
1324
		}
1325
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1326
		# Create the necessary bindings
1327
		bind $w <<Cut>> "status_log cut\n;tk_textCut \[::ChatWindow::GetCurrentWindow $w\]"
1328
		bind $w <<Copy>> "status_log copy\n;tk_textCopy \[::ChatWindow::GetCurrentWindow $w\]"
1329
		bind $w <<Paste>> "status_log paste\n;tk_textPaste \[::ChatWindow::GetCurrentWindow $w\]"
1330
6193 by germinator2000
Second part of the GUI patch by David Layer, I reviewed it line by line and fix some minor issues. Now the only patch to be apply is on the makefile and on tkcximage, Phil take a look at it when you have time. Apply this only on HEAD branch, not on 0.96 release
1331
		# Different shortcuts for MacOS
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1332
		if { [OnMac] } {
7742 by tomhennigan
Fix Command-Option-h bug in tabbed chat.
1333
			bind $w <Command-Option-h> "::amsn::ShowChatList \"[trans history]\" \[::ChatWindow::getCurrentTab $w\] ::log::OpenLogWin"
7519 by thaven
Mac only: same app menu for main window and chat window.
1334
5419 by bluetit
Added search dialog to chatwindow.
1335
			# Control-w for closing current tab not implemented on Mac (germinator)
7519 by thaven
Mac only: same app menu for main window and chat window.
1336
			bind $w <Command-Right> "::ChatWindow::GoToNextTab $w"
1337
			bind $w <Command-Left> "::ChatWindow::GoToPrevTab $w"
6193 by germinator2000
Second part of the GUI patch by David Layer, I reviewed it line by line and fix some minor issues. Now the only patch to be apply is on the makefile and on tkcximage, Phil take a look at it when you have time. Apply this only on HEAD branch, not on 0.96 release
1338
                        
7519 by thaven
Mac only: same app menu for main window and chat window.
1339
			bind $w <Control-Tab> "::ChatWindow::GoToNextTab $w"
1340
			bind $w <Control-Shift-Tab> "::ChatWindow::GoToPrevTab $w"
6431 by vivia
That is useful! :) Feel free to change the binding if you dont like it and can come up with sth better...
1341
			#Implement bindings for webcam, see below?
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1342
		} else {
1343
			bind $w <Control-h> \
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
1344
				"::amsn::ShowChatList \"[trans history]\" \[::ChatWindow::GetCurrentWindow $w\] ::log::OpenLogWin"
5424 by bluetit
Small fixes to search
1345
			bind $w <Control-H> \
1346
				"::amsn::ShowChatList \"[trans history]\" \[::ChatWindow::GetCurrentWindow $w\] ::log::OpenLogWin"
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
1347
			bind $w <Control-w> "::ChatWindow::CloseTab \[set ::ChatWindow::win2tab(\[::ChatWindow::GetCurrentWindow $w\])\]"
5424 by bluetit
Small fixes to search
1348
			bind $w <Control-W> "::ChatWindow::CloseTab \[set ::ChatWindow::win2tab(\[::ChatWindow::GetCurrentWindow $w\])\]"
7476 by kakaroto
Added Ctrl-Tab to switch to next tab and Ctrl-Shift-Tab to switch to previous tab. Removed binding of <Tab> to go to the send button (really, it's so totally useless! and it causes the ctrl-tab and ctrl-shift-tab to focus the sendbutton since they trigger the binding..)
1349
			bind $w <Control-Tab> "::ChatWindow::GoToNextTab $w"
1350
			bind $w <Control-Shift-Tab> "::ChatWindow::GoToPrevTab $w"
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
1351
			bind $w <Control-Next> "::ChatWindow::GoToNextTab $w"
1352
			bind $w <Control-Prior> "::ChatWindow::GoToPrevTab $w"
7251 by billiob
change Control-n bindings from "::CAMGUI::WebcamWizard" to "::AVAssistant::AVAssistant"
1353
			bind $w <Control-n> "::AVAssistant::AVAssistant"
1354
			bind $w <Control-N> "::AVAssistant::AVAssistant"
5425 by bluetit
Added search support to chatwindow
1355
		}
1356
1357
		searchdialog $w.search
1358
		$w.search hide
1359
		$w.search bindwindow $w
1360
7654 by kakaroto
As requested by 'phantom' at http://www.amsn-project.net/forums/viewtopic.php?t=4180
1361
		if {[::config::getKey escape_close_cw 1] == 1} {
1362
			bind $w <<Escape>> "::ChatWindow::ContainerClose $w; break"
1363
		}
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
1364
		bind $w <Destroy> "::ChatWindow::DetachAll %W"
5687 by scapor
unsetting more unused variables .. NEEDS SERIOUS TESTING AS IM UNSURE
1365
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1366
		# These bindings are handlers for closing the window (Leave the SB, store settings...)
1367
		wm protocol $w WM_DELETE_WINDOW "::ChatWindow::ContainerClose $w"
1368
1369
1370
		return $w
1371
	}
1372
1373
1374
	proc CreateTabbedWindow { container } {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1375
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1376
		set w "${container}.msg_${::ChatWindow::winid}"
1377
		incr ::ChatWindow::winid
1378
1379
		status_log "tabbed window is : $w\n" red
1380
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
1381
		frame $w -background [::skin::getKey chatwindowbg] -relief solid -bd 0 -padx 0 -pady 0
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1382
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
1383
		# If the platform is NOT windows, set the windows' icon to our xbm
1384
		if { ![OnWin] && [version_vcompare [info patchlevel] 8.4.8] >= 0 } {
1385
			catch {wm iconbitmap $w @[::skin::GetSkinFile pixmaps amsn.xbm]}
1386
			catch {wm iconmask $w @[::skin::GetSkinFile pixmaps amsnmask.xbm]}
1387
		}
1388
1389
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1390
		# Create the necessary bindings
1391
		bind $w <<Cut>> "status_log cut\n;tk_textCut $w"
1392
		bind $w <<Copy>> "status_log copy\n;tk_textCopy $w"
1393
		bind $w <<Paste>> "status_log paste\n;tk_textPaste $w"
1394
1395
		#Change shortcut for history on Mac OS X
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1396
		if { [OnMac] } {
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1397
			bind $w <Command-Option-h> \
1398
				"::amsn::ShowChatList \"[trans history]\" $w ::log::OpenLogWin"
1399
		} else {
1400
			bind $w <Control-h> \
1401
				"::amsn::ShowChatList \"[trans history]\" $w ::log::OpenLogWin"
1402
		}
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
1403
		#I think it's not needed because the container already have <<escape>> binding
1404
		#bind $w <<Escape>> "::ChatWindow::Close $w; break"
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1405
		bind $w <Destroy> "window_history clear %W; ::ChatWindow::Closed $w %W"
1406
1407
1408
		return $w
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
1409
	
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1410
	}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1411
	###################################################
1412
	# CreateTopLevelWindow
1413
	# This proc should create the toplevel window for a chat window
1414
	# configure it and then return it's pathname
1415
	#
1416
	proc CreateTopLevelWindow { } {
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1417
	
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1418
		set w ".msg_$::ChatWindow::winid"
3010 by yozko
Initial ChatWindow abstraction
1419
		incr ::ChatWindow::winid
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
1420
			
1421
		toplevel $w -class Amsn -background [::skin::getKey chatwindowbg]	
1422
		
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1423
		# If there isn't a configured size for Chat Windows, use the default one and store it.
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1424
		if {[catch { wm geometry $w [::config::getKey winchatsize] } res]} {
1425
			wm geometry $w 350x390
3010 by yozko
Initial ChatWindow abstraction
1426
			::config::setKey winchatsize 350x390
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
1427
			::config::setKey winmaximized 0
3010 by yozko
Initial ChatWindow abstraction
1428
			status_log "No config(winchatsize). Setting default size for chat window\n" red
1429
		}
1430
1431
		if { [winfo exists .bossmode] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1432
			set ::BossMode($w) "iconic"
1433
			wm state $w withdraw
3010 by yozko
Initial ChatWindow abstraction
1434
		} else {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1435
			wm state $w iconic
3010 by yozko
Initial ChatWindow abstraction
1436
		}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1437
7433 by scapor
disable wm iconphoto for windows as it the image is corrupted and for tk < 8.4.8 where it's not supported. if this feature is not liked I will remove it
1438
#		wm title $w "[trans chat]"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1439
		wm group $w .
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1440
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
1441
		# If the platform is NOT windows, set the windows' icon to our xbm
1442
		if { ![OnWin] && [version_vcompare [info patchlevel] 8.4.8] >= 0 } {
1443
			catch {wm iconbitmap $w @[::skin::GetSkinFile pixmaps amsn.xbm]}
1444
			catch {wm iconmask $w @[::skin::GetSkinFile pixmaps amsnmask.xbm]}
1445
		}
1446
1447
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1448
		# Create the necessary bindings
1449
		bind $w <<Cut>> "status_log cut\n;tk_textCut $w"
1450
		bind $w <<Copy>> "status_log copy\n;tk_textCopy $w"
1451
		bind $w <<Paste>> "status_log paste\n;tk_textPaste $w"
1452
1453
		#Change shortcut for history on Mac OS X
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1454
		if { [OnMac] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1455
			bind $w <Command-Option-h> \
1456
				"::amsn::ShowChatList \"[trans history]\" $w ::log::OpenLogWin"
1457
		} else {
1458
			bind $w <Control-h> \
1459
				"::amsn::ShowChatList \"[trans history]\" $w ::log::OpenLogWin"
1460
		}
1461
7654 by kakaroto
As requested by 'phantom' at http://www.amsn-project.net/forums/viewtopic.php?t=4180
1462
		if {[::config::getKey escape_close_cw 1] == 1} {
1463
			bind $w <<Escape>> "::ChatWindow::Close $w; break"
1464
		}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1465
		bind $w <Destroy> "window_history clear %W; ::ChatWindow::Closed $w %W"
1466
1467
		#Different shortcuts on Mac OS X
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1468
		if { [OnMac] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1469
			bind $w <Command-,> "Preferences"
3010 by yozko
Initial ChatWindow abstraction
1470
		}
1471
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1472
1473
		# These bindings are handlers for closing the window (Leave the SB, store settings...)
1474
		wm protocol $w WM_DELETE_WINDOW "::ChatWindow::Close $w"
1475
1476
1477
		return $w
1478
1479
	}
1480
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
1481
	proc NewChatWindowCreated { window menu }  {
1482
	    variable chatWindowMenus
1483
	    set chatWindowMenus($window) $menu
1484
	}
1485
	proc ChatWindowDestroyed { window }  {
1486
	    variable chatWindowMenus
1487
	    array unset chatWindowMenus $window
1488
	}
1489
1490
	proc ShowHideChatWindowMenus { {window .} {toggle 0} } {
1491
	    variable chatWindowMenus
1492
1493
	    if {$toggle} { 
1494
		if { [::config::getKey showcwmenus -1] == -1 } {
1495
		    if { [ShowFirstTimeMenuHidingFeature $window] == 0 } {
1496
			return
1497
		    }
1498
		}
1499
		::config::setKey showcwmenus [expr ![::config::getKey showcwmenus -1]] 
1500
		
1501
	    } 
1502
	    
1503
	    if { [::config::getKey showcwmenus -1]} {
1504
		foreach win [array names chatWindowMenus] {
1505
		    if { [winfo exists $win] } {
1506
			$win configure -menu [set chatWindowMenus($win)]
1507
		    }
1508
		}
1509
	    } else {
1510
		foreach win [array names chatWindowMenus] {
1511
		    if { [winfo exists $win] } {
1512
			$win configure -menu {}
1513
		    }
1514
		}
1515
	    }
1516
5779 by kakaroto
Added control-m binding for chatwindows too
1517
	}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1518
1519
	#############################################
1520
	# CreateMainMenu $w
1521
	# This proc should create the main menu of the chat window
1522
	# it only creates the menu supposed to appear in the menu bar actually
1523
	#
1524
	proc CreateMainMenu { w } {
1525
		set mainmenu $w.menu	
1526
6466 by jonne_z
Accompanies my previous commit
1527
		if {[package provide pixmapmenu] != "" && \
6467 by jonne_z
Oops, this should be better
1528
			[info commands pixmapmenu_isEnabled] != "" && [pixmapmenu_isEnabled]} {
5516 by bluetit
Amsn now uses pixmap menus :) Report all bugs please!
1529
			pack [menubar $mainmenu] -fill x -side top
1530
		} else {
1531
			menu $mainmenu -tearoff 0 -type menubar -borderwidth 0 -activeborderwidth -0
1532
		}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1533
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1534
		# App menu, only on Mac OS X (see Mac Interface Guidelines)
7519 by thaven
Mac only: same app menu for main window and chat window.
1535
		if { [OnMac] } { create_apple_menu $mainmenu }
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1536
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1537
		set chatmenu [CreateChatMenu $w $mainmenu]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1538
		set editmenu [CreateEditMenu $w $mainmenu]
1539
		set viewmenu [CreateViewMenu $w $mainmenu]
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1540
		set actionsmenu [CreateActionsMenu $w $mainmenu]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1541
		set contactmenu [CreateContactMenu $w $mainmenu]
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1542
		set helpmenu [CreateHelpMenu $w $mainmenu]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1543
1544
		#no need to call it "file"
1545
		# http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html
1546
		$mainmenu add cascade -label "[trans chat]" -menu $chatmenu
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1547
		$mainmenu add cascade -label "[trans edit]" -menu $editmenu
1548
		$mainmenu add cascade -label "[trans view]" -menu $viewmenu
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1549
		$mainmenu add cascade -label "[trans actions]" -menu $actionsmenu		
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1550
		$mainmenu add cascade -label "[trans contact]" -menu $contactmenu
9133 by tomhennigan
Add the windowlist utility if on OS X. Gives a "Window" menu as required by Apple's HIG.
1551
		if { [OnMac] } {
1552
			# Add a window menu as required by Apple's HIG.
1553
			package require windowlist
1554
			set window [windowlist::windowMenu $mainmenu]
1555
		}
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1556
		$mainmenu add cascade -label "[trans help]" -menu $helpmenu
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1557
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1558
		return $mainmenu
1559
	}
1560
7519 by thaven
Mac only: same app menu for main window and chat window.
1561
	#############################################
1562
	# CreateChatMenu $menu
1563
	# This proc should create the Chat submenu of the chat window
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1564
	#
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1565
	proc CreateChatMenu { w menu } {
1566
		set chatmenu $menu.msn
1567
		menu $chatmenu -tearoff 0 -type normal
1568
1569
		#new chat
1570
		$chatmenu add command -label "[trans newchat]..." \
6220 by billiob
make the feature about starting a new conversation from the CW working
1571
			-command [list ::amsn::ShowUserList [trans sendmsg] ::amsn::chatUser]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1572
			
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1573
		if { [OnMac] } {
1574
			#----------------------
1575
			$chatmenu add separator
1576
			
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1577
			$chatmenu add command -label "[trans close]" \
1578
				-command "::ChatWindow::Close $w" -accelerator "Command-W"
1579
		} 
1580
		
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1581
		#Save
1582
		$chatmenu add command -label "[trans savetofile]..." \
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
1583
			-command "::ChatWindow::SaveToFile \[::ChatWindow::getCurrentTab $w\]"		
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1584
1585
		#----------------------
1586
		$chatmenu add separator
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1587
		
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1588
		#Invite a user to the chat
1589
		$chatmenu add command -label "[trans invite]..." \
1590
			-command "::amsn::ShowInviteList \"[trans invite]\" \[::ChatWindow::getCurrentTab $w\]"
1591
1592
1593
#TODO:		#powertool should add the "hide window" thing here	
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1594
#		if { ![OnMac] } {
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1595
#			$chatmenu add command -label "[trans hidewindow]" \
1596
#				-command "wm state \[winfo toplevel \[::ChatWindow::getCurrentTab $w\]\] withdraw"
1597
#		}
1598
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1599
		if { ![OnMac] } {
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1600
			#----------------------
1601
			$chatmenu add separator
1602
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1603
			$chatmenu add command -label "[trans close]" \
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
1604
				-command "::ChatWindow::Close $w"
3010 by yozko
Initial ChatWindow abstraction
1605
		}
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1606
		
1607
		return $chatmenu
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1608
		
1609
	}
1610
1611
	#############################################
1612
	# CreateEditMenu $menu
1613
	# This proc should create the Edit submenu of the chat window
1614
	#
1615
	proc CreateEditMenu { w menu } {
1616
1617
		set editmenu $menu.edit
1618
1619
		menu $editmenu -tearoff 0 -type normal
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1620
3010 by yozko
Initial ChatWindow abstraction
1621
		#Change the accelerator on Mac OS X
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1622
		if { [OnMac] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1623
			$editmenu add command -label "[trans cut]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1624
				-command "tk_textCut \[::ChatWindow::getCurrentTab $w\]" -accelerator "Command+X"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1625
			$editmenu add command -label "[trans copy]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1626
				-command "tk_textCopy \[::ChatWindow::getCurrentTab $w\]" -accelerator "Command+C"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1627
			$editmenu add command -label "[trans paste]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1628
				-command "tk_textPaste \[::ChatWindow::getCurrentTab $w\]" -accelerator "Command+V"
5419 by bluetit
Added search dialog to chatwindow.
1629
			$editmenu add separator
5424 by bluetit
Small fixes to search
1630
			$editmenu add command \-label "[trans find]" \
5425 by bluetit
Added search support to chatwindow
1631
				-command "$w.search show" -accelerator "Command+F"
5493 by germinator2000
Fix binding for search dialog on Mac OS X
1632
			$editmenu add command -label "[trans findnext]" -command "$w.search findnext" -accelerator "Command+G"
1633
			$editmenu add command -label "[trans findprev]" -command "$w.search findprev" -accelerator "Command+Shift+G"
6431 by vivia
That is useful! :) Feel free to change the binding if you dont like it and can come up with sth better...
1634
			$editmenu add separator
1635
			$editmenu add command -label "[trans editavsettings]" \
7655 by jonne_z
Typo in starting the audio/video assistant on Mac.
1636
				 -command "::AVAssistant::AVAssistant" ;#Accelerator?
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1637
		} else {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1638
			$editmenu add command -label "[trans cut]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1639
				-command "tk_textCut \[::ChatWindow::getCurrentTab $w\]" -accelerator "Ctrl+X"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1640
			$editmenu add command -label "[trans copy]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1641
				-command "tk_textCopy \[::ChatWindow::getCurrentTab $w\]" -accelerator "Ctrl+C"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1642
			$editmenu add command -label "[trans paste]" \
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
1643
				-command "tk_textPaste \[::ChatWindow::getCurrentTab $w\]" -accelerator "Ctrl+V"
5419 by bluetit
Added search dialog to chatwindow.
1644
			$editmenu add separator
1645
			$editmenu add command -label "[trans find]" \
5425 by bluetit
Added search support to chatwindow
1646
				-command "$w.search show" -accelerator "Ctrl+F"
5493 by germinator2000
Fix binding for search dialog on Mac OS X
1647
			$editmenu add command -label "[trans findnext]" -command "$w.search findnext" -accelerator "F3"
1648
			$editmenu add command -label "[trans findprev]" -command "$w.search findprev" -accelerator "Shift+F3"
6431 by vivia
That is useful! :) Feel free to change the binding if you dont like it and can come up with sth better...
1649
			$editmenu add separator
1650
			$editmenu add command -label "[trans editavsettings]" \
6957 by billiob
- add wanted lang keys (i hope you regret now :devil:)
1651
				-command "::AVAssistant::AVAssistant"  -accelerator "Ctrl+N"
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1652
		}
5493 by germinator2000
Fix binding for search dialog on Mac OS X
1653
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1654
		return $editmenu
1655
	}
1656
1657
1658
	#############################################
1659
	# CreateViewMenu $menu
1660
	# This proc should create the View submenu of the chat window
1661
	#
1662
	proc CreateViewMenu { w menu } {
1663
1664
		set viewmenu $menu.view
1665
		menu $viewmenu -tearoff 0 -type normal
1666
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1667
		#show emoticons check
1668
		$viewmenu add checkbutton -label "[trans chatsmileys]" \
1669
			-onvalue 1 -offvalue 0 -variable [::config::getVar chatsmileys]
1670
1671
		#show dp check
1672
		$viewmenu add checkbutton -label "[trans showdisplaypic]" \
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
1673
		    -command "::amsn::ShowOrHidePicture"\
1674
		    -onvalue 1 -offvalue 0 -variable [::config::getVar showdisplaypic]
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
1675
		# Show the button bar check
1676
		$viewmenu add checkbutton -label "[trans hidebuttonbar]" \
1677
		    -command [list ::ChatWindow::ShowOrHideButtonBar]  \
1678
		    -onvalue 0 -offvalue 1 -variable [::config::getVar ShowButtonBar]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1679
		
1680
		#----------------------
1681
		$viewmenu add separator			
1682
		
1683
		#chatstyle
3666 by airadier
Minor rearrangements in chat window menus
1684
		$viewmenu add cascade -label "[trans style]" -menu [CreateStyleMenu $viewmenu]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1685
1686
		#textstyle
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1687
		$viewmenu add cascade -label "[trans textsize]" -menu [CreateTextSizeMenu $viewmenu]
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1688
7102 by kakaroto
Patch provided by Sake Sashemi (http://amsn-project.net/forums/viewtopic.php?p=17434)
1689
		#changefont
1690
		$viewmenu add command -label "[trans changefont]" -command "after 1 change_font [string range $w 1 end] mychatfont"
1691
1692
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1693
		#----------------------
1694
		$viewmenu add separator
1695
1696
		#Clear
1697
		$viewmenu add command -label "[trans clear]" -command [list ::ChatWindow::Clear $w]
1698
1699
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1700
		return $viewmenu
1701
	}
1702
1703
	#############################################
1704
	# CreateTextSizeMenu $menu
1705
	# This proc should create the TextSize submenu of the View menu
1706
	# of the chat window
1707
	#
1708
	proc CreateTextSizeMenu { menu } {
1709
		set textsizemenu $menu.textsize
1710
		menu $textsizemenu -tearoff 0 -type normal
1711
7102 by kakaroto
Patch provided by Sake Sashemi (http://amsn-project.net/forums/viewtopic.php?p=17434)
1712
		$textsizemenu add radiobutton -label "[trans smallest]" -value -2 -variable [::config::getVar textsize] -command "change_myfontsize -2"
1713
		$textsizemenu add radiobutton -label "[trans small]" -value -1 -variable [::config::getVar textsize] -command "change_myfontsize -1"
1714
		$textsizemenu add radiobutton -label "[trans medium]" -value 0 -variable [::config::getVar textsize] -command "change_myfontsize 0"
1715
		$textsizemenu add radiobutton -label "[trans large]" -value 2 -variable [::config::getVar textsize] -command "change_myfontsize 2"
1716
		$textsizemenu add radiobutton -label "[trans largest]" -value 4 -variable [::config::getVar textsize] -command "change_myfontsize 4"
1717
	
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1718
		return $textsizemenu
1719
	}
1720
1721
	#############################################
1722
	# CreateStyleMenu $menu
1723
	# This proc should create the Style submenu of the View menu
1724
	# of the chat window
1725
	#
1726
	proc CreateStyleMenu { menu } { 
1727
1728
		set stylemenu $menu.style
1729
		menu $stylemenu -tearoff 0 -type normal
1730
1731
		$stylemenu add radiobutton -label "[trans msnstyle]" \
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1732
			-value "msn" -variable [::config::getVar chatstyle]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1733
		$stylemenu add radiobutton -label "[trans ircstyle]" \
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1734
			-value "irc" -variable [::config::getVar chatstyle]
8758 by square87
Added a new chat style: compact style
1735
		$stylemenu add radiobutton -label "[trans compactstyle]" \
8759 by square87
typo
1736
			-value "compact" -variable [::config::getVar chatstyle]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1737
		$stylemenu add radiobutton -label "[trans customstyle]..." \
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
1738
			-value "custom" -variable [::config::getVar chatstyle] \
1739
			-command "::amsn::enterCustomStyle"
3010 by yozko
Initial ChatWindow abstraction
1740
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1741
		return $stylemenu
1742
1743
	}
1744
1745
	#############################################
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1746
	# CreateActionsMenu $w $menu
1747
	# This proc should create the Actions submenu of the chat window
1748
	#
1749
	proc CreateActionsMenu { w menu } {
1750
		set actionsmenu $menu.actions
1751
1752
		menu $actionsmenu -tearoff 0 -type normal
1753
1754
		$actionsmenu add command -label "[trans sendfile]..." \
1755
			-command "::amsn::FileTransferSend \[::ChatWindow::getCurrentTab $w\]"
1756
8138 by kakaroto
Cleaned the API for using the SIP client and made that into an MSNSIP namespace.. Also made the UI integrated...
1757
		$actionsmenu add separator
1758
6004 by thaven
Apply English Title Style in Menus, and make a few other little corrections to the menus.
1759
		$actionsmenu add command -label "[trans askcam]..." \
1760
			-command "::amsn::ShowChatList \"[trans askcam]\" \[::ChatWindow::getCurrentTab $w\] ::MSNCAM::AskWebcamQueue"
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1761
6004 by thaven
Apply English Title Style in Menus, and make a few other little corrections to the menus.
1762
		$actionsmenu add command -label "[trans sendcam]..." \
1763
			-command "::amsn::ShowChatList \"[trans sendcam]\" \[::ChatWindow::getCurrentTab $w\] ::MSNCAM::SendInviteQueue"
9800 by kakaroto
Disable sip calls properly, but allow it to still exist when using MSNP18 since it works with tunneled sip. Disable from chatwindow, assistant and fs test at connect time
1764
		
1765
		global enable_sip
1766
		if {$enable_sip} {
1767
			$actionsmenu add command -label "[trans sendsip]..." \
1768
			    -command "::amsn::ShowChatList \"[trans sendsip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 0\""
1769
1770
			$actionsmenu add command -label "[trans sendvideosip]..." \
1771
			    -command "::amsn::ShowChatList \"[trans sendvideosip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 1\""
1772
		}
8138 by kakaroto
Cleaned the API for using the SIP client and made that into an MSNSIP namespace.. Also made the UI integrated...
1773
8030 by baaazen
second step for games: inviting works (but still only direct connections!) and disconnecting-problem for WLM fixed ...
1774
		$actionsmenu add separator
8138 by kakaroto
Cleaned the API for using the SIP client and made that into an MSNSIP namespace.. Also made the UI integrated...
1775
8030 by baaazen
second step for games: inviting works (but still only direct connections!) and disconnecting-problem for WLM fixed ...
1776
		$actionsmenu add cascade -label "[trans playgame]" -menu [::MSNGamesGUI::buildMenu $actionsmenu $w]
1777
		
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1778
		#nudge to add item here
1779
	
1780
		return $actionsmenu
1781
	}
1782
1783
1784
	#############################################
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1785
	# Createcontactmenu $menu
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1786
	# This proc should create the Contact submenu of the chat window
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1787
	#
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1788
	proc CreateContactMenu { w menu } {
1789
		set contactmenu $menu.contact
1790
1791
		menu $contactmenu -tearoff 0 -type normal
1792
1793
1794
		#Chat history
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
1795
		if { [OnMac] } {
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1796
			$contactmenu add command -label "[trans history]" \
3666 by airadier
Minor rearrangements in chat window menus
1797
				-command "::amsn::ShowChatList \"[trans history]\" \[::ChatWindow::getCurrentTab $w\] ::log::OpenLogWin" \
1798
				-accelerator "Command-Option-H"
1799
		} else {
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1800
			$contactmenu add command -label "[trans history]" \
3666 by airadier
Minor rearrangements in chat window menus
1801
				-command "::amsn::ShowChatList \"[trans history]\" \[::ChatWindow::getCurrentTab $w\] ::log::OpenLogWin" \
1802
				-accelerator "Ctrl+H"
1803
		}
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1804
1805
		#webcam history
1806
		$contactmenu add command -label "[trans webcamhistory]" \
4350 by kakaroto
Added webcam logs and fixed a bug in capture extension
1807
		    -command "::amsn::ShowChatList \"[trans webcamhistory]\" \[::ChatWindow::getCurrentTab $w\] ::log::OpenCamLogWin" 
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1808
1809
		#received files
1810
		$contactmenu add command -label "[trans openreceived]..." \
1811
			-command {launch_filemanager "[::config::getKey receiveddir]"}
1812
1813
1814
		#-------------------------
1815
		$contactmenu add separator
1816
		
1817
		#profile
1818
		$contactmenu add command -label "[trans viewprofile]" \
1819
			-command "::amsn::ShowChatList \"[trans viewprofile]\" \[::ChatWindow::getCurrentTab $w\] ::hotmail::viewProfile"		
1820
		
1821
		#email
1822
		$contactmenu add command -label "[trans sendmail]..." \
1823
			-command "::amsn::ShowChatList \"[trans sendmail]\" \[::ChatWindow::getCurrentTab $w\] launch_mailer"		
1824
		
6055 by thaven
Implemented the send sms item in the chatwindow menu
1825
		#sms
1826
		$contactmenu add command -label "[trans sendmobmsg]..." \
6056 by thaven
Oops... forgot to edit the langkey after doing copy/paste...
1827
			-command "::amsn::ShowChatList \"[trans sendmobmsg]\" \[::ChatWindow::getCurrentTab $w\] ::MSNMobile::OpenMobileWindow"
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1828
1829
		#-------------------------
1830
		$contactmenu add separator
1831
		
1832
		#block/unblock
1833
		$contactmenu add command -label "[trans block]/[trans unblock]" \
1834
			-command "::amsn::ShowChatList \"[trans block]/[trans unblock]\" \[::ChatWindow::getCurrentTab $w\] ::amsn::blockUnblockUser"		
1835
		
1836
		#add to list
1837
		$contactmenu add command -label "[trans addtocontacts]" \
1838
			-command "::amsn::ShowAddList \"[trans addtocontacts]\" \[::ChatWindow::getCurrentTab $w\] ::MSN::addUser"
1839
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1840
1841
		#-------------------------
1842
		$contactmenu add separator
1843
6051 by thaven
Implemented one TODO from chatwindow menus (Contact -> Alarm settings)
1844
		#alarm
1845
		$contactmenu add command -label "[trans cfgalarm]" \
1846
			-command "::amsn::ShowChatList \"[trans cfgalarm]\" \[::ChatWindow::getCurrentTab $w\] ::abookGui::showUserAlarmSettings"
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1847
1848
5910 by scapor
chatwindow menus reorganisation following Gnome Hig for linux/window and Mac OSX interface guidelines for mac osx
1849
		#-------------------------
1850
		$contactmenu add separator
1851
1852
		#properties							
1853
		$contactmenu add command -label "[trans properties]" \
1854
			-command "::amsn::ShowChatList \"[trans properties]\" \[::ChatWindow::getCurrentTab $w\] ::abookGui::showUserProperties"
1855
1856
		
1857
		return $contactmenu
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1858
	}
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1859
	
1860
	#############################################
1861
	# CreateHelpMenu $w $menu
1862
	# This proc should create the Actions submenu of the chat window
1863
	#
1864
	proc CreateHelpMenu { w menu } {
5929 by scapor
main window menus ... a lot of work TODO, especially for the groups stuff and the TODO menu items. please use events between protocol/groups.tcl and gui.tcl, I already added one.
1865
		set helpmenu $menu.helpmenu
5918 by scapor
the menu is too crowded otehrwise, feedback was used. why is that helpmenu on the right ?
1866
1867
		menu $helpmenu -tearoff 0 -type normal
1868
1869
		$helpmenu add command -label "[trans helpcontents]" \
1870
			-command "::amsn::showHelpFileWindow HELP [list [trans helpcontents]]"
1871
1872
		$helpmenu add separator
1873
1874
		$helpmenu add command -label "[trans about]" -command ::amsn::aboutWindow
1875
1876
		return $helpmenu
1877
	}	
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1878
1879
1880
	################################################
1881
	# CreateCopyPasteMenu
1882
	# This proc creates the menu shown when a user right clicks 
1883
	# on the input of the chat window
1884
	#
1885
	proc CreateCopyPasteMenu { w } {
1886
		set menu $w.copypaste
1887
1888
		menu $menu -tearoff 0 -type normal
1889
1890
		$menu add command -label [trans cut] \
1891
			-command "status_log cut\n;tk_textCut $w"
1892
		$menu add command -label [trans copy] \
1893
			-command "status_log copy\n;tk_textCopy $w"
1894
		$menu add command -label [trans paste] \
1895
			-command "status_log paste\n;tk_textPaste $w"
7437 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
1896
		$menu add command -label [trans insertsmiley] -command ""
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1897
1898
		return $menu
1899
	}
1900
	
1901
	################################################
1902
	# CreateCopyMenu
1903
	# This proc creates the menu shown when a user right clicks 
1904
	# on the output of the chat window
1905
	#
1906
	proc CreateCopyMenu { w } {
1907
1908
		set menu $w.copy
1909
1910
		menu $menu -tearoff 0 -type normal
1911
1912
		$menu add command -label [trans copy] \
1913
			-command "status_log copy\n;copy 0 $w"
3363 by germinator2000
Remove xmms stuff from amsn-core, use the new plugin instead
1914
			
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1915
		return $menu
1916
	}
1917
1918
	###################################################
1919
	# CreateTopFrame
1920
	# This proc creates the top frame of a chatwindow
1921
	#
1922
	proc CreateTopFrame { w } {
1923
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
1924
		# Create our frame
4565 by lephilousophe
Added pixmap for the To field in chat window
1925
		set top [GetTopFrame $w]
1926
		
4575 by lephilousophe
New mutex system for PutMessage (thanks to Billiob)
1927
		framec $top -type canvas -relief solid -borderwidth [::skin::getKey chat_top_border] -bordercolor [::skin::getKey topbarborder] -background [::skin::getKey topbarbg] -state disabled
4565 by lephilousophe
Added pixmap for the To field in chat window
1928
		
1929
		if { [::skin::getKey chat_top_pixmap] } {
1930
			set bg "::$top.bg"
5782 by scapor
mem savings etc
1931
			set topimg [image create photo [TmpImgName]] ;#gets destroyed
4565 by lephilousophe
Added pixmap for the To field in chat window
1932
			$topimg copy [::skin::loadPixmap cwtopback]
1933
			::picture::Colorize $topimg [::skin::getKey topbarbg]
7312 by lephilousophe
Some cleaning in gui.tcl
1934
			scalable-bg $bg -source $topimg \
1935
				-n [::skin::getKey topbarpady] -e [::skin::getKey topbarpadx] \
1936
				-s [::skin::getKey topbarpady] -w [::skin::getKey topbarpadx] \
1937
				-width 0 -height 0 -resizemethod [::skin::getKey chat_top_resize "tile"]
4565 by lephilousophe
Added pixmap for the To field in chat window
1938
			$top create image 0 0 -image [$bg name] -anchor nw -tag backgnd
7342 by lephilousophe
Now fixed the slowdown we got with scale method...
1939
			bind [$top getinnerframe] <Configure> "$bg configure -width %w -height %h"
1940
			bind [$top getinnerframe] <Destroy> "$bg destroy; image delete $topimg"
4565 by lephilousophe
Added pixmap for the To field in chat window
1941
		}
1942
		
1943
		set toX [::skin::getKey topbarpadx]
7734 by kakaroto
Fix the exploit with the -displayof bug from Tcl/tk
1944
		set usrsX [expr {$toX + [font measure bplainf -displayof $top "[trans to]:"] + 5}]
4565 by lephilousophe
Added pixmap for the To field in chat window
1945
		set txtY [::skin::getKey topbarpady]
1946
		
1947
		$top create text $toX $txtY -fill [::skin::getKey topbartext] -state disabled -font bplainf -text "[trans to]:" -anchor nw -tag to
1948
1949
		$top create text $usrsX $txtY -fill [::skin::getKey topbartext] -state disabled -font sboldf -anchor nw -tag text
1950
		
1951
		#As the contact list isn't filled we set the height to fit with the To field
7341 by lephilousophe
So much simpler...
1952
		$top configure -height [expr {[::ChatWindow::MeasureTextCanvas $top "to" "h"] + 2*[::skin::getKey topbarpady]}]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1953
1954
		return $top
1955
	}
1956
1957
1958
	###################################################
1959
	# CreateStatusBar
1960
	# This proc creates the status bar of a chatwindow
1961
	#
1962
	proc CreateStatusBar { w } {
1963
		
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
1964
		#Create the frame
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1965
		set statusbar $w.statusbar
3472 by lio_lion
some fixes and enhancements for framec
1966
		framec $statusbar -class Amsn -relief solid\
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
1967
				-borderwidth [::skin::getKey chat_status_border] \
1968
				-bordercolor [::skin::getKey chat_status_border_color] \
1969
				-background [::skin::getKey statusbarbg]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1970
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
1971
		# set our inner widget's names
1972
		set status [$statusbar getinnerframe].status
1973
		set charstyped [$statusbar getinnerframe].charstyped
3197 by germinator2000
In skins.tcl file: MacOSX: always use border of 0, always use chatwindowbg for buttonbarbg
1974
1975
		#Create text insert frame
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1976
		text $status  -width 5 -height 1 -wrap none \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
1977
			-font bplainf -borderwidth 0 -background [::skin::getKey statusbarbg] -foreground [::skin::getKey statusbartext]\
3484 by lio_lion
add skinned bgcolour for selected text in statusbar and topbar
1978
			-highlightthickness 0 -selectbackground [::skin::getKey statusbarbg_sel] -selectborderwidth 0 \
7626 by billiob
HUGE skins improvements thanks to Nuitari (from the forums)
1979
			-selectforeground [::skin::getKey statusbartext_sel] -exportselection 1 -pady 4
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1980
		text $charstyped  -width 4 -height 1 -wrap none \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
1981
			-font splainf -borderwidth 0 -background [::skin::getKey statusbarbg] -foreground [::skin::getKey statusbartext]\
3484 by lio_lion
add skinned bgcolour for selected text in statusbar and topbar
1982
			-highlightthickness 0 -selectbackground [::skin::getKey statusbarbg_sel] -selectborderwidth 0 \
7626 by billiob
HUGE skins improvements thanks to Nuitari (from the forums)
1983
			-selectforeground [::skin::getKey statusbartext_sel] -exportselection 1 -pady 4
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1984
1985
1986
		# Configure them
1987
		$charstyped tag configure center -justify left
1988
		$status configure -state disabled
1989
		$charstyped configure -state disabled
1990
1991
		# Pack them
3453 by lio_lion
create procedures for statusbar as previous commits
1992
		pack $status -side left -expand true -fill x -padx 0 -pady 0 -anchor w
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
1993
1994
		if { [::config::getKey charscounter] } {
1995
			pack $charstyped -side right -expand false -padx 0 -pady 0 -anchor e
1996
		}
1997
1998
		return $statusbar
1999
	}
2000
2001
	proc CreatePanedWindow { w } {
2002
		
2003
		set paned $w.f
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2004
		
2005
		panedwindow $paned \
2006
			-background [::skin::getKey chatwindowbg] \
2007
			-borderwidth 0 \
2008
			-relief flat \
2009
			-orient vertical
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2010
2011
		set output [GetOutFrame $w]
2012
		set input [GetInFrame $w]
2013
2014
		frame $output -class Amsn -borderwidth 0 -relief solid \
2015
			-background [::skin::getKey chatwindowbg] -height [::config::getKey winchatoutheight]
2016
2017
		frame $input -class Amsn -borderwidth 0 -relief solid \
2018
			-background [::skin::getKey chatwindowbg]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2019
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2020
		$paned add $output $input
2021
		$paned paneconfigure $output -minsize 50 -height 200
2022
		$paned paneconfigure $input -minsize 100 -height 120
2023
		$paned configure \
2024
			-showhandle [::skin::getKey chat_sash_showhandle] \
2025
			-sashpad [::skin::getKey chat_sash_pady] \
2026
			-sashwidth [::skin::getKey chat_sash_width] \
2027
			-sashrelief [::skin::getKey chat_sash_relief]
3222 by germinator2000
Small fix for hover send button
2028
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2029
		CreateOutputWindow $w $output
2030
		CreateInputWindow $w $input
2031
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2032
		# Bind on focus, so we always put the focus on the input window
2033
		bind $paned <FocusIn> "focus $input"
3339 by kakaroto
Fixed the scrolling problem and chatwindow input/ouput frame minsizes...
2034
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2035
		bind $input <Configure> "::ChatWindow::InputPaneConfigured $paned $input $output %W %h"
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2036
		bind $output <Configure> "::ChatWindow::OutputPaneConfigured $paned $input $output %W %h"
2037
		bind $paned <Configure> "::ChatWindow::PanedWindowConfigured $paned $input $output %W %h"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2038
2039
		return $paned
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2040
	}
2041
2042
2043
	proc GetSashHeight { paned } {
2044
		set sashheight [expr { [$paned cget -sashpad ] + [$paned cget -sashwidth]}]
2045
		if { [ $paned cget -showhandle ] } {
2046
			set handleheight [expr { [$paned cget -sashpad ] + (([$paned cget -sashwidth]+1)/2) + ([$paned cget -handlesize]/2) }]
2047
			if { $handleheight > $sashheight } {
2048
				set sashheight $handleheight
2049
			}
2050
		}
2051
2052
		return $sashheight
2053
	}
2054
2055
	proc SetSashPos { paned input output } {
7297 by kakaroto
Now resizing of chat window will finally have a 'good' resizing of the input frame...
2056
		# We need to get the 'old' bottom size BEFORE doing the [update idletasks]
2057
		# We need to do the [update idletasks] for 'some' reason, probably because placing the sash inside of an event handler 
2058
		# of a sash change will scew up everything... and I think Tk8.5 crashes if we don't...
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2059
		set bottomsize [winfo height $input]
7297 by kakaroto
Now resizing of chat window will finally have a 'good' resizing of the input frame...
2060
		update idletasks
2061
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2062
		if { $bottomsize < [$paned panecget $input -minsize] } {
2063
			set bottomsize [$paned panecget $input -minsize]
2064
		}
2065
		set sashheight [::ChatWindow::GetSashHeight $paned]
2066
		$paned sash place 0 0 [expr {[winfo height $paned] - ($bottomsize + $sashheight)}]
2067
	}
2068
2069
	proc InputPaneConfigured { paned input output W newh } {
3315 by lio_lion
some minor improvements for the calls for saving sizes
2070
		#only run this if the window is the outer frame
3325 by lio_lion
when resizing a window the output frame now changes size instead of the input
2071
		if { ![string equal $input $W]} { return }
3315 by lio_lion
some minor improvements for the calls for saving sizes
2072
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
2073
		set win [string first "msg" $paned]
2074
		set win [string first "." $paned $win]
2075
		incr win -1
2076
		set win [string range $paned 0 $win]
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
2077
2078
		set scrolling [getScrolling [::ChatWindow::GetOutText $win]]
3339 by kakaroto
Fixed the scrolling problem and chatwindow input/ouput frame minsizes...
2079
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2080
		#check that the drag adhered to minsize input pane
2081
		#first checking that there is enough room otherwise you get an infinite loop
2082
		if { ( [winfo height $input] < [$paned panecget $input -minsize] ) \
2083
			&& ( [winfo height $output] > [$paned panecget $output -minsize] ) \
2084
			&& ( [winfo height $paned] > [$paned panecget $output -minsize] ) } {
2085
			::ChatWindow::SetSashPos $paned $input $output
3339 by kakaroto
Fixed the scrolling problem and chatwindow input/ouput frame minsizes...
2086
		}
2087
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
2088
		if { $scrolling } { after 100 "catch {::ChatWindow::Scroll [::ChatWindow::GetOutText $win]}" }
3339 by kakaroto
Fixed the scrolling problem and chatwindow input/ouput frame minsizes...
2089
3315 by lio_lion
some minor improvements for the calls for saving sizes
2090
		if { [::config::getKey savechatwinsize] } {
3338 by lio_lion
tcl8.3 support
2091
			::config::setKey winchatoutheight [winfo height $output]
3315 by lio_lion
some minor improvements for the calls for saving sizes
2092
		}
3196 by kakaroto
fixed what tom removed
2093
	}
2094
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2095
	# this proc is only needed when the sash is moved manually
2096
	# and the input pane is off the screen so the obove doesnt get called
2097
	proc OutputPaneConfigured { paned input output W newh } {
2098
		#only run this if the window is the outer frame
2099
		if { ![string equal $output $W]} { return }
2100
2101
		#only run if input frame not visible
2102
		if { [winfo height $paned] <= [lindex [$paned sash coord 0] 1] + [::ChatWindow::GetSashHeight $paned] } {
2103
		
2104
			#check that the drag adhered to minsize for the input pane
2105
			if { ( [winfo height $input] < [$paned panecget $input -minsize] ) \
2106
					&& ( [winfo height $output] > [$paned panecget $output -minsize] ) \
2107
					&& ( [winfo height $paned] > [$paned panecget $output -minsize] ) } {
7087 by kakaroto
Fixed issues with inkdraw plugin where the buttons in the buttonbar change position when we switch from draw to text mode... now there are no pack forget.. the smileys and font buttons get disabled instead which is better I think so no buttons get scrambled of place...
2108
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2109
				::ChatWindow::SetSashPos $paned $input $output
2110
			}
2111
		}
2112
	}
2113
	
3325 by lio_lion
when resizing a window the output frame now changes size instead of the input
2114
	proc PanedWindowConfigured { paned input output W newh } {
2115
		#only run this if the window is the outer frame
2116
		if { ![string equal $paned $W]} { return }
3336 by lio_lion
change the sash movement method
2117
3325 by lio_lion
when resizing a window the output frame now changes size instead of the input
2118
		#keep the input pane the same size, only change the output		
2119
		#dont call the first time it is created
3342 by lio_lion
pane resizing and minsizes, should be all good this time
2120
		#as the input size hasnt been set yet
2121
		if {([winfo height $input] != 1) || ([winfo height $output] != 1) } {
2122
			::ChatWindow::SetSashPos $paned $input $output
3325 by lio_lion
when resizing a window the output frame now changes size instead of the input
2123
		}
2124
	}
2125
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2126
	proc CreateOutputWindow { w paned } {
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2127
		set out [CreateOutputFrame $w $paned]
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2128
		
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2129
		pack $out -side left -expand true -fill both \
2130
		    -padx [::skin::getKey chat_output_padx] \
2131
		    -pady [::skin::getKey chat_output_pady]
2132
		
9550 by billiob
fix ugly width computing of out DP frame in CW
2133
		set picture [CreateDisplayPicturesFrame $w $paned]
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2134
			
9550 by billiob
fix ugly width computing of out DP frame in CW
2135
		pack $picture -side right -fill y -anchor ne \
2136
		    -padx [::skin::getKey chat_dp_padx] \
2137
		    -pady [::skin::getKey chat_dp_pady]
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2138
	}
2139
2140
	proc CreateOutputFrame { w fr } {
2141
		set out $fr.scroll
2142
		set text $out.text
2143
4617 by lio_lion
fix a padding issue for scrolledwindows
2144
		ScrolledWindow $out -auto vertical -scrollbar vertical -ipad 0
6178 by lephilousophe
Apply J's patch to Trunk too...
2145
		framec $text -type ::ChatWindow::rotext -relief solid -foreground white \
2146
			-background [::skin::getKey chat_output_back_color] -width 45 -height 3 \
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2147
			-setgrid 0 -wrap word -exportselection 1 -highlightthickness 0 -selectborderwidth 1 \
2148
			-borderwidth [::skin::getKey chat_output_border] \
2149
			-bordercolor [::skin::getKey chat_output_border_color]
3466 by lio_lion
another small bug fix
2150
		set textinner [$text getinnerframe]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2151
3314 by lio_lion
Further improvement on pane size saving
2152
		$out setwidget $text
3383 by lio_lion
fix some skinned padding, as well as fix spacing
2153
3414 by germinator2000
Remove some "if aqua" inside chatwindow.tcl
2154
		
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2155
		# Configure our widgets
6178 by lephilousophe
Apply J's patch to Trunk too...
2156
		$text configure -state normal
3478 by lio_lion
correction for selected coloured text
2157
		$text tag configure green -foreground darkgreen -font sboldf
2158
		$text tag configure red -foreground red -font sboldf
2159
		$text tag configure blue -foreground blue -font sboldf
2160
		$text tag configure gray -foreground #404040 -font splainf
4565 by lephilousophe
Added pixmap for the To field in chat window
2161
		$text tag configure gray_italic -foreground #000000 -font sbolditalf
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2162
		$text tag configure white -foreground white -background black -font sboldf
3478 by lio_lion
correction for selected coloured text
2163
		$text tag configure url -foreground #000080 -font splainf -underline true
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2164
2165
		# Create our bindings
3466 by lio_lion
another small bug fix
2166
		bind $textinner <<Button3>> "tk_popup $w.copy %X %Y"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2167
2168
		# Do not bind copy command on button 1 on Mac OS X 
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2169
		if { ![OnMac] } {
8492 by lephilousophe
Make mouse Mac compatible everywhere
2170
			bind $textinner <<Button1>> "copy 0 $w"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2171
		}
2172
6178 by lephilousophe
Apply J's patch to Trunk too...
2173
		# When someone type something in out.text, regive the focus to in.input and insert that key,
2174
		bind $textinner <KeyPress> "::ChatWindow::lastKeytyped %A %K $w"
6802 by tomhennigan
Change some [![catch {tk windowingsystem} wsystem] && $wsystem == "aqua"] statements to [OnMac].
2175
		if {[OnMac]} {
6178 by lephilousophe
Apply J's patch to Trunk too...
2176
			bind $textinner <Command-KeyPress> ";"
2177
			bind $textinner <Command-KeyPress-v> "::ChatWindow::pasteToInput $w"
2178
		}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2179
2180
		#Added to stop amsn freezing when control-up pressed in the output window
2181
		#If you can find why it is freezing and can stop it remove this line
3466 by lio_lion
another small bug fix
2182
		bind $textinner <Control-Up> "break"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2183
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2184
		return $out
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2185
	}
6178 by lephilousophe
Apply J's patch to Trunk too...
2186
	
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2187
	proc CreateDisplayPicturesFrame { w fr } {
2188
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2189
		# Pack them
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2190
		if { [::config::getKey old_dpframe 0] == 0 } {
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
2191
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2192
			# Create them
2193
			frame $fr.f -class Amsn -borderwidth 0  -padx 0 -pady 0 \
2194
	                    -relief solid -background [::skin::getKey chatwindowbg]
2195
			ScrolledWindow $fr.f.sw -scrollbar vertical -auto vertical -borderwidth 0
2196
			ScrollableFrame $fr.f.sw.sf -width 0 -bg [::skin::getKey chatwindowbg]
2197
			$fr.f.sw setwidget $fr.f.sw.sf
2198
			
2199
			# Name our widgets
2200
			set f [$fr.f.sw.sf getframe]
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
2201
			set dpsframe $f.dps
2202
			set images $dpsframe.imgs
2203
			set showpic $dpsframe.showpic
2204
2205
			frame $dpsframe -class Amsn -borderwidth 0 -padx 0 -pady 0 \
2206
					-relief solid -background [::skin::getKey chatwindowbg]
2207
			frame $images -class Amsn -borderwidth 0 -padx 0 -pady 0 \
2208
				-relief solid -background [::skin::getKey chatwindowbg]
2209
2210
2211
			label $showpic -bd 0 -padx 0 -pady 0 -image [::skin::loadPixmap imgshow] \
2212
					-bg [::skin::getKey chatwindowbg] -highlightthickness 0 -font splainf \
2213
					-highlightbackground [::skin::getKey chatwindowbg] -activebackground [::skin::getKey chatwindowbg]
2214
			bind $showpic <Enter> "$showpic configure -image [::skin::loadPixmap imgshow_hover]"
2215
			bind $showpic <Leave> "$showpic configure -image [::skin::loadPixmap imgshow]"
2216
			set_balloon $showpic [trans showdisplaypic]
2217
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2218
			pack $fr.f.sw -fill y -anchor ne
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
2219
			pack $dpsframe -side top -padx 0 -pady 0 -anchor ne
2220
			pack $images -side left -anchor ne
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2221
			pack $showpic -side right -anchor ne
8786 by vivia
someone test this, i cannot get farsight to work anymore
2222
2223
			bind $showpic <<Button1>> [list ::amsn::ToggleShowTopPicture]
2224
			::amsn::ShowOrHideTopPicture
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2225
		} else {
2226
			# Create them
2227
			frame $fr.f -class Amsn -borderwidth 0  -padx 0 -pady 0 \
2228
	                    -relief solid -background [::skin::getKey chatwindowbg]
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2229
		}
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2230
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
2231
		return $fr.f
2232
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
2233
	}
2234
6178 by lephilousophe
Apply J's patch to Trunk too...
2235
	#pasteToInput -- text pasted in output window goes to input window
2236
	#This is processed before the paste occurs, so this is sufficient.
2237
	proc pasteToInput {w} {
2238
		focus -force [::ChatWindow::GetInputText $w]
2239
	}
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2240
8975 by billiob
WIP: show out voip controls
2241
	#lastkeytyped
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
2242
	#Force the focus to the input text box when someone try to write something in the output
6178 by lephilousophe
Apply J's patch to Trunk too...
2243
	proc lastKeytyped {typed keysym w} {
2244
		if {[regexp {^[ -~]$} $typed]} {
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
2245
			focus -force [::ChatWindow::GetInputText $w]
2246
			[::ChatWindow::GetInputText $w] insert insert $typed
6178 by lephilousophe
Apply J's patch to Trunk too...
2247
		} elseif {$keysym == "BackSpace"} {
2248
			focus -force [::ChatWindow::GetInputText $w]
2249
			[::ChatWindow::GetInputText $w] delete "insert - 1 char" insert
2250
		} elseif {$keysym == "Delete"} {
2251
			focus -force [::ChatWindow::GetInputText $w]
2252
			[::ChatWindow::GetInputText $w] delete insert "insert + 1 char"
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
2253
		}
2254
	}
2255
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2256
	proc CreateInputWindow { w paned } {
2257
2258
		status_log "Creating input frame\n"
2259
		# Name our widgets
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2260
		set leftframe $paned.left
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2261
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2262
		# Create The left frame
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2263
		frame $leftframe -class Amsn -background [::skin::getKey chatwindowbg] -relief solid -borderwidth 0
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2264
2265
		# Create the other widgets for the bottom frame
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2266
		set input [CreateInputFrame $w $leftframe]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2267
		set buttons [CreateButtonBar $w $leftframe]
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2268
		set picture [CreatePictureFrame $w $paned]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2269
3383 by lio_lion
fix some skinned padding, as well as fix spacing
2270
		pack $buttons -side top -expand false -fill x -anchor n \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2271
				-padx [::skin::getKey chat_buttons_padx] \
2272
				-pady [::skin::getKey chat_buttons_pady]
3383 by lio_lion
fix some skinned padding, as well as fix spacing
2273
		pack $input -side top -expand true -fill both -anchor n \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2274
				-padx [::skin::getKey chat_input_padx] \
2275
				-pady [::skin::getKey chat_input_pady]
3383 by lio_lion
fix some skinned padding, as well as fix spacing
2276
		pack $leftframe -side left -expand true -fill both \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2277
				-padx [::skin::getKey chat_leftframe_padx] \
2278
				-pady [::skin::getKey chat_leftframe_pady]
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2279
		pack $picture -side right -fill y -anchor ne \
2280
				-padx [::skin::getKey chat_dp_padx] \
2281
				-pady [::skin::getKey chat_dp_pady]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2282
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2283
		if {![::config::getKey ShowButtonBar] == 1 } {
2284
			pack forget $buttons
2285
		}
2286
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2287
		# Bind the focus
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2288
		bind $paned <FocusIn> "focus $input"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2289
5877 by scapor
possible to not have the buttonbar in chatwindows with winskin
2290
		#send chatwininput postevent
2291
		set evPar(input) $input
2292
		set evPar(buttons) $buttons
2293
		set evPar(picture) $picture
2294
		set evPar(window) "$w"
2295
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2296
		::plugins::PostEvent chatwininput evPar
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2297
	}
2298
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2299
	proc ShowButtonBarRightClick { win x y } {
2300
		catch {menu $win.buttonbarmenu -tearoff 0}
2301
		$win.buttonbarmenu delete 0 end
2302
		# Setup the menu
2303
		if {[::config::getKey ShowButtonBar] == 1 } {
2304
			$win.buttonbarmenu add command -label "[trans hidebuttonbar]" -command [list ::ChatWindow::HideButtonBar]
2305
			# Show the menu
2306
			tk_popup $win.buttonbarmenu $x $y
2307
		}
2308
	}
2309
2310
	proc ShowOrHideButtonBar { } {
2311
		if {[::config::getKey ShowButtonBar 1] == 0 } {
2312
			status_log "Hiding Button Bar"
2313
			::ChatWindow::HideButtonBar
2314
		} else {
2315
			status_log "Showing Button Bar"
2316
			::ChatWindow::ShowButtonBar 
2317
		}
2318
	}
2319
2320
	proc HideButtonBar { } {
2321
		# Hide the button bar
2322
		set chatids [::ChatWindow::getAllChatIds]
2323
		# Loop through all chats
2324
		foreach chat $chatids {
2325
			set win [::ChatWindow::For $chat]
2326
			# Un pack the Bar
2327
			pack forget [::ChatWindow::GetButtonBarForWin $win]
2328
		}
2329
		
2330
		::config::setKey ShowButtonBar 0
2331
		
2332
	}
2333
2334
	proc ShowButtonBar { } {
2335
		# Show the button bar
2336
		set chatids [::ChatWindow::getAllChatIds]
2337
		# Loop through the chats
2338
		foreach chat $chatids {
2339
			set win [::ChatWindow::For $chat]
2340
			set buttons [::ChatWindow::GetButtonBarForWin $win]
2341
			# Repack the bar
2342
			pack [::ChatWindow::GetButtonBarForWin $win] -anchor n \
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2343
			    -side top -in [GetLeftFrame $win]  \
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2344
			    -anchor n -expand 0 -fill x -ipadx 0 -ipady 0 \
2345
			    -padx 3 -pady 4 -side top
2346
			pack $win.f.bottom.left.in -side top -expand true \
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2347
			    -fill both -anchor n -in [GetLeftFrame $win] \
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2348
			    -padx [::skin::getKey chat_input_padx] \
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
2349
			    -pady [::skin::getKey chat_input_pady]
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2350
		}
2351
2352
		::config::setKey ShowButtonBar 1
2353
	}
2354
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2355
	proc CreateInputFrame { w bottom} { 
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2356
		# Create The input frame
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2357
		set input $bottom.in
3472 by lio_lion
some fixes and enhancements for framec
2358
		framec $input -class Amsn -relief solid \
3476 by germinator2000
Small change to make it look better on Mac, just tell me if it's good on Win/Linux too
2359
				-background [::skin::getKey sendbuttonbg] \
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2360
				-borderwidth [::skin::getKey chat_input_border] \
2361
				-bordercolor [::skin::getKey chat_input_border_color]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2362
		
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2363
		# set our inner widget's names
4259 by scapor
chatwin changes for possibilities for plugins to add stuff under/above the sendbutton etc .. you'll see my plugin later :)
2364
		set sendbuttonframe [$input getinnerframe].sbframe
2365
		set sendbutton $sendbuttonframe.send
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2366
		set text [$input getinnerframe].text
2367
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2368
		# Create the text widget and the send button widget
6657 by lephilousophe
THat should fix bug where we can't go down more than 3 lines when the textwindow is huge
2369
		text $text -background [::skin::getKey chat_input_back_color] -width 15 -wrap word -font bboldf \
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2370
			-borderwidth 0 -relief solid -highlightthickness 0 -exportselection 1
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2371
		
4259 by scapor
chatwin changes for possibilities for plugins to add stuff under/above the sendbutton etc .. you'll see my plugin later :)
2372
		frame $sendbuttonframe -borderwidth 0 -bg [::skin::getKey sendbuttonbg]
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2373
		
2374
		# Send button in conversation window, specifications and command.
7439 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2375
		button $sendbutton -image [::skin::loadPixmap nullimage] \
7221 by kakaroto
Adding an image to the login button in the login screen..
2376
		    -command "::amsn::MessageSend $w $text" \
7361 by lephilousophe
Added a setting for send button foreground
2377
		    -fg [::skin::getKey sendbuttonfg] -bg [::skin::getKey sendbuttonbg] -bd 0 -relief flat \
7363 by lephilousophe
Shit : typo :@
2378
		    -activebackground [::skin::getKey sendbuttonbg] -activeforeground [::skin::getKey sendbuttonfghover] \
7221 by kakaroto
Adding an image to the login button in the login screen..
2379
		    -text [trans send] -font sboldf -highlightthickness 0 -pady 0 -padx 0 \
2380
		    -overrelief flat -compound center
3010 by yozko
Initial ChatWindow abstraction
2381
7439 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2382
		set send_button_bg [scalable-bg $sendbutton.bg -source [::skin::loadPixmap sendbutton] \
2383
					-n [::skin::getKey sendbuttony 1] -e [::skin::getKey sendbuttonx 1] \
2384
					-s [::skin::getKey sendbuttony 1] -w [::skin::getKey sendbuttonx 1] \
2385
					-resizemethod [::skin::getKey sendbuttonresize "tile"]]
2386
		
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2387
		# Configure my widgets
3193 by bluetit
gui vars in new chat code
2388
		$sendbutton configure -state normal
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2389
		$text configure -state normal
2390
2391
		# Create my bindings
2392
		bind $sendbutton <Return> "::amsn::MessageSend $w $text; break"
7439 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2393
2394
		bind $sendbutton <Enter> [list $send_button_bg configure -source [::skin::loadPixmap sendbutton_hover]]
2395
		bind $sendbutton <Leave> [list $send_button_bg configure -source [::skin::loadPixmap sendbutton]]
2396
		bind $sendbutton <Configure> [list ::ChatWindow::SendButtonResized $sendbutton $send_button_bg %w %h]
2397
		bind $sendbutton <Destroy> [list $send_button_bg destroy]
2398
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2399
		bind $text <Shift-Return> {%W insert insert "\n"; %W see insert; break}
2400
		bind $text <Control-KP_Enter> {%W insert insert "\n"; %W see insert; break}
2401
		bind $text <Shift-KP_Enter> {%W insert insert "\n"; %W see insert; break}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2402
7209 by kakaroto
factorize the code, this is better instead of having two duplicate lines of code...
2403
		# Add a binding for Ctrl-Backspace that seems to be default in Tk to Meta-Backspace (Meta == Alt) but isn't the right thing..
2404
		bind $text <Control-Key-BackSpace> [bind Text <Meta-Key-BackSpace>]
2405
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2406
		# Change shortcuts on Mac OS X (TKAqua). ALT=Option Control=Command on Mac
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2407
		if { [OnMac] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2408
			bind $text <Command-Return> {%W insert insert "\n"; %W see insert; break}
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2409
			bind $text <Command-Shift-space> BossMode
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2410
			bind $text <Command-a> {%W tag add sel 1.0 {end - 1 chars};break}
3774 by germinator2000
-Fix small bug menu in TkAqua for changing font size
2411
			bind $text <Command-A> {%W tag add sel 1.0 {end - 1 chars};break}
7210 by tomhennigan
As reported by friday in the forums, all applications respond to Option-Backspace. (CF. http://forums.cocoaforge.com/viewtopic.php?t=13132)
2412
			bind $text <Option-Key-BackSpace> [bind Text <Meta-Key-BackSpace>]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2413
		} else {
2414
			bind $text <Control-Return> {%W insert insert "\n"; %W see insert; break}
2415
			bind $text <Control-Alt-space> BossMode
2416
			bind $text <Control-a> {%W tag add sel 1.0 {end - 1 chars};break}
3774 by germinator2000
-Fix small bug menu in TkAqua for changing font size
2417
			bind $text <Control-A> {%W tag add sel 1.0 {end - 1 chars};break}
7476 by kakaroto
Added Ctrl-Tab to switch to next tab and Ctrl-Shift-Tab to switch to previous tab. Removed binding of <Tab> to go to the send button (really, it's so totally useless! and it causes the ctrl-tab and ctrl-shift-tab to focus the sendbutton since they trigger the binding..)
2418
			#bind $text <Tab> "focus $sendbutton; break"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2419
		}
2420
7437 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2421
		bind $text <<Button3>> [list ::ChatWindow::OpenPasteMenu $w %X %Y] 
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2422
		bind $text <<Button2>> "paste $w 1"
3010 by yozko
Initial ChatWindow abstraction
2423
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2424
		#Better binding, works for Tk 8.4 only (see proc tification too)
3010 by yozko
Initial ChatWindow abstraction
2425
		if { [catch {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2426
			$text edit modified false
2427
			bind $text <<Modified>> "::amsn::TypingNotification $w $text"
3010 by yozko
Initial ChatWindow abstraction
2428
		} res]} {
2429
			#If fails, fall back to 8.3
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2430
			bind $text <Key> "::amsn::TypingNotification $w $text"
2431
			bind $text <Key-Meta_L> "break;"
2432
			bind $text <Key-Meta_R> "break;"
2433
			bind $text <Key-Alt_L> "break;"
2434
			bind $text <Key-Alt_R> "break;"
2435
			bind $text <Key-Control_L> "break;"
2436
			bind $text <Key-Control_R> "break;"
2437
			bind $text <Key-Return> "break;"
3010 by yozko
Initial ChatWindow abstraction
2438
		}
2439
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2440
		bind $text <Key-Delete> "::amsn::DeleteKeyPressed $w $text %K"
2441
		bind $text <Key-BackSpace> "::amsn::DeleteKeyPressed $w $text %K"
2442
		bind $text <Key-Up> {my_TextSetCursor %W [::amsn::UpKeyPressed %W]; break}
2443
		bind $text <Key-Down> {my_TextSetCursor %W [::amsn::DownKeyPressed %W]; break}
6577 by tjikkun
TextKeySelect for older tk version ok now?
2444
		bind $text <Shift-Key-Up> {::tk::TextKeySelect %W [::amsn::UpKeyPressed %W]; break}
2445
		bind $text <Shift-Key-Down> {::tk::TextKeySelect %W [::amsn::DownKeyPressed %W]; break}
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
2446
3010 by yozko
Initial ChatWindow abstraction
2447
		global skipthistime
2448
		set skipthistime 0
2449
5635 by kakaroto
Added the binding for Ctrl-Shift-S in chatwindow to send text using keyboard
2450
		bind $text <Control-S> "window_history add %W; ::amsn::MessageSend $w %W; break"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2451
		bind $text <Return> "window_history add %W; ::amsn::MessageSend $w %W; break"
2452
		bind $text <Key-KP_Enter> "window_history add %W; ::amsn::MessageSend $w %W; break"
3010 by yozko
Initial ChatWindow abstraction
2453
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
2454
		#Different shortcuts on Mac OS X / TkAqua
2455
		if { [OnMac] } {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2456
			bind $text <Control-s> "window_history add %W; ::amsn::MessageSend $w %W; break"
2457
			bind $text <Command-Up> "window_history previous %W; break"
2458
			bind $text <Command-Down> "window_history next %W; break"
3010 by yozko
Initial ChatWindow abstraction
2459
		} else {
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2460
			bind $text <Alt-s> "window_history add %W; ::amsn::MessageSend $w %W; break"
2461
			bind $text <Control-Up> "window_history previous %W; break"
2462
			bind $text <Control-Down> "window_history next %W; break"
3010 by yozko
Initial ChatWindow abstraction
2463
		}
2464
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2465
		bind $input <FocusIn> "focus $text"
2466
2467
2468
		# Pack My input frame widgets
2469
		pack $text -side left -expand true -fill both -padx 1 -pady 1
4433 by scapor
have the 8.3 sendbutton as younness proposed (a line above and under it )
2470
		pack $sendbutton -side top
4409 by scapor
skin-option to not show the send button
2471
		if {[::skin::getKey chat_show_sendbuttonframe]} {
4879 by scapor
sendbutton packed to the right
2472
			pack $sendbuttonframe -side right -padx [::skin::getKey chat_sendbutton_padx]\
4433 by scapor
have the 8.3 sendbutton as younness proposed (a line above and under it )
2473
				-pady [::skin::getKey chat_sendbutton_pady]
4409 by scapor
skin-option to not show the send button
2474
		}
4259 by scapor
chatwin changes for possibilities for plugins to add stuff under/above the sendbutton etc .. you'll see my plugin later :)
2475
2476
		#send chatsendbutton postevent
2477
		set evPar(window_name) "$w"
2478
		set evPar(bottomleft) [$input getinnerframe]
2479
		::plugins::PostEvent chatsendbutton evPar
5613 by vivia
Drag and Drop file sending, depends on tkdnd package, based on plugin by MeV. HandleFileDrop trimming may need to be adjusted for windows
2480
9758 by vivia
This SHOULD work but it doesnt :(
2481
		set droptarget [::ChatWindow::GetInputText $w]
9853 by vivia
I beg it to work, but it never does... ☹
2482
		status_log "Going to register DND for $droptarget"
2483
		if {[catch {tkdnd::drop_target register $droptarget *} res]} {
9757 by vivia
WIP: tkDND2.0 ... doesnt work, dunno why, gtg
2484
	                status_log "dnd error: $res"
2485
	        } else {
9853 by vivia
I beg it to work, but it never does... ☹
2486
			status_log "DND bind for $droptarget"
9758 by vivia
This SHOULD work but it doesnt :(
2487
			#bind $droptarget <<Drop>> {puts works}
9853 by vivia
I beg it to work, but it never does... ☹
2488
	                bind $droptarget <<Drop:DND_Files>> [list ::fileDropHandler %D sendfile $w]
2489
			bind $droptarget <<Drop:DND_Text>> [list ::fileDropHandler %D pasteText $w]
9757 by vivia
WIP: tkDND2.0 ... doesnt work, dunno why, gtg
2490
		}
2491
2492
#		# Drag and Drop file sending
2493
#		if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Files <Drop> "fileDropHandler %D sendfile $w"} res ]} {
2494
#				status_log "dnd error: $res"
2495
#		}
2496
#		#::dnd bindtarget [::ChatWindow::GetInputText $w] UniformResourceLocator <Drop> "%W insert end %D"
2497
#		if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Text <Drop> {%W insert end %D}} res ]} {
2498
##				status_log "dnd error: $res"
2499
#		}
5613 by vivia
Drag and Drop file sending, depends on tkdnd package, based on plugin by MeV. HandleFileDrop trimming may need to be adjusted for windows
2500
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2501
		return $input
2502
	}
2503
7439 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2504
	proc SendButtonResized {sendbutton sendbutton_bg width height} {
2505
		#Don't put {} here for expr as we need to substitute in the current context
2506
		$sendbutton_bg configure -width [expr $width+2*[::skin::getKey sendbuttonx 1]] \
2507
		    -height [expr $height+2*[::skin::getKey sendbuttony 1]]
2508
		bind $sendbutton <Configure> ""
2509
		$sendbutton configure -image [$sendbutton_bg name]
2510
	}
2511
7437 by kakaroto
As suggested by Coup (http://www.amsn-project.net/forums/viewtopic.php?t=3401)
2512
	proc OpenPasteMenu { w x y } {
2513
		$w.copypaste entryconfigure [$w.copypaste index [trans insertsmiley]] \
2514
		    -command "::smiley::smileyMenu \[winfo pointerx $w\] \[winfo pointery $w\] [::ChatWindow::GetInputText $w]"
2515
		tk_popup $w.copypaste $x $y
2516
	}
4178 by scapor
fix for the bug where the balloon of the block-icon always says 'block' even if the user ifs already blocked. I couldn't make this work fior the mene though .. maybe an ugly hack ? needs revision I guess ;)
2517
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2518
	proc CreateButtonBar { w bottom } {
2519
2520
		status_log "Creating button bar\n"
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2521
		# create the frame
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2522
		set buttons $bottom.buttons
3472 by lio_lion
some fixes and enhancements for framec
2523
		framec $buttons -class Amsn -relief solid \
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2524
				-borderwidth [::skin::getKey chat_buttons_border] \
2525
				-bordercolor [::skin::getKey chat_buttons_border_color] \
2526
				-background [::skin::getKey buttonbarbg]	
2527
7281 by kakaroto
New option to show or hide the button bar from a chat window. Patch provided by Grunty. Thanx.
2528
		# Bind to show the buttonbar right click menu to hide it
2529
		set buttonsinner [$buttons getinnerframe]
2530
		bind $buttonsinner <<Button3>> [list ::ChatWindow::ShowButtonBarRightClick $w %X %Y]
2531
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2532
		# Name our widgets
2533
		set buttonsinner [$buttons getinnerframe]
2534
		set smileys $buttonsinner.smileys
2535
		set fontsel $buttonsinner.fontsel
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2536
		set voice $buttonsinner.voice
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
2537
		set block $buttonsinner.block
2538
		set sendfile $buttonsinner.sendfile
2539
		set invite $buttonsinner.invite
4171 by scapor
Webcam button in the chatwindow, does the same as the menu-item right now. Tom, will you make in-the-default-skin-fitting images :D.
2540
		set webcam $buttonsinner.webcam
8591 by billiob
add a button to hangup/call in the button bar in the CW
2541
		set call $buttonsinner.call
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2542
		set callv $buttonsinner.callv
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2543
2544
		# widget name from another proc
3452 by lio_lion
Create and use function ::ChatWindow::GetInputText, move lastKeytyped to chatwindow
2545
		set input [::ChatWindow::GetInputText $w]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2546
2547
3197 by germinator2000
In skins.tcl file: MacOSX: always use border of 0, always use chatwindowbg for buttonbarbg
2548
		#Smiley button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2549
		button $smileys  -image [::skin::loadPixmap butsmile] -relief flat -padx 0 \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2550
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0 \
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2551
			-highlightbackground [::skin::getKey buttonbarbg]  -activebackground [::skin::getKey buttonbarbg]\
2552
			-command "::smiley::smileyMenu \[winfo rootx $smileys\] \[winfo rooty $smileys\] $input"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2553
		set_balloon $smileys [trans insertsmiley]
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2554
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2555
	       	#Font button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2556
		button $fontsel -image [::skin::loadPixmap butfont] -relief flat -padx 0 \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2557
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2558
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2559
			-command "after 1 change_font [string range $w 1 end] mychatfont"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2560
		set_balloon $fontsel [trans changefont]
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2561
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2562
		#Voice button
2563
		button $voice -image [::skin::loadPixmap butvoice] -relief flat -padx 0 \
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2564
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2565
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]
2566
		set_balloon $voice [trans sendvoice]
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2567
3197 by germinator2000
In skins.tcl file: MacOSX: always use border of 0, always use chatwindowbg for buttonbarbg
2568
		#Block button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2569
		button $block -image [::skin::loadPixmap butblock] -relief flat -padx 0 \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2570
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2571
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2572
			-command "::amsn::ShowChatList \"[trans block]/[trans unblock]\" $w ::amsn::blockUnblockUser"
4214 by lio_lion
better way to have a variable baloon, implemented for block/unblock button
2573
		set_balloon $block "--command--::ChatWindow::SetBlockText $w"
3197 by germinator2000
In skins.tcl file: MacOSX: always use border of 0, always use chatwindowbg for buttonbarbg
2574
		
2575
		#Send file button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2576
		button $sendfile -image [::skin::loadPixmap butsend] -relief flat -padx 0 \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2577
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2578
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2579
			-command "::amsn::FileTransferSend $w"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2580
		set_balloon $sendfile [trans sendfile]
3927 by germinator2000
Now using real sendbutton on Mac OS X
2581
	
3197 by germinator2000
In skins.tcl file: MacOSX: always use border of 0, always use chatwindowbg for buttonbarbg
2582
		#Invite another contact button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2583
		button $invite -image [::skin::loadPixmap butinvite] -relief flat -padx 0 \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
2584
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2585
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2586
			-command "::amsn::ShowInviteMenu $w \[winfo pointerx $w\] \[winfo pointery $w\]"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2587
		set_balloon $invite [trans invite]
4171 by scapor
Webcam button in the chatwindow, does the same as the menu-item right now. Tom, will you make in-the-default-skin-fitting images :D.
2588
2589
		#Webcam button
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2590
		button $webcam -image [::skin::loadPixmap butwebcam] -relief flat -padx 0 \
2591
			-background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2592
			-highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2593
			-command "::ChatWindow::webcambuttonAction $w"
2594
		set_balloon $webcam "--command--::ChatWindow::SetWebcamText"
8591 by billiob
add a button to hangup/call in the button bar in the CW
2595
		
9800 by kakaroto
Disable sip calls properly, but allow it to still exist when using MSNP18 since it works with tunneled sip. Disable from chatwindow, assistant and fs test at connect time
2596
		global enable_sip
2597
		if {$enable_sip} {
2598
			#Call button
2599
			button $call -image [::skin::loadPixmap butcall] -relief flat -padx 0 \
2600
			    -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2601
			    -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2602
			    -command "::amsn::InviteCallFromCW $w 0"
2603
			set_balloon $call "[trans sendsip]"
6856 by tjikkun
more version compare + i forgot to commit my reverted chatwindow edit for black & white window icons
2604
9800 by kakaroto
Disable sip calls properly, but allow it to still exist when using MSNP18 since it works with tunneled sip. Disable from chatwindow, assistant and fs test at connect time
2605
			#Video button
2606
			button $callv -image [::skin::loadPixmap butcallvideo] -relief flat -padx 0 \
2607
			    -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2608
			    -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2609
			    -command "::amsn::InviteCallFromCW $w 1"
2610
			set_balloon $callv "[trans sendvideosip]"
2611
		}
5695 by scapor
cleaning and some TODO work
2612
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2613
		# Pack them
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2614
		pack $fontsel $smileys $voice -side left -padx 0 -pady 0
9800 by kakaroto
Disable sip calls properly, but allow it to still exist when using MSNP18 since it works with tunneled sip. Disable from chatwindow, assistant and fs test at connect time
2615
		if {$enable_sip} {
2616
			pack $block $webcam $sendfile $invite $call $callv -side right -padx 0 -pady 0
2617
		} else {
2618
			pack $block $webcam $sendfile $invite -side right -padx 0 -pady 0
2619
		}
5695 by scapor
cleaning and some TODO work
2620
8492 by lephilousophe
Make mouse Mac compatible everywhere
2621
		bind $voice    <<Button1-Press>> "::ChatWindow::start_voice_clip $w"
2622
		bind $voice    <<Button1>> "::ChatWindow::stop_and_send_voice_clip $w"
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2623
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2624
		# Create our bindings
8213 by billiob
add HangUp button to button bar. I hope it works since i can't test currently
2625
		bind $smileys <Enter> "$smileys configure -image [::skin::loadPixmap butsmile_hover]"
2626
		bind $smileys <Leave> "$smileys configure -image [::skin::loadPixmap butsmile]"
2627
		bind $fontsel <Enter> "$fontsel configure -image [::skin::loadPixmap butfont_hover]"
2628
		bind $fontsel <Leave> "$fontsel configure -image [::skin::loadPixmap butfont]"
2629
		bind $voice <Enter> "$voice configure -image [::skin::loadPixmap butvoice_hover]"
2630
		bind $voice <Leave> "$voice configure -image [::skin::loadPixmap butvoice]"
4214 by lio_lion
better way to have a variable baloon, implemented for block/unblock button
2631
		bind $block <Enter> "$block configure -image [::skin::loadPixmap butblock_hover]"
3218 by bluetit
change image on hover chatbuttons
2632
		bind $block <Leave> "$block configure -image [::skin::loadPixmap butblock]"
3927 by germinator2000
Now using real sendbutton on Mac OS X
2633
		
3218 by bluetit
change image on hover chatbuttons
2634
		bind $sendfile <Enter> "$sendfile configure -image [::skin::loadPixmap butsend_hover]"
2635
		bind $sendfile <Leave> "$sendfile configure -image [::skin::loadPixmap butsend]"
2636
		bind $invite <Enter> "$invite configure -image [::skin::loadPixmap butinvite_hover]"
2637
		bind $invite <Leave> "$invite configure -image [::skin::loadPixmap butinvite]"
4171 by scapor
Webcam button in the chatwindow, does the same as the menu-item right now. Tom, will you make in-the-default-skin-fitting images :D.
2638
		bind $webcam <Enter> "$webcam configure -image [::skin::loadPixmap butwebcam_hover]"
2639
		bind $webcam <Leave> "$webcam configure -image [::skin::loadPixmap butwebcam]"
9800 by kakaroto
Disable sip calls properly, but allow it to still exist when using MSNP18 since it works with tunneled sip. Disable from chatwindow, assistant and fs test at connect time
2640
2641
		if {$enable_sip} {
2642
			bind $call <Enter> "$call configure -image [::skin::loadPixmap butcall_hover]"
2643
			bind $call <Leave> "$call configure -image [::skin::loadPixmap butcall]"
2644
			bind $callv <Enter> "$callv configure -image [::skin::loadPixmap butcallvideo_hover]"
2645
			bind $callv <Leave> "$callv configure -image [::skin::loadPixmap butcallvideo]"
2646
		}
3218 by bluetit
change image on hover chatbuttons
2647
		
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2648
		#send chatwindowbutton postevent
3650 by lio_lion
correct usage of evpar
2649
		set evPar(bottom) $buttonsinner
2650
		set evPar(window_name) "$w"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
2651
		::plugins::PostEvent chatwindowbutton evPar
2652
2653
		return $buttons
2654
	}
5755 by scapor
might need such a proc for the balloon too byut that's esthetics
2655
2656
2657
	proc webcambuttonAction { w } {
2658
		if {[::config::getKey webcamDevice] != ""} {
2659
			::amsn::ShowChatList \"[trans sendwebcaminvite]\" $w ::MSNCAM::SendInviteQueue
6231 by germinator2000
Apply batch by tom for webcam button (and revised by Sander)
2660
		} elseif {[OnMac] } {
2661
			# On mac webcamDevice always returns 0. So we need to check manually if the grabber is open. If the grabber isn't open then we create it.
2662
			# The behaviour of the grabber window opening without the user configuring the cam first is default for most OS X applications, and a lot of users have requested this.
2663
			if {[winfo exists .grabber]} {
2664
				::amsn::ShowChatList \"[trans sendwebcaminvite]\" $w ::MSNCAM::SendInviteQueue
2665
			} else {
2666
				::CAMGUI::CreateGrabberWindowMac
2667
				::amsn::ShowChatList \"[trans sendwebcaminvite]\" $w ::MSNCAM::SendInviteQueue
2668
			}
5755 by scapor
might need such a proc for the balloon too byut that's esthetics
2669
		} else {
7252 by kakaroto
finally, the last little change to get rid of the old webcam wizard!
2670
			::AVAssistant::AVAssistant
5755 by scapor
might need such a proc for the balloon too byut that's esthetics
2671
		}
6231 by germinator2000
Apply batch by tom for webcam button (and revised by Sander)
2672
	}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2673
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2674
	proc AddVoipControls {chatid video {sip ""} {callid ""}} {
8783 by tomhennigan
Commit changes to tcl_farsight.
2675
		
8964 by billiob
WIP: improve voip controls
2676
		set win [::ChatWindow::For $chatid]
2677
2678
		set frame_in [GetInDisplayPictureFrame $win].voip
9514 by billiob
fix window already exists for voip controls
2679
		if {[winfo exists $frame_in]} {destroy $frame_in}
8964 by billiob
WIP: improve voip controls
2680
		set frame_out [GetOutDisplayPicturesFrame $win].voip
9514 by billiob
fix window already exists for voip controls
2681
		if {[winfo exists $frame_out]} {destroy $frame_out}
2682
8964 by billiob
WIP: improve voip controls
2683
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2684
		package require voipcontrols
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2685
		status_log "Creating CW Voip controls"
8964 by billiob
WIP: improve voip controls
2686
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2687
		voipcontrol $frame_in -orient vertical \
2688
			-bg [::skin::getKey chatwindowbg]\
9185 by kakaroto
Use the new buthangup_mini for voipcontrols
2689
			-endcallimage [::skin::loadPixmap buthangup_mini] \
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2690
			-endcallstate disabled \
9152 by billiob
improve the voipcontrols
2691
			-mutedimage [::skin::loadPixmap mic_muted] \
2692
			-unmutedimage [::skin::loadPixmap mic] \
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2693
			-mutecommand [list ::ChatWindow::MuteIn $frame_in] \
2694
			-mutevariable ::ChatWindow::voip_mute_in \
2695
			-volumecommand [list ::ChatWindow::VolumeIn $frame_in] \
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2696
			-volumevariable [::config::getVar fs_in_volume]
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2697
		if { [::config::getKey old_dpframe 0] == 0 } {
2698
			set orient "horizontal"
2699
		} else {
2700
			set orient "vertical"
2701
		}
2702
		voipcontrol $frame_out -orient $orient \
2703
			-bg [::skin::getKey chatwindowbg]\
9185 by kakaroto
Use the new buthangup_mini for voipcontrols
2704
			-endcallimage [::skin::loadPixmap buthangup_mini] \
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2705
			-endcallstate disabled \
9152 by billiob
improve the voipcontrols
2706
			-mutedimage [::skin::loadPixmap speaker_muted] \
2707
			-unmutedimage [::skin::loadPixmap speaker] \
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2708
			-mutecommand [list ::ChatWindow::MuteOut $frame_out] \
2709
			-mutevariable ::ChatWindow::voip_mute_out \
2710
			-volumecommand [list ::ChatWindow::VolumeOut $frame_out] \
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2711
			-volumevariable [::config::getVar fs_out_volume]
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2712
		$frame_in configure -width [$frame_in getSize]
2713
		pack $frame_in -side left -padx 0 -pady 0 -anchor w -fill y
2714
		if { [::config::getKey old_dpframe 0] == 0 } {
2715
			$frame_out configure -height [$frame_out getSize]
2716
			pack $frame_out -side bottom -padx 0 -pady 0 -anchor ne -fill x
2717
		} else {
2718
			$frame_out configure -width [$frame_out getSize]
2719
			$frame_out configure -height 150
2720
			pack $frame_out -side bottom -padx 0 -pady 0 -anchor ne
8964 by billiob
WIP: improve voip controls
2721
		}
8812 by kakaroto
Integrate the level windows inside the chat window, and fix the window getting minimized whenever MakeFor is used to make sure the window exists...
2722
2723
		set ::ChatWindow::voip_mute_in 0
2724
2725
		set ::ChatWindow::voip_mute_out 0
2726
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2727
		UpdateVoipControls $chatid $video $sip $callid
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2728
2729
2730
		#Redraw the frames correctly
2731
		::amsn::ShowOrHidePicture
2732
		if { [winfo exists [::ChatWindow::GetOutDisplayPicturesFrame $win].dps] } {
2733
				::amsn::ShowOrHideTopPicture
2734
		}
2735
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2736
	}
2737
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2738
	proc UpdateVoipControls {chatid video {sip ""} {callid ""}} {
8783 by tomhennigan
Commit changes to tcl_farsight.
2739
		
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2740
		set window [::ChatWindow::For $chatid]
2741
8809 by billiob
add a SW/F to the InDPFrame in the CW
2742
		set frame_in [GetInDisplayPictureFrame $window].voip
8807 by billiob
use scrollwindow to embed voip controls+ out DPs. but it doesn't behave the way i want :s
2743
		set frame_out [GetOutDisplayPicturesFrame $window].voip
9152 by billiob
improve the voipcontrols
2744
		if {![winfo exists $frame_in] || ![winfo exists $frame_out]} {
2745
			return
2746
		}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2747
8954 by kakaroto
stop spamming the status log
2748
		#status_log "Updating CW Voip controls"
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2749
8964 by billiob
WIP: improve voip controls
2750
		#IN
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2751
		if {[catch {set volume [::Farsight::SetVolumeIn [::config::getKey fs_in_volume]]} ] } {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2752
			$frame_in configure -volumestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2753
		} else {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2754
			$frame_in configure -volumestate normal
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2755
		}
2756
		if {[catch {set mute [::Farsight::GetMuteIn]} ] } {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2757
			$frame_in configure -mutestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2758
		} else {
2759
			set ::ChatWindow::voip_mute_in $mute
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2760
			$frame_in configure -mutestate normal
9380 by kakaroto
Fix voipcontrols mute/unmute buttons appearance at initial startup
2761
			if {$mute} {
2762
				$frame_in Mute
2763
			} else {
2764
				$frame_in UnMute
2765
			}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2766
		}
2767
8964 by billiob
WIP: improve voip controls
2768
		#OUT
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2769
		if {[catch {set volume [::Farsight::SetVolumeOut [::config::getKey fs_out_volume]]} ] } {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2770
			$frame_out configure -volumestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2771
		} else {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2772
			$frame_out configure -volumestate normal
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2773
		}
2774
		if {[catch {set mute [::Farsight::GetMuteOut]} ] } {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2775
			$frame_out configure -mutestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2776
		} else {
2777
			set ::ChatWindow::voip_mute_out $mute
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2778
			$frame_out configure -mutestate normal
9380 by kakaroto
Fix voipcontrols mute/unmute buttons appearance at initial startup
2779
			if {$mute} {
2780
				$frame_out Mute
2781
			} else {
2782
				$frame_out UnMute
2783
			}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2784
		}
2785
2786
		if {$sip != "" && $callid != ""} {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2787
			$frame_in configure -endcallstate normal\
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2788
			    -endcallcommand [list ::amsn::HangupSIPCall $video $chatid $sip $callid]
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2789
			$frame_out configure -endcallstate normal\
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2790
			    -endcallcommand [list ::amsn::HangupSIPCall $video $chatid $sip $callid]
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2791
		} else {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2792
			$frame_in configure -endcallstate disabled
2793
			$frame_out configure -endcallstate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2794
		}
2795
	}
2796
2797
	proc RemoveVoipControls {chatid} {
8783 by tomhennigan
Commit changes to tcl_farsight.
2798
		
8964 by billiob
WIP: improve voip controls
2799
		set win [::ChatWindow::For $chatid]
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2800
8964 by billiob
WIP: improve voip controls
2801
		set frame_in [GetInDisplayPictureFrame $win].voip
2802
		set frame_out [GetOutDisplayPicturesFrame $win].voip
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2803
2804
		status_log "Removing CW Voip controls"
8964 by billiob
WIP: improve voip controls
2805
		catch {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2806
			destroy $frame_in
9109 by billiob
should fix some bugs with voipcontrols
2807
		}
2808
		catch {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2809
			destroy $frame_out
8964 by billiob
WIP: improve voip controls
2810
		}
9109 by billiob
should fix some bugs with voipcontrols
2811
		
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2812
		if { [::config::getKey old_dpframe 0] != 0 } {
2813
			#WTF IS THIS NOT WORKING?????
2814
			[GetOutDisplayPicturesFrame $win] configure -width 0
2815
			[winfo parent [GetOutDisplayPicturesFrame $win]] configure -width 0
2816
		}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2817
		catch {
2818
			unset ::ChatWindow::voip_mute_in
9113 by billiob
no longer use the amplification stuff. volume is in dB
2819
		}
2820
		catch {
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2821
			unset ::ChatWindow::voip_mute_out
9113 by billiob
no longer use the amplification stuff. volume is in dB
2822
		}
9551 by kakaroto
Revert billiob's latest commit because it breaks regression. Scrolled frame was used for multi user chats
2823
2824
		#Redraw the frames correctly
2825
		::amsn::ShowOrHidePicture
2826
		if { [winfo exists [::ChatWindow::GetOutDisplayPicturesFrame $win].dps] } {
2827
				::amsn::ShowOrHideTopPicture
2828
		}
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2829
	}
2830
2831
	proc MuteIn {w } {
2832
		if {[catch {::Farsight::SetMuteIn $::ChatWindow::voip_mute_in}]} {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2833
			$w configure -mutestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2834
		}
2835
	}
2836
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2837
	proc VolumeIn {widget val} {
2838
		if {[catch {::Farsight::SetVolumeIn $val}]} {
9109 by billiob
should fix some bugs with voipcontrols
2839
			$widget configure -volumestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2840
		}
2841
	}
2842
	proc MuteOut {w } {
2843
		if {[catch {::Farsight::SetMuteOut $::ChatWindow::voip_mute_out}]} {
9103 by billiob
Clean a bit voipcontrols code in cw.tcl
2844
			$w configure -mutestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2845
		}
2846
	}
2847
9440 by kakaroto
Make the volume setting a config variable, so volume settings will be saved and restore through multiple calls
2848
	proc VolumeOut {widget val} {
2849
		if {[catch {::Farsight::SetVolumeOut $val}]} {
9152 by billiob
improve the voipcontrols
2850
			$widget configure -volumestate disabled
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
2851
		}
2852
	}
8213 by billiob
add HangUp button to button bar. I hope it works since i can't test currently
2853
	
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2854
	proc setCallButton {chatid type video {sip ""} {callid ""}} {
8213 by billiob
add HangUp button to button bar. I hope it works since i can't test currently
2855
		set win [For $chatid]
2856
		if { $win == 0 } {
2857
			status_log "Oops, no CW for chatid : $chatid" red
2858
			return
2859
		}
2860
		set buttons [GetButtonBarForWin $win]
2861
		set buttonsinner [$buttons getinnerframe]
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2862
		if {$video } {
2863
			set button $buttonsinner.callv
2864
			set otherbutton $buttonsinner.call
2865
			set txt [trans sendvideosip]
2866
		} else {
2867
			set button $buttonsinner.call
2868
			set otherbutton $buttonsinner.callv
2869
			set txt [trans sendsip]
2870
		}
2871
		if {$type == "invite" } {
2872
			set cmd [list ::amsn::InviteCallFromCW [::ChatWindow::For $chatid] $video]
2873
			set disable 0
2874
		} elseif {$type == "hangup" } {
2875
			set cmd [list ::amsn::HangupSIPCall $video $chatid $sip $callid] 
2876
			set disable 1
2877
			set txt [trans hangup]
2878
		} elseif {$type == "cancel" } {
2879
			set cmd [list ::amsn::CancelSIPCall $video $chatid $sip $callid]
2880
			set disable 1
2881
			set txt [trans hangup]
9384 by kakaroto
If you use the buttonbar to reject a sip call, it wouldn't disable the CW accept/reject and wouldn't send the reject to the peer... now fixed
2882
		} elseif {$type == "decline" } {
2883
			set cmd [list ::amsn::DeclineSIPCall $video $chatid $sip $callid]
2884
			set disable 1
2885
			set txt [trans reject]
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2886
		} else {
2887
			return
2888
		}
2889
2890
		if {[winfo exists $button]} {
2891
			$button configure -command ${cmd}
2892
			set_balloon $button $txt
2893
		} else {
2894
			return
2895
		}
2896
9384 by kakaroto
If you use the buttonbar to reject a sip call, it wouldn't disable the CW accept/reject and wouldn't send the reject to the peer... now fixed
2897
		if {$disable} {
9256 by kakaroto
Add a video call button to the button bar in the CW and make sure that we enable/disable and work with the right button when we start a video call
2898
			if {$video} {
2899
				$button configure -image [::skin::loadPixmap buthangupvideo]
2900
				bind $button <Enter> "$button configure -image [::skin::loadPixmap buthangupvideo_hover]"
2901
				bind $button <Leave> "$button configure -image [::skin::loadPixmap buthangupvideo]"
2902
			} else {
2903
				$button configure -image [::skin::loadPixmap buthangup]
2904
				bind $button <Enter> "$button configure -image [::skin::loadPixmap buthangup_hover]"
2905
				bind $button <Leave> "$button configure -image [::skin::loadPixmap buthangup]"
2906
			}
2907
			$otherbutton configure -state disabled
2908
		} else {
2909
			if {$video} {
2910
				$button configure -image [::skin::loadPixmap butcallvideo]
2911
				bind $button <Enter> "$button configure -image [::skin::loadPixmap butcallvideo_hover]"
2912
				bind $button <Leave> "$button configure -image [::skin::loadPixmap butcallvideo]"
2913
			} else {
2914
				$button configure -image [::skin::loadPixmap butcall]
2915
				bind $button <Enter> "$button configure -image [::skin::loadPixmap butcall_hover]"
2916
				bind $button <Leave> "$button configure -image [::skin::loadPixmap butcall]"
2917
			}
2918
			$otherbutton configure -state normal
8591 by billiob
add a button to hangup/call in the button bar in the CW
2919
		}
8213 by billiob
add HangUp button to button bar. I hope it works since i can't test currently
2920
	}
2921
6396 by kakaroto
FINALLY it works for Mac!!!!!
2922
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2923
	proc start_voice_clip { w } {
2924
		variable voice_sound
2925
		variable voice_text_pack
2926
2927
		set chatid [Name $w]
2928
		if { [llength  [::MSN::usersInChat $chatid]] > 0 } {
6399 by kakaroto
am I stupid or what ? I guess too tired...
2929
			if { [catch {require_snack} ] || [package vcompare [set ::snack::patchLevel] 2.2.9] < 0 || [catch {package require tcl_siren }] } {
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2930
				amsn::WinWrite $chatid "\n" red
2931
				amsn::WinWriteIcon $chatid greyline 3
2932
				amsn::WinWrite $chatid "\n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
2933
				amsn::WinWriteIcon $chatid voice_icon 3 2
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2934
				amsn::WinWrite $chatid "[timestamp] [trans snackneeded]\n" red
2935
				amsn::WinWriteIcon $chatid greyline 3
2936
				return
2937
			}
2938
2939
			catch { $voice_sound destroy }
2940
2941
			set voice_sound [::snack::sound]
2942
			if { [catch {$voice_sound record} res]} {
2943
				
2944
				amsn::WinWrite $chatid "\n" red
2945
				amsn::WinWriteIcon $chatid greyline 3
2946
				amsn::WinWrite $chatid "\n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
2947
				amsn::WinWriteIcon $chatid voice_icon 3 2
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2948
				amsn::WinWrite $chatid "[timestamp] [trans recorderror $res]\n" red
2949
				amsn::WinWriteIcon $chatid greyline 3
2950
				$voice_sound destroy
2951
			} else {
2952
				set inputtext [GetInputText $w]
2953
				set inputframe [winfo parent $inputtext]
7087 by kakaroto
Fixed issues with inkdraw plugin where the buttons in the buttonbar change position when we switch from draw to text mode... now there are no pack forget.. the smileys and font buttons get disabled instead which is better I think so no buttons get scrambled of place...
2954
2955
				# Here, we'll build a list of the packes children of the inputframe, excluding the send button.. this will allow us to remove anything packed inside
2956
				# the inputframe and replace it with the voice clip widget... we'll also save the pack info for each one of them... 
2957
				# This is useful if we want to keep the capability of sending voice clips when the inkdraw plugin is activated and the text widget is unpacked
2958
				# and the drawboard is packed instead... 
2959
				set slaves [pack slaves $inputframe]
2960
				set voice_text_pack [list]
2961
				foreach slave $slaves {
2962
					if {$slave != "$inputframe.sbframe" } {
2963
						lappend voice_text_pack [list $slave [pack info $slave]]
2964
						pack forget $slave
2965
					}
2966
				}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2967
				canvas $inputframe.wave -background [::skin::getKey chat_input_back_color] -borderwidth 0 -relief solid
7087 by kakaroto
Fixed issues with inkdraw plugin where the buttons in the buttonbar change position when we switch from draw to text mode... now there are no pack forget.. the smileys and font buttons get disabled instead which is better I think so no buttons get scrambled of place...
2968
				eval pack $inputframe.wave -side left -padx 0 -pady 0 -expand true -fill both
6712 by kakaroto
I HOPE this fixes the bug...
2969
2970
				# This update here is necessary because it seems if we don't update, the waveform won't appear...
2971
				# this is because we depend on the [winfo width] and [winfo height] for the waveform size
6361 by kakaroto
Made the "15seconds limit" visible for users..
2972
				update
6811 by tomhennigan
Just a small fix to catch an error where the user clicks/unclicks too quickly on the voiceclip icon.
2973
				
2974
				# If the user clicks/unclicks quickly then the update statement will cause the waveform to be destroyed. So we check for that.
2975
				if {![winfo exists ${inputframe}.wave]} {
2976
					status_log "VoiceClips: Waveform destroyed during start_voice_clip function." red
2977
					return
2978
				}
2979
				
6362 by kakaroto
oups, forgot to save before commit...
2980
				$inputframe.wave create waveform 0 0 -sound $voice_sound -zerolevel 0 -width [winfo width $inputframe.wave] -height [winfo height $inputframe.wave] -pixelspersecond [expr {[winfo width $inputframe.wave] / 15}]
6712 by kakaroto
I HOPE this fixes the bug...
2981
6361 by kakaroto
Made the "15seconds limit" visible for users..
2982
								
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2983
				
2984
				::MSN::SendRecordingUserNotification $chatid
2985
				after 15000 "::ChatWindow::stop_and_send_voice_clip $w"
2986
			}
2987
		}
2988
	}
2989
2990
	# This proc is not needed because I found the undocumented 'datasamples' subcommand...
2991
	proc SoundToWave { sound filename } {
2992
		$sound convert -rate 16000 -channels 2
2993
		
2994
		set input [$sound data]
2995
		
2996
		binary scan $input @0a4ia4 riff size wave
2997
		set offset 12
7385 by lephilousophe
Remove some debug
2998
		#puts "found size $size"
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
2999
		while { $offset < $size } {
3000
			binary scan $input @${offset}a4i id chunk_size
3001
			incr offset 8
7385 by lephilousophe
Remove some debug
3002
			#puts "found chunk $id $chunk_size"
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3003
			if {$id == "data" } {
3004
				set data [string range $input $offset [expr {$offset + $chunk_size - 1}]]
3005
			} 
3006
			incr offset $chunk_size
3007
			
3008
		}
3009
		
3010
		if { [info exists data] } {
3011
			set enc [::Siren::NewEncoder]
7385 by lephilousophe
Remove some debug
3012
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3013
			if { [catch {set out [::Siren::Encode $enc $data] } res] } {
3014
				::Siren::Close $enc    		
3015
				status_log "Error Encoding : $res"
3016
				return 0
3017
			}
7385 by lephilousophe
Remove some debug
3018
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3019
			::Siren::WriteWav $enc $filename $out 
3020
			::Siren::Close $enc
3021
		}
3022
		return 1
3023
	}
3024
		
3025
	proc DecodeWave { file_in file_out } {
7815 by kakaroto
Allow users who do not have libsnack installed to still be able to *receive* voice clips.
3026
		if { [catch {package require tcl_siren 0.3}] } {
6715 by kakaroto
corrected the DeplayedStop
3027
			return -1
3028
		} else {
3029
			set fd [open $file_in r]
3030
			fconfigure $fd -translation binary
3031
			set input [read $fd]
3032
			close $fd
3033
			
3034
			set riff ""
3035
			set wave ""
3036
			binary scan $input @0a4ia4 riff size wave
3037
			set offset 12
3038
			if { $riff == "RIFF" && $wave == "WAVE" } {
3039
				while { $offset < $size } {
3040
					binary scan $input @${offset}a4i id chunk_size
3041
					incr offset 8
3042
					if {$id == "fmt " } {
3043
						binary scan $input @${offset}ssiiss format channels sampleRate byteRate blockAlign bitsPerSample
3044
					}
3045
					if {$id == "data" } {
3046
						set data [string range $input $offset [expr {$offset + $chunk_size - 1}]]
3047
					} 
3048
					incr offset $chunk_size
3049
					
3050
				}
3051
			}
3052
			
3053
			if {![info exists format] } {
3054
				set format 1
3055
			}
3056
			
3057
			if { [info exists data] && [expr {$format == 0x028E}] } {
3058
				set dec [::Siren::NewDecoder]
3059
				if { [catch {set out [::Siren::Decode $dec $data] } res] } {
3060
					::Siren::Close $dec    		
3061
					status_log "Error Decoding : $res"
3062
					return 0
3063
				}
3064
				::Siren::WriteWav $dec $file_out $out 
3065
				::Siren::Close $dec
3066
				return 1
3067
			} else {
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3068
				return 0
3069
			}
3070
		}
3071
	}
3072
	
3073
3074
	proc stop_and_send_voice_clip { w } {
3075
		variable voice_sound
3076
		variable voice_text_pack
3077
		global HOME
3078
3079
		after cancel "::ChatWindow::stop_and_send_voice_clip $w"
3080
3081
		set chatid [Name $w]
3082
		if { [info exists voice_text_pack] } {
3083
			set inputtext [GetInputText $w]
3084
			set inputframe [winfo parent $inputtext]
3085
			
6712 by kakaroto
I HOPE this fixes the bug...
3086
			# This update is here to prevent a race condition. if you click very fast ont he voice button the first time
3087
			# the 'pressed' event will get called, and the 'unpressed' event will be called too right after it, but if we do 
3088
			# a 'package require snack', etc.. it might take some time for it to load, etc, so we could get the stop_voice_clip
3089
			# proc being called before the start_voice_clip has finished processing, so we can get here, destroy the wave form before 
3090
			# the start_voice_clip proc finished using it, which would result in a bug.
3091
			# 
6808 by tomhennigan
This seems to fix the issues with voiceclips :-)
3092
			update idletasks
6712 by kakaroto
I HOPE this fixes the bug...
3093
			
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3094
			destroy $inputframe.wave
7087 by kakaroto
Fixed issues with inkdraw plugin where the buttons in the buttonbar change position when we switch from draw to text mode... now there are no pack forget.. the smileys and font buttons get disabled instead which is better I think so no buttons get scrambled of place...
3095
			foreach slave $voice_text_pack {
3096
				eval pack [lindex $slave 0] [lindex $slave 1]
3097
			}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3098
			unset voice_text_pack
3099
		}
3100
3101
		# Should we remove the usersInChat ? I know I added it for some reason.. can't remember what.. 
3102
		# think about you send a voice clip and the user closes your window at the same time? should the message be lost ?
3103
		if { [llength  [::MSN::usersInChat $chatid]] > 0 && [catch {$voice_sound stop}] == 0} {
3104
			
3105
			set timestamp [clock format [clock seconds] -format "%d %b %Y @ %H_%m_%S"]
3106
			set user [lindex [::MSN::usersInChat $chatid] 0]
3107
			
3108
			create_dir [file join $HOME voiceclips]
3109
			set filename [file join $HOME voiceclips ${user}_${timestamp}.wav]
3110
			set filename_siren [file join $HOME voiceclips ${user}_${timestamp}_encoded.wav]
3111
3112
			if { [$voice_sound min] > -1000 && [$voice_sound max] < 1000 } {
3113
				amsn::WinWrite $chatid "\n" red
3114
				amsn::WinWriteIcon $chatid greyline 3
3115
				amsn::WinWrite $chatid "\n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
3116
				amsn::WinWriteIcon $chatid voice_icon 3 2
6397 by kakaroto
ok, a few changes here... I make sure to load the shipped version of snack for windows and mac + it removed the 'version compatibility' error you get because of providing 2.2.10 in one place (snack.tcl) and providing 2.2 in another place (inside the .dll/.dylib). I also changed that for every 'package require snack' inside of amsn's code. I also fixed the 2.2 vs. 2.2.10 package require/provide..
3117
				if { [$voice_sound length -unit seconds] < 2 } {
6737 by kakaroto
Reverting Phil's commit @7867
3118
					amsn::WinWrite $chatid "[timestamp] [trans nosound_or_hold]\n" red					
6397 by kakaroto
ok, a few changes here... I make sure to load the shipped version of snack for windows and mac + it removed the 'version compatibility' error you get because of providing 2.2.10 in one place (snack.tcl) and providing 2.2 in another place (inside the .dll/.dylib). I also changed that for every 'package require snack' inside of amsn's code. I also fixed the 2.2 vs. 2.2.10 package require/provide..
3119
				} else {
3120
					amsn::WinWrite $chatid "[timestamp] [trans nosound]\n" red
3121
				}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3122
			} else {
3123
				set enc [::Siren::NewEncoder]
6396 by kakaroto
FINALLY it works for Mac!!!!!
3124
				# We need to add the -byteorder littleEndian because on Mac, the datasamples are in big endian and tcl_siren expects little endian
3125
				# since WAV file contents are in little endian.
3126
				if { [catch {set out [::Siren::Encode $enc [$voice_sound datasamples -byteorder littleEndian]] } res] } {
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3127
					::Siren::Close $enc    		
3128
					status_log "Error Encoding voice clip to Siren codec : $res" red
3129
					return 0
3130
				}
3131
				::Siren::WriteWav $enc $filename_siren $out 
3132
				::Siren::Close $enc
3133
				
3134
				$voice_sound write $filename
3135
				
3136
				
3137
				::MSN::ChatQueue $chatid [list ::MSNP2P::SendVoiceClip $chatid $filename_siren]
3138
				
3139
				set uid [getUniqueValue]
3140
				
3141
				amsn::WinWrite $chatid "\n" red
3142
				amsn::WinWriteIcon $chatid greyline 3
3143
				amsn::WinWrite $chatid "\n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
3144
				amsn::WinWriteIcon $chatid voice_icon 3 2
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3145
				amsn::WinWrite $chatid "[timestamp] [trans sentvoice]\n  " green
3146
				amsn::WinWriteClickable $chatid "[trans play]" [list ::ChatWindow::playVoiceClip $w $filename $uid] play_voice_clip_$uid
3147
				amsn::WinWriteClickable $chatid "[trans stop]" [list ::ChatWindow::stopVoiceClip $w $filename $uid] stop_voice_clip_$uid
3148
				[::ChatWindow::GetOutText $w] tag configure play_voice_clip_$uid -elide false
3149
				[::ChatWindow::GetOutText $w] tag configure stop_voice_clip_$uid -elide true
3150
				amsn::WinWrite $chatid " - " green
3151
				amsn::WinWriteClickable $chatid "[trans saveas]" [list ::ChatWindow::saveVoiceClip $filename] 
6811 by tomhennigan
Just a small fix to catch an error where the user clicks/unclicks too quickly on the voiceclip icon.
3152
				amsn::WinWrite $chatid "\n" red
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3153
				amsn::WinWriteIcon $chatid greyline 3
3154
			}
3155
		}
3156
		catch {$voice_sound destroy}
3157
	}
3158
3159
	proc playVoiceClip { w filename uid} {
3160
		variable play_snd_$uid
3161
7500 by lephilousophe
This check isn't good : it won't work with Alsa
3162
		if { [file exists $filename] } {
7815 by kakaroto
Allow users who do not have libsnack installed to still be able to *receive* voice clips.
3163
			if { [catch {
3164
				set snd [snack::sound]
3165
				set play_snd_$uid $snd
3166
				$snd read $filename
3167
				$snd play -command [list ::ChatWindow::stopVoiceClipDelayed $w $filename $uid]	
3168
				[::ChatWindow::GetOutText $w] tag configure play_voice_clip_$uid -elide true
3169
				[::ChatWindow::GetOutText $w] tag configure stop_voice_clip_$uid -elide false	} ] } {
3170
				if { [info exists snd] } { 
3171
					catch { $snd destroy } 
3172
					catch { unset play_snd_$uid }
3173
				}
3174
				# Full back to play_sound which.. hopefully does not have a 'usesnack' setting.
3175
				play_sound $filename 1
3176
			}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3177
		}
3178
	}
3179
6715 by kakaroto
corrected the DeplayedStop
3180
	proc stopVoiceClipDelayed { w filename uid} {
6713 by kakaroto
FINALLY libsiren now has the decoder implemented too. You should be able to receive AND send voice clips, 100% naturally :)
3181
		# We need this little hack because it looks like snack (at least on my PC) calls our callback 1 second before the audio
3182
		# really finished playing.
6715 by kakaroto
corrected the DeplayedStop
3183
		after 1200 [list ::ChatWindow::stopVoiceClip $w $filename $uid]
6713 by kakaroto
FINALLY libsiren now has the decoder implemented too. You should be able to receive AND send voice clips, 100% naturally :)
3184
	}
3185
6715 by kakaroto
corrected the DeplayedStop
3186
	proc stopVoiceClip { w filename uid} {
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3187
		variable play_snd_$uid
3188
3189
		if { [info exists play_snd_$uid] } {
3190
			set snd [set play_snd_$uid]
3191
			catch { $snd stop }
3192
			catch { $snd destroy }
3193
			unset play_snd_$uid
3194
		}
3195
		set text [::ChatWindow::GetOutText $w]
3196
		if { [winfo exists $text] } {
3197
			$text tag configure play_voice_clip_$uid -elide false
3198
			$text tag configure stop_voice_clip_$uid -elide true	
3199
		}
3200
	}
6713 by kakaroto
FINALLY libsiren now has the decoder implemented too. You should be able to receive AND send voice clips, 100% naturally :)
3201
6359 by kakaroto
Fixes a little typo in order to be able to also receive/decode voice clips (on windows only!!!)
3202
	proc ReceivedVoiceClip {chatid filename } {
7262 by vivia
Patch from square87: first, fixes bug which shows up when we receive a voiceclip when a window isnt open, second, corrects spacing with green line and voice icon picture
3203
6359 by kakaroto
Fixes a little typo in order to be able to also receive/decode voice clips (on windows only!!!)
3204
		set filename_decoded "[filenoext $filename]_decoded.wav"
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3205
		
3206
		# This proc should be uncommented once tcl_siren implements the decoder
6715 by kakaroto
corrected the DeplayedStop
3207
		if { [DecodeWave $filename $filename_decoded] == -1 } {
3208
			amsn::WinWrite $chatid "\n" red
3209
			amsn::WinWriteIcon $chatid greyline 3
7262 by vivia
Patch from square87: first, fixes bug which shows up when we receive a voiceclip when a window isnt open, second, corrects spacing with green line and voice icon picture
3210
			amsn::WinWrite $chatid " \n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
3211
			amsn::WinWriteIcon $chatid voice_icon 3 2
6715 by kakaroto
corrected the DeplayedStop
3212
			amsn::WinWrite $chatid "[timestamp] [trans snackneeded]\n" red
3213
			amsn::WinWriteIcon $chatid greyline 3
3214
			return
3215
		} else {
3216
			set uid [getUniqueValue]
7262 by vivia
Patch from square87: first, fixes bug which shows up when we receive a voiceclip when a window isnt open, second, corrects spacing with green line and voice icon picture
3217
			
3218
			if {![info exists ::ChatWindow::msg_windows($chatid)]} {
3219
				::ChatWindow::MakeFor $chatid
3220
			}
6715 by kakaroto
corrected the DeplayedStop
3221
			set w [::ChatWindow::For $chatid]
7262 by vivia
Patch from square87: first, fixes bug which shows up when we receive a voiceclip when a window isnt open, second, corrects spacing with green line and voice icon picture
3222
6715 by kakaroto
corrected the DeplayedStop
3223
			amsn::WinWrite $chatid "\n" red
3224
			amsn::WinWriteIcon $chatid greyline 3
7262 by vivia
Patch from square87: first, fixes bug which shows up when we receive a voiceclip when a window isnt open, second, corrects spacing with green line and voice icon picture
3225
			amsn::WinWrite $chatid " \n" red
7128 by kakaroto
Added voice.png image and made that the image for the WinWriteIcon calls of the voice clips..
3226
			amsn::WinWriteIcon $chatid voice_icon 3 2
6715 by kakaroto
corrected the DeplayedStop
3227
			amsn::WinWrite $chatid "[timestamp] [trans receivedvoice]\n  " green
3228
			amsn::WinWriteClickable $chatid "[trans play]" [list ::ChatWindow::playVoiceClip $w $filename_decoded $uid] play_voice_clip_$uid
3229
			amsn::WinWriteClickable $chatid "[trans stop]" [list ::ChatWindow::stopVoiceClip $w $filename_decoded $uid] stop_voice_clip_$uid
3230
			[::ChatWindow::GetOutText $w] tag configure play_voice_clip_$uid -elide false
3231
			[::ChatWindow::GetOutText $w] tag configure stop_voice_clip_$uid -elide true
3232
			amsn::WinWrite $chatid " - " green
3233
			amsn::WinWriteClickable $chatid "[trans saveas]" [list ::ChatWindow::saveVoiceClip $filename_decoded] 
6811 by tomhennigan
Just a small fix to catch an error where the user clicks/unclicks too quickly on the voiceclip icon.
3234
			amsn::WinWrite $chatid "\n" red
6715 by kakaroto
corrected the DeplayedStop
3235
			amsn::WinWriteIcon $chatid greyline 3
3236
			
3237
			if { [::config::getKey autolisten_voiceclips 1] } {
3238
				playVoiceClip $w $filename_decoded $uid
3239
			}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3240
		}
3241
	}
3242
3243
	proc saveVoiceClip { filename } {
3244
		if {[file exists $filename] } {
3245
			set file [chooseFileDialog "" "Save Voice Clip" "" "" save [list [list [trans soundfiles] [list *.wav]] [list [trans allfiles] *]]]
3246
			
3247
			if { $file != "" } {
6715 by kakaroto
corrected the DeplayedStop
3248
				if { ![string equal -nocase [file extension $file] ".wav"] } {
3249
					append file ".wav"
3250
				}
6358 by kakaroto
This is one big commit... SURPRISEEEEEEEEEEE, lol, I've been saving this surprise for 2 months now I think...
3251
				file copy -force $filename $file
3252
			}
3253
		}
3254
	}
6231 by germinator2000
Apply batch by tom for webcam button (and revised by Sander)
3255
5756 by scapor
I ain't gonna live forever
3256
	proc SetWebcamText {} {
6231 by germinator2000
Apply batch by tom for webcam button (and revised by Sander)
3257
	 if {[::config::getKey webcamDevice] != "" || [OnMac]} {
5756 by scapor
I ain't gonna live forever
3258
			return "[trans sendwebcaminvite]"
5755 by scapor
might need such a proc for the balloon too byut that's esthetics
3259
5756 by scapor
I ain't gonna live forever
3260
		} else {
3261
			return "[trans webcamconfigure]"
3262
		}
3263
	}
5755 by scapor
might need such a proc for the balloon too byut that's esthetics
3264
3265
4311 by germinator2000
Fix the bug of nickname staying the same in the tooltipis of chatwindow
3266
	#Show a different ballon if the user is currently blocked or unblocked
4178 by scapor
fix for the bug where the balloon of the block-icon always says 'block' even if the user ifs already blocked. I couldn't make this work fior the mene though .. maybe an ugly hack ? needs revision I guess ;)
3267
	proc SetBlockText {win_name} {
3268
		set Chatters [::MSN::usersInChat [::ChatWindow::Name $win_name]]
3269
		set NrOfChatters [llength $Chatters]
3270
3271
		if { $NrOfChatters == 0 || $NrOfChatters > 1} {
3272
			return "[trans block]/[trans unblock]"
3273
		} else {
3274
			if {[::MSN::userIsBlocked [lindex $Chatters 0]] == 0} {
3275
				return "[trans block]"
3276
			} else {
3277
				return "[trans unblock]"
3278
			}
3279
		}
3280
	}
4311 by germinator2000
Fix the bug of nickname staying the same in the tooltipis of chatwindow
3281
	#Show the nickname of someone in the balloon
3282
	#If someone changed nick, the new nick appear in the new balloon
3283
	proc SetNickText {chatid} {
3284
		return [::abook::getDisplayNick $chatid]
3285
	}
4178 by scapor
fix for the bug where the balloon of the block-icon always says 'block' even if the user ifs already blocked. I couldn't make this work fior the mene though .. maybe an ugly hack ? needs revision I guess ;)
3286
3287
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3288
	proc CreatePictureFrame { w bottom } {
3289
3290
		status_log "Creating picture frame\n"
8809 by billiob
add a SW/F to the InDPFrame in the CW
3291
3292
		frame $bottom.f -class Amsn -borderwidth 0  -padx 0 -pady 0 \
3293
	                    -relief solid -background [::skin::getKey chatwindowbg]
3294
8964 by billiob
WIP: improve voip controls
3295
		set f $bottom.f
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
3296
		set frame $f.pic
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3297
		set picture $frame.image
3298
		set showpic $frame.showpic
3299
3300
		# Create them
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3301
		frame $frame -class Amsn -borderwidth 0 -relief solid -background [::skin::getKey chatwindowbg]
8749 by kakaroto
Added initial (fugly) support for volume controls for audio conversations in the chat window
3302
3472 by lio_lion
some fixes and enhancements for framec
3303
		framec $picture -type label -relief solid -image [::skin::getNoDisplayPicture] \
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
3304
				-borderwidth [::skin::getKey chat_dp_border] \
3305
				-bordercolor [::skin::getKey chat_dp_border_color] \
3306
				-background [::skin::getKey chatwindowbg]
3307
		set pictureinner [$picture getinnerframe]
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3308
3464 by lio_lion
add options for skinning the colour of the borders in the chatwindow
3309
		set_balloon $pictureinner [trans nopic]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
3310
		label $showpic -bd 0 -padx 0 -pady 0 -image [::skin::loadPixmap imgshow] \
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3311
			-bg [::skin::getKey chatwindowbg] -highlightthickness 0 -font splainf \
3312
			-highlightbackground [::skin::getKey chatwindowbg] -activebackground [::skin::getKey chatwindowbg]
4611 by scapor
hover on imghide/show
3313
		bind $showpic <Enter> "$showpic configure -image [::skin::loadPixmap imgshow_hover]"
3314
		bind $showpic <Leave> "$showpic configure -image [::skin::loadPixmap imgshow]"
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3315
		set_balloon $showpic [trans showdisplaypic]
3316
8808 by billiob
improve voip controls
3317
		# Pack them
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3318
		#pack $picture -side left -padx 0 -pady [::skin::getKey chatpady] -anchor w
8964 by billiob
WIP: improve voip controls
3319
		pack $frame -side right -padx 0 -pady 0 -anchor e -fill y
3320
		pack $showpic -side right -padx 0 -pady 0
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3321
3322
		# Create our bindings
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
3323
		bind $showpic <<Button1>> "::amsn::ToggleShowPicture"
3324
		if { [::config::getKey old_dpframe 0] == 0 } {
8492 by lephilousophe
Make mouse Mac compatible everywhere
3325
			bind $pictureinner <<Button1>> "::amsn::ShowPicMenu $w %X %Y\n"
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
3326
			bind $pictureinner <<Button3>> "::amsn::ShowPicMenu $w %X %Y\n"
8692 by billiob
better to show the error in the status_log
3327
			if {[catch {::dnd bindtarget $pictureinner Files <Drop> "fileDropHandler %D setdp self"} res]} {
8724 by billiob
oops, typo...
3328
				status_log "dnd error: $res"
8692 by billiob
better to show the error in the status_log
3329
			}
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
3330
		} else {
8492 by lephilousophe
Make mouse Mac compatible everywhere
3331
			bind $pictureinner <<Button1>> "::amsn::ShowOldPicMenu $w %X %Y\n"
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
3332
			bind $pictureinner <<Button3>> "::amsn::ShowOldPicMenu $w %X %Y\n"
3333
		}
3334
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
3335
		#For TkAqua: Disable temporary, crash issue with that line
3336
		if { ![OnMac] } {
3337
			bind $picture <Configure> "::ChatWindow::ImageResized $w %h [::skin::getKey chat_dp_pady]"
4153 by lio_lion
fix for resizing a display pic, and then the associated minsize of the bottom frame
3338
		}
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
3339
		::amsn::ShowOrHidePicture
8809 by billiob
add a SW/F to the InDPFrame in the CW
3340
		return $bottom.f
3189 by kakaroto
Cleaned chatwindow code for creating a new window and tried to add the panned window thing.. commiting while unstable..
3341
3342
	}
3010 by yozko
Initial ChatWindow abstraction
3343
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
3344
        #///////////////////////////////////////////////////////////////////////////////
3345
        # ::ChatWindow::GoToPrevTab ( container )
3346
        # Used to switch to the next tab in a container. Called by the binding for the
3347
        # <ctrl>+<PageUp> key combination. The list of windows in the container is used to
3348
        # determine the next tab. ::ChatWindow::SwitchToTab is used for switching.
3349
        # Arguments:
3350
        # - container => The container window in which the current tab is located.
3351
        proc GoToPrevTab { container } {
3352
            set currentWin [::ChatWindow::getCurrentTab $container]
3353
            set windows [set ::ChatWindow::containerwindows($container)]
3354
            set tabPos [lsearch $windows $currentWin]
3355
3356
            # If the current tab is the last go the the first, else go to the next.
3357
            if { $tabPos == 0 } {
5715 by scapor
expr speedups
3358
                set nextTab [expr {[llength $windows] - 1}]
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
3359
            } else {
5715 by scapor
expr speedups
3360
                set nextTab [expr {$tabPos - 1}]
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
3361
            }
3362
3363
            SwitchToTab $container [lindex $windows $nextTab]
3364
        }
3365
        #///////////////////////////////////////////////////////////////////////////////
3366
3367
3368
        #///////////////////////////////////////////////////////////////////////////////
3369
        # ::ChatWindow::GoToNextTab ( container )
3370
        # Used to switch to the next tab in a container. Called by the binding for the
3371
        # <ctrl>+<pagedown> key combination. The list of windows in the container is used to
3372
        # determine the next tab. ::ChatWindow::SwitchToTab is used for switching.
3373
        # Arguments:
3374
        # - container => The container window in which the current tab is located.
3375
        proc GoToNextTab { container } {
3376
            set currentWin [::ChatWindow::getCurrentTab $container]
3377
            set windows [set ::ChatWindow::containerwindows($container)]
3378
            set tabPos [lsearch $windows $currentWin]
3379
3380
            # If the current tab is the last go the the first, else go to the next.
5715 by scapor
expr speedups
3381
            if { $tabPos == [expr {[llength $windows] - 1}] } {
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
3382
                set nextTab 0
3383
            } else {
5715 by scapor
expr speedups
3384
                set nextTab [expr {$tabPos + 1}]
5232 by vivia
Added Ctrl-w binding to close the current tab (non-Mac) and Ctrl-PageUp Ctrl-PageDown for switching between tabs
3385
            }
3386
3387
            SwitchToTab $container [lindex $windows $nextTab]
3388
        }
3389
        #///////////////////////////////////////////////////////////////////////////////
3390
3391
3010 by yozko
Initial ChatWindow abstraction
3392
	#///////////////////////////////////////////////////////////////////////////////
4153 by lio_lion
fix for resizing a display pic, and then the associated minsize of the bottom frame
3393
	# ::ChatWindow::ImageResized (win, height, padding)
3394
	# Resets the minsize for the bottom frame when the image size changes
3395
	# Arguments:
3396
	#  - win => Is the window where the image has been changed
3397
	#  - height => Is the new height of the image
3398
	#  - padding => Is the padding around the image
3399
	proc ImageResized { win height padding} {
3400
		#TODO: need to remove hard coding here
8809 by billiob
add a SW/F to the InDPFrame in the CW
3401
		set picheight [image height [[GetInDisplayPictureFrame $win].pic.image cget -image]]
4153 by lio_lion
fix for resizing a display pic, and then the associated minsize of the bottom frame
3402
		if { $height < $picheight } {
3403
			set height $picheight
3404
		}
3405
3406
		set h [expr {$height + ( 2 * $padding ) }]
3407
		if { $h < 100 } {
3408
			set h 100
3409
		}
3410
		
3411
		status_log "setting bottom pane misize for $win to $h\n"
7503 by lephilousophe
Better organization to avoid CW structure dependency with other parts
3412
		$win.f paneconfigure [GetInFrame $win] -minsize $h
4153 by lio_lion
fix for resizing a display pic, and then the associated minsize of the bottom frame
3413
	}
3414
3415
3416
	#///////////////////////////////////////////////////////////////////////////////
3010 by yozko
Initial ChatWindow abstraction
3417
	# ::ChatWindow::SetFor (chatid, window)
3418
	# Sets the specified window to be the one which will show messages and information
3419
	# for the chat names 'chatid'
3420
	# Arguments:
3421
	#  - chatid => Is the chat id of the window, the passport account of the buddy
3422
	#  - window => Is the window widget to be assigned (.msg_n - Where n is an integer)
3423
	proc SetFor { chatid window } {
3424
		if {$chatid != ""} {
3425
			set ::ChatWindow::msg_windows($chatid) $window
3426
			set ::ChatWindow::chat_ids($window) $chatid
3427
		}
3428
	}
3429
	#///////////////////////////////////////////////////////////////////////////////
3430
3431
3432
	#///////////////////////////////////////////////////////////////////////////////
3433
	# ::ChatWindow::Status (window, msg, [icon ""])
3434
	# Writes the message $msg in the status bar of the window $window. It will add
3435
	# the icon $icon at the beginning of the message, if specified.
3436
	# Arguments:
3437
	#  - window => Is the window widget focused (.msg_n - Where n is an integer)
3438
	#  - msg => The status message that will be showed in the status bar of $window
3439
	#  - [icon ""] => [NOT REQUIRED] The icon that will be at left of the message
3440
	proc Status { win_name msg {icon ""}} {
3441
		set msg [string map {"\n" " "} $msg]
3442
3443
		if { [winfo exists $win_name] } {
3444
3453 by lio_lion
create procedures for statusbar as previous commits
3445
			[::ChatWindow::GetStatusText ${win_name}] configure -state normal
3446
			[::ChatWindow::GetStatusText ${win_name}] delete 0.0 end
3010 by yozko
Initial ChatWindow abstraction
3447
3448
			if { "$icon"!=""} {
3453 by lio_lion
create procedures for statusbar as previous commits
3449
				[::ChatWindow::GetStatusText ${win_name}] image create end -image [::skin::loadPixmap $icon] -pady 0 -padx 1
3010 by yozko
Initial ChatWindow abstraction
3450
			}
3451
3453 by lio_lion
create procedures for statusbar as previous commits
3452
			[::ChatWindow::GetStatusText ${win_name}] insert end $msg
3453
			[::ChatWindow::GetStatusText ${win_name}] configure -state disabled
3010 by yozko
Initial ChatWindow abstraction
3454
3455
		}
3456
	}
3457
	#///////////////////////////////////////////////////////////////////////////////
3458
4565 by lephilousophe
Added pixmap for the To field in chat window
3459
	
7341 by lephilousophe
So much simpler...
3460
	proc MeasureTextCanvas { widget id dimension } {
3461
		set bbox [$widget bbox $id]
3462
		if {[llength $bbox] < 4} {
3463
			set bbox [list 0 0 0 0]
3464
		}
4565 by lephilousophe
Added pixmap for the To field in chat window
3465
		if { $dimension == "w" } {
7341 by lephilousophe
So much simpler...
3466
			return [expr {[lindex $bbox 2]-[lindex $bbox 0]}]
3467
		} else {
3468
			return [expr {[lindex $bbox 3]-[lindex $bbox 1]}]
4565 by lephilousophe
Added pixmap for the To field in chat window
3469
		}
3470
	}
3010 by yozko
Initial ChatWindow abstraction
3471
3472
	#///////////////////////////////////////////////////////////////////////////////
3473
	# ::ChatWindow::TopUpdate (chatid)
3474
	# Gets the users in 'chatid' from the protocol layer, and updates the top of the
3475
	# window with the user names and states.
3476
	# Arguments:
3477
	#  - chatid => Is the chat id of the window, the passport account of the buddy
3478
	proc TopUpdate { chatid } {
3479
		if { [::ChatWindow::For $chatid] == 0 } {
3480
			return 0
3481
		}
3482
3483
		set title ""
3484
		set user_list [::MSN::usersInChat $chatid]
3485
3486
		if {[llength $user_list] == 0} {
5664 by vivia
Fixed TopUpdate and History etc if chat was opened while appearing offline
3487
			#return 0
3488
			#We have a chatwindow, but no SB for it.
3489
			#Check if the chatid is a valid user...
3490
			if { [lsearch [::abook::getAllContacts] $chatid] != -1 } {
3491
				set user_list $chatid
3492
			} else {
3493
				return 0
3494
			}
3010 by yozko
Initial ChatWindow abstraction
3495
		}
3496
9032 by square87
TopUpdate: big code cleaning
3497
		set win_name [::ChatWindow::For $chatid]
4565 by lephilousophe
Added pixmap for the To field in chat window
3498
		set top [::ChatWindow::GetTopFrame ${win_name}]
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
3499
		set scrolling [getScrolling [::ChatWindow::GetOutText ${win_name}]]
3010 by yozko
Initial ChatWindow abstraction
3500
4631 by scapor
camicon bugfixes
3501
		set camicon [::skin::loadPixmap camicon]
7690 by billiob
Patch from square87 to improve the top of the CW : support for smileys, styles, colors (through the ColoredNicks plugin)
3502
		set toX [::skin::getKey topbarpadx]
3503
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3504
		set font [$top itemcget text -font]
3505
		if { $font != "" } {
3506
			set incr_y [font metrics $font -displayof $top -linespace]
3507
		} else {
3508
			set f [font create -family helvetica -size 12 -weight normal]
3509
			set incr_y [font metrics $f -displayof $top -linespace]
3510
			font delete $f
3511
		}
3512
8930 by square87
Add feature: Show/hide users in a multichat
3513
		set usrsX [expr {$toX + [font measure bplainf -displayof $top "[trans to]:"] + 5}]
3514
		set Ycoord [lindex [$top coords text] 1]
9498 by kakaroto
Might fix this bug : http://www.amsn-project.net/forums/viewtopic.php?t=6583&highlight=
3515
		set Ycoord [expr {int($Ycoord)}]
8930 by square87
Add feature: Show/hide users in a multichat
3516
		set maxw [expr {[winfo width $top] - [::skin::getKey topbarpadx] - [expr {int([lindex [$top coords text] 0])} ] } ]
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3517
		set default_incr_y $incr_y
8930 by square87
Add feature: Show/hide users in a multichat
3518
		set default_maxw $maxw
9032 by square87
TopUpdate: big code cleaning
3519
		set defaultfont sboldf
8930 by square87
Add feature: Show/hide users in a multichat
3520
		
9032 by square87
TopUpdate: big code cleaning
3521
		$top dchars text 0 end
3522
		$top dchars cw_txt 0 end
9606 by kakaroto
When we are in a 4+ multi user chat, if one leaves, we must delete the text that says "show/hide users"
3523
		$top dchars showhideusers 0 end
9032 by square87
TopUpdate: big code cleaning
3524
		$top delete camicon cw_txt bg ;#remove the camicon(s) and default icons
8930 by square87
Add feature: Show/hide users in a multichat
3525
9032 by square87
TopUpdate: big code cleaning
3526
		#this code is for multichat with more then 3 users
3527
		if {[llength $user_list] > 3} {
9606 by kakaroto
When we are in a 4+ multi user chat, if one leaves, we must delete the text that says "show/hide users"
3528
			$top dchars showhideusers 0 end
8930 by square87
Add feature: Show/hide users in a multichat
3529
			set txt [list ]
9032 by square87
TopUpdate: big code cleaning
3530
			if {[::config::getKey hide_users_in_cw]} {
3531
				set len [llength $user_list]
3532
				set user_list ""
8930 by square87
Add feature: Show/hide users in a multichat
3533
			
9032 by square87
TopUpdate: big code cleaning
3534
				lappend txt [list font sboldf] [list text "[trans showuserscw $len]"]
3535
			} else {
3536
				lappend txt [list font sboldf] [list text "[trans hideuserscw]"]
3537
			}
9606 by kakaroto
When we are in a 4+ multi user chat, if one leaves, we must delete the text that says "show/hide users"
3538
			::guiContactList::renderContact $top "showhideusers" $maxw $txt 0
8930 by square87
Add feature: Show/hide users in a multichat
3539
			$top configure -state normal 
9606 by kakaroto
When we are in a 4+ multi user chat, if one leaves, we must delete the text that says "show/hide users"
3540
			$top move showhideusers $usrsX $Ycoord
8930 by square87
Add feature: Show/hide users in a multichat
3541
			
9606 by kakaroto
When we are in a 4+ multi user chat, if one leaves, we must delete the text that says "show/hide users"
3542
			$top bind showhideusers <Button-1> "::ChatWindow::ShowHideUsers"
3543
			$top bind showhideusers <Enter> "$top configure -cursor hand2"
3544
			$top bind showhideusers <Leave> "$top configure -cursor left_ptr"
8930 by square87
Add feature: Show/hide users in a multichat
3545
			
9032 by square87
TopUpdate: big code cleaning
3546
			set Ycoord [expr {$Ycoord + $incr_y + 2}]
3547
		}
3548
		
3010 by yozko
Initial ChatWindow abstraction
3549
		foreach user_login $user_list {
4629 by scapor
show icon when contact has a cam .. not tested properly yet in groupchats etc ...
3550
			set shares_cam [::abook::getContactData $user_login webcam_shared]
3551
			
5382 by vivia
Added proc ::abook::getpsmmedia, added $psm to custom nickname, email appears only once in chatwindow if emailsincontactlist enabled
3552
			if { [::config::getKey emailsincontactlist] == 1 } {
7690 by billiob
Patch from square87 to improve the top of the CW : support for smileys, styles, colors (through the ColoredNicks plugin)
3553
				set user_name [list text ""]
3554
				set user_name_str ""
3555
			} else {
3556
				set user_name [::abook::getDisplayNick $user_login 1]
3557
				set user_name_str [string map {"\n" " "} [::abook::removeStyles $user_name]]
3558
			}
3559
3560
			if { [::config::getKey psmplace] == 0 } {
3561
				set psmmedia [list text ""]
3562
			} else {
3563
				set psmmedia [::abook::getpsmmedia $user_login 1]
3564
			}
3565
3010 by yozko
Initial ChatWindow abstraction
3566
			set state_code [::abook::getVolatileData $user_login state]
3567
			if { $state_code == "" } {
3568
				set user_state ""
3569
				set state_code FLN
3570
			} else {
3571
				set user_state [::MSN::stateToDescription $state_code]
3572
			}
3573
8930 by square87
Add feature: Show/hide users in a multichat
3574
			set maxw $default_maxw
9032 by square87
TopUpdate: big code cleaning
3575
			set incr_y $default_incr_y
3576
			
3577
			set user_name_dim $usrsX
9057 by square87
Remove newlines from topcw
3578
			set new_temp_list [list ]
9032 by square87
TopUpdate: big code cleaning
3579
			foreach unit $user_name {
3580
				switch [lindex $unit 0] {
3581
					"text" {
3582
						incr user_name_dim [font measure sboldf -displayof $top [lindex $unit 1]]
9057 by square87
Remove newlines from topcw
3583
						lappend new_temp_list [lindex $unit]
9032 by square87
TopUpdate: big code cleaning
3584
					}
3585
					"smiley" {
3586
						if {[image height [lindex $unit 1]] > $incr_y} {
3587
							set incr_y [image height [lindex $unit 1]]
3588
						}
3589
						incr user_name_dim [image width [lindex $unit 1]]
9057 by square87
Remove newlines from topcw
3590
						lappend new_temp_list [lindex $unit]
9032 by square87
TopUpdate: big code cleaning
3591
					}
3592
					"newline" {}
9057 by square87
Remove newlines from topcw
3593
					default { lappend new_temp_list [lindex $unit] }
9032 by square87
TopUpdate: big code cleaning
3594
				}
3595
			}
9605 by kakaroto
The top bar of the CW didn't have the right height if there was a smiley in the PSM instead of the nick... Fixes : http://www.amsn-project.net/forums/viewtopic.php?t=7122&highlight=
3596
			foreach unit $psmmedia {
3597
				switch [lindex $unit 0] {
3598
					"smiley" {
3599
						if {[image height [lindex $unit 1]] > $incr_y} {
3600
							set incr_y [image height [lindex $unit 1]]
3601
						}
3602
					}
3603
				}
3604
			}
9057 by square87
Remove newlines from topcw
3605
			set user_name $new_temp_list
9032 by square87
TopUpdate: big code cleaning
3606
			#to be sure there is a < and a > more
3607
			incr user_name_dim [font measure sboldf -displayof $top " <<${user_login}>> "]
3608
3609
3610
			if { "$user_state" != "" && "$user_state" != "online" } {
3611
				#There is a free space before status name so it doesn't stick next to the psm
3612
				set statetxt " \([trans $user_state]\)"
3613
			} else {
3614
				set statetxt ""
3615
			}
3616
			
3617
			if { $shares_cam == 1} {
3618
				incr maxw [expr { 0 - [image width $camicon] - 10 }]
3619
			}
3620
3621
			set nicktxt [list ]
3622
			set truncatenames [::config::getKey truncatenames]
3623
			lappend nicktxt [list trunc $truncatenames] 
3624
			set nicktxt [concat $nicktxt $user_name]
3625
			
3626
			if {!$truncatenames} {
3627
				set maxw 2000
3628
			}
3629
			
3630
			if {$user_name_dim >= $maxw && $truncatenames} {
3631
				lappend nicktxt [list trunc 0] [list text " <${user_login}> $statetxt"] [list trunc 1]
3632
			} else {
7690 by billiob
Patch from square87 to improve the top of the CW : support for smileys, styles, colors (through the ColoredNicks plugin)
3633
				lappend nicktxt [list text " <${user_login}> "]
3634
				set nicktxt [concat $nicktxt $psmmedia]
9032 by square87
TopUpdate: big code cleaning
3635
				lappend nicktxt [list trunc 0] [list text $statetxt] [list trunc 1]
3636
			}
7690 by billiob
Patch from square87 to improve the top of the CW : support for smileys, styles, colors (through the ColoredNicks plugin)
3637
7770 by square87
fixed bug about color text in top-CW - bug reported here: http://www.amsn-project.net/forums/viewtopic.php?t=4523
3638
			#get the default colour for the specific state
3639
			set defaultcolour [::skin::getKey topbartext]
3640
			if { ([llength $user_list] == 1) && ( "$user_state" != "" ) } {
9032 by square87
TopUpdate: big code cleaning
3641
				switch $state_code {
3642
					"IDL" { set defaultcolour [::skin::getKey topbaridletext] }
3643
					"BRB" { set defaultcolour [::skin::getKey topbarbrbtext] }
3644
					"AWY" { set defaultcolour [::skin::getKey topbarawaytext] }
3645
					"LUN" { set defaultcolour [::skin::getKey topbarlunchtext] }
3646
					"PHN" { set defaultcolour [::skin::getKey topbarphonetext] }
3647
					"BSY" { set defaultcolour [::skin::getKey topbarbusytext] }
3648
					"FLN" { set defaultcolour [::skin::getKey topbarofflinetext] }
3649
				}
3650
			}
3651
9054 by square87
Fix: when a user is offline topcw is not coloured in the right way. Reported by Mirko Hansen
3652
			set list_1  [list [list default $defaultcolour $defaultfont] [list colour reset] [list font reset] [list font $defaultfont]]
9032 by square87
TopUpdate: big code cleaning
3653
			set nicktxt [concat $list_1 $nicktxt]
3654
			::guiContactList::renderContact $top [list cw_${user_login} cw_txt] $maxw $nicktxt 0
8869 by square87
Fixed: underline and overstrike aren't well set if there is background text
3655
			
9032 by square87
TopUpdate: big code cleaning
3656
			$top move cw_${user_login} $usrsX $Ycoord
7690 by billiob
Patch from square87 to improve the top of the CW : support for smileys, styles, colors (through the ColoredNicks plugin)
3657
3658
			if { $user_name_str != "" } {
3659
				set title "${title}${user_name_str}, "
5920 by vivia
Show emails in CL + no tabs didnt show email in CW title bar
3660
			} else {
3661
				set title "${title}${user_login}, "
3662
			}
4629 by scapor
show icon when contact has a cam .. not tested properly yet in groupchats etc ...
3663
			
4652 by scapor
fixes for camicon if adding users where we don't have a value for yet
3664
			if { $shares_cam == 1 } {
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3665
				if {[image height $camicon] > $incr_y} {
3666
					set incr_y [image height $camicon]
3667
				}
4629 by scapor
show icon when contact has a cam .. not tested properly yet in groupchats etc ...
3668
3669
				#the image aligned-right to the text
4636 by scapor
some cleaning and power to the skinner
3670
				set Xcoord [expr {[winfo width $top] - [image width $camicon]}]
4633 by scapor
bindings .. seem not to work :s
3671
	
6963 by kakaroto
I think that this is the fix where we had some users have the top bar of a CW in a multi user convo with a height too small to contain all the users in the CW...
3672
				$top create image $Xcoord $Ycoord -anchor nw -image $camicon -tags [list camicon camicon_$user_login] -state normal
4633 by scapor
bindings .. seem not to work :s
3673
4645 by scapor
Thanks Tom for fixing hte bindings (-state normal) and some cleaning
3674
				#If clicked, invite the user to send webcam
4633 by scapor
bindings .. seem not to work :s
3675
				$top bind camicon_$user_login <Button-1> "::MSNCAM::AskWebcamQueue $user_login" 
3676
4645 by scapor
Thanks Tom for fixing hte bindings (-state normal) and some cleaning
3677
				#add the balloon-binding
3678
				$top bind camicon <Enter> [list balloon_enter %W %X %Y "[trans askwebcam]"]
3679
				$top bind camicon <Motion> [list balloon_motion %W %X %Y "[trans askwebcam]"]
9032 by square87
TopUpdate: big code cleaning
3680
				$top bind camicon <Leave> "set Bulle(first) 0; kill_balloon"
4645 by scapor
Thanks Tom for fixing hte bindings (-state normal) and some cleaning
3681
				#change the cursor
3682
				$top bind camicon <Enter> "+$top configure -cursor hand2"
3683
				$top bind camicon <Leave> "+$top configure -cursor left_ptr"
4629 by scapor
show icon when contact has a cam .. not tested properly yet in groupchats etc ...
3684
			}
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3685
3686
			set Ycoord [expr {$Ycoord + $incr_y + 2}]
3010 by yozko
Initial ChatWindow abstraction
3687
		}
4648 by lephilousophe
Fixed 2 bugs with Topbar pixmap widget
3688
6883 by lephilousophe
Better like that : thanks YOuness to show me the light ;)
3689
		bind $top <Configure> [list ::ChatWindow::TopUpdate $chatid]
4648 by lephilousophe
Fixed 2 bugs with Topbar pixmap widget
3690
9032 by square87
TopUpdate: big code cleaning
3691
		if {[llength $user_list] > 0 && ![::config::getKey hide_users_in_cw]} {
8930 by square87
Add feature: Show/hide users in a multichat
3692
			#Change color of top background by the status of the contact
3693
			ChangeColorState $user_list $user_state $state_code ${win_name}
3694
		}
6309 by billiob
bug fix; OIM are like a normal message; change the titles of CW back
3695
3696
		set title [EscapeTitle [string replace $title end-1 end " - [trans chat]"]]
3031 by yozko
Code cleaning and reorganization in chatwindow.tcl
3697
		set ::ChatWindow::titles(${win_name}) ${title}
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3698
8484 by kakaroto
murat from IRC is having a bug where Ycoord is "28.0" instead of "28", don't know why.. but this should fix it!
3699
		set Ycoord [expr {int($Ycoord)}]
7983 by square87
fixed. topcw: added case when smileys are more big then text and when the text is too small. Code optmization.
3700
		$top configure -height $Ycoord
3010 by yozko
Initial ChatWindow abstraction
3701
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3702
		if { [GetContainerFromWindow $win_name] == "" } {
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
3703
			if { [info exists ::ChatWindow::new_message_on(${win_name})] && $::ChatWindow::new_message_on(${win_name}) == "asterisk" } {
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3704
				wm title ${win_name} "*${title}"
3705
			} else {
3706
				wm title ${win_name} ${title}
3707
			}
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
3708
		} else {
3709
			NameTabButton $win_name $chatid
3010 by yozko
Initial ChatWindow abstraction
3710
		}
3711
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
3712
		if { $scrolling } { catch {::ChatWindow::Scroll [::ChatWindow::GetOutText ${win_name}]} }
3010 by yozko
Initial ChatWindow abstraction
3713
3268 by lio_lion
new postevent TopUpdate
3714
		#PostEvent 'TopUpdate'
3715
		set evPar(chatid) "chatid"
3716
		set evPar(win_name) "win_name"
3717
		set evPar(user_list) "user_list"
3718
		::plugins::PostEvent TopUpdate evPar
4635 by scapor
remove camicon before redrawing, have it always on hte right
3719
		
3010 by yozko
Initial ChatWindow abstraction
3720
		update idletasks
3721
7731 by kakaroto
Better flickering on windows..
3722
		# If we had a flickering window, bypass windows bug and reflicker it after the title change..
3723
		if { [OnWin] } {
3724
			# Make sure we check the toplevel window, in case we use a container.
3725
			set window $win_name
3726
			set container [GetContainerFromWindow $window]
3727
			if { $container != ""} {
3728
				set window $container
3729
			}
3730
3731
			if {[bind $window <FocusIn>] != "" } {
3732
				catch {winflash $window -count 1}
3733
			}
3734
		}
3735
6883 by lephilousophe
Better like that : thanks YOuness to show me the light ;)
3736
		after cancel [list ::ChatWindow::TopUpdate $chatid]
3010 by yozko
Initial ChatWindow abstraction
3737
	}
8930 by square87
Add feature: Show/hide users in a multichat
3738
	
3739
	proc ShowHideUsers {} {
3740
		if {[::config::getKey hide_users_in_cw]} {
3741
			::config::setKey hide_users_in_cw 0
3742
		} else {
3743
			::config::setKey hide_users_in_cw 1
3744
		}
3745
		
3746
		foreach chat_id [getAllChatIds] {
3747
			TopUpdate $chat_id
3748
		}
3749
	}
4635 by scapor
remove camicon before redrawing, have it always on hte right
3750
3751
	
3010 by yozko
Initial ChatWindow abstraction
3752
	#///////////////////////////////////////////////////////////////////////////////
3274 by germinator2000
Modular!!!!!!
3753
	# ::ChatWindow::ChangeColorState {user_list user_state state_code win_name}
3754
	# Change the color of the top window when the other contact is in another status
3755
	proc ChangeColorState {user_list user_state state_code win_name} {
3756
		#get the colour for the state
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3757
		set colour [::skin::getKey topbarbg]
3484 by lio_lion
add skinned bgcolour for selected text in statusbar and topbar
3758
		set scolour [::skin::getKey topbarbg_sel]
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3759
		set tcolour [::skin::getKey topbartext]
3468 by lio_lion
add border colour options for states in top bar
3760
		set bcolour [::skin::getKey topbarborder]
3274 by germinator2000
Modular!!!!!!
3761
		if { ([llength $user_list] == 1) && ("$user_state" != "" ) } {
7627 by billiob
more improvements from Nuitari
3762
			if { $state_code == "IDL" } {
3763
				set colour [::skin::getKey topbaridlebg]
3764
				set tcolour [::skin::getKey topbaridletext]
3765
				set bcolour [::skin::getKey topbaridleborder]
3766
			} elseif { $state_code == "BRB" } {
3767
				set colour [::skin::getKey topbarbrbbg]
3768
				set tcolour [::skin::getKey topbarbrbtext]
3769
				set bcolour [::skin::getKey topbarbrbborder]
3770
			} elseif { $state_code == "AWY" } {
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3771
				set colour [::skin::getKey topbarawaybg]
3772
				set tcolour [::skin::getKey topbarawaytext]
3468 by lio_lion
add border colour options for states in top bar
3773
				set bcolour [::skin::getKey topbarawayborder]
7627 by billiob
more improvements from Nuitari
3774
			} elseif { $state_code == "LUN" } {
3775
				set colour [::skin::getKey topbarlunchbg]
3776
				set tcolour [::skin::getKey topbarlunchtext]
3777
				set bcolour [::skin::getKey topbarlunchborder]
3778
			} elseif { $state_code == "PHN" } {
3779
				set colour [::skin::getKey topbarphonebg]
3780
				set tcolour [::skin::getKey topbarphonetext]
3781
				set bcolour [::skin::getKey topbarphoneborder]
3782
			} elseif { $state_code == "BSY" } {
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3783
				set colour [::skin::getKey topbarbusybg]
3784
				set tcolour [::skin::getKey topbarbusytext]
3468 by lio_lion
add border colour options for states in top bar
3785
				set bcolour [::skin::getKey topbarbusyborder]
3274 by germinator2000
Modular!!!!!!
3786
			} elseif { ($state_code == "FLN") } {
3398 by yozko
BIG COMMIT, aMSN Skin System has suffered BIG changes (a lot more comming, this is the infrastructure)
3787
				set colour [::skin::getKey topbarofflinebg]
3788
				set tcolour [::skin::getKey topbarofflinetext]
3468 by lio_lion
add border colour options for states in top bar
3789
				set bcolour [::skin::getKey topbarofflineborder]
3274 by germinator2000
Modular!!!!!!
3790
			}
3791
		}
3792
		#set the areas to the colour
4565 by lephilousophe
Added pixmap for the To field in chat window
3793
		
3794
		set top [GetTopFrame ${win_name}]
4575 by lephilousophe
New mutex system for PutMessage (thanks to Billiob)
3795
		$top configure -bg $colour -bordercolor $bcolour
3796
		$top itemconfigure text -fill $tcolour
4580 by lephilousophe
I forgot to change the To color :$
3797
		$top itemconfigure to -fill $tcolour
4565 by lephilousophe
Added pixmap for the To field in chat window
3798
		
4648 by lephilousophe
Fixed 2 bugs with Topbar pixmap widget
3799
		set bg "::$top.bg"
3800
3801
		if { [::skin::getKey chat_top_pixmap] && [info procs $bg] != ""} {
4565 by lephilousophe
Added pixmap for the To field in chat window
3802
			set topimg [$bg cget -source]
3803
			$topimg copy [::skin::loadPixmap cwtopback]
3804
			::picture::Colorize $topimg $colour
5440 by lephilousophe
Fix pixmap top bar : now the color change when our contact change of status
3805
			$bg BuildImage
4648 by lephilousophe
Fixed 2 bugs with Topbar pixmap widget
3806
			bind $top <Configure> "[bind $top <Configure>]; $bg configure -width %w -height %h" 
4565 by lephilousophe
Added pixmap for the To field in chat window
3807
		}
3274 by germinator2000
Modular!!!!!!
3808
	}
3010 by yozko
Initial ChatWindow abstraction
3809
3810
	#///////////////////////////////////////////////////////////////////////////////
3811
	# ::ChatWindow::UnsetFor (chatid, window)
3812
	# Tells the GUI system that window $window is no longer available for $chatid
3813
	# Arguments:
3814
	#  - chatid => Is the chat id of the window, the passport account of the buddy
3815
	#  - window => Is the window widget assigned (.msg_n - Where n is an integer)
3816
	proc UnsetFor {chatid window} {
3817
		if {[info exists ::ChatWindow::msg_windows($chatid)]} {
3818
			unset ::ChatWindow::msg_windows($chatid)
3819
			unset ::ChatWindow::chat_ids($window)
3820
		}
3821
	}
3822
	#///////////////////////////////////////////////////////////////////////////////
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3823
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3824
	proc FlickerTab { win {new 1}} {
3825
		variable win2tab
3826
		variable winflicker
3670 by markitusfiber
added balloon for the tabs
3827
		variable visibletabs
7830 by vivia
Now we can chat on multiple tabs without losing the variable :D
3828
		variable containerwindows
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3829
3830
		if { $win == 0 || ![info exists win2tab($win)] } { return }
4765 by germinator2000
Fix bug 21-69-68
3831
		if {![winfo exists $win]} { return }
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3832
		if { $win == [GetCurrentWindow [winfo toplevel $win]] } { return }
3833
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3834
		set tab $win2tab($win)
5721 by scapor
another fix
3835
		set container [string range $tab 0 [expr {[string last "." $tab] - 1}] ]
5724 by vivia
fixed chatwindow bug caused by scapor
3836
		set container [string range $container 0 [expr {[string last "." $container] -1}] ]
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3837
9805 by alexandernst
Now trayicon can blink on new unread messages
3838
                TrayBlinkStart $win
3839
3670 by markitusfiber
added balloon for the tabs
3840
		#if tab is not visible, then we should change the color of the < or > button
3841
		#to let know there is an invisible tab flickering (an incoming message)
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3842
		if { [info exists visibletabs($container)] } {
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
3843
		
3844
			foreach window [set containerwindows($container)] {
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3845
				set visible 0
3846
				foreach winvisible [set visibletabs($container)] {
3847
					if { ![string equal $window $winvisible] } {
9402 by kakaroto
This should be a very nice improvement to how Mac dock bouncing works :)
3848
						if { !$visible && [string equal $window $win] } {
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3849
							set right 0
3850
						} elseif { [string equal $window $win] } {
3851
							set right 1
3852
						}
3853
					} else {
3854
						set visible 1
3855
					}
3856
				}
3857
			}
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
3858
	
3859
	
3759 by markitusfiber
now binded the container with <Escape> and execute a CloseTab (current one)
3860
			if { [info exists right] } {
3861
				if { $right == 0 } {
3862
					#we change the less color
3863
					catch { ${container}.bar.less configure -bg green }
3864
				} else {
3865
					#we flicker the more button
3866
					catch { ${container}.bar.more configure -bg green }
3867
				}
3868
			}
3869
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3870
9110 by square87
topcw upgraded
3871
		if { [::picture::IsAnimated [::skin::GetSkinFile pixmaps tab_flicker.gif]] } {
3872
			ConfigureTab $tab "tab_flicker"
9063 by square87
The new topcw
3873
		} else {
9110 by square87
topcw upgraded
3874
			after cancel "::ChatWindow::FlickerTab $win 0"
3875
			if { $new == 1 || ![info exists winflicker($win)]} {
3876
				set winflicker($win) 0
3877
			}
3878
3879
			set count [set winflicker($win)]
3880
3881
			if { [expr {$count % 2}] == 0 } {
3882
				ConfigureTab $tab "tab_flicker"
3883
			} else {
3884
				ConfigureTab $tab "tab"	
3885
			}
3886
3887
			incr winflicker($win)
3888
3889
			#if { $count > 10 } {
3890
			#	$tab configure -image [::skin::loadPixmap tab_flicker]
3891
			#	return
3892
			#}
3893
3894
			#Check if the container window lost focus, then make it flicker:
3895
			set container [GetContainerFromWindow $win]
3896
			if { $container != "" } {
3897
				if { ![info exists ::ChatWindow::new_message_on(${container})] &&
3898
				     [string first $container [focus]] != 0 } {
3899
					Flicker $container
3900
				}	
3901
			}
3902
			
3903
			
3904
			after 300 "::ChatWindow::FlickerTab $win 0"
3905
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3906
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3907
3908
	proc GetContainerFor { user } {
3909
		variable containers
3910
		 
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
3911
		if { [::config::getKey tabbedchat] == 1 } {
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3912
			if { [info exists containers(global)] && $containers(global) != ""} {
3913
				return $containers(global)
3914
			} else {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
3915
	
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3916
				set containers(global) [CreateNewContainer]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
3917
		
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3918
				return $containers(global)
3919
			}
3920
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
3921
		} elseif { [::config::getKey tabbedchat] == 2 } {
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
3922
			set gid "group[lindex [::abook::getContactData $user group] 0]"
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3923
			if { [info exists containers($gid)] && $containers($gid) != ""} {
3924
				return $containers($gid)
3925
			} else {
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
3926
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3927
				set containers($gid) [CreateNewContainer]
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
3928
			
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3929
				return $containers($gid)
3930
			}
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
3931
		} else {
3932
			return ""
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3933
		}
3934
		
3935
3936
	}
3937
3938
	proc AddWindowToContainer { container win } {
3939
		variable containerwindows
3940
3941
		if { ![info exists containerwindows($container)] } {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3942
3943
			set tab [CreateTabButton $container $win]
3944
			pack $tab -side left -expand false -fill both -anchor e
3945
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3946
			set containerwindows($container) $win
3947
			SwitchToTab $container $win
4681 by germinator2000
Remove some strange window behaviors issues on Mac OS X
3948
			
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
3949
			if { [OnMac] } {
4681 by germinator2000
Remove some strange window behaviors issues on Mac OS X
3950
				lower $container
3951
			}
3952
			
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3953
		} else {
3954
			if { [lsearch [set containerwindows($container)] $win] == -1 } {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3955
				set tab [CreateTabButton $container $win]
3956
				pack $tab -side left -expand false -fill both -anchor e
3957
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3958
				lappend containerwindows($container) $win
3959
			} else {
3960
				return
3961
			}
3962
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3963
		CheckForTooManyTabs $container
3964
	}
3965
3966
3967
	proc GetContainerFromWindow { win } {
3968
		variable containerwindows
3969
3970
		if { ![info exists containerwindows] } {
3971
			return ""
3972
		} else {
3973
			foreach container [array names containerwindows] {
3974
				if { [lsearch [set containerwindows($container)] $win] != -1 } {
3975
					return $container
3976
				}
3977
			}
3978
		}
3979
3980
		return ""
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3981
3982
	}
9063 by square87
The new topcw
3983
9110 by square87
topcw upgraded
3984
	proc ConfigureTab {tab img} {
3985
		$tab delete tab_bg
3986
		$tab create image 1 0 -image [::skin::loadPixmap $img] -anchor nw -tags tab_bg
3987
		$tab lower tab_bg tab_text
9063 by square87
The new topcw
3988
	}
9064 by square87
topcw:
3989
	
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3990
3991
	proc CreateTabButton { container win} {
9063 by square87
The new topcw
3992
		variable containerwindows
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
3993
		variable tab2win
3994
		variable win2tab
9063 by square87
The new topcw
3995
		
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
3996
		set w [string map { "." "_"} $win]
3997
		set tab $container.bar.$w
3998
9110 by square87
topcw upgraded
3999
		set tab_width [image width [::skin::loadPixmap tab]]
4000
		set tab_height [image height [::skin::loadPixmap tab]]
4175 by scapor
Commit Youness's proposed patch for the multi-line tabs problem
4001
4002
		set nick [string trim $win] ;# to avoid havng a blank tab if the user has  a nick like "\n\n\n my nick"
9110 by square87
topcw upgraded
4003
	#	set idx [string first "\n" $nick]
4004
	#	if { $idx != -1 } {
4005
	#	        set nick [string range $nick 0 [expr {$idx -1}]]
4006
	#	}
4175 by scapor
Commit Youness's proposed patch for the multi-line tabs problem
4007
9063 by square87
The new topcw
4008
		set nick [list [list text $nick]]
9110 by square87
topcw upgraded
4009
		canvas $tab -bg [::skin::getKey tabbarbg] -width $tab_width -height $tab_height
9063 by square87
The new topcw
4010
		::guiContactList::renderContact $tab tab_text $tab_width $nick 0
9568 by kakaroto
Fix the tab close hover image as reported (and patch provided) by dimitrispan88 at http://www.amsn-project.net/forums/viewtopic.php?t=7091&start=15
4011
		$tab create image [::skin::getKey tab_close_x] [::skin::getKey tab_close_y] -image [::skin::loadPixmap tab_close] -activeimage [::skin::loadPixmap tab_close_hover] -anchor nw -tags tab_close
9110 by square87
topcw upgraded
4012
		$tab create image 1 0 -image [::skin::loadPixmap tab] -anchor nw -tags [list tab_bg]
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
4013
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4014
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4015
		bind $tab <Enter> "::ChatWindow::TabEntered $tab $win"
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4016
		bind $tab <Leave> "::ChatWindow::TabLeft $tab $win"
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4017
		bind $tab <<Button2>> "::ChatWindow::CloseTab $tab"
5359 by lio_lion
fix a bug that caused amsn to crash when dragging the close button on a tab
4018
		$tab bind tab_close <ButtonRelease-1> [list after 0 "::ChatWindow::CloseTab $tab"]
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
4019
		$tab bind tab_bg <ButtonRelease-1> "::ChatWindow::SwitchToTab $container $win"
4020
		$tab bind tab_text <ButtonRelease-1> "::ChatWindow::SwitchToTab $container $win"
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4021
4022
		set tab2win($tab) $win
4023
		set win2tab($win) $tab
3656 by markitusfiber
right click tab menu created, maybe improved but works :-P
4024
3665 by airadier
Better way of binding the command (less problems, try to avoid nested evaluations and quoting as possible).
4025
		bind $tab <<Button3>> [list ::ChatWindow::createRightTabMenu $tab %X %Y]
3656 by markitusfiber
right click tab menu created, maybe improved but works :-P
4026
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4027
		return $tab
9063 by square87
The new topcw
4028
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4029
7199 by kakaroto
as requested by Paller, a new tab contextual menu entry : "Close All Other Tabs" to close all tabs but keep the one selected (by the right click, not the one focused)
4030
	proc CloseOtherTabs { tokeep } {
4031
		variable containerwindows
4032
		variable win2tab
4033
4034
		set w [winfo toplevel $tokeep]
4035
4036
		if {![info exists containerwindows($w)] || [winfo toplevel $w] != $w} {
4037
			return
4038
		}
4039
4040
		foreach window [set containerwindows($w)] {
4041
			set tab [set win2tab($window)]
4042
			if {$tab != $tokeep} {
4043
				CloseTab $tab
4044
			}
4045
		}
4046
	}
9063 by square87
The new topcw
4047
	
5861 by scapor
memleak fix
4048
	proc CloseTab { tab {detach 0}} {
4049
		variable win_history
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4050
		variable containercurrent
4051
		variable containerprevious
4052
		variable containerwindows
4053
		variable tab2win
4054
		variable win2tab
4055
		
4056
		set win [set tab2win($tab)]
8204 by billiob
do not close the CW if there's a sip call
4057
		if {[::amsn::SIPchatidExistsInList [Name $win]]} {
4058
			status_log " we can't close, there's a sip call running ..." green
9195 by kakaroto
Add support for video calls without using MSNP18
4059
			if {[$::farsight IsVideo] } {
4060
				::amsn::infoMsg [trans closeorcallvideo]
4061
			} else {
4062
				::amsn::infoMsg [trans closeorcall]
4063
			}
8204 by billiob
do not close the CW if there's a sip call
4064
			return
4065
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4066
		set container [winfo toplevel $win]
4067
5861 by scapor
memleak fix
4068
		if {!$detach} {
4069
			array unset win_history [GetInputText $win]
4070
		}
4071
		
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4072
		destroy $win
4073
		destroy [set win2tab($win)]
4074
		set idx [lsearch [set containerwindows($container)] $win]
4075
		set containerwindows($container) [lreplace [set containerwindows($container)] $idx $idx]
4076
		unset win2tab($win)
4077
		unset tab2win($tab)
4078
4079
		if { [info exists containerprevious($container)] && [set containerprevious($container)] != "" } {
4080
			set newwin [set containerprevious($container)]
4081
			if { [GetContainerFromWindow $newwin] != $container } {
4082
				set newwin [lindex [set containerwindows($container)] 0]
4083
			}
4084
		} else {
9063 by square87
The new topcw
4085
			set newwin [lindex [set containerwindows($container)] 0]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4086
		}
4087
4088
		CheckForTooManyTabs $container
4089
4090
		if { $newwin == "" } { 
4091
			set containercurrent($container) ""
4092
			destroy $container
6161 by kakaroto
damn it, I lost my log message somehow.. anyways, I added show/hide functionality consistency to the CL and the CW.
4093
		        ChatWindowDestroyed $container
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4094
		} else {
4095
			SwitchToTab $container $newwin
4096
		}
4097
		
4098
	}
4099
4100
	proc TabEntered { tab win } {
4101
		after cancel "::ChatWindow::FlickerTab $win"; 
9110 by square87
topcw upgraded
4102
		ConfigureTab $tab "tab_hover"
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4103
		set chatid [::ChatWindow::Name $win]
4104
		NameTabButton $win $chatid 1
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4105
	}
4106
	
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4107
	proc TabLeft {tab win} {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4108
		if { [info exists ::ChatWindow::oldpixmap($tab)] } { 
4109
			set image [set ::ChatWindow::oldpixmap($tab)]
4110
		} else {
9110 by square87
topcw upgraded
4111
			set image tab
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4112
		}
4113
4114
		set win [set ::ChatWindow::tab2win($tab)]
4115
		if { $win == [GetCurrentWindow [winfo toplevel $win]] } { 
9110 by square87
topcw upgraded
4116
			set image tab_current
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4117
		}
9110 by square87
topcw upgraded
4118
		
4119
		ConfigureTab $tab $image
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4120
		set chatid [::ChatWindow::Name $win]
4121
		NameTabButton $win $chatid 0
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4122
	 }
4123
3567 by markitusfiber
tabs named with chatid (emails)
4124
	#///////////////////////////////////////////////////////////////////////////////////
3597 by markitusfiber
option to have email on the tabs
4125
	# NameTabButton $win $chatid
4126
	# This proc changes the name of the tab
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4127
	proc NameTabButton { win chatid {hovered 0}} {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4128
		variable win2tab
9063 by square87
The new topcw
4129
		
4130
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4131
		set tab [set win2tab($win)]
4132
		set users [::MSN::usersInChat $chatid]
3905 by netmask
Attempt a button with background pixmap and text for Tcl/Tk 8.3.
4133
		# We have two ways of changing a tab button text
4134
		if { $::tcl_version >= 8.4 } {
4135
			set tabvar $tab
4136
		} else {
4137
			set tabvar ${tab}_lbl
4138
		}
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4139
		#status_log "naming tab $win with chatid info $chatid\n" red
9063 by square87
The new topcw
4140
		
4141
		$tabvar dchars tab_text 0 end
4142
		$tabvar delete tab_text
9184 by kakaroto
Fix new tab buttons ignoring the tabfg and tabfg_hover skin options
4143
		if {$hovered} {
4144
			set tabfg [::skin::getKey tabfg_hover]
4145
		} else {
4146
			set tabfg [::skin::getKey tabfg]
4147
		}
4148
4149
		set style [list [list space 10] [list margin 0 8] \
4150
			       [list default $tabfg splainf] [list colour reset]]
3925 by bluetit
tabs now drawn with canvas. x button included. new skin keys are tab_text_x tab_text_y tab_text_width tab_close_x tab_close_y
4151
		
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4152
		if { $users == "" || [llength $users] == 1} {
9063 by square87
The new topcw
4153
			set nick [::abook::getDisplayNick $chatid 1]
3597 by markitusfiber
option to have email on the tabs
4154
			if { $nick == "" || [::config::getKey tabtitlenick] == 0 } {
9720 by square87
Fix the bad behaviour of "Display nicks in the tabs instead of email" option.
4155
				set txt [concat $style [list [list text $chatid]]]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4156
			} else {
9063 by square87
The new topcw
4157
				set txt [concat $style $nick]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4158
			}
4159
		} elseif { [llength $users] != 1 } {
4160
			set number [llength $users]
9063 by square87
The new topcw
4161
			set txt [trans conversationwith $number]
4162
			set txt [concat $style [list [list text $txt]]]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4163
		}
9063 by square87
The new topcw
4164
		
9568 by kakaroto
Fix the tab close hover image as reported (and patch provided) by dimitrispan88 at http://www.amsn-project.net/forums/viewtopic.php?t=7091&start=15
4165
		::guiContactList::renderContact $tabvar tab_text [expr {[::skin::getKey tab_close_x] - 5}] $txt 0
4166
		$tabvar create image [::skin::getKey tab_close_x] [::skin::getKey tab_close_y] -image [::skin::loadPixmap tab_close]  -activeimage [::skin::loadPixmap tab_close_hover] -anchor nw -tags tab_close
9063 by square87
The new topcw
4167
		
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4168
		::ChatWindow::UpdateContainerTitle [winfo toplevel $win]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4169
	}
4170
4171
4172
	proc GetCurrentWindow { container } {
4173
		variable containercurrent
4174
4175
		if { [info exists containercurrent($container)] && [set containercurrent($container)] != "" } {
4176
			return [set containercurrent($container)]
3578 by markitusfiber
added option in adpref to show the nick or email in the tabs and in a tabbed window
4177
		} else {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4178
			return $container
3578 by markitusfiber
added option in adpref to show the nick or email in the tabs and in a tabbed window
4179
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4180
3567 by markitusfiber
tabs named with chatid (emails)
4181
	}
4182
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4183
	proc SwitchToTab { container win } {
4184
		variable containercurrent
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4185
		variable win2tab
4186
		variable containerprevious
4101 by bluetit
fixed problems with last commit
4187
		variable containerwindows
4188
		
3880 by kakaroto
fixed the refreshs of the window with multiple tabs
4189
		if { [info exists containerwindows($container)] &&
4190
		     [lsearch [set containerwindows($container)] $win] == -1 } { 
4191
			status_log "can't switch to a window that doesn't belong to the correct container"
9565 by billiob
fix (really...) skin setting : tab_close_x
4192
			return
9805 by alexandernst
Now trayicon can blink on new unread messages
4193
		} else {
4194
			::ChatWindow::TrayBlinkStop $win
3880 by kakaroto
fixed the refreshs of the window with multiple tabs
4195
		}
4101 by bluetit
fixed problems with last commit
4196
		
5695 by scapor
cleaning and some TODO work
4197
#TODO:		# Don't switch if tab clicked is already current tab. > 2 used because otherwise windows for new mesages dont appear. this means this is only effective with three or more tabs open. hope someone can find how to fix this.
4102 by bluetit
final fix. only works for > 2 tabs open, otherwise new message chatwindows don't appear.
4198
		if { [info exists containercurrent($container)] == 1 && [set containercurrent($container)] == $win && [llength [set containerwindows($container)]] > 2  } { return }
5419 by bluetit
Added search dialog to chatwindow.
4199
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4200
		if { [info exists containercurrent($container)] && [set containercurrent($container)] != "" } {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4201
			set w [set containercurrent($container)]
4202
			pack forget $w
4203
			set containerprevious($container) $w
4204
			if { [info exists win2tab($w)] } {
4205
				set tab $win2tab($w)
9110 by square87
topcw upgraded
4206
				ConfigureTab $tab "tab"
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4207
			}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4208
		}
4101 by bluetit
fixed problems with last commit
4209
		
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4210
		set  containercurrent($container) $win
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4211
		pack $win -side bottom -expand true -fill both
3574 by markitusfiber
improved tab system -- emails in the tabs and window title
4212
5419 by bluetit
Added search dialog to chatwindow.
4213
		# Tell search dialog we've changed tabs
4214
		if { [winfo exists $container.search] } {
4215
			$container.search configure -searchin [::ChatWindow::GetOutText $win]
4216
		}
4217
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4218
		if { ![info exists containerprevious($container)] } {
4219
			set containerprevious($container) $win
4220
		}
4221
4222
		if { [info exists win2tab($win)] } {
4223
			set tab $win2tab($win)
9110 by square87
topcw upgraded
4224
			ConfigureTab $tab "tab_current"
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4225
		}
4226
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4227
		::ChatWindow::UpdateContainerTitle $container
4228
7639 by tomhennigan
Should fix issues with switching tabs, and the input not being focussed =]
4229
		# Should fix the issue with tab switching and the input not focusing.
8453 by kakaroto
Maybe finally fix the critical flickering problem : http://www.amsn-project.net/forums/viewtopic.php?t=4450
4230
		#update idletasks
7639 by tomhennigan
Should fix issues with switching tabs, and the input not being focussed =]
4231
7864 by kakaroto
Attempt at fixing focus switching indefinitely
4232
#		bind $win <Map> [list focus [::ChatWindow::GetInputText $win] ]
5712 by scapor
thanks youness .. I first added a catch but I don't see why it would fail so I guess its ok this way
4233
7639 by tomhennigan
Should fix issues with switching tabs, and the input not being focussed =]
4234
		focus [::ChatWindow::GetInputText $win]
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4235
	}
4236
7432 by scapor
tryout: winicon is changed to DP of user for chatwindows to easily find chats in windowmanager listings.OK or not ?
4237
	#updates the title and the icon of the container window
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4238
	proc UpdateContainerTitle { container } {
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4239
		#get the name of the "window" which is hte name of the tab in fact
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4240
		set win [GetCurrentWindow $container]
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4241
		#get the ID of the chat (email if only one user)
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4242
		set chatid [::ChatWindow::Name $win]
7432 by scapor
tryout: winicon is changed to DP of user for chatwindows to easily find chats in windowmanager listings.OK or not ?
4243
		set usersinchat [::MSN::usersInChat $chatid]
7453 by baaazen
fixes the window title of the chatwindow being cleared if there is no SB connection
4244
		if {$usersinchat == ""} {
4245
			set usersinchat $chatid
4246
		}
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4247
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4248
		#we'll set a title for the container-window, beginning from scratch
4249
		set title ""
4250
7432 by scapor
tryout: winicon is changed to DP of user for chatwindows to easily find chats in windowmanager listings.OK or not ?
4251
5695 by scapor
cleaning and some TODO work
4252
#TODO: have the titled made up with a template with vars like $nicknames, $groupname and [trans chat] etc
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4253
		if { $chatid != 0 } {
7432 by scapor
tryout: winicon is changed to DP of user for chatwindows to easily find chats in windowmanager listings.OK or not ?
4254
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4255
			#append all nicknames in the chat first to the title	
7432 by scapor
tryout: winicon is changed to DP of user for chatwindows to easily find chats in windowmanager listings.OK or not ?
4256
			foreach user $usersinchat { 
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4257
				#strip out newlines and tabs
4258
				set nick [string map {"\n" " " "\t" " "} [::abook::getDisplayNick $user]]
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4259
				set title "${title}${nick}, "
4260
			}
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4261
4262
			#replace the last ", " with " : <name of the containerwindow> - chat"
6309 by billiob
bug fix; OIM are like a normal message; change the titles of CW back
4263
			set title [string replace $title end-1 end " : [GetContainerName $container] - [trans chat]"]
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4264
		}
4265
7453 by baaazen
fixes the window title of the chatwindow being cleared if there is no SB connection
4266
		if { [::OIM_GUI::IsOIM $chatid] == 1 } {
6556 by billiob
remove useless old OIM code
4267
			set title "$chatid - [trans oim]"
4268
		}
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4269
		#don't think this proc does much .. anyway ;)
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
4270
		set title [EscapeTitle $title]
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4271
		#store our generated title in the array which is needed to reset the title after out "blink"
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4272
		set ::ChatWindow::titles($container) $title
4273
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4274
		#put an asterisk for the title if a new message has arrived
3641 by airadier
Improved tab flickering. If you leave a window with a flickering tab, the window will flicker again.
4275
		if { [info exists ::ChatWindow::new_message_on($container)] && [set ::ChatWindow::new_message_on($container)] == "asterisk" } {
3625 by kakaroto
forgot some fixes.. flickering speed and container title fix when flickering is disabled
4276
			wm title $container "*$title"
4277
		} else {
4278
			wm title $container "$title"
4279
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4280
		
7441 by scapor
remove icon chaticon changing to dp and add a plugin event for if someone were to want this anyway
4281
		#Post event for plugins to know the window title was changed
4282
		set evPar(title) $title
4283
		set evPar(win) $win
4284
		set evPar(chatid) $chatid
4285
		::plugins::PostEvent chatwin_title_changed evPar
3574 by markitusfiber
improved tab system -- emails in the tabs and window title
4286
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4287
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4288
	#this proc is to get the name of the containerwindow, like groupname for groupchats
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4289
	proc GetContainerName { container } {
4290
		variable containers
4291
4292
		foreach type [array names containers] {
4293
			if { $container == [set containers($type)] } {
4294
				if { $type == "global" } {
4681 by germinator2000
Remove some strange window behaviors issues on Mac OS X
4295
					return ""
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4296
				} elseif { [string first "group" $type] == 0} {
4297
					set gid [string range $type 5 end]
4298
					set name [::groups::GetName $gid]
4299
					if {$name != "" } {
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4300
						return "$name"
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4301
					} else {
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4302
						return "$type"
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4303
					}
4304
				} else {
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4305
					return "$type"
3593 by kakaroto
Added flickering of the whole container when a tab flickers and added better title support for container
4306
				}
4307
			}
4308
		} 
4309
4310
		return ""
4311
	}
3576 by markitusfiber
*** empty log message ***
4312
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
4313
	proc UseContainer { } {
3645 by airadier
Default tabs to "group mode", and don't show the ugly tab mode selection dialog... :)
4314
		set istabbed [::config::getKey tabbedchat]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4315
3569 by kakaroto
no more tabbs, to use them, manually do "set ::forcetabs 1" each time you start amsn.. for testing only
4316
		if { $istabbed == 1 || $istabbed == 2 } {
4317
			return 1
4318
		} else {
4319
			return 0
4320
		}
4321
4322
	}
3545 by kakaroto
Added tabbed window VERY EXPERIMENTAL
4323
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
4324
	proc CheckForTooManyTabs { container {dorepack "1"}} {
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4325
		variable containerwindows
4326
		variable visibletabs
4327
		variable win2tab
7682 by baaazen
the fix of rev. 9094 caused a call of CheckForTooManyTabs while the value of containerwindows wasn't set yet -> fixed
4328
		if { ![info exists containerwindows($container)] } {
4329
			return
4330
		}
4331
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4332
		set bar_w [winfo width ${container}.bar]
4333
		set tab_w [image width [::skin::loadPixmap tab]]
4334
3936 by bluetit
added images for less and more tabs buttons
4335
		set less_w [image width [::skin::loadPixmap moretabs]] 
4336
		set more_w [image width [::skin::loadPixmap lesstabs]]
3991 by lio_lion
add -highlightthickness 0 to canvas, CORRECT SPACING - PLEASE BE CAREFULL
4337
5715 by scapor
expr speedups
4338
		set bar_w [expr {$bar_w - $less_w - $more_w}]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4339
5720 by scapor
bugfix
4340
		set max_tabs [expr int(floor($bar_w / $tab_w))]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4341
		set number_tabs [llength [set containerwindows($container)]]
4342
	
4343
		set less ${container}.bar.less
4344
		set more ${container}.bar.more
9624 by kakaroto
Create the More/Less buttons at CW creation, so when we resize the CW, we just pack/unpack the widgets instead of destroying/recreatng them...
4345
4346
		pack forget $less
4347
		pack forget $more
5337 by scapor
show the groupname after nicknames for tabbed windows .. also added some comments to make the code more readable
4348
4349
#		status_log "Got $number_tabs tabs in $container that has a max of $max_tabs\n" red
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4350
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4351
		if { $number_tabs < 2 } {
4352
			pack forget ${container}.bar
4353
		} else {
3830 by airadier
Fix for hidden tabs bug.
4354
			#Fix  hidden tabs problem, thanks to Le philousophe
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
4355
			pack ${container}.bar -side top -fill both -expand false
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
4356
			
4357
			#These lines are absolutely necessary on Mac OS X to fix a crash problem
4358
			if { [OnMac] && [winfo exists [GetCurrentWindow $container]] && $dorepack } {
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
4359
				pack forget [GetCurrentWindow $container]
4360
				pack [GetCurrentWindow $container] -side bottom -expand true -fill both
4361
			}
3839 by airadier
Bug fix for previous hidden tabbed windows fix.
4362
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4363
		}
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4364
		if { $max_tabs > 0 && $number_tabs > $max_tabs } {
4365
			pack $more -side right -expand false -fill both -anchor e
4366
			pack $less -side right -expand false -fill both -anchor e
4367
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
4368
			UpdateVisibleTabs $container  $max_tabs		
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4369
			UpdateLessMoreButtons $container $less $more
4370
4371
		} else {
4372
			set visibletabs($container) [set containerwindows($container)]
3885 by germinator2000
Fix crashing issue with tabs on Mac OS X (without removing update idletasks)
4373
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4374
		}
4375
		foreach window [set containerwindows($container)] {
4376
			set tab [set win2tab($window)]
4377
			catch {pack forget $tab}
4378
		}
4379
		foreach window [set visibletabs($container)] {
4380
			set tab [set win2tab($window)]
4381
			pack $tab -side left -expand false -fill both -anchor e
4382
		}
4383
	}
4384
4385
	proc LessTabs { container less more} {
4386
		variable visibletabs
4387
		variable containerwindows
4388
		variable win2tab
4389
4390
		set visible [set visibletabs($container)]
4391
		set windows [set containerwindows($container)]
4392
4393
		set first [lindex $visible 0]
4394
		set last [lindex $visible end]
4395
4396
		set idx [lsearch $windows $first]
4397
		incr idx -1
4398
4399
		set new [lindex $windows $idx]
4400
		if {$new != "" } {
4401
			set tab [set win2tab($new)]
4402
			catch {pack forget [set win2tab($last)]}
4403
			if { $first != $last } {
4404
				pack $tab -side left -expand false -fill both -anchor e -before [set win2tab($first)]
4405
			} else {
4406
				pack $tab -side left -expand false -fill both -anchor e
4407
			}
4408
			set visibletabs($container) [lrange $visible 0 end-1] 
4409
			set visibletabs($container) [linsert [set visibletabs($container)] 0 $new]
4410
		} else {
4411
			$less conf -state disabled
4412
		}
4413
		$more conf -state normal	
4414
4415
		UpdateLessMoreButtons $container $less $more
4416
		
4417
	}
4418
4419
	proc MoreTabs { container less more} {
4420
		variable visibletabs
4421
		variable containerwindows
4422
		variable win2tab
4423
4424
		set visible [set visibletabs($container)]
4425
		set windows [set containerwindows($container)]
4426
4427
		set first [lindex $visible 0]
4428
		set last [lindex $visible end]
4429
4430
		set idx [lsearch $windows $last]
4431
		incr idx 
4432
4433
		set new [lindex $windows $idx]
4434
		if {$new != "" } {
4435
			set tab [set win2tab($new)]
4436
			catch {pack forget [set win2tab($first)]}
4437
			pack $tab -side left -expand false -fill both -anchor e
4438
			set visibletabs($container) [lrange $visible 1 end]
4439
			lappend visibletabs($container) $new
4440
			
4441
		} else {
4442
			$more conf -state disabled
4443
		}
4444
		$less conf -state normal
4445
4446
		UpdateLessMoreButtons $container $less $more
4447
	}
4448
4449
	proc UpdateVisibleTabs { container max } {
4450
		variable visibletabs
4451
		variable containerwindows
4452
4453
		set visible [set visibletabs($container)]
4454
		set windows [set containerwindows($container)]
4455
4456
		set first_idx [lsearch $windows [lindex $visible 0]]
4457
		if {$first_idx == -1 } {
4458
			set first_idx [lsearch $windows [lindex $visible 0]]
4459
		}
4460
		
5715 by scapor
expr speedups
4461
		set visible [lrange $windows $first_idx [expr {$first_idx + $max - 1}]]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4462
		if { [llength $visible] < $max } {
5715 by scapor
expr speedups
4463
			set visible [lrange $windows end-[expr {$max -1}] end]
3592 by kakaroto
fixed alot of ugly things in tabbed windows..
4464
		}
4465
4466
		set visibletabs($container) $visible
4467
4468
	}
4469
4470
	proc UpdateLessMoreButtons { container less more } {
4471
		variable visibletabs
4472
		variable containerwindows
4473
4474
		set visible [set visibletabs($container)]
4475
		set windows [set containerwindows($container)]
4476
		
4477
		set first [lindex $visible 0]
4478
		set last [lindex $visible end]
4479
		
4480
		set idx [lsearch $windows $first]
4481
		incr idx -1
4482
		
4483
		set new [lindex $windows $idx]
4484
		if {$new == "" } {
4485
			$less conf -state disabled
4486
		}
4487
		
4488
		set idx [lsearch $windows $last]
4489
		incr idx 
4490
		
4491
		set new [lindex $windows $idx]
4492
		if {$new == "" } {
4493
			$more conf -state disabled
4494
		}
4495
	}
4496
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
4497
	proc getCurrentTab { win } {
9092 by kakaroto
getCurrentTab is crap, use GetCurrentWindow instead.. we don't need to check the config setting since it could be changed while amsn is running.. also we need to make sure that the variable exists... this fixes a bug with so many things for example 'save log' from a 'to mobile' chat window when tabs are enabled
4498
		return [GetCurrentWindow $win]
3605 by markitusfiber
now the menus are working, no copy paste bugs and added the option to show email in the tab instead of nick
4499
	}
4500
3665 by airadier
Better way of binding the command (less problems, try to avoid nested evaluations and quoting as possible).
4501
	proc createRightTabMenu { tab x y} {
3664 by kakaroto
fixed .tabmenu bug and added xml parsing procs..
4502
		if { [winfo exists .tabmenu] } { destroy .tabmenu }
3665 by airadier
Better way of binding the command (less problems, try to avoid nested evaluations and quoting as possible).
4503
		menu .tabmenu -tearoff 0 -type normal
3656 by markitusfiber
right click tab menu created, maybe improved but works :-P
4504
		.tabmenu insert end command -command "::ChatWindow::CloseTab $tab; destroy .tabmenu" -label "[trans close]"
7199 by kakaroto
as requested by Paller, a new tab contextual menu entry : "Close All Other Tabs" to close all tabs but keep the one selected (by the right click, not the one focused)
4505
		.tabmenu insert end command -command "::ChatWindow::CloseOtherTabs $tab; destroy .tabmenu" -label "[trans closeothers]"
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4506
		.tabmenu insert end command -command "::ChatWindow::DetachTab $tab; destroy .tabmenu" -label "[trans detach]"
3665 by airadier
Better way of binding the command (less problems, try to avoid nested evaluations and quoting as possible).
4507
		tk_popup .tabmenu $x $y
4508
		#return .tabmenu
3656 by markitusfiber
right click tab menu created, maybe improved but works :-P
4509
	}
4510
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4511
	proc DetachTab { tab } {
4513 by lephilousophe
Now we keep the history when we detach a tab
4512
		global win_history
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4513
		set win [set ::ChatWindow::tab2win($tab)]
4514
		set out [GetOutText $win]
4515
		set in [GetInputText $win]
4516
		set dump_out [$out dump 0.0 end]
4517
		set dump_in [$in dump 0.0 end]
4518
4519
		foreach tag [$out tag names] {
3721 by lio_lion
get 'all' tag options when detaching a window
4520
			foreach option [$out tag configure $tag] {
4521
				if { ([llength $option] == 5) && ([lindex $option 4] != {}) } {
4522
					lappend tags_out($tag) [lindex $option 0]
4523
					lappend tags_out($tag) [lindex $option 4]
4524
				}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4525
			}
4526
		}
4527
4528
4529
		status_log "Got dumps : \n$dump_out\n\n$dump_in\n" red
4530
4531
		set chatid [Name $win]
4532
		
4533
		UnsetFor $chatid $win
4534
		set new [RecreateWindow $chatid]
4535
4536
		set ::ChatWindow::titles(${new}) [set ::ChatWindow::titles(${win})]
4537
		set ::ChatWindow::first_message(${new}) [set ::ChatWindow::first_message(${win})]
4538
		set ::ChatWindow::recent_message(${new}) [set ::ChatWindow::recent_message(${win})]
4491 by lephilousophe
Finished the detach tab function
4539
		set ::ChatWindow::containercurrent(${new}) ${new}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4540
4513 by lephilousophe
Now we keep the history when we detach a tab
4541
		#We now copy the history of what we said
4542
		set winhisto [GetInputText $win]
4543
		set newhisto [GetInputText $new]
4544
		if { [info exists win_history(${winhisto}_count)] } {
4545
			set win_history(${newhisto}_count) $win_history(${winhisto}_count)
4546
			set win_history(${newhisto}_index) $win_history(${winhisto}_index)
4547
			set win_history(${newhisto}) $win_history(${winhisto})
4548
			if { [info exists win_history(${winhisto}_temp)] } {
4549
				set win_history(${newhisto}_temp) $win_history(${winhisto}_temp)
4550
			}
4551
		}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4552
		
4553
		unset ::ChatWindow::titles(${win})
4554
		unset ::ChatWindow::first_message(${win})
4555
		unset ::ChatWindow::recent_message(${win})
4556
4557
		#Delete images if not in use
8809 by billiob
add a SW/F to the InDPFrame in the CW
4558
		catch {destroy [GetInDisplayPictureFrame $win].pic}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4559
5861 by scapor
memleak fix
4560
		CloseTab $tab 1
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4561
4513 by lephilousophe
Now we keep the history when we detach a tab
4562
		#We now clean the old history
4563
		if { [info exists win_history(${winhisto}_count)] } {
4564
			unset win_history(${winhisto}_count)
4565
			unset win_history(${winhisto}_index)
4566
			unset win_history(${winhisto})
4567
			if { [info exists win_history(${winhisto}_temp)] } {
4568
				unset win_history(${winhisto}_temp)
4569
			}
4570
		}
4571
		
6579 by vivia
Thanx Youness - Why does it work now?
4572
		set out [GetOutText $new]
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4573
		set in [GetInputText $new]
4574
6579 by vivia
Thanx Youness - Why does it work now?
4575
		$out configure -state normal -font bplainf -foreground black
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4576
6580 by vivia
Works OK now. Seems I was testing with unsaved files! Thanx Youness
4577
		undump $out $dump_out 1 [array get tags_out]
4513 by lephilousophe
Now we keep the history when we detach a tab
4578
		#We dumped an invisible new line due to end index so remove it now
4579
		$out delete "end - 1 lines"
6580 by vivia
Works OK now. Seems I was testing with unsaved files! Thanx Youness
4580
		undump $in $dump_in 0
4513 by lephilousophe
Now we keep the history when we detach a tab
4581
		$in delete "end - 1 lines"
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4582
		
4583
	}
4584
6580 by vivia
Works OK now. Seems I was testing with unsaved files! Thanx Youness
4585
	proc undump { w dump rotext {tags_config ""}} {
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4586
		status_log "tags : $tags_config\n" red
6580 by vivia
Works OK now. Seems I was testing with unsaved files! Thanx Youness
4587
		if { $rotext } { set insert_cmd roinsert } else { set insert_cmd insert }
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4588
		foreach {tag options} $tags_config {
4589
			status_log "tag $tag has options $options" red
4590
			foreach {option value} $options { 
4591
				status_log "option $option of tag $tag is $value\n" red
4592
				if {$value != "" } {
4593
					status_log "setting tag option to $value\n" red
4594
					$w tag configure $tag $option $value
4595
				}
4596
			}
4597
		}
4598
4599
		foreach { key value index } $dump {
4600
			#status_log "Undumping into $w, the key $key with value $value at index $index\n" red
4601
			switch -- $key {
4602
				text { 
6580 by vivia
Works OK now. Seems I was testing with unsaved files! Thanx Youness
4603
					$w $insert_cmd $index $value
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4604
				} 
4605
				mark {
4606
					$w mark set $value $index
4607
				} 
4608
				image {
6582 by vivia
Should fix detaching for emoticons containing the # character. Youness said : paste this and commit - and it worked!
4609
					if { [catch {image width $value} ]} {
4610
						if { [string first "#" $value] != -1 } {
4611
							set value [string range $value 0 [expr {[string last "#" $value] -1}]]
4612
						} else {
4613
							set value ""
4614
						}
4615
						if { [catch {image width $value} ]} {
4616
							set value ""
4617
						}
4618
						
4619
					}
4620
					if { $value != "" } {
4621
						$w image create $index -image $value
4622
					}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4623
				}
4624
				window {
4625
					if {[winfo exists $value] } {
4626
						$w window create $index -window $value
4627
					} else {
4628
						status_log "undumping a window that doesn't exist\n" error
4629
					}
4630
				}
4631
				tagon {
4632
					set tags($value) $index
4633
				}
4634
				tagoff {
4635
					$w tag add $value [set tags($value)] $index
4636
				}
4637
				default {
4638
					status_log "Undumping to window $w an unknown key $key with value $value at index $index\n" red
4639
				}
4640
			}
4641
		}
4642
		
4643
	}
4644
4645
	proc RecreateWindow { chatid } {
4646
	
4647
		set win_name [::ChatWindow::Open]
4648
		::ChatWindow::SetFor $chatid $win_name
4649
	
4650
		set ::ChatWindow::first_message($win_name) 0
7913 by scapor
Fix of typo in commit 9373
4651
		set usr_name [lindex [::MSN::usersInChat $chatid] 0]
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4652
	
4653
		# PostEvent 'new_conversation' to notify plugins that the window was created
7912 by scapor
make it consistent, passing only the name of the var
4654
		set evPar(chatid) chatid
4655
		set evPar(usr_name) usr_name
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4656
		::plugins::PostEvent new_conversation evPar
4657
		
4658
4659
		set top_win [winfo toplevel $win_name]
4660
4661
		if { [winfo exists .bossmode] } {
4662
			set ::BossMode(${top_win}) "normal"
4663
			wm state ${top_win} withdraw
4664
		} else {
7674 by baaazen
Improvement: Make aMSN remember the 'maximized' state of chat windows, not just their size.
4665
			if { [::config::getKey winmaximized 0] == 1 } {
4666
				wm state ${top_win} zoomed
4667
			} else {
4668
				wm state ${top_win} normal
4669
			}
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4670
		}
4671
		
4672
		wm deiconify ${top_win}
4673
		
4674
4675
		update idletasks
4042 by germinator2000
Fix hanging issue on TkAqua (finally)
4676
6174 by thaven
This one is a messy diff.... but I did it a few days ago and didn't catch any bugs yet, so I think it's quite safe to commit.
4677
		if { [OnMac] } {
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4678
			::ChatWindow::MacPosition ${top_win}
4679
		}
4680
		::ChatWindow::TopUpdate $chatid
4681
4491 by lephilousophe
Finished the detach tab function
4682
		set usr_name [lindex [::MSN::usersInChat $chatid] 0]
9221 by vivia
Detaching tabs works again, thanks xmav for reporting
4683
		if { [winfo exists [GetOutDisplayPicturesFrame $win_name].dps] } {
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
4684
			::amsn::ShowOrHidePicture
4685
			::amsn::ShowOrHideTopPicture
4686
			::amsn::UpdatePictures $win_name
4491 by lephilousophe
Finished the detach tab function
4687
		} else {
7378 by kakaroto
Ok, finally the merge of DualDisplayPicture plugin into the core! That took me right there, more than 7 hours of work. I HATE BWIDGET'S SCROLLABLEFRAMEEEEEEEEEEEEE :@
4688
			if { [::config::getKey showdisplaypic] && $usr_name != ""} {
4689
				::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name]
4690
			} else {
4691
				::amsn::ChangePicture $win_name [::skin::getDisplayPicture $usr_name] [trans showuserpic $usr_name] nopack
4692
			}
4491 by lephilousophe
Finished the detach tab function
4693
		}
4694
		
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4695
		#We have a window for that chatid, raise it
4696
		raise ${top_win}
4697
7667 by vivia
Fixed crash when detaching last tab
4698
		#Causes freeze when detaching the last tab...
4699
		after idle [list after 0 [list focus [::ChatWindow::GetInputText ${win_name}]]]
3674 by kakaroto
removed tab-bar from container with only one tab and added EXPERIMENTAL detach tab menu item...
4700
4701
		return $win_name
4702
4703
	}
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
4704
4705
	###################################################
4706
	# proc getScrolling : gets the scrolling status of
4707
	# textwidget $tw. Returns 1 to scroll, 0 not to.
4708
	
4709
	proc getScrolling { tw } {
4710
		variable scrolling
4711
		
4712
		#status_log "getScrolling: $tw\n"
4713
		
4714
		if { [info exists scrolling($tw)] } {
4715
		#We are scrolling to the bottom so we are obviously stuck to the end
4716
			return 1
4821 by lephilousophe
Fix bug with getScrolling : 319...321
4717
		} elseif { [winfo exists $tw] } {
4718
			if { [lindex [$tw yview] 1] == 1.0 } {
4719
				#We are at the bottom of the tw so we are stuck to the end
4720
				return 1
4721
			} else {
4722
				#The tw doesn't exist
4723
				return 0
4724
			}
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
4725
		} else {
4726
			return 0
4727
		}
4728
	}
4729
	
4730
	#########################################################
4731
	# proc Scroll : Scrolls down the textwidget $tw
4732
4733
	proc Scroll { tw } {
4734
		variable scrolling
4821 by lephilousophe
Fix bug with getScrolling : 319...321
4735
4736
		if { ![winfo exists $tw] } { return }
4742 by lephilousophe
Fix the scrolling bug (I hope : needs testing !!!!) Thanks to Fish Face
4737
		
4738
		if { ![info exists scrolling($tw)] } {
4739
			set scrolling($tw) 0
4740
		}
4741
		#status_log "Scroll: $tw "
4742
		incr scrolling($tw)
4743
		$tw yview end
4744
4745
		after 100 "catch {incr ::ChatWindow::scrolling($tw) -1; if {\$::ChatWindow::scrolling($tw) == 0 } {unset ::ChatWindow::scrolling($tw) }}"
4746
		
4747
	}
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
4748
4749
	proc SaveToFile { w } {
9091 by kakaroto
Fix issue on windows with multichats.. ::MSN::SBX.log is an invalid filename. Thanks to Gadrin and BW : http://www.amsn-project.net/forums/viewtopic.php?t=6459
4750
		set chatid [::ChatWindow::Name $w]
9094 by kakaroto
Save filename for chats using _$date
4751
4752
		switch -- [::config::getKey dateformat] {
4753
			"MDY" {
4754
				set date [clock format [clock seconds] -format "%m%d%Y"]
4755
			}
4756
			"DMY" {
4757
				set date [clock format [clock seconds] -format "%d%m%Y"]
4758
			}
4759
			"YMD" -
4760
			default {
4761
				set date [clock format [clock seconds] -format "%Y%m%d"]
4762
			}
4763
		}
4764
4765
		if {$chatid == 0 || [llength [::MSN::usersInChat $chatid]] > 1} {
4766
			set filename "[trans chat]_${date}.log"
9091 by kakaroto
Fix issue on windows with multichats.. ::MSN::SBX.log is an invalid filename. Thanks to Gadrin and BW : http://www.amsn-project.net/forums/viewtopic.php?t=6459
4767
		} else {
9094 by kakaroto
Save filename for chats using _$date
4768
			set filename "${chatid}_${date}.log"
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
4769
		}
4770
		set txtw [::ChatWindow::GetOutText $w]
9091 by kakaroto
Fix issue on windows with multichats.. ::MSN::SBX.log is an invalid filename. Thanks to Gadrin and BW : http://www.amsn-project.net/forums/viewtopic.php?t=6459
4771
		set file [chooseFileDialog $filename [trans save] $w "" save]
7795 by kakaroto
Only show one window for saving a chat, no need for two.. removes old ccmsn code.
4772
		
4773
		if { $file != "" } {
4774
			if { [catch {set fd [open $file w] }] } {
4775
				msg_box "[trans invalidfile2 $file]"
4776
				return
4777
			}
4778
		
4779
			set content ""
4780
			set dump [$txtw  dump  -text 0.0 end]
4781
			foreach { text output index } $dump {
4782
				append content $output
4783
			}
4784
		
4785
			puts $fd $content
4786
			close $fd
4787
		}
4788
	}
3862 by tjikkun
some changes in incomming message handling
4789
}
4790
4791
::snit::widget chatwindow {
4792
4793
	hulltype toplevel
4794
	delegate option * to hull
4795
4796
	constructor {args} {
4797
#		button $win.open -text Open -command [mymethod open]
4798
#		button $win.save -text Save -command [mymethod save]
4799
4800
		# ....
4801
4802
		$self configurelist $args
4803
4804
	}
4805
4806
	method messageReceived { message } {
5490 by billiob
change puts to status_log
4807
		status_log "(chatwindow.tcl)[$message getBody]"
3862 by tjikkun
some changes in incomming message handling
4808
	}
4809
}
4810
4811
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
4812
proc EscapeTitle { title } {
4813
	
4951 by kakaroto
seems it was a bad idea...
4814
        return $title
4815
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
4816
	# This RE is just a character class for everything "bad"
4950 by kakaroto
more restrictive regex... it should be reviewed anyways...
4817
	set RE {[\u0080-\uffff]}
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
4818
	
4819
	# We will substitute with a fragment of Tcl script in brackets
4820
	set substitution "?" ;#{[format \\\\u%04x [scan "\\&" %c]]}
4821
	
4822
	# Now we apply the substitution to get a subst-string that
4823
	# will perform the computational parts of the conversion.
4955 by kakaroto
fixed the NS problem (bug 1357602)
4824
	return [regsub -all $RE $title $substitution]
4949 by kakaroto
Now titles in chat windows should contain all the nickname, and special characters are replaced with a question mark
4825
4951 by kakaroto
seems it was a bad idea...
4826
}