~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
67
68
69
70
71
# !/usr/bin/python
# -*- coding: utf-8 -*-

# Glitter Toolkit

__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
__licenses__ = ["LICENSE.LGPL"]
__description__ = "Tests for the horizontal box widget"

import os
import sys

# Change sys path to glitter path
glitter_path = os.path.split(sys.path[0])[0]
sys.path[0] = glitter_path

from window import Window

import gtk
import clutter

from window import Window
from box import HBox
from label import Label
from image import Image
from variable_space import VariableSpace

class TestVariableSpace(object):
    """ Tests for the variable space widget """
    
    def __init__(self):
        """ Initialize test """
        
        self.window = Window("Glitter tests")
        self.window.connect("destroy", self.destroy)

        self.stage = self.window.get_stage()
        self.stage.connect('notify::width', self.do_resize)
        self.stage.connect('notify::height', self.do_resize)
                
        self.hbox = HBox()
        self.hbox.spacing = 0.0
        self.stage.add(self.hbox)
        self.hbox._update_layout()
        
        self.image1 = Image("base.py")
        self.hbox.pack(self.image1)
        
        self.varspace = VariableSpace()
        self.hbox.pack(self.varspace)
        
        self.image2 = Image("base.py")
        self.hbox.pack(self.image2)
        self.image2.size_ratio = 1.0
        
        self.image3 = Image("base.py")
        self.hbox.pack(self.image3)
        self.hbox.unpack(self.image3)
        
        self.window.show_all()
        gtk.main()

    def do_resize(self, stage, event):
        self.hbox._update_layout()
        
    def destroy(self, widget, data=None):
        gtk.main_quit()

        
if __name__ == '__main__':
    TestVariableSpace()