/* todo: make a real infrastructure here! */
RESULT SwigFromPython(ePtr<gPixmap> &res, PyObject *obj);
+eListboxPythonMultiContent::eListboxPythonMultiContent()
+ :m_buildFunc(0)
+{
+}
+
+eListboxPythonMultiContent::~eListboxPythonMultiContent()
+{
+ if (m_buildFunc)
+ Py_DECREF(m_buildFunc);
+}
+
void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
{
eRect itemrect(offset, m_itemsize);
style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
painter.clear();
+ PyObject *items=0;
+
if (m_list && cursorValid())
{
- PyObject *items = PyList_GET_ITEM(m_list, m_cursor); // borrowed reference!
-
+ items = PyList_GET_ITEM(m_list, m_cursor); // borrowed reference!
+
+ if (m_buildFunc)
+ {
+ if (PyCallable_Check(m_buildFunc)) // when we have a buildFunc then call it
+ {
+ if (PyTuple_Check(items))
+ items = PyObject_CallObject(m_buildFunc, items);
+ else
+ eDebug("items is no tuple");
+ }
+ else
+ eDebug("buildfunc is not callable");
+ }
+
if (!items)
{
eDebug("eListboxPythonMultiContent: error getting item %d", m_cursor);
style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
error_out:
+ if (m_buildFunc && PyCallable_Check(m_buildFunc) && items)
+ Py_DECREF(items);
+
painter.clippop();
}
+void eListboxPythonMultiContent::setBuildFunc(PyObject *cb)
+{
+ if (m_buildFunc)
+ Py_DECREF(m_buildFunc);
+ m_buildFunc=cb;
+ if (cb)
+ Py_INCREF(m_buildFunc);
+}
+
int eListboxPythonMultiContent::currentCursorSelectable()
{
- /* each list-entry is a list of tuples. if the first of these is none, it's not selectable */
+ /* each list-entry is a list of tuples. if the first of these is none, it's not selectable */
if (m_list && cursorValid())
{
PyObject *item = PyList_GET_ITEM(m_list, m_cursor);
if (PyList_Check(item))
- if (PyList_Check(item))
- {
- item = PyList_GET_ITEM(item, 0);
- if (item != Py_None)
- return 1;
- }
+ {
+ item = PyList_GET_ITEM(item, 0);
+ if (item != Py_None)
+ return 1;
+ }
+ else if (m_buildFunc && PyCallable_Check(m_buildFunc))
+ // FIXME .. how we can detect non selectable entrys when we have a buildFunc callback
+ return 1;
}
return 0;
}
self.l = eListboxEPGContent()
else:
self.l = eListboxPythonMultiContent()
+ if type == EPG_TYPE_SINGLE:
+ self.l.setBuildFunc(self.buildSingleEntry)
+ else:
+ self.l.setBuildFunc(self.buildMultiEntry)
self.epgcache = eEPGCache.getInstance()
def getEventFromId(self, service, eventid):
def getCurrentChangeCount(self):
if self.type == EPG_TYPE_SINGLE:
return 0
- return self.l.getCurrentSelection()[0][0]
+ return self.l.getCurrentSelection()[0]
def getCurrent(self):
if self.type == EPG_TYPE_SINGLE:
eventid = self.l.getCurrentSelection()[0]
evt = self.getEventFromId(self.service, eventid)
else:
- tmp = self.l.getCurrentSelection()[0]
- eventid = tmp[1]
- service = ServiceReference(tmp[2])
+ tmp = self.l.getCurrentSelection()
+ eventid = tmp[2]
+ service = ServiceReference(tmp[1])
event = self.getEventFromId(service, eventid)
evt = ( event, service )
return evt
w = width/10*5;
self.descr_rect = Rect(xpos, 0, width, height)
- def buildSingleEntry(self, eventId, beginTime, duration, EventName, rec=False):
+ def buildSingleEntry(self, eventId, beginTime, duration, EventName):
+ rec=(self.timer.isInTimer(eventid=eventId, begin=beginTime, duration=duration, service=self.service) > 0)
r1=self.datetime_rect
r2=self.descr_rect
- res = [ eventId ]
+ res = [ None ] # no private data needed
t = localtime(beginTime)
res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4])))
if rec:
r2=self.progress_rect
r3=self.descr_rect
r4=self.start_end_rect
- res = [ (changecount, eventId, service, begTime, duration) ]
+ res = [ None ] # no private data needed
re = compile('\xc2\x86.*?\xc2\x87')
list = re.findall(sname)
if len(list):
def fillMultiEPG(self, services):
t = time()
- test = [ 'RIBDTCN' ]
+ test = [ '0RIBDTCN' ]
for service in services:
tuple = ( service.ref.toString(), 0 )
test.append( tuple )
-# self.list = self.queryEPG(test, self.buildMultiEntry)
- tmp = self.queryEPG(test)
- self.list = [ ]
- for x in tmp:
- self.list.append(self.buildMultiEntry(0, x[0], x[1], x[2], x[3], x[4], x[5], x[6]))
+ self.list = self.queryEPG(test)
self.l.setList(self.list)
print time() - t
self.selectionChanged()
t = time()
test = [ 'RIBDTCN' ]
for x in self.list:
- data = x[0]
- service = data[2]
- begTime = data[3]
- duration = data[4]
+ service = x[1]
+ begTime = x[3]
+ duration = x[4]
if begTime is None:
begTime = 0
test.append((service, direction, begTime))
-# self.list = self.queryEPG(test, self.buildMultiEntry)
tmp = self.queryEPG(test)
cnt=0
for x in tmp:
- changecount = self.list[cnt][0][0] + direction
+ changecount = self.list[cnt][0] + direction
if changecount >= 0:
if x[2] is not None:
- self.list[cnt]=self.buildMultiEntry(changecount, x[0], x[1], x[2], x[3], x[4], x[5], x[6])
+ self.list[cnt]=(changecount, x[0], x[1], x[2], x[3], x[4], x[5], x[6])
cnt+=1
self.l.setList(self.list)
print time() - t
else:
self.service = service
test = [ 'IBDT', (service.ref.toString(), 0, -1, -1) ]
-# self.list = self.queryEPG(test, self.buildSingleEntry)
- tmp = self.queryEPG(test)
- self.list = [ ]
- for x in tmp:
- self.list.append(self.buildSingleEntry(x[0], x[1], x[2], x[3], (self.timer.isInTimer(eventid=x[0], begin=x[1], duration=x[2], service=service) > 0)))
-# self.list.append(self.buildSingleEntry(refstr, x[0], x[1], x[2], x[3]))
- self.l.setList(self.list)
+ self.l.setList(self.queryEPG(test))
print time() - t
self.selectionChanged()