[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r23759: {arm} Sort dialog for configuration options is now functional. How (in arm/trunk/src: interface util)
Author: atagar
Date: 2010-11-05 16:47:47 +0000 (Fri, 05 Nov 2010)
New Revision: 23759
Modified:
arm/trunk/src/interface/controller.py
arm/trunk/src/util/torConfig.py
Log:
Sort dialog for configuration options is now functional. However, the code's ugly as sin so next gonna break it out into a popup function...
Modified: arm/trunk/src/interface/controller.py
===================================================================
--- arm/trunk/src/interface/controller.py 2010-11-05 16:18:32 UTC (rev 23758)
+++ arm/trunk/src/interface/controller.py 2010-11-05 16:47:47 UTC (rev 23759)
@@ -745,6 +745,7 @@
popup.addfstr(2, 2, "<b>page up</b>: scroll up a page")
popup.addfstr(2, 41, "<b>page down</b>: scroll down a page")
+ popup.addfstr(3, 2, "<b>s</b>: sort ordering")
# TODO: reintroduce options for the configFilePanel
#strippingLabel = "on" if panels["torrc"].stripComments else "off"
#popup.addfstr(3, 2, "<b>s</b>: comment stripping (<b>%s</b>)" % strippingLabel)
@@ -1503,6 +1504,11 @@
prevOrdering += "<%s>%s</%s>, " % (colorStr, sortStr, colorStr)
prevOrdering = prevOrdering[:-2] + "</b>"
+ # constructs a mapping of str to enum for configStatePanel.FIELD_ATTR
+ strToEnumAttr = {}
+ for i in range(7):
+ strToEnumAttr[configStatePanel.FIELD_ATTR[i][0]] = i
+
# Makes listing of all options
options = []
for sortType in range(7): options.append(configStatePanel.FIELD_ATTR[sortType][0])
@@ -1519,7 +1525,7 @@
if selections:
for sortType in selections:
sortStr, colorStr = configStatePanel.FIELD_ATTR[sortType]
- prevOrdering += "<%s>%s</%s>, " % (colorStr, sortStr, colorStr)
+ newOrdering += "<%s>%s</%s>, " % (colorStr, sortStr, colorStr)
newOrdering = newOrdering[:-2] + "</b>"
else: newOrdering += "</b>"
popup.addfstr(2, 2, newOrdering)
@@ -1543,6 +1549,7 @@
selection = options[cursorLoc]
if selection == "Cancel": break
else:
+ selections.append(strToEnumAttr[selection])
options.remove(selection)
cursorLoc = min(cursorLoc, len(options) - 1)
elif key == 27: break # esc - cancel
Modified: arm/trunk/src/util/torConfig.py
===================================================================
--- arm/trunk/src/util/torConfig.py 2010-11-05 16:18:32 UTC (rev 23758)
+++ arm/trunk/src/util/torConfig.py 2010-11-05 16:47:47 UTC (rev 23759)
@@ -308,6 +308,9 @@
contents - torrc contents
"""
+ # TODO: needs to recognize tor's new multiline values
+ # https://trac.torproject.org/projects/tor/ticket/1929
+
conn = torTools.getConn()
contents = _stripComments(contents)
issuesFound, seenOptions = {}, []