changeset 725:e8f9f4815ab4

attempt at subtermview autoscroll but it doesn't work Ignore-this: 4cb643412a6478a73526608a851ef9f4
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 14 Jun 2012 06:23:31 +0000
parents 27fdbe9a8118
children 8fba62df5e39
files bin/curvecalc light9/curvecalc/curvecalc.glade light9/curvecalc/subtermview.py
diffstat 3 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bin/curvecalc	Thu Jun 14 03:46:52 2012 +0000
+++ b/bin/curvecalc	Thu Jun 14 06:23:31 2012 +0000
@@ -66,7 +66,8 @@
         # this is the only one i found that would set the size right,
         # but it's a minimum size, which i don't really want
         mainwin.set_size_request(1000, 1000)
-        
+
+        wtree.get_object("subterms").connect("add", self.onSubtermChildAdded)
         self.add_subterms_for_song(song, curveset, subterms)
         self.refreshCurveView()       
         
@@ -106,6 +107,11 @@
         gtk.rc_reparse_all()
         reactor.callLater(1, self.refreshTheme)
 
+    def onSubtermChildAdded(self, subtermsTable, *args):
+        # this would probably work, but isn't getting called
+        v = subtermsTable.get_parent().props.vadjustment
+        v.props.value = v.props.upper
+
     def onQuit(self, *args):
         reactor.crash()
         # there's a hang after this, maybe in sem_wait in two
--- a/light9/curvecalc/curvecalc.glade	Thu Jun 14 03:46:52 2012 +0000
+++ b/light9/curvecalc/curvecalc.glade	Thu Jun 14 06:23:31 2012 +0000
@@ -482,6 +482,8 @@
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
                                 <property name="n_columns">2</property>
+                                <signal name="add" handler="onSubtermChildAdded" swapped="no"/>
+                                <signal name="child-added" handler="onSubtermChildAdded" swapped="no"/>
                                 <child>
                                   <placeholder/>
                                 </child>
--- a/light9/curvecalc/subtermview.py	Thu Jun 14 03:46:52 2012 +0000
+++ b/light9/curvecalc/subtermview.py	Thu Jun 14 06:23:31 2012 +0000
@@ -66,11 +66,29 @@
 
     stv = Subtermview(graph, term)
     y = master.get_property('n-rows')
-    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)
+    scrollToRowUponAdd(stv.label)  
     if show:
         master.show_all()
     return term
 
 
+def scrollToRowUponAdd(widgetInRow):
+    """when this table widget is ready, scroll the table so we can see it"""
+    
+    # this doesn't work right, yet
+    return
+    
+    vp = widgetInRow
+    while vp.get_name() != 'GtkViewport':
+        print "walk", vp.get_name()
+        vp = vp.get_parent()
+    adj = vp.props.vadjustment
+
+    def firstExpose(widget, event, adj, widgetInRow):
+        print "scroll", adj.props.value
+        adj.props.value = adj.props.upper
+        widgetInRow.disconnect(handler)
+        
+    handler = widgetInRow.connect('expose-event', firstExpose, adj, widgetInRow)