summaryrefslogtreecommitdiff
path: root/portato/gui
diff options
context:
space:
mode:
authornecoro <>2007-04-27 18:32:07 +0000
committernecoro <>2007-04-27 18:32:07 +0000
commitce3139188ed3f4564d37a1ffb02bb20daff6adb1 (patch)
tree93aaf3259750f9d3c61712d4b6dd420258c096c3 /portato/gui
parent9b4319e484de43ac72b407d0656e967445c36dd4 (diff)
downloadportato-ce3139188ed3f4564d37a1ffb02bb20daff6adb1.tar.gz
portato-ce3139188ed3f4564d37a1ffb02bb20daff6adb1.tar.bz2
portato-ce3139188ed3f4564d37a1ffb02bb20daff6adb1.zip
fixed bugs in gtk and qt
Diffstat (limited to 'portato/gui')
-rw-r--r--portato/gui/gtk/windows.py19
-rw-r--r--portato/gui/qt/terminal.py59
2 files changed, 58 insertions, 20 deletions
diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py
index 7c6f41b..ffeb01f 100644
--- a/portato/gui/gtk/windows.py
+++ b/portato/gui/gtk/windows.py
@@ -914,15 +914,18 @@ class MainWindow (Window):
def title_update (self, title):
- if self.tray:
- self.tray.set_tooltip(title)
-
- if title == None:
- title = "Console"
- else:
- title = ("Console (%s)" % title)
+ def __update(title):
+ if self.tray:
+ self.tray.set_tooltip(title)
+
+ if title == None:
+ title = "Console"
+ else:
+ title = ("Console (%s)" % title)
+
+ self.notebook.set_tab_label_text(self.termHB, title)
- gobject.idle_add(self.notebook.set_tab_label_text, self.termHB, title)
+ gobject.idle_add(__update, title)
def cb_cat_list_selection (self, view):
"""Callback for a category-list selection. Updates the package list with the packages in the category."""
diff --git a/portato/gui/qt/terminal.py b/portato/gui/qt/terminal.py
index 85bea0e..bae6240 100644
--- a/portato/gui/qt/terminal.py
+++ b/portato/gui/qt/terminal.py
@@ -12,12 +12,23 @@
from PyQt4 import Qt
-from threading import Thread, Lock
+from Queue import Queue
+from threading import Thread
from os import read
from portato.gui.wrapper import Console
from portato.helper import debug
+class WriteEvent (Qt.QEvent):
+ TYPE = Qt.QEvent.Type(1001)
+
+ def __init__ (self, string):
+ Qt.QEvent.__init__(self, self.TYPE)
+ self.string = string
+
+ def get_string(self):
+ return self.string
+
class BoldFormat (Qt.QTextCharFormat):
def __init__(self):
@@ -76,20 +87,29 @@ class QtConsole (Console, Qt.QTextEdit):
self.pty = None
self.running = False
self.stdFormat = self.currentCharFormat()
- self.formatQueue = []
- self.formatLock = Lock()
+ self.formatQueue = Queue()
self.title = None
+ self.writeQueue = ""
self.setReadOnly(True)
# we need these two signals, as threads are not allowed to access the GUI
# solution: thread sends signal, which is handled by the main loop
- Qt.QObject.connect(self, Qt.SIGNAL("doSomeWriting"), self._write)
+# Qt.QObject.connect(self, Qt.SIGNAL("doSomeWriting"), self._write)
Qt.QObject.connect(self, Qt.SIGNAL("deletePrevChar()"), self._deletePrev)
def _deletePrev (self):
"""Deletes the previous character."""
self.textCursor().deletePreviousChar()
+
+ def event (self, event):
+ if event.type() == WriteEvent.TYPE:
+ self._write(event.get_string())
+ event.accept()
+ return True
+
+ event.ignore()
+ return False
def _write (self, text):
"""Writes some text. A text of "\\x1b" signals _write() to reload
@@ -115,7 +135,23 @@ class QtConsole (Console, Qt.QTextEdit):
def write(self, text):
"""Convenience function for emitting the writing signal."""
- self.emit(Qt.SIGNAL("doSomeWriting"), text)
+
+ def send (text):
+ Qt.QCoreApplication.postEvent(self, WriteEvent(text))
+
+ if text is None:
+ send(self.writeQueue)
+ self.writeQueue = ""
+
+ if text == esc_seq[0]:
+ send(self.writeQueue)
+ send(text)
+ self.writeQueue = ""
+ elif len(self.writeQueue) == 4:
+ send(self.writeQueue+text)
+ self.writeQueue = ""
+ else:
+ self.writeQueue = self.writeQueue + text
def start_new_thread (self):
"""Starts a new thread, which will listen for some input.
@@ -174,6 +210,10 @@ class QtConsole (Console, Qt.QTextEdit):
if s == "\r": continue
self.write(s)
+ self.write(None)
+# self.emit(Qt.SIGNAL("doSomeWriting"), "".join(self.writeQueue))
+# self.writeQueue = []
+
def parse_seq (self, seq):
"""Parses a sequence of bytes.
If a new attribute has been encountered, a new format is created and added
@@ -225,9 +265,7 @@ class QtConsole (Console, Qt.QTextEdit):
@param format: the format to add
@type format: Qt.QTextCharFormat"""
- self.formatLock.acquire()
- self.formatQueue.append(format)
- self.formatLock.release()
+ self.formatQueue.put(format)
def get_format (self):
"""Returns a format from the queue.
@@ -237,10 +275,7 @@ class QtConsole (Console, Qt.QTextEdit):
@returns: the popped format
@rtype: Qt.QTextCharFormat"""
- self.formatLock.acquire()
- f = self.formatQueue.pop(0)
- self.formatLock.release()
- return f
+ return self.formatQueue.get()
def virgin_format (self):
"""The normal standard format. It is necessary to create it as a new one for some