[gyrus/gyrus-python] Fixed bug #600506
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gyrus/gyrus-python] Fixed bug #600506
- Date: Thu, 12 Nov 2009 19:32:54 +0000 (UTC)
commit de50e8a9a903929b4c7ef01301447a41b41b72de
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Thu Nov 12 16:29:32 2009 -0300
Fixed bug #600506
ChangeLog | 6 +
data/glade/sessions.glade | 2 +-
src/GyrusSession.py | 543 +++++++++++++++++++++++----------------------
3 files changed, 282 insertions(+), 269 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 77b99b0..e13e531 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-02 Francisco Rojas <frojas alumnos utalca cl>
+
+ * src/GyrusSession.py: (_on_checkbutton_secure_toggled)
+ Change automatically the port number when the secure connection is selected
+ Fixes bug #600506
+
2009-11-01 Francisco Rojas <frojas alumnos utalca cl>
* src/GyrusMailboxesTreeview.py: (get_list_of_mailbox)
diff --git a/data/glade/sessions.glade b/data/glade/sessions.glade
index 8fbf807..9b1d8d1 100644
--- a/data/glade/sessions.glade
+++ b/data/glade/sessions.glade
@@ -215,7 +215,7 @@
<widget class="GtkSpinButton" id="spinbutton_port">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="adjustment">143 1 65536 1 10 10</property>
+ <property name="adjustment">143 1 65536 1 10 0</property>
<property name="climb_rate">1</property>
</widget>
</child>
diff --git a/src/GyrusSession.py b/src/GyrusSession.py
index c5237bc..7ecad79 100644
--- a/src/GyrusSession.py
+++ b/src/GyrusSession.py
@@ -47,271 +47,278 @@ COLUMN_USER = 3
COLUMN_TLS = 4
class GyrusSession():
- def __init__ (self,gyrus):
- self.gyrus = gyrus
- self.name = None
- self.host = None
- self.port = None
- self.user = None
- self.tls = None
- self.treeview_sessions = None
- self.model_session = gtk.TreeStore(gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_INT,
- gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_STRING)
-
- def load_interface (self):
- glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "sessions.glade"),"dialog_sessions",None)
- self.window_dialog = glade_file.get_widget ("dialog_sessions")
- self.treeview_sessions = glade_file.get_widget ("treeview_sessions")
- self.button_new = glade_file.get_widget ("button_new")
- self.button_open = glade_file.get_widget ("button_open")
- self.button_delete = glade_file.get_widget ("button_delete")
- self.button_cancel = glade_file.get_widget ("button_cancel")
- self.button_properties = glade_file.get_widget ("button_properties")
-
- self.button_open.connect ("clicked", self.on_button_open_clicked)
- self.button_cancel.connect ("clicked", self.on_button_cancel_clicked)
- self.button_properties.connect ("clicked", self.on_button_properties_clicked)
- self.button_delete.connect ("clicked", self.on_button_delete_clicked)
- self.button_new.connect ("clicked", self.on_button_new_clicked)
-
- self.button_properties.set_sensitive(False)
- self.button_delete.set_sensitive(False)
- self.button_open.set_sensitive(False)
- self.button_new.grab_focus()
-
- self.treeview_sessions.set_model (self.model_session)
-
- self.treeview_sessions.set_rules_hint (True)
- self.treeview_sessions.set_reorderable (True)
-
- col = gtk.TreeViewColumn (_("Name"))
- self.treeview_sessions.append_column (col)
- cell = gtk.CellRendererText()
- col.pack_start (cell,True)
- col.add_attribute (cell,"text",COLUMN_NAME)
-
- selection = self.treeview_sessions.get_selection()
- selection.connect("changed",self.on_session_selection_change)
-
-
- def load_interface_edit_session(self,action):
- glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR,"sessions.glade"),"dialog_session_edit",None)
- self.window_dialog_session_edit = glade_file.get_widget ("dialog_session_edit")
- self.checkbutton_secure = glade_file.get_widget ("checkbutton_secure")
- self.entry_host = glade_file.get_widget ("entry_host")
- self.entry_user = glade_file.get_widget ("entry_user")
- self.entry_passwd = glade_file.get_widget ("entry_passwd")
- self.spinbutton_port = glade_file.get_widget ("spinbutton_port")
- self.button_session_edit_ok = glade_file.get_widget ("button_session_edit_ok")
- self.button_session_edit_cancel = glade_file.get_widget ("button_session_edit_cancel")
- self.entry_name = glade_file.get_widget ("entry_name")
- self.checkbutton_secure = glade_file.get_widget ("checkbutton_secure")
- self.window_dialog_session_edit.set_modal(True)
-
- self.button_session_edit_cancel.connect ("clicked", self.on_button_session_edit_cancel_clicked)
- self.entry_name.connect("changed", self.verify_data)
-
-
- if (action == "new"):
- self.button_session_edit_ok.connect ("clicked", self.on_button_session_edit_ok_new_clicked)
- self.window_dialog_session_edit.set_title (_("New session"))
- self.entry_host.set_text("")
- self.entry_user.set_text("")
- self.entry_name.set_text("")
- self.spinbutton_port.set_value(143)
- self.button_session_edit_ok.set_sensitive(False)
- else:
- self.button_session_edit_ok.connect ("clicked", self.on_button_session_edit_ok_clicked)
- self.window_dialog_session_edit.set_title (_("Edit session"))
- self.entry_name.set_sensitive(True)
-
- treeselection = self.treeview_sessions.get_selection()
- model,iter = treeselection.get_selected()
-
- if (iter):
- self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
-
- self.entry_host.set_text (self.host)
- self.spinbutton_port.set_value(self.port)
- self.entry_user.set_text (self.user)
- self.entry_name.set_text (self.name)
- self.checkbutton_secure.set_active (self.tls)
-
- self.window_dialog_session_edit.show()
-
- def verify_data (self,entry):
- l = entry.get_text_length()
-
- if (l <= 0):
- self.button_session_edit_ok.set_sensitive(False)
- else:
- self.button_session_edit_ok.set_sensitive(True)
-
-
- def on_button_new_clicked (self,button):
- self.load_interface_edit_session("new")
-
-
- def on_button_delete_clicked (self,button):
- treeselection = self.treeview_sessions.get_selection()
- model,iter = treeselection.get_selected()
-
- if (iter):
- self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
-
- res = gyrus_util.show_message(_("Delete this session: ") + self.name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_OK_CANCEL)
-
- if res == gtk.RESPONSE_OK:
- client = gconf.client_get_default()
-
- session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
- index = session.index(self.name)
- del session[index]
-
- client.set_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING,session)
-
- client.unset (PATH_SESSIONS + self.name + "/" + "Host")
- client.unset (PATH_SESSIONS + self.name + "/" + "Port")
- client.unset (PATH_SESSIONS + self.name + "/" + "User")
- client.unset (PATH_SESSIONS + self.name + "/" + "UseTLS")
- client.unset (PATH_SESSIONS + self.name)
-
- self.load_preferences(None)
-
- def on_button_session_edit_cancel_clicked (self,button):
- self.window_dialog_session_edit.destroy()
-
- def on_button_properties_clicked (self,button):
- treeselection = self.treeview_sessions.get_selection()
- model,iter = treeselection.get_selected()
-
- if (iter):
- self.load_interface_edit_session("edit")
- self.window_dialog_session_edit.set_title (_("Edit session"))
- self.entry_name.set_sensitive(False)
-
- def on_button_session_edit_ok_new_clicked (self,button):
- name = self.entry_name.get_text().strip()
-
- if (len(name) == 0):
- self.show_message (_("A session name is required."),gtk.MESSAGE_ERROR)
- return
-
- client = gconf.client_get_default()
- session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
-
- try:
- index = session.index(name)
- self.show_message (_("Session already exists."))
- return
- except:
- session.append(name)
- client.set_list (PATH_KEY + "StoredSessions",gconf.VALUE_STRING,session)
-
- host = self.entry_host.get_text()
- port = self.spinbutton_port.get_value_as_int()
- user = self.entry_user.get_text()
- passwd = self.entry_passwd.get_text()
- usetls = self.checkbutton_secure.get_active()
-
- client.set_string (PATH_SESSIONS + name + "/" + "Host",host)
- client.set_int (PATH_SESSIONS + name + "/" + "Port",port)
- client.set_string (PATH_SESSIONS + name + "/" + "User", user)
- client.set_bool (PATH_SESSIONS + name + "/" + "UseTLS",usetls)
-
- self.window_dialog_session_edit.destroy()
- self.load_preferences(name)
-
- def on_button_session_edit_ok_clicked (self,button):
- host = self.entry_host.get_text()
- port = self.spinbutton_port.get_value_as_int()
- user = self.entry_user.get_text()
- name = self.entry_name.get_text()
- passwd = self.entry_passwd.get_text()
- usetls = self.checkbutton_secure.get_active()
-
- client = gconf.client_get_default()
- client.set_string (PATH_SESSIONS + name + "/" + "Host",host)
- client.set_int (PATH_SESSIONS + name + "/" + "Port",port)
- client.set_string (PATH_SESSIONS + name + "/" + "User",user)
- client.set_bool (PATH_SESSIONS + name + "/" + "UseTLS",usetls)
-
- self.window_dialog_session_edit.destroy()
- self.load_preferences (name)
-
- def get_data_of_session_selected (self,iter,model):
- if (iter):
- self.name,self.host,self.port,self.user,self.tls = model.get(iter,
- COLUMN_NAME,
- COLUMN_IP,
- COLUMN_PORT,
- COLUMN_USER,
- COLUMN_TLS)
-
- def on_button_open_clicked (self,button):
- treeselection = self.treeview_sessions.get_selection()
- model,iter = treeselection.get_selected()
-
- if (iter):
- self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
- self.gyrus.append_page_to_notebook(self)
-
- # close dialog session
- self.on_button_cancel_clicked(None)
-
- def on_button_cancel_clicked (self,button):
- self.window_dialog.destroy()
-
- def load_preferences (self,defaultsession=None):
- iter_default = None
- client = gconf.client_get_default()
-
- session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
-
- if (not session == None):
- self.model_session.clear()
- for name in session:
- key = PATH_SESSIONS + name + "/"
-
- host = client.get_string(key + "Host")
- port = client.get_int(key + "Port")
- user = client.get_string(key + "User")
- tls = client.get_bool(key + "UseTLS")
-
- iter = self.model_session.append (None)
- self.model_session.set (iter,
- COLUMN_NAME,name,
- COLUMN_IP,host,
- COLUMN_PORT,port,
- COLUMN_USER ,user,
- COLUMN_TLS,tls)
-
- if (name==defaultsession):
- iter_default = iter
-
- if self.model_session.get_iter_first():
- if (defaultsession == None):
- iter_default = self.model_session.get_iter_first()
-
- if iter_default:
- path = self.model_session.get_path(iter_default)
- self.treeview_sessions.set_cursor(path,None,False)
-
- def on_session_selection_change (self,selection):
- model,iter = selection.get_selected()
-
- if (iter):
- self.button_properties.set_sensitive(True)
- self.button_delete.set_sensitive(True)
- self.button_open.set_sensitive(True)
- self.button_open.grab_focus()
- else:
- self.button_properties.set_sensitive(False)
- self.button_delete.set_sensitive(False)
- self.button_open.set_sensitive(False)
- self.button_new.grab_focus()
-
+ def __init__ (self,gyrus):
+ self.gyrus = gyrus
+ self.name = None
+ self.host = None
+ self.port = None
+ self.user = None
+ self.tls = None
+ self.treeview_sessions = None
+ self.model_session = gtk.TreeStore(gobject.TYPE_STRING,
+ gobject.TYPE_STRING,
+ gobject.TYPE_INT,
+ gobject.TYPE_STRING,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_STRING)
+
+ def load_interface (self):
+ glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "sessions.glade"),"dialog_sessions",None)
+ self.window_dialog = glade_file.get_widget ("dialog_sessions")
+ self.treeview_sessions = glade_file.get_widget ("treeview_sessions")
+ self.button_new = glade_file.get_widget ("button_new")
+ self.button_open = glade_file.get_widget ("button_open")
+ self.button_delete = glade_file.get_widget ("button_delete")
+ self.button_cancel = glade_file.get_widget ("button_cancel")
+ self.button_properties = glade_file.get_widget ("button_properties")
+
+ self.button_open.connect ("clicked", self.on_button_open_clicked)
+ self.button_cancel.connect ("clicked", self.on_button_cancel_clicked)
+ self.button_properties.connect ("clicked", self.on_button_properties_clicked)
+ self.button_delete.connect ("clicked", self.on_button_delete_clicked)
+ self.button_new.connect ("clicked", self.on_button_new_clicked)
+
+ self.button_properties.set_sensitive(False)
+ self.button_delete.set_sensitive(False)
+ self.button_open.set_sensitive(False)
+ self.button_new.grab_focus()
+
+ self.treeview_sessions.set_model (self.model_session)
+
+ self.treeview_sessions.set_rules_hint (True)
+ self.treeview_sessions.set_reorderable (True)
+
+ col = gtk.TreeViewColumn (_("Name"))
+ self.treeview_sessions.append_column (col)
+ cell = gtk.CellRendererText()
+ col.pack_start (cell,True)
+ col.add_attribute (cell,"text",COLUMN_NAME)
+
+ selection = self.treeview_sessions.get_selection()
+ selection.connect("changed",self.on_session_selection_change)
+
+
+ def load_interface_edit_session(self,action):
+ glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR,"sessions.glade"),"dialog_session_edit",None)
+ self.window_dialog_session_edit = glade_file.get_widget ("dialog_session_edit")
+ self.entry_host = glade_file.get_widget ("entry_host")
+ self.entry_user = glade_file.get_widget ("entry_user")
+ self.entry_passwd = glade_file.get_widget ("entry_passwd")
+ self.spinbutton_port = glade_file.get_widget ("spinbutton_port")
+ self.button_session_edit_ok = glade_file.get_widget ("button_session_edit_ok")
+ self.button_session_edit_cancel = glade_file.get_widget ("button_session_edit_cancel")
+ self.entry_name = glade_file.get_widget ("entry_name")
+ self.checkbutton_secure = glade_file.get_widget ("checkbutton_secure")
+ self.window_dialog_session_edit.set_modal(True)
+
+ self.checkbutton_secure.connect('toggled',
+ self._on_checkbutton_secure_toggled)
+
+ self.button_session_edit_cancel.connect ("clicked", self.on_button_session_edit_cancel_clicked)
+ self.entry_name.connect("changed", self.verify_data)
+
+
+ if (action == "new"):
+ self.button_session_edit_ok.connect ("clicked", self.on_button_session_edit_ok_new_clicked)
+ self.window_dialog_session_edit.set_title (_("New session"))
+ self.entry_host.set_text("")
+ self.entry_user.set_text("")
+ self.entry_name.set_text("")
+ self.spinbutton_port.set_value(143)
+ self.button_session_edit_ok.set_sensitive(False)
+ else:
+ self.button_session_edit_ok.connect ("clicked", self.on_button_session_edit_ok_clicked)
+ self.window_dialog_session_edit.set_title (_("Edit session"))
+ self.entry_name.set_sensitive(True)
+
+ treeselection = self.treeview_sessions.get_selection()
+ model,iter = treeselection.get_selected()
+
+ if (iter):
+ self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
+
+ self.entry_host.set_text (self.host)
+ self.spinbutton_port.set_value(self.port)
+ self.entry_user.set_text (self.user)
+ self.entry_name.set_text (self.name)
+ self.checkbutton_secure.set_active (self.tls)
+
+ self.window_dialog_session_edit.show()
+
+ def verify_data (self,entry):
+ l = entry.get_text_length()
+
+ if (l <= 0):
+ self.button_session_edit_ok.set_sensitive(False)
+ else:
+ self.button_session_edit_ok.set_sensitive(True)
+
+
+ def on_button_new_clicked (self,button):
+ self.load_interface_edit_session("new")
+
+
+ def on_button_delete_clicked (self,button):
+ treeselection = self.treeview_sessions.get_selection()
+ model,iter = treeselection.get_selected()
+
+ if (iter):
+ self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
+
+ res = gyrus_util.show_message(_("Delete this session: ") + self.name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_OK_CANCEL)
+
+ if res == gtk.RESPONSE_OK:
+ client = gconf.client_get_default()
+
+ session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
+ index = session.index(self.name)
+ del session[index]
+
+ client.set_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING,session)
+
+ client.unset (PATH_SESSIONS + self.name + "/" + "Host")
+ client.unset (PATH_SESSIONS + self.name + "/" + "Port")
+ client.unset (PATH_SESSIONS + self.name + "/" + "User")
+ client.unset (PATH_SESSIONS + self.name + "/" + "UseTLS")
+ client.unset (PATH_SESSIONS + self.name)
+
+ self.load_preferences(None)
+
+ def on_button_session_edit_cancel_clicked (self,button):
+ self.window_dialog_session_edit.destroy()
+
+ def on_button_properties_clicked (self,button):
+ treeselection = self.treeview_sessions.get_selection()
+ model,iter = treeselection.get_selected()
+
+ if (iter):
+ self.load_interface_edit_session("edit")
+ self.window_dialog_session_edit.set_title (_("Edit session"))
+ self.entry_name.set_sensitive(False)
+
+ def on_button_session_edit_ok_new_clicked (self,button):
+ name = self.entry_name.get_text().strip()
+
+ if (len(name) == 0):
+ self.show_message (_("A session name is required."),gtk.MESSAGE_ERROR)
+ return
+
+ client = gconf.client_get_default()
+ session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
+
+ try:
+ index = session.index(name)
+ self.show_message (_("Session already exists."))
+ return
+ except:
+ session.append(name)
+ client.set_list (PATH_KEY + "StoredSessions",gconf.VALUE_STRING,session)
+
+ host = self.entry_host.get_text()
+ port = self.spinbutton_port.get_value_as_int()
+ user = self.entry_user.get_text()
+ passwd = self.entry_passwd.get_text()
+ usetls = self.checkbutton_secure.get_active()
+
+ client.set_string (PATH_SESSIONS + name + "/" + "Host",host)
+ client.set_int (PATH_SESSIONS + name + "/" + "Port",port)
+ client.set_string (PATH_SESSIONS + name + "/" + "User", user)
+ client.set_bool (PATH_SESSIONS + name + "/" + "UseTLS",usetls)
+
+ self.window_dialog_session_edit.destroy()
+ self.load_preferences(name)
+
+ def on_button_session_edit_ok_clicked (self,button):
+ host = self.entry_host.get_text()
+ port = self.spinbutton_port.get_value_as_int()
+ user = self.entry_user.get_text()
+ name = self.entry_name.get_text()
+ passwd = self.entry_passwd.get_text()
+ usetls = self.checkbutton_secure.get_active()
+
+ client = gconf.client_get_default()
+ client.set_string (PATH_SESSIONS + name + "/" + "Host",host)
+ client.set_int (PATH_SESSIONS + name + "/" + "Port",port)
+ client.set_string (PATH_SESSIONS + name + "/" + "User",user)
+ client.set_bool (PATH_SESSIONS + name + "/" + "UseTLS",usetls)
+
+ self.window_dialog_session_edit.destroy()
+ self.load_preferences (name)
+
+ def get_data_of_session_selected (self,iter,model):
+ if iter:
+ self.name,self.host,self.port,self.user,self.tls = model.get(iter,
+ COLUMN_NAME,
+ COLUMN_IP,
+ COLUMN_PORT,
+ COLUMN_USER,
+ COLUMN_TLS)
+
+ def on_button_open_clicked (self,button):
+ treeselection = self.treeview_sessions.get_selection()
+ model,iter = treeselection.get_selected()
+
+ if iter:
+ self.name,self.host,self.port,self.user,self.tls = model.get(iter,COLUMN_NAME,COLUMN_IP,COLUMN_PORT,COLUMN_USER,COLUMN_TLS)
+ self.gyrus.append_page_to_notebook(self)
+
+ # close dialog session
+ self.on_button_cancel_clicked(None)
+
+ def on_button_cancel_clicked (self,button):
+ self.window_dialog.destroy()
+
+ def load_preferences (self,defaultsession=None):
+ iter_default = None
+ client = gconf.client_get_default()
+
+ session = client.get_list(PATH_KEY + "StoredSessions",gconf.VALUE_STRING)
+
+ if not session == None:
+ self.model_session.clear()
+ for name in session:
+ key = PATH_SESSIONS + name + "/"
+
+ host = client.get_string(key + "Host")
+ port = client.get_int(key + "Port")
+ user = client.get_string(key + "User")
+ tls = client.get_bool(key + "UseTLS")
+
+ iter = self.model_session.append (None)
+ self.model_session.set (iter,
+ COLUMN_NAME,name,
+ COLUMN_IP,host,
+ COLUMN_PORT,port,
+ COLUMN_USER ,user,
+ COLUMN_TLS,tls)
+
+ if name==defaultsession:
+ iter_default = iter
+
+ if self.model_session.get_iter_first():
+ if defaultsession == None:
+ iter_default = self.model_session.get_iter_first()
+
+ if iter_default:
+ path = self.model_session.get_path(iter_default)
+ self.treeview_sessions.set_cursor(path,None,False)
+
+ def on_session_selection_change (self,selection):
+ model,iter = selection.get_selected()
+
+ if (iter):
+ self.button_properties.set_sensitive(True)
+ self.button_delete.set_sensitive(True)
+ self.button_open.set_sensitive(True)
+ self.button_open.grab_focus()
+ else:
+ self.button_properties.set_sensitive(False)
+ self.button_delete.set_sensitive(False)
+ self.button_open.set_sensitive(False)
+ self.button_new.grab_focus()
+
+ def _on_checkbutton_secure_toggled(self, data=None):
+ if self.checkbutton_secure.get_active():
+ self.spinbutton_port.set_value(993)
+ else:
+ self.spinbutton_port.set_value(143)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]