From 09e693a8061d0b96c3aac8aae6ae12d6272b2c3e Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Mon, 30 Jun 2008 21:06:17 +0200 Subject: Now the new design is able to do the same as the old one --- portato/gui/windows/plugin.py | 84 ++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 33 deletions(-) (limited to 'portato/gui/windows/plugin.py') 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 ((""+p.name+"", p.author, _(self.statsStore[p.status][0])) for p in plugins): - self.store.append(p) + for p in plugins: + self.store.append(["%s" % 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] = "%s" % 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 -- cgit v1.2.3-70-g09d2 From a32293a8bbb0a90512d4f8e0fbc385257b29e72a Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Thu, 3 Jul 2008 17:59:53 +0200 Subject: Should show dependencies now --- portato/gui/templates/PluginWindow.glade | 160 +++++++++++++++---------------- portato/gui/windows/plugin.py | 50 +++++++++- 2 files changed, 128 insertions(+), 82 deletions(-) (limited to 'portato/gui/windows/plugin.py') diff --git a/portato/gui/templates/PluginWindow.glade b/portato/gui/templates/PluginWindow.glade index 01db971..8ba7aa9 100644 --- a/portato/gui/templates/PluginWindow.glade +++ b/portato/gui/templates/PluginWindow.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -41,81 +41,55 @@ 2 5 - + True - 5 - True - GTK_BUTTONBOX_EDGE - - - True - True - Enabled - 0 - True - - - - - - True - True - Temporarily enabled - 0 - enabledRB - - - 1 - - + True + True + _Install dependencies + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + True - + True True - Temporarily disabled - 0 - enabledRB - + True - - 2 - - + True - True - Disabled - 0 - enabledRB - + Needed dependencies + True - False - False - 3 + label_item - 2 - 3 - 4 - GTK_FILL + 2 + 3 - + True - 0 label - True - 1 2 - 1 - 2 GTK_FILL @@ -133,56 +107,82 @@ - + True + 0 label + True + 1 2 + 1 + 2 GTK_FILL - + True - True + 5 + True + GTK_BUTTONBOX_EDGE - + True True - True + Enabled + 0 + True + - + True - Needed dependencies - True + True + Temporarily enabled + 0 + enabledRB - label_item + 1 + + + + + True + True + Temporarily disabled + 0 + enabledRB + + + + 2 + + + + + True + True + Disabled + 0 + enabledRB + + + + False + False + 3 - 2 - 3 - - - - - True - True - True - _Install dependencies - True - 0 - - - 1 2 - 2 - 3 + 3 + 4 + GTK_FILL diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py index 6e8fdab..17c5326 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -42,6 +42,10 @@ class PluginWindow (AbstractDialog): 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) self.view = self.tree.get_widget("pluginList") self.store = gtk.ListStore(str) @@ -59,6 +63,32 @@ class PluginWindow (AbstractDialog): self.window.show_all() + def build_dep_list (self): + store = gtk.TreeStore(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) + + self.depList.append_column(col) + + def fill_dep_list (self, inst = [], ninst = []): + store = self.depList.get_model() + store.clear() + + 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() @@ -91,8 +121,24 @@ class PluginWindow (AbstractDialog): status = self.changedPlugins.get(plugin, plugin.status) self.buttons[status].set_active(True) - self.installBtn.hide() - self.depExpander.hide() + 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() -- cgit v1.2.3-70-g09d2 From cf70f253a11871ba6db372eb4735335ec97129cd Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Fri, 4 Jul 2008 15:57:28 +0200 Subject: Added ability to install missing plugin deps --- portato/gui/templates/PluginWindow.glade | 172 +++++++++++++++---------------- portato/gui/windows/main.py | 2 +- portato/gui/windows/plugin.py | 47 +++++++-- 3 files changed, 126 insertions(+), 95 deletions(-) (limited to 'portato/gui/windows/plugin.py') diff --git a/portato/gui/templates/PluginWindow.glade b/portato/gui/templates/PluginWindow.glade index 9e1fc43..f76193e 100644 --- a/portato/gui/templates/PluginWindow.glade +++ b/portato/gui/templates/PluginWindow.glade @@ -1,6 +1,6 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -38,7 +38,6 @@ True 0 - GTK_SHADOW_OUT True @@ -46,82 +45,62 @@ 2 10 - + True - 5 - True - GTK_BUTTONBOX_EDGE - - - True - True - Enabled - 0 - True - - - - - - True - True - Temporarily enabled - 0 - enabledRB - - - 1 - - + True + True + _Install dependencies + True + 0 + + + + 1 + 2 + 2 + 3 + + 10 + + + + + True + True - + True True - Temporarily disabled - 0 - enabledRB - + False + True - - 2 - - + True - True - Disabled - 0 - enabledRB - + Needed dependencies + True - False - False - 3 + label_item - 2 - 3 - 4 - GTK_FILL + 2 + 3 + 10 - + True - 0 label - True - 1 2 - 1 - 2 GTK_FILL + 10 @@ -138,61 +117,82 @@ - + True + 0 label + True + 1 2 + 1 + 2 GTK_FILL - 10 - + True - True + 5 + True + GTK_BUTTONBOX_EDGE - + True True - False - True + Enabled + 0 + True + - + True - Needed dependencies - True + True + Temporarily enabled + 0 + enabledRB - label_item + 1 + + + + + True + True + Temporarily disabled + 0 + enabledRB + + + + 2 + + + + + True + True + Disabled + 0 + enabledRB + + + + False + False + 3 - 2 - 3 - 10 - - - - - True - True - True - _Install dependencies - True - 0 - - - 1 2 - 2 - 3 - - 10 + 3 + 4 + GTK_FILL diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 479274d..265d4dd 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -1553,7 +1553,7 @@ class MainWindow (Window): else: plugins = list(queue.get_plugins()) - PluginWindow(self.window, plugins) + PluginWindow(self.window, plugins, self.queue) return True def cb_show_updates_clicked (self, *args): diff --git a/portato/gui/windows/plugin.py b/portato/gui/windows/plugin.py index 9760658..392654e 100644 --- a/portato/gui/windows/plugin.py +++ b/portato/gui/windows/plugin.py @@ -15,7 +15,9 @@ from __future__ import absolute_import import gtk from .basic import AbstractDialog +from ..dialogs import blocked_dialog, unmask_dialog from ...backend import system +from ...backend.exceptions import PackageNotFoundException, BlockedException from ...helper import debug class PluginWindow (AbstractDialog): @@ -25,7 +27,7 @@ class PluginWindow (AbstractDialog): for s in (_("Disabled"), _("Temporarily enabled"), _("Enabled"), _("Temporarily disabled")): statsStore.append([s]) - def __init__ (self, parent, plugins): + def __init__ (self, parent, plugins, queue = None): """Constructor. @param parent: the parent window @@ -33,7 +35,10 @@ class PluginWindow (AbstractDialog): AbstractDialog.__init__(self, parent) self.plugins = plugins + self.queue = queue self.changedPlugins = {} + self.inst = [] + self.ninst = [] self.buttons = map(self.tree.get_widget, ("disabledRB", "tempEnabledRB", "enabledRB", "tempDisabledRB")) map(lambda b: b.set_mode(False), self.buttons) @@ -46,6 +51,8 @@ class PluginWindow (AbstractDialog): self.depList = self.tree.get_widget("depList") self.build_dep_list() + self.buttonBox = self.tree.get_widget("buttonBox") + self.instIcon = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) self.view = self.tree.get_widget("pluginList") @@ -109,6 +116,8 @@ class PluginWindow (AbstractDialog): def cb_list_selection (self, selection): plugin = self.get_actual() + self.inst = [] + self.ninst = [] if plugin: if not plugin.description: @@ -123,23 +132,45 @@ class PluginWindow (AbstractDialog): 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) + if system.find_packages(dep, pkgSet = "installed", with_version = False): + self.inst.append(dep) else: - ninst.append(dep) + self.ninst.append(dep) - self.fill_dep_list(inst, ninst) + self.fill_dep_list(self.inst, self.ninst) self.depExpander.show() self.installBtn.show() - self.installBtn.set_sensitive(bool(ninst)) + self.installBtn.set_sensitive(bool(self.ninst)) + else: self.installBtn.hide() self.depExpander.hide() + + self.buttonBox.set_sensitive(not plugin._unresolved_deps and plugin.status != plugin.STAT_HARD_DISABLED) + + def cb_install_clicked (self, *args): + if not self.queue: + return False + + for cpv in self.ninst: + + pkg = system.find_best_match(cpv, masked = False, only_cpv = True) + if not pkg: + pkg = system.find_best_match(cpv, masked = True, only_cpv = True) + + try: + try: + self.queue.append(pkg, type = "install") + except PackageNotFoundException, e: + if unmask_dialog(e[0]) == gtk.RESPONSE_YES: + self.queue.append(pkg, type = "install", unmask = True) + except BlockedException, e: + blocked_dialog(e[0], e[1]) + + return True def get_actual (self): store, it = self.view.get_selection().get_selected() -- cgit v1.2.3-70-g09d2