View Single Post
BrentDC's Avatar
Posts: 903 | Thanked: 632 times | Joined on Apr 2008
#5
Originally Posted by TrueJournals View Post
Not going to write any test code, so I haven't tried this at all... First I think you'll need to test for whether it's a ScrolledWindow or FingerScroll... For a ScrolledWindow, use gethadjustment(), then set the value of the returned gtk.Adjustment to some increment above or below its current value, then use sethadjustment() on the ScrolledWindow.

I hope that made sense. Not sure about the FingerScroll.

[edit]Here's some mostly-code:
Code:
if event.keyval == (UP keysym):
    if type(self.sw) == type(gtk.ScrolledWindow()):
        adj = self.sw.get_vadjustment()
        val = adj.get_value()
        adj.set_value(val+(adjustment))
        self.sw.set_vadjustment(adj) # Not sure if this is necessary
    elif type(self.sw) == type(mokoui.FingerScroll()):
        pass
        #Not sure about this
Obviously, this leaves about some values, and I haven't looked into mokoui.FingerScrol. You would also want to test that mokoui is imported before you just call type(mokoui.FingerScroll())

[edit2]Looking at mokoui... I believe the code would be the same as the scrolledwindow code, so no need to type test. Again, I haven't tried this at all (I've never even dealt with mokoui before).
I just tested the code, using gtk.SROLL_PAGE_UP as the adjustment value, and it works (with a couple issues). The only problem is that it scrolls by small margins, so I tried:

Code:
adj.set_page_increment(gtk.SCROLL_PAGES)
But it says "AttributeError: 'gtk.Adjustment' object has no attribute 'set_page_increment'", which is strange. Because the pygtk reference seems to disagree...Also mokoui.FingerSroll seems to have a completely different api, because it doesn't have a gtk.Adjustment. I'll figure that out, but the first thing is stumping me.

Last edited by BrentDC; 2009-04-05 at 01:42.