/usr/share/cain/gui/Preferences.py is in cain 1.9-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | """Implements the preferences."""
from PreferencesDialog import PreferencesDialog
from copy import copy
import wx
import sys
class Preferences:
"""The preferences."""
def __init__(self):
"""."""
# Don't change these names. They are used as keys.
self.default = [['Compilation',
['Compiler', 'g++', 80],
['Flags', '-O3 -funroll-loops -finline-limit=6000', 400]],
['SBML',
['Version', ['3', '2', '1'], None]],
['gnuplot',
['X Scale', '1', 80],
['Y Scale', '1', 80],
['Style', ['lines', 'linespoints'], None]]]
# Reset to the default.
self.reset()
def reset(self):
# Clear the data.
self.data = {}
for category in self.default:
# The first element is the category name.
d = {}
self.data[category[0]] = d
for (field, value, width) in category[1:]:
# If the value field is a list.
if type(value) == type([]):
# The default is the first element of the list.
d[field] = value[0]
else:
# Otherwise it is simply the value.
d[field] = value
def openDialog(self):
dialog = PreferencesDialog(self)
if dialog.ShowModal() == wx.ID_OK:
# CONTINUE: Validate.
for subject in self.default:
category = subject[0]
for (field, value, width) in subject[1:]:
if type(value) == type([]):
self.data[category][field] = \
value[dialog.controls[category][field].\
GetSelection()]
else:
self.data[category][field] = \
dialog.controls[category][field].GetValue()
dialog.Destroy()
def main():
app = wx.PySimpleApp()
preferences = Preferences()
preferences.openDialog()
app.MainLoop()
for category in preferences.data:
print category
for field in preferences.data[category]:
print ' ', preferences.data[category][field]
if __name__ == '__main__':
main()
|