[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/release] Use consistent coloring across logs, graphs and conns.



commit ead474f1498dfe6baa1fd6636ec7d14da6706bb6
Author: Kamran Riaz Khan <krkhan@xxxxxxxxxxxxxx>
Date:   Sun Jul 10 20:43:56 2011 +0500

    Use consistent coloring across logs, graphs and conns.
---
 src/gui/arm.xml                  |    3 +++
 src/gui/connections/circEntry.py |    7 +++++--
 src/gui/connections/connEntry.py |    5 +++--
 src/gui/graphing/graphStats.py   |    9 +++++----
 src/gui/logPanel.py              |   16 ++++++++++------
 src/util/gtkTools.py             |   21 +++++++++++++++++++++
 6 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/src/gui/arm.xml b/src/gui/arm.xml
index 0aafb28..67409ae 100644
--- a/src/gui/arm.xml
+++ b/src/gui/arm.xml
@@ -435,6 +435,7 @@
                                 <property name="model">treestore_conn</property>
                                 <property name="headers_visible">False</property>
                                 <property name="headers_clickable">False</property>
+                                <property name="rules_hint">True</property>
                                 <property name="search_column">0</property>
                                 <child>
                                   <object class="GtkTreeViewColumn" id="treeviewcolumn_conn_origin">
@@ -617,6 +618,7 @@ each direction. (Default: 0) &lt;/span&gt;</property>
                         <property name="model">liststore_sticky</property>
                         <property name="headers_visible">False</property>
                         <property name="headers_clickable">False</property>
+                        <property name="rules_hint">True</property>
                         <property name="search_column">0</property>
                         <child>
                           <object class="GtkTreeViewColumn" id="treeviewcolumn_sticky_key">
@@ -667,6 +669,7 @@ each direction. (Default: 0) &lt;/span&gt;</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="model">liststore_log</property>
+                    <property name="rules_hint">True</property>
                     <child>
                       <object class="GtkTreeViewColumn" id="treeviewcolumn_log_timestamp">
                         <property name="title">Time</property>
diff --git a/src/gui/connections/circEntry.py b/src/gui/connections/circEntry.py
index a7ddc13..b3aa29a 100644
--- a/src/gui/connections/circEntry.py
+++ b/src/gui/connections/circEntry.py
@@ -5,6 +5,7 @@ Connection panel entries for client circuits.
 import time
 
 from cli.connections import circEntry
+from util import gtkTools
 
 class CircEntry(circEntry.CircEntry):
   @classmethod
@@ -20,8 +21,9 @@ class CircHeaderLine(circEntry.CircHeaderLine):
     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)
+    theme = gtkTools.Theme()
 
-    return (local, foreign, timeLabel, self.baseType, 'blue')
+    return (local, foreign, timeLabel, self.baseType, theme.colors['active'])
 
 class CircLine(circEntry.CircLine):
   @classmethod
@@ -32,6 +34,7 @@ class CircLine(circEntry.CircLine):
     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)
+    theme = gtkTools.Theme()
 
-    return (local, foreign, timeLabel, self.baseType, 'black')
+    return (local, foreign, timeLabel, self.baseType, theme.colors['normal'])
 
diff --git a/src/gui/connections/connEntry.py b/src/gui/connections/connEntry.py
index 1acef49..e7e666b 100644
--- a/src/gui/connections/connEntry.py
+++ b/src/gui/connections/connEntry.py
@@ -7,7 +7,7 @@ import time
 
 from cli.connections import connEntry, entries
 from cli.connections.connEntry import CONFIG, Category
-from util import uiTools, torTools
+from util import gtkTools, uiTools, torTools
 
 class ConnectionEntry(connEntry.ConnectionEntry):
   @classmethod
@@ -55,6 +55,7 @@ class ConnectionLine(connEntry.ConnectionLine):
       dst = "%s:%s" % (self.foreign.ipAddr, self.foreign.port)
 
     timeLabel = uiTools.getTimeLabel(time.time() - self.startTime)
+    theme = gtkTools.Theme()
 
-    return (src, dst, timeLabel, self.getType(), 'red')
+    return (src, dst, timeLabel, self.getType(), theme.colors['insensitive'])
 
diff --git a/src/gui/graphing/graphStats.py b/src/gui/graphing/graphStats.py
index 51150f8..250503d 100644
--- a/src/gui/graphing/graphStats.py
+++ b/src/gui/graphing/graphStats.py
@@ -11,7 +11,7 @@ import gobject
 import gtk
 
 from TorCtl import TorCtl
-from util import uiTools, torTools
+from util import gtkTools, uiTools, torTools
 
 from cagraph.ca_graph import CaGraph
 from cagraph.axis.xaxis import CaGraphXAxis
@@ -62,10 +62,11 @@ class GraphStats(TorCtl.PostEventListener):
 
     series = CaGraphSeriesArea(graph, 0, 1)
 
-    primaryColor = placeholder.style.fg[gtk.STATE_NORMAL]
-    secondaryColor = placeholder.style.fg[gtk.STATE_INSENSITIVE]
+    theme = gtkTools.Theme()
+    primaryColor = theme.colors['normal']
+    secondaryColor = theme.colors['insensitive']
     colors = { 'primary' : (primaryColor.red_float, primaryColor.green_float, primaryColor.blue_float, 0.5),
-               'secondary' : (secondaryColor.red_float, secondaryColor.green_float, secondaryColor.blue_float, 0.7) }
+               'secondary' : (secondaryColor.red_float, secondaryColor.green_float, secondaryColor.blue_float, 0.5) }
 
     series.style.point_radius = 0.0
     series.style.line_color = colors[name]
diff --git a/src/gui/logPanel.py b/src/gui/logPanel.py
index 20331ad..192eb8d 100644
--- a/src/gui/logPanel.py
+++ b/src/gui/logPanel.py
@@ -13,14 +13,14 @@ import gobject
 import gtk
 
 from TorCtl import TorCtl
-from util import log, uiTools, torTools
+from util import log, gtkTools, uiTools, torTools
 
 from cli.logPanel import (expandEvents, setEventListening, getLogFileEntries,
                           LogEntry, TorEventObserver,
                           DEFAULT_CONFIG)
 
-RUNLEVEL_EVENT_COLOR = {log.DEBUG: "#C73043", log.INFO: "#762A2A", log.NOTICE: "#222222",
-                        log.WARN: "#AB7814", log.ERR: "#EC131F"}
+RUNLEVEL_EVENT_COLOR = {log.DEBUG: 'insensitive', log.INFO: 'normal', log.NOTICE: 'normal',
+                        log.WARN: 'active', log.ERR: 'active'}
 STARTUP_EVENTS = 'N3'
 REFRESH_RATE = 3
 
@@ -52,7 +52,8 @@ class LogPanel:
 
     armEventBacklog = deque()
     for level, msg, eventTime in log._getEntries(setRunlevels):
-      armEventEntry = LogEntry(eventTime, "ARM_" + level, msg, RUNLEVEL_EVENT_COLOR[level])
+      theme = gtkTools.Theme()
+      armEventEntry = LogEntry(eventTime, "ARM_" + level, msg, theme.colors[RUNLEVEL_EVENT_COLOR[level]])
       armEventBacklog.appendleft(armEventEntry)
 
     while armEventBacklog or torEventBacklog:
@@ -88,6 +89,7 @@ class LogPanel:
     try:
       for entry in self.msgLog:
         timeLabel = time.strftime('%H:%M:%S', time.localtime(entry.timestamp))
+
         row = (long(entry.timestamp), timeLabel, entry.type, entry.msg, entry.color)
         liststore.append(row)
     finally:
@@ -107,11 +109,13 @@ class LogPanel:
     gobject.idle_add(self.fill_log)
 
   def _register_arm_event(self, level, msg, eventTime):
-    eventColor = RUNLEVEL_EVENT_COLOR[level]
+    theme = gtkTools.Theme()
+    eventColor = theme.colors[RUNLEVEL_EVENT_COLOR[level]]
     self.register_event(LogEntry(eventTime, "ARM_%s" % level, msg, eventColor))
 
   def _register_torctl_event(self, level, msg):
-    eventColor = RUNLEVEL_EVENT_COLOR[level]
+    theme = gtkTools.Theme()
+    eventColor = theme.colors[RUNLEVEL_EVENT_COLOR[level]]
     self.register_event(LogEntry(time.time(), "TORCTL_%s" % level, msg, eventColor))
 
   def _compare_rows(self, treemodel, iter1, iter2, data=None):
diff --git a/src/util/gtkTools.py b/src/util/gtkTools.py
new file mode 100644
index 0000000..083fb5d
--- /dev/null
+++ b/src/util/gtkTools.py
@@ -0,0 +1,21 @@
+"""
+Helper module for getting Gtk+ theme colors.
+"""
+
+import gtk
+
+COLOR_MAP = {
+  'normal' : ('fg', gtk.STATE_NORMAL),
+  'active' : ('fg', gtk.STATE_ACTIVE),
+  'insensitive' : ('fg', gtk.STATE_INSENSITIVE),
+}
+
+class Theme:
+  def __init__(self):
+    self.colors = {}
+
+    widget = gtk.Button()
+
+    for (key, (prop, state)) in COLOR_MAP.items():
+      self.colors[key] = getattr(widget.style, prop)[state]
+



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits