From 0885d993b40c92d86a61e3952c9df6c00578bfce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 24 Jun 2008 10:54:57 +0200 Subject: Removed frontend specification from notify plugin --- plugins/notify.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/notify.xml b/plugins/notify.xml index 8de08c8..9a89987 100644 --- a/plugins/notify.xml +++ b/plugins/notify.xml @@ -3,7 +3,6 @@ René 'Necoro' Neumann Notify - gtk portato.plugins.notify -- cgit v1.2.3 From 05d555bdd35332c1b2b45c9261a3c2ace3888591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 24 Jun 2008 10:55:27 +0200 Subject: Removed frontend tag; added dependencies tag --- plugin.xsd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/plugin.xsd b/plugin.xsd index 38cb872..985b105 100644 --- a/plugin.xsd +++ b/plugin.xsd @@ -6,7 +6,13 @@ - + + + + + + + @@ -78,12 +84,4 @@ - - - - - - - - -- cgit v1.2.3 From 014b668a1bd5b1bc768587b80d18c7038f748f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Mon, 30 Jun 2008 20:02:52 +0200 Subject: Added stuff to plugin.py --- portato/plugin.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/portato/plugin.py b/portato/plugin.py index 5926922..ae89a1c 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -18,12 +18,16 @@ import os, os.path from xml.dom.minidom import parse from lxml import etree +from .backend import system from .constants import PLUGIN_DIR, XSD_LOCATION from .helper import debug, info, warning, error, flatten class PluginImportException (ImportError): pass +class UnmatchedDepsException (Exception): + pass + class Options (object): """The -element.""" @@ -72,7 +76,10 @@ class Menu: try: mod = __import__(imp, globals(), locals(), [call]) except ImportError: - raise PluginImportException, imp + if self.plugin.unmatched_deps: + raise UnmatchedDepsException + else: + raise PluginImportException, imp try: self.call = eval("mod."+call) # build function @@ -172,6 +179,8 @@ class Plugin: self._import = None self.hooks = [] self.menus = [] + self.deps = [] + self.unmatched_deps = [] self.options = Options() self.status = self.STAT_ENABLED @@ -205,6 +214,15 @@ class Plugin: self.options.parse(o.getElementsByTagName("option")) self.status = self.STAT_DISABLED if self.options.get("disabled") else self.STAT_ENABLED + + def parse_deps (self, deps): + if deps: + for d in deps.firstChild.getElementsByTagName("dependency"): + self.deps.append(d.firstChild.nodeValue.strip()) + + for d in self.deps: + if not system.find_packages(d, "installed", with_version = False): + self.unmatched_deps.append(d) def set_import (self, imports): """This gets a list of imports and parses them - setting the import needed to call the plugin. @@ -221,7 +239,10 @@ class Plugin: mod = __import__(self._import) del mod except ImportError: - raise PluginImportException, self._import + if self.unmatched_deps: + raise UnmatchedDepsException + else: + raise PluginImportException, self._import def needs_import (self): """Returns True if an import is required prior to calling the plugin. @@ -389,6 +410,7 @@ class PluginQueue: if frontendOK is None or frontendOK == True: plugin = Plugin(p, elem.getElementsByTagName("name")[0], elem.getElementsByTagName("author")[0]) + plugin.parse_deps(elem.getElementsByTagName("dependencies")) plugin.parse_hooks(elem.getElementsByTagName("hooks")) plugin.set_import(elem.getElementsByTagName("import")) plugin.parse_menus(elem.getElementsByTagName("menu")) -- cgit v1.2.3 From 9b22030eda3b9af70ae052611cf485a0d7ae063b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Mon, 30 Jun 2008 20:12:55 +0200 Subject: First draft of the new plugin window --- portato/gui/templates/PluginWindow.glade | 180 +++++++++++++++++++++++++++++-- 1 file changed, 172 insertions(+), 8 deletions(-) diff --git a/portato/gui/templates/PluginWindow.glade b/portato/gui/templates/PluginWindow.glade index 1de5fc0..28b46e6 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 @@ -18,17 +18,181 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - + True - False - GTK_POLICY_NEVER - GTK_POLICY_NEVER + True + 120 + True - + True - True - False + False + GTK_POLICY_NEVER + GTK_POLICY_NEVER + + + True + True + False + + + + True + False + + + + + True + 4 + 2 + + + True + label + + + 2 + GTK_FILL + + + + + True + label + + + 1 + 2 + GTK_FILL + + + + + True + label + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + 5 + True + GTK_BUTTONBOX_EDGE + + + True + True + Enabled + 0 + True + + + True + + + + + True + True + Temporarily enabled + 0 + True + radiobutton1 + + + 1 + True + + + + + True + True + Temporarily disabled + 0 + True + radiobutton1 + + + 2 + True + + + + + True + True + Disabled + 0 + True + radiobutton1 + + + 3 + True + + + + + 2 + 3 + 4 + GTK_FILL + + + + + True + label + + + 2 + 3 + GTK_FILL + + + + + True + True + + + True + True + True + + + + + True + expander + + + label_item + + + + + 1 + 2 + 2 + 3 + + + + + True + False + -- cgit v1.2.3 From 09e693a8061d0b96c3aac8aae6ae12d6272b2c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= 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/templates/PluginWindow.glade | 265 +++++++++++++++---------------- portato/gui/windows/plugin.py | 84 ++++++---- portato/plugin.py | 1 + 3 files changed, 182 insertions(+), 168 deletions(-) diff --git a/portato/gui/templates/PluginWindow.glade b/portato/gui/templates/PluginWindow.glade index 28b46e6..01db971 100644 --- a/portato/gui/templates/PluginWindow.glade +++ b/portato/gui/templates/PluginWindow.glade @@ -1,11 +1,12 @@ - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 Plugins + False True GTK_WIN_POS_CENTER_ON_PARENT True @@ -18,183 +19,177 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - + True - True - 120 - True + False + GTK_POLICY_NEVER + GTK_POLICY_NEVER - + True - False - GTK_POLICY_NEVER - GTK_POLICY_NEVER - - - True - True - False - - + False + True + False - - True - False - + + + + + True + 4 + 2 + 5 - + True - 4 - 2 + 5 + True + GTK_BUTTONBOX_EDGE - + True - label + True + Enabled + 0 + True + - - 2 - GTK_FILL - - + True - label + True + Temporarily enabled + 0 + enabledRB - 1 - 2 - GTK_FILL + 1 - + True - label + True + Temporarily disabled + 0 + enabledRB + - 1 - 2 - 1 - 2 - GTK_FILL + 2 - + True - 5 - True - GTK_BUTTONBOX_EDGE - - - True - True - Enabled - 0 - True - - - True - - - - - True - True - Temporarily enabled - 0 - True - radiobutton1 - - - 1 - True - - - - - True - True - Temporarily disabled - 0 - True - radiobutton1 - - - 2 - True - - - - - True - True - Disabled - 0 - True - radiobutton1 - - - 3 - True - - + True + Disabled + 0 + enabledRB + - 2 - 3 - 4 - GTK_FILL + False + False + 3 + + + 2 + 3 + 4 + GTK_FILL + + + + + True + 0 + label + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + <b>Author:</b> + True + True + + + 1 + 2 + GTK_FILL + + + + + True + label + + + 2 + GTK_FILL + + + + + True + True - + True - label + True + True - - 2 - 3 - GTK_FILL - - + True - True - - - True - True - True - - - - - True - expander - - - label_item - - + Needed dependencies + True - 1 - 2 - 2 - 3 + label_item - True - False + 2 + 3 + + + + + True + True + True + _Install dependencies + True + 0 + + + 1 + 2 + 2 + 3 + + False + 1 + @@ -232,7 +227,7 @@ False - 1 + 2 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 diff --git a/portato/plugin.py b/portato/plugin.py index ae89a1c..cbadfd1 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -176,6 +176,7 @@ class Plugin: self.file = file self.name = name.firstChild.nodeValue.strip() self.author = author.firstChild.nodeValue.strip() + self.description = "" self._import = None self.hooks = [] self.menus = [] -- cgit v1.2.3 From a32293a8bbb0a90512d4f8e0fbc385257b29e72a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= 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(-) 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