~ubuntu-branches/ubuntu/saucy/amsn/saucy

« back to all changes in this revision

Viewing changes to chatwindow.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Devid Antonio Filoni
  • Date: 2010-04-13 23:21:29 UTC
  • mfrom: (1.1.11 upstream) (3.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100413232129-vgpx20brdd2qavs7
Tags: 0.98.3-0ubuntu1
* Merge from Debian unstable (LP: #449072), remaining Ubuntu changes:
  - add 08_use_aplay_for_sound.dpatch patch by Festor Wailon Dacoba to use
    aplay to play sounds
  + debian/control:
    - modify iceweasel to firefox | abrowser in amsn Suggests field
    - add xdg-utils and gstreamer0.10-nice to amsn Depends field
    - mofify sox to alsa-utils in amsn Suggests field as we are now using
      aplay
* New upstream release (LP: #562619), tarball repacked according to
  debian/README.source.
* Fix missing-debian-source-format lintian warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#           By Alberto D�z            #
4
4
#########################################
5
5
 
6
 
::Version::setSubversionId {$Id: chatwindow.tcl 11713 2009-10-19 18:52:33Z billiob $}
 
6
::Version::setSubversionId {$Id: chatwindow.tcl 11981 2010-03-07 20:26:51Z lephilousophe $}
7
7
 
8
8
package require framec
9
9
package require scalable-bg
37
37
                variable containerid 0
38
38
                variable scrolling
39
39
                variable macbouncewindows [list]
 
40
                variable trayblinkwindows [list]
40
41
        }
41
42
        #///////////////////////////////////////////////////////////////////////////////
42
43
 
489
490
                ::MSN::leaveChat $chatid
490
491
                
491
492
                catch { unset ::amsn::lastchatwith(${chatid}) }
 
493
                if {[OnMac]} {
 
494
                        MacBounceDone $window
 
495
                }
 
496
                TrayBlinkStop $window
492
497
        }
493
498
        #///////////////////////////////////////////////////////////////////////////////
494
499
 
572
577
 
573
578
        }
574
579
 
 
580
        proc TrayBlinkStart { window } {
 
581
            variable trayblinkwindows
 
582
            if { [::config::getKey blinktray] == 0 } {
 
583
                    if {[llength $trayblinkwindows] > 0} {
 
584
                            set trayblinkwindows [list]
 
585
                            after cancel ::ChatWindow::TrayBlink 0
 
586
                            after cancel ::ChatWindow::TrayBlink 1
 
587
                            statusicon_proc [::MSN::myStatusIs]
 
588
                    }
 
589
                return
 
590
            }
 
591
            set idx [lsearch [set trayblinkwindows] $window]
 
592
            if {$idx == -1} {
 
593
                lappend trayblinkwindows $window
 
594
                after cancel ::ChatWindow::TrayBlink 0
 
595
                after cancel ::ChatWindow::TrayBlink 1
 
596
                ::ChatWindow::TrayBlink 1
 
597
            }
 
598
        }
 
599
 
 
600
        proc TrayBlinkStop { window } {
 
601
            variable trayblinkwindows
 
602
            set idx [lsearch [set trayblinkwindows] $window]
 
603
            if {$idx >= 0} {
 
604
                set trayblinkwindows [lreplace [set trayblinkwindows] $idx $idx]
 
605
                if { [llength $trayblinkwindows] == 0 } {
 
606
                    after cancel ::ChatWindow::TrayBlink 0
 
607
                    after cancel ::ChatWindow::TrayBlink 1
 
608
                    statusicon_proc [::MSN::myStatusIs]
 
609
                }
 
610
            }
 
611
        }
 
612
 
 
613
        proc TrayBlink { blink } {
 
614
            variable trayblinkwindows
 
615
            if { [::config::getKey blinktray] == 0 } {
 
616
                return
 
617
            }
 
618
            if { $blink == 0 } {
 
619
                statusicon_proc [::MSN::myStatusIs]
 
620
                after [::skin::getKey trayblink_delay] ::ChatWindow::TrayBlink 1
 
621
            } else {
 
622
                statusicon_blink_proc [::MSN::myStatusIs]
 
623
                after [::skin::getKey trayblink_delay]  ::ChatWindow::TrayBlink 0
 
624
            }
 
625
            if { [llength $trayblinkwindows] == 0 } {
 
626
                after cancel ::ChatWindow::TrayBlink 0
 
627
                after cancel ::ChatWindow::TrayBlink 1
 
628
                statusicon_proc [::MSN::myStatusIs]
 
629
            }
 
630
        }
 
631
 
575
632
        proc MacKeepBouncing { } {
576
633
                if {[catch {::carbon::notification "" 1} res]} {
577
634
                        status_log $res
634
691
 
635
692
                if {[llength $macbouncewindows] > 0 } {
636
693
                        set win [lindex $macbouncewindows 0]
637
 
                        wm state $win normal
638
 
                        raise $win
 
694
                        if {[catch {wm state $win normal}]} {
 
695
                                MacBounceDone $win
 
696
                                MacRaiseWindows
 
697
                        } else {
 
698
                                raise $win
 
699
                        }
639
700
                        return 1
640
701
                } else {
641
702
                        return 0
680
741
                                if {[OnMac]} {
681
742
                                        MacBounceStart $window
682
743
                                }
 
744
                                TrayBlinkStart $window
683
745
                        }
684
746
                        return 0
685
747
                }
694
756
                        # so we do it in a catch statement, if it fails. Then load the extension before
695
757
                        # calling winflash. If this one or the first one were successful, we add a bind
696
758
                        # on FocusIn to call the winflash with the -state 0 option to disable it and we return.
 
759
                        TrayBlinkStart $window
697
760
                        if { [OnWin] } {
698
761
                                if { [catch {winflash $window -count 5} ] } {
699
762
                                        if { ![catch { 
700
763
                                                package require winflash
701
764
                                                winflash $window -count 5
702
765
                                        } ] } {
703
 
                                                bind $window <FocusIn> "catch \" winflash $window -state 0\"; bind $window <FocusIn> \"\""
 
766
                                                bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
704
767
                                                return
705
768
                                        }
706
769
                                } else {
707
 
                                        bind $window <FocusIn> "catch \" winflash $window -state 0\"; bind $window <FocusIn> \"\""
 
770
                                        bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
708
771
                                        return
709
772
                                }
710
773
                        } elseif { [OnLinux] } {
714
777
                                                package require linflash
715
778
                                                linflash $window
716
779
                                        } ] } {
717
 
                                                bind $window <FocusIn> "catch \" linunflash $window \"; bind $window <FocusIn> \"\""
 
780
                                                bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
718
781
                                                return
719
782
                                        } else {
720
783
                                                
721
784
                                                # in case it didn't work, but we were able to set the 'urgency'
722
785
                                                # hint, we must unset it even if it failed, 
723
786
                                                # but still fallback to the flickering of the title.
724
 
                                                bind $window <FocusIn> "catch \" linunflash $window \"; bind $window <FocusIn> \"\""    
 
787
                                                bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
725
788
                                        }
726
789
                                } else {
727
 
                                        bind $window <FocusIn> "catch \" linunflash $window \"; bind $window <FocusIn> \"\""
 
790
                                        bind $window <FocusIn> [list ::ChatWindow::GotFocusUnflash ${window}]
728
791
                                        return
729
792
                                }
730
793
                        } elseif { [OnMac] } {
748
811
                        set ::ChatWindow::new_message_on(${window}) "flicker"
749
812
                        
750
813
                } else {
751
 
 
752
814
                        catch {wm title ${window} "$::ChatWindow::titles($window)"} res
753
815
                        catch {unset ::ChatWindow::new_message_on(${window})}
754
816
                        if {[OnMac]} {
755
817
                                MacBounceDone $window
756
818
                        }
 
819
                        TrayBlinkStop $window
757
820
                }
758
821
        }
759
822
        #///////////////////////////////////////////////////////////////////////////////
788
851
                        if {[OnMac]} {
789
852
                                MacBounceDone $window
790
853
                        }
 
854
                        TrayBlinkStop $window
791
855
                }
792
856
        }
793
857
        #///////////////////////////////////////////////////////////////////////////////
794
858
 
 
859
        proc GotFocusUnflash { window } {
 
860
            bind ${window} <FocusIn> ""
 
861
            if {[OnUnix]} {
 
862
                catch { linunflash $window }
 
863
            } elseif {[OnWin]} {
 
864
                catch { winflash $window -state 0 }
 
865
            }
 
866
            TrayBlinkStop $window
 
867
        }
795
868
 
796
869
        #///////////////////////////////////////////////////////////////////////////////
797
870
        # ::ChatWindow::MacPosition
1685
1758
 
1686
1759
                $actionsmenu add command -label "[trans sendcam]..." \
1687
1760
                        -command "::amsn::ShowChatList \"[trans sendcam]\" \[::ChatWindow::getCurrentTab $w\] ::MSNCAM::SendInviteQueue"
1688
 
 
1689
1761
                
1690
 
                $actionsmenu add command -label "[trans sendsip]..." \
1691
 
                    -command "::amsn::ShowChatList \"[trans sendsip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 0\""
1692
 
 
1693
 
                $actionsmenu add command -label "[trans sendvideosip]..." \
1694
 
                    -command "::amsn::ShowChatList \"[trans sendvideosip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 1\""
1695
 
 
 
1762
                global enable_sip
 
1763
                if {$enable_sip} {
 
1764
                        $actionsmenu add command -label "[trans sendsip]..." \
 
1765
                            -command "::amsn::ShowChatList \"[trans sendsip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 0\""
 
1766
 
 
1767
                        $actionsmenu add command -label "[trans sendvideosip]..." \
 
1768
                            -command "::amsn::ShowChatList \"[trans sendvideosip]\" \[::ChatWindow::getCurrentTab $w\] \"::amsn::SIPCallInviteUser 1\""
 
1769
                }
1696
1770
 
1697
1771
                $actionsmenu add separator
1698
1772
 
2401
2475
                set evPar(bottomleft) [$input getinnerframe]
2402
2476
                ::plugins::PostEvent chatsendbutton evPar
2403
2477
 
2404
 
                # Drag and Drop file sending
2405
 
                if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Files <Drop> "fileDropHandler %D sendfile $w"} res ]} {
2406
 
                                status_log "dnd error: $res"
2407
 
                }
2408
 
                #::dnd bindtarget [::ChatWindow::GetInputText $w] UniformResourceLocator <Drop> "%W insert end %D"
2409
 
                if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Text <Drop> {%W insert end %D}} res ]} {
2410
 
                                status_log "dnd error: $res"
2411
 
                }
 
2478
                set droptarget [::ChatWindow::GetInputText $w]
 
2479
                if {[catch {tkdnd::drop_target register $droptarget *} res]} {
 
2480
                        status_log "dnd error: $res"
 
2481
                } else {
 
2482
                        #bind $droptarget <<Drop>> {puts works}
 
2483
                        bind $droptarget <<Drop>> [list ::fileDropHandler %D sendfile $w]
 
2484
                }
 
2485
 
 
2486
#               # Drag and Drop file sending
 
2487
#               if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Files <Drop> "fileDropHandler %D sendfile $w"} res ]} {
 
2488
#                               status_log "dnd error: $res"
 
2489
#               }
 
2490
#               #::dnd bindtarget [::ChatWindow::GetInputText $w] UniformResourceLocator <Drop> "%W insert end %D"
 
2491
#               if {[catch {::dnd bindtarget [::ChatWindow::GetInputText $w] Text <Drop> {%W insert end %D}} res ]} {
 
2492
##                              status_log "dnd error: $res"
 
2493
#               }
2412
2494
 
2413
2495
                return $input
2414
2496
        }
2505
2587
                        -command "::ChatWindow::webcambuttonAction $w"
2506
2588
                set_balloon $webcam "--command--::ChatWindow::SetWebcamText"
2507
2589
                
2508
 
                #Call button
2509
 
                button $call -image [::skin::loadPixmap butcall] -relief flat -padx 0 \
2510
 
                        -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2511
 
                        -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2512
 
                        -command "::amsn::InviteCallFromCW $w 0"
2513
 
                set_balloon $call "[trans sendsip]"
2514
 
 
2515
 
                #Video button
2516
 
                button $callv -image [::skin::loadPixmap butcallvideo] -relief flat -padx 0 \
2517
 
                        -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
2518
 
                        -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
2519
 
                        -command "::amsn::InviteCallFromCW $w 1"
2520
 
                set_balloon $callv "[trans sendvideosip]"
2521
 
 
 
2590
                global enable_sip
 
2591
                if {$enable_sip} {
 
2592
                        #Call button
 
2593
                        button $call -image [::skin::loadPixmap butcall] -relief flat -padx 0 \
 
2594
                            -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
 
2595
                            -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
 
2596
                            -command "::amsn::InviteCallFromCW $w 0"
 
2597
                        set_balloon $call "[trans sendsip]"
 
2598
 
 
2599
                        #Video button
 
2600
                        button $callv -image [::skin::loadPixmap butcallvideo] -relief flat -padx 0 \
 
2601
                            -background [::skin::getKey buttonbarbg] -highlightthickness 0 -borderwidth 0\
 
2602
                            -highlightbackground [::skin::getKey buttonbarbg] -activebackground [::skin::getKey buttonbarbg]\
 
2603
                            -command "::amsn::InviteCallFromCW $w 1"
 
2604
                        set_balloon $callv "[trans sendvideosip]"
 
2605
                }
2522
2606
 
2523
2607
                # Pack them
2524
2608
                pack $fontsel $smileys $voice -side left -padx 0 -pady 0
2525
 
                pack $block $webcam $sendfile $invite $call $callv -side right -padx 0 -pady 0
 
2609
                if {$enable_sip} {
 
2610
                        pack $block $webcam $sendfile $invite $call $callv -side right -padx 0 -pady 0
 
2611
                } else {
 
2612
                        pack $block $webcam $sendfile $invite -side right -padx 0 -pady 0
 
2613
                }
2526
2614
 
2527
2615
                bind $voice    <<Button1-Press>> "::ChatWindow::start_voice_clip $w"
2528
2616
                bind $voice    <<Button1>> "::ChatWindow::stop_and_send_voice_clip $w"
2543
2631
                bind $invite <Leave> "$invite configure -image [::skin::loadPixmap butinvite]"
2544
2632
                bind $webcam <Enter> "$webcam configure -image [::skin::loadPixmap butwebcam_hover]"
2545
2633
                bind $webcam <Leave> "$webcam configure -image [::skin::loadPixmap butwebcam]"
2546
 
                bind $call <Enter> "$call configure -image [::skin::loadPixmap butcall_hover]"
2547
 
                bind $call <Leave> "$call configure -image [::skin::loadPixmap butcall]"
2548
 
                bind $callv <Enter> "$callv configure -image [::skin::loadPixmap butcallvideo_hover]"
2549
 
                bind $callv <Leave> "$callv configure -image [::skin::loadPixmap butcallvideo]"
 
2634
 
 
2635
                if {$enable_sip} {
 
2636
                        bind $call <Enter> "$call configure -image [::skin::loadPixmap butcall_hover]"
 
2637
                        bind $call <Leave> "$call configure -image [::skin::loadPixmap butcall]"
 
2638
                        bind $callv <Enter> "$callv configure -image [::skin::loadPixmap butcallvideo_hover]"
 
2639
                        bind $callv <Leave> "$callv configure -image [::skin::loadPixmap butcallvideo]"
 
2640
                }
2550
2641
                
2551
2642
                #send chatwindowbutton postevent
2552
2643
                set evPar(bottom) $buttonsinner
3738
3829
                set container [string range $tab 0 [expr {[string last "." $tab] - 1}] ]
3739
3830
                set container [string range $container 0 [expr {[string last "." $container] -1}] ]
3740
3831
 
 
3832
                TrayBlinkStart $win
 
3833
 
3741
3834
                #if tab is not visible, then we should change the color of the < or > button
3742
3835
                #to let know there is an invisible tab flickering (an incoming message)
3743
3836
                if { [info exists visibletabs($container)] } {
4053
4146
                if { $users == "" || [llength $users] == 1} {
4054
4147
                        set nick [::abook::getDisplayNick $chatid 1]
4055
4148
                        if { $nick == "" || [::config::getKey tabtitlenick] == 0 } {
4056
 
                                set txt [concat $style [list [list text $tab]]]
 
4149
                                set txt [concat $style [list [list text $chatid]]]
4057
4150
                        } else {
4058
4151
                                set txt [concat $style $nick]
4059
4152
                        }
4091
4184
                     [lsearch [set containerwindows($container)] $win] == -1 } { 
4092
4185
                        status_log "can't switch to a window that doesn't belong to the correct container"
4093
4186
                        return
 
4187
                } else {
 
4188
                        ::ChatWindow::TrayBlinkStop $win
4094
4189
                }
4095
4190
                
4096
4191
#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.