+ if p == select:
+ self.moveToIndex(i)
+ i += 1
+
+ def getCurrentDirectory(self):
+ return self.current_directory
+
+ def canDescent(self):
+ if self.getSelection() is None:
+ return False
+ return self.getSelection()[1]
+
+ def descent(self):
+ if self.getSelection() is None:
+ return
+ self.changeDir(self.getSelection()[0], select = self.current_directory)
+
+ def getFilename(self):
+ if self.getSelection() is None:
+ return None
+ x = self.getSelection()[0]
+ if isinstance(x, eServiceReference):
+ x = x.getPath()
+ return x
+
+ def getServiceRef(self):
+ if self.getSelection() is None:
+ return None
+ x = self.getSelection()[0]
+ if isinstance(x, eServiceReference):
+ return x
+ return None
+
+ def execBegin(self):
+ harddiskmanager.on_partition_list_change.append(self.partitionListChanged)
+
+ def execEnd(self):
+ harddiskmanager.on_partition_list_change.remove(self.partitionListChanged)
+
+ def refresh(self):
+ self.changeDir(self.current_directory, self.getFilename())
+
+ def partitionListChanged(self, action, device):
+ self.refreshMountpoints()
+ if self.current_directory is None:
+ self.refresh()
+
+
+def MultiFileSelectEntryComponent(name, absolute = None, isDir = False, selected = False):
+ res = [ (absolute, isDir, selected, name) ]
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 55, 1, 470, 20, 0, RT_HALIGN_LEFT, name))
+ if isDir:
+ png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "extensions/directory.png"))
+ else:
+ extension = name.split('.')
+ extension = extension[-1].lower()
+ if EXTENSIONS.has_key(extension):
+ png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "extensions/" + EXTENSIONS[extension] + ".png"))
+ else:
+ png = None
+ if png is not None:
+ res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 30, 2, 20, 20, png))
+
+ if not name.startswith('<'):
+ if selected is False:
+ icon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_off.png"))
+ res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 2, 0, 25, 25, icon))
+ else:
+ icon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/lock_on.png"))
+ res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 2, 0, 25, 25, icon))
+
+ return res
+
+
+class MultiFileSelectList(FileList):
+ def __init__(self, preselectedFiles, directory, showMountpoints = False, matchingPattern = None, showDirectories = True, showFiles = True, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None):
+ self.selectedFiles = preselectedFiles
+ if self.selectedFiles is None:
+ self.selectedFiles = []
+ FileList.__init__(self, directory, showMountpoints = showMountpoints, matchingPattern = matchingPattern, showDirectories = showDirectories, showFiles = showFiles, useServiceRef = useServiceRef, inhibitDirs = inhibitDirs, inhibitMounts = inhibitMounts, isTop = isTop, enableWrapAround = enableWrapAround, additionalExtensions = additionalExtensions)
+ self.changeDir(directory)
+ self.l.setItemHeight(25)
+ self.l.setFont(0, gFont("Regular", 20))
+ self.onSelectionChanged = [ ]
+
+ def selectionChanged(self):
+ for f in self.onSelectionChanged:
+ f()
+
+ def changeSelectionState(self):
+ idx = self.l.getCurrentSelectionIndex()
+ count = 0
+ newList = []
+ for x in self.list:
+ if idx == count:
+ if x[0][3].startswith('<'):
+ newList.append(x)
+ else:
+ if x[0][1] is True:
+ realPathname = x[0][0]
+ else:
+ realPathname = self.current_directory + x[0][0]
+ if x[0][2] == True:
+ SelectState = False
+ for entry in self.selectedFiles:
+ if entry == realPathname:
+ self.selectedFiles.remove(entry)
+
+ else:
+ SelectState = True
+ alreadyinList = False
+ for entry in self.selectedFiles:
+ if entry == realPathname:
+ alreadyinList = True
+ if not alreadyinList:
+ self.selectedFiles.append(realPathname)
+ newList.append(MultiFileSelectEntryComponent(name = x[0][3], absolute = x[0][0], isDir = x[0][1], selected = SelectState ))
+ else:
+ newList.append(x)
+
+ count += 1
+
+ self.list = newList