# HG changeset patch # User Drew Perttula # Date 2012-06-10 08:47:19 # Node ID 16042667ab5136406edd02bba5b7bcaa40d6c768 # Parent ed50631cf333666f0267925a2358fef974263c0d ui for making a new subterm Ignore-this: 88632c01c5e8ffb6bca4159160b7b40 diff --git a/bin/curvecalc b/bin/curvecalc --- a/bin/curvecalc +++ b/bin/curvecalc @@ -18,9 +18,7 @@ from twisted.internet import reactor import time, textwrap, os, optparse, urllib2, gtk, gobject, linecache, signal import louie as dispatcher from twisted.python.util import sibpath -from rdflib import URIRef -from rdflib import Graph -import rdflib +from rdflib import URIRef, Graph, Literal, RDF, RDFS import logging log = logging.getLogger() @@ -68,9 +66,7 @@ class Main(object): # but it's a minimum size, which i don't really want mainwin.set_size_request(1000, 1000) - self.add_subterms_for_song(song, curveset, subterms, - wtree.get_object("subterms") - ) + self.add_subterms_for_song(song, curveset, subterms) self.refreshCurveView() self.makeStatusLines(wtree.get_object("status")) @@ -85,6 +81,28 @@ class Main(object): self.curveset.new_curve(entry.get_text()) nc.hide() + def onNewSubterm(self, *args): + ns = self.wtree.get_object("newSubterm") + # the plan is to autocomplete this on existing subterm names + # (but let you make one up, too) + entry = self.wtree.get_object("newSubtermName").get_children()[0] + entry.set_text("") + if ns.run() == 1: + newname = entry.get_text() + makeCurve = self.wtree.get_object("newSubtermMakeCurve").get_active() + + uri = L9['sub/%s' % newname] + self.graph.add((uri, RDF.type, L9.Subterm)) + self.graph.add((uri, RDFS.label, Literal(newname))) + add_one_subterm(self.graph, uri, + self.curveset, self.subterms, + self.wtree.get_object("subterms"), + None, show=True) + if makeCurve: + self.curveset.new_curve(newname) + + ns.hide() + def refreshTheme(self): gtk.rc_reparse_all() reactor.callLater(1, self.refreshTheme) @@ -114,7 +132,8 @@ class Main(object): def onSave(self, *args): savekey(self.song, self.subterms, self.curveset) - def add_subterms_for_song(self, song, curveset, subterms, master): + def add_subterms_for_song(self, song, curveset, subterms): + master = self.wtree.get_object("subterms") for st in self.graph.objects(song, L9['subterm']): log.info("song %s has subterm %s", song, st) add_one_subterm(self.graph, @@ -186,16 +205,6 @@ class Main(object): def onReloadSubs(self, *args): # wants to be ctrl-r too dispatcher.send('reload all subs') - def onAddSubterm(self): - uri = L9['sub/%s' % newname.get()] - graph.add((uri, RDF.type, L9.Subterm)) - graph.add((uri, RDFS.label, Literal(newname.get()))) - add_one_subterm(graph, uri, - curveset, subterms, ssv, None) - if evt.state & 4: # control key modifier - curveset.new_curve(newname.get()) - newname.set('') - def main(): startTime = time.time() diff --git a/light9/curvecalc/curvecalc.glade b/light9/curvecalc/curvecalc.glade --- a/light9/curvecalc/curvecalc.glade +++ b/light9/curvecalc/curvecalc.glade @@ -430,33 +430,23 @@ - + + gtk-add True - False - new subterm named (C-Enter for curve too, C-n for focus): + True + True + False + True + False - True + False 1 - - True - True - - True - False - False - True - True - - - False - True - 2 - + @@ -612,6 +602,7 @@ Available in functions: nsin/ncos period False gtk-refresh + False 5 @@ -631,7 +622,7 @@ Available in functions: nsin/ncos period False end - + gtk-cancel True True @@ -646,7 +637,7 @@ Available in functions: nsin/ncos period - + gtk-add True True @@ -671,7 +662,7 @@ Available in functions: nsin/ncos period - + True False Name for new curve @@ -703,12 +694,130 @@ Available in functions: nsin/ncos period - button12 - button2 + button5 + button4 - - song01(t) + + False + 5 + popup + New curve + True + mouse + normal + + + True + False + 2 + + + True + False + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-add + True + True + True + True + True + False + True + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + Name for new subterm + + + True + True + 1 + + + + + True + False + + + True + True + True + True + liststore1 + True + 0 + + + True + True + 0 + + + + + _Make new curve with the same name + True + True + False + False + True + True + True + + + True + True + 1 + + + + + True + True + 2 + + + + + + button12 + button3 + True @@ -742,4 +851,8 @@ Available in functions: nsin/ncos period + + + song01(t) + diff --git a/light9/curvecalc/subtermview.py b/light9/curvecalc/subtermview.py --- a/light9/curvecalc/subtermview.py +++ b/light9/curvecalc/subtermview.py @@ -50,7 +50,7 @@ class Subtermview(object): self.exprView = sev.box -def add_one_subterm(graph, subUri, curveset, subterms, master, expr=None): +def add_one_subterm(graph, subUri, curveset, subterms, master, expr=None, show=False): subname = graph.label(subUri) print "%s's label is %s" % (subUri, subname) if not subname: # fake sub, like for a chase @@ -70,7 +70,8 @@ def add_one_subterm(graph, subUri, curve master.resize(y + 1, columns=2) master.attach(stv.label, 0, 1, y, y + 1, xoptions=0, yoptions=0) master.attach(stv.exprView, 1, 2, y, y + 1, yoptions=0) - + if show: + master.show_all() return term