summaryrefslogtreecommitdiff
path: root/portato/gui/windows/plugin.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/plugin.py84
1 files changed, 51 insertions, 33 deletions
diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py
index fb9446e..6e8fdab 100644
--- a/portato/gui/windows/plugin.py
+++ b/portato/gui/windows/plugin.py
@@ -34,48 +34,40 @@ 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")
- 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.window.show_all()
+ self.view.get_selection().connect("changed", self.cb_list_selection)
- def cb_status_changed (self, cell, path, new_text):
- path = int(path)
-
- self.store[path][2] = "<b>%s</b>" % new_text
+ self.window.show_all()
- # convert string to constant
- const = None
- for num, val in enumerate(self.statsStore):
- if val[0] == new_text:
- const = num
- break
+ def cb_state_toggled (self, rb):
+
+ plugin = self.get_actual()
- assert (const is not None)
+ if plugin:
+ state = self.buttons.index(rb)
- self.changedPlugins.update({self.plugins[path] : const})
- debug("new changed plugins: %s => %d", self.plugins[path].name, const)
+ 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 +75,29 @@ 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_label(plugin.description)
+ self.descrLabel.show()
+
+ self.authorLabel.set_label(plugin.author)
+
+ status = self.changedPlugins.get(plugin, plugin.status)
+ self.buttons[status].set_active(True)
+
+ 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