~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to tests/testcomplex.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-07-07 13:43:47 UTC
  • mto: (6.1.9 sid) (1.2.12)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20110707134347-cari9kxjiakzej9z
Tags: upstream-0.14.1
ImportĀ upstreamĀ versionĀ 0.14.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import gobject
2
 
gobject.threads_init()
3
 
import gst
4
 
import pygtk
5
 
pygtk.require("2.0")
6
 
import gtk
7
 
import goocanvas
8
 
import sys
9
 
import os
10
 
from itertools import cycle
11
 
from util import *
12
 
 
13
 
 
14
 
root = os.path.abspath(os.path.curdir)
15
 
print root
16
 
if not root in sys.path:
17
 
    sys.path.insert(0, root)
18
 
 
19
 
from complextimeline import ComplexTrack
20
 
from pitivi.timeline.objects import MEDIA_TYPE_VIDEO
21
 
 
22
 
SOURCES = (
23
 
    ("source1", 300 * gst.SECOND),
24
 
    ("source2", 200 * gst.SECOND),
25
 
    ("source3", 10 * gst.SECOND),
26
 
)
27
 
 
28
 
class TestComposition(gobject.GObject):
29
 
    __gtype_name__ = "TestComposition"
30
 
    __gsignals__ = {
31
 
        "source-added" : (gobject.SIGNAL_RUN_LAST,
32
 
            gobject.TYPE_NONE,
33
 
            (gobject.TYPE_PYOBJECT, )),
34
 
        "source-removed" : (gobject.SIGNAL_RUN_LAST,
35
 
            gobject.TYPE_NONE,
36
 
            (gobject.TYPE_PYOBJECT, )),
37
 
    }
38
 
 
39
 
    def __init__(self, *args, **kwargs):
40
 
        gobject.GObject.__init__(self, *args, **kwargs)
41
 
        self.media_type = MEDIA_TYPE_VIDEO
42
 
 
43
 
    def addSource(self, source, position):
44
 
        self.emit("source-added", source)
45
 
 
46
 
    def removeSource(self, source):
47
 
        self.emit("source-removed", source)
48
 
 
49
 
class TestTimelineObject(gobject.GObject):
50
 
    __gtype_name__ = "TestObject"
51
 
    __gsignals__ = {
52
 
        "start-duration-changed" : (gobject.SIGNAL_RUN_LAST,
53
 
            gobject.TYPE_NONE,
54
 
            (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, )),
55
 
    }
56
 
 
57
 
    class Factory:
58
 
        name=None
59
 
 
60
 
    def __init__(self, name, start, duration):
61
 
        gobject.GObject.__init__(self)
62
 
        self.start = start
63
 
        self.duration = duration
64
 
        self.factory = self.Factory()
65
 
        self.factory.name=name
66
 
 
67
 
    def setStartDurationTime(self, start=-1, duration=-1):
68
 
        if start != -1:
69
 
            self.start = start
70
 
        if duration != -1:
71
 
            self.duration = duration
72
 
        self.emit("start-duration-changed", self.start, self.duration)
73
 
 
74
 
c = goocanvas.Canvas()
75
 
t = ComplexTrack(c)
76
 
model = TestComposition()
77
 
t.set_composition(model)
78
 
c.get_root_item().add_child(t)
79
 
cur = long(0)
80
 
for name, duration in SOURCES:
81
 
    model.addSource(TestTimelineObject(name, cur, duration), None)
82
 
    cur += duration
83
 
print t.width
84
 
c.set_size_request(int(t.width), int(t.height))
85
 
s = gtk.ScrolledWindow()
86
 
s.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_NEVER)
87
 
s.add(c)
88
 
z = gtk.HScale(t.get_zoom_adjustment())
89
 
b = gtk.VBox()
90
 
b.pack_start(s, True, True)
91
 
b.pack_start(z, False, False)
92
 
w = gtk.Window()
93
 
w.add(b)
94
 
w.show_all()
95
 
w.connect("destroy", gtk.main_quit)
96
 
gtk.main()
97
 
 
98