[SCM] calf/master: + Big Bull: internal rearrangements, added pygoocanvas frontend stub, added appropriate svn properties (svn:ignore and svn:executable)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:19 UTC 2013


The following commit has been merged in the master branch:
commit 481468f53b806497f372e650b377fcfee335af51
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Fri Jun 20 21:57:54 2008 +0000

    + Big Bull: internal rearrangements, added pygoocanvas frontend stub, added appropriate svn properties (svn:ignore and svn:executable)
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@207 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/bigbull/client.py b/bigbull/client.py
index e646af3..5c6410c 100644
--- a/bigbull/client.py
+++ b/bigbull/client.py
@@ -42,40 +42,3 @@ class CommandExec:
             else:
                 h.receiveError(self)
 
-class LV2Port(object):
-    def __init__(self, data):
-        for prop in ["symbol", "name", "classes", "isAudio", "isControl", "isEvent", "isInput", "isOutput", "default", "maximum", "minimum", "scalePoints", "index"]:
-            if prop in data:
-                self.__dict__[prop] = data[prop]
-            else:
-                self.__dict__[prop] = None
-
-class LV2Plugin(object):
-    def __init__(self, data):
-        self.uri = data["uri"]
-        self.name = data["name"]
-        self.license = data["license"]
-        self.classes = set(data["classes"])
-        self.requiredFeatures = set(data["requiredFeatures"])
-        self.optionalFeatures = set(data["optionalFeatures"])
-        self.ports = []
-        for port in data["ports"]:
-            self.ports.append(LV2Port(port))
-        
-    def decode(self, data):
-        self.name = data['doap:name']
-
-class BBClient(object):
-    def __init__(self):
-        self.plugins = []
-        cmd = CommandExec('get_uris', 'http://lv2plug.in/ns/lv2core#')
-        cmd.onOK(self.uris_received)
-        cmd.run()
-    def uris_received(self, data):
-        self.uris = data.result
-        for uri in self.uris:
-            cmd = CommandExec('get_plugin_info', uri)
-            cmd.onOK(self.uri_info_received)
-            cmd.run()
-    def uri_info_received(self, data):
-        self.plugins.append(LV2Plugin(data.result))
diff --git a/bigbull/fakeserv.py b/bigbull/fakeserv.py
index fefe6da..f6e9d7f 100644
--- a/bigbull/fakeserv.py
+++ b/bigbull/fakeserv.py
@@ -178,95 +178,7 @@ def parseTTL(uri, content, model):
 
 class FakeServer(object):
     def __init__(self):
-        self.initManifests()
-        #parseTTL("http://lv2plug.in/ns/lv2core#", file("/usr/lib/lv2/lv2core.lv2/lv2.ttl").read(), m)
-        
-    def initManifests(self):
-        lv2path = ["/usr/lib/lv2", "/usr/local/lib/lv2"]
-        self.manifests = SimpleRDFModel()
-        self.paths = {}
-        self.plugin_info = dict()
-        # Scan manifests
-        for dir in lv2path:
-            for bundle in glob.iglob(dir + "/*.lv2"):
-                fn = bundle+"/manifest.ttl"
-                if os.path.exists(fn):
-                    parseTTL(fn, file(fn).read(), self.manifests)
-        # Read all specifications from all manifests
-        if (lv2 + "Specification" in self.manifests.bySubject["$classes"]):
-            specs = self.manifests.getByType(lv2 + "Specification")
-            filenames = set()
-            for spec in specs:
-                subj = self.manifests.bySubject[spec]
-                if rdfs+"seeAlso" in subj:
-                    for fn in subj[rdfs+"seeAlso"]:
-                        filenames.add(fn)
-            for fn in filenames:
-                parseTTL(fn, file(fn).read(), self.manifests)
-        #fn = "/usr/lib/lv2/lv2core.lv2/lv2.ttl"
-        #parseTTL(fn, file(fn).read(), self.manifests)
-        self.plugins = self.manifests.getByType(lv2 + "Plugin")
-        
-    def get_uris(self, base_uri):
-        if base_uri == 'http://lv2plug.in/ns/lv2core#':
-            return self.plugins
-        raise StringException("Invalid base URI")
-        
-    def get_plugin_info(self, uri):
-        if uri not in self.plugin_info:
-            world = SimpleRDFModel()
-            world.copyFrom(self.manifests)
-            seeAlso = self.manifests.bySubject[uri]["http://www.w3.org/2000/01/rdf-schema#seeAlso"]
-            for doc in seeAlso:
-                # print "Loading " + doc
-                parseTTL(doc, file(doc).read(), world)
-            self.plugin_info[uri] = world                
-        info = self.plugin_info[uri]
-        dest = {}
-        dest['uri'] = uri
-        dest['name'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#name'][0]
-        dest['license'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#license'][0]
-        dest['classes'] = info.bySubject[uri]["a"]
-        dest['requiredFeatures'] = info.getProperty(uri, lv2 + "requiredFeature", optional = True)
-        dest['optionalFeatures'] = info.getProperty(uri, lv2 + "optionalFeature", optional = True)
-        ports = []
-        porttypes = {
-            "isAudio" : lv2 + "AudioPort",
-            "isControl" : lv2 + "ControlPort",
-            "isEvent" : lv2evt + "EventPort",
-            "isInput" : lv2 + "InputPort",
-            "isOutput" : lv2 + "OutputPort",
-        }
-        
-        for port in info.bySubject[uri][lv2 + "port"]:
-            psubj = info.bySubject[port]
-            pdata = {}
-            pdata['index'] = int(info.getProperty(psubj, lv2 + "index")[0])
-            pdata['symbol'] = info.getProperty(psubj, lv2 + "symbol")[0]
-            pdata['name'] = info.getProperty(psubj, lv2 + "name")[0]
-            classes = set(info.getProperty(psubj, "a"))
-            pdata['classes'] = classes
-            for pt in porttypes.keys():
-                pdata[pt] = porttypes[pt] in classes
-            sp = info.getProperty(psubj, lv2 + "scalePoint")
-            if sp and len(sp):
-                splist = []
-                for pt in sp:
-                    name = info.getProperty(pt, rdfs + "label", optional = True, single = True)
-                    if name != None:
-                        value = info.getProperty(pt, rdf + "value", optional = True, single = True)
-                        if value != None:
-                            splist.append((name, value))
-                pdata['scalePoints'] = splist
-            else:
-                pdata['scalePoints'] = []
-            pdata['default'] = info.getProperty(psubj, [lv2 + "default"], optional = True, single = True)
-            pdata['minimum'] = info.getProperty(psubj, [lv2 + "minimum"], optional = True, single = True)
-            pdata['maximum'] = info.getProperty(psubj, [lv2 + "maximum"], optional = True, single = True)
-            ports.append(pdata)
-        ports.sort(lambda x, y: cmp(x['index'], y['index']))
-        dest['ports'] = ports
-        return dest
+        pass
 
 def start():
     global instance
diff --git a/bigbull/inspect.py b/bigbull/inspect.py
old mode 100644
new mode 100755
index baf71a4..dc2822f
--- a/bigbull/inspect.py
+++ b/bigbull/inspect.py
@@ -1,28 +1,16 @@
 import os
 import sys
 import fakeserv
+import lv2
 import client
 
 fakeserv.start()
 
-plugins = {}
+db = lv2.LV2DB()
+plugins = db.getPluginList()
 
-class URIListReceiver:
-    def receiveData(self, data):
-        #print "URI list received: " + repr(data.result)
-        for uri in data.result:
-            cmd = client.CommandExec('get_plugin_info', uri)
-            cmd.run()
-            res = cmd.result
-            plugins[res["name"]] = res
-
-cmd = client.CommandExec('get_uris', 'http://lv2plug.in/ns/lv2core#')
-cmd.onOK(URIListReceiver())
-cmd.run()
-
-for p in plugins.keys():
-    pl = plugins[p]
-    plugin = client.LV2Plugin(pl)
+for uri in plugins:
+    plugin = db.getPluginInfo(uri)
     print "Plugin: %s" % plugin.name
     print "License: %s" % plugin.license
     print "Classes: %s" % plugin.classes
@@ -35,7 +23,7 @@ for p in plugins.keys():
         for type in types:
             if port.__dict__["is" + type]:
                 extra.append(type)
-        for sp in ["default", "minimum", "maximum"]:
+        for sp in ["defaultValue", "minimum", "maximum"]:
             if port.__dict__[sp] != None:
                 extra.append("%s=%s" % (sp, port.__dict__[sp]))
         print "%4s %-20s %-40s %s" % (port.index, port.symbol, port.name, ", ".join(extra))
diff --git a/bigbull/fakeserv.py b/bigbull/lv2.py
similarity index 80%
copy from bigbull/fakeserv.py
copy to bigbull/lv2.py
index fefe6da..3a35b37 100644
--- a/bigbull/fakeserv.py
+++ b/bigbull/lv2.py
@@ -95,9 +95,10 @@ class SimpleRDFModel:
             for p in self.bySubject[s].keys():
                 print "%s %s %s" % (s, p, self.bySubject[s][p])
 
-def parseTTL(uri, content, model):
+def parseTTL(uri, content, model, debug):
     # Missing stuff: translated literals, blank nodes
-    print "Parsing: %s" % uri
+    if debug:
+        print "Parsing: %s" % uri
     prefixes = {}
     lexer = yappy.parser.Lexer([
         (r"(?m)^\s*#[^\n]*", ""),
@@ -176,10 +177,18 @@ def parseTTL(uri, content, model):
         else:
             print uri + ": Unexpected: " + repr(x)
 
-class FakeServer(object):
+class LV2Port(object):
     def __init__(self):
+        pass
+
+class LV2Plugin(object):
+    def __init__(self):
+        pass
+        
+class LV2DB:
+    def __init__(self, debug = False):
+        self.debug = debug
         self.initManifests()
-        #parseTTL("http://lv2plug.in/ns/lv2core#", file("/usr/lib/lv2/lv2core.lv2/lv2.ttl").read(), m)
         
     def initManifests(self):
         lv2path = ["/usr/lib/lv2", "/usr/local/lib/lv2"]
@@ -191,7 +200,7 @@ class FakeServer(object):
             for bundle in glob.iglob(dir + "/*.lv2"):
                 fn = bundle+"/manifest.ttl"
                 if os.path.exists(fn):
-                    parseTTL(fn, file(fn).read(), self.manifests)
+                    parseTTL(fn, file(fn).read(), self.manifests, self.debug)
         # Read all specifications from all manifests
         if (lv2 + "Specification" in self.manifests.bySubject["$classes"]):
             specs = self.manifests.getByType(lv2 + "Specification")
@@ -202,33 +211,31 @@ class FakeServer(object):
                     for fn in subj[rdfs+"seeAlso"]:
                         filenames.add(fn)
             for fn in filenames:
-                parseTTL(fn, file(fn).read(), self.manifests)
+                parseTTL(fn, file(fn).read(), self.manifests, self.debug)
         #fn = "/usr/lib/lv2/lv2core.lv2/lv2.ttl"
         #parseTTL(fn, file(fn).read(), self.manifests)
         self.plugins = self.manifests.getByType(lv2 + "Plugin")
         
-    def get_uris(self, base_uri):
-        if base_uri == 'http://lv2plug.in/ns/lv2core#':
-            return self.plugins
-        raise StringException("Invalid base URI")
+    def getPluginList(self):
+        return self.plugins
         
-    def get_plugin_info(self, uri):
+    def getPluginInfo(self, uri):
         if uri not in self.plugin_info:
             world = SimpleRDFModel()
             world.copyFrom(self.manifests)
             seeAlso = self.manifests.bySubject[uri]["http://www.w3.org/2000/01/rdf-schema#seeAlso"]
             for doc in seeAlso:
                 # print "Loading " + doc
-                parseTTL(doc, file(doc).read(), world)
+                parseTTL(doc, file(doc).read(), world, self.debug)
             self.plugin_info[uri] = world                
         info = self.plugin_info[uri]
-        dest = {}
-        dest['uri'] = uri
-        dest['name'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#name'][0]
-        dest['license'] = info.bySubject[uri]['http://usefulinc.com/ns/doap#license'][0]
-        dest['classes'] = info.bySubject[uri]["a"]
-        dest['requiredFeatures'] = info.getProperty(uri, lv2 + "requiredFeature", optional = True)
-        dest['optionalFeatures'] = info.getProperty(uri, lv2 + "optionalFeature", optional = True)
+        dest = LV2Plugin()
+        dest.uri = uri
+        dest.name = info.bySubject[uri]['http://usefulinc.com/ns/doap#name'][0]
+        dest.license = info.bySubject[uri]['http://usefulinc.com/ns/doap#license'][0]
+        dest.classes = info.bySubject[uri]["a"]
+        dest.requiredFeatures = info.getProperty(uri, lv2 + "requiredFeature", optional = True)
+        dest.optionalFeatures = info.getProperty(uri, lv2 + "optionalFeature", optional = True)
         ports = []
         porttypes = {
             "isAudio" : lv2 + "AudioPort",
@@ -240,14 +247,15 @@ class FakeServer(object):
         
         for port in info.bySubject[uri][lv2 + "port"]:
             psubj = info.bySubject[port]
-            pdata = {}
-            pdata['index'] = int(info.getProperty(psubj, lv2 + "index")[0])
-            pdata['symbol'] = info.getProperty(psubj, lv2 + "symbol")[0]
-            pdata['name'] = info.getProperty(psubj, lv2 + "name")[0]
+            pdata = LV2Port()
+            pdata.uri = port
+            pdata.index = int(info.getProperty(psubj, lv2 + "index")[0])
+            pdata.symbol = info.getProperty(psubj, lv2 + "symbol")[0]
+            pdata.name = info.getProperty(psubj, lv2 + "name")[0]
             classes = set(info.getProperty(psubj, "a"))
-            pdata['classes'] = classes
+            pdata.classes = classes
             for pt in porttypes.keys():
-                pdata[pt] = porttypes[pt] in classes
+                pdata.__dict__[pt] = porttypes[pt] in classes
             sp = info.getProperty(psubj, lv2 + "scalePoint")
             if sp and len(sp):
                 splist = []
@@ -257,25 +265,14 @@ class FakeServer(object):
                         value = info.getProperty(pt, rdf + "value", optional = True, single = True)
                         if value != None:
                             splist.append((name, value))
-                pdata['scalePoints'] = splist
+                pdata.scalePoints = splist
             else:
-                pdata['scalePoints'] = []
-            pdata['default'] = info.getProperty(psubj, [lv2 + "default"], optional = True, single = True)
-            pdata['minimum'] = info.getProperty(psubj, [lv2 + "minimum"], optional = True, single = True)
-            pdata['maximum'] = info.getProperty(psubj, [lv2 + "maximum"], optional = True, single = True)
+                pdata.scalePoints = []
+            pdata.defaultValue = info.getProperty(psubj, [lv2 + "default"], optional = True, single = True)
+            pdata.minimum = info.getProperty(psubj, [lv2 + "minimum"], optional = True, single = True)
+            pdata.maximum = info.getProperty(psubj, [lv2 + "maximum"], optional = True, single = True)
             ports.append(pdata)
-        ports.sort(lambda x, y: cmp(x['index'], y['index']))
-        dest['ports'] = ports
+        ports.sort(lambda x, y: cmp(x.index, y.index))
+        dest.ports = ports
         return dest
 
-def start():
-    global instance
-    instance = FakeServer()
-
-def queue(cmdObject):
-    global instance
-    #try:
-    cmdObject.calledOnOK(type(instance).__dict__[cmdObject.type](instance, *cmdObject.args))
-    #except:
-    #    cmdObject.calledOnError(repr(sys.exc_info()))
-    
diff --git a/bigbull/mainwin.py b/bigbull/mainwin.py
new file mode 100755
index 0000000..6a5d2e1
--- /dev/null
+++ b/bigbull/mainwin.py
@@ -0,0 +1,185 @@
+import pygtk
+pygtk.require('2.0')
+import gtk
+import lv2
+import fakeserv
+import client
+import cairo
+import goocanvas
+import random
+
+class ModuleBox():
+    def __init__(self, parent, plugin):
+        self.width = 200
+        self.group = None
+        self.parent = parent
+        self.plugin = plugin
+        self.group = goocanvas.Group(parent = self.parent)
+        self.create_items()
+        
+    def create_items(self):
+        fontName = "DejaVu Sans Mono Book 10"
+        self.group.module = self
+        while self.group.get_n_children() > 0:
+            self.group.remove_child(0)
+        ctx = self.group.get_canvas().create_cairo_context()
+        width = 100
+        margin = 2
+        spacing = 6
+        portBoxes = {}
+        portTitles = {}
+        frameColor = 0xC0C0C0FF
+        textColor = 0xFFFFFFFF
+        self.title = goocanvas.Text(parent = self.group, font = fontName, text = "<b>" + self.plugin.name + "</b>", width = 100, x = 0, y = 0, alignment = "center", use_markup = True, fill_color_rgba = textColor)
+        y = self.title.get_requested_height(ctx, width) + spacing
+        for port in self.plugin.ports:
+            al = "center"
+            if port.isInput: 
+                al = "left"
+            elif port.isOutput:
+                al = "right"
+            title = goocanvas.Text(parent = self.group, text = port.name, font = fontName, width = width - 2 * margin, x = margin, y = y, alignment = al, fill_color_rgba = textColor)
+            height = 1 + int(title.get_requested_height(ctx, width - 2 * margin))
+            title.ensure_updated()
+            bnds = title.get_bounds()
+            bw = bnds.x2 - bnds.x1 + 2 * margin
+            color = 0x404040FF
+            if port.isAudio:
+                color = 0x000080FF
+            if port.isControl:
+                color = 0x008000FF
+            if port.isEvent:
+                color = 0x800000FF
+            if port.isInput:
+                box = goocanvas.Rect(parent = self.group, x = 0, y = y - 1, width = bw, height = height + 2, line_width = 1, fill_color_rgba = color, stroke_color_rgba = frameColor)
+            elif port.isOutput:
+                box = goocanvas.Rect(parent = self.group, x = bnds.x2 - margin, y = y - 1, width = width - bnds.x2 + margin, height = height + 2, line_width = 1, fill_color_rgba = color, stroke_color_rgba = frameColor)
+            box.lower(title)
+            y += height + spacing
+            portBoxes[port.uri] = box
+            portTitles[port.uri] = title
+            box.uri = port.uri
+            box.connect_object("button-press-event", self.port_button_press, port.uri)
+            title.connect_object("button-press-event", self.port_button_press, port.uri)
+        self.rect = goocanvas.Rect(parent = self.group, width = 100, height = y, line_width = 1, stroke_color_rgba = frameColor, fill_color_rgba = 0x202020FF)
+        self.rect.lower(self.title)
+        self.portBoxes = portBoxes
+        self.portTitles = portTitles
+        self.group.ensure_updated()
+        
+    def delete_items(self):
+        self.group.remove()
+        
+    def port_button_press(self, port_uri, box, event):
+        if event.button == 1:
+            print "Port URI is " + port_uri
+            return True
+
+class App:
+    def __init__(self):
+        fakeserv.start()
+        self.lv2db = lv2.LV2DB()
+        
+    def create(self):
+        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+        self.window.connect("delete_event", self.delete_event)
+        self.window.connect("destroy", self.destroy)
+        self.main_vbox = gtk.VBox()
+        self.create_main_menu()
+        self.scroll = gtk.ScrolledWindow()
+        self.create_canvas()
+        self.scroll.add(self.canvas)
+        self.main_vbox.pack_start(self.menu_bar, expand = False, fill = False)
+        self.main_vbox.add(self.scroll)
+        self.window.add(self.main_vbox)
+        self.window.show_all()
+        self.moving = None
+        
+    def create_main_menu(self):
+        self.menu_bar = gtk.MenuBar()
+        
+        self.file_menu = self.add_submenu(self.menu_bar, "_File")
+        self.add_option(self.file_menu, "_Exit", self.exit)
+        self.plugin_menu = self.add_submenu(self.menu_bar, "_Plugins")
+        for uri in self.lv2db.getPluginList():
+            plugin = self.lv2db.getPluginInfo(uri)
+            self.add_option(self.plugin_menu, plugin.name, self.add_plugin, (plugin, None, None))
+        
+    def create_canvas(self):
+        self.canvas = goocanvas.Canvas()
+        self.canvas.props.automatic_bounds = True
+        self.canvas.set_size_request(640, 480)
+        self.canvas.set_scale(1)
+        #self.canvas.connect("size-allocate", self.update_canvas_bounds)
+        self.canvas.props.background_color_rgb = 0
+        #self.canvas.props.integer_layout = True
+        self.canvas.update()
+        self.canvas.get_root_item().connect("button-press-event", self.canvas_button_press)
+        
+    def add_submenu(self, menu, option):
+        submenu = gtk.Menu()
+        item = gtk.MenuItem(option)
+        menu.append(item)
+        item.set_submenu(submenu)
+        return submenu
+    
+    def add_option(self, menu, option, handler, data = None):
+        item = gtk.MenuItem(option)
+        item.connect_object("activate", handler, data)
+        menu.add(item)
+        
+    def add_plugin(self, params):
+        (plugin, x, y) = params
+        mbox = ModuleBox(self.canvas.get_root_item(), plugin)
+        bounds = self.canvas.get_bounds()
+        if x == None:
+            (x, y) = (random.randint(bounds[0], bounds[2] - 100), random.randint(bounds[1], bounds[3] - 50))
+        mbox.group.translate(x, y)
+        mbox.group.connect("button-press-event", self.box_button_press)
+        mbox.group.connect("button-release-event", self.box_button_release)
+        mbox.group.connect("motion-notify-event", self.box_motion_notify)
+        
+    def canvas_button_press(self, widget, item, event):
+        if event.button == 3:
+            menu = gtk.Menu()
+            for uri in self.lv2db.getPluginList():
+                plugin = self.lv2db.getPluginInfo(uri)
+                self.add_option(menu, plugin.name, self.add_plugin, (plugin, event.x, event.y))
+            menu.show_all()
+            menu.popup(None, None, None, event.button, event.time)
+        
+    def box_button_press(self, group, widget, event):
+        if event.button == 1:
+            self.moving = group
+            self.motion_x = event.x
+            self.motion_y = event.y
+            return True
+        elif event.button == 3:
+            menu = gtk.Menu()
+            self.add_option(menu, "Delete", self.delete_block, group.module)
+            menu.show_all()
+            menu.popup(None, None, None, event.button, event.time)
+            return True
+    
+    def box_button_release(self, group, widget, event):
+        if event.button == 1:
+            self.moving = None
+    
+    def box_motion_notify(self, group, widget, event):
+        if self.moving == group:
+            self.moving.translate(event.x - self.motion_x, event.y - self.motion_y)
+    
+    def exit(self, data):
+        self.window.destroy()
+        
+    def delete_block(self, data):
+        data.delete_items()
+
+    def delete_event(self, widget, data = None):
+        gtk.main_quit()
+    def destroy(self, widget, data = None):
+        gtk.main_quit()
+        
+app = App()
+app.create()
+gtk.main()

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list