[gcompris/gcomprixogoo] Persistent board list administration menu



commit 2a54fbd4fa836e3986b8ac4d67d04549c5b960b3
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Fri Dec 25 17:03:49 2009 +0100

    Persistent board list administration menu
    
    Now the long to load administration menu is made persistent,
    I mean that the user can select another menu then come back
    to the boar list menu and it will not be reloaded. Thus the
    user interface is more responsive.

 src/administration-activity/admin/board_list.py    |   10 ++++++
 src/administration-activity/admin/module_boards.py |   31 +++++++++++++-------
 2 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/src/administration-activity/admin/board_list.py b/src/administration-activity/admin/board_list.py
index 6b42449..a67b26c 100644
--- a/src/administration-activity/admin/board_list.py
+++ b/src/administration-activity/admin/board_list.py
@@ -46,6 +46,8 @@ class Board_list:
       self.cur = db_cursor
       self.con = db_connect
 
+  def init(self):
+
       # ---------------
       # Boards Management
       # ---------------
@@ -174,6 +176,14 @@ class Board_list:
       box3.pack_end(self.button_login, False, False, 0)
 
 
+  def show(self, db_connect, db_cursor):
+    self.cur = db_cursor
+    self.con = db_connect
+    self.frame.show()
+
+  def hide(self):
+    self.frame.hide()
+
   # -------------------
   # Board Management
   # -------------------
diff --git a/src/administration-activity/admin/module_boards.py b/src/administration-activity/admin/module_boards.py
index b2b816a..4dfe9fe 100644
--- a/src/administration-activity/admin/module_boards.py
+++ b/src/administration-activity/admin/module_boards.py
@@ -35,6 +35,7 @@ import board_list
 class Boards(module.Module):
   """Administrating GCompris Boards"""
 
+  already_loaded = False
 
   def __init__(self, canvas):
     module.Module.__init__(self, canvas, "boards", _("Boards"))
@@ -45,6 +46,16 @@ class Boards(module.Module):
     return 3
 
   def start(self, area):
+    # Connect to our database
+    self.con = sqlite.connect(gcompris.get_database())
+    self.cur = self.con.cursor()
+
+    if Boards.already_loaded:
+      self.rootitem.props.visibility = goocanvas.ITEM_VISIBLE
+      self.boardList.show(self.con, self.cur)
+      return
+
+    Boards.already_loaded = True
 
     # 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.
@@ -55,30 +66,28 @@ class Boards(module.Module):
 
     module.Module.start(self)
 
-    # Connect to our database
-    self.con = sqlite.connect(gcompris.get_database())
-    self.cur = self.con.cursor()
-
-    frame = gtk.Frame(_("Boards"))
-    frame.show()
+    self.frame = gtk.Frame(_("Boards"))
+    self.frame.show()
 
     goocanvas.Widget(
       parent = self.rootitem,
-      widget=frame,
+      widget=self.frame,
       x=area[0]+self.module_panel_ofset,
       y=area[1]+self.module_panel_ofset,
       width=area[2]-area[0]-2*self.module_panel_ofset,
       height=area[3]-area[1]-2*self.module_panel_ofset,
       anchor=gtk.ANCHOR_NW)
 
-    board_list.Board_list(self.con, self.cur,
-                          frame)
+    self.boardList = board_list.Board_list(self.con, self.cur,
+                                           self.frame)
+    self.boardList.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.boardList.hide()
 
     # Close the database
     self.cur.close()



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