mirror of
https://github.com/dyne/FreeJ.git
synced 2026-06-16 12:59:33 +02:00
initial code for the gtk gui.
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
<?xml version="1.0"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.16 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<widget class="GtkWindow" id="main">
|
||||
<property name="visible">True</property>
|
||||
<signal name="destroy" handler="gtk_main_quit"/>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenuBar" id="menubar1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_File</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem1">
|
||||
<property name="label">gtk-new</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem2">
|
||||
<property name="label">gtk-open</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem3">
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem4">
|
||||
<property name="label">gtk-save-as</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem5">
|
||||
<property name="label">gtk-quit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Edit</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu2">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem6">
|
||||
<property name="label">gtk-cut</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem7">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem8">
|
||||
<property name="label">gtk-paste</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem9">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_View</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenu" id="menu3">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="imagemenuitem10">
|
||||
<property name="label">gtk-about</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHPaned" id="hpaned1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="treeview1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<widget class="GtkTextView" id="status">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="entry1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="padding">2</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHButtonBox" id="hbuttonbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">3</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout_style">spread</property>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">Open File</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="open_file"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">Open Script</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="padding">3</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
@@ -0,0 +1,110 @@
|
||||
import freej
|
||||
import gtk
|
||||
import threading
|
||||
import gtk.glade
|
||||
gtk.gdk.threads_init ()
|
||||
|
||||
class MyConsole(freej.ConsoleController):
|
||||
def __init__(self, textview):
|
||||
self.textview = textview
|
||||
freej.ConsoleController.__init__(self)
|
||||
print "init"
|
||||
def poll(self):
|
||||
return 0
|
||||
def dispatch(self):
|
||||
return 0
|
||||
def notice(self, msg):
|
||||
iter = self.textview.get_buffer().get_end_iter()
|
||||
self.textview.get_buffer().insert(iter, msg+'\n')
|
||||
def error(self, msg):
|
||||
iter = self.textview.get_buffer().get_end_iter()
|
||||
self.textview.get_buffer().insert(iter, msg+'\n')
|
||||
def warning(self, msg):
|
||||
iter = self.textview.get_buffer().get_end_iter()
|
||||
self.textview.get_buffer().insert(iter, msg+'\n')
|
||||
def act(self, msg):
|
||||
print " X*",msg
|
||||
def func(self, msg):
|
||||
print " X*",msg
|
||||
def refresh(self, msg):
|
||||
print " X*",msg
|
||||
|
||||
|
||||
# -----------------------------------------------------
|
||||
|
||||
class MyCall(freej.DumbCall):
|
||||
def __init__(self, func, *args):
|
||||
super(MyCall, self).__init__()
|
||||
self.func = func
|
||||
self.args = args
|
||||
|
||||
def callback(self):
|
||||
self.func(*self.args)
|
||||
|
||||
class FreeJ(object):
|
||||
def __init__(self):
|
||||
self.cx = freej.Context()
|
||||
|
||||
self.scr = freej.SdlScreen( 400, 300)
|
||||
|
||||
self.cx.add_screen( self.scr )
|
||||
self.open_layer('/home/caedes/ca-midi.xavi')
|
||||
self.th = threading.Thread(target = self.cx.start , name = "freej")
|
||||
|
||||
#cb = MyCall(self.finished)
|
||||
#v.add_eos_call(cb)
|
||||
|
||||
def open_layer(self, filename):
|
||||
#v = freej.VideoLayer()
|
||||
print " * opening:",filename
|
||||
v = self.cx.open(filename)
|
||||
if not v:
|
||||
print " * cant open",filename
|
||||
return
|
||||
v.init(self.cx)
|
||||
v.open(filename)
|
||||
v.start()
|
||||
self.cx.add_layer( v )
|
||||
v.thisown = False
|
||||
|
||||
def finished(self):
|
||||
print "video looping!"
|
||||
|
||||
|
||||
class App(FreeJ):
|
||||
def __init__(self):
|
||||
self.fname = 'freej_mixer.glade'
|
||||
self.wTree = gtk.glade.XML(self.fname)
|
||||
self.window = self.wTree.get_widget("main")
|
||||
self.window.connect('destroy', gtk.main_quit)
|
||||
textview = self.wTree.get_widget("status")
|
||||
self.console = MyConsole(textview)
|
||||
freej.set_console(self.console)
|
||||
FreeJ.__init__(self)
|
||||
self.th.start();
|
||||
self.wTree.signal_autoconnect({"open_file":self.open_file})
|
||||
|
||||
def open_file(self, *args):
|
||||
self.filew = gtk.FileChooserDialog("File selection",
|
||||
None,
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||
self.filew.set_default_response(gtk.RESPONSE_OK)
|
||||
response = self.filew.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
filename = self.filew.get_filename()
|
||||
self.open_layer(filename)
|
||||
self.filew.hide()
|
||||
|
||||
# -----------------------------------------------------
|
||||
|
||||
|
||||
# -----------------------------------------------------
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = App()
|
||||
gtk.main()
|
||||
print "exiting"
|
||||
app.cx.quit = False
|
||||
|
||||
Reference in New Issue
Block a user