~ferama/cgmail/main

« back to all changes in this revision

Viewing changes to src/manager/accpropdialog.py

  • Committer: Marco Ferragina
  • Date: 2007-05-07 21:24:16 UTC
  • Revision ID: marco.ferragina@gmail.com-20070507212416-tr1j4laj54003qxu
Lot of bug fixed. Accounts properties dialog improved

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
                self.widgets = gtk.glade.XML(GLADE_FILE, domain = "cgmail")
27
27
 
28
28
                dict = {
29
 
                        "on_imap_other_rb_toggled": self.on_imap_other_toggled
 
29
                        "on_imap_other_rb_toggled": self.on_imap_other_toggled,
 
30
                        "on_use_custom_port_cb_toggled" : self.on_use_custom_port_toggled,
 
31
                        "on_ssl_connection_toggled" : self.on_ssl_connection_toggled
30
32
                }
31
33
 
32
34
                self.widgets.signal_autoconnect(dict)
80
82
                self.user_entry = self.widgets.get_widget("user_entry")
81
83
                self.passw_entry = self.widgets.get_widget("password_entry")
82
84
                self.server_entry = self.widgets.get_widget("server_entry")
 
85
                self.use_custom_port_cb = self.widgets.get_widget("use_custom_port_cb")
83
86
                self.port_spin = self.widgets.get_widget("port_spin")
84
87
                self.standard_connection = self.widgets.get_widget("standard_connection")
85
88
                self.ssl_connection = self.widgets.get_widget("ssl_connection")
88
91
                self.imap_mbox_entry = self.widgets.get_widget("imap_mbox_entry")
89
92
 
90
93
                self.imap_mbox_entry.set_sensitive(False)
91
 
 
 
94
                
92
95
        
93
96
        def fill(self, amanager, id = None):
 
97
 
94
98
                self.amanager = amanager
95
99
                self.account_id = id
96
100
                
124
128
                        if info["type"] != "gmail":
125
129
                                self.server_entry.set_text(info["server"])
126
130
                                self.port_spin.set_value(int(info["port"]))
 
131
                                
127
132
                                if info["ssl"] == "0":
128
133
                                        self.standard_connection.set_active(True)
129
134
                                else:
136
141
                                                self.imap_other_rb.set_active(True)
137
142
                                                self.imap_mbox_entry.set_sensitive(True)
138
143
                                                self.imap_mbox.set_text(info["mbox"])
139
 
 
 
144
                        
 
145
                        if self.port_is_standard():
 
146
                                self.use_custom_port_cb.set_active(False)
 
147
                        else:
 
148
                                self.use_custom_port_cb.set_active(True)
 
149
 
 
150
 
 
151
        
 
152
        def port_is_standard(self):
 
153
                type = None
 
154
                try:
 
155
                        model = self.typebox.get_model()
 
156
                        iter = self.typebox.get_active_iter()
 
157
                        type = model.get_value(iter, 1)
 
158
                except:
 
159
                        pass
 
160
                
 
161
                port = str(self.port_spin.get_value_as_int())
 
162
                ssl = "0"
 
163
                if self.ssl_connection.get_active():
 
164
                        ssl = "1"
 
165
 
 
166
 
 
167
                if port == "110" and type == "pop3" and  ssl == "0": return True
 
168
                if port == "995" and type == "pop3" and  ssl == "1": return True
 
169
                if port == "143" and type == "imap" and ssl == "0": return True
 
170
                if port == "993" and type == "imap" and ssl == "1": return True
 
171
                return False
140
172
        
141
173
        def enable_disable_widg(self, type):
142
174
                if type == "pop3":
169
201
                ssl = "0"
170
202
                if self.ssl_connection.get_active():
171
203
                        ssl = "1"
172
 
 
 
204
                
173
205
                account_enabled = "0"
174
206
                if self.account_enabled_cb.get_active():
175
207
                        account_enabled = "1"
187
219
                        type = model.get_value(iter, 1)
188
220
                except:
189
221
                        pass
 
222
 
 
223
                if not self.use_custom_port_cb.get_active():
 
224
                        if ssl == "1":
 
225
                                if type == "pop3":
 
226
                                        port = "995"
 
227
                                elif type == "imap":
 
228
                                        port = "993"
 
229
                        else:
 
230
                                if type == "pop3":
 
231
                                        port = "110"
 
232
                                elif type == "imap":
 
233
                                        port = "143"
 
234
 
 
235
 
190
236
                
191
237
                dic = {}
192
238
                if result == gtk.RESPONSE_OK or \
252
298
                # no response. Close button clicked on the dialog window
253
299
                self.dialog.destroy()
254
300
        
 
301
        def on_use_custom_port_toggled(self,w):
 
302
                if w.get_active():
 
303
                        self.port_spin.set_sensitive(True)
 
304
                else:
 
305
                        self.port_spin.set_sensitive(False)     
 
306
 
 
307
        def on_ssl_connection_toggled(self, w):
 
308
 
 
309
                model = self.typebox.get_model()
 
310
                iter = self.typebox.get_active_iter()
 
311
                type = model.get_value(iter, 1)
 
312
 
 
313
                if w.get_active():
 
314
                        if type == "pop3":
 
315
                                self.port_spin.set_value(995)
 
316
                        elif type == "imap":
 
317
                                self.port_spin.set_value(993)
 
318
                else:
 
319
                        if type == "pop3":
 
320
                                self.port_spin.set_value(110)
 
321
                        elif type == "imap":
 
322
                                self.port_spin.set_value(143)
 
323
        
255
324
        def on_imap_other_toggled(self, w):
256
325
                if w.get_active():
257
326
                        self.imap_mbox_entry.set_sensitive(True)
268
337
                except:
269
338
                        print "notype error"
270
339
                        pass
271
 
                        
 
340
 
 
341
                if self.port_is_standard():
 
342
                        self.use_custom_port_cb.set_active(False)
 
343
                else:
 
344
                        self.use_custom_port_cb.set_active(True)
272
345
        
273
346
 
274
347
if __name__ == "__main__":