From 3a1d0db1f30133bae568341428d427cf5a5d0495 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Wed, 24 Jan 2007 22:15:27 +0000 Subject: - Added icons - Added support for killing the process - Reorganised setup and starting-script --- doc/Changelog | 2 + portato.py | 20 +- portato/constants.py | 5 +- portato/gui/gtk/glade/portato.glade | 487 +++++++++++++++++++++--------------- portato/gui/gtk/windows.py | 65 +++-- portato/gui/gui_helper.py | 18 +- setup.py | 25 +- 7 files changed, 381 insertions(+), 241 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index f2d037a..9a8f78b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -4,6 +4,8 @@ - added console-status - working slots (for update_world) - enhanced "--newuse" +- added some stock-images +- added ability to kill the running emerge process 0.5.1: - new config parser and new config-layout diff --git a/portato.py b/portato.py index 1f77354..65cee2c 100755 --- a/portato.py +++ b/portato.py @@ -12,12 +12,12 @@ # # Written by René 'Necoro' Neumann -from portato.constants import VERSION +from portato.constants import VERSION, FRONTENDS, STD_FRONTEND import sys if __name__ == "__main__": - uimod = "gtk" + uimod = STD_FRONTEND if len(sys.argv) > 1: if sys.argv[1] in ("--help","--version","-h","-v"): @@ -30,13 +30,17 @@ There is NO WARRANTY, to the extent permitted by law. Written by René 'Necoro' Neumann """ % VERSION else: uimod = sys.argv[1] - - if uimod == "gtk": - from portato.gui.gtk import run - elif uimod == "curses": - from portato.gui.curses import run + if uimod in FRONTENDS: + try: + exec ("from portato.gui.%s import run" % uimod) + except ImportError: + print "'%s' should be installed, but cannot be imported. This is definitly a bug." % uimod + sys.exit(1) else: - print "Unknown interface %s. Correct interfaces are: gtk, curses" % uimod + print ("Unknown interface '%s'. Correct interfaces are:" % uimod) , + for u in FRONTENDS: + print u , + print sys.exit(1) run() diff --git a/portato/constants.py b/portato/constants.py index 9424036..c4ffd6e 100644 --- a/portato/constants.py +++ b/portato/constants.py @@ -3,7 +3,7 @@ # File: portato/constants.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -15,3 +15,6 @@ CONFIG_LOCATION = CONFIG_DIR+"portato.cfg" DATA_DIR = "portato/gui/gtk/glade/" VERSION = 9999 + +FRONTENDS = ["gtk"] +STD_FRONTEND = "gtk" diff --git a/portato/gui/gtk/glade/portato.glade b/portato/gui/gtk/glade/portato.glade index 811dced..8956a2d 100644 --- a/portato/gui/gtk/glade/portato.glade +++ b/portato/gui/gtk/glade/portato.glade @@ -21,19 +21,41 @@ True - + True _Preferences True + + + True + gtk-preferences + 1 + 0.5 + 0.5 + 0 + 0 + + - + True - _Reload Portage + Re_load Portage True + + + True + gtk-refresh + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -42,11 +64,22 @@ - + True _Close True + + + True + gtk-quit + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -85,6 +118,11 @@ + + + True + + True @@ -101,6 +139,30 @@ + + + True + + + + + True + _Kill Emerge + True + + + + True + gtk-stop + 1 + 0.5 + 0.5 + 0 + 0 + + + + @@ -114,11 +176,22 @@ True - + True _About True + + + True + gtk-about + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -230,72 +303,48 @@ 4 2 - + True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC + 1 + True - + True + True + Installed + True + + + False + - - - 2 - 2 - 3 - 5 - 5 - - - - - True - + + True + True + Masked + True + + + + False + 1 + + + + + True + True + Testing + True + + + + False + 2 + - - - 1 - 2 - GTK_FILL - 5 - - - - - True - GTK_JUSTIFY_CENTER - True - - - 2 - GTK_FILL - - 10 - - - - - True - True - <span foreground='red'><b>MISSING KEYWORD</b></span> - True - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - True - <b>Installed, but not in portage anymore</b> - True 1 @@ -349,55 +398,79 @@ - + + True + True + <b>Installed, but not in portage anymore</b> + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + True + <span foreground='red'><b>MISSING KEYWORD</b></span> + True + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + GTK_JUSTIFY_CENTER + True + + + 2 + GTK_FILL + + 10 + + + + True - 1 - True - - - True - True - Installed - True - - - - False - - - - True - True - Masked - True - - - - False - 1 - + + + + 1 + 2 + GTK_FILL + 5 + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC - + True - True - Testing - True - - - False - 2 - - 1 2 - 1 - 2 - GTK_FILL + 2 + 3 + 5 + 5 @@ -781,186 +854,186 @@ - - True - 0 - 5 - <u><i>Masking Keywords</i></u> - True - True - - - 7 - 8 - 5 - - - - + True - 0 - 5 - <u><i>Testing Keywords</i></u> - True - True - 4 - 5 - 5 + 1 + 2 + 3 + 4 - + True 0 - 5 - <u><i>Use-Flags</i></u> - True + File name to use, if package.use is a directory: True - 1 - 2 - 6 + 3 + 4 - + True - - - True - 0 - GTK_SHADOW_OUT - - - True - 0 - <u>You may use the following placeholders:</u> - -<i>$(cat)</i>: category -<i>$(pkg)</i>: package name -<i>$(cat-1)/$(cat-2)</i>: first/second part of the category - True - - - - - - label_item - - - - + Add only exact version to package.use + True 2 + 2 + 3 - + True - Add only exact version to package.mask/package.unmask + Add only exact version to package.keywords True 2 - 8 - 9 + 5 + 6 - + True 0 - File name to use, if package.mask/package.unmask is a directory: + File name to use, if package.keywords is a directory: True - 9 - 10 + 6 + 7 - + True 1 2 - 9 - 10 + 6 + 7 - + True 1 2 - 6 - 7 + 9 + 10 - + True 0 - File name to use, if package.keywords is a directory: + File name to use, if package.mask/package.unmask is a directory: True - 6 - 7 + 9 + 10 - + True - Add only exact version to package.keywords + Add only exact version to package.mask/package.unmask True 2 - 5 - 6 + 8 + 9 - + True - Add only exact version to package.use - True + + + True + 0 + GTK_SHADOW_OUT + + + True + 0 + <u>You may use the following placeholders:</u> + +<i>$(cat)</i>: category +<i>$(pkg)</i>: package name +<i>$(cat-1)/$(cat-2)</i>: first/second part of the category + True + + + + + + label_item + + + + 2 - 2 - 3 - + True 0 - File name to use, if package.use is a directory: + 5 + <u><i>Use-Flags</i></u> + True True - 3 - 4 + 1 + 2 + 6 - + True + 0 + 5 + <u><i>Testing Keywords</i></u> + True + True - 1 - 2 - 3 - 4 + 4 + 5 + 5 + + + + + True + 0 + 5 + <u><i>Masking Keywords</i></u> + True + True + + + 7 + 8 + 5 @@ -1024,4 +1097,26 @@ + + True + + + True + Kill Process + True + + + + True + gtk-stop + 1 + 0.5 + 0.5 + 0 + 0 + + + + + diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index eb5e3c5..239606a 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -3,7 +3,7 @@ # File: portato/gui/gtk/windows.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -35,9 +35,11 @@ import vte # other from portage_util import unique_array +GLADE_FILE = DATA_DIR+"portato.glade" + class Window: def __init__ (self): - self.tree = gtk.glade.XML(DATA_DIR+"portato.glade", root = self.__class__.__name__) + self.tree = gtk.glade.XML(GLADE_FILE, root = self.__class__.__name__) self.tree.signal_autoconnect(self) self.window = self.tree.get_widget(self.__class__.__name__) @@ -60,6 +62,11 @@ class Window: return ret return wrapper + def create_popup (self, name): + popupTree = gtk.glade.XML(GLADE_FILE, root = name) + popupTree.signal_autoconnect(self) + return popupTree.get_widget(name) + class AbstractDialog (Window): """A class all our dialogs get derived from. It sets useful default vars and automatically handles the ESC-Button.""" @@ -106,7 +113,7 @@ class AboutWindow (AbstractDialog): A Portage-GUI This software is licensed under the terms of the GPLv2. -Copyright (C) 2006 René 'Necoro' Neumann <necoro@necoro.net> +Copyright (C) 2006-2007 René 'Necoro' Neumann <necoro@necoro.net> Thanks to Fred for support and ideas :P """ % VERSION) @@ -598,16 +605,14 @@ class MainWindow (Window): self.build_queue_list() # the terminal - term = vte.Terminal() - term.set_scrollback_lines(1024) - term.set_scroll_on_output(True) - term.set_font_from_string("Monospace 11") - # XXX why is this not working with the colors - term.set_color_background(gtk.gdk.color_parse("white")) - term.set_color_foreground(gtk.gdk.color_parse("black")) + self.console = vte.Terminal() + self.console.set_scrollback_lines(1024) + self.console.set_scroll_on_output(True) + self.console.set_font_from_string("Monospace 11") + self.console.connect("button-press-event", self.cb_right_click) self.termHB = self.tree.get_widget("termHB") - termScroll = gtk.VScrollbar(term.get_adjustment()) - self.termHB.pack_start(term, True, True) + termScroll = gtk.VScrollbar(self.console.get_adjustment()) + self.termHB.pack_start(self.console, True, True) self.termHB.pack_start(termScroll, False) # notebook @@ -618,14 +623,13 @@ class MainWindow (Window): self.packageTable = PackageTable(self) self.packageTable.table.hide_all() - # popup - popupTree = gtk.glade.XML(DATA_DIR+"portato.glade", root = "queuePopup") - popupTree.signal_autoconnect(self) - self.queuePopup = popupTree.get_widget("queuePopup") + # popups + self.queuePopup = self.create_popup("queuePopup") + self.consolePopup = self.create_popup("consolePopup") # set emerge queue self.queueTree = GtkTree(self.queueList.get_model()) - self.queue = EmergeQueue(console = GtkConsole(term), tree = self.queueTree, db = self.db, title_update = self.title_update) + self.queue = EmergeQueue(console = GtkConsole(self.console), tree = self.queueTree, db = self.db, title_update = self.title_update) def show_package (self, *args, **kwargs): self.packageTable.update(*args, **kwargs) @@ -865,21 +869,27 @@ class MainWindow (Window): AboutWindow(self.window) return True - def cb_queue_right_click (self, queue, event): + def cb_right_click (self, object, event): if event.button == 3: x = int(event.x) y = int(event.y) time = event.time - pthinfo = queue.get_path_at_pos(x, y) - if pthinfo is not None: - path, col, cellx, celly = pthinfo - if self.queueTree.is_in_emerge(self.queueTree.get_original().get_iter(path)): - queue.grab_focus() - queue.set_cursor(path, col, 0) - self.queuePopup.popup(None, None, None, event.button, time) - return True + + if object == self.queueList: + pthinfo = object.get_path_at_pos(x, y) + if pthinfo is not None: + path, col, cellx, celly = pthinfo + if self.queueTree.is_in_emerge(self.queueTree.get_original().get_iter(path)): + object.grab_focus() + object.set_cursor(path, col, 0) + self.queuePopup.popup(None, None, None, event.button, time) + return True + elif object == self.console: + self.consolePopup.popup(None, None, None, event.button, time) else: return False + else: + return False def cb_oneshot_clicked (self, action): sel = self.queueList.get_selection() @@ -893,6 +903,9 @@ class MainWindow (Window): self.cfg.set_local(package, "oneshot_opt", set) self.queue.append(package, update = True, oneshot = set, forceUpdate = True) + + def cb_kill_clicked (self, action): + self.queue.kill_emerge() def cb_destroy (self, widget): """Calls main_quit().""" diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 7d8ead8..759752e 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -3,7 +3,7 @@ # File: portato/gui/gui_helper.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006 René 'Necoro' Neumann +# Copyright (C) 2006-2007 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. @@ -26,6 +26,8 @@ from subprocess import Popen, PIPE, STDOUT from threading import Thread import pty import time +import os +import signal class Config: """Wrapper around a ConfigParser and for additional local configurations.""" @@ -469,10 +471,10 @@ class EmergeQueue: self.console.set_pty(master) # start emerge - process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False) + self.process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False) # start thread waiting for the stop of emerge - Thread(name="Emerge-Thread", target=self._update_packages, args=(packages+self.deps.keys(), process)).start() + Thread(name="Emerge-Thread", target=self._update_packages, args=(packages+self.deps.keys(), self.process)).start() # remove for i in it: @@ -555,6 +557,16 @@ class EmergeQueue: else: self._emerge([],[],[], command = command) + def kill_emerge (self): + """Kills the emerge process.""" + try: + os.kill(self.process.pid, signal.SIGTERM) + debug("Process should be killed") + except AttributeError: + debug("AttributeError occured ==> process not exisiting - ignore") + except OSError: + debug("OSError occured ==> process already stopped - ignore") + def remove_with_children (self, it, removeNewFlags = True): """Convenience function which removes all children of an iterator and than the iterator itself. diff --git a/setup.py b/setup.py index b4d12f8..d48d396 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,24 @@ # -*- coding: utf-8 -*- from distutils.core import setup, Extension -from portato.constants import VERSION, DATA_DIR +from portato.constants import VERSION, DATA_DIR, FRONTENDS + +packages = ["portato", "portato.gui", "portato.backend"] +ext_modules = [] +data_files = [] +cmdclass = {} + +if "gtk" in FRONTENDS: + packages.append("portato.gui.gtk") + data_files.append((DATA_DIR, ["portato/gui/gtk/glade/portato.glade"])) setup(name="Portato", - version=VERSION, - author="René 'Necoro' Neumann", - license="GPLv2", - author_email="necoro@necoro.net", - packages=["portato", "portato.gui", "portato.backend", "portato.gui.gtk"], - data_files=[(DATA_DIR, ["portato/gui/gtk/glade/portato.glade"])] + version = VERSION, + author = "René 'Necoro' Neumann", + license = "GPLv2", + author_email = "necoro@necoro.net", + packages = packages, + data_files = data_files, + ext_modules = ext_modules, + cmdclass = cmdclass ) -- cgit v1.2.3-54-g00ecf