Author: dmeyer
Date: Sat Feb 10 19:07:24 2007
New Revision: 9191

Added:
   trunk/ui/src/tv/plugins/directory.py
   trunk/ui/src/tv/plugins/guide.py
      - copied, changed from r9169, /trunk/ui/src/tv/tvguide.py
Removed:
   trunk/ui/src/tv/tvguide.py
   trunk/ui/src/tv/tvmenu.py
Modified:
   trunk/ui/src/tv/__init__.py
   trunk/ui/src/tv/config.cxml
   trunk/ui/src/tv/plugins/config.cxml

Log:
Some cleanup in the tv menu. Eveything including the guide
is now a plugin.


Modified: trunk/ui/src/tv/__init__.py
==============================================================================
--- trunk/ui/src/tv/__init__.py (original)
+++ trunk/ui/src/tv/__init__.py Sat Feb 10 19:07:24 2007
@@ -1,18 +1,16 @@
 # -*- coding: iso-8859-1 -*-
 # -----------------------------------------------------------------------------
-# __init__.py - Freevo tv plugin
+# tv - Freevo tv plugin
 # -----------------------------------------------------------------------------
 # $Id$
 #
-#
 # -----------------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
-# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+# Copyright (C) 2002 Krister Lagerstrom, 2003-2007 Dirk Meyer, et al.
 #
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
-#                Rob Shortt <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,35 +31,55 @@
 # freevo core plugins
 import freevo.ipc
 
+# freevo core imports
+import freevo.ipc
+
 # freevo imports
-from freevo.ui.mainmenu import MainMenuPlugin
+from freevo.ui.mainmenu import MainMenuItem, MainMenuPlugin
+from freevo.ui.menu import Item, Menu
 
+# connect to tvserver using freevo.ipc
+mbus = freevo.ipc.Instance('freevo')
+mbus.connect('freevo.ipc.tvserver')
+
+# get tvserver interface
+tvserver = freevo.ipc.Instance('freevo').tvserver
+
+class Info(Item):
+    def __getitem__(self, key):
+        if key in ('comingup', 'running'):
+            return getattr(tvserver.recordings, key)
+        if key == 'recordserver':
+            return tvserver.recordings.server
+        return Info.__getitem__(self, key)
 
-class PluginInterface(MainMenuPlugin):
+
+class TVMenu(MainMenuItem):
     """
-    Plugin interface to integrate the tv module into Freevo
+    The TV main menu.
     """
-    def __init__(self):
-        """
-        init the plugin.
-        """
-        MainMenuPlugin.__init__(self)
+    def __init__(self, parent):
+        MainMenuItem.__init__(self, '', self.show, parent=parent, skin_type = 
'tv')
 
-        # import here to avoid importing all this when some helpers only
-        # want to import something from iside the tv directory
 
-        from freevo.ui import config
-        
-        # connect to tvserver using freevo.ipc
-        mbus = freevo.ipc.Instance('freevo')
-        mbus.connect('freevo.ipc.tvserver')
-    
-        from tvmenu import TVMenu
-        self.TVMenu = TVMenu
+    def show(self):
+        items = []
+        plugins_list = MainMenuPlugin.plugins('tv')
+        for p in plugins_list:
+            items += p.items(self)
+
+        m = Menu(_('TV Main Menu'), items, type = 'tv main menu')
+        m.infoitem = Info()
+        self.pushmenu(m)
 
+
+class PluginInterface(MainMenuPlugin):
+    """
+    Plugin interface to integrate the tv module into Freevo
+    """
         
     def items(self, parent):
         """
         return the tv menu
         """
-        return [ self.TVMenu(parent) ]
+        return [ TVMenu(parent) ]

Modified: trunk/ui/src/tv/config.cxml
==============================================================================
--- trunk/ui/src/tv/config.cxml (original)
+++ trunk/ui/src/tv/config.cxml Sat Feb 10 19:07:24 2007
@@ -1,9 +1,6 @@
 <?xml version="1.0"?>
 <config name="tv" plugin="10">
     <desc lang="en">tv configuration</desc>
-    <var name="record-dir" type="str">
-        <desc>Directory where the recordings are stored</desc>
-    </var>
 
     <var name="dateformat" default="%e-%b"/>
 

Modified: trunk/ui/src/tv/plugins/config.cxml
==============================================================================
--- trunk/ui/src/tv/plugins/config.cxml (original)
+++ trunk/ui/src/tv/plugins/config.cxml Sat Feb 10 19:07:24 2007
@@ -2,7 +2,21 @@
 <config name="tv.plugin">
     <desc lang="en">tv plugins</desc>
 
-    <group name="genre" plugin="10">
+    <group name="guide" plugin="10">
+        <desc>Add item to show the guide</desc>
+    </group>
+
+    <group name="directory" plugin="20">
+        <desc>
+            Add a directory item to the recorded files to the tv menu. The
+            plugin does nothing with the path to the directory is not set.
+        </desc>
+        <var name="path" type="str">
+            <desc>Directory where the recordings are stored</desc>
+        </var>
+    </group>
+
+    <group name="genre" plugin="30">
         <desc>Add item to browse the EPG by genre</desc>
     </group>
 

Added: trunk/ui/src/tv/plugins/directory.py
==============================================================================
--- (empty file)
+++ trunk/ui/src/tv/plugins/directory.py        Sat Feb 10 19:07:24 2007
@@ -0,0 +1,52 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# directory.py - Show directory with recorded shows
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2007 Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# -----------------------------------------------------------------------------
+
+# kaa imports
+import kaa.beacon
+
+# freevo imports
+from freevo.ui.config import config
+from freevo.ui.mainmenu import MainMenuPlugin
+from freevo.ui.menu import ActionItem
+from freevo.ui.directory import DirItem
+
+class PluginInterface(MainMenuPlugin):
+
+    def items(self, parent):
+        if config.tv.plugin.directory.path:
+            return [ ActionItem(_('Recorded Shows'), parent, self.browse) ]
+        return []
+
+    def browse(self, parent):
+        record_dir = kaa.beacon.get(config.tv.plugin.directory.path)
+        d = DirItem(record_dir, parent, type='tv')
+        d.browse()
+        

Copied: trunk/ui/src/tv/plugins/guide.py (from r9169, 
/trunk/ui/src/tv/tvguide.py)
==============================================================================
--- /trunk/ui/src/tv/tvguide.py (original)
+++ trunk/ui/src/tv/plugins/guide.py    Sat Feb 10 19:07:24 2007
@@ -6,11 +6,11 @@
 #
 # -----------------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
-# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+# Copyright (C) 2002 Krister Lagerstrom, 2003-2007 Dirk Meyer, et al.
 #
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -38,14 +38,35 @@
 import kaa.epg
 import kaa.notifier
 
+# freevo core imports
+import freevo.ipc
+
+# freevo imports
 from freevo.ui.event import *
-from freevo.ui.menu import Item, Menu
-from program import ProgramItem
+from freevo.ui.mainmenu import MainMenuPlugin
+from freevo.ui.menu import Menu, ActionItem
+from freevo.ui.tv.program import ProgramItem
+from freevo.ui.application import MessageWindow
+
+# get tvserver interface
+tvserver = freevo.ipc.Instance('freevo').tvserver
 
 # get logging object
 log = logging.getLogger('tv')
 
+class PluginInterface(MainMenuPlugin):
+
+    def items(self, parent):
+        return [ ActionItem(_('TV Guide'), parent, self.show) ]
+
+    def show(self, parent):
+        if not tvserver.epg.connected():
+            MessageWindow(_('TVServer not running')).show()
+            return
+        guide = TVGuide(self)
+        parent.pushmenu(guide)
 
+    
 class TVGuide(Menu):
     """
     TVGuide menu.
@@ -55,7 +76,6 @@
         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)
@@ -87,7 +107,6 @@
 
         if not timestamp:
             timestamp = self.current_time
-        print time.localtime(timestamp)
 
         log.info('channel: %s time %s', self.channel, timestamp)
         wait = kaa.notifier.YieldCallback()

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to