Author: dmeyer
Date: Sat Jan 20 20:28:51 2007
New Revision: 9024
Removed:
trunk/ui/src/tv/plugins/xine.py
Modified:
trunk/ui/src/tv/favorite.py
trunk/ui/src/tv/program.py
trunk/ui/src/tv/tvguide.py
trunk/ui/src/tv/tvmenu.py
Log:
Adjust to new application and menu code. There is no tv player
written yet, so you can only schedule recordings but not watch tv.
Modified: trunk/ui/src/tv/favorite.py
==============================================================================
--- trunk/ui/src/tv/favorite.py (original)
+++ trunk/ui/src/tv/favorite.py Sat Jan 20 20:28:51 2007
@@ -36,7 +36,7 @@
# freevo imports
from menu import Item, Action, Menu
-from gui.windows import MessageBox
+from application import MessageWindow
# get tvserver interface
tvserver = freevo.ipc.Instance('freevo').tvserver
@@ -92,4 +92,4 @@
def add(self):
tvserver.favorites.add(self)
txt = _('"%s" has been scheduled as favorite') % self.title
- MessageBox(txt).show()
+ MessageWindow(txt).show()
Modified: trunk/ui/src/tv/program.py
==============================================================================
--- trunk/ui/src/tv/program.py (original)
+++ trunk/ui/src/tv/program.py Sat Jan 20 20:28:51 2007
@@ -45,7 +45,7 @@
import config
import plugin
from menu import Item, Action, Menu, ActionItem
-from gui.windows import MessageBox
+from application import MessageWindow
# tv imports
import favorite
@@ -182,20 +182,20 @@
def schedule(self):
(result, msg) = tvserver.recordings.schedule(self)
if result:
- MessageBox(_('"%s" has been scheduled for recording') % \
+ MessageWindow(_('"%s" has been scheduled for recording') % \
self.title).show()
else:
- MessageBox(_('Scheduling Failed')+(': %s' % msg)).show()
+ MessageWindow(_('Scheduling Failed')+(': %s' % msg)).show()
self.get_menustack().delete_submenu()
def remove(self):
(result, msg) = tvserver.recordings.remove(self.scheduled.id)
if result:
- MessageBox(_('"%s" has been removed as recording') % \
+ MessageWindow(_('"%s" has been removed as recording') % \
self.title).show()
else:
- MessageBox(_('Scheduling Failed')+(': %s' % msg)).show()
+ MessageWindow(_('Scheduling Failed')+(': %s' % msg)).show()
self.get_menustack().delete_submenu()
@@ -210,17 +210,15 @@
def watch_channel(self):
- p = plugin.getbyname(plugin.TV)
- if p:
- p.play(self.channel.id)
+ MessageWindow('Not implemented yet').show()
def watch_recording(self):
- MessageBox('Not implemented yet').show()
+ MessageWindow('Not implemented yet').show()
def search_similar(self):
- MessageBox('Not implemented yet').show()
+ MessageWindow('Not implemented yet').show()
def create_favorite(self):
@@ -229,4 +227,4 @@
def remove_favorite(self):
- MessageBox('Not implemented yet').show()
+ MessageWindow('Not implemented yet').show()
Modified: trunk/ui/src/tv/tvguide.py
==============================================================================
--- trunk/ui/src/tv/tvguide.py (original)
+++ trunk/ui/src/tv/tvguide.py Sat Jan 20 20:28:51 2007
@@ -36,190 +36,159 @@
import logging
import kaa.epg
-
-# freevo core imports
-import freevo.ipc
-
-# freevo imports
-import gui
-import gui.areas
+import kaa.notifier
from event import *
-from application import MenuApplication
-from menu import Item
+from menu import Item, Menu
from program import ProgramItem
# get logging object
log = logging.getLogger('tv')
-_guide = None
-def get_singleton():
+class TVGuide(Menu):
"""
- return the global tv guide
+ TVGuide menu.
"""
- global _guide
- if not _guide:
- _guide = TVGuide()
- return _guide
+ def __init__(self, parent):
+ Menu.__init__(self, _('TV Guide'), choices=[], type = 'tvgrid')
+ self.parent = parent
+ self.channel_index = 0
+ self.current_time = int(time.time())
+ print time.localtime(self.current_time)
+
+ # current channel is the first one
+ self.channels = kaa.epg.get_channels(sort=True)
+ self.channel = self.get_channel()
+ # current program is the current running
+ self.selected = None
+ self.get_program()
-class TVGuide(MenuApplication):
- """
- TVGuide application. It is _inside_ the menu, so it is a
- MenuApplication.
- """
- def __init__(self):
- MenuApplication.__init__(self, 'tvguide', 'tvmenu', False)
- self.item = None
- self.channel_index = 0
-
def get_channel(self, offset=0):
co = self.channel_index + offset
- channels = kaa.epg.get_channels(sort=True)
if co < 0:
- co = len(channels)+co
- elif co > len(channels)-1:
- co = co-len(channels)
+ co = len(self.channels)+co
+ elif co > len(self.channels)-1:
+ co = co-len(self.channels)
self.channel_index = co
- return channels[co]
+ return self.channels[co]
+
- def get_program(self, time=None):
+ @kaa.notifier.yield_execution()
+ def get_program(self, timestamp=None):
"""
- return a program object based on time and the current channel.
+ return a program object based on timestamp and the current channel.
"""
# TODO: keep a cache of program objects for the current guide view
# unless this happens to be fast enough
- if not time:
- time = self.current_time
+ if not timestamp:
+ timestamp = self.current_time
+ print time.localtime(timestamp)
+
+ log.info('channel: %s time %s', self.channel, timestamp)
+ wait = kaa.notifier.YieldCallback()
+ kaa.epg.search(channel=self.channel, time=timestamp, callback=wait)
+ yield wait
+ prg = wait.get()
- log.debug('channel: %s', self.channel)
- p = kaa.epg.search(channel=self.channel, time=time)
- if p:
+ if prg:
# one program found, return it
- return p[0]
- # Now we are in trouble, there is no program item. We need to create a
fake
- # one between the last stop and the next start time. This is very
slow!!!
- p = kaa.epg.search(channel=self.channel, time=(0, time))
- p.sort(lambda x,y: cmp(x.start, y.start))
- if p:
- start = p[-1].stop
- else:
- start = 0
-
- p = kaa.epg.search(channel=self.channel, time=(time, sys.maxint))
- p.sort(lambda x,y: cmp(x.start, y.start))
- if p:
- stop = p[0].start
+ prg = prg[0]
else:
- stop = sys.maxint
-
- data = { 'start': start, 'stop': stop, 'title': _('No Program') }
- return kaa.epg.Program(self.channel, data)
-
-
- def start(self, parent):
- self.engine = gui.areas.Handler('tv', ('screen', 'title', 'subtitle',
- 'view', 'tvlisting', 'info'))
- self.parent = parent
- # create fake parent item for ProgramItems
- self.item = Item(parent, None, 'tv')
-
- self.current_time = int(time.time())
+ # Now we are in trouble, there is no program item. We need to
create a fake
+ # one between the last stop and the next start time. This is very
slow!!!
+ wait = kaa.notifier.YieldCallback()
+ kaa.epg.search(channel=self.channel, time=(0, timestamp),
callback=wait)
+ yield wait
+ p = wait.get()
+ p.sort(lambda x,y: cmp(x.start, y.start))
+ if p:
+ start = p[-1].stop
+ else:
+ start = 0
- # current channel is the first one
- self.channel = self.get_channel()
+ wait = kaa.notifier.YieldCallback()
+ kaa.epg.search(channel=self.channel, time=(timestamp, sys.maxint),
+ callback=wait)
+ yield wait
+ p = wait.get()
+ p.sort(lambda x,y: cmp(x.start, y.start))
+ if p:
+ stop = p[0].start
+ else:
+ stop = sys.maxint
- # current program is the current running
- self.selected = ProgramItem(self.get_program(), self.item)
+ dbdata = { 'start': start, 'stop': stop, 'title': _('No Program') }
+ prg = kaa.epg.Program(self.channel, dbdata)
- return True
-
-
- def show(self):
- """
- show the guide
- """
- self.selected = ProgramItem(self.get_program(), self.item)
- self.refresh()
- MenuApplication.show(self)
+ self.selected = ProgramItem(prg, self.parent)
+ if self.selected.start > 0:
+ self.current_time = self.selected.start + 1
+ if self.selected.stop < sys.maxint:
+ self.current_time = self.selected.start + 1
+ if self.stack:
+ # FIXME: gui calls notifier.step()
+ kaa.notifier.OneShotTimer(self.stack.refresh).start(0)
- def hide(self):
- """
- hide the guide
- """
- MenuApplication.hide(self)
-
-
def eventhandler(self, event):
- if MenuApplication.eventhandler(self, event):
- return True
+ if not self.selected:
+ # not ready yet
+ return False
if event == MENU_CHANGE_STYLE:
return True
-
+
if event == MENU_UP:
self.channel = self.get_channel(-1)
- self.selected = ProgramItem(self.get_program(), self.item)
- self.refresh()
+ self.get_program()
return True
if event == MENU_DOWN:
self.channel = self.get_channel(1)
- self.selected = ProgramItem(self.get_program(), self.item)
- self.refresh()
+ self.get_program()
return True
if event == MENU_LEFT:
if self.selected.start == 0:
return True
- epg_prog = self.get_program(self.selected.program.start - 1)
- self.selected = ProgramItem(epg_prog, self.item)
- if self.selected.start > 0:
- self.current_time = self.selected.start + 1
- self.refresh()
+ self.get_program(self.selected.program.start - 1)
return True
if event == MENU_RIGHT:
if self.selected.stop == sys.maxint:
return True
- epg_prog = self.get_program(self.selected.program.stop + 1)
- self.selected = ProgramItem(epg_prog, self.item)
- if self.selected.stop < sys.maxint:
- self.current_time = self.selected.start + 1
- self.refresh()
+ self.get_program(self.selected.program.stop + 1)
return True
if event == MENU_PAGEUP:
# FIXME: 9 is only a bad guess by Rob
self.channel = self.get_channel(-9)
- self.selected = ProgramItem(self.get_program(), self.item)
- self.refresh()
+ self.get_program()
return True
if event == MENU_PAGEDOWN:
# FIXME: 9 is only a bad guess by Rob
self.channel = self.get_channel(9)
- self.selected = ProgramItem(self.get_program(), self.item)
- self.refresh()
+ self.get_program()
return True
if event == TV_SHOW_CHANNEL:
self.selected.channel_details()
return True
-
+
if event == MENU_SUBMENU:
self.selected.submenu(additional_items=True)
return True
-
+
if event == TV_START_RECORDING:
self.selected.submenu(additional_items=True)
return True
-
+
if event == PLAY:
self.selected.watch_channel()
return True
@@ -233,13 +202,5 @@
else:
self.selected.watch_channel()
return True
-
- if event == PLAY_END:
- self.show()
- return True
return False
-
-
- def refresh(self):
- self.engine.draw(self)
Modified: trunk/ui/src/tv/tvmenu.py
==============================================================================
--- trunk/ui/src/tv/tvmenu.py (original)
+++ trunk/ui/src/tv/tvmenu.py Sat Jan 20 20:28:51 2007
@@ -8,20 +8,6 @@
# Todo:
#
# -----------------------------------------------------------------------
-# $Log$
-# Revision 1.29 2005/08/07 13:56:59 dischi
-# use Signal inside a gui button and add connect to the box
-#
-# Revision 1.28 2005/08/07 10:46:40 dischi
-# adjust to new menu interface
-#
-# Revision 1.27 2005/06/18 11:53:52 dischi
-# adjust to new menu code
-#
-# Revision 1.26 2005/06/04 17:18:15 dischi
-# adjust to gui changes
-#
-# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
# Please see the file doc/CREDITS for a complete list of authors.
@@ -57,7 +43,7 @@
import tvguide
from directory import DirItem
-from gui.windows import MessageBox, WaitBox
+from application import TextWindow, MessageWindow
import logging
log = logging.getLogger('tv')
@@ -74,39 +60,6 @@
return Info.__getitem__(self, key)
-class EPGUpdate(ActionItem):
-
- def __init__(self, parent):
- ActionItem.__init__(self, 'Update TV Guide', parent, self.update,
- description='Update TV Guide information')
- self.msg = None
- self.child = None
-
-
- def debug(self, line):
- log.debug(line)
-
-
- def completed(self, code):
- self.msg.destroy()
- self.msg = None
- self.child = None
- print code
-
-
- def update(self):
- if self.msg or self.child:
- return
- self.msg = WaitBox('Updating Guide, please wait')
- self.msg.show()
- self.child = kaa.notifier.Process(['freevo', 'tv_grab'])
- self.child.signals['stdout'].connect(self.debug)
- self.child.signals['stderr'].connect(self.debug)
- self.child.signals['completed'].connect(self.completed)
- self.child.start()
-
-
-
class TVMenu(MainMenuItem):
"""
The tv main menu
@@ -128,8 +81,6 @@
name = _('Recorded Shows'),
type='tv'))
- items.append(EPGUpdate(None))
-
# XXX: these are becomming plugins
# items.append(menu.MenuItem(_('Search Guide'),
# action=self.show_search))
@@ -152,15 +103,11 @@
if False:
msg = _('The list of TV channels is invalid!\n')
msg += _('Please check the config file.')
- MessageBox(msg).show()
+ MessageWindow(msg).show()
return
- guide = plugin.getbyname('tvguide')
- if not guide:
- guide = tvguide.get_singleton()
-
- if guide.start(self):
- self.pushmenu(guide)
+ guide = tvguide.TVGuide(self)
+ self.pushmenu(guide)
# FIXME: debug, remove me
t2 = time.time()
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog