From 2d76b0ba7f6d0040c42e53df87f1ffbcbbe2cba1 Mon Sep 17 00:00:00 2001
From: necoro <>
Date: Tue, 10 Apr 2007 20:09:37 +0000
Subject: Some more functionality for the Qt-Frontend (complete emerge)
---
portato/gui/gtk/glade/portato.glade | 385 ++++++++++++++++++------------------
portato/gui/gtk/windows.py | 2 +-
portato/gui/gui_helper.py | 38 ++--
portato/gui/qt/dialogs.py | 3 +
portato/gui/qt/terminal.py | 20 +-
portato/gui/qt/ui/MainWindow.ui | 13 +-
portato/gui/qt/uncheckbox.py | 38 ++++
portato/gui/qt/windows.py | 65 +++++-
8 files changed, 347 insertions(+), 217 deletions(-)
create mode 100644 portato/gui/qt/uncheckbox.py
(limited to 'portato')
diff --git a/portato/gui/gtk/glade/portato.glade b/portato/gui/gtk/glade/portato.glade
index 7735975..f862b79 100644
--- a/portato/gui/gtk/glade/portato.glade
+++ b/portato/gui/gtk/glade/portato.glade
@@ -401,49 +401,73 @@
4
2
-
+
True
- 1
- True
-
-
- True
- True
- Installed
- True
-
-
-
- False
-
-
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
-
+
True
- True
- Masked
- True
-
-
- False
- 1
-
+
+
+ 2
+ 2
+ 3
+ 5
+ 5
+
+
+
+
+ True
-
- 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
2
@@ -507,79 +531,55 @@
-
- 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
+
-
-
- 1
- 2
- GTK_FILL
- 5
-
-
-
-
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
-
+
+ True
+ True
+ Masked
+ True
+
+
+
+ False
+ 1
+
+
+
+
True
+ True
+ Testing
+ True
+
+
+ False
+ 2
+
+ 1
2
- 2
- 3
- 5
- 5
+ 1
+ 2
+ GTK_FILL
@@ -904,7 +904,8 @@
- True
+ False
+ True
0
@@ -1089,186 +1090,186 @@
-
+
True
+ 0
+ 5
+ <u><i>Masking Keywords</i></u>
+ True
+ True
- 1
- 2
- 3
- 4
+ 7
+ 8
+ 5
-
+
True
0
- File name to use, if package.use is a directory:
+ 5
+ <u><i>Testing Keywords</i></u>
+ True
True
- 3
- 4
+ 4
+ 5
+ 5
-
+
True
- Add only exact version to package.use
- True
+ 0
+ 5
+ <u><i>Use-Flags</i></u>
+ True
+ True
+
+
+ 1
+ 2
+ 6
+
+
+
+
+ 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
- Add only exact version to package.keywords
+ Add only exact version to package.mask/package.unmask
True
2
- 5
- 6
+ 8
+ 9
-
+
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
1
2
- 6
- 7
+ 9
+ 10
-
+
True
1
2
- 9
- 10
+ 6
+ 7
-
+
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
- Add only exact version to package.mask/package.unmask
+ Add only exact version to package.keywords
True
2
- 8
- 9
+ 5
+ 6
-
+
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
- 0
- 5
- <u><i>Use-Flags</i></u>
- True
- True
-
-
- 1
- 2
- 6
-
-
-
-
+
True
0
- 5
- <u><i>Testing Keywords</i></u>
- True
+ File name to use, if package.use is a directory:
True
- 4
- 5
- 5
+ 3
+ 4
-
+
True
- 0
- 5
- <u><i>Masking Keywords</i></u>
- True
- True
- 7
- 8
- 5
+ 1
+ 2
+ 3
+ 4
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index 3fa39a8..e62ed52 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -605,7 +605,7 @@ class PackageTable:
return True
def cb_package_revert_clicked (self, button):
- """Callback for pressed cancel-button. Closes the window."""
+ """Callback for pressed revert-button."""
self.actual_package().remove_new_use_flags()
self.actual_package().remove_new_masked()
self.actual_package().remove_new_testing()
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py
index ecc3ba6..2b8ab44 100644
--- a/portato/gui/gui_helper.py
+++ b/portato/gui/gui_helper.py
@@ -499,11 +499,13 @@ class EmergeQueue:
sub_emerge(command)
- def emerge (self, force = False):
+ def emerge (self, force = False, options = None):
"""Emerges everything in the merge-queue.
@param force: If False, '-pv' is send to emerge. Default: False.
- @type force: boolean"""
+ @type force: boolean
+ @param options: Additional options to send to the emerge command
+ @type options: string[]"""
def prepare(queue):
"""Prepares the list of iterators and the list of packages."""
@@ -522,6 +524,7 @@ class EmergeQueue:
s = system.get_oneshot_option()
if not force: s += system.get_pretend_option()
+ if options is not None: s += options
self._emerge(s, list, its)
@@ -532,14 +535,17 @@ class EmergeQueue:
s = []
if not force: s = system.get_pretend_option()
+ if options is not None: s += options
self._emerge(s, list, its)
- def unmerge (self, force = False):
+ def unmerge (self, force = False, options = None):
"""Unmerges everything in the umerge-queue.
@param force: If False, '-pv' is send to emerge. Default: False.
- @type force: boolean"""
+ @type force: boolean
+ @param options: Additional options to send to the emerge command
+ @type options: string[]"""
if len(self.unmergequeue) == 0: return # nothing in queue
@@ -548,20 +554,28 @@ class EmergeQueue:
# set options
s = system.get_unmerge_option()
if not force: s += system.get_pretend_option()
+ if options is not None: s += options
self._emerge(s,list, [self.unmergeIt])
- def update_world(self, force = False, newuse = False, deep = False):
+ def update_world(self, force = False, newuse = False, deep = False, options = None):
"""Does an update world. newuse and deep are the arguments handed to emerge.
@param force: If False, '-pv' is send to emerge. Default: False.
- @type force: boolean"""
-
- options = system.get_update_option()
-
- if newuse: options += system.get_newuse_option()
- if deep: options += system.get_deep_option()
- if not force: options += system.get_pretend_option()
+ @type force: boolean
+ @param newuse: If True, append newuse options
+ @type force: boolean
+ @param deep: If True, append deep options
+ @type deep: boolean
+ @param options: Additional options to send to the emerge command
+ @type options: string[]"""
+
+ opts = system.get_update_option()
+
+ if newuse: opts += system.get_newuse_option()
+ if deep: opts += system.get_deep_option()
+ if not force: opts += system.get_pretend_option()
+ if options is not None: opts += options
self._emerge(options, ["world"], [self.emergeIt])
diff --git a/portato/gui/qt/dialogs.py b/portato/gui/qt/dialogs.py
index cf32439..7b5609e 100644
--- a/portato/gui/qt/dialogs.py
+++ b/portato/gui/qt/dialogs.py
@@ -36,3 +36,6 @@ def remove_deps_dialog (parent):
def remove_queue_dialog (parent):
return QMessageBox.question(parent, "Portato", "Do you really want to clear the whole queue?", QMessageBox.Yes | QMessageBox.No)
+
+def changed_flags_dialog (parent, what = "flags"):
+ return QMessageBox.information(parent, "Portato", "You have changed %s. Portato will write these changes into the appropriate files. Please backup them if you think it is necessairy." % what, QMessageBox.Ok)
diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py
index 9fbc39c..eabe467 100644
--- a/portato/gui/qt/terminal.py
+++ b/portato/gui/qt/terminal.py
@@ -99,21 +99,29 @@ class QtConsole (Console, QtGui.QTextEdit):
def write(self, text):
self.emit(QtCore.SIGNAL("doSomeWriting"), text)
+ def start_new_thread (self):
+ self.run = True
+ self.current = Thread(target=self.__run)
+ self.current.setDaemon(True) # close application even if this thread is running
+ self.current.start()
+
def set_pty (self, pty):
if not self.running:
self.pty = pty
-
- t = Thread(target=self.__run)
- t.setDaemon(True) # close application even if this thread is running
- t.start()
-
+ self.start_new_thread()
self.running = True
+
else:
+ # quit current thread
+ self.run = False
+ # self.current.join()
self.clear()
+
self.pty = pty # set this after clearing to lose no chars :)
+ self.start_new_thread()
def __run (self):
- while True:
+ while self.run:
s = read(self.pty, 1)
if s == "": break
diff --git a/portato/gui/qt/ui/MainWindow.ui b/portato/gui/qt/ui/MainWindow.ui
index 5a8f950..f942ea7 100644
--- a/portato/gui/qt/ui/MainWindow.ui
+++ b/portato/gui/qt/ui/MainWindow.ui
@@ -167,11 +167,11 @@ p, li { white-space: pre-wrap; }
-
-
+
- 3
- 0
+ 13
+ 13
0
0
@@ -428,6 +428,13 @@ p, li { white-space: pre-wrap; }
+
+
+ UncheckBox
+ QCheckBox
+ portato/gui/qt/uncheckbox.h
+
+
diff --git a/portato/gui/qt/uncheckbox.py b/portato/gui/qt/uncheckbox.py
new file mode 100644
index 0000000..d87fb06
--- /dev/null
+++ b/portato/gui/qt/uncheckbox.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/gui/qt/uncheckbox.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 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.
+#
+# Written by René 'Necoro' Neumann
+
+from PyQt4.QtGui import QCheckBox
+from PyQt4.QtCore import Qt
+
+class UncheckBox (QCheckBox):
+ """A checkbox which looks like a normal one, but cannot be checked by the user.
+ Focusing and hovering are disabled too."""
+
+ def __init__ (self, *args):
+ QCheckBox.__init__(self, *args)
+ self.setFocusPolicy(Qt.NoFocus)
+
+ def mousePressEvent (self, event):
+ if event.button() == Qt.LeftButton: # ignore leftbutton clicks
+ pass
+ else:
+ QCheckBox.mousePressEvent(self, event)
+
+ def keyPressEvent (self, event):
+ if event.key() == Qt.Key_Space: # ignore space
+ pass
+ else:
+ QCheckBox.keyPressEvent(self, event)
+
+ def enterEvent (self, event):
+ # disable hovering - this is set to True somewhere I cannot fix ;)
+ self.setAttribute(Qt.WA_Hover, False)
diff --git a/portato/gui/qt/windows.py b/portato/gui/qt/windows.py
index e6fc7bc..46d9ec6 100644
--- a/portato/gui/qt/windows.py
+++ b/portato/gui/qt/windows.py
@@ -86,8 +86,8 @@ class SearchDialog (Window):
@type parent: QtGui.QWidget
@param list: list of results to show
@type list: string[]
- @param jump_to: function to call if "OK"-Button is hit
- @type jump_to: function(string)"""
+ @param jumpTo: function to call if "OK"-Button is hit
+ @type jumpTo: function(string)"""
Window.__init__(self, parent)
@@ -109,8 +109,16 @@ class PackageDetails:
self.window.pkgTab.setHidden(True)
self.window.tabWidget.removeTab(0)
+ self.window.installedCheck.blockSignals(True)
+
QtCore.QObject.connect(self.window.versCombo, QtCore.SIGNAL("currentIndexChanged(int)"), self.cb_combo_changed)
+
QtCore.QObject.connect(self.window.pkgEmergeBtn, QtCore.SIGNAL("clicked()"), self.cb_emerge_clicked)
+ QtCore.QObject.connect(self.window.pkgUnmergeBtn, QtCore.SIGNAL("clicked()"), self.cb_unmerge_clicked)
+ QtCore.QObject.connect(self.window.pkgRevertBtn, QtCore.SIGNAL("clicked()"), self.cb_revert_clicked)
+
+ #QtCore.QObject.connect(self.window.maskedCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_masked_clicked)
+ #QtCore.QObject.connect(self.window.testingCheck, QtCore.SIGNAL("clicked(bool)"), self.cb_testing_clicked)
def update (self, cp, queue = None, version = None, doEmerge = True, instantChange = False):
"""Updates the table to show the contents for the package.
@@ -237,7 +245,26 @@ class PackageDetails:
self.window.tabWidget.setCurrentIndex(self.window.QUEUE_PAGE)
return True
- def cb_combo_changed (self, combo):
+ def cb_unmerge_clicked (self):
+ """Callback for pressed unmerge-button. Adds the package to the EmergeQueue."""
+ if not am_i_root():
+ not_root_dialog(self.window)
+ else:
+ self._update_keywords(False)
+ self.window.tabWidget.setCurrentIndex(self.window.QUEUE_PAGE)
+ return True
+
+ def cb_revert_clicked (self, button):
+ """Callback for pressed revert-button."""
+ self.actual_package().remove_new_use_flags()
+ self.actual_package().remove_new_masked()
+ self.actual_package().remove_new_testing()
+ self.cb_combo_changed()
+ if self.instantChange:
+ self._update_keywords(True, update = True)
+ return True
+
+ def cb_combo_changed (self):
"""Callback for the changed ComboBox.
It then rebuilds the useList and the checkboxes."""
@@ -419,6 +446,38 @@ class MainWindow (Window):
self.queue.remove_with_children(selected)
self.doUpdate = False
+ @QtCore.pyqtSignature("")
+ def on_emergeBtn_clicked (self):
+ """Do emerge."""
+
+ self.tabWidget.setCurrentIndex(self.CONSOLE_PAGE)
+
+ if len(flags.newUseFlags) > 0:
+ changed_flags_dialog(self, "use flags")
+ flags.write_use_flags()
+
+ if len(flags.new_masked)>0 or len(flags.new_unmasked)>0 or len(flags.newTesting)>0:
+ debug("new masked:",flags.new_masked)
+ debug("new unmasked:", flags.new_unmasked)
+ debug("new testing:", flags.newTesting)
+ changed_flags_dialog(self, "masking keywords")
+ flags.write_masked()
+ flags.write_testing()
+ system.reload_settings()
+
+ if not self.doUpdate:
+ self.queue.emerge(force=True, options = ["--nospinner"])
+ else:
+ self.queue.update_world(force=True, newuse = self.cfg.get_boolean("newuse_opt"), deep = self.cfg.get_boolean("deep_opt"), options = ["--nospinner"])
+ self.doUpdate = False
+
+ @QtCore.pyqtSignature("")
+ def on_unmergeBtn_clicked (self):
+ """Do unmerge."""
+
+ self.tabWidget.setCurrentIndex(self.CONSOLE_PAGE)
+ self.queue.unmerge(force = True)
+
def cb_cat_list_selected (self, index, prev):
self.selCatName = str(index.data().toString())
self.fill_pkg_list(self.selCatName)
--
cgit v1.2.3-70-g09d2