diff --git a/bin/curvecalc b/bin/curvecalc
--- a/bin/curvecalc
+++ b/bin/curvecalc
@@ -18,19 +18,18 @@ from twisted.internet import reactor
import time, textwrap, os, optparse, gtk, linecache, signal, traceback, json
from urlparse import parse_qsl
import louie as dispatcher
-from rdflib import URIRef, Graph, Literal, RDF, RDFS
+from rdflib import URIRef, Literal, RDF, RDFS
import logging
-log = logging.getLogger()
-import run_local
+from run_local import log
from light9 import showconfig, prof, networking
from light9.rdfdb import clientsession
from light9.curvecalc.curve import Curveset
from light9.curvecalc import curveview
-from light9.curvecalc.musicaccess import Music, currentlyPlayingSong
+from light9.curvecalc.musicaccess import Music
from light9.wavelength import wavelength
from light9.namespaces import L9
-from light9.curvecalc.subterm import savekey, graphPathForSubterms, Subterm
+from light9.curvecalc.subterm import Subterm
from light9.curvecalc.subtermview import add_one_subterm
from light9.curvecalc.output import Output
from light9.gtkpyconsole import togglePyConsole
@@ -77,6 +76,7 @@ class Main(object):
def setSong():
songChoice(graph.value(session, L9['currentSong']))
graph.addHandler(setSong)
+ # next here, watch songChoice and patch the graph
ec = EditChoice(graph, songChoice, label="Editing song:")
wtree.get_object("currentSongEditChoice").add(ec)
@@ -94,13 +94,17 @@ class Main(object):
targets=[('text/uri-list', 0, 0)],
actions=gtk.gdk.ACTION_COPY)
w.connect("drag-data-received", self.onDataReceived)
- connect(mainwin)
+ #connect(mainwin)
# that's not enough- deeper windows don't accept the
# event.
- mainwin.forall(connect) # not very effective
+ #mainwin.forall(connect) # not very effective
+ wtree.get_object("newSubZone").drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
+ targets=[('text/uri-list', 0, 0)],
+ actions=gtk.gdk.ACTION_COPY)
+
# this probably isn't rerunning often enough to catch new data
- connect(wtree.get_object("subterms")) # works for that area
+ #connect(wtree.get_object("subterms")) # works for that area
# may not work
wtree.get_object("paned1").set_position(600)
@@ -114,11 +118,6 @@ class Main(object):
uri = URIRef(data)
subName = self.graph.label(uri)
- if not list(self.graph.subjects(L9['sub'], uri)):
- # might be a new one just created in KC
- print "didn't find %r, reloading subs" % uri
- self.onReloadSubs()
-
try:
self.makeSubterm(subName, withCurve=True)
except SubtermExists:
@@ -129,6 +128,11 @@ class Main(object):
curveView.add_points([(t - .5, 0),
(t, 1)])
+ def onDragDataInNewSubZone(self, widget, context, x, y, selection,
+ targetType, time):
+ self.makeSubterm(newname="cx", withCurve=True,
+ sub=URIRef(selection.data.strip()))
+
def handleSubtermDrop(self, data):
params = parse_qsl(data.split('?')[1])
flattened = dict(params)
@@ -175,19 +179,25 @@ class Main(object):
def songSubtermsContext(self):
return self.currentSong()
- def makeSubterm(self, newname, withCurve=False, expr=None):
+ def makeSubterm(self, newname, withCurve=False, expr=None, sub=None):
uri = self.currentSong() + "/sub/%f" % time.time()
ctx = self.songSubtermsContext()
- self.graph.patch(Patch(addQuads=[
+ quads = [
(uri, RDF.type, L9.Subterm, ctx),
(uri, RDFS.label, Literal(newname), ctx),
(self.currentSong(), L9['subterm'], uri, ctx),
- ]))
+ ]
+ if sub is not None:
+ quads.append((uri, L9['sub'], sub, ctx))
+ if expr is not None:
+ quads.append((uri, L9['expression'], Literal(expr), ctx))
+ self.graph.patch(Patch(addQuads=quads))
if withCurve:
self.curveset.new_curve(newname)
-
+ return uri
+
def set_subterms_from_graph(self):
master = self.wtree.get_object("subterms")
log.info("removing subterm widgets")
@@ -252,8 +262,13 @@ class Main(object):
def onSave(self, *args):
with self.graph.currentState() as g:
- savekey(g.value(self.session, L9['currentSong']),
- self.curveset)
+ song = g.value(self.session, L9['currentSong'])
+
+ log.info("saving curves for %r", song)
+ self.curveset.save(basename=os.path.join(
+ showconfig.curvesDir(),
+ showconfig.songFilenameFromURI(song)))
+ log.info("saved")
def makeStatusLines(self, master):
"""various labels that listen for dispatcher signals"""
diff --git a/light9/curvecalc/curve.py b/light9/curvecalc/curve.py
--- a/light9/curvecalc/curve.py
+++ b/light9/curvecalc/curve.py
@@ -151,6 +151,7 @@ class Curveset(object):
This fires 'add_curve' dispatcher events to announce the new curves.
"""
+ log.info("Curveset.load %s", basename)
for filename in sorted(glob.glob("%s-*"%basename), key=self.sorter):
curvename = filename[filename.rfind('-')+1:]
if skipMusic and curvename in ['music', 'smooth_music']:
diff --git a/light9/curvecalc/curvecalc.glade b/light9/curvecalc/curvecalc.glade
--- a/light9/curvecalc/curvecalc.glade
+++ b/light9/curvecalc/curvecalc.glade
@@ -511,9 +511,9 @@
True
False
2
+
-
@@ -526,9 +526,22 @@
+ False
+ True
+ 0
+
+
+
+
+
True
True
- 0
+ 1
@@ -536,21 +549,7 @@
True
False
-
-
- False
- True
- 0
-
+
diff --git a/light9/curvecalc/subterm.py b/light9/curvecalc/subterm.py
--- a/light9/curvecalc/subterm.py
+++ b/light9/curvecalc/subterm.py
@@ -133,28 +133,3 @@ class Subterm(object):
def __repr__(self):
return "" % self.uri
-
-def graphPathForSubterms(song):
- return showconfig.subtermsForSong(showconfig.songFilenameFromURI(song)) + ".n3"
-
-def createSubtermGraph(song, subterms):
- """rdf graph describing the subterms, readable by add_subterms_for_song"""
- graph = Graph()
- for subterm in subterms:
- assert subterm.submaster.name, "submaster %r has no name" % subterm.submaster
- uri = URIRef(song + "/subterm/" + subterm.submaster.name)
- graph.add((song, L9['subterm'], uri))
- graph.add((uri, RDF.type, L9['Subterm']))
- graph.add((uri, RDFS.label, Literal(subterm.submaster.name)))
- graph.add((uri, L9['sub'], L9['sub/%s' % subterm.submaster.name]))
- graph.add((uri, L9['expression'], Literal(subterm.subexpr.expr)))
- return graph
-
-def savekey(song, curveset):
- log.info("saving %r", song)
- g = createSubtermGraph(song, subterms)
- g.serialize(graphPathForSubterms(song), format="nt")
-
- curveset.save(basename=os.path.join(showconfig.curvesDir(),
- showconfig.songFilenameFromURI(song)))
- log.info("saved")
diff --git a/light9/curvecalc/subtermview.py b/light9/curvecalc/subtermview.py
--- a/light9/curvecalc/subtermview.py
+++ b/light9/curvecalc/subtermview.py
@@ -1,6 +1,6 @@
import gtk, logging
from louie import dispatcher
-from rdflib import Literal
+from rdflib import Literal, URIRef
from light9.namespaces import L9
log = logging.getLogger()
@@ -58,10 +58,22 @@ class Subtermview(object):
self.label = gtk.Label("sub")
self.graph.addHandler(self.setName)
+
+ self.label.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
+ targets=[('text/uri-list', 0, 0)],
+ actions=gtk.gdk.ACTION_COPY)
+ self.label.connect("drag-data-received", self.onDataReceivedOnLabel)
sev = Subexprview(self.graph, self.subterm.uri, self.subterm.saveContext)
self.exprView = sev.box
+ def onDataReceivedOnLabel(self, widget, context, x, y, selection,
+ targetType, time):
+ self.graph.patchObject(self.subterm.saveContext,
+ self.subterm.uri,
+ L9['sub'],
+ URIRef(selection.data.strip()))
+
def setName(self):
# some of this could be pushed into Submaster
sub = self.graph.value(self.subterm.uri, L9['sub'])
diff --git a/show/dance2013/demo.html b/show/dance2013/demo.html
--- a/show/dance2013/demo.html
+++ b/show/dance2013/demo.html
@@ -3,3 +3,6 @@ some resources
demo1 sub
demo2 sub
demo3 sub
+
+song1
+song2