2008-05-22 05:41:04 -07:00
|
|
|
import clutter
|
|
|
|
import gobject
|
2008-05-24 08:31:54 -07:00
|
|
|
from ui_elements.rounded_rectangle import RoundedRectangle
|
2008-05-22 05:41:04 -07:00
|
|
|
|
|
|
|
class ProgressBar(clutter.Group):
|
|
|
|
|
|
|
|
def __init__(self, Controller):
|
|
|
|
clutter.Group.__init__(self)
|
|
|
|
|
|
|
|
self.media_controller = Controller
|
|
|
|
|
|
|
|
self.bg = clutter.Rectangle()
|
|
|
|
self.fg = clutter.Rectangle()
|
|
|
|
|
|
|
|
|
|
|
|
self.add(self.bg)
|
|
|
|
self.bg.show()
|
|
|
|
self.add(self.fg)
|
|
|
|
self.fg.show()
|
|
|
|
|
|
|
|
def setup_from_theme_id(self, themeMgr, id):
|
|
|
|
element = themeMgr.search_docs("progress_bar", id).childNodes
|
|
|
|
colour_element = themeMgr.search_docs("progress_bar", id).getElementsByTagName("colour")
|
|
|
|
|
|
|
|
#width = clutter.Stage.get_width(), height = 10
|
|
|
|
(self.width, self.height) = themeMgr.get_dimensions(element, themeMgr.stage)
|
|
|
|
|
|
|
|
colour_element_bg = themeMgr.find_element(colour_element, "id", "background")
|
|
|
|
colour_element_fg = themeMgr.find_element(colour_element, "id", "foreground")
|
|
|
|
if not colour_element_bg is None:
|
|
|
|
colour_element_bg = colour_element_bg.childNodes
|
|
|
|
bgColour = themeMgr.get_colour(colour_element_bg, "background")
|
|
|
|
if not colour_element_fg is None:
|
|
|
|
colour_element_fg = colour_element_fg.childNodes
|
|
|
|
fgColour = themeMgr.get_colour(colour_element_fg, "foreground")
|
|
|
|
#bgColour = themeMgr.get_colour(element, "background")
|
|
|
|
#fgColour = themeMgr.get_colour(element, "foreground")
|
|
|
|
|
2008-05-24 08:31:54 -07:00
|
|
|
|
2008-05-22 05:41:04 -07:00
|
|
|
self.bg.set_size(self.width, self.height)
|
2008-05-24 08:31:54 -07:00
|
|
|
#self.bg = RoundedRectangle(self.width, self.height)
|
|
|
|
self.bg.set_color(bgColour)
|
|
|
|
#self.bg.show()
|
|
|
|
#self.add(self.bg)
|
2008-05-22 05:41:04 -07:00
|
|
|
|
2008-06-05 16:48:42 -07:00
|
|
|
self.fg = clutter.Rectangle() #RoundedRectangle(20, self.height)
|
2008-05-22 05:41:04 -07:00
|
|
|
self.fg.set_color(fgColour)
|
2008-05-24 08:31:54 -07:00
|
|
|
self.fg.show()
|
|
|
|
self.add(self.fg)
|
2008-06-05 16:48:42 -07:00
|
|
|
self.fg.set_size(0, self.height)
|
2008-05-22 05:41:04 -07:00
|
|
|
|
|
|
|
def display(self):
|
|
|
|
self.displayed = True
|
|
|
|
|
|
|
|
|
|
|
|
self.show()
|
|
|
|
gobject.timeout_add(1000, self.tick)
|
|
|
|
|
|
|
|
def tick(self):
|
|
|
|
if self.displayed:
|
|
|
|
percent = self.media_controller.get_position_percent()
|
|
|
|
new_width = int(float(self.width) * float(percent))
|
|
|
|
|
|
|
|
#print "new width: %s" % float(new_width)
|
|
|
|
self.fg.set_width(new_width)
|
|
|
|
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|