-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigwindow.py
95 lines (70 loc) · 2.9 KB
/
configwindow.py
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
import gtk
import pygtk
import gobject
import gettext
from config import *
_ = gettext.gettext
class ConfigWindow(gtk.Window):
def __init__(self,manager):
super(ConfigWindow,self).__init__()
self.set_title(_("Gtracker configuration"))
self.set_modal(True)
self.manager = manager
self.config = Config()
self.resp = None
table = gtk.Table(2,2,True)
userStr = gtk.Label(_("Username"))
self.userTxt = gtk.Entry()
self.userTxt.set_text(str(self.config.username))
passStr = gtk.Label(_("Password"))
self.passTxt = gtk.Entry()
self.passTxt.set_visibility(False)
self.passTxt.set_text(str(self.config.password))
intervalStr = gtk.Label(_("Interval"))
self.intervalTxt = gtk.Entry()
self.intervalTxt.set_text(str(self.config.interval))
self.multiline = gtk.CheckButton(_("Show stories using two lines"))
self.multiline.set_active(self.config.multiline)
self.separator = gtk.CheckButton(_("Show separator between stories"))
self.separator.set_active(self.config.separator)
showPasswd = gtk.CheckButton(_("Show password"));
showPasswd.connect("toggled", self.show_passwd,showPasswd)
self.ok = gtk.Button(_("Ok"))
self.ok.connect("clicked",self.save)
self.cancel = gtk.Button(_("Cancel"))
self.cancel.connect("clicked",self.dontsave)
table.attach(userStr,0,1,0,1)
table.attach(self.userTxt,1,2,0,1)
table.attach(passStr,0,1,1,2)
table.attach(self.passTxt,1,2,1,2)
table.attach(intervalStr,0,1,2,3)
table.attach(self.intervalTxt,1,2,2,3)
table.attach(self.multiline,0,2,3,4)
table.attach(self.separator,0,2,4,5)
table.attach(showPasswd,0,2,5,6)
table.attach(self.ok,0,1,6,7)
table.attach(self.cancel,1,2,6,7)
self.add(table)
self.show_all()
def show_passwd(self,widget,data=None):
self.passTxt.set_visibility(data.get_active())
def save(self,widget):
username = self.userTxt.get_text()
password = self.passTxt.get_text()
interval = int(self.intervalTxt.get_text())
multiline = self.multiline.get_active()
separator = self.separator.get_active()
if not self.config.save(username,password,interval,multiline,separator):
self.manager.show_error(_("Could not save configuration info!"))
return False
self.manager.interval = interval
self.manager.config.multiline = multiline
self.manager.config.separator = separator
if len(username)>0 and len(password)>0 and (username!=self.manager.username or password!=self.manager.password):
self.manager.username = username
self.manager.password = password
gobject.idle_add(self.manager.check_thread)
self.destroy()
return True
def dontsave(self,widget):
self.destroy()