[gcompris/gcomprixogoo] No more reload the logs in the administration menu



commit 25e05705f8097aa39d9509f3678d327b2f0aca91
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Fri Dec 25 17:16:41 2009 +0100

    No more reload the logs in the administration menu
    
    The log (report) are long to start. Like for the board list
    they are loaded only once.

 src/administration-activity/admin/log_list.py      |   14 ++++++-
 .../admin/module_reports.py                        |   42 ++++++++++++-------
 2 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/src/administration-activity/admin/log_list.py b/src/administration-activity/admin/log_list.py
index b29fd62..f5ee2fe 100644
--- a/src/administration-activity/admin/log_list.py
+++ b/src/administration-activity/admin/log_list.py
@@ -49,9 +49,13 @@ class Log_list:
   # area is the drawing area for the list
   def __init__(self, frame, db_connect, db_cursor):
 
+      self.frame = frame
       self.cur = db_cursor
       self.con = db_connect
 
+  # area is the drawing area for the list
+  def init(self):
+
       # The user_id to work on
       self.current_user_id = 0
       self.user_list = []
@@ -73,7 +77,7 @@ class Log_list:
       # Main box is vertical
       top_box = gtk.VBox(False, 8)
       top_box.show()
-      frame.add(top_box)
+      self.frame.add(top_box)
 
       # First line label and combo
       label_box = gtk.HBox(False, 8)
@@ -175,6 +179,14 @@ class Log_list:
       self.user_changed_cb(self.combo_user)
       self.reload_log()
 
+  def show(self, db_connect, db_cursor):
+    self.cur = db_cursor
+    self.con = db_connect
+    self.frame.show()
+
+  def hide(self):
+    self.frame.hide()
+
   # -------------------
   # Log Management
   # -------------------
diff --git a/src/administration-activity/admin/module_reports.py b/src/administration-activity/admin/module_reports.py
index 81bbaf6..564b8db 100644
--- a/src/administration-activity/admin/module_reports.py
+++ b/src/administration-activity/admin/module_reports.py
@@ -34,6 +34,7 @@ import log_list
 class Reports(module.Module):
   """Administrating GCompris Reports"""
 
+  already_loaded = False
 
   def __init__(self, canvas):
       module.Module.__init__(self, canvas, "reports", _("Reports") )
@@ -45,23 +46,30 @@ class Reports(module.Module):
 
 
   def start(self, area):
-      # Connect to our database
-      self.con = sqlite.connect(gcompris.get_database())
-      self.cur = self.con.cursor()
+    # Connect to our database
+    self.con = sqlite.connect(gcompris.get_database())
+    self.cur = self.con.cursor()
 
-      # Create our rootitem. We put each canvas item in it so at the end we
-      # only have to kill it. The canvas deletes all the items it contains automaticaly.
-      self.rootitem = goocanvas.Group(
-        parent = self.canvas
-          )
+    if Reports.already_loaded:
+      self.rootitem.props.visibility = goocanvas.ITEM_VISIBLE
+      self.logList.show(self.con, self.cur)
+      return
 
-      # Call our parent start
-      module.Module.start(self)
+    Reports.already_loaded = True
 
-      frame = gtk.Frame(_("Users") + " / " + _("Reports") )
-      frame.show()
+    # Create our rootitem. We put each canvas item in it so at the end we
+    # only have to kill it. The canvas deletes all the items it contains automaticaly.
+    self.rootitem = goocanvas.Group(
+      parent = self.canvas
+      )
 
-      goocanvas.Widget(
+    # Call our parent start
+    module.Module.start(self)
+
+    frame = gtk.Frame(_("Users") + " / " + _("Reports") )
+    frame.show()
+
+    goocanvas.Widget(
         parent = self.rootitem,
         widget = frame,
         x=area[0]+self.module_panel_ofset,
@@ -70,13 +78,15 @@ class Reports(module.Module):
         height=area[3]-area[1]-2*self.module_panel_ofset,
         anchor=gtk.ANCHOR_NW)
 
-      log_list.Log_list(frame, self.con, self.cur)
+    self.logList = log_list.Log_list(frame, self.con, self.cur)
+    self.logList.init()
 
   def stop(self):
     module.Module.stop(self)
 
-    # Remove the root item removes all the others inside it
-    self.rootitem.remove()
+    # This module is slow to start, we just hide it
+    self.rootitem.props.visibility = goocanvas.ITEM_INVISIBLE
+    self.logList.hide()
 
     # Close the database
     self.cur.close()



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