20
20
GUI-specific interface functions for X11.
22
>>> ini_find_section(TEST_LINES, 'User Prefs')
25
__revision__ = '$Rev: 1315 $'
26
__date__ = '$Date: 2007-05-26 10:29:35 +0100 (Sat, 26 May 2007) $'
23
__revision__ = '$Rev: 1316 $'
24
__date__ = '$Date: 2007-05-27 13:44:46 +0100 (Sun, 27 May 2007) $'
27
25
__author__ = '$Author: johann $'
32
30
from shotfactory03.gui import linux as base
31
from shotfactory03.inifile import IniFile
35
34
class Gui(base.Gui):
45
44
inifile = home + '/.opera/opera6.ini'
46
45
if os.path.exists(inifile):
47
46
print 'removing crash dialog from', inifile
48
lines = file(inifile).readlines()
49
ini_set(lines, 'User Prefs', 'Run', 0)
50
ini_set(lines, 'User Prefs', 'Show New Opera Dialog', 1)
51
open(inifile, 'w').write(''.join(lines))
53
def ini_set(lines, section, key, value):
54
if lines[0][-2] == chr(13):
58
start, stop = self.ini_find_section(lines, section)
61
lines.append('[' + section + ']')
62
lines.append(key + '=' + str(value) + crlf)
64
index = self.ini_find_key_line(lines, start, stop, key)
66
lines[index] = key + '=' + str(value) + crlf
68
lines.insert(stop, key + '=' + str(value) + crlf)
71
def ini_find_section(lines, section):
73
for index, line in enumerate(lines):
74
if line.startswith('[' + section + ']'):
76
if start and line.strip() == '':
79
return start, len(lines)
83
def ini_find_key_line(lines, start, stop, key):
84
for index in range(start, stop):
85
if lines[index].startswith(key + '='):
89
if __name__ == '__main__':
47
ini = IniFile(inifile)
48
ini.set(lines, 'User Prefs', 'Run', 0)
49
ini.set(lines, 'User Prefs', 'Show New Opera Dialog', 1)