Convert tabs to spaces. Remove accidently committed debug line
[xiph/unicode.git] / souffleur / Souffleur.py
blobe88e7e815a997c3976b5987a5b83b79b482a074d
1 #!/usr/bin/env python
3 #import oggStreams
4 from gstfile import GstFile
5 import sys
7 try:
8 import pygtk
9 #tell pyGTK, if possible, that we want GTKv2
10 pygtk.require("2.0")
11 except:
12 #Some distributions come with GTK2, but not pyGTK
13 pass
14 try:
15 import gtk
16 import gobject
17 import gtk.glade
18 except:
19 print "You need to install pyGTK or GTKv2 ",
20 print "or set your PYTHONPATH correctly."
21 print "try: export PYTHONPATH=",
22 print "/usr/local/lib/python2.2/site-packages/"
23 sys.exit(1)
24 #now we have both gtk and gtk.glade imported
25 #Also, we know we are running GTK v2
27 class Souffleur:
28 # gladefile=""
29 def __init__(self):
30 """
31 In this init we are going to display the main
32 Souffleur window
33 """
34 gladefile="souffleur.glade"
35 windowname="MAIN_WINDOW"
36 self.wTree=gtk.glade.XML (gladefile,windowname)
37 self.gladefile = gladefile
38 # we only have two callbacks to register, but
39 # you could register any number, or use a
40 # special class that automatically
41 # registers all callbacks. If you wanted to pass
42 # an argument, you would use a tuple like this:
43 # dic = { "on button1_clicked" : (self.button1_clicked, arg1,arg2) , ...
45 #dic = { "on_button1_clicked" : self.button1_clicked, \
46 # "gtk_main_quit" : (gtk.mainquit) }
47 dic = { "gtk_main_quit" : (gtk.main_quit),\
48 "on_main_file_quit_activate": (gtk.main_quit), \
49 "on_main_file_open_activate": self.mainFileOpen}
50 self.wTree.signal_autoconnect (dic)
52 self.windowFileOpen=None
53 self.windowStreams=gtk.glade.XML (self.gladefile,"STREAM_WINDOW")
54 ### Setup LIST_STREAMS
55 LIST = self.windowStreams.get_widget("LIST_STREAMS")
56 if LIST:
57 self.streamsTreeStore = gtk.TreeStore(gobject.TYPE_STRING)
58 LIST.set_model(self.streamsTreeStore)
59 cell = gtk.CellRendererText()
60 tvcolumn = gtk.TreeViewColumn('Streams', cell, text = 0)
61 LIST.append_column(tvcolumn)
62 WND=self.windowStreams.get_widget("STREAM_WINDOW")
63 WND.hide()
64 return
65 #==============================================================================
66 def mainFileOpen(self, widget):
67 if(self.windowFileOpen==None):
68 self.windowFileOpen=gtk.glade.XML (self.gladefile,"OPEN_OGG")
69 dic={"on_OPEN_BUTTON_CANCEL_clicked": self.openFileCancel,\
70 "on_OPEN_BUTTON_OPEN_clicked": self.openFileOpen }
71 self.windowFileOpen.signal_autoconnect(dic)
72 # WND=self.windowFileOpen.get_widget("OPEN_OGG")
73 # Filter=gtk.FileFilter()
74 # Filter.set_name("OGM file")
75 # Filter.add_pattern("*.og[gm]")
76 # WND.add_filter(Filter)
77 else:
78 WND=self.windowFileOpen.get_widget("OPEN_OGG")
79 if(WND==None):
80 self.windowFileOpen=None
81 self.mainFileOpen(widget)
82 else:
83 WND.show()
84 return
85 #==============================================================================
86 def openFileCancel(self, widget):
87 if(self.windowFileOpen==None): return
88 WND=self.windowFileOpen.get_widget("OPEN_OGG")
89 WND.hide()
90 return
91 #==============================================================================
92 def openFileOpen(self, widget):
93 WND=self.windowFileOpen.get_widget("OPEN_OGG")
94 FN=WND.get_filename()
95 Streams = None
96 if((FN!="")and(FN!=None)):
97 # self.Streams=oggStreams.oggStreams(FN)
98 print FN
99 Streams = GstFile(FN)
100 if Streams:
101 Streams.run()
102 WND.hide()
103 WND=self.windowStreams.get_widget("STREAM_WINDOW")
104 WND.show()
105 self.addStreams(Streams)
106 # self.refreshStreamsWindow()
107 return
108 #==============================================================================
109 def addStreams(self, Streams):
110 if not Streams:
111 return
112 iter = self.streamsTreeStore.append(None)
113 self.streamsTreeStore.set(iter, 0, Streams.MIME + " " + Streams.SOURCE)
114 for i in Streams.STREAMS.keys():
115 child = self.streamsTreeStore.append(iter)
116 self.streamsTreeStore.set(child, 0, i +" " + Streams.STREAMS[i])
117 print i +" " + Streams.STREAMS[i]
118 return
119 # def refreshStreamsWindow(self):
120 # TStreams=self.Streams.getStreams()
121 # for OGGStream in Streams:
122 #TODO
123 # pass
124 # return
125 #==============================================================================
126 # MAIN:
127 #==============================================================================
128 souffleur=Souffleur()
129 gtk.main()