-
Notifications
You must be signed in to change notification settings - Fork 1
/
activity.py
73 lines (54 loc) · 2.18 KB
/
activity.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
from gettext import gettext as _
from area import Area
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
from sugar3.activity import activity
from sugar3.graphics.toolbutton import ToolButton
from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.activity.widgets import StopButton
from sugar3.activity.widgets import ActivityToolbarButton
class ConnectTheDotsActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self.make_toolbar()
hbox = Gtk.HBox()
self.set_canvas(hbox)
self.area = Area()
hbox.pack_start(self.area, True, False, 0)
self.show_all()
def make_toolbar(self):
toolbarbox = ToolbarBox()
self.set_toolbar_box(toolbarbox)
button = ActivityToolbarButton(self)
toolbarbox.toolbar.insert(button, -1)
toolbarbox.toolbar.insert(Gtk.SeparatorToolItem(), -1)
button_new = ToolButton("new-button")
button_new.set_tooltip(_("New"))
button_new.connect("clicked", self._next_level)
toolbarbox.toolbar.insert(button_new, -1)
separator = Gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
toolbarbox.toolbar.insert(separator, -1)
button = StopButton(self)
toolbarbox.toolbar.insert(button, -1)
def _next_level(self, button):
self.area.next_level()