2
# -*- coding: iso-8859-15 -*-
4
# Copyright (c) 2007 Mike (mosburger) Desjardins <desjardinsmike@gmail.com>
5
# Please do not email the above person for support. The
6
# email address is only there for license/copyright purposes.
8
# This is the preferences dialog for a calendar applet for Avant Window
11
# This library is free software; you can redistribute it and/or
12
# modify it under the terms of the GNU Lesser General Public
13
# License as published by the Free Software Foundation; either
14
# version 2 of the License, or (at your option) any later version.
16
# This library is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
# Lesser General Public License for more details.
21
# You should have received a copy of the GNU Lesser General Public
22
# License along with this library; if not, write to the
23
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24
# Boston, MA 02111-1307, USA.
28
from awn.extras import _
31
class CalendarPrefs(gtk.Window):
33
# There *must* be a more "Pythonic" way to do this:
38
"Outlook Web Access": 3}
43
3: "Outlook Web Access"}
46
_("Classic LCD"): ("667F66FF", "000000FF", "000000FF", False),
47
_("Indy Glow LCD"): ("22B7B7FF", "000000FF", "000000FF", False),
48
_("Backlit Amber LCD"): ("AA4A3AFF", "000000FF", "000000FF", False),
49
_("Backlit Green LCD"): ("337A33FF", "000000FF", "000000FF", False),
50
_("Green LED"): ("000000FF", "00FF66FF", "000000FF", False),
51
_("Red LED"): ("000000FF", "FF2211FF", "000000FF", False),
52
_("Blue LED"): ("000000FF", "00AAFFFF", "000000FF", False),
53
_("Plain White"): ("0000008F", "FFFFFFFF", "000000FF", True),
54
_("Plain Black"): ("0000003F", "000000FF", "000000FF", True)}
56
calendar_appearance = {
57
_("Red"): "calendar-red.png",
58
_("Green"): "calendar-green.png",
59
_("Blue"): "calendar-blue.png",
60
_("Gray"): "calendar-gray.png",
61
_("Black"): "calendar-black.png"}
63
def crypt(self, sequence, key):
64
sign = (key > 0) * 2 - 1
65
random.seed(abs(key * sign))
67
for i in xrange(len(sequence)):
68
r = random.randint(0, 255)
69
s += chr((ord(sequence[i]) + r * sign) % 128)
72
def __init__(self, applet):
73
super(CalendarPrefs, self).__init__()
75
self.set_title(_("Preferences"))
76
vbox = gtk.VBox(True, 0)
79
cal_appearance_index = \
80
self.applet.get_int_config('cal_appearance_index')
81
clock_appearance_index = \
82
self.applet.get_int_config('clock_appearance_index')
84
self.twelve_hour_checkbox = gtk.CheckButton(_("Twelve Hour Clock"))
85
self.twelve_hour_checkbox.set_active(applet.twelve_hour_clock)
86
hbox0 = gtk.HBox(False, 0)
87
hbox0.pack_start(self.twelve_hour_checkbox, True, False, 0)
88
vbox.pack_start(hbox0, False, False, 0)
90
# self.blink_checkbox = gtk.CheckButton(_("Blinking Colon"))
91
# if applet.blinky_colon == True:
92
# self.blink_checkbox.set_active(True)
94
# self.blink_checkbox.set_active(False)
95
# hbox1 = gtk.HBox(False,0)
96
# hbox1.pack_start(self.blink_checkbox,True,False,0)
97
# vbox.pack_start(hbox1,False,False,0)
99
hbox1a = gtk.HBox(True, 0)
100
self.clock_appear_combo = gtk.combo_box_new_text()
101
for item in self.clock_appearance.keys():
102
self.clock_appear_combo.append_text(item)
103
self.clock_appear_combo.set_active(clock_appearance_index)
104
clock_appear_label = gtk.Label(_("Clock Appearance"))
105
hbox1a.pack_start(clock_appear_label, True, False, 0)
106
hbox1a.pack_start(self.clock_appear_combo, True, True, 0)
107
vbox.pack_start(hbox1a, True, False, 0)
109
hbox1b = gtk.HBox(True, 0)
110
self.cal_appear_combo = gtk.combo_box_new_text()
111
for item in self.calendar_appearance.keys():
112
self.cal_appear_combo.append_text(item)
113
self.cal_appear_combo.set_active(cal_appearance_index)
114
cal_appear_label = gtk.Label(_("Calendar Appearance"))
115
hbox1b.pack_start(cal_appear_label, True, False, 0)
116
hbox1b.pack_start(self.cal_appear_combo, True, True, 0)
117
vbox.pack_start(hbox1b, True, False, 0)
119
hbox2 = gtk.HBox(True, 0)
120
self.integ_combo = gtk.combo_box_new_text()
121
self.integ_combo.append_text(_("None"))
122
self.integ_combo.append_text(_("Evolution"))
123
self.integ_combo.append_text(_("Google Calendar"))
124
self.integ_combo.append_text(_("Outlook Web Access"))
125
self.integ_combo.set_active(self.int_opt[applet.integ_text])
126
self.integ_combo.connect("changed", self.combo_changed, "bla")
127
int_label = gtk.Label(_("Calendar Integration"))
128
hbox2.pack_start(int_label, True, False, 0)
129
hbox2.pack_start(self.integ_combo, True, True, 0)
130
vbox.pack_start(hbox2, True, False, 0)
132
#hbox3 = gtk.HBox(True, 0)
133
#self.user_label = gtk.Label(_("Calendar Username"))
134
#hbox3.pack_start(self.user_label)
135
#self.user = gtk.Entry(40)
136
#self.user.set_text(self.applet.username)
137
#hbox3.pack_start(self.user)
138
#vbox.pack_start(hbox3,False,False,2)
140
#hbox4 = gtk.HBox(True, 0)
141
#self.password_label = gtk.Label(_("Calendar Password"))
142
#hbox4.pack_start(self.password_label)
143
#self.password = gtk.Entry(20)
144
#self.password.set_visibility(False)
145
#self.password.set_text(self.applet.password)
146
#hbox4.pack_start(self.password)
147
#vbox.pack_start(hbox4,False,False,2)
149
hbox5 = gtk.HBox(True, 0)
150
self.url_label = gtk.Label(_("Calendar URL"))
151
hbox5.pack_start(self.url_label)
152
self.url = gtk.Entry(50)
153
self.url.set_text(self.applet.url)
154
hbox5.pack_start(self.url)
155
vbox.pack_start(hbox5, False, False, 2)
157
hbox6 = gtk.HBox(True, 0)
158
ok = gtk.Button(stock=gtk.STOCK_OK)
159
ok.connect("clicked", self.ok_button, "ok")
161
cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
162
cancel.connect("clicked", self.cancel_button, "cancel")
164
vbox.pack_end(hbox6, True, False, 2)
166
self.set_credential_sensitivity()
168
def set_credential_sensitivity(self):
169
option = self.int_opt_inv[self.integ_combo.get_active()]
170
if option == "Google Calendar" or option == "Outlook Web Access":
171
#self.user_label.set_sensitive(True)
172
#self.user.set_sensitive(True)
173
#self.password_label.set_sensitive(True)
174
#self.password.set_sensitive(True)
175
if option == "Google Calendar":
176
self.url_label.set_sensitive(False)
177
self.url.set_sensitive(False)
179
self.url_label.set_sensitive(True)
180
self.url.set_sensitive(True)
182
#self.user_label.set_sensitive(False)
183
#self.user.set_sensitive(False)
184
#self.password_label.set_sensitive(False)
185
#self.password.set_sensitive(False)
186
self.url_label.set_sensitive(False)
187
self.url.set_sensitive(False)
189
def combo_changed(self, widget, bla):
190
self.set_credential_sensitivity()
192
def ok_button(self, widget, event):
193
integration = self.int_opt_inv[self.integ_combo.get_active()]
194
self.applet.set_string_config('integration', integration)
195
#self.applet.set_string_config('username', self.user.get_text())
196
#self.applet.set_string_config('password',
197
# self.crypt(self.password.get_text(),
199
self.applet.set_string_config('url', self.url.get_text())
200
self.applet.set_boolean_config('twelve_hour_clock',
201
self.twelve_hour_checkbox.get_active())
202
#self.applet.set_boolean_config('blinking_colon',
203
# self.blink_checkbox.get_active())
204
background, text, border, plain = \
205
self.clock_appearance[self.clock_appear_combo.get_active_text()]
206
self.applet.set_string_config('clock_background', background)
207
self.applet.set_string_config('clock_foreground', text)
208
self.applet.set_string_config('clock_border', border)
209
self.applet.set_boolean_config('clock_plain', plain)
211
self.calendar_appearance[self.cal_appear_combo.get_active_text()]
212
self.applet.set_string_config('graphic', graphic)
213
self.applet.set_int_config('clock_appearance_index',
214
self.clock_appear_combo.get_active())
215
self.applet.set_int_config('cal_appearance_index',
216
self.cal_appear_combo.get_active())
219
def cancel_button(self, widget, event):