diff options
-rw-r--r-- | portato/dependency.py | 24 | ||||
-rw-r--r-- | portato/gui/gtk/windows.py | 92 | ||||
-rw-r--r-- | portato/gui/templates/MainWindow.glade | 238 |
3 files changed, 237 insertions, 117 deletions
diff --git a/portato/dependency.py b/portato/dependency.py index 91e4fb5..a52a630 100644 --- a/portato/dependency.py +++ b/portato/dependency.py @@ -19,6 +19,7 @@ __docformat__ = "restructuredtext" from .helper import debug +from .backend import system class Dependency (object): @@ -29,6 +30,9 @@ class Dependency (object): dep : string The dependency string. It is immutable. + + satisfied : boolean + Is this dependency satisfied? """ def __init__ (self, dep): @@ -38,7 +42,15 @@ class Dependency (object): :param dep: dependency string :type dep: string """ - self.__dep = dep + self._dep = dep + + def is_satisfied (self): + """ + Checks if this dependency is satisfied. + + :rtype: boolean + """ + return system.find_best_match(self.dep, only_cpv = True, only_installed = True) is not None def __cmp__ (self, b): return cmp(self.dep, b.dep) @@ -51,13 +63,13 @@ class Dependency (object): __repr__ = __str__ - def __get_dep (self): - return self.__dep + def _get_dep (self): + return self._dep - dep = property(__get_dep) + dep = property(_get_dep) + satisfied = property(is_satisfied) class OrDependency (Dependency): - """ Dependency representing an "or". @@ -77,7 +89,7 @@ class OrDependency (Dependency): :type deps: iter<string> """ - self.__dep = tuple(Dependency(dep) for dep in deps) + self._dep = tuple(Dependency(dep) for dep in deps) def __str__ (self): return "<|| %s>" % str(self.dep) diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index aecebd3..7036ecb 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -29,6 +29,7 @@ from ...session import Session from ...constants import CONFIG_LOCATION, VERSION, APP_ICON from ...backend import flags, system from ...backend.exceptions import PackageNotFoundException, BlockedException +from ... import dependency # more GUI stuff from ..gui_helper import Database, Config, EmergeQueue @@ -422,7 +423,6 @@ class PreferenceWindow (AbstractDialog): """Just closes - w/o saving.""" self.window.destroy() - class PackageTable: """A window with data about a specfic package.""" @@ -477,11 +477,22 @@ class PackageTable: self.useList = self.tree.get_widget("useList") self.build_use_list() + # depList + self.depList = self.tree.get_widget("dependencyList") + self.build_dep_list() + # views self.ebuildView = self.tree.get_widget("ebuildScroll").get_child() self.changelogView = self.tree.get_widget("changelogScroll").get_child() self.filesView = self.tree.get_widget("filesScroll").get_child() + # 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) + def update (self, cp, queue = None, version = None, doEmerge = True, instantChange = False, type = None): """Updates the table to show the contents for the package. @@ -588,6 +599,55 @@ class PackageTable: self.useFlagsLL.hide() self.useFlagsLabel.hide() + def fill_dep_list(self): + + deptree = self.actual_package().get_dependencies() + store = self.depList.get_model() + + def add (tree, it): + + def get_icon (dep): + if dep.satisfied: + return self.icons["installed"] + elif dep.dep[0] == "!": + return self.icons["block"] + else: + return None + + # useflags + for use, usetree in tree.flags.iteritems(): + 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 + ordeps = (dep for dep in tree.deps if isinstance(dep, dependency.OrDependency)) + + for ordep in ordeps: + orit = store.append(it, [self.icons["or"], _("One of the following")]) + + for dep in ordep.dep: + store.append(orit, [get_icon(dep), dep.dep]) + + # normal + 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]) + + ndeps = [dep for dep in tree.deps if not isinstance(dep, dependency.OrDependency)] + ndeps.sort(key = sort_key) + for dep in ndeps: + store.append(it, [get_icon(dep), dep.dep]) + + add (deptree, None) + def fill_use_list(self): pkg = self.actual_package() @@ -616,6 +676,23 @@ class PackageTable: installed = use in instuse store.append(actual_exp_it, [enabled, installed, use, system.get_use_desc(use, self.cp)]) + 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 build_use_list (self): """Builds the useList.""" store = gtk.TreeStore(bool, bool, str, str) @@ -723,6 +800,11 @@ class PackageTable: self.useList.get_model().clear() self.useList.columns_autosize() self.fill_use_list() + + # set dep list + self.depList.get_model().clear() + self.useList.columns_autosize() + self.fill_dep_list() # # rebuild the buttons and checkboxes in all the different manners which are possible @@ -784,14 +866,6 @@ class PackageTable: else: self.unmergeBtn.set_sensitive(True) - # XXX: workaround: currently the useflags are selected as the first tab - # but on first start we want the general page - if not self.vb.get_property("visible"): - self.vb.show_all() - self.notebook.set_current_page(0) - else: - self.vb.show_all() - return True def cb_button_pressed (self, b, event): diff --git a/portato/gui/templates/MainWindow.glade b/portato/gui/templates/MainWindow.glade index 22be0ae..854b397 100644 --- a/portato/gui/templates/MainWindow.glade +++ b/portato/gui/templates/MainWindow.glade @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.1 on Tue Mar 4 11:40:35 2008 --> +<!--Generated with glade3 3.4.1 on Wed Mar 5 12:47:35 2008 --> <glade-interface> <widget class="GtkWindow" id="MainWindow"> <property name="border_width">2</property> @@ -593,271 +593,271 @@ <placeholder/> </child> <child> - <widget class="GtkLabel" id="licenseLabel"> + <widget class="GtkLabel" id="useFlagsLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">label</property> + <property name="label">use flags</property> + <property name="ellipsize">PANGO_ELLIPSIZE_END</property> <property name="single_line_mode">True</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="licenseLabelLabel"> + <widget class="GtkLabel" id="useFlagsLabelLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes"><b>License:</b></property> + <property name="label" translatable="yes"><b>Use Flags:</b></property> <property name="use_markup">True</property> <property name="single_line_mode">True</property> </widget> <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkLabel" id="notInSysLabel"> + <widget class="GtkCheckButton" id="testingCheck"> <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="no_show_all">True</property> - <property name="label" translatable="yes"><b>Installed, but not in portage anymore</b></property> - <property name="use_markup">True</property> + <property name="label" translatable="yes">Testing</property> + <property name="xalign">0</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="cb_testing_toggled"/> </widget> <packing> - <property name="right_attach">2</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">7</property> + <property name="bottom_attach">8</property> + <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="missingLabel"> + <widget class="GtkLabel" id="maskedLabel"> <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="no_show_all">True</property> - <property name="label" translatable="yes"><span foreground='red'><b>MISSING KEYWORD</b></span></property> - <property name="use_markup">True</property> + <property name="xalign">0</property> </widget> <packing> + <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">5</property> - <property name="bottom_attach">6</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkHBox" id="linkBox"> + <widget class="GtkCheckButton" id="maskedCheck"> <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="spacing">5</property> - <child> - <placeholder/> - </child> + <property name="no_show_all">True</property> + <property name="label" translatable="yes">Masked</property> + <property name="xalign">0</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="cb_masked_toggled"/> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">8</property> + <property name="bottom_attach">9</property> + <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="descLabelLabel"> + <widget class="GtkCheckButton" id="installedCheck"> <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="no_show_all">True</property> + <property name="label" translatable="yes">Installed</property> <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Description:</b></property> - <property name="use_markup">True</property> - <property name="single_line_mode">True</property> + <property name="response_id">0</property> + <property name="draw_indicator">True</property> + <signal name="button_press_event" handler="cb_button_pressed"/> </widget> <packing> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> - <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkLabel" id="overlayLabelLabel"> + <widget class="GtkLabel" id="homepageLinkLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Overlay:</b></property> + <property name="label" translatable="yes"><b>Homepage:</b></property> <property name="use_markup">True</property> <property name="single_line_mode">True</property> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkLabel" id="descLabel"> + <widget class="GtkLabel" id="overlayLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">label</property> - <property name="wrap">True</property> + <property name="single_line_mode">True</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="overlayLabel"> + <widget class="GtkLabel" id="descLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> <property name="label" translatable="yes">label</property> - <property name="single_line_mode">True</property> + <property name="wrap">True</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="homepageLinkLabel"> + <widget class="GtkLabel" id="overlayLabelLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Homepage:</b></property> + <property name="label" translatable="yes"><b>Overlay:</b></property> <property name="use_markup">True</property> <property name="single_line_mode">True</property> </widget> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkCheckButton" id="installedCheck"> + <widget class="GtkLabel" id="descLabelLabel"> <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="no_show_all">True</property> - <property name="label" translatable="yes">Installed</property> <property name="xalign">0</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - <signal name="button_press_event" handler="cb_button_pressed"/> + <property name="label" translatable="yes"><b>Description:</b></property> + <property name="use_markup">True</property> + <property name="single_line_mode">True</property> </widget> <packing> - <property name="top_attach">6</property> - <property name="bottom_attach">7</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> + <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkCheckButton" id="maskedCheck"> + <widget class="GtkHBox" id="linkBox"> <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="no_show_all">True</property> - <property name="label" translatable="yes">Masked</property> - <property name="xalign">0</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="cb_masked_toggled"/> + <property name="spacing">5</property> + <child> + <placeholder/> + </child> </widget> <packing> - <property name="top_attach">8</property> - <property name="bottom_attach">9</property> - <property name="x_options">GTK_FILL</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="maskedLabel"> + <widget class="GtkLabel" id="missingLabel"> <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="xalign">0</property> + <property name="no_show_all">True</property> + <property name="label" translatable="yes"><span foreground='red'><b>MISSING KEYWORD</b></span></property> + <property name="use_markup">True</property> </widget> <packing> - <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">8</property> - <property name="bottom_attach">9</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkCheckButton" id="testingCheck"> + <widget class="GtkLabel" id="notInSysLabel"> <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="no_show_all">True</property> - <property name="label" translatable="yes">Testing</property> - <property name="xalign">0</property> - <property name="response_id">0</property> - <property name="draw_indicator">True</property> - <signal name="toggled" handler="cb_testing_toggled"/> + <property name="label" translatable="yes"><b>Installed, but not in portage anymore</b></property> + <property name="use_markup">True</property> </widget> <packing> - <property name="top_attach">7</property> - <property name="bottom_attach">8</property> - <property name="x_options">GTK_FILL</property> + <property name="right_attach">2</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="useFlagsLabelLabel"> + <widget class="GtkLabel" id="licenseLabelLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes"><b>Use Flags:</b></property> + <property name="label" translatable="yes"><b>License:</b></property> <property name="use_markup">True</property> <property name="single_line_mode">True</property> </widget> <packing> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="x_options">GTK_FILL</property> <property name="y_options"></property> <property name="y_padding">5</property> </packing> </child> <child> - <widget class="GtkLabel" id="useFlagsLabel"> + <widget class="GtkLabel" id="licenseLabel"> <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="no_show_all">True</property> <property name="xalign">0</property> - <property name="label">use flags</property> - <property name="ellipsize">PANGO_ELLIPSIZE_END</property> + <property name="label" translatable="yes">label</property> <property name="single_line_mode">True</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="y_options"></property> </packing> </child> @@ -910,6 +910,40 @@ </packing> </child> <child> + <widget 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> + <widget class="GtkTreeView" id="dependencyList"> + <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="headers_visible">False</property> + <property name="headers_clickable">True</property> + <property name="enable_search">False</property> + </widget> + </child> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> + <child> + <widget 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> + </widget> + <packing> + <property name="type">tab</property> + <property name="position">2</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> <widget class="GtkScrolledWindow" id="ebuildScroll"> <property name="visible">True</property> <property name="can_focus">True</property> @@ -921,7 +955,7 @@ </child> </widget> <packing> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -932,7 +966,7 @@ </widget> <packing> <property name="type">tab</property> - <property name="position">2</property> + <property name="position">3</property> <property name="tab_fill">False</property> </packing> </child> @@ -948,7 +982,7 @@ </child> </widget> <packing> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> @@ -959,7 +993,7 @@ </widget> <packing> <property name="type">tab</property> - <property name="position">3</property> + <property name="position">4</property> <property name="tab_fill">False</property> </packing> </child> @@ -975,7 +1009,7 @@ </child> </widget> <packing> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> <child> @@ -986,7 +1020,7 @@ </widget> <packing> <property name="type">tab</property> - <property name="position">4</property> + <property name="position">5</property> <property name="tab_fill">False</property> </packing> </child> |