Back to index

gcompris  8.2.2
module_users.py
Go to the documentation of this file.
00001 #  gcompris - module_users
00002 #
00003 # Copyright (C) 2005 Bruno Coudoin and Yves Combe
00004 #
00005 #   This program is free software; you can redistribute it and/or modify
00006 #   it under the terms of the GNU General Public License as published by
00007 #   the Free Software Foundation; either version 2 of the License, or
00008 #   (at your option) any later version.
00009 #
00010 #   This program is distributed in the hope that it will be useful,
00011 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 #   GNU General Public License for more details.
00014 #
00015 #   You should have received a copy of the GNU General Public License
00016 #   along with this program; if not, write to the Free Software
00017 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 #
00019 
00020 import gnomecanvas
00021 import gcompris
00022 import gcompris.utils
00023 import gcompris.skin
00024 import gtk
00025 import gtk.gdk
00026 import gobject
00027 from gettext import gettext as _
00028 
00029 # Database
00030 from pysqlite2 import dbapi2 as sqlite
00031 
00032 import module
00033 import class_list
00034 
00035 class Users(module.Module):
00036   """Administrating GCompris Users"""
00037 
00038 
00039   def __init__(self, canvas):
00040       print("Gcompris_administration __init__ users panel.")
00041       module.Module.__init__(self, canvas, "users", _("Classes") + " / " + _("Users") )
00042 
00043   # Return the position it must have in the administration menu
00044   # The smaller number is the highest.
00045   def position(self):
00046     return 0
00047 
00048 
00049   def start(self, area):
00050       print "starting users panel"
00051 
00052       # Connect to our database
00053       self.con = sqlite.connect(gcompris.get_database())
00054       self.cur = self.con.cursor()
00055 
00056       # Create our rootitem. We put each canvas item in it so at the end we
00057       # only have to kill it. The canvas deletes all the items it contains automaticaly.
00058       self.rootitem = self.canvas.add(
00059           gnomecanvas.CanvasGroup,
00060           x=0.0,
00061           y=0.0
00062           )
00063 
00064       # Call our parent start
00065       module.Module.start(self)
00066 
00067       frame = gtk.Frame(_("Classes") + " / " + _("Users") )
00068       frame.show()
00069 
00070       self.rootitem.add(
00071         gnomecanvas.CanvasWidget,
00072         widget=frame,
00073         x=area[0]+self.module_panel_ofset,
00074         y=area[1]+self.module_panel_ofset,
00075         width=area[2]-area[0]-2*self.module_panel_ofset,
00076         height=area[3]-area[1]-2*self.module_panel_ofset,
00077         anchor=gtk.ANCHOR_NW,
00078         size_pixels=False)
00079 
00080 
00081       class_list.Class_list(frame, self.con, self.cur)
00082 
00083 
00084   def stop(self):
00085     print "stopping users panel"
00086     module.Module.stop(self)
00087 
00088     # Remove the root item removes all the others inside it
00089     self.rootitem.destroy()
00090 
00091     # Close the database
00092     self.cur.close()
00093     self.con.close()
00094 
00095