~glitter-team/glitter/trunk

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
# !/usr/bin/python
# -*- coding: utf-8 -*-

# Glitter Toolkit

__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
__licenses__ = ["LICENSE.LGPL"]
__description__ = "Toolbar widget"

import gobject

from widget import *
from container import Container
from image import Image

class Toolbar(Container):
    """ 
    A toolbar widget offers an overlay container for displaying tools and 
    should be placed over the actual content the tools refer to.
    
    An example for this are overlay controls in a playing video.
    
    """
    
    def __init__(self):
        """ Initialize toolbar widget """
        
        super(Toolbar, self).__init__()
        
        self._init_elements()
        
        self._update_style(self.style)

    def _init_elements(self):
        """ Initializes graphical elements """
        
        self._background_image = Image()
        self.add(self._background_image)
        
    def _update_style(self, props=None):
        """ Updates style """
        
        super(Toolbar, self)._update_style(props)
        
        for key, value in props:
            if key == 'background-image':
                self.background_image = value
                self._background_image.set_source(self.background_image)
                self._background_image._update_layout()    
        
    def _update_layout(self):
        """ Updates layout """
        
        super(Toolbar, self)._update_layout()
        
        for child in self.get_children():
            child._update_layout()
        
#    def add(self, child):
#        """ Overrides clutter.Actor--add(child) method; calls layout update """
#        
#        super(Toolbar, self).add(child)
#        
#        self._update_layout()