commit e17fa925a2369c4b65fc91a60e53cd29cc62e688 Author: Kamran Riaz Khan krkhan@inspirated.com Date: Sat Jul 9 18:46:56 2011 +0500
Add getListingRow() methods to GUI entry lines.
This delegates the row construction to entry line classes instead of connection panel, making the effort of having derived GUI entry classes worthwhile :) . --- src/gui/connections/circEntry.py | 16 ++++++++++++++++ src/gui/connections/connEntry.py | 9 +++++++++ src/gui/connections/connPanel.py | 5 +---- 3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/src/gui/connections/circEntry.py b/src/gui/connections/circEntry.py index 63436cf..cb79a9b 100644 --- a/src/gui/connections/circEntry.py +++ b/src/gui/connections/circEntry.py @@ -2,6 +2,8 @@ Connection panel entries for client circuits. """
+import time + from cli.connections import circEntry
class CircEntry(circEntry.CircEntry): @@ -14,8 +16,22 @@ class CircHeaderLine(circEntry.CircHeaderLine): def convertToGui(self, instance): instance.__class__ = self
+ def getListingRow(self): + local = "%s:%s" % (self.local.ipAddr, self.local.port) + foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port) + timeLabel = "%d s" % (time.time() - self.startTime) + + return (local, foreign, timeLabel, self.baseType, 'black') + class CircLine(circEntry.CircLine): @classmethod def convertToGui(self, instance): instance.__class__ = self
+ def getListingRow(self): + local = "%s:%s" % (self.local.ipAddr, self.local.port) + foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port) + timeLabel = "%d s" % (time.time() - self.startTime) + + return (local, foreign, timeLabel, self.baseType, 'black') + diff --git a/src/gui/connections/connEntry.py b/src/gui/connections/connEntry.py index 4db0a10..bc4ec53 100644 --- a/src/gui/connections/connEntry.py +++ b/src/gui/connections/connEntry.py @@ -3,6 +3,8 @@ Connection panel entries related to actual connections to or from the system (ie, results seen by netstat, lsof, etc). """
+import time + from cli.connections import connEntry
class ConnectionEntry(connEntry.ConnectionEntry): @@ -15,3 +17,10 @@ class ConnectionLine(connEntry.ConnectionLine): def convertToGui(self, instance): instance.__class__ = self
+ def getListingRow(self): + local = "%s:%s" % (self.local.ipAddr, self.local.port) + foreign = "%s:%s" % (self.foreign.ipAddr, self.foreign.port) + timeLabel = "%d s" % (time.time() - self.startTime) + + return (local, foreign, timeLabel, self.baseType, 'black') + diff --git a/src/gui/connections/connPanel.py b/src/gui/connections/connPanel.py index d8d987a..2c2248a 100644 --- a/src/gui/connections/connPanel.py +++ b/src/gui/connections/connPanel.py @@ -89,10 +89,7 @@ class ConnectionPanel(CliConnectionPanel): if isinstance(line, connEntry.ConnectionLine) and line.isUnresolvedApp(): self._resolveApps()
- local = "%s:%s" % (line.local.ipAddr, line.local.port) - foreign = "%s:%s" % (line.foreign.ipAddr, line.foreign.port) - timeLabel = "%d s" % (time.time() - line.startTime) - row = (local, foreign, timeLabel, line.baseType, 'black') + row = line.getListingRow()
if isinstance(line, circEntry.CircHeaderLine): currentiter = treestore.append(None, row)
tor-commits@lists.torproject.org