diff bin/curvecalc @ 692:ccdd04f4ca7d

subterm display is working Ignore-this: 54254c7f9d6cd89bd80031ed1cf92066
author Drew Perttula <drewp@bigasterisk.com>
date Fri, 08 Jun 2012 05:11:41 +0000
parents 62d83d456f2e
children 34dacd800505
line wrap: on
line diff
--- a/bin/curvecalc	Fri Jun 08 04:00:36 2012 +0000
+++ b/bin/curvecalc	Fri Jun 08 05:11:41 2012 +0000
@@ -53,19 +53,6 @@
                            l.config(text=sn+": "+tf(val)),
                            signame, weak=False)
 
-def add_subterms_for_song(graph, song, curveset, subterms, master):
-    for st in graph.objects(song, L9['subterm']):
-        log.info("song %s has subterm %s", song, st)
-        try:
-            add_one_subterm(graph, graph.value(st, L9['sub']), curveset,
-                            subterms, master, graph.value(st, L9['expression']))
-        except rdflib.exceptions.UniquenessError:
-            print "working around curvecalc save corruption"
-            # curvecalc put all the expressions on one subterm, which is wrong
-            for expr in graph.objects(st, L9['expression']):
-                add_one_subterm(graph, graph.value(st, L9['sub']),
-                                curveset, subterms, master, expr)
-                
 
 def makeGraph():
     graphOrig = showconfig.getGraph()
@@ -130,7 +117,8 @@
         line.pack(side='top',fill='x')
 
 class Main(object):
-    def __init__(self):
+    def __init__(self, graph, song, curveset, subterms):
+        self.graph = graph
         wtree = gtk.Builder()
         wtree.add_from_file(sibpath(__file__, "../light9/curvecalc/curvecalc.glade"))
         mainwin = wtree.get_object("MainWindow")
@@ -139,6 +127,23 @@
         mainwin.show_all()
         #gobject.timeout_add(1000 // framerate, self.updateLoop)
 
+        mainwin.set_title("curvecalc - %s" % graph.label(song))
+
+        self.add_subterms_for_song(song, curveset, subterms,
+                                   wtree.get_object("subterms")
+                                   )
+
+    def add_subterms_for_song(self, song, curveset, subterms, master):
+        for st in self.graph.objects(song, L9['subterm']):
+            log.info("song %s has subterm %s", song, st)
+            add_one_subterm(self.graph,
+                            self.graph.value(st, L9['sub']),
+                            curveset,
+                            subterms,
+                            master,
+                            self.graph.value(st, L9['expression']))
+        master.show_all()
+
 def main():
     startTime = time.time()
     parser = optparse.OptionParser()
@@ -165,17 +170,6 @@
     music=Music()
     graph = makeGraph()
 
-    start=Main()
-    #gtk2reactor.install()
-
-    if opts.startup_only:
-        log.debug("quitting now because of --startup-only")
-        return
-
-    gtk.main()
-    1/0
-    ###################
-
     curveset = Curveset(sliders=opts.sliders)
     subterms = []
 
@@ -194,7 +188,17 @@
     maxtime = wavelength(musicfilename)
     dispatcher.connect(lambda: maxtime, "get max time", weak=False)
 
-    root.title("curvecalc - %s" % graph.label(song))
+    start = Main(graph, song, curveset, subterms)
+    #gtk2reactor.install()
+
+    if opts.startup_only:
+        log.debug("quitting now because of --startup-only")
+        return
+
+    gtk.main()
+    1/0
+    ###################
+
 
     if 'fixed top rows':
         zc = Zoomcontrol(root)
@@ -225,8 +229,6 @@
         createHelpLines(helpBox)
         helpBox.pack(side='top', fill='x')
 
-    add_subterms_for_song(graph, song, curveset, subterms,
-                          subtermScroll.subwidget('window'))
     setupKeyBindings(root, song, subterms, curveset)
     setupMenubar(menubar, root, song, subterms, curveset)