Changeset - 1e01727312f0
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 12 years ago 2013-06-14 05:29:19
drewp@bigasterisk.com
CC more drag support and code cleanup
Ignore-this: d6c3af63d8062a4f20ed0f88ba7048a5
3 files changed with 15 insertions and 41 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -89,30 +89,18 @@ class Main(object):
 
        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 @@ class Main(object):
 
                                  (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:
light9/curvecalc/curveview.py
Show inline comments
 
@@ -459,7 +459,7 @@ class Curveview(object):
 
        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
light9/curvecalc/subtermview.py
Show inline comments
 
@@ -77,7 +77,8 @@ class Subtermview(object):
 
        # 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:
0 comments (0 inline, 0 general)