Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidepoc/ui/toolbar.py
blob: 96f70f01caa4ec96bf247662cfb5036664a1212c (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
46
47
48
49
50
51
52
53

# python import
from gettext import gettext as _

# gtk import
import gtk

# sugar import
from sugar.graphics.toolbutton import ToolButton

def _cb(widget, data=None):
    pass

BUTTONS = {
        'computer': ['computer', 'Computer', _cb]
        }

TOOLBARS = {
        'default': [
            'computer'
            ]
        }

TITLES = {
        'default': _('Default')
        }

class Toolbar(gtk.Toolbar):

    def __init__(self, toolbox, name='default'):
        # init parent
        gtk.Toolbar.__init__(self)
        # add buttons
        for _b in TOOLBARS[name]:
            self._add_button(_b)
        # add to parent
        toolbox.add_toolbar(TITLES[name], self)
        # show
        self.show()

    def _add_button(self, button_id):
        # ...
        if button_id in BUTTONS:
            _icon, _tooltip, _cb = BUTTONS[button_id]
            # ...
            _buton = ToolButton(_icon)
            _buton.set_tooltip(_tooltip)
            _buton.connect('clicked', _cb)
            self.insert(_buton, -1)
            _buton.show()
        # ...
        else:
            pass