+ current = self.getCurrent()
+ if current is not None:
+ self.session.open(MovieContextMenu, self, current)
+
+ def abort(self):
+ self.saveconfig()
+ self.close(None)
+
+ def saveconfig(self):
+ if self.saveflag == True:
+ config.movielist.moviesort.save()
+ config.movielist.listtype.save()
+ config.movielist.description.save()
+ configfile.save()
+ self.saveflag = False
+
+ def getTagDescription(self, tag):
+ # TODO: access the tag database
+ return tag
+
+ def updateTags(self):
+ # get a list of tags available in this list
+ self.tags = list(self["list"].tags)
+
+ # by default, we do not display any filtering options
+ self.tag_first = ""
+ self.tag_second = ""
+
+ # when tags are present, however, the first two are
+ # directly mapped to the second, third ("green", "yellow") buttons
+ if len(self.tags) > 0:
+ self.tag_first = self.getTagDescription(self.tags[0])
+
+ if len(self.tags) > 1:
+ self.tag_second = self.getTagDescription(self.tags[1])
+
+ self["key_green"].text = self.tag_first
+ self["key_yellow"].text = self.tag_second
+
+ # the rest is presented in a list, available on the
+ # fourth ("blue") button
+ if len(self.tags) > 2:
+ self["key_blue"].text = _("Other...")
+ else:
+ self["key_blue"].text = ""
+
+ def setListType(self, type):
+ self["list"].setListType(type)
+
+ def setDescriptionState(self, val):
+ self["list"].setDescriptionState(val)
+
+ def setSortType(self, type):
+ self["list"].setSortType(type)
+
+ def reloadList(self):
+ self["list"].reload(self.current_ref, self.selected_tags)
+ title = _("Recorded files...")
+ if self.selected_tags is not None:
+ title += " - " + ','.join(self.selected_tags)
+ self.setTitle(title)
+
+ def showAll(self):
+ self.selected_tags = None
+ self.reloadList()
+
+ def showTagsN(self, n):
+ if len(self.tags) < n:
+ self.showTagWarning()
+ else:
+ print "select tag #%d, %s, %s" % (n, self.tags[n - 1], ','.join(self.tags))
+ self.selected_tags = set([self.tags[n - 1]])
+ self.reloadList()
+
+ def showTagsFirst(self):
+ self.showTagsN(1)
+
+ def showTagsSecond(self):
+ self.showTagsN(2)
+
+ def tagChosen(self, tag):
+ if tag is not None:
+ self.selected_tags = set([tag[0]])
+ self.reloadList()
+
+ def showTagsMenu(self):
+ if len(self.tags) < 3:
+ self.showTagWarning()
+ else:
+ list = [(tag, self.getTagDescription(tag)) for tag in self.tags ]
+ self.session.openWithCallback(self.tagChosen, ChoiceBox, title=_("Please select keyword to filter..."), list = list)
+
+ def showTagWarning(self):
+ # TODO
+ self.session.open(MessageBox, _("You need to define some keywords first!\nPress the menu-key to define keywords.\nDo you want to define keywords now?"), MessageBox.TYPE_ERROR)