diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-07-05 03:39:34 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-07-05 03:39:34 +0200 |
commit | 15f98dc02d9914164494a860a95bd83b7e8958ef (patch) | |
tree | 77fac842f9729c993f3960d2e85126d3d18fdf5e | |
parent | 794bca2b17086ff4fa89bda6c0915815571d2aa9 (diff) | |
download | portato-15f98dc02d9914164494a860a95bd83b7e8958ef.tar.gz portato-15f98dc02d9914164494a860a95bd83b7e8958ef.tar.bz2 portato-15f98dc02d9914164494a860a95bd83b7e8958ef.zip |
Port DependencyDetail
Diffstat (limited to '')
-rw-r--r-- | plugins/package_details.py | 109 | ||||
-rw-r--r-- | portato/gui/templates/MainWindow.ui | 23 | ||||
-rw-r--r-- | portato/gui/windows/main.py | 103 | ||||
-rw-r--r-- | portato/plugin.py | 12 |
4 files changed, 118 insertions, 129 deletions
diff --git a/plugins/package_details.py b/plugins/package_details.py index cda3c94..044cb54 100644 --- a/plugins/package_details.py +++ b/plugins/package_details.py @@ -14,6 +14,8 @@ import gtk import os from portato.gui import views +from portato.backend import system + class Detail (WidgetPlugin): __author__ = "René 'Necoro' Neumann" _view_ = None @@ -84,6 +86,113 @@ class FilesDetail (ScrolledDetail): except IOError, e: yield _("Error: %s") % e.strerror +class DependencyDetail (ScrolledDetail): + __description__ = _("Shows the dependencies of a package") + _widget_name_ = _("Dependencies") + + def widget_init (self): + 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) + + self._view_ = self.build_list() + ScrolledDetail.widget_init(self) + + def sort_key (self, 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 (self, 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 (self, dep): + if dep.satisfied: + return self.icons["installed"] + elif dep.dep[0] == "!": + return self.icons["block"] + else: + return None + + def build_list (self): + listView = views.LazyStoreView(self.fill_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_list(self, pkg): + + store = gtk.TreeStore(gtk.gdk.Pixbuf, str) + + def add (tree, it): + # useflags + flags = sorted(tree.flags.iteritems(), cmp = self.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 = self.sort_key) + for dep in ndeps: + store.append(it, [self.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 + +register(DependencyDetail) register(EbuildDetail) register(FilesDetail) register(ChangelogDetail) 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 @@ <property name="tab_fill">False</property> </packing> </child> - <child> - <object class="GtkScrolledWindow" id="dependencyScroll"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <child> - <placeholder/> - </child> - </object> - </child> - <child type="tab"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes">Dependencies</property> - </object> - <packing> - <property name="position">2</property> - <property name="tab_fill">False</property> - </packing> - </child> </object> <packing> <property name="position">1</property> 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(): """ |