changeset 951:1e01727312f0

CC more drag support and code cleanup Ignore-this: d6c3af63d8062a4f20ed0f88ba7048a5
author drewp@bigasterisk.com
date Fri, 14 Jun 2013 05:29:19 +0000
parents 41c6fbe95214
children 59f1898cec60
files bin/curvecalc light9/curvecalc/curveview.py light9/curvecalc/subtermview.py
diffstat 3 files changed, 15 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/bin/curvecalc	Thu Jun 13 21:59:32 2013 +0000
+++ b/bin/curvecalc	Fri Jun 14 05:29:19 2013 +0000
@@ -89,30 +89,18 @@
         self.refreshCurveView()       
         
         self.makeStatusLines(wtree.get_object("status"))
-
-
+        self.setupNewSubZone()
         self.acceptDragsOnCurveViews()
-        
-        def connect(w):
-            w.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
-                            targets=[('text/uri-list', 0, 0)],
-                            actions=gtk.gdk.ACTION_COPY)
-            w.connect("drag-data-received", self.onDataReceived)
-        #connect(mainwin)
-        # that's not enough- deeper windows don't accept the
-        # event. 
-        #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
-
+                
         # may not work
         wtree.get_object("paned1").set_position(600)
 
+    def setupNewSubZone(self):
+        wtree.get_object("newSubZone").drag_dest_set(
+            flags=gtk.DEST_DEFAULT_ALL,
+            targets=[('text/uri-list', 0, 0)],
+            actions=gtk.gdk.ACTION_COPY)
+        
     def acceptDragsOnCurveViews(self):
         w = self.wtree.get_object("curves")
         w.drag_dest_set(flags=gtk.DEST_DEFAULT_ALL,
@@ -141,33 +129,18 @@
                                   (t, 1)])
         w.connect("drag-data-received", recv)
         
-    def onDataReceived(self, widget, context, x, y, selection,
+    def onDragDataInNewSubZone(self, widget, context, x, y, selection,
                        targetType, time):
-        data = selection.data.strip()
+        data = URIRef(selection.data.strip())
         if '?' in data:
             self.handleSubtermDrop(data)
             return
-        uri = URIRef(data)
-        subName = self.graph.label(uri)
-        
-        try:
-            self.makeSubterm(subName, withCurve=True)
-        except SubtermExists:
-            pass
-        curveView = self.curvesetView.row(subName).curveView
-        t = self.lastSeenInputTime # curveView.current_time() # new curve hasn't heard the time yet. this has gotten too messy- everyone just needs to be able to reach the time source
-        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()))
+        self.makeSubterm(newname="cx", withCurve=True, sub=data)
         
     def handleSubtermDrop(self, data):
         params = parse_qsl(data.split('?')[1])
         flattened = dict(params)
-        self.makeSubterm(flattened['subtermName'],
+        self.makeSubterm(Literal(flattened['subtermName']),
                          expr=flattened['subtermExpr'])
 
         for cmd, name in params:
--- a/light9/curvecalc/curveview.py	Thu Jun 13 21:59:32 2013 +0000
+++ b/light9/curvecalc/curveview.py	Fri Jun 14 05:29:19 2013 +0000
@@ -459,7 +459,7 @@
         here'
         """
         # maybe self.canvas.get_pointer would be ok for this? i didn't try it
-        if self.entered:
+        if self.entered and hasattr(self, 'lastMouseX'):
             t = self.world_from_screen(self.lastMouseX, 0)[0]
             return t
         return None
--- a/light9/curvecalc/subtermview.py	Thu Jun 13 21:59:32 2013 +0000
+++ b/light9/curvecalc/subtermview.py	Fri Jun 14 05:29:19 2013 +0000
@@ -77,7 +77,8 @@
         # some of this could be pushed into Submaster
         sub = self.graph.value(self.subterm.uri, L9['sub'])
         if sub is None:
-            self.label.set_text("no sub (%s)" % self.subterm.uri)
+            tail = self.subterm.uri.rsplit('/', 1)[-1]
+            self.label.set_text("no sub (%s)" % tail)
             return
         label = self.graph.label(sub)
         if label is None: