[SCM] calf/master: More clean-ups in jackvis and conndiagram, primitive Refresh function.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:40:16 UTC 2013
The following commit has been merged in the master branch:
commit acebbd642dfd83b5157ba622221910879d56e700
Author: Krzysztof Foltman <wdev at foltman.com>
Date: Wed May 12 23:04:24 2010 +0100
More clean-ups in jackvis and conndiagram, primitive Refresh function.
diff --git a/bigbull/conndiagram.py b/bigbull/conndiagram.py
index 6c4b605..815c85f 100644
--- a/bigbull/conndiagram.py
+++ b/bigbull/conndiagram.py
@@ -69,9 +69,11 @@ class VisibleWire():
self.update_shape()
def delete(self):
- self.wire.remove()
- self.src.module.remove_wire(self)
- self.dest.module.remove_wire(self)
+ if self.wire is not None:
+ self.wire.remove()
+ self.src.module.remove_wire(self)
+ self.dest.module.remove_wire(self)
+ self.wire = None
def update_shape(self):
(x1, y1) = self.src.get_endpoint()
@@ -110,7 +112,7 @@ class Dragging():
found = None
for type, obj, item in items:
if type == 'port':
- if item.module != self and self.get_graph().get_parser().can_connect(self.port_view.model, obj.model):
+ if item.module != self and self.get_graph().get_controller().can_connect(self.port_view.model, obj.model):
found = obj
self.set_connect_candidate(found)
if found is not None:
@@ -144,7 +146,7 @@ class Dragging():
dst.update_style()
if src.isInput:
src, dst = dst, src
- self.get_graph().get_parser().connect(src.model, dst.model)
+ self.get_graph().get_controller().connect(src.model, dst.model)
self.get_graph().connect(src, dst)
def remove_wire(self):
@@ -163,8 +165,8 @@ class PortView():
def get_graph(self):
return self.module.graph
- def get_parser(self):
- return self.module.get_parser()
+ def get_controller(self):
+ return self.module.get_controller()
def get_id(self):
return self.model.get_id()
@@ -236,8 +238,8 @@ class ModuleView():
spacing = 4
fontName = "DejaVu Sans Bold 9"
- def __init__(self, parser, parent, model, graph):
- self.parser = parser
+ def __init__(self, controller, parent, model, graph):
+ self.controller = controller
self.graph = graph
self.group = None
self.connect_candidate = None
@@ -248,8 +250,8 @@ class ModuleView():
self.wires = []
self.create_items()
- def get_parser(self):
- return self.parser
+ def get_controller(self):
+ return self.controller
def create_items(self):
self.group.module = self
@@ -296,6 +298,8 @@ class ModuleView():
def delete_items(self):
self.group.remove()
+ for w in list(self.wires):
+ w.delete()
def port_button_press(self, port_view, box, event):
if event.button == 1:
@@ -318,16 +322,16 @@ class ModuleView():
self.update_wires()
class ConnectionGraphEditor:
- def __init__(self, app, parser):
+ def __init__(self, app, controller):
self.app = app
- self.parser = parser
+ self.controller = controller
self.moving = None
self.dragging = None
self.modules = set()
pass
- def get_parser(self):
- return self.parser
+ def get_controller(self):
+ return self.controller
def create(self, sx, sy):
self.create_canvas(sx, sy)
@@ -374,7 +378,7 @@ class ConnectionGraphEditor:
self.add_module(*params)
def add_module(self, model, x, y):
- mbox = ModuleView(self.parser, self.canvas.get_root_item(), model, self)
+ mbox = ModuleView(self.controller, self.canvas.get_root_item(), model, self)
self.modules.add(mbox)
bounds = self.canvas.get_bounds()
if x == None:
@@ -423,18 +427,19 @@ class ConnectionGraphEditor:
self.moving.module.translate(event.x - self.motion_x, event.y - self.motion_y)
group.module.update_wires()
- # Connect elements visually (but not logically, that's what controller/parser is for)
- def connect(self, p1, p2, wireitem = None):
- # p1, p2 are PortView objects
- # if wireitem is set, then this is manual connection, and parser.connect() is called
- # if wireitem is None, then this is automatic connection, and parser.connect() is bypassed
- if p2.isInput:
- (src, dest) = (p1, p2)
- else:
- (dest, src) = (p1, p2)
+ # Connect elements visually (but not logically, that's what controller is for)
+ def connect(self, src, dest):
wire = VisibleWire(src, dest)
src.module.wires.append(wire)
dest.module.wires.append(wire)
+ return wire
+
+ def clear(self):
+ for m in self.modules:
+ m.delete_items()
+ self.modules.clear()
+ self.moving = None
+ self.dragging = None
def blow_up(self):
GraphDetonator().blow_up(self)
diff --git a/bigbull/jackvis.py b/bigbull/jackvis.py
index 00a9c9e..f90d008 100755
--- a/bigbull/jackvis.py
+++ b/bigbull/jackvis.py
@@ -76,15 +76,27 @@ class JACKGraphInfo(object):
self.connections_name.add(("%s:%s" % (cname1, pname1), "%s:%s" % (cname2, pname2)))
self.connections_id.add(("%s:%s" % (cid1, pid1), "%s:%s" % (cid2, pid2)))
-class JACKGraphParser(object):
+class ClientModuleModel():
+ def __init__(self, client, checker):
+ (self.client, self.checker) = (client, checker)
+ def get_name(self):
+ return self.client.get_name()
+ def get_port_list(self):
+ return filter(self.checker, self.client.ports)
+
+class JACKGraphController(object):
def __init__(self):
self.bus = dbus.SessionBus()
self.service = self.bus.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
self.patchbay = dbus.Interface(self.service, "org.jackaudio.JackPatchbay")
self.graph = None
+ self.view = None
self.fetch_graph()
def fetch_graph(self):
- self.graph = JACKGraphInfo(*self.patchbay.GetGraph(self.graph.known_version if self.graph is not None else 0))
+ req_version = self.graph.version if self.graph is not None else 0
+ graphdata = self.patchbay.GetGraph(req_version)
+ if int(graphdata[0]) != req_version:
+ self.graph = JACKGraphInfo(*graphdata)
def can_connect(self, first, second):
if first.is_port_input() == second.is_port_input():
return False
@@ -97,19 +109,39 @@ class JACKGraphParser(object):
self.patchbay.ConnectPortsByName(first.client_name, first.name, second.client_name, second.name)
def disconnect(self, first, second):
self.patchbay.DisconnectPortsByName(first.client_name, first.name, second.client_name, second.name)
+ def refresh(self):
+ self.fetch_graph()
+ self.view.clear()
+ self.add_all()
+ def add_all(self):
+ width, left_mods = self.add_clients(10.0, 10.0, lambda port: port.is_port_output())
+ width2, right_mods = self.add_clients(width + 20, 10.0, lambda port: port.is_port_input())
+ pmap = self.view.get_port_map()
+ for (c, p) in self.graph.connections_name:
+ if p in pmap and c in pmap:
+ print "Connect %s to %s" % (c, p)
+ self.view.connect(pmap[c], pmap[p])
+ else:
+ print "Connect %s to %s - not found" % (c, p)
+ for m in right_mods:
+ m.translate(950 - width - 20 - width2, 0)
+ def add_clients(self, x, y, checker):
+ margin = 10
+ mwidth = 0
+ mods = []
+ for cl in self.graph.clients:
+ mod = self.view.add_module(ClientModuleModel(cl, checker), x, y)
+ y += mod.rect.props.height + margin
+ if mod.rect.props.width > mwidth:
+ mwidth = mod.rect.props.width
+ mods.append(mod)
+ return mwidth, mods
-class ClientModuleModel():
- def __init__(self, client, checker):
- (self.client, self.checker) = (client, checker)
- def get_name(self):
- return self.client.get_name()
- def get_port_list(self):
- return filter(self.checker, self.client.ports)
-
class App:
def __init__(self):
- self.parser = JACKGraphParser()
- self.cgraph = conndiagram.ConnectionGraphEditor(self, self.parser)
+ self.controller = JACKGraphController()
+ self.cgraph = conndiagram.ConnectionGraphEditor(self, self.controller)
+ self.controller.view = self.cgraph
def canvas_popup_menu_handler(self, widget):
self.canvas_popup_menu(0, 0, 0)
@@ -152,42 +184,23 @@ class App:
self.window.show_all()
self.main_vbox.connect("popup-menu", self.canvas_popup_menu_handler)
self.cgraph.canvas.connect("button-press-event", self.canvas_button_press_handler)
- self.add_all()
+ self.controller.add_all()
+ self.cgraph.clear()
+ self.controller.add_all()
self.cgraph.canvas.update()
#this is broken
#self.cgraph.blow_up()
-
- def add_all(self):
- width, left_mods = self.add_clients(10.0, 10.0, lambda port: port.is_port_output())
- width2, right_mods = self.add_clients(width + 20, 10.0, lambda port: port.is_port_input())
- pmap = self.cgraph.get_port_map()
- for (c, p) in self.parser.graph.connections_name:
- if p in pmap and c in pmap:
- print "Connect %s to %s" % (c, p)
- self.cgraph.connect(pmap[c], pmap[p])
- else:
- print "Connect %s to %s - not found" % (c, p)
- for m in right_mods:
- m.translate(950 - width - 20 - width2, 0)
-
- def add_clients(self, x, y, checker):
- margin = 10
- mwidth = 0
- mods = []
- for cl in self.parser.graph.clients:
- mod = self.cgraph.add_module(ClientModuleModel(cl, checker), x, y)
- y += mod.rect.props.height + margin
- if mod.rect.props.width > mwidth:
- mwidth = mod.rect.props.width
- mods.append(mod)
- return mwidth, mods
-
+
def create_main_menu(self):
self.menu_bar = gtk.MenuBar()
self.file_menu = add_submenu(self.menu_bar, "_File")
+ add_option(self.file_menu, "_Refresh", self.refresh)
add_option(self.file_menu, "_Blow-up", self.blow_up)
add_option(self.file_menu, "_Exit", self.exit)
+ def refresh(self, data):
+ self.controller.refresh()
+
def blow_up(self, data):
self.cgraph.blow_up()
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list