Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidepoc/ui/toolbar.py
diff options
context:
space:
mode:
Diffstat (limited to 'atoidepoc/ui/toolbar.py')
-rw-r--r--atoidepoc/ui/toolbar.py72
1 files changed, 56 insertions, 16 deletions
diff --git a/atoidepoc/ui/toolbar.py b/atoidepoc/ui/toolbar.py
index 96f70f0..f7e729c 100644
--- a/atoidepoc/ui/toolbar.py
+++ b/atoidepoc/ui/toolbar.py
@@ -1,5 +1,6 @@
# python import
+import logging
from gettext import gettext as _
# gtk import
@@ -8,46 +9,85 @@ import gtk
# sugar import
from sugar.graphics.toolbutton import ToolButton
-def _cb(widget, data=None):
- pass
+# get application logger
+logger = logging.getLogger('atoidepoc')
+
+def _cb_add(widget, toolbar):
+ logger.debug('[toolbar] _cb_add - name: %s' % toolbar.name)
+
+def _cb_open(widget, toolbar):
+ logger.debug('[toolbar] _cb_open - name: %s' % toolbar.name)
+
+def _cb_play(widget, toolbar):
+ logger.debug('[toolbar] _cb_play - name: %s' % toolbar.name)
BUTTONS = {
- 'computer': ['computer', 'Computer', _cb]
+ 'add' : ['list-add', _cb_add],
+ 'open' : ['media', _cb_open],
+ 'play' : ['player_play', _cb_play],
}
TOOLBARS = {
- 'default': [
- 'computer'
- ]
+ 'graphic' : ['add'],
+ 'sound' : ['add'],
+ 'story' : ['open', 'play', ],
}
TITLES = {
- 'default': _('Default')
+ 'graphic' : {
+ 'toolbar': _('Graphic'),
+ 'buttons': {
+ 'add': _('Add Graphic'),
+ }
+ },
+ 'sound' : {
+ 'toolbar': _('Sound'),
+ 'buttons': {
+ 'add': _('Add Sound'),
+ }
+ },
+ 'story' : {
+ 'toolbar': _('Story'),
+ 'buttons': {
+ 'open': _('Open Story'),
+ 'play': _('Play Story'),
+ }
+ },
}
class Toolbar(gtk.Toolbar):
- def __init__(self, toolbox, name='default'):
+ def __init__(self, toolbox, name='player'):
# init parent
gtk.Toolbar.__init__(self)
+ # keep the name
+ self.set_name(name)
# add buttons
- for _b in TOOLBARS[name]:
+ for _b in TOOLBARS[self.name]:
self._add_button(_b)
# add to parent
- toolbox.add_toolbar(TITLES[name], self)
+ toolbox.add_toolbar(TITLES[self.name]['toolbar'], self)
# show
self.show()
def _add_button(self, button_id):
- # ...
+ # little check
if button_id in BUTTONS:
- _icon, _tooltip, _cb = BUTTONS[button_id]
- # ...
+ # get button icon and cb
+ _icon, _cb = BUTTONS[button_id]
+ # get tooltip
+ _tooltip = TITLES[self.name]['buttons'][button_id]
+ # set icon
_buton = ToolButton(_icon)
+ # set tooltip
_buton.set_tooltip(_tooltip)
- _buton.connect('clicked', _cb)
+ # do connect
+ _buton.connect('clicked', _cb, self)
+ # add to the toolbar
self.insert(_buton, -1)
+ # show it
_buton.show()
- # ...
+ # ??
else:
- pass
+ # DEBUG
+ logger.debug('[toolbar] _add_button - unknown: %s' % button_id)