21
22
# Boston, MA 02111-1307, USA.
26
APP="awn-calendar-applet"
28
APP = "awn-calendar-applet"
32
30
#locale.setlocale(locale.LC_ALL, '')
33
31
gettext.bindtextdomain(APP, DIR)
34
32
gettext.textdomain(APP)
35
33
_ = gettext.gettext
37
36
class CalendarPrefs(gtk.Window):
39
# There *must* be a more "Pythonic" way to do this:
40
int_opt = { "None" : 0, "Evolution" : 1, "Google Calendar" : 2, "Outlook Web Access" : 3 }
41
int_opt_inv = { 0 : "None", 1 : "Evolution", 2 : "Google Calendar", 3 : "Outlook Web Access" }
43
clock_appearance = { _("Classic LCD") : ("667F66FF", "000000FF", "000000FF", False),
44
_("Indy Glow LCD") : ("22B7B7FF", "000000FF", "000000FF", False),
45
_("Backlit Amber LCD") : ("AA4A3AFF", "000000FF", "000000FF", False),
46
_("Backlit Green LCD") : ("337A33FF", "000000FF", "000000FF", False),
47
_("Green LED") : ("000000FF", "00FF66FF", "000000FF", False),
48
_("Red LED") : ("000000FF", "FF2211FF", "000000FF", False),
49
_("Blue LED") : ("000000FF", "00AAFFFF", "000000FF", False),
50
_("Plain White") : ("0000008F", "FFFFFFFF", "000000FF", True),
51
_("Plain Black") : ("0000003F", "000000FF", "000000FF", True) }
53
calendar_appearance = { _("Red") : "calendar-red.png",
54
_("Green") : "calendar-green.png",
55
_("Blue") : "calendar-blue.png",
56
_("Gray") : "calendar-gray.png",
57
_("Black") : "calendar-black.png" }
59
def crypt(self,sequence, key):
60
sign = (key > 0) * 2 - 1
61
random.seed (abs (key * sign))
63
for i in xrange (len (sequence)):
64
r = random.randint(0, 255)
65
s += chr ((ord (sequence [i]) + r * sign) % 128)
68
def __init__(self,applet):
69
super(CalendarPrefs, self).__init__()
71
self.set_title(_("Preferences"))
72
vbox = gtk.VBox(True, 0)
75
cal_appearance_index = self.applet.gconf_client.get_int(self.applet.gconf_path + "/cal_appearance_index")
76
if cal_appearance_index == None:
77
self.applet.gconf_client.set_int(self.applet.gconf_path + "/cal_appearance_index", 0)
78
cal_appearance_index = self.applet.gconf_client.get_int(self.applet.gconf_path + "/cal_appearance_index")
80
clock_appearance_index = self.applet.gconf_client.get_int(self.applet.gconf_path + "/clock_appearance_index")
81
if clock_appearance_index == None:
82
self.applet.gconf_client.set_int(self.applet.gconf_path + "/clock_appearance_index", 0)
83
clock_appearance_index = self.applet.gconf_client.get_int(self.applet.gconf_path + "/clock_appearance_index")
85
self.twelve_hour_checkbox = gtk.CheckButton(_("Twelve Hour Clock"))
86
if applet.twelve_hour_clock == True:
87
self.twelve_hour_checkbox.set_active(True)
89
self.twelve_hour_checkbox.set_active(False)
90
hbox0 = gtk.HBox(False,0)
91
hbox0.pack_start(self.twelve_hour_checkbox,True,False,0)
92
vbox.pack_start(hbox0,False,False,0)
94
# self.blink_checkbox = gtk.CheckButton(_("Blinking Colon"))
95
# if applet.blinky_colon == True:
96
# self.blink_checkbox.set_active(True)
98
# self.blink_checkbox.set_active(False)
99
# hbox1 = gtk.HBox(False,0)
100
# hbox1.pack_start(self.blink_checkbox,True,False,0)
101
# vbox.pack_start(hbox1,False,False,0)
103
hbox1a = gtk.HBox(True, 0)
104
self.clock_appear_combo = gtk.combo_box_new_text()
105
for item in self.clock_appearance.keys():
106
self.clock_appear_combo.append_text(item)
107
self.clock_appear_combo.set_active(clock_appearance_index)
108
clock_appear_label = gtk.Label(_("Clock Appearance"))
109
hbox1a.pack_start(clock_appear_label,True,False,0)
110
hbox1a.pack_start(self.clock_appear_combo,True,True,0)
111
vbox.pack_start(hbox1a,True,False,0)
113
hbox1b = gtk.HBox(True, 0)
114
self.cal_appear_combo = gtk.combo_box_new_text()
115
for item in self.calendar_appearance.keys():
116
self.cal_appear_combo.append_text(item)
117
self.cal_appear_combo.set_active(cal_appearance_index)
118
cal_appear_label = gtk.Label(_("Calendar Appearance"))
119
hbox1b.pack_start(cal_appear_label,True,False,0)
120
hbox1b.pack_start(self.cal_appear_combo,True,True,0)
121
vbox.pack_start(hbox1b,True,False,0)
123
hbox2 = gtk.HBox(True, 0)
124
self.integ_combo = gtk.combo_box_new_text()
125
self.integ_combo.append_text(_("None"))
126
self.integ_combo.append_text(_("Evolution"))
127
self.integ_combo.append_text(_("Google Calendar"))
128
self.integ_combo.append_text(_("Outlook Web Access"))
129
self.integ_combo.set_active(self.int_opt[applet.integ_text])
130
self.integ_combo.connect("changed", self.combo_changed, "bla")
131
int_label = gtk.Label(_("Calendar Integration"))
132
hbox2.pack_start(int_label,True,False,0)
133
hbox2.pack_start(self.integ_combo,True,True,0)
134
vbox.pack_start(hbox2,True,False,0)
136
#hbox3 = gtk.HBox(True, 0)
137
#self.user_label = gtk.Label(_("Calendar Username"))
138
#hbox3.pack_start(self.user_label)
139
#self.user = gtk.Entry(40)
140
#self.user.set_text(self.applet.username)
141
#hbox3.pack_start(self.user)
142
#vbox.pack_start(hbox3,False,False,2)
144
#hbox4 = gtk.HBox(True, 0)
145
#self.password_label = gtk.Label(_("Calendar Password"))
146
#hbox4.pack_start(self.password_label)
147
#self.password = gtk.Entry(20)
148
#self.password.set_visibility(False)
149
#self.password.set_text(self.applet.password)
150
#hbox4.pack_start(self.password)
151
#vbox.pack_start(hbox4,False,False,2)
153
hbox5 = gtk.HBox(True, 0)
154
self.url_label = gtk.Label(_("Calendar URL"))
155
hbox5.pack_start(self.url_label)
156
self.url = gtk.Entry(50)
157
self.url.set_text(self.applet.url)
158
hbox5.pack_start(self.url)
159
vbox.pack_start(hbox5,False,False,2)
161
hbox6 = gtk.HBox(True, 0)
162
ok = gtk.Button(stock=gtk.STOCK_OK)
163
ok.connect("clicked", self.ok_button, "ok")
165
cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
166
cancel.connect("clicked", self.cancel_button, "cancel")
168
vbox.pack_end(hbox6,True,False,2)
170
self.set_credential_sensitivity()
173
def set_credential_sensitivity(self):
174
option = self.int_opt_inv[self.integ_combo.get_active()]
175
if option == "Google Calendar" or option == "Outlook Web Access":
176
#self.user_label.set_sensitive(True)
177
#self.user.set_sensitive(True)
178
#self.password_label.set_sensitive(True)
179
#self.password.set_sensitive(True)
180
if option == "Google Calendar":
181
self.url_label.set_sensitive(False)
182
self.url.set_sensitive(False)
184
self.url_label.set_sensitive(True)
185
self.url.set_sensitive(True)
187
#self.user_label.set_sensitive(False)
188
#self.user.set_sensitive(False)
189
#self.password_label.set_sensitive(False)
190
#self.password.set_sensitive(False)
191
self.url_label.set_sensitive(False)
192
self.url.set_sensitive(False)
194
def combo_changed(self, widget, bla):
195
self.set_credential_sensitivity()
197
def ok_button(self, widget, event):
198
self.applet.gconf_client.set_string(self.applet.gconf_path + "/integration", self.int_opt_inv[self.integ_combo.get_active()])
199
#self.applet.gconf_client.set_string(self.applet.gconf_path + "/username", self.user.get_text())
200
#self.applet.gconf_client.set_string(self.applet.gconf_path + "/password", self.crypt(self.password.get_text(),17760704))
201
self.applet.gconf_client.set_string(self.applet.gconf_path + "/url", self.url.get_text())
202
self.applet.gconf_client.set_bool(self.applet.gconf_path + "/twelve_hour_clock", self.twelve_hour_checkbox.get_active())
203
# self.applet.gconf_client.set_bool(self.applet.gconf_path + "/blinking_colon", self.blink_checkbox.get_active())
204
background, text, border, plain = self.clock_appearance[self.clock_appear_combo.get_active_text()]
205
self.applet.gconf_client.set_string(self.applet.gconf_path + "/clock_background", background)
206
self.applet.gconf_client.set_string(self.applet.gconf_path + "/clock_foreground", text)
207
self.applet.gconf_client.set_string(self.applet.gconf_path + "/clock_border", border)
208
self.applet.gconf_client.set_bool(self.applet.gconf_path + "/clock_plain", plain)
209
self.applet.gconf_client.set_string(self.applet.gconf_path + "/graphic", self.calendar_appearance[self.cal_appear_combo.get_active_text()])
210
self.applet.gconf_client.set_int(self.applet.gconf_path + "/clock_appearance_index", self.clock_appear_combo.get_active())
211
self.applet.gconf_client.set_int(self.applet.gconf_path + "/cal_appearance_index", self.cal_appear_combo.get_active())
214
def cancel_button(self, widget, event):
38
# There *must* be a more "Pythonic" way to do this:
43
"Outlook Web Access": 3}
48
3: "Outlook Web Access"}
51
_("Classic LCD"): ("667F66FF", "000000FF", "000000FF", False),
52
_("Indy Glow LCD"): ("22B7B7FF", "000000FF", "000000FF", False),
53
_("Backlit Amber LCD"): ("AA4A3AFF", "000000FF", "000000FF", False),
54
_("Backlit Green LCD"): ("337A33FF", "000000FF", "000000FF", False),
55
_("Green LED"): ("000000FF", "00FF66FF", "000000FF", False),
56
_("Red LED"): ("000000FF", "FF2211FF", "000000FF", False),
57
_("Blue LED"): ("000000FF", "00AAFFFF", "000000FF", False),
58
_("Plain White"): ("0000008F", "FFFFFFFF", "000000FF", True),
59
_("Plain Black"): ("0000003F", "000000FF", "000000FF", True)}
61
calendar_appearance = {
62
_("Red"): "calendar-red.png",
63
_("Green"): "calendar-green.png",
64
_("Blue"): "calendar-blue.png",
65
_("Gray"): "calendar-gray.png",
66
_("Black"): "calendar-black.png"}
68
def crypt(self, sequence, key):
69
sign = (key > 0) * 2 - 1
70
random.seed(abs(key * sign))
72
for i in xrange(len(sequence)):
73
r = random.randint(0, 255)
74
s += chr((ord(sequence[i]) + r * sign) % 128)
77
def __init__(self, applet):
78
super(CalendarPrefs, self).__init__()
80
self.set_title(_("Preferences"))
81
vbox = gtk.VBox(True, 0)
84
cal_appearance_index = \
85
self.applet.get_int_config('cal_appearance_index')
86
clock_appearance_index = \
87
self.applet.get_int_config('clock_appearance_index')
89
self.twelve_hour_checkbox = gtk.CheckButton(_("Twelve Hour Clock"))
90
if applet.twelve_hour_clock == True:
91
self.twelve_hour_checkbox.set_active(True)
93
self.twelve_hour_checkbox.set_active(False)
94
hbox0 = gtk.HBox(False, 0)
95
hbox0.pack_start(self.twelve_hour_checkbox, True, False, 0)
96
vbox.pack_start(hbox0, False, False, 0)
98
# self.blink_checkbox = gtk.CheckButton(_("Blinking Colon"))
99
# if applet.blinky_colon == True:
100
# self.blink_checkbox.set_active(True)
102
# self.blink_checkbox.set_active(False)
103
# hbox1 = gtk.HBox(False,0)
104
# hbox1.pack_start(self.blink_checkbox,True,False,0)
105
# vbox.pack_start(hbox1,False,False,0)
107
hbox1a = gtk.HBox(True, 0)
108
self.clock_appear_combo = gtk.combo_box_new_text()
109
for item in self.clock_appearance.keys():
110
self.clock_appear_combo.append_text(item)
111
self.clock_appear_combo.set_active(clock_appearance_index)
112
clock_appear_label = gtk.Label(_("Clock Appearance"))
113
hbox1a.pack_start(clock_appear_label, True, False, 0)
114
hbox1a.pack_start(self.clock_appear_combo, True, True, 0)
115
vbox.pack_start(hbox1a, True, False, 0)
117
hbox1b = gtk.HBox(True, 0)
118
self.cal_appear_combo = gtk.combo_box_new_text()
119
for item in self.calendar_appearance.keys():
120
self.cal_appear_combo.append_text(item)
121
self.cal_appear_combo.set_active(cal_appearance_index)
122
cal_appear_label = gtk.Label(_("Calendar Appearance"))
123
hbox1b.pack_start(cal_appear_label, True, False, 0)
124
hbox1b.pack_start(self.cal_appear_combo, True, True, 0)
125
vbox.pack_start(hbox1b, True, False, 0)
127
hbox2 = gtk.HBox(True, 0)
128
self.integ_combo = gtk.combo_box_new_text()
129
self.integ_combo.append_text(_("None"))
130
self.integ_combo.append_text(_("Evolution"))
131
self.integ_combo.append_text(_("Google Calendar"))
132
self.integ_combo.append_text(_("Outlook Web Access"))
133
self.integ_combo.set_active(self.int_opt[applet.integ_text])
134
self.integ_combo.connect("changed", self.combo_changed, "bla")
135
int_label = gtk.Label(_("Calendar Integration"))
136
hbox2.pack_start(int_label, True, False, 0)
137
hbox2.pack_start(self.integ_combo, True, True, 0)
138
vbox.pack_start(hbox2, True, False, 0)
140
#hbox3 = gtk.HBox(True, 0)
141
#self.user_label = gtk.Label(_("Calendar Username"))
142
#hbox3.pack_start(self.user_label)
143
#self.user = gtk.Entry(40)
144
#self.user.set_text(self.applet.username)
145
#hbox3.pack_start(self.user)
146
#vbox.pack_start(hbox3,False,False,2)
148
#hbox4 = gtk.HBox(True, 0)
149
#self.password_label = gtk.Label(_("Calendar Password"))
150
#hbox4.pack_start(self.password_label)
151
#self.password = gtk.Entry(20)
152
#self.password.set_visibility(False)
153
#self.password.set_text(self.applet.password)
154
#hbox4.pack_start(self.password)
155
#vbox.pack_start(hbox4,False,False,2)
157
hbox5 = gtk.HBox(True, 0)
158
self.url_label = gtk.Label(_("Calendar URL"))
159
hbox5.pack_start(self.url_label)
160
self.url = gtk.Entry(50)
161
self.url.set_text(self.applet.url)
162
hbox5.pack_start(self.url)
163
vbox.pack_start(hbox5, False, False, 2)
165
hbox6 = gtk.HBox(True, 0)
166
ok = gtk.Button(stock=gtk.STOCK_OK)
167
ok.connect("clicked", self.ok_button, "ok")
169
cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
170
cancel.connect("clicked", self.cancel_button, "cancel")
172
vbox.pack_end(hbox6, True, False, 2)
174
self.set_credential_sensitivity()
176
def set_credential_sensitivity(self):
177
option = self.int_opt_inv[self.integ_combo.get_active()]
178
if option == "Google Calendar" or option == "Outlook Web Access":
179
#self.user_label.set_sensitive(True)
180
#self.user.set_sensitive(True)
181
#self.password_label.set_sensitive(True)
182
#self.password.set_sensitive(True)
183
if option == "Google Calendar":
184
self.url_label.set_sensitive(False)
185
self.url.set_sensitive(False)
187
self.url_label.set_sensitive(True)
188
self.url.set_sensitive(True)
190
#self.user_label.set_sensitive(False)
191
#self.user.set_sensitive(False)
192
#self.password_label.set_sensitive(False)
193
#self.password.set_sensitive(False)
194
self.url_label.set_sensitive(False)
195
self.url.set_sensitive(False)
197
def combo_changed(self, widget, bla):
198
self.set_credential_sensitivity()
200
def ok_button(self, widget, event):
201
integration = self.int_opt_inv[self.integ_combo.get_active()]
202
self.applet.set_string_config('integration', integration)
203
#self.applet.set_string_config('username', self.user.get_text())
204
#self.applet.set_string_config('password',
205
# self.crypt(self.password.get_text(),
207
self.applet.set_string_config('url', self.url.get_text())
208
self.applet.set_boolean_config('twelve_hour_clock',
209
self.twelve_hour_checkbox.get_active())
210
#self.applet.set_boolean_config('blinking_colon',
211
# self.blink_checkbox.get_active())
212
background, text, border, plain = \
213
self.clock_appearance[self.clock_appear_combo.get_active_text()]
214
self.applet.set_string_config('clock_background', background)
215
self.applet.set_string_config('clock_foreground', text)
216
self.applet.set_string_config('clock_border', border)
217
self.applet.set_boolean_config('clock_plain', plain)
219
self.calendar_appearance[self.cal_appear_combo.get_active_text()]
220
self.applet.set_string_config('graphic', graphic)
221
self.applet.set_int_config('clock_appearance_index',
222
self.clock_appear_combo.get_active())
223
self.applet.set_int_config('cal_appearance_index',
224
self.cal_appear_combo.get_active())
227
def cancel_button(self, widget, event):