- add movie selector
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 29 Jul 2005 01:09:09 +0000 (01:09 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 29 Jul 2005 01:09:09 +0000 (01:09 +0000)
14 files changed:
keymap.xml
lib/python/Components/Makefile.am
lib/python/Components/MovieList.py [new file with mode: 0644]
lib/python/Components/__init__.py
lib/python/Screens/InfoBar.py
lib/python/Screens/Makefile.am
lib/python/Screens/MovieSelection.py [new file with mode: 0644]
lib/python/Screens/__init__.py
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h
lib/service/servicefs.cpp
lib/service/servicefs.h
skin.py

index dde32c9..7b9d0c6 100644 (file)
@@ -42,6 +42,7 @@
                <key id="KEY_MENU" mapto="mainMenu" flags="mr" />
                <key id="KEY_OK" mapto="toggleShow" flags="mr" />
                <key id="KEY_EXIT" mapto="hide" flags="mr" />
+               <key id="KEY_VIDEO" mapto="showMovies" flags="m" />
        </map>
        
        <map context="ChannelSelectActions">
                <key id="KEY_A" mapto="bouquet:" flags="m" />
        </map>
        <map context="OkCancelActions">
-               <key id="\x0a" mapto="ok" flags="mr" />
-               <key id="\x1b" mapto="cancel" flags="mr" />
+               <key id="\x0a" mapto="ok" flags="m" />
+               <key id="\x1b" mapto="cancel" flags="m" />
 
                <!-- use this on rcu, ok? -->
-               <key id="KEY_OK" mapto="ok" flags="mr" />
-               <key id="KEY_EXIT" mapto="cancel" flags="mr" />
+               <key id="KEY_OK" mapto="ok" flags="m" />
+               <key id="KEY_EXIT" mapto="cancel" flags="m" />
 
-               <key id="KEY_ENTER" mapto="ok" flags="mr" />
-               <key id="KEY_ESC" mapto="cancel" flags="mr" />
+               <key id="KEY_ENTER" mapto="ok" flags="m" />
+               <key id="KEY_ESC" mapto="cancel" flags="m" />
        </map>
        <map context="WindowActions">
                
index d9b3890..7d35f56 100644 (file)
@@ -6,4 +6,4 @@ install_DATA = \
        Clock.py HTMLSkin.py ServiceList.py VariableText.py                     \
        ConfigList.py Header.py ServiceName.py VariableValue.py                 \
        EventInfo.py Label.py ServiceScan.py VolumeBar.py                       \
-       GUIComponent.py MenuList.py TextInput.py __init__.py
+       GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py
diff --git a/lib/python/Components/MovieList.py b/lib/python/Components/MovieList.py
new file mode 100644 (file)
index 0000000..4144353
--- /dev/null
@@ -0,0 +1,89 @@
+from HTMLComponent import *
+from GUIComponent import *
+
+from enigma import eListboxPythonMultiContent, eListbox, gFont
+
+from enigma import eServiceReference, eServiceCenter, \
+       eServiceCenterPtr, iListableServicePtr, \
+       iStaticServiceInformationPtr
+
+
+
+RT_HALIGN_LEFT = 0
+RT_HALIGN_RIGHT = 1
+RT_HALIGN_CENTER = 2
+RT_HALIGN_BLOCK = 4
+
+RT_VALIGN_TOP = 0
+RT_VALIGN_CENTER = 8
+RT_VALIGN_BOTTOM = 16
+
+RT_WRAP = 32
+
+
+#
+# | name of movie              |
+#
+def MovieListEntry(serviceref, serviceHandler):
+       res = [ serviceref ]
+
+       info = iStaticServiceInformationPtr()
+
+       if serviceHandler.info(serviceref, info):
+               # ignore service which refuse to info
+               del info
+               return
+       
+       res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, info.getName(serviceref)))
+       res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "Toller Film"))
+       res.append((0, 50, 200, 20, 1, RT_HALIGN_LEFT, "Aufgenommen: irgendwann"))
+       res.append((200, 50, 200, 20, 1, RT_HALIGN_RIGHT, "1232MB"))
+       
+       return res
+
+class MovieList(HTMLComponent, GUIComponent):
+       def __init__(self, root):
+               GUIComponent.__init__(self)
+               self.l = eListboxPythonMultiContent()
+               self.load(root)
+               self.l.setList(self.list)
+               self.l.setFont(0, gFont("Arial", 30))
+               self.l.setFont(1, gFont("Arial", 18))
+       
+       def getCurrent(self):
+               return self.l.getCurrentSelection()
+       
+       def GUIcreate(self, parent):
+               self.instance = eListbox(parent)
+               self.instance.setContent(self.l)
+               self.instance.setItemHeight(75)
+       
+       def GUIdelete(self):
+               self.instance.setContent(None)
+               self.instance = None
+
+       def load(self, root):
+               # this lists our root service, then building a 
+               # nice list
+               
+               self.list = [ ]
+               
+               serviceHandler = eServiceCenterPtr()
+               eServiceCenter.getInstance(serviceHandler)
+               list = iListableServicePtr()
+               
+               if serviceHandler.list(root, list):
+                       raise "listing of movies failed"
+
+               movieList = [ ]
+               while 1:
+                       s = eServiceReference()
+                       if list.getNext(s):
+                               del s
+                               del list
+                               break
+                       movieList.append(s)
+               
+               # now process them...
+               for ref in movieList:
+                       self.list.append(MovieListEntry(ref, serviceHandler))
index d7cd406..9f15abd 100644 (file)
@@ -3,5 +3,5 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
        "GUIComponent", "GUISkin", "HTMLComponent", "HTMLSkin", "Header",
        "Label", "MenuList", "PerServiceDisplay", "ProgressBar", "ServiceList",
        "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar",
-       "components", "config", "TimerList", "TimeInput" ]
+       "components", "config", "TimerList", "TimeInput", "MovieList" ]
 
index f89eba0..be6b65c 100644 (file)
@@ -7,6 +7,7 @@ from Components.ServiceName import ServiceName
 from Components.EventInfo import EventInfo
 
 from Screens.MessageBox import MessageBox
+from Screens.MovieSelection import MovieSelection
 
 from enigma import *
 
@@ -31,7 +32,8 @@ class InfoBar(Screen):
                                "zapDown": self.zapDown,
                                "instantRecord": self.instantRecord,
                                "hide": self.hide,
-                               "toggleShow": self.toggleShow
+                               "toggleShow": self.toggleShow,
+                               "showMovies": self.showMovies,
                        })
 #              self["okbutton"] = Button("mainMenu", [self.mainMenu])
                
@@ -100,4 +102,6 @@ class InfoBar(Screen):
                                                epg = ev
                        # fix me, description. 
                        self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg, "instant record")
-
+       
+       def showMovies(self):
+               self.session.open(MovieSelection)
index e9eeec2..0da3f51 100644 (file)
@@ -3,4 +3,4 @@ installdir = $(LIBDIR)/enigma2/python/Screens
 install_DATA = \
        ChannelSelection.py ClockDisplay.py ConfigMenu.py InfoBar.py Menu.py    \
        MessageBox.py ScartLoopThrough.py Screen.py ServiceScan.py TimerEdit.py \
-       __init__.py
+       MovieSelection.py __init__.py
diff --git a/lib/python/Screens/MovieSelection.py b/lib/python/Screens/MovieSelection.py
new file mode 100644 (file)
index 0000000..f5f2652
--- /dev/null
@@ -0,0 +1,29 @@
+from Screen import Screen
+from Components.Button import Button
+from Components.ServiceList import ServiceList
+from Components.ActionMap import ActionMap
+from Components.MovieList import MovieList
+
+from enigma import eServiceReference
+
+class MovieSelection(Screen):
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               
+               self.movemode = False
+               self.bouquet_mark_edit = False
+               
+               self["list"] = MovieList(eServiceReference("2:0:1:0:0:0:0:0:0:0:/"))
+               
+               #self["okbutton"] = Button("ok", [self.channelSelected])
+               
+               self["actions"] = ActionMap(["OkCancelActions"], 
+                       {
+                               "cancel": self.close,
+                               "ok": self.movieSelected,
+                       })
+               self["actions"].csel = self
+
+       def movieSelected(self):
+#              self.session.nav.playService(self["list"].getCurrent())
+               self.close()
index c91f5f5..d24aa00 100644 (file)
@@ -1,4 +1,4 @@
 __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu", 
-       "InfoBar", "MessageBox", "Menu", "ScartLoopThrough", "Screen", "ServiceScan",
+       "InfoBar", "MessageBox", "Menu", "MovieSelection", 
+       "ScartLoopThrough", "Screen", "ServiceScan",
        "TimerEdit"]
-
index 4592a97..7e24f9c 100644 (file)
@@ -208,7 +208,11 @@ TEMPLATE_TYPEDEF(ePtr<iRecordableService>, iRecordableServicePtr);
 class iListableService: public iObject
 {
 public:
+               /* legacy interface: get a list */
        virtual RESULT getContent(std::list<eServiceReference> &list)=0;
+       
+               /* new, shiny interface: streaming. */
+       virtual RESULT getNext(eServiceReference &ptr)=0;
 };
 
 TEMPLATE_TYPEDEF(ePtr<iListableService>, iListableServicePtr);
index a32ce32..5bd25f6 100644 (file)
@@ -78,6 +78,12 @@ RESULT eDVBServiceList::getContent(std::list<eServiceReference> &list)
        return 0;
 }
 
+RESULT eDVBServiceList::getNext(eServiceReference &)
+{
+               /* implement me */
+       return -1;
+}
+
 RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
 {
        ePtr<eDVBService> service;
index e9489cd..5c75043 100644 (file)
@@ -34,6 +34,7 @@ private:
 public:
        virtual ~eDVBServiceList();
        RESULT getContent(std::list<eServiceReference> &list);
+       RESULT getNext(eServiceReference &ptr);
 };
 
 class eDVBServicePlay: public iPlayableService, public Object, public iServiceInformation
index 9db8502..739dd0a 100644 (file)
@@ -81,6 +81,7 @@ DEFINE_REF(eServiceFS);
 
 eServiceFS::eServiceFS(const char *path): path(path)
 {
+       m_list_valid = 0;
 }
 
 eServiceFS::~eServiceFS()
@@ -132,4 +133,22 @@ RESULT eServiceFS::getContent(std::list<eServiceReference> &list)
        return 0;
 }
 
+RESULT eServiceFS::getNext(eServiceReference &ptr)
+{
+       if (!m_list_valid)
+       {
+               m_list_valid = 1;
+               int res = getContent(m_list);
+               if (res)
+                       return res;
+       }
+       
+       if (!m_list.size())
+               return -ERANGE;
+       
+       ptr = m_list.front();
+       m_list.pop_front();
+       return 0;
+}
+
 eAutoInitPtr<eServiceFactoryFS> init_eServiceFactoryFS(eAutoInitNumbers::service+1, "eServiceFactoryFS");
index 61fcb4a..e87b53a 100644 (file)
@@ -27,10 +27,14 @@ private:
        std::string path;
        friend class eServiceFactoryFS;
        eServiceFS(const char *path);
+       
+       int m_list_valid;
+       std::list<eServiceReference> m_list;
 public:
        virtual ~eServiceFS();
        
        RESULT getContent(std::list<eServiceReference> &list);
+       RESULT getNext(eServiceReference &ptr);
 };
 
 #endif
diff --git a/skin.py b/skin.py
index ab86832..aba7fbf 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -92,7 +92,7 @@ dom = xml.dom.minidom.parseString(
                        <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;26" backgroundColor="dark" />
 <!--                   <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
                </screen>
-               <screen name="ChannelSelection" position="90,100" size="560,420" title="Channel Selection">
+               <screen name="ChannelSelection" position="90,100" size="560,420" title="Channel Selection">
                        <widget name="list" position="0,50" size="560,340" />
 <!--                   <widget name="okbutton" position="340,50" size="140,30" />-->
                        <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" />
@@ -100,6 +100,9 @@ dom = xml.dom.minidom.parseString(
                        <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" />
                        <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" />
                </screen>
+               <screen name="MovieSelection" position="150,100" size="400,420" title="Select-a-movie">
+                       <widget name="list" position="0,50" size="400,300" />
+               </screen>
                <screen name="ServiceScan" position="150,100" size="300,200" title="Service Scan">
                        <widget name="scan_progress" position="10,10" size="280,50" />
                        <widget name="scan_state" position="10,60" size="280,30" />