[gyrus/gyrus-python] modified: ChangeLog
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gyrus/gyrus-python] modified: ChangeLog
- Date: Thu, 9 Jul 2009 14:32:54 +0000 (UTC)
commit 874f5f02f7c9f74bb71b4dce2199cde9baf6a19d
Author: Alejandro Valdes jimenez <avaldes amvj in utalca cl>
Date: Thu Jul 9 10:26:12 2009 -0400
modified: ChangeLog
new file: src/GyrusSession.py
modified: src/Makefile.am
modified: src/gyrus.py
modified: src/gyrus_session.py
modified: src/gyrus_util.py
ChangeLog | 5 +
src/GyrusSession.py | 317 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/Makefile.am | 2 +-
src/gyrus.py | 20 ++-
src/gyrus_session.py | 48 +++++----
src/gyrus_util.py | 8 +-
6 files changed, 368 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d937a3c..9cafc08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-07-09 Alejandro Valdes jimenez <avaldes gnome org>
+
+ * src/GyrusSession.py: add script.
+ Fixes bug #520334
+
2009-07-08 Alejandro Valdes jimenez <avaldes gnome org>
* src/gyrus_acl.py: removed.
diff --git a/src/GyrusSession.py b/src/GyrusSession.py
new file mode 100644
index 0000000..c5237bc
--- /dev/null
+++ b/src/GyrusSession.py
@@ -0,0 +1,317 @@
+#!/usr/bin/env python
+#
+# GyrusSession.py Cyrus Administrator. Administrator Object.
+#
+# GYRUS -- GNOME Cyrus Administrator.
+#
+# Copyright 2009 Alejandro Valdes Jimenez <avaldes gnome org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import pygtk
+pygtk.require('2.0')
+import os
+import gtk
+import gtk.glade
+import gettext
+import gnome
+import gobject
+import gconf
+import gyrus_util
+
+from gettext import gettext as _
+
+import config
+
+PATH_KEY = "/apps/gyrus/"
+PATH_SESSIONS = "/apps/gyrus/sessions/"
+
+# for model of sessions
+COLUMN_NAME = 0
+COLUMN_IP = 1
+COLUMN_PORT = 2
+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()
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 69d4e11..c0b4210 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,6 @@ app_PYTHON = \
gyrus_admin_mailbox.py \
gyrus_constant.py \
gyrus.py \
- gyrus_session.py \
GyrusAdmin.py \
GyrusMailboxesTreeView.py \
GyrusMailboxesStore.py \
@@ -17,6 +16,7 @@ app_PYTHON = \
GyrusAclStore.py \
GyrusDialogFindMailbox.py \
GyrusReport.py \
+ GyrusSession.py \
gyrus_util.py
diff --git a/src/gyrus.py b/src/gyrus.py
index d8084f4..aabde6a 100644
--- a/src/gyrus.py
+++ b/src/gyrus.py
@@ -15,12 +15,12 @@ from gettext import gettext as _
import config
from gyrus_constant import *
-import gyrus_session
import gyrus_util
from GyrusDialogFindMailbox import GyrusDialogFindMailbox
from GyrusReport import GyrusReport
from GyrusAdmin import GyrusAdmin
+from GyrusSession import GyrusSession
@@ -103,8 +103,8 @@ class Gyrus:
self.imap_server = {"page":"admin"}
# get preferences
- self.model_session = gyrus_session.get_model_treeview_sessions ()
- gyrus_session.load_preferences(self)
+ #self.session = GyrusSession()
+ #self.session.load_preferences(None)
# create man container
vbox = gtk.VBox(False,0)
@@ -142,7 +142,7 @@ class Gyrus:
self.actiongroup_window.add_actions([
('FileMenu', None, _('_File')),
('OpenSession', gtk.STOCK_DISCONNECT, _('Go to server...'),'<control>O',
- _('Show the list of servers'), gyrus_session.load_interface),
+ _('Show the list of servers'), self.on_opensession_action),
('Quit', gtk.STOCK_QUIT, _('_Quit'), None, _('Quit the Program'), self.quit_program),
('EditMenu', None, _('_Edit')),
('AclMenu', None, _('_ACL')),
@@ -215,6 +215,12 @@ class Gyrus:
def main(self):
"Begin cicle main"
gtk.main()
+
+ def on_opensession_action(self,action,data):
+ self.session = GyrusSession(self)
+ self.session.load_interface()
+ self.session.load_preferences(None)
+
def quit_program(self,data1=None,data2=None):
"Quit of program"
@@ -224,8 +230,8 @@ class Gyrus:
self.about.show()
def create_about_dialog (self):
- authors = ('Alejandro Valdes Jimenez','Francisco Rojas')
- translator_credits = ('Alejandro Valdes Jimenez')
+ authors = ('Alejandro Valdes Jimenez <avaldes gnome org>','Francisco Rojas <frojas alumnos utalca cl>')
+ translator_credits = ('Alejandro Valdes Jimenez <avaldes gnome org>')
logo = gtk.gdk.pixbuf_new_from_file (LOGO)
ad = gtk.AboutDialog()
@@ -244,7 +250,7 @@ class Gyrus:
about.hide ()
return True
- def append_page_to_notebook(self, session):
+ def append_page_to_notebook(self,session):
# load a new instance of table_page
admin = GyrusAdmin(session)
diff --git a/src/gyrus_session.py b/src/gyrus_session.py
index 8f0d0eb..d815b7b 100644
--- a/src/gyrus_session.py
+++ b/src/gyrus_session.py
@@ -33,32 +33,38 @@ class Session:
def load_interface (widget,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")
- button_new = glade_file.get_widget ("button_new")
- button_open = glade_file.get_widget ("button_open")
- button_delete = glade_file.get_widget ("button_delete")
- button_cancel = glade_file.get_widget ("button_cancel")
- button_properties = glade_file.get_widget ("button_properties")
-
- button_open.connect ("clicked", on_button_open_clicked,self)
- button_cancel.connect ("clicked", on_button_cancel_clicked,self)
- button_properties.connect ("clicked", on_button_properties_clicked,self)
- button_delete.connect ("clicked", on_button_delete_clicked,self)
- button_new.connect ("clicked", on_button_new_clicked,self)
-
- 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)
+ 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")
+ button_new = glade_file.get_widget ("button_new")
+ button_open = glade_file.get_widget ("button_open")
+ button_delete = glade_file.get_widget ("button_delete")
+ button_cancel = glade_file.get_widget ("button_cancel")
+ button_properties = glade_file.get_widget ("button_properties")
+
+ button_open.connect ("clicked", on_button_open_clicked,self)
+ button_cancel.connect ("clicked", on_button_cancel_clicked,self)
+ button_properties.connect ("clicked", on_button_properties_clicked,self)
+ button_delete.connect ("clicked", on_button_delete_clicked,self)
+ button_new.connect ("clicked", on_button_new_clicked,self)
+
+ 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)
+
+ if self.model_session.get_iter_root():
+ print "tiene"
+ else:
+ print "vacio"
+ #button_open.set_sensitive(False)
def load_interface_edit_session(self):
glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR,"sessions.glade"),"dialog_session_edit",None)
diff --git a/src/gyrus_util.py b/src/gyrus_util.py
index 5957fb4..ceb2617 100644
--- a/src/gyrus_util.py
+++ b/src/gyrus_util.py
@@ -4,10 +4,12 @@ import gtk
import os
import re
-def show_message (msg, type):
- dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, type,gtk.BUTTONS_OK, msg)
- dialog.run()
+def show_message (msg,type,buttons=gtk.BUTTONS_OK):
+ #dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, type,gtk.BUTTONS_OK, msg)
+ dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL,type,buttons,msg)
+ result = dialog.run()
dialog.destroy()
+ return result
def is_only_numbers (value):
""" if the value contains only numbers return True, otherwise False"""
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]