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 14 insertions and 40 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -86,36 +86,24 @@ class Main(object):
 
        wtree.get_object("subterms").connect("add", self.onSubtermChildAdded)
 
        
 

	
 
        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,
 
                        targets=[('text/uri-list', 0, 0)],
 
                        actions=gtk.gdk.ACTION_COPY)
 
        def recv(widget, context, x, y, selection,
 
@@ -138,39 +126,24 @@ class Main(object):
 
            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
 
            print "time", t
 
            curveView.add_points([(t - .5, 0),
 
                                  (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:
 
            if cmd == 'curve':
 
                self.curveset.new_curve(name)
 

	
light9/curvecalc/curveview.py
Show inline comments
 
@@ -456,13 +456,13 @@ class Curveview(object):
 
        todo: there should be a faint timecursor line under the mouse
 
        so it's more obvious that we use that time for some
 
        events. Rt-click should include Ctrl+P as 'play/pause from
 
        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
 

	
 
    def goLive(self):
 
        """this is for startup performance only, since the curves were
light9/curvecalc/subtermview.py
Show inline comments
 
@@ -74,13 +74,14 @@ class Subtermview(object):
 
                               URIRef(selection.data.strip()))
 

	
 
    def setName(self):
 
        # 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:
 
            self.label.set_text("sub %s has no label" % sub)
 
            return
 
        self.label.set_text(label)
0 comments (0 inline, 0 general)