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
|
# python import
import logging
# ..
from gettext import gettext as _
# sugar import
from sugar.activity import activity
# hulahop import
from hulahop.webview import WebView
# atoidejouer import
import app_main
# ..
from atoideweb.tools import config, keys
from atoideweb.ui import toolbar
# get application logger
logger = logging.getLogger('atoidejouer')
URL_BASE = 'http://localhost:5000/'
def _toolbar_changed(toolbox, page, activity_):
"""Catch toolbox activity tab focus to display settings screen.
"""
# is the activity tab?
if page == 0:
# show the activity screen
activity_._change_screen(toolbar=None, name='activity')
else:
pass
# propagate it
return True
class AToiDeWebActivity(activity.Activity, app_main.AToiDeWeb):
def __init__(self, handle):
# init parents
app_main.AToiDeWeb.__init__(self)
activity.Activity.__init__(self, handle)
# ..
self.max_participants = 1
# get toolbox
self._toolbox = activity.ActivityToolbox(self)
# add tool bars
self.set_toolbox(self._toolbox)
# ...
self.web_view = WebView()
self.set_canvas(self.web_view)
self.web_view.show()
# show
self._toolbox.show()
# tmp var
_toolbar = None
# init toolbars
for _n in ['story', 'graphics', 'graphics_add', 'sounds', 'sounds_add']:
# init toolbar
_t = toolbar.Toolbar(self, name=_n)
# if default toolbar .. set default screen
if _n == 'story':
self._change_screen(_t)
_toolbar = _t
# set default tab
self._toolbox.set_current_toolbar(1)
# ..
self._toolbox.connect('current-toolbar-changed', _toolbar_changed, self)
def get_toolbox(self):
return self._toolbox
def _change_screen(self, toolbar=None, name=None):
# ...
_name = toolbar.name if name is None else name
# ...
self.web_view.load_uri(URL_BASE + _name)
def read_file(self, file_path):
app_main.AToiDeWeb.read_file(self, file_path)
def write_file(self, file_path):
app_main.AToiDeWeb.write_file(self, file_path)
def close(self, skip_save=False):
app_main.AToiDeWeb.close(self)
activity.Activity.close(self, skip_save=True)
|