summaryrefslogtreecommitdiff
path: root/slime-0.11/ui_config.py
blob: f184797b92dc6d4971e806fdb980aaf2d1ba3db8 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import os
from Config import *
from ConfigEditor import *

config_file = "~/.slime/config"

config_vars = {

"count-width": (CONFIG_INTEGER, 3, "Width for message count in folder list"),

"from-address": (CONFIG_STRING, "", "User's address (automatic, if empty)"),
"reply-to": (CONFIG_STRING, "", "Default Reply-To"),
"fcc-folder": (CONFIG_STRING, "", 
	"Folder to store copy of sent mail (no copy, if empty)"),
"signature-file": (CONFIG_STRING, "~/.signature", "Signature file"),

"make-pgp-signatures": (CONFIG_BOOLEAN, 0, "Make PGP signatures?"),
"check-pgp-signatures": (CONFIG_BOOLEAN, 0, "Check PGP signatures?"),
"pgp-path": (CONFIG_STRING, "/usr/bin/pgp", "PGP command (full path)"),
"pgp-username": (CONFIG_STRING, "", "PGP username"),
"pgp-max-password-age": (CONFIG_INTEGER, 60,
		"Time (in minutes) to remember PGP passphrase"),

"smtp-server": (CONFIG_STRING, "localhost", "SMTP server"),
"max-references-length": (CONFIG_INTEGER, 500,
	"Max length for References header"),
"external-editor": (CONFIG_STRING, "", "External editor"),

"normal-font": (CONFIG_STRING, "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1",
		"Normal font"),
"unread-font": (CONFIG_STRING, "-misc-fixed-bold-r-semicondensed--13-120-75-75-c-60-iso8859-1",
		"Unread font"),
"command-font": (CONFIG_STRING, "-misc-fixed-medium-r-normal--10-*-*-*-*-*-iso8859-1",
		"Command button font"),
"max-subject-indent": (CONFIG_INTEGER, 4,
		"Max subject indentation"),
"max-folder-indent": (CONFIG_INTEGER, 2,
		"Max folder indentation"),
"important-headers": (CONFIG_STRING, "From To Cc Date Subject",
		"Headers shown normally"),

"inbox-scan-frequency": (CONFIG_INTEGER, 1,
	"Frequency of new message scan (minutes)"),

}

config_layout = [
	["Mail sending",
		"from-address",
		"reply-to",
		"smtp-server",
		"max-references-length",
		"fcc-folder",
		"external-editor",
		"signature-file",
	],
	["PGP",
		"make-pgp-signatures",
		"check-pgp-signatures",
		"pgp-path",
		"pgp-username",
		"pgp-max-password-age",
	],
	["Appearance",
		"normal-font",
		"unread-font",
		"max-subject-indent",
		"max-folder-indent",
		"important-headers",
		"count-width",
	],
	["Misc",
		"inbox-scan-frequency",
	],
]

config = Config(config_vars)

def edit_config():
	global config, config_layout
	ConfigEditor(config, config_layout)

def load_config():
	p = os.path.expanduser(config_file)
	if os.path.isfile(p):
		f = open(p, "r")
		config.read(f)
		f.close()

def save_config():
	p = os.path.expanduser(config_file)
	if os.path.isfile(p):
		pnew = p + ".new"
		fp = open(p, "r")
		fpnew = open(pnew, "w")
		config.rewrite(fp, fpnew)
		fp.close()
		fpnew.close()
		os.rename(p + ".new", p)
	else:
		f = open(p, "w")
		config.write(f)
		f.close()