try making save box a FileChooserButton: DOESN'T WORK
[opo.git] / gallery-front-end.py
blob36f4602698ce9c884f2571500c398686e08620a1
1 #!/usr/bin/python
2 import pygst
3 pygst.require("0.10")
4 import gst
5 import pygtk
6 pygtk.require('2.0')
7 import gtk
9 WIDTH = 320
10 HEIGHT = 240
12 def videotestsrc():
13 """Make an interesting video test src"""
14 videosrc = gst.element_factory_make("videotestsrc", "video")
15 sp = videosrc.set_property
16 sp("pattern", "zone-plate")
17 sp("kt2", 0)
18 sp("kx2", 2)
19 sp("ky2", 3)
20 sp("kxy", 2)
21 sp("kt2", 0)
22 return videosrc
25 class Screen:
26 def __init__(self, pipeline, videosrc=None, index, n):
27 #video screen
28 self.screen = gtk.DrawingArea()
29 self.screen.set_size_request(WIDTH, HEIGHT)
31 #pack window
32 self.window = gtk.Window()
33 self.vbox = gtk.VBox() # vertical box
34 self.vbox.pack_start(self.screen)
35 self.window.add(self.vbox)
37 # Create GStreamer bits and bobs
38 self.videosrc = videosrc
39 self.pipeline = pipeline
40 self.pipeline.add(self.videosrc)
41 self.sink = gst.element_factory_make("ximagesink", "sink")
42 self.pipeline.add(self.sink)
43 self.videosrc.link(self.sink)
45 self.window.show_all()
46 self.realise()
47 self.sink.set_xwindow_id(self.screen.window.xid)
48 self.pipeline.set_state(gst.STATE_PLAYING)
51 class Control:
52 def __init__(self):
53 self.pipeline = gst.Pipeline()
54 #buttons
55 self.play_button = gtk.Button(stock=gtk.STOCK_MEDIA_PLAY)
56 self.play_button.connect("clicked", self.play_onclick)
57 self.stop_button = gtk.Button(stock=gtk.STOCK_MEDIA_STOP)
58 self.stop_button.connect("clicked", self.stop_onclick)
59 self.quit_button = gtk.Button(stock=gtk.STOCK_QUIT)
60 self.quit_button.connect("clicked", self.quit_onclick)
62 self.buttons = gtk.HButtonBox()
63 self.buttons.add(self.play_button)
64 self.buttons.add(self.stop_button)
65 self.buttons.add(self.quit_button)
67 #pack window
68 self.window = gtk.Window()
69 self.vbox = gtk.VBox() # vertical box
70 self.vbox.pack_start(self.buttons)
71 self.window.add(self.vbox)
72 self.window.connect("destroy", self.destroy)
73 self.window.show_all()
77 def play_onclick(self, widget):
78 print "play"
79 self.start_playing()
82 def stop_onclick(self, widget):
83 print "stop"
84 self.pipeline.set_state(gst.STATE_READY)
86 def destroy(self, widget, data=None):
87 print "bye"
88 gtk.main_quit()
90 quit_onclick = destroy
92 def start_playing(self):
93 self.videosrc = videotestsrc()
94 self.pipeline.add(self.videosrc)
95 self.
98 self.screens = [Screen(pipeline, videosrc, x, SCREENS) for x in range(SCREENS)]
100 self.sink = gst.element_factory_make("ximagesink", "sink")
101 self.pipeline.add(self.sink)
102 self.videosrc.link(self.sink)
104 self.sink.set_xwindow_id(self.screen.window.xid)
106 self.pipeline.set_state(gst.STATE_PLAYING)
108 start = Control()
109 gtk.main()