diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-03 23:47:18 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2008-07-03 23:47:18 +0200 |
commit | b92627b162d3db44e683e92ad78cb713f7557f8d (patch) | |
tree | 7cca4ebca195f40bab765bd045775ef639e9ebd8 /portato/gui/windows | |
parent | 72649c40b6278dbc29a595517fa11948d4df0532 (diff) | |
parent | a32293a8bbb0a90512d4f8e0fbc385257b29e72a (diff) | |
download | portato-b92627b162d3db44e683e92ad78cb713f7557f8d.tar.gz portato-b92627b162d3db44e683e92ad78cb713f7557f8d.tar.bz2 portato-b92627b162d3db44e683e92ad78cb713f7557f8d.zip |
Merged in the new plugin window and the plugin deps
Diffstat (limited to '')
-rw-r--r-- | portato/gui/windows/plugin.py | 129 |
1 files changed, 97 insertions, 32 deletions
diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py index fb9446e..9760658 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -15,6 +15,7 @@ from __future__ import absolute_import import gtk from .basic import AbstractDialog +from ...backend import system from ...helper import debug class PluginWindow (AbstractDialog): @@ -34,48 +35,70 @@ class PluginWindow (AbstractDialog): self.plugins = plugins self.changedPlugins = {} - view = self.tree.get_widget("pluginList") - self.store = gtk.ListStore(str,str,str) + self.buttons = map(self.tree.get_widget, ("disabledRB", "tempEnabledRB", "enabledRB", "tempDisabledRB")) + map(lambda b: b.set_mode(False), self.buttons) + + self.descrLabel = self.tree.get_widget("descrLabel") + self.authorLabel = self.tree.get_widget("authorLabel") + + self.depExpander = self.tree.get_widget("depExpander") + self.installBtn = self.tree.get_widget("installBtn") + self.depList = self.tree.get_widget("depList") + self.build_dep_list() + + self.instIcon = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) - view.set_model(self.store) + self.view = self.tree.get_widget("pluginList") + self.store = gtk.ListStore(str) - cell = gtk.CellRendererText() - col = gtk.TreeViewColumn(_("Plugin"), cell, markup = 0) - view.append_column(col) + self.view.set_model(self.store) - col = gtk.TreeViewColumn(_("Authors"), cell, text = 1) - view.append_column(col) - - ccell = gtk.CellRendererCombo() - ccell.set_property("model", self.statsStore) - ccell.set_property("text-column", 0) - ccell.set_property("has-entry", False) - ccell.set_property("editable", True) - ccell.connect("edited", self.cb_status_changed) - col = gtk.TreeViewColumn(_("Status"), ccell, markup = 2) - view.append_column(col) + cell = gtk.CellRendererText() + col = gtk.TreeViewColumn("Plugin", cell, markup = 0) + self.view.append_column(col) - for p in (("<b>"+p.name+"</b>", p.author, _(self.statsStore[p.status][0])) for p in plugins): - self.store.append(p) + for p in plugins: + self.store.append(["<b>%s</b>" % p.name]) + + self.view.get_selection().connect("changed", self.cb_list_selection) self.window.show_all() - def cb_status_changed (self, cell, path, new_text): - path = int(path) - - self.store[path][2] = "<b>%s</b>" % new_text + def build_dep_list (self): + store = gtk.ListStore(gtk.gdk.Pixbuf, str) + + self.depList.set_model(store) + + col = gtk.TreeViewColumn() + + cell = gtk.CellRendererPixbuf() + col.pack_start(cell, False) + col.add_attribute(cell, "pixbuf", 0) + + cell = gtk.CellRendererText() + col.pack_start(cell, True) + col.add_attribute(cell, "text", 1) - # convert string to constant - const = None - for num, val in enumerate(self.statsStore): - if val[0] == new_text: - const = num - break + self.depList.append_column(col) - assert (const is not None) + def fill_dep_list (self, inst = [], ninst = []): + store = self.depList.get_model() + store.clear() - self.changedPlugins.update({self.plugins[path] : const}) - debug("new changed plugins: %s => %d", self.plugins[path].name, const) + for dep in inst: + store.append([self.instIcon, dep]) + for dep in ninst: + store.append([None, dep]) + + def cb_state_toggled (self, rb): + + plugin = self.get_actual() + + if plugin: + state = self.buttons.index(rb) + + self.changedPlugins[plugin] = state + debug("new changed plugins: %s => %d", plugin.name, state) def cb_ok_clicked (self, btn): for plugin, val in self.changedPlugins.iteritems(): @@ -83,3 +106,45 @@ class PluginWindow (AbstractDialog): self.close() return True + + def cb_list_selection (self, selection): + plugin = self.get_actual() + + if plugin: + if not plugin.description: + self.descrLabel.hide() + else: + self.descrLabel.set_markup(plugin.description) + self.descrLabel.show() + + self.authorLabel.set_label(plugin.author) + + status = self.changedPlugins.get(plugin, plugin.status) + self.buttons[status].set_active(True) + + if plugin.deps: + inst = [] + ninst = [] + + for dep in plugin.deps: + if system.find_packages(dep, pkgSet = "installed"): + inst.append(dep) + else: + ninst.append(dep) + + self.fill_dep_list(inst, ninst) + self.depExpander.show() + + self.installBtn.show() + self.installBtn.set_sensitive(bool(ninst)) + else: + self.installBtn.hide() + self.depExpander.hide() + + def get_actual (self): + store, it = self.view.get_selection().get_selected() + + if it: + return self.plugins[int(store.get_path(it)[0])] + else: + return None |