~ml-launchpad/ubuntu/natty/gcompris/fix-for-777349

« back to all changes in this revision

Viewing changes to src/administration-activity/admin/module_profiles.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  gcompris - module_profiles.py
 
2
#
 
3
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
 
4
#
 
5
#   This program is free software; you can redistribute it and/or modify
 
6
#   it under the terms of the GNU General Public License as published by
 
7
#   the Free Software Foundation; either version 3 of the License, or
 
8
#   (at your option) any later version.
 
9
#
 
10
#   This program is distributed in the hope that it will be useful,
 
11
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#   GNU General Public License for more details.
 
14
#
 
15
#   You should have received a copy of the GNU General Public License
 
16
#   along with this program; if not, see <http://www.gnu.org/licenses/>.
 
17
 
 
18
#
 
19
 
 
20
import goocanvas
 
21
import gcompris
 
22
import gcompris.utils
 
23
import gcompris.skin
 
24
import gtk
 
25
import gtk.gdk
 
26
from gcompris import gcompris_gettext as _
 
27
 
 
28
import module
 
29
import profile_list
 
30
 
 
31
# Database
 
32
from pysqlite2 import dbapi2 as sqlite
 
33
 
 
34
class Profiles(module.Module):
 
35
  """Administrating GCompris Profiles"""
 
36
 
 
37
 
 
38
  def __init__(self, canvas):
 
39
    module.Module.__init__(self, canvas, "profiles", _("Profiles"))
 
40
 
 
41
  # Return the position it must have in the administration menu
 
42
  # The smaller number is the highest.
 
43
  def position(self):
 
44
    return 2
 
45
 
 
46
  def start(self, area):
 
47
    # Connect to our database
 
48
    self.con = sqlite.connect(gcompris.get_database())
 
49
    self.cur = self.con.cursor()
 
50
 
 
51
    # Create our rootitem. We put each canvas item in it so at the end we
 
52
    # only have to kill it. The canvas deletes all the items it contains automaticaly.
 
53
 
 
54
    self.rootitem = goocanvas.Group(
 
55
      parent = self.canvas,
 
56
      )
 
57
 
 
58
    module.Module.start(self)
 
59
 
 
60
    frame = gtk.Frame(_("Profiles"))
 
61
    frame.show()
 
62
 
 
63
    goocanvas.Widget(
 
64
      parent = self.rootitem,
 
65
      widget=frame,
 
66
      x=area[0]+self.module_panel_ofset,
 
67
      y=area[1]+self.module_panel_ofset,
 
68
      width=area[2]-area[0]-2*self.module_panel_ofset,
 
69
      height=area[3]-area[1]-2*self.module_panel_ofset,
 
70
      anchor=gtk.ANCHOR_NW)
 
71
 
 
72
    profile_list.Profile_list(frame, self.con, self.cur)
 
73
 
 
74
  def stop(self):
 
75
    module.Module.stop(self)
 
76
 
 
77
    # Remove the root item removes all the others inside it
 
78
    self.rootitem.remove()
 
79
 
 
80
    # Close the database
 
81
    self.cur.close()
 
82
    self.con.close()