diff options
Diffstat (limited to 'geneticone')
-rw-r--r-- | geneticone/gui/gtk/__init__.py | 2 | ||||
-rw-r--r-- | geneticone/gui/gtk/dialogs.py | 2 | ||||
-rw-r--r-- | geneticone/gui/gtk/windows.py | 7 | ||||
-rw-r--r-- | geneticone/gui/gtk/wrapper.py | 77 | ||||
-rw-r--r-- | geneticone/gui/gui_helper.py | 31 | ||||
-rw-r--r-- | geneticone/gui/wrapper.py | 132 |
6 files changed, 234 insertions, 17 deletions
diff --git a/geneticone/gui/gtk/__init__.py b/geneticone/gui/gtk/__init__.py index e58319a..e7b1bb5 100644 --- a/geneticone/gui/gtk/__init__.py +++ b/geneticone/gui/gtk/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# File: geneticone/gui/__init__.py +# File: geneticone/gui/gtk/__init__.py # This file is part of the Genetic/One-Project, a graphical portage-frontend. # # Copyright (C) 2006 René 'Necoro' Neumann diff --git a/geneticone/gui/gtk/dialogs.py b/geneticone/gui/gtk/dialogs.py index 92b3c7f..cb643ce 100644 --- a/geneticone/gui/gtk/dialogs.py +++ b/geneticone/gui/gtk/dialogs.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# File: geneticone/gui/dialogs.py +# File: geneticone/gui/gtk/dialogs.py # This file is part of the Genetic/One-Project, a graphical portage-frontend. # # Copyright (C) 2006 René 'Necoro' Neumann diff --git a/geneticone/gui/gtk/windows.py b/geneticone/gui/gtk/windows.py index 0277e51..7b9dd94 100644 --- a/geneticone/gui/gtk/windows.py +++ b/geneticone/gui/gtk/windows.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# File: geneticone/gui/windows.py +# File: geneticone/gui/gtk/windows.py # This file is part of the Genetic/One-Project, a graphical portage-frontend. # # Copyright (C) 2006 René 'Necoro' Neumann @@ -10,7 +10,7 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -VERSION = "0.4.5" +VERSION = "0.4.6-svn" CONFIG_LOCATION = "/etc/geneticone/geneticone.cfg" # gtk stuff @@ -28,6 +28,7 @@ from geneticone.backend.exceptions import * # more GUI stuff from geneticone.gui.gui_helper import Database, Config, EmergeQueue from dialogs import * +from wrapper import GtkTree, GtkConsole # for the terminal import vte @@ -760,7 +761,7 @@ class MainWindow: self.window.show_all() # set emerge queue - self.queue = EmergeQueue(console=term, tree = emergeStore, db = self.db) + self.queue = EmergeQueue(console = GtkConsole(term), tree = GtkTree(emergeStore), db = self.db) def create_uimanager(self): ui =""" diff --git a/geneticone/gui/gtk/wrapper.py b/geneticone/gui/gtk/wrapper.py new file mode 100644 index 0000000..4407816 --- /dev/null +++ b/geneticone/gui/gtk/wrapper.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +# +# File: geneticone/gui/gtk/wrapper.py +# This file is part of the Genetic/One-Project, a graphical portage-frontend. +# +# Copyright (C) 2006 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +from geneticone.gui.wrapper import Tree, Console + +class GtkTree (Tree): + """The implementation of the abstract tree.""" + + def __init__ (self, tree, col = 0): + """Constructor. + + @param tree: original tree + @type tree: gtk.TreeStore + @param col: the column where the cpv is stored + @type col: int""" + + self.tree = tree + self.cpv_col = col + + def iter_has_parent (self, it): + return (self.tree.iter_parent(it) != None) + + def parent_iter (self, it): + return self.tree.iter_parent(it) + + def first_child_iter (self, it): + return self.tree.iter_children(it) + + def iter_has_children (self, it): + return self.tree.iter_has_children(it) + + def next_iter (self, it): + return self.tree.iter_next(it) + + def get_value (self, it, column): + return self.tree.get_value(it, column) + + def get_path_from_iter (self, it): + return self.tree.get_string_from_iter(it) + + def append (self, parent = None, values = None): + return self.tree.append(parent, values) + + def remove (self, it): + return self.tree.remove(it) + + def get_original (self): + return self.tree + + def get_cpv_column (self): + return self.cpv_col + +class GtkConsole (Console): + """The implementation of the abstract Console for GTK.""" + + def __init__ (self, console): + """Constructor. + + @param console: the original console + @type console: vte.Terminal""" + + self.console = console + + def set_pty (self, pty): + self.console.set_pty(pty) + + def get_original (self): + return self.console diff --git a/geneticone/gui/gui_helper.py b/geneticone/gui/gui_helper.py index 2f758b2..8afc137 100644 --- a/geneticone/gui/gui_helper.py +++ b/geneticone/gui/gui_helper.py @@ -15,6 +15,9 @@ from geneticone import backend from geneticone.backend import flags from geneticone.helper import * +# the wrapper +from wrapper import Console, Tree + # some stuff needed from subprocess import Popen, PIPE, STDOUT from threading import Thread @@ -219,9 +222,9 @@ class EmergeQueue: """Constructor. @param tree: Tree to append all the items to. - @type tree: gtk.TreeStore + @type tree: Tree @param console: Output is shown here. - @type console: vte.Terminal + @type console: Console @param db: A database instance. @type db: Database""" @@ -236,7 +239,11 @@ class EmergeQueue: # member vars self.tree = tree + if self.tree and not isinstance(self.tree, Tree): raise TypeError, "tree passed is not a Tree-object" + self.console = console + if self.console and not isinstance(self.console, Console): raise TypeError, "console passed is not a Console-object" + self.db = db # our iterators pointing at the toplevels; they are set to None if do not have a tree @@ -309,9 +316,9 @@ class EmergeQueue: options += ["updating from "+old.get_version()] except backend.PackageNotFoundException, e: # package not found / package is masked -> delete current tree and re-raise the exception - if self.tree.iter_parent(it): - while self.tree.iter_parent(it): - it = self.tree.iter_parent(it) + if self.tree.iter_has_parent(it): + while self.tree.iter_has_parent(it): + it = self.tree.parent_iter(it) self.remove_with_children(it) raise e @@ -363,7 +370,7 @@ class EmergeQueue: return # nothing changed - return else: hasBeenInQueue = (cpv in self.mergequeue or cpv in self.oneshotmerge) - parentIt = self.tree.iter_parent(self.iters[cpv]) + parentIt = self.tree.parent_iter(self.iters[cpv]) # delete it out of the tree - but NOT the changed flags self.remove_with_children(self.iters[cpv], removeNewFlags = False) @@ -532,13 +539,13 @@ class EmergeQueue: @param removeNewFlags: True if new flags should be removed; False otherwise. Default: True. @type removeNewFlags: boolean""" - childIt = self.tree.iter_children(parentIt) + childIt = self.tree.first_child_iter(parentIt) while childIt: - if (self.tree.iter_has_child(childIt)): # recursive call + if (self.tree.iter_has_children(childIt)): # recursive call self.remove_children(childIt, removeNewFlags) temp = childIt - childIt = self.tree.iter_next(childIt) + childIt = self.tree.next_iter(childIt) self.remove(temp, removeNewFlags) def remove (self, it, removeNewFlags = True): @@ -549,9 +556,9 @@ class EmergeQueue: @param removeNewFlags: True if new flags should be removed; False otherwise. Default: True. @type removeNewFlags: boolean""" - if self.tree.iter_parent(it): # NEVER remove our top stuff - cpv = self.tree.get_value(it,0) - if self.tree.get_string_from_iter(it).split(":")[0] == self.tree.get_string_from_iter(self.emergeIt): # in Emerge + if self.tree.iter_has_parent(it): # NEVER remove our top stuff + cpv = self.tree.get_value(it, self.tree.get_cpv_column()) + if self.tree.get_path_from_iter(it).split(":")[0] == self.tree.get_path_from_iter(self.emergeIt): # in Emerge del self.iters[cpv] try: del self.deps[cpv] diff --git a/geneticone/gui/wrapper.py b/geneticone/gui/wrapper.py new file mode 100644 index 0000000..fd69e82 --- /dev/null +++ b/geneticone/gui/wrapper.py @@ -0,0 +1,132 @@ +# -*- coding: utf-8 -*- +# +# File: geneticone/gui/wrapper.py +# This file is part of the Genetic/One-Project, a graphical portage-frontend. +# +# Copyright (C) 2006 René 'Necoro' Neumann +# This is free software. You may redistribute copies of it under the terms of +# the GNU General Public License version 2. +# There is NO WARRANTY, to the extent permitted by law. +# +# Written by René 'Necoro' Neumann <necoro@necoro.net> + +class Tree: + """This represents an abstract of a Tree-Widget. It should be used for all operations not in a specific frontend, where a Tree is needed. + Each frontend _MUST_ define its own subclass and implement ALL of the methods, otherwise a NotImplementedError will be thrown.""" + + def iter_has_parent (self, it): + """Returns whether the actual iterator has a parent. + + @param it: the iterator + @type it: Iterator + @returns: True if it has a parent it, else False. + @rtype: boolean""" + raise NotImplementedError + + def parent_iter (self, it): + """Returns the parent iter. + + @param it: the iterator + @type it: Iterator + @returns: Parent iterator or None if the current it has no parent. + @rtype: Iterator; None""" + raise NotImplementedError + + def first_child_iter (self, it): + """Returns the first child iter. + + @param it: the iterator + @type it: Iterator + @returns: First child iterator or None if the current it has no children. + @rtype: Iterator; None""" + raise NotImplementedError + + def iter_has_children (self, it): + """Returns whether the actual iterator has children. + + @param it: the iterator + @type it: Iterator + @returns: True if it has children, else False. + @rtype: boolean""" + raise NotImplementedError + + def next_iter (self, it): + """Returns the next iter. + + @param it: the iterator + @type it: Iterator + @returns: Nex iterator or None if the current iter is the last one. + @rtype: Iterator; None""" + raise NotImplementedError + + def get_value (self, it, column): + """Returns the value of the specific column at the given iterator. + + @param it: the iterator + @type it: Iterator + @param column: the column of the iterator from where to get the value + @type column: int + @returns: the value + @rtype: anything""" + raise NotImplementedError + + def get_path_from_iter(self, it): + """Returns a string defining the path to the given iterator. In this path all nodes are divided by a colon ':'. + For example: 2:4:5 could mean the 6th child of the 5th child of the 3rd element. It might also mean the 5th child of the 4th child of the 2nd element. It does not matter, where counting starts as long as it is consistent. + + @param it: the iterator + @type it: Iterator + @returns: the path string + @rtype: string""" + raise NotImplementedError + + def append (self, parent = None, values = None): + """Appends some values right after the given parent. If parent is None, it is appended as the first element. + + @param parent: the iterator to append the values right after; if None it symbolizes the top + @type parent: Iterator + @param values: a list of values which are going to be appended to the tree + @type values: list + @returns: Iterator pointing to the newly appended stuff + @rtype: Iterator""" + raise NotImplementedError + + def remove(self, it): + """Removes an iterator out of the tree. + @attention: The iterator can point to anything hereafter. Do not reuse! + + @param it: iterator to remove + @type it: Iterator""" + raise NotImplementedError + + def get_original(self): + """Returns the original tree-object. + + @returns: original tree-object + @rtype: tree-object""" + raise NotImplementedError + + def get_cpv_column (self): + """Returns the number of the column where the cpv's are stored. + + @returns: column with cpv's + @rtype: int""" + raise NotImplementedError + +class Console: + """This represents the abstract of a console. It should be used for all operations not in a specific frontend, where a console is needed. + Each frontend _MUST_ define its own subclass and implement ALL of the methods, otherwise a NotImplementedError will be thrown.""" + + def set_pty (self, pty): + """This sets the pseudo-terminal where to print the incoming output to. + + @param pty: the terminal to print to + @type pty: file-descriptor""" + raise NotImplementedError + + def get_original(self): + """Returns the original console-object. + + @returns: original console-object + @rtype: console-object""" + raise NotImplementedError |