/usr/share/gcompris/python/administration.py is in gcompris-data 15.02-1.1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | # gcompris - administration.py
#
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# Administration Board module
import goocanvas
import gcompris
import gcompris.utils
import gcompris.skin
import gtk
import gtk.gdk
from gcompris import gcompris_gettext as _
# To add a panel, add a python module in the admin subdir
# This module must have a start() and end() function
class Gcompris_administration:
"""Administering GCompris"""
def __init__(self, gcomprisBoard):
self.gcomprisBoard = gcomprisBoard
# The panel being displayed
self.current_panel = None
self.current_panel_stopped = False
# 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.gcomprisBoard.canvas.get_root_item())
gapx = 6
gapy = 10
panel_x = 120
self.select_area = (gapx, gapy, panel_x + gapx , gcompris.BOARD_HEIGHT-gapy)
self.panel_area = (panel_x + 2*gapx ,
gapy,
gcompris.BOARD_WIDTH-gapx,
gcompris.BOARD_HEIGHT-gapy)
def pause(self, pause):
if(self.current_panel != None):
if pause:
# Stop current panel
self.current_panel.stop()
self.current_panel_stopped = True
else:
# Restart the current panel
self.current_panel.start(self.panel_area)
self.current_panel_stopped = False
def start(self):
# Find the list of modules in admin/
# that means all files, but __init__.py and module.py
list_modules = []
import glob
m_list = glob.glob('admin/module_*.py')
if m_list == []:
m_list = glob.glob(gcompris.PYTHON_PLUGIN_DIR+'/admin/module_*.py')
for file in m_list:
m_name = file.split('/')[-1].split('.')[0].split('_')[1]
if gcompris.sugar_detected():
if (m_name == 'profiles' or m_name == 'boards'):
continue
else:
if (m_name == 'logins' or m_name == 'activities'):
continue
list_modules.append(m_name)
# Now import modules,
# and get the list of string 'name.Name' for initialisation below.
modules_init = []
for module in list_modules:
exec('from admin import module_' + module + ' as ' + module)
modules_init.append(module+ '.' + module[0].upper() + module[1:])
del list_modules
self.gcomprisBoard.level=1
self.gcomprisBoard.maxlevel=1
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=1
gcompris.bar_set(gcompris.BAR_JOURNAL | gcompris.BAR_SHARE)
gcompris.set_default_background(self.gcomprisBoard.canvas.get_root_item())
gcompris.bar_set_level(self.gcomprisBoard)
gcompris.bar_location(25, -1, 0.6)
goocanvas.Rect(
parent = self.rootitem,
x = self.select_area[0],
y = self.select_area[1],
width = self.select_area[2] - self.select_area[0],
height = self.select_area[3] - self.select_area[1],
fill_color = "white",
stroke_color_rgba=0x111199FFL,
line_width=1.0
)
# A White background in the panel area
goocanvas.Rect(
parent = self.rootitem,
x = self.panel_area[0],
y = self.panel_area[1],
width = self.panel_area[2] - self.panel_area[0],
height = self.panel_area[3] - self.panel_area[1],
fill_color="white",
stroke_color_rgba=0x111199FFL,
line_width=1.0
)
# Get the menu position for each module
# The list of modules
modules_ordered = []
for module in modules_init:
p = eval(module +'(self.rootitem).position()')
modules_ordered.append((p, module))
# Display the menu in the selection area
# The list of modules
i = 0
modules_ordered.sort()
for tmodule in modules_ordered:
module = tmodule[1]
eval(module +'(self.rootitem).init(i, self.select_area, self.select_event)')
i+=1
def end(self):
# Stop current panel
if(self.current_panel != None and not self.current_panel_stopped):
self.current_panel.stop()
self.current_panel_stopped = False
def ok(self):
pass
def repeat(self):
pass
def config(self):
pass
def key_press(self, keyval, commit_str, preedit_str):
return False
# ---- End of Initialisation
# Event when a tool is selected
def select_event(self, item, target, event, module):
if event.type == gtk.gdk.BUTTON_PRESS:
if event.button == 1:
# Do not reload it
if(self.current_panel == module):
return
# Stop previous panel if any
if(self.current_panel != None):
self.current_panel.stop()
self.current_panel_stopped = False
self.current_panel = module
# Start the new panel
module.start(self.panel_area)
|