~ubuntu-branches/ubuntu/gutsy/amsn/gutsy

« back to all changes in this revision

Viewing changes to trayicon.tcl.new

  • Committer: Bazaar Package Importer
  • Author(s): Theodore Karkoulis
  • Date: 2006-01-04 15:26:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060104152602-ipe1yg00rl3nlklv
Tags: 0.95-1
New Upstream Release (closes: #345052, #278575).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
if { $initialize_amsn == 1 } {
3
 
    global statusicon mailicon systemtray_exist iconmenu
4
 
 
5
 
    set statusicon 0
6
 
    set mailicon 0
7
 
    set systemtray_exist 0
8
 
    set iconmenu 0
9
 
}
10
 
proc iconify_proc {} {
11
 
        global statusicon config systemtray_exist
12
 
        if { [focus] == "."} {
13
 
                wm iconify .
14
 
                if { $config(closingdocks) } {
15
 
                   wm state . withdrawn
16
 
                }
17
 
        } else {
18
 
                wm deiconify .
19
 
                wm state . normal
20
 
                raise .
21
 
                focus -force .
22
 
        }
23
 
        #bind $statusicon <Button-1> deiconify_proc
24
 
}
25
 
 
26
 
proc trayicon_init {} {
27
 
        global program_dir config systemtray_exist password iconmenu
28
 
        set ext "[file /usr/share/amsn/plugins/traydock/libtray.so]"
29
 
        if { [file exists $ext] != 1 } {
30
 
                msg_box "[trans traynotcompiled]"
31
 
                close_dock
32
 
                set config(dock) 0
33
 
                return
34
 
        }
35
 
        
36
 
        if { $systemtray_exist == 0 && $config(dock) == 3} {
37
 
                load $ext Tray
38
 
                set  systemtray_exist [systemtray_exist]; #a system tray exist?
39
 
        }
40
 
        set iconmenu .immain           
41
 
#       menu .imstatus -tearoff 0 -type normal              #######     submenu in the icon menu won't work in my setup. why?
42
 
#       .imstatus add command -label [trans online] -command "::MSN::changeStatus NLN"
43
 
#       .imstatus add command -label [trans noactivity] -command "::MSN::changeStatus IDL"
44
 
#       .imstatus add command -label [trans busy] -command "::MSN::changeStatus BSY"
45
 
#       .imstatus add command -label [trans rightback] -command "::MSN::changeStatus BRB"
46
 
#       .imstatus add command -label [trans away] -command "::MSN::changeStatus AWY"
47
 
#       .imstatus add command -label [trans onphone] -command "::MSN::changeStatus PHN"
48
 
#       .imstatus add command -label [trans gonelunch] -command "::MSN::changeStatus LUN"
49
 
#       .imstatus add command -label [trans appearoff] -command "::MSN::changeStatus HDN"
50
 
#       .imstatus add separator
51
 
#       .imstatus add command -label "[trans changenick]..." -command cmsn_change_name
52
 
#       
53
 
 
54
 
        menu $iconmenu -tearoff 0 -type normal
55
 
        $iconmenu add command -label "[trans offline]"
56
 
        #$iconmenu add command -label "[trans offline]"
57
 
        $iconmenu add separator
58
 
        if { [string length $config(login)] > 0 } {
59
 
             if {$password != ""} {
60
 
                #$iconmenu add command -label "[trans login] $config(login)" -command "::MSN::connect $config(login) $password" -state normal
61
 
             } else {
62
 
                #$iconmenu add command -label "[trans login] $config(login)" -command cmsn_draw_login -state normal
63
 
             }
64
 
        } else {
65
 
             #$iconmenu add command -label "[trans login]" -command "::MSN::connect $config(login) $password" -state disabled
66
 
        }
67
 
        #$iconmenu add command -label "[trans login]..." -command cmsn_draw_login
68
 
        $iconmenu add command -label "[trans logout]" -command "::MSN::logout; save_alarms" -state disabled
69
 
        $iconmenu add command -label "[trans changenick]..." -command cmsn_change_name -state disabled
70
 
        $iconmenu add separator
71
 
        $iconmenu add command -label "[trans sendmsg]..." -command  "::amsn::ChooseList \"[trans sendmsg]\" online ::amsn::chatUser 1 0" -state disabled
72
 
        $iconmenu add command -label "[trans sendmail]..." -command "::amsn::ChooseList \"[trans sendmail]\" both \"launch_mailer\" 1 0" -state disabled
73
 
        #$iconmenu add command -label "[trans checkver]..." -command "check_version"
74
 
        $iconmenu add separator
75
 
        $iconmenu add command -label "[trans mystatus]" -state disabled
76
 
        $iconmenu add command -label "   [trans online]" -command "::MSN::changeStatus NLN" -state disabled
77
 
        $iconmenu add command -label "   [trans noactivity]" -command "::MSN::changeStatus IDL" -state disabled
78
 
        $iconmenu add command -label "   [trans busy]" -command "::MSN::changeStatus BSY" -state disabled
79
 
        $iconmenu add command -label "   [trans rightback]" -command "::MSN::changeStatus BRB" -state disabled
80
 
        $iconmenu add command -label "   [trans away]" -command "::MSN::changeStatus AWY" -state disabled
81
 
        $iconmenu add command -label "   [trans onphone]" -command "::MSN::changeStatus PHN" -state disabled
82
 
        $iconmenu add command -label "   [trans gonelunch]" -command "::MSN::changeStatus LUN" -state disabled
83
 
        $iconmenu add command -label "   [trans appearoff]" -command "::MSN::changeStatus HDN" -state disabled
84
 
        $iconmenu add separator
85
 
        $iconmenu add command -label "[trans close]" -command "close_cleanup;exit"
86
 
}
87
 
 
88
 
proc statusicon_proc {status} {
89
 
        global systemtray_exist config statusicon user_info list_states user_stat iconmenu
90
 
        set cmdline ""
91
 
        set icon .si
92
 
        if { $systemtray_exist == 1 && $statusicon == 0 && $config(dock) == 3} {
93
 
                set pixmap "[GetSkinFile pixmaps doffline.xpm]"
94
 
                set statusicon [newti $icon -pixmap $pixmap -tooltip offline]
95
 
                bind $icon <Double-Button-1> iconify_proc
96
 
                bind $icon <Button3-ButtonRelease> "tk_popup $iconmenu %X %Y"
97
 
        }
98
 
        set my_name [urldecode [lindex $user_info 4]]
99
 
        
100
 
        if {$systemtray_exist == 1 && $statusicon != 0 && $config(dock) == 3 && $status != "REMOVE"} {
101
 
                if { $status != "" } {
102
 
                        if { $status == "FLN" } {
103
 
                                $iconmenu entryconfigure 2 -state disabled
104
 
                                $iconmenu entryconfigure 3 -state disabled
105
 
                                $iconmenu entryconfigure 5 -state disabled
106
 
                                $iconmenu entryconfigure 6 -state disabled
107
 
                                $iconmenu entryconfigure 8 -state disabled
108
 
                                $iconmenu entryconfigure 9 -state disabled
109
 
                                $iconmenu entryconfigure 10 -state disabled
110
 
                                $iconmenu entryconfigure 11 -state disabled
111
 
                                $iconmenu entryconfigure 12 -state disabled
112
 
                                $iconmenu entryconfigure 13 -state disabled
113
 
                                $iconmenu entryconfigure 14 -state disabled
114
 
                                $iconmenu entryconfigure 15 -state disabled
115
 
                                $iconmenu entryconfigure 16 -state disabled
116
 
 
117
 
                        } else {
118
 
                                $iconmenu entryconfigure 2 -state normal
119
 
                                $iconmenu entryconfigure 3 -state normal
120
 
                                $iconmenu entryconfigure 5 -state normal
121
 
                                $iconmenu entryconfigure 6 -state normal
122
 
                                $iconmenu entryconfigure 8 -state normal
123
 
                                $iconmenu entryconfigure 9 -state normal
124
 
                                $iconmenu entryconfigure 10 -state normal
125
 
                                $iconmenu entryconfigure 11 -state normal
126
 
                                $iconmenu entryconfigure 12 -state normal
127
 
                                $iconmenu entryconfigure 13 -state normal
128
 
                                $iconmenu entryconfigure 14 -state normal
129
 
                                $iconmenu entryconfigure 15 -state normal
130
 
                                $iconmenu entryconfigure 16 -state normal
131
 
                        }
132
 
                                
133
 
                        switch $status {
134
 
                          "FLN" {
135
 
                                set pixmap "[GetSkinFile pixmaps doffline.xpm]"
136
 
                                set tooltip "[trans offline]"                     
137
 
                          }
138
 
                        
139
 
                          "NLN" {
140
 
                                set pixmap "[GetSkinFile pixmaps donline.xpm]"
141
 
                                set tooltip "$my_name ($config(login)): [trans online]"
142
 
                          }
143
 
                          
144
 
                          "IDL" {
145
 
                                set pixmap "[GetSkinFile pixmaps dinactive.xpm]"
146
 
                                set tooltip "$my_name ($config(login)): [trans noactivity]"
147
 
                                #$iconmenu entryconfigure 0 -label $tooltip
148
 
                          }
149
 
                          "BSY" {
150
 
                                set pixmap "[GetSkinFile pixmaps dbusy.xpm]"
151
 
                                set tooltip "$my_name ($config(login)): [trans busy]"
152
 
                                #$iconmenu entryconfigure 0 -label $tooltip
153
 
                          }
154
 
                          "BRB" {
155
 
                                set pixmap "[GetSkinFile pixmaps dbrb.xpm]"
156
 
                                set tooltip "$my_name ($config(login)): [trans rightback]"
157
 
                                #$iconmenu entryconfigure 0 -label $tooltip
158
 
                          }
159
 
                          "AWY" {
160
 
                                set pixmap "[GetSkinFile pixmaps daway.xpm]"
161
 
                                set tooltip "$my_name ($config(login)): [trans away]"
162
 
                                #$iconmenu entryconfigure 0 -label $tooltip
163
 
                          }
164
 
                          "PHN" {
165
 
                                set pixmap "[GetSkinFile pixmaps dphone.xpm]"
166
 
                                set tooltip "$my_name ($config(login)): [trans onphone]"
167
 
                                #$iconmenu entryconfigure 0 -label $tooltip
168
 
                          }
169
 
                          "LUN" {
170
 
                                set pixmap "[GetSkinFile pixmaps dlunch.xpm]"
171
 
                                set tooltip "$my_name ($config(login)): [trans gonelunch]"
172
 
                                #$iconmenu entryconfigure 0 -label $tooltip
173
 
                          }
174
 
                          "HDN" {
175
 
                                set pixmap "[GetSkinFile pixmaps dhidden.xpm]"
176
 
                                set tooltip "$my_name ($config(login)): [trans appearoff]"
177
 
                                #$iconmenu entryconfigure 0 -label $tooltip
178
 
                          }
179
 
                          - {
180
 
                                set pixmap "null"
181
 
                          }
182
 
                        }
183
 
 
184
 
                        $iconmenu entryconfigure 0 -label "$config(login)"
185
 
                        if { $pixmap != "null"} {
186
 
                                configureti $statusicon -pixmap $pixmap -tooltip $tooltip
187
 
                        }
188
 
                }
189
 
        } elseif {$systemtray_exist == 1 && $statusicon != 0 && $status == "REMOVE"} {
190
 
                remove_icon $statusicon
191
 
                set statusicon 0
192
 
        }
193
 
}
194
 
 
195
 
proc mailicon_proc {num} {
196
 
        global systemtray_exist mailicon config password
197
 
        set icon .mi
198
 
        if {$systemtray_exist == 1 && $mailicon == 0 && $config(dock) == 3  && $num >0} {
199
 
                set pixmap "[GetSkinFile pixmaps unread.gif]"
200
 
                if { $num == 1 } {
201
 
                        set msg [trans onenewmail]
202
 
                } elseif { $num == 2 } {
203
 
                        set msg [trans twonewmail 2]
204
 
                } else {
205
 
                        set msg [trans newmail $num]
206
 
                }                       
207
 
                set mailicon [newti $icon -pixmap $pixmap -tooltip $msg]
208
 
                bind $icon <Button-1> "hotmail_login $config(login) $password"
209
 
        } elseif {$systemtray_exist == 1 && $mailicon != 0 && $num ==0} {
210
 
                remove_icon $mailicon
211
 
                set mailicon 0
212
 
        } elseif {$systemtray_exist == 1 && $mailicon != 0 && $config(dock) == 3  && $num >0} {
213
 
                if { $num == 1 } {
214
 
                        set msg [trans onenewmail]
215
 
                } elseif { $num == 2 } {
216
 
                        set msg [trans twonewmail 2]
217
 
                } else {
218
 
                        set msg [trans newmail $num]
219
 
                }
220
 
                configureti $mailicon -tooltip $msg
221
 
        } 
222
 
}
223
 
 
224
 
proc remove_icon {icon} {
225
 
        global systemtray_exist config
226
 
        if {$systemtray_exist == 1 && $icon != 0} {
227
 
                removeti $icon
228
 
#                destroy $icon
229
 
        
230
 
        }
231
 
}
232
 
 
233
 
 
234
 
                
235
 
                
236
 
        
237