~ubuntu-branches/ubuntu/trusty/gcompris/trusty

« back to all changes in this revision

Viewing changes to src/boards/python/admin/module.py

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2006-12-15 23:08:17 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215230817-exr5ks1hd73s3tlk
Tags: 8.2.2-1
* New upstream bugfix release, fixes among other things the support for
  the version of gnucap shipped in etch.
* Add missing dependency on python-gtk2 (Closes: #396523).
* Removed reference to non-existent sound file from memory.c (upstream
  fix - impacts 8.2 as well).  
* Now suggests gnuchess, gnucap, and tuxpaint.
* Updated extended description for the main package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  gcompris - module.py
 
2
#
 
3
# Copyright (C) 2005 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 2 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, write to the Free Software
 
17
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
#
 
19
 
 
20
# This is the base Class for all Administration modules.
 
21
 
 
22
import gnomecanvas
 
23
import gcompris
 
24
import gcompris.utils
 
25
import gcompris.skin
 
26
import gtk
 
27
import gtk.gdk
 
28
from gettext import gettext as _
 
29
 
 
30
class Module:
 
31
    """GCompris Administrative Module"""
 
32
 
 
33
    def __init__(self, canvas, module_name, module_label):
 
34
        self.module_name = module_name
 
35
        self.module_label = module_label
 
36
        self.canvas = canvas
 
37
 
 
38
        self.selector_color = 0xC5D2DDFFL
 
39
        self.outline_color  = 0XD8B09AFFL
 
40
        self.module_panel_ofset = 3
 
41
 
 
42
    # Return the position it must have in the administration menu
 
43
    # The smaller number is the highest.
 
44
    # By default, return 999 to let the module be low
 
45
    def position(self):
 
46
        return 999
 
47
 
 
48
    def init(self, index, select_area, callback):
 
49
        print("Gcompris_administration init panel.")
 
50
 
 
51
        height = 80
 
52
        gap = 35
 
53
        x   = select_area[0] + (select_area[2] - select_area[0]) / 2
 
54
        y1  = select_area[1] + height * index + 2
 
55
        y2  = select_area[1] + height * (index + 1) + 1
 
56
 
 
57
        # Create our rootitem. We put each canvas item in it so at the end we
 
58
        # only have to kill it. The canvas deletes all the items it contains automaticaly.
 
59
 
 
60
        self.root_select_item = self.canvas.add(
 
61
            gnomecanvas.CanvasGroup,
 
62
            x=0.0,
 
63
            y=0.0
 
64
            )
 
65
 
 
66
        self.select_item = self.root_select_item.add(
 
67
            gnomecanvas.CanvasRect,
 
68
            x1=select_area[0]+2,
 
69
            y1=y1,
 
70
            x2=select_area[2]-2,
 
71
            y2=y2,
 
72
            fill_color="white",
 
73
            outline_color="white",
 
74
            width_units=1.0
 
75
            )
 
76
        self.select_item.connect("event", callback, self)
 
77
 
 
78
        y1 += 30
 
79
        print "config_" + self.module_name + ".png"
 
80
        print gcompris.skin.image_to_skin("config_" +
 
81
                                          self.module_name +
 
82
                                          ".png")
 
83
        item = self.root_select_item.add(
 
84
            gnomecanvas.CanvasPixbuf,
 
85
            pixbuf = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("config_" +
 
86
                                                                            self.module_name +
 
87
                                                                            ".png")),
 
88
            x = x,
 
89
            y = y1,
 
90
            anchor=gtk.ANCHOR_CENTER,
 
91
            )
 
92
        item.connect("event", callback, self)
 
93
 
 
94
        y1 += gap
 
95
 
 
96
        item = self.root_select_item.add (
 
97
            gnomecanvas.CanvasText,
 
98
            text=_(self.module_label),
 
99
            font=gcompris.skin.get_font("gcompris/tiny"),
 
100
            x = x,
 
101
            y = y1,
 
102
            fill_color="black"
 
103
            )
 
104
        item.connect("event", callback, self)
 
105
 
 
106
 
 
107
    def get_module_name(self):
 
108
        return self.module_name
 
109
 
 
110
    def start(self):
 
111
        self.select_item.set(
 
112
            fill_color_rgba=self.selector_color,
 
113
            outline_color_rgba=self.outline_color
 
114
            )
 
115
 
 
116
    def stop(self):
 
117
        self.select_item.set(
 
118
            fill_color="white",
 
119
            outline_color="white"
 
120
            )
 
121