Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ReckonPrimer.activity/toolbar.py
blob: 5a563784d6ce143e22830be96fa12fc7eca901c4 (plain)
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
import gtk

from sugar.activity import activity
from sugar.graphics.toolbutton import ToolButton

from session import Session


class Toolbar:
    
    def __init__(self, parent):
        self._parent = parent
        
    def show(self):
        
        mytoolbox = gtk.Toolbar()
        
        learner_button = ToolButton() 
        learner_button.set_tooltip("Learner")
        learner_button.connect('clicked', self.toggle_mode, "Learner")

        author_button = ToolButton() 
        author_button.set_tooltip("Author")
        author_button.connect('clicked', self.toggle_mode, "Author")
        
        
        
        mytoolbox.insert(author_button, -1)
        author_button.show()
        
        mytoolbox.insert(learner_button, -1)
        learner_button.show()
        mytoolbox.show()

        toolbox = activity.ActivityToolbox(self._parent)
        toolbox.add_toolbar("Switch Lerner -- Author",mytoolbox)
        self._parent.set_toolbox(toolbox)
        toolbox.show()

    def toggle_mode(self, args, mode):
        # self._parent._session.close()
        session = Session("xo-user-name", self._parent)
        session.setMode(mode)
        session.run()