Example #1
0
	def updateList(self):
		self.list = []
		pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)[:]
		for x in config.misc.pluginbrowser.plugin_order.value.split(","):
			plugin = list(plugin for plugin in pluginlist if plugin.path[24:] == x)
			if plugin:
				self.list.append(PluginEntryComponent(plugin[0], self.listWidth))
				pluginlist.remove(plugin[0])
		self.list = self.list + [PluginEntryComponent(plugin, self.listWidth) for plugin in pluginlist]
		self["list"].l.setList(self.list)
 def updateList(self):
     self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
     self.list = [
         PluginEntryComponent(plugin, self.listWidth)
         for plugin in self.pluginlist
     ]
     self["list"].l.setList(self.list)
Example #3
0
 def updateList(self):
     self.pluginlist = plugins.getPlugins(self.where)
     if self.where in (PluginDescriptor.WHERE_PLUGINMENU,
                       PluginDescriptor.WHERE_EXTENSIONSMENU):
         self.pluginlist.sort(
             key=attrgetter('weight', 'name')
         )  # sort first by weight, then by name; we get pretty much a weight sorted but otherwise random list
     else:  #if self.where in (PluginDescriptor.WHERE_EVENTINFO, PluginDescriptor.WHERE_MOVIELIST):
         self.pluginlist.sort(key=attrgetter('weight'))
     self.list = [
         PluginEntryComponent(plugin) for plugin in self.pluginlist
     ]
     self["list"].l.setList(self.list)
     if self.where == PluginDescriptor.WHERE_PLUGINMENU:
         if fileExists(
                 resolveFilename(
                     SCOPE_PLUGINS,
                     "SystemPlugins/SoftwareManager/plugin.py")):
             # TRANSLATORS: leaving this empty is encouraged to not cause any confusion (this string was taken directly from the standard PluginBrowser)
             self["red"].setText(_("Manage extensions"))
             self["green"].setText(
                 _("Sort") if not self.movemode else _("End Sort"))
             self["SoftwareActions"].setEnabled(True)
             self["PluginDownloadActions"].setEnabled(False)
             self["ColorActions"].setEnabled(True)
         else:
             # TRANSLATORS: leaving this empty is encouraged to not cause any confusion (this string was taken directly from the standard PluginBrowser)
             self["red"].setText(_("Remove Plugins"))
             # TRANSLATORS: leaving this empty is encouraged to not cause any confusion (this string was taken directly from the standard PluginBrowser)
             self["green"].setText(_("Download Plugins"))
             self["SoftwareActions"].setEnabled(False)
             self["PluginDownloadActions"].setEnabled(True)
             self["ColorActions"].setEnabled(False)
     else:
         self["red"].setText("")
         self["green"].setText(
             _("Sort") if not self.movemode else _("End Sort"))
         self["SoftwareActions"].setEnabled(False)
         self["PluginDownloadActions"].setEnabled(False)
         self["ColorActions"].setEnabled(True)
Example #4
0
    def save(self):
        selected = self.selected
        if not self.movemode:
            OriginalPluginBrowser.save(self)
        elif selected != -1:
            Len = len(self.pluginlist)
            newpos = self["list"].getSelectedIndex()
            entry = self.pluginlist[selected]
            self.pluginlist.remove(entry)
            self.pluginlist.insert(newpos, entry)

            # we moved up, increase weight of plugins after us
            if newpos < selected:
                print("[PluginSort]", entry.name, "moved up")
                i = newpos + 1
                # since we moved up, there has to be an entry after this one
                diff = abs(self.pluginlist[i].weight -
                           self.pluginlist[newpos].weight) + 1
                print(
                    "[PluginSort] Using weight from %d (%d) and %d (%d) to calculate diff (%d)"
                    % (i, self.pluginlist[i].weight, newpos,
                       self.pluginlist[newpos].weight, diff))
                while i < Len:
                    if DEBUG:
                        print("[PluginSort] INCREASE WEIGHT OF",
                              self.pluginlist[i].name, "BY", diff)
                    self.pluginlist[i].weight += diff
                    i += 1
            # we moved down, decrease weight of plugins before us
            elif newpos > selected:
                print("[PluginSort]", entry.name, "moved down")
                i = newpos - 1
                # since we moved up, there has to be an entry before this one
                diff = abs(self.pluginlist[newpos].weight -
                           self.pluginlist[i].weight) + 1
                print(
                    "[PluginSort] Using weight from %d (%d) and %d (%d) to calculate diff (%d)"
                    % (newpos, self.pluginlist[newpos].weight, i,
                       self.pluginlist[i].weight, diff))
                while i > -1:
                    if DEBUG:
                        print("[PluginSort] DECREASE WEIGHT OF",
                              self.pluginlist[i].name, "BY", diff)
                    self.pluginlist[i].weight -= diff
                    i -= 1
            else:
                if DEBUG:
                    print("[PluginSort]", entry.name,
                          "did not move (%d to %d)?" % (selected, newpos))

            self.list = [
                PluginEntryComponent(plugin) for plugin in self.pluginlist
            ]
            if DEBUG:
                print("[PluginSort] NEW LIST:",
                      [(plugin.name, plugin.weight)
                       for plugin in self.pluginlist])
            self["list"].l.setList(self.list)
            self.selected = -1
        else:
            self.selected = self["list"].getSelectedIndex()
            self.list[self.selected] = SelectedPluginEntryComponent(
                self.pluginlist[self.selected])
            self["list"].l.setList(self.list)