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

# Glitter Toolkit

__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
__licenses__ = ["LICENSE.LGPL"]
__description__ = "Tests for the scroll area 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

from scroll_area import ScrollArea
from image import Image

class TestScrollArea(object):
    """ Tests for the frame widget, depends on Image 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.scroll_area = ScrollArea(2.0, 2.0)
        self.stage.add(self.scroll_area)
        self.scroll_area.natural_x = 0.1
        self.scroll_area.natural_y = 0.1
        self.scroll_area.natural_width = 0.8
        self.scroll_area.natural_height = 0.8
        self.scroll_area._update_layout()
        
        self.image = Image("test2.svg")
        self.scroll_area.pack(self.image)
        #self.label._update_layout()

        self.window.show_all()
        gtk.main()
        
    def destroy(self, widget, data=None):
        gtk.main_quit()

    def do_resize(self, stage, event):
        self.scroll_area._update_layout()
        
if __name__ == '__main__':
    TestScrollArea()