Progress bar seek to click
When the user clicks on the progess bar, we should seek to the location of the click.
This commit is contained in:
parent
1e2d27377f
commit
d9a6c0987e
|
@ -28,21 +28,25 @@ class PBar(gtk.HScale):
|
|||
self.set_range(0, 101)
|
||||
self.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
|
||||
self.connect("change-value", self.change_value)
|
||||
self.connect("button-press-event", self.button_down)
|
||||
self.connect("motion-notify-event", self.mouse_motion)
|
||||
gobject.timeout_add(500, self.update)
|
||||
self.show()
|
||||
|
||||
def update(self):
|
||||
global update
|
||||
self.set_value(update() * 100)
|
||||
return True
|
||||
|
||||
def change_value(self, scale, type, value):
|
||||
global seek
|
||||
seek(value / 100.0)
|
||||
|
||||
def button_down(self, widget, event):
|
||||
alloc = self.get_allocation()
|
||||
prcnt = event.x / alloc.width
|
||||
seek(prcnt)
|
||||
self.update()
|
||||
|
||||
def mouse_motion(self, widget, event):
|
||||
alloc = self.get_allocation()
|
||||
prcnt = event.x / float(alloc.width)
|
||||
self.set_tooltip_text(time_at(prcnt))
|
||||
print widget, event, alloc.width
|
||||
|
|
Loading…
Reference in New Issue