- Work on channel change OSD

This commit is contained in:
noisymime 2008-02-20 20:45:41 +00:00
parent ac832fe79e
commit 01541bd5b0
2 changed files with 81 additions and 18 deletions

View File

@ -198,7 +198,7 @@ class MythBackendConnection(threading.Thread):
request_size = max_request_size
elif (request_size > request_size_step) and (num_bytes != request_size):
request_size -= request_size_step
if num_bytes < request_size:
if num_bytes < request_size and self.videoPlayer.glossMgr.debug:
print "TV_PLAYER: Failed to receive full allocation"
#print "End optimisation"

View File

@ -1,5 +1,5 @@
import gst
import pygtk
import pygtk, gtk
import pygst
import os
import clutter
@ -22,7 +22,7 @@ class Module:
self.dbMgr = dbMgr
self.setup_ui()
self.osd = osd()
self.osd = osd_channel(self.stage)
self.videoController = VideoController(glossMgr)
self.dbController = tv_db_controller(dbMgr)
#self.dbController.get_current_show(1033)
@ -70,7 +70,7 @@ class Module:
if self.isRunning:
#Handle up/down presses for OSD
if (event.keyval == clutter.keysyms.Up) or (event.keyval == clutter.keysyms.Down):
self.osd.on_key_press_event(self.stage, event, self)
self.osd.on_key_press_event(event, self)
self.videoController.on_key_press_event(event)
@ -130,19 +130,68 @@ class Module:
self.videoController.unpause_video()
self.loading_scr.remove_elegant()
class osd:
class osd_channel(clutter.Group):
font = "Lucida Grande "
name_font_size = 30
prog_title_font_size = 22
detail_font_size = 18
def __init__(self):
self.background = clutter.Texture()
self.text = clutter.Label()
self.text.set_font_name("Mono 40")
self.text.show()
def __init__(self, stage):
clutter.Group.__init__(self)
self.stage = stage
pixbuf = gtk.gdk.pixbuf_new_from_file("ui/splash_box.png")
self.box = clutter.Texture()
self.box.set_pixbuf(pixbuf)
self.box.set_opacity(int(255 * 0.75))
self.box.set_height(int(self.stage.get_height()* 0.15))
self.add(self.box)
self.logo = clutter.Texture()
height = int(self.box.get_height() * 0.90)
height = height + (height % 2) # Make sure that the dimension is even
self.logo.set_height(height)
self.logo.set_width(height)
self.logo.set_position(5, int(self.box.get_height() * 0.05 ) )
self.add(self.logo)
self.name = clutter.Label()
self.name.set_font_name(self.font + str(self.name_font_size))
self.name.set_color(clutter.color_parse('White'))
pos_x = self.logo.get_x() + int (self.logo.get_width() * 1.1)
pos_x = pos_x
self.name.set_position(pos_x, 0)
self.name.set_text(" ")
self.add(self.name)
self.prog_title = clutter.Label()
self.prog_title.set_font_name(self.font + str(self.prog_title_font_size))
self.prog_title.set_color(clutter.color_parse('White'))
self.prog_title.set_position(\
self.name.get_x(),\
self.name.get_y() + self.name.get_height()\
)
self.add(self.prog_title)
self.detail = clutter.Label()
self.detail.set_font_name(self.font + str(self.detail_font_size))
self.detail.set_color(clutter.color_parse('White'))
self.detail.set_position(\
self.prog_title.get_x(),\
self.prog_title.get_y() + self.prog_title.get_height()\
)
self.add(self.detail)
pos_x = (self.stage.get_width() - self.box.get_width()) / 2
pos_y = int(self.stage.get_height() * 0.66)
self.set_position(pos_x, pos_y)
self.on_screen = False
self.channelOffset = 0
self.input_count = 0
def on_key_press_event(self, stage, event, tv_player):
def on_key_press_event(self, event, tv_player):
if self.on_screen:
if (event.keyval == clutter.keysyms.Up):
self.channelOffset += 1
@ -152,24 +201,38 @@ class osd:
#Increment the input counter (Only when this reaches 0 will the osd be removed from screen
self.input_count += 1
else:
stage.add(self.text)
self.stage.add(self)
self.channelOffset = 0
self.currentChannel = tv_player.channels[tv_player.currentChannel+self.channelOffset]
self.currentShow = tv_player.dbController.get_current_show(self.currentChannel.chanID)
self.text.set_text(self.currentChannel.name)
self.on_screen = True
self.timeout_id = gobject.timeout_add(3000, self.exit, stage)
self.name.set_text(self.currentChannel.name)
try:
pixbuf = gtk.gdk.pixbuf_new_from_file(self.currentChannel.icon)
self.logo.set_pixbuf(pixbuf)
except gobject.GError, e:
print "Channel Icon not found: " + self.currentChannel.icon
if not self.currentShow is None:
self.prog_title.set_text(self.currentShow.title)
self.detail.set_text(self.currentShow.description)
else:
self.prog_title.set_text("")
self.detail.set_text("")
def exit(self, stage):
self.show_all()
self.show()
self.on_screen = True
self.timeout_id = gobject.timeout_add(3000, self.exit)
def exit(self):
#First check the input counter, we only remove the osd from screen if this is 0
if self.input_count > 0:
self.input_count -= 1
return False
if self.on_screen:
stage.remove(self.text)
self.stage.remove(self)
self.on_screen = False
return False