gyrus r329 - in branches/gyrus-python: . src



Author: csaavedra
Date: Wed Mar  5 12:44:31 2008
New Revision: 329
URL: http://svn.gnome.org/viewvc/gyrus?rev=329&view=rev

Log:
2008-03-04  Francisco Rojas  <frojas alumnos utalca cl>

        * src/gyrus.py:
        * src/gyrus_admin_mailbox.py:
        * src/gyrus_constant.py:

        Separate UI and functionality from the function get_list_of_mailbox 
        and add helpful information to treeview model. Fixes bug #520372.



Modified:
   branches/gyrus-python/ChangeLog
   branches/gyrus-python/src/gyrus.py
   branches/gyrus-python/src/gyrus_admin_mailbox.py
   branches/gyrus-python/src/gyrus_constant.py

Modified: branches/gyrus-python/src/gyrus.py
==============================================================================
--- branches/gyrus-python/src/gyrus.py	(original)
+++ branches/gyrus-python/src/gyrus.py	Wed Mar  5 12:44:31 2008
@@ -343,8 +343,8 @@
 	
 	def on_refresh_action (self,action):
 		admin = self.get_current_gyrus_admin()
-		gyrus_admin_mailbox.get_list_of_mailbox(admin)
-
+		lstore,num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
+		self.refresh_treeview_user (lstore,num_usr)
 	
 	def on_entryacldelete_action (self,action):
 		admin = self.get_current_gyrus_admin()
@@ -417,7 +417,8 @@
 
 			if res == True:
 				# refresh list of mailbox
-				gyrus_admin_mailbox.get_list_of_mailbox(admin)
+				lstore , num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
+				self.refresh_treeview_user (lstore,num_usr)
 			else:
 				self.show_message (msg,gtk.MESSAGE_ERROR)
 
@@ -521,7 +522,8 @@
 				auth = self.autenthicate_user (admin)
 
 				if (auth == True):
-					gyrus_admin_mailbox.get_list_of_mailbox(admin)
+					lstore , num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
+					self.refresh_treeview_user(lstore,num_usr)
 	
 					self.actiongroup_window.set_sensitive (True)
 					self.actiongroup_server.set_sensitive (True)
@@ -544,7 +546,16 @@
 			self.actiongroup_mailbox.set_sensitive (False)
 			self.actiongroup_acl.set_sensitive (False)
 			self.clear_all_widget_of_admin(admin)
-
+	
+	def refresh_treeview_user(self,lstore,num_users):		
+		admin = self.get_current_gyrus_admin()
+		admin.treeview_users.set_model(lstore)
+		col = admin.treeview_users.get_column(0)
+		if ( col != 0 ):
+			col.set_title(_("Mailboxs" + " (" + str(num_users) + ")"))
+		else:
+			col.set_title(_("Mailboxs") + " (0)")
+	
 
 	def clear_all_widget_of_admin (self,admin):
 		admin.cnx = None
@@ -712,7 +723,8 @@
 						self.show_message (setmsg,gtk.MESSAGE_ERROR)
 
 					# refresh list of mailbox
-					gyrus_admin_mailbox.get_list_of_mailbox(admin)
+					lstore , num_usr =gyrus_admin_mailbox.get_list_of_mailbox(admin)
+					self.refresh_treeview_user(lstore,num_usr)
 				else:
 					self.show_message (msg,gtk.MESSAGE_ERROR)
 			else:

Modified: branches/gyrus-python/src/gyrus_admin_mailbox.py
==============================================================================
--- branches/gyrus-python/src/gyrus_admin_mailbox.py	(original)
+++ branches/gyrus-python/src/gyrus_admin_mailbox.py	Wed Mar  5 12:44:31 2008
@@ -2,6 +2,7 @@
 import pygtk
 pygtk.require('2.0')
 import gtk
+import gobject
 import gettext
 
 from gyrus_constant import *
@@ -45,13 +46,21 @@
 
 	
 def get_list_of_mailbox(admin):
+	
+	lstore = gtk.ListStore(
+	    gtk.gdk.Pixbuf,
+	    gobject.TYPE_STRING,
+            gobject.TYPE_UINT,
+            gobject.TYPE_UINT)
+	
+	
 	model = admin.treeview_users.get_model()
 	model.clear()
 
 	# get all mailbox (only top-level)
 	type, data = admin.cnx.list(NAMESPACE,"%")
 
-	col = admin.treeview_users.get_column(0)
+	
 
 	if not data[0] == None:
 
@@ -61,24 +70,31 @@
 			info_mailbox = mailbox.split("\"")
 			domain_name_mailbox = info_mailbox[3].split(".")
 			try:
+				
 				name_mailbox = domain_name_mailbox[1]
+				
 				#Checks name_mailbox will not repeat
 				if not (name_mailbox == token):
 					token = name_mailbox
-					iter = model.append(None)
-					model.set (iter,COLUMN_MAILBOX_ICON, 
+					iter = lstore.append(None)
+					
+					#get other data we want save 
+					res,msg,free,quota = get_quota_of_mailbox (admin,name_mailbox)
+
+					lstore.set (iter,COLUMN_MAILBOX_ICON, 
 							gtk.gdk.pixbuf_new_from_file_at_size (DIRGYRUS + "images/gyrus.png",15,15),
-							COLUMN_MAILBOX,name_mailbox)
+							COLUMN_MAILBOX,name_mailbox,
+							COLUMN_FREE,free,
+							COLUMN_QUOTA_ASSIGNED,quota)
+							
 					num_users = num_users + 1
 			except:
 				print "error"
 				pass
 
-		col.set_title(_("Mailboxs" + " (" + str(num_users) + ")"))
-	else:
-		col.set_title(_("Mailboxs") + " (0)")
-		
 	
+	
+	return lstore,num_users
 
 def get_quota_of_mailbox (admin,mailbox):
 	response = admin.cnx.getquota(NAMESPACE + mailbox)

Modified: branches/gyrus-python/src/gyrus_constant.py
==============================================================================
--- branches/gyrus-python/src/gyrus_constant.py	(original)
+++ branches/gyrus-python/src/gyrus_constant.py	Wed Mar  5 12:44:31 2008
@@ -42,8 +42,12 @@
 
 	
 # for model of mailbox
-COLUMN_MAILBOX_ICON = 0
-COLUMN_MAILBOX = 1
+(
+	COLUMN_MAILBOX_ICON,
+	COLUMN_MAILBOX,
+	COLUMN_QUOTA_ASSIGNED,
+	COLUMN_FREE
+) = range (4)
 
 NAMESPACE = "user."
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]