From 15f98dc02d9914164494a860a95bd83b7e8958ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 5 Jul 2009 03:39:34 +0200 Subject: Port DependencyDetail --- portato/gui/templates/MainWindow.ui | 23 -------- portato/gui/windows/main.py | 103 +----------------------------------- portato/plugin.py | 12 +++-- 3 files changed, 9 insertions(+), 129 deletions(-) (limited to 'portato') diff --git a/portato/gui/templates/MainWindow.ui b/portato/gui/templates/MainWindow.ui index 5577f9b..78d11db 100644 --- a/portato/gui/templates/MainWindow.ui +++ b/portato/gui/templates/MainWindow.ui @@ -780,29 +780,6 @@ False - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Dependencies - - - 2 - False - - 1 diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index 184d29b..814a764 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -98,7 +98,7 @@ class PackageTable: # views self.views = map (lambda x: self.tree.get_widget(x).get_child(), [ - "dependencyScroll", "useListScroll" + "useListScroll" ]) self.useList = self.tree.get_widget("useListScroll").get_child() @@ -448,10 +448,7 @@ class MainWindow (Window): # icons self.icons = {} - self.icons["use"] = self.window.render_icon(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU) self.icons["installed"] = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) - self.icons["or"] = self.window.render_icon(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU) - self.icons["block"] = self.window.render_icon(gtk.STOCK_NO, gtk.ICON_SIZE_MENU) # get the logging window as soon as possible self.logView = LogView(self.tree.get_widget("logView")) @@ -522,9 +519,6 @@ class MainWindow (Window): # the different scrolls - depScroll = self.tree.get_widget("dependencyScroll") - depScroll.add(self.build_dep_list()) - useScroll = self.tree.get_widget("useListScroll") useScroll.add(self.build_use_list()) @@ -563,7 +557,7 @@ class MainWindow (Window): self.load_session(defaults_only = True) # last ressort splash(_("Loading Plugin Widgets")) - plugin.load_plugin_widgets() + plugin.load_plugin_widgets(self.window) splash(_("Finishing startup")) @@ -821,99 +815,6 @@ class MainWindow (Window): self.versionList.get_selection().select_path(pos) self.versionList.scroll_to_cell(pos) - def build_dep_list (self): - - listView = LazyStoreView(self.fill_dep_list) - - 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) - - listView.append_column(col) - listView.set_headers_visible(False) - - return listView - - def fill_dep_list(self, pkg): - - store = gtk.TreeStore(gtk.gdk.Pixbuf, str) - - def sort_key (x): - split = system.split_cpv(x.dep) - - if split is None: # split_cpv returns None if this is only a CP; we assume there are only valid deps - return x.dep - else: - return "/".join(split[0:2]) - - def cmp_flag (x, y): - # get strings - as tuples are passed - x = x[0] - y = y[0] - - # remove "!" - ret = 0 - if x[0] == "!": - ret = 1 - x = x[1:] - if y[0] == "!": - ret = ret - 1 # if it is already 1, it is 0 now :) - y = y[1:] - - # cmp -- if two flags are equal, the negated one is greater - return cmp(x,y) or ret - - def get_icon (dep): - if dep.satisfied: - return self.icons["installed"] - elif dep.dep[0] == "!": - return self.icons["block"] - else: - return None - - def add (tree, it): - # useflags - flags = sorted(tree.flags.iteritems(), cmp = cmp_flag) - for use, usetree in flags: - if use[0] == "!": - usestring = _("If '%s' is disabled") % use[1:] - else: - usestring = _("If '%s' is enabled") % use - useit = store.append(it, [self.icons["use"], usestring]) - add(usetree, useit) - - # ORs - for ortree in tree.ors: - orit = store.append(it, [self.icons["or"], _("One of the following")]) - add(ortree, orit) - - # Sub (all of) - for subtree in tree.subs: - allit = store.append(it, [None, _("All of the following")]) - add(subtree, allit) - - # normal - ndeps = sorted(tree.deps, key = sort_key) - for dep in ndeps: - store.append(it, [get_icon(dep), dep.dep]) - - try: - deptree = pkg.get_dependencies() - except AssertionError: - w = _("Can't display dependencies: This package has an unsupported dependency string.") - error(w) - store.append(None, [None, w]) - else: - add(deptree, None) - - return store - def build_use_list (self): """Builds the useList.""" diff --git a/portato/plugin.py b/portato/plugin.py index 716a9b2..0da14f1 100644 --- a/portato/plugin.py +++ b/portato/plugin.py @@ -306,7 +306,9 @@ class WidgetPlugin (Plugin): Plugin.__init__(self, *args, **kwargs) self.__widgets = [] #: List of `Widget` - def _widget_init (self): + def _widget_init (self, window): + self.window = window + if self.status == self.STAT_ENABLED and not self._unresolved_deps: self.widget_init() @@ -440,10 +442,10 @@ class PluginQueue (object): self._organize() - def load_widgets(self): + def load_widgets(self, window): for p in self.plugins: if isinstance(p, WidgetPlugin): - p._widget_init() + p._widget_init(window) for w in p.widgets: WidgetSlot.slots[w.slot].add_widget(w) info(_("Widgets of plugin '%s' loaded."), p.name) @@ -637,12 +639,12 @@ def load_plugins(): __plugins.load() -def load_plugin_widgets(): +def load_plugin_widgets(window): """ Loads the widgets of the plugins. """ if __plugins is not None: - __plugins.load_widgets() + __plugins.load_widgets(window) def get_plugin_queue(): """ -- cgit v1.2.3