MyTube: add option to disable msg "load new entries"
[enigma2-plugins.git] / mytube / src / MyTubeSearch.py
1 from enigma import eListboxPythonMultiContent, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, gFont, eTimer
2 from MyTubeService import GoogleSuggestions
3 from Screens.Screen import Screen
4 from Screens.LocationBox import MovieLocationBox
5 from Components.config import config, ConfigText, getConfigListEntry
6 from Components.config import KEY_DELETE, KEY_BACKSPACE, KEY_ASCII, KEY_TIMEOUT
7 from Components.ConfigList import ConfigListScreen
8 from Components.ActionMap import ActionMap
9 from Components.Button import Button
10 from Components.Label import Label
11 from Components.Sources.List import List
12 from Components.MultiContent import MultiContentEntryText 
13 from Components.Task import job_manager
14 from Tools.Directories import resolveFilename, SCOPE_HDD
15
16 from threading import Thread
17 from threading import Condition
18 from xml.etree.cElementTree import parse as cet_parse
19 from StringIO import StringIO
20 #import urllib
21 from urllib import FancyURLopener
22
23 class MyOpener(FancyURLopener):
24         version = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12'
25
26 class ConfigTextWithGoogleSuggestions(ConfigText):
27         class SuggestionsThread(Thread):
28                 def __init__(self, suggestionsService):
29                         Thread.__init__(self)
30                         self.suggestionsService = suggestionsService
31                         self.value = None
32                         self.running = True
33                         self.condition = Condition()
34
35                 def run(self):
36                         while self.running:
37                                 self.condition.acquire()
38                                 if self.value is None:
39                                         self.condition.wait()
40                                 value = self.value
41                                 self.value = None
42                                 self.condition.release()
43                                 if value is not None:
44                                         self.suggestionsService.getSuggestions(value)
45
46                 def stop(self):
47                         self.running = False
48                         self.condition.acquire()
49                         self.condition.notify()
50                         self.condition.release()
51                         self.join()
52
53                 def getSuggestions(self, value):
54                         self.condition.acquire()
55                         self.value = value
56                         self.condition.notify()
57                         self.condition.release()
58
59         def __init__(self, default = "", fixed_size = True, visible_width = False, threaded = False):
60                 ConfigText.__init__(self, default, fixed_size, visible_width)
61                 self.suggestions = GoogleSuggestions(self.propagateSuggestions, ds = "yt", hl = "en")
62                 self.suggestionsThread = None
63                 self.threaded = threaded
64                 self.suggestionsListActivated = False
65
66         def propagateSuggestions(self, suggestionsList):
67                 if self.suggestionsWindow:
68                         self.suggestionsWindow.update(suggestionsList)
69
70         def getSuggestions(self):
71                 if self.suggestionsThread is not None:
72                         self.suggestionsThread.getSuggestions(self.value)
73                 else:
74                         self.suggestions.getSuggestions(self.value)
75
76         def handleKey(self, key):
77                 if not self.suggestionsListActivated:
78                         ConfigText.handleKey(self, key)
79                         if key in [KEY_DELETE, KEY_BACKSPACE, KEY_ASCII, KEY_TIMEOUT]:
80                                 self.getSuggestions()
81
82         def onSelect(self, session):
83                 if self.threaded:
84                         if self.suggestionsThread is not None:
85                                 self.suggestionsThread.stop()
86                         self.suggestionsThread = ConfigTextWithGoogleSuggestions.SuggestionsThread(self.suggestions)
87                         self.suggestionsThread.start()
88                 else:
89                         self.suggestionsThread = None
90                 ConfigText.onSelect(self, session)
91                 if session is not None:
92                         self.suggestionsWindow = session.instantiateDialog(MyTubeSuggestionsListScreen, self)
93                         self.suggestionsWindow.deactivate()
94                         self.suggestionsWindow.hide()
95                 self.suggestions.getSuggestions(self.value)
96
97         def onDeselect(self, session):
98                 if self.suggestionsThread is not None:
99                         self.suggestionsThread.stop()
100                 ConfigText.onDeselect(self, session)
101                 if self.suggestionsWindow:
102                         session.deleteDialog(self.suggestionsWindow)
103                         self.suggestionsWindow = None
104
105         def suggestionListUp(self):
106                 if self.suggestionsWindow.getlistlenght() > 0:
107                         self.value = self.suggestionsWindow.up()
108
109         def suggestionListDown(self):
110                 if self.suggestionsWindow.getlistlenght() > 0:
111                         self.value = self.suggestionsWindow.down()
112
113         def suggestionListPageDown(self):
114                 if self.suggestionsWindow.getlistlenght() > 0:
115                         self.value = self.suggestionsWindow.pageDown()
116
117         def suggestionListPageUp(self):
118                 if self.suggestionsWindow.getlistlenght() > 0:
119                         self.value = self.suggestionsWindow.pageUp()
120
121         def activateSuggestionList(self):
122                 ret = False
123                 if self.suggestionsWindow is not None and self.suggestionsWindow.shown:
124                         self.tmpValue = self.value
125                         self.value = self.suggestionsWindow.activate()
126                         self.allmarked = False
127                         self.suggestionsListActivated = True
128                         ret = True
129                 return ret
130
131         def deactivateSuggestionList(self):
132                 ret = False
133                 if self.suggestionsWindow is not None:
134                         self.suggestionsWindow.deactivate()
135                         self.getSuggestions()
136                         self.allmarked = True
137                         self.suggestionsListActivated = False
138                         ret = True
139                 return ret
140
141         def cancelSuggestionList(self):
142                 self.value = self.tmpValue
143                 return self.deactivateSuggestionList()
144
145         def enableSuggestionSelection(self,value):
146                 if self.suggestionsWindow is not None:
147                         self.suggestionsWindow.enableSelection(value)
148
149 default = resolveFilename(SCOPE_HDD)
150 tmp = config.movielist.videodirs.value
151 if default not in tmp:
152         tmp.append(default)
153
154 class MyTubeSuggestionsListScreen(Screen):
155         skin = """
156                 <screen name="MyTubeSuggestionsListScreen" title="MyTube - Search" position="60,93" zPosition="6" size="610,160" flags="wfNoBorder" >
157                         <ePixmap position="0,0" zPosition="-1" size="610,160" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MyTube/suggestions_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
158                         <widget source="suggestionslist" render="Listbox" position="10,5" zPosition="7" size="580,150" scrollbarMode="showOnDemand" transparent="1" >
159                                 <convert type="TemplatedMultiContent">
160                                         {"template": [
161                                                         MultiContentEntryText(pos = (0, 1), size = (340, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name
162                                                         MultiContentEntryText(pos = (350, 1), size = (180, 24), font=1, flags = RT_HALIGN_RIGHT, text = 1), # index 1 are the rtesults
163                                                 ],
164                                         "fonts": [gFont("Regular", 22),gFont("Regular", 18)],
165                                         "itemHeight": 25
166                                         }
167                                 </convert>
168                         </widget>
169                 </screen>"""
170                 
171         def __init__(self, session, configTextWithGoogleSuggestion):
172                 Screen.__init__(self, session)
173                 self.activeState = False
174                 self.list = []
175                 self.suggestlist = []
176                 self["suggestionslist"] = List(self.list)
177                 self.configTextWithSuggestion = configTextWithGoogleSuggestion
178
179         def update(self, suggestions):
180                 if suggestions and len(suggestions) > 0:
181                         if not self.shown:
182                                 self.show()
183                         suggestions_tree = cet_parse(StringIO(suggestions)).getroot()
184                         if suggestions_tree:
185                                 self.list = []
186                                 self.suggestlist = []
187                                 for suggestion in suggestions_tree.findall("CompleteSuggestion"):
188                                         name = None
189                                         numresults = None
190                                         for subelement in suggestion:
191                                                 if subelement.attrib.has_key('data'):
192                                                         name = subelement.attrib['data'].encode("UTF-8")
193                                                 if subelement.attrib.has_key('int'):
194                                                         numresults = subelement.attrib['int']
195                                                 if name and numresults:
196                                                         self.suggestlist.append((name, numresults ))
197                                 if len(self.suggestlist):
198                                         self.suggestlist.sort(key=lambda x: int(x[1]))
199                                         self.suggestlist.reverse()
200                                         for entry in self.suggestlist:
201                                                 self.list.append((entry[0], entry[1] + _(" Results") ))
202                                         self["suggestionslist"].setList(self.list)
203                                         self["suggestionslist"].setIndex(0)
204                 else:
205                         self.hide()
206
207         def getlistlenght(self):
208                 return len(self.list)
209
210         def up(self):
211                 print "up"
212                 if self.list and len(self.list) > 0:
213                         self["suggestionslist"].selectPrevious()
214                         return self.getSelection()
215
216         def down(self):
217                 print "down"
218                 if self.list and len(self.list) > 0:
219                         self["suggestionslist"].selectNext()
220                         return self.getSelection()
221         
222         def pageUp(self):
223                 print "up"
224                 if self.list and len(self.list) > 0:
225                         self["suggestionslist"].selectPrevious()
226                         return self.getSelection()
227
228         def pageDown(self):
229                 print "down"
230                 if self.list and len(self.list) > 0:
231                         self["suggestionslist"].selectNext()
232                         return self.getSelection()
233
234         def activate(self):
235                 print "activate"
236                 self.activeState = True
237                 return self.getSelection()
238
239         def deactivate(self):
240                 print "deactivate"
241                 self.activeState = False
242                 return self.getSelection()
243
244         def getSelection(self):
245                 if self["suggestionslist"].getCurrent() is None:
246                         return None
247                 print self["suggestionslist"].getCurrent()[0]
248                 return self["suggestionslist"].getCurrent()[0]
249
250         def enableSelection(self,value):
251                 self["suggestionslist"].selectionEnabled(value)
252
253
254 class MyTubeSettingsScreen(Screen, ConfigListScreen):
255         skin = """
256                 <screen name="MyTubeSettingsScreen" flags="wfNoBorder" position="0,0" size="720,576" title="MyTube - Settings" >
257                         <ePixmap position="0,0" zPosition="-1" size="720,576" pixmap="~/mytubemain_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
258                         <widget name="title" position="60,50" size="600,50" zPosition="5" valign="center" halign="left" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
259                         <widget name="config" zPosition="2" position="60,120" size="610,370" scrollbarMode="showOnDemand" transparent="1" />
260
261                         <ePixmap position="100,500" size="100,40" zPosition="0" pixmap="~/plugin.png" alphatest="on" transparent="1" />
262                         <ePixmap position="220,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
263                         <ePixmap position="360,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
264                         <widget name="key_red" position="220,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
265                         <widget name="key_green" position="360,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
266                 </screen>"""
267
268         def __init__(self, session, plugin_path):
269                 Screen.__init__(self, session)
270                 self.skin_path = plugin_path
271                 self.session = session
272
273                 self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "MediaPlayerActions"],
274                 {
275                         "ok": self.keyOK,
276                         "back": self.keyCancel,
277                         "red": self.keyCancel,
278                         "green": self.keySave,
279                         "up": self.keyUp,
280                         "down": self.keyDown,
281                         "left": self.keyLeft,
282                         "right": self.keyRight,
283                 }, -1)
284                 
285                 self["key_red"] = Button(_("Close"))
286                 self["key_green"] = Button(_("Save"))
287                 self["title"] = Label()
288                 
289                 self.searchContextEntries = []
290                 self.ProxyEntry = None
291                 self.loadFeedEntry = None
292                 self.VideoDirname = None
293                 ConfigListScreen.__init__(self, self.searchContextEntries, session)
294                 self.createSetup()
295                 self.onLayoutFinish.append(self.layoutFinished)
296                 self.onShown.append(self.setWindowTitle)
297
298         def layoutFinished(self):
299                 self["title"].setText(_("MyTubePlayer settings"))
300
301         def setWindowTitle(self):
302                 self.setTitle(_("MyTubePlayer settings"))
303
304         def createSetup(self):
305                 self.searchContextEntries = []
306                 self.searchContextEntries.append(getConfigListEntry(_("Display search results by:"), config.plugins.mytube.search.orderBy))
307                 self.searchContextEntries.append(getConfigListEntry(_("Search restricted content:"), config.plugins.mytube.search.racy))
308                 self.searchContextEntries.append(getConfigListEntry(_("Search category:"), config.plugins.mytube.search.categories))
309                 self.searchContextEntries.append(getConfigListEntry(_("Search region:"), config.plugins.mytube.search.lr))
310                 self.loadFeedEntry = getConfigListEntry(_("Load feed on startup:"), config.plugins.mytube.general.loadFeedOnOpen)
311                 self.searchContextEntries.append(self.loadFeedEntry)
312                 if config.plugins.mytube.general.loadFeedOnOpen.value:
313                         self.searchContextEntries.append(getConfigListEntry(_("Start with following feed:"), config.plugins.mytube.general.startFeed))
314                 self.searchContextEntries.append(getConfigListEntry(_("Videoplayer stop/exit behavior:"), config.plugins.mytube.general.on_movie_stop))
315                 self.searchContextEntries.append(getConfigListEntry(_("Videobrowser exit behavior:"), config.plugins.mytube.general.on_exit))
316                 """self.ProxyEntry = getConfigListEntry(_("Use HTTP Proxy Server:"), config.plugins.mytube.general.useHTTPProxy)
317                 self.searchContextEntries.append(self.ProxyEntry)
318                 if config.plugins.mytube.general.useHTTPProxy.value:
319                         self.searchContextEntries.append(getConfigListEntry(_("HTTP Proxy Server IP:"), config.plugins.mytube.general.ProxyIP))
320                         self.searchContextEntries.append(getConfigListEntry(_("HTTP Proxy Server Port:"), config.plugins.mytube.general.ProxyPort))"""
321                 # disabled until i have time for some proper tests      
322                 self.VideoDirname = getConfigListEntry(_("Download location"), config.plugins.mytube.general.videodir)
323                 if config.usage.setup_level.index >= 2: # expert+
324                         self.searchContextEntries.append(self.VideoDirname)
325                 self.searchContextEntries.append(getConfigListEntry(_("Clear history on Exit:"), config.plugins.mytube.general.clearHistoryOnClose))
326                 self.searchContextEntries.append(getConfigListEntry(_("Ask to load new entries"), config.plugins.mytube.general.AutoLoadFeeds))
327
328                 self["config"].list = self.searchContextEntries
329                 self["config"].l.setList(self.searchContextEntries)
330                 if not self.selectionChanged in self["config"].onSelectionChanged:
331                         self["config"].onSelectionChanged.append(self.selectionChanged)
332
333         def selectionChanged(self):
334                 current = self["config"].getCurrent()
335
336         def newConfig(self):
337                 print "newConfig", self["config"].getCurrent()
338                 if self["config"].getCurrent() == self.loadFeedEntry:
339                         self.createSetup()
340
341         def keyOK(self):
342                 cur = self["config"].getCurrent()
343                 if config.usage.setup_level.index >= 2 and cur == self.VideoDirname:
344                         self.session.openWithCallback(
345                                 self.pathSelected,
346                                 MovieLocationBox,
347                                 _("Choose target folder"),
348                                 config.plugins.mytube.general.videodir.value,
349                                 minFree = 100 # We require at least 100MB free space
350                         )
351                 else:
352                         self.keySave()
353
354         def pathSelected(self, res):
355                 if res is not None:
356                         if config.movielist.videodirs.value != config.plugins.mytube.general.videodir.choices:
357                                 config.plugins.mytube.general.videodir.setChoices(config.movielist.videodirs.value, default=res)
358                         config.plugins.mytube.general.videodir.value = res
359
360         def keyUp(self):
361                 self["config"].instance.moveSelection(self["config"].instance.moveUp)
362
363         def keyDown(self):
364                 self["config"].instance.moveSelection(self["config"].instance.moveDown)
365
366         def keyRight(self):
367                 ConfigListScreen.keyRight(self)
368                 self.newConfig()
369
370         def keyLeft(self):
371                 ConfigListScreen.keyLeft(self)
372                 self.newConfig()
373
374         def keyCancel(self):
375                 print "cancel"
376                 for x in self["config"].list:
377                         x[1].cancel()
378                 self.close()    
379
380         def keySave(self):
381                 print "saving"
382                 config.plugins.mytube.search.orderBy.save()
383                 config.plugins.mytube.search.racy.save()
384                 config.plugins.mytube.search.categories.save()
385                 config.plugins.mytube.search.lr.save()
386                 config.plugins.mytube.general.loadFeedOnOpen.save()
387                 config.plugins.mytube.general.startFeed.save()
388                 config.plugins.mytube.general.on_movie_stop.save()
389                 config.plugins.mytube.general.on_exit.save()
390                 config.plugins.mytube.general.videodir.save()
391                 config.plugins.mytube.general.clearHistoryOnClose.save()
392                 config.plugins.mytube.general.AutoLoadFeeds.save()
393                 if config.plugins.mytube.general.clearHistoryOnClose.value:
394                         config.plugins.mytube.general.history.value = ""
395                         config.plugins.mytube.general.history.save()
396                 #config.plugins.mytube.general.useHTTPProxy.save()
397                 #config.plugins.mytube.general.ProxyIP.save()
398                 #config.plugins.mytube.general.ProxyPort.save()
399                 for x in self["config"].list:
400                         x[1].save()
401                 config.plugins.mytube.general.save()
402                 config.plugins.mytube.search.save()
403                 config.plugins.mytube.save()
404                 """if config.plugins.mytube.general.useHTTPProxy.value is True:
405                         proxy = {'http': 'http://'+str(config.plugins.mytube.general.ProxyIP.getText())+':'+str(config.plugins.mytube.general.ProxyPort.value)}
406                         self.myopener = MyOpener(proxies=proxy)
407                         urllib.urlopen = MyOpener(proxies=proxy).open
408                 else:
409                         self.myopener = MyOpener()
410                         urllib.urlopen = MyOpener().open"""
411                 self.close()
412
413
414 class MyTubeTasksScreen(Screen):
415         skin = """
416                 <screen name="MyTubeTasksScreen" flags="wfNoBorder" position="0,0" size="720,576" title="MyTube - Tasks" >
417                         <ePixmap position="0,0" zPosition="-1" size="720,576" pixmap="~/mytubemain_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
418                         <widget name="title" position="60,50" size="600,50" zPosition="5" valign="center" halign="left" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
419                         <widget source="tasklist" render="Listbox" position="60,120" size="610,370" zPosition="7" scrollbarMode="showOnDemand" transparent="1" >
420                                 <convert type="TemplatedMultiContent">
421                                         {"template": [
422                                                         MultiContentEntryText(pos = (0, 1), size = (200, 24), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the name
423                                                         MultiContentEntryText(pos = (210, 1), size = (150, 24), font=1, flags = RT_HALIGN_RIGHT, text = 2), # index 2 is the state
424                                                         MultiContentEntryProgress(pos = (370, 1), size = (100, 24), percent = -3), # index 3 should be progress 
425                                                         MultiContentEntryText(pos = (480, 1), size = (100, 24), font=1, flags = RT_HALIGN_RIGHT, text = 4), # index 4 is the percentage
426                                                 ],
427                                         "fonts": [gFont("Regular", 22),gFont("Regular", 18)],
428                                         "itemHeight": 25
429                                         }
430                                 </convert>
431                         </widget>
432                         <ePixmap position="100,500" size="100,40" zPosition="0" pixmap="~/plugin.png" alphatest="on" transparent="1" />
433                         <ePixmap position="220,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
434                         <widget name="key_red" position="220,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
435                 </screen>"""
436
437         def __init__(self, session, plugin_path, tasklist):
438                 Screen.__init__(self, session)
439                 self.skin_path = plugin_path
440                 self.session = session
441                 self.tasklist = tasklist
442                 self["tasklist"] = List(self.tasklist)
443                 
444                 self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions", "MediaPlayerActions"],
445                 {
446                         "ok": self.keyOK,
447                         "back": self.keyCancel,
448                         "red": self.keyCancel,
449                 }, -1)
450                 
451                 self["key_red"] = Button(_("Close"))
452                 self["title"] = Label()
453                 
454                 self.onLayoutFinish.append(self.layoutFinished)
455                 self.onShown.append(self.setWindowTitle)
456                 self.onClose.append(self.__onClose)
457                 self.Timer = eTimer()
458                 self.Timer.callback.append(self.TimerFire)
459                 
460         def __onClose(self):
461                 del self.Timer
462
463         def layoutFinished(self):
464                 self["title"].setText(_("MyTubePlayer active video downloads"))
465                 self.Timer.startLongTimer(2)
466
467         def TimerFire(self):
468                 self.Timer.stop()
469                 self.rebuildTaskList()
470         
471         def rebuildTaskList(self):
472                 self.tasklist = []
473                 for job in job_manager.getPendingJobs():
474                         self.tasklist.append((job,job.name,job.getStatustext(),int(100*job.progress/float(job.end)) ,str(100*job.progress/float(job.end)) + "%" ))
475                 self['tasklist'].setList(self.tasklist)
476                 self['tasklist'].updateList(self.tasklist)
477                 self.Timer.startLongTimer(2)
478
479         def setWindowTitle(self):
480                 self.setTitle(_("MyTubePlayer active video downloads"))
481
482         def keyOK(self):
483                 current = self["tasklist"].getCurrent()
484                 print current
485                 if current:
486                         job = current[0]
487                         from Screens.TaskView import JobView
488                         self.session.openWithCallback(self.JobViewCB, JobView, job)
489         
490         def JobViewCB(self, why):
491                 print "WHY---",why
492
493         def keyCancel(self):
494                 self.close()    
495
496         def keySave(self):
497                 self.close()
498
499
500 class MyTubeHistoryScreen(Screen):
501         skin = """
502                 <screen name="MyTubeHistoryScreen" position="60,93" zPosition="6" size="610,160" flags="wfNoBorder" title="MyTube - History">
503                         <ePixmap position="0,0" zPosition="-1" size="610,160" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/MyTube/suggestions_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
504                         <widget source="historylist" render="Listbox" position="10,5" zPosition="7" size="580,150" scrollbarMode="showOnDemand" transparent="1" >
505                                 <convert type="TemplatedMultiContent">
506                                         {"template": [
507                                                         MultiContentEntryText(pos = (0, 1), size = (340, 24), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the name
508                                                 ],
509                                         "fonts": [gFont("Regular", 22),gFont("Regular", 18)],
510                                         "itemHeight": 25
511                                         }
512                                 </convert>
513                         </widget>
514                 </screen>"""
515
516         def __init__(self, session):
517                 Screen.__init__(self, session)
518                 self.session = session
519                 self.historylist = []
520                 print "self.historylist",self.historylist
521                 self["historylist"] = List(self.historylist)
522                 self.activeState = False
523                 
524         def activate(self):
525                 print "activate"
526                 self.activeState = True
527                 self.history = config.plugins.mytube.general.history.value.split(',')
528                 if self.history[0] == '':
529                         del self.history[0]
530                 print "self.history",self.history
531                 self.historylist = []
532                 for entry in self.history:
533                         self.historylist.append(( str(entry),))
534                 self["historylist"].setList(self.historylist)
535                 self["historylist"].updateList(self.historylist)
536
537         def deactivate(self):
538                 print "deactivate"
539                 self.activeState = False
540
541         def status(self):
542                 print self.activeState
543                 return self.activeState
544         
545         def getSelection(self):
546                 if self["historylist"].getCurrent() is None:
547                         return None
548                 print self["historylist"].getCurrent()[0]
549                 return self["historylist"].getCurrent()[0]
550
551         def up(self):
552                 print "up"
553                 self["historylist"].selectPrevious()
554                 return self.getSelection()
555
556         def down(self):
557                 print "down"
558                 self["historylist"].selectNext()
559                 return self.getSelection()
560         
561         def pageUp(self):
562                 print "up"
563                 self["historylist"].selectPrevious()
564                 return self.getSelection()
565
566         def pageDown(self):
567                 print "down"
568                 self["historylist"].selectNext()
569                 return self.getSelection()
570
571