79 lines
1.7 KiB
Python
79 lines
1.7 KiB
Python
#! /usr/bin/python
|
|
|
|
# To change this template, choose Tools | Templates
|
|
# and open the template in the editor.
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Mar 16, 2010 6:17:38 PM$"
|
|
|
|
|
|
import gtk
|
|
import gobject
|
|
|
|
import guibuilder
|
|
import gstreamer
|
|
import ocarina
|
|
|
|
from ct import times
|
|
from ct import call
|
|
from et import scanlib
|
|
|
|
|
|
class ProgressBar(gtk.EventBox):
|
|
def __init__(self):
|
|
gtk.EventBox.__init__(self)
|
|
self.bar = gtk.ProgressBar()
|
|
self.bar.set_fraction(0)
|
|
|
|
self.connect("button_release_event",self.clicked)
|
|
gobject.timeout_add(500,self.updatebar)
|
|
|
|
self.add(self.bar)
|
|
self.bar.show()
|
|
self.show()
|
|
|
|
|
|
def clicked(self,widgit,data):
|
|
if data.button == 1:
|
|
prcnt = float(data.x) / float(self.bar.get_allocation()[2])
|
|
self.bar.set_fraction(prcnt)
|
|
print prcnt
|
|
call.seek(prcnt)
|
|
#gstreamer.seek(prcnt,fraction=True)
|
|
|
|
|
|
def updatebar(self):
|
|
try:
|
|
self.bar.set_fraction(gstreamer.getProgress())
|
|
current = times.ms2str(gstreamer.currentpos())
|
|
duration = times.ms2str(gstreamer.duration())
|
|
self.bar.set_text(current + " / " + duration)
|
|
except:
|
|
pass
|
|
return True
|
|
|
|
|
|
|
|
class LibScanBar(gtk.ProgressBar):
|
|
def __init__(self):
|
|
gtk.ProgressBar.__init__(self)
|
|
gobject.timeout_add(500,self.updatebar)
|
|
ocarina.events.invite(ocarina.events.SCANLIB_START,self.show)
|
|
ocarina.events.invite(ocarina.events.SCANLIB_STOP,self.hide)
|
|
|
|
|
|
def updatebar(self):
|
|
(cur,tot) = scanlib.progress()
|
|
if cur > 0:
|
|
self.set_text(str(cur) + " / " + str(tot))
|
|
self.set_fraction(float(cur) / float(tot))
|
|
else:
|
|
self.set_text(str(tot))
|
|
self.set_fraction(0)
|
|
return True
|
|
|
|
|
|
def make_progbar(attrs):return ProgressBar()
|
|
def make_libscanbar(attrs):return LibScanBar()
|
|
guibuilder.parts["progbar"] = make_progbar
|
|
guibuilder.parts["scanlibbar"] = make_libscanbar |