176
202
self.Toolbar.unset_style()
178
204
self.ConnectSignals()
180
AlarmThread = CheckAlarmThread.CheckAlarmThread\
205
self.UpdateList = True
206
self.AlarmThread = CheckAlarmThread.CheckAlarmThread\
181
207
(MainWindowGlade.get_widget('status_bar'),\
182
208
MainWindowGlade,StatusIcon,self.alarm_model, self.row,\
183
self.MainTreeViewSelection, StartGUI, PREFIX)
209
self.MainTreeViewSelection, StartGUI, PREFIX, self)
211
self.AlarmThread.start()
187
213
pynotify.init("Alarm-Clock")
189
215
def AddTree(self):
192
216
self.alarm_model = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
194
self.MainTreeView = gtk.TreeView(self.alarm_model)
195
self.AlarmScrolledWindow = MainWindowGlade.get_widget('alarms_main_scroll')
196
self.AlarmScrolledWindow.add(self.MainTreeView)
197
self.MainTreeView.show()
199
self.MainTreeView.set_enable_search(True)
200
self.MainTreeView.set_search_column(2)
204
self.summary_renderer = gtk.CellRendererText()
205
self.summary_renderer.set_property('editable', True)
206
self.summary_column = gtk.TreeViewColumn(_("Name"), self.summary_renderer, text=3)
207
self.summary_column.set_expand(True)
212
self.type_renderer = gtk.CellRendererPixbuf()
213
self.type_renderer_text = gtk.CellRendererText()
218
MainTreeView = gtk.TreeView(self.alarm_model)
219
AlarmScrolledWindow = MainWindowGlade.get_widget('alarms_main_scroll')
220
AlarmScrolledWindow.add(MainTreeView)
223
MainTreeView.set_enable_search(True)
224
MainTreeView.set_search_column(2)
228
summary_renderer = gtk.CellRendererText()
229
summary_renderer.set_property('editable', True)
230
self.summary_column = gtk.TreeViewColumn(_("Name"), summary_renderer, text=3)
235
type_renderer = gtk.CellRendererPixbuf()
236
type_renderer_text = gtk.CellRendererText()
215
238
self.type_column = gtk.TreeViewColumn(_("Type"))
217
self.type_column.pack_start(self.type_renderer, expand=False)
218
self.type_column.add_attribute(self.type_renderer, 'pixbuf', 1)
220
self.type_column.pack_start(self.type_renderer_text, expand=True)
221
self.type_column.add_attribute(self.type_renderer_text, 'text', 0)
225
self.type_column.set_min_width(140)
229
self.date_renderer = gtk.CellRendererText()
230
self.date_column = gtk.TreeViewColumn(_("Date and Time"), self.date_renderer, text=2)
231
self.date_column.set_min_width(180)
235
self.MainTreeView.append_column(self.summary_column)
236
self.MainTreeView.append_column(self.type_column)
237
self.MainTreeView.append_column(self.date_column)
238
self.MainTreeViewSelection = self.MainTreeView.get_selection()
240
self.type_column.pack_start(type_renderer, expand=False)
241
self.type_column.add_attribute(type_renderer, 'pixbuf', 1)
243
self.type_column.pack_start(type_renderer_text, expand=True)
244
self.type_column.add_attribute(type_renderer_text, 'text', 0)
250
date_renderer = gtk.CellRendererText()
251
self.date_column = gtk.TreeViewColumn(_("Date and Time"), date_renderer, text=2)
257
# time_remaining_renderer = gtk.CellRendererText()
258
# self.time_remaining_column = gtk.TreeViewColumn(_("Time remaining"), time_remaining_renderer, text=3)
263
SizesFile = file(os.getenv("HOME") + "/.config/alarm-clock/columns", "r")
264
Sizes = eval(SizesFile.readlines()[0])
267
Sizes = [150, 150, 100, 100]
268
self.summary_column.set_expand(True)
278
MainTreeView.append_column(self.summary_column)
279
self.summary_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
280
self.summary_column.set_fixed_width(Sizes[0])
281
self.summary_column.set_resizable(True)
282
self.summary_column.set_expand(False)
285
MainTreeView.append_column(self.type_column)
286
self.type_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
287
self.type_column.set_fixed_width(Sizes[1])
288
self.type_column.set_resizable(True)
291
MainTreeView.append_column(self.date_column)
292
self.date_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
293
self.date_column.set_fixed_width(Sizes[2])
294
self.date_column.set_resizable(True)
297
# MainTreeView.append_column(self.time_remaining_column)
298
# self.time_remaining_column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
299
# self.time_remaining_column.set_fixed_width(Sizes[0])
300
# self.time_remaining_column.set_resizable(True)
307
self.MainTreeViewSelection = MainTreeView.get_selection()
240
self.MainTreeView.connect("button_press_event", self.MainTreeButton)
241
self.MainTreeView.connect("key_press_event", self.MainTreeKey)
242
self.summary_renderer.connect("edited", self.EditingCell)
309
MainTreeView.connect("button_press_event", self.MainTreeButton)
310
MainTreeView.connect("key_press_event", self.MainTreeKey)
311
summary_renderer.connect("edited", self.EditingCell)
244
313
def EditingCell(self, Widget, RowNumber, NewValue):
245
314
AlarmsFile = file(os.getenv("HOME") + "/.config/alarm-clock/alarms", "r")
289
356
if button.type == gtk.gdk._2BUTTON_PRESS:
290
357
self.ChangeAlarmPrefs(None)
291
358
if button.button == 3:
292
self.pop = gtk.Menu()
294
self.add_alarm = gtk.ImageMenuItem(_("Add new alarm..."), False)
295
self.add_image = gtk.Image()
296
self.add_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
297
self.add_alarm.set_image(self.add_image)
299
self.add_counter = gtk.ImageMenuItem(_("Add new counter..."), False)
300
self.add_cntr_image = gtk.Image()
301
self.add_cntr_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
302
self.add_counter.set_image(self.add_cntr_image)
304
self.sep1 = gtk.SeparatorMenuItem()
305
self.sep2 = gtk.SeparatorMenuItem()
307
self.remove_alarm = gtk.ImageMenuItem(_("Remove this alarm"), False)
308
self.remove_image = gtk.Image()
309
self.remove_image.set_from_stock("gtk-remove", gtk.ICON_SIZE_MENU)
310
self.remove_alarm.set_image(self.remove_image)
312
self.alarm_properties = gtk.ImageMenuItem("gtk-properties", False)
315
self.pop.add(self.add_alarm)
316
self.pop.add(self.add_counter)
317
self.pop.add(self.sep1)
318
self.pop.add(self.remove_alarm)
319
self.pop.add(self.sep2)
320
self.pop.add(self.alarm_properties)
323
self.add_alarm.connect("activate", self.AddAlarmDialog)
324
self.add_counter.connect("activate", self.AddSimpleCounterDialog)
325
self.remove_alarm.connect("activate", self.RemoveAlarmDialog)
326
self.alarm_properties.connect("activate", self.ChangeAlarmPrefs)
329
self.pop.popup(None, None, None, button.button, button.time)
361
add_alarm = gtk.ImageMenuItem(_("Add new alarm..."), False)
362
add_image = gtk.Image()
363
add_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
364
add_alarm.set_image(add_image)
366
add_counter = gtk.ImageMenuItem(_("Add new counter..."), False)
367
add_cntr_image = gtk.Image()
368
add_cntr_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
369
add_counter.set_image(add_cntr_image)
371
sep1 = gtk.SeparatorMenuItem()
372
sep2 = gtk.SeparatorMenuItem()
374
remove_alarm = gtk.ImageMenuItem(_("Remove this alarm"), False)
375
remove_image = gtk.Image()
376
remove_image.set_from_stock("gtk-remove", gtk.ICON_SIZE_MENU)
377
remove_alarm.set_image(remove_image)
379
alarm_properties = gtk.ImageMenuItem("gtk-properties", False)
385
pop.add(remove_alarm)
387
pop.add(alarm_properties)
390
add_alarm.connect("activate", self.AddAlarmDialog)
391
add_counter.connect("activate", self.AddSimpleCounterDialog)
392
remove_alarm.connect("activate", self.RemoveAlarmDialog)
393
alarm_properties.connect("activate", self.ChangeAlarmPrefs)
396
pop.popup(None, None, None, button.button, button.time)
331
398
def MainTreeKey (self,widget,key):
332
399
key = gtk.gdk.keyval_name(key.keyval)
336
403
if (key == "Return" or key == "KP_Return"):
337
404
self.ChangeAlarmPrefs(None)
406
def ShowMissedAlarms(self, widget):
407
AlarmModel = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
410
AlarmFile = file(os.getenv("HOME") + "/.config/alarm-clock/old-alarms", "r")
412
for line in AlarmFile:
414
self.ParseTupletToList(line, AlarmModel)
418
MissedGlade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'missed_alarms_dialog')
419
MissedWindow = MissedGlade.get_widget('missed_alarms_dialog')
420
MissedTree = MissedGlade.get_widget('missed_tree')
422
MissedWindow.set_transient_for(MainWindow)
424
self.summary_renderer = gtk.CellRendererText()
425
self.summary_renderer.set_property('editable', True)
426
self.summary_column = gtk.TreeViewColumn(_("Name"), self.summary_renderer, text=3)
427
self.summary_column.set_expand(True)
432
self.type_renderer = gtk.CellRendererPixbuf()
433
self.type_renderer_text = gtk.CellRendererText()
435
self.type_column = gtk.TreeViewColumn(_("Type"))
437
self.type_column.pack_start(self.type_renderer, expand=False)
438
self.type_column.add_attribute(self.type_renderer, 'pixbuf', 1)
440
self.type_column.pack_start(self.type_renderer_text, expand=True)
441
self.type_column.add_attribute(self.type_renderer_text, 'text', 0)
445
self.type_column.set_min_width(140)
449
self.date_renderer = gtk.CellRendererText()
450
self.date_column = gtk.TreeViewColumn(_("Date and Time"), self.date_renderer, text=2)
451
self.date_column.set_min_width(180)
455
MissedTree.append_column(self.summary_column)
456
MissedTree.append_column(self.type_column)
457
MissedTree.append_column(self.date_column)
474
if len(AlarmModel) == 0:
475
MissedGlade.get_widget('clear_button').set_sensitive(False)
478
MissedTree.set_model(AlarmModel)
480
self.Model = AlarmModel
482
MissedWindow.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
484
Signals = { "clear_alarms" : self.ClearOld,
485
"close_old" : self.CloseOld }
487
MissedGlade.signal_autoconnect(Signals)
491
def ClearOld(self, button):
492
button.set_sensitive(False)
495
os.remove(os.getenv("HOME") + "/.config/alarm-clock/old-alarms")
500
def CloseOld(self, button):
501
button.get_toplevel().destroy()
503
def ReportBug(self, menu):
504
os.system('xdg-open \"https://bugs.launchpad.net/alarmclock\"')
340
506
def ConnectSignals(self):
341
507
self.Signals = { "show_about" : self.ShowAboutDialog,
753
954
# Saving changes!
755
956
self.AlarmBuffer[0] = self.NameEntry.get_text()
756
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
958
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
959
AMPM = self.TimeCombo.get_active()
960
Hour = self.AlarmProps.get_widget('alarm_props_hour_spin').get_value()
961
Min = self.AlarmProps.get_widget('alarm_props_minute_spin').get_value()
964
self.AlarmBuffer[1] = "%i:%i" % (12, Min)
966
self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
969
self.AlarmBuffer[1] = "%i:%i" % (0, Min)
971
self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
972
if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
973
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
757
978
if self.SingleRadio.get_active():
758
979
self.AlarmBuffer[2] = 0
759
980
if self.ScheduleRadio.get_active():
855
1076
# Saving changes!
857
1078
self.AlarmBuffer[0] = self.NameEntry.get_text()
858
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1080
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1081
AMPM = self.TimeCombo.get_active()
1082
Hour = self.AlarmProps.get_widget('alarm_props_hour_spin').get_value()
1083
Min = self.AlarmProps.get_widget('alarm_props_minute_spin').get_value()
1086
self.AlarmBuffer[1] = "%i:%i" % (12, Min)
1088
self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
1091
self.AlarmBuffer[1] = "%i:%i" % (0, Min)
1093
self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
1096
if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1097
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
859
1102
if self.SingleRadio.get_active():
860
1103
self.AlarmBuffer[2] = 0
861
1104
if self.ScheduleRadio.get_active():
903
1146
self.RefreshTemplateList()
904
1147
self.TemplateSelection.select_path(self.row,)
906
def StopTheSound(self,obj):
1149
def StopTheSound(self,obj = None, x = None):
907
1150
MainWindowGlade.get_widget('stop_sound').set_sensitive(False)
908
1151
FadeStopped = True
909
1152
PlayerInstance.set_state(gst.STATE_NULL)
910
1153
PlayerInstance.set_property("volume", 0)
1154
StatusIcon.set_blinking(False)
913
1157
def StatusClicked(self,obj):
1158
if StatusIcon.get_blinking() == True:
1159
StatusIcon.set_blinking(False)
914
1163
if self.main_hidden:
915
1165
self.fc = file(os.getenv("HOME") + "/.config/alarm-clock/configuration", "r")
916
1166
self.Pos = self.fc.readline()
918
self.Pos = eval(self.Pos)
919
MainWindow.move(self.Pos[0][0], self.Pos[0][1])
920
MainWindow.resize(self.Pos[1][0], self.Pos[1][1])
1169
self.Pos = eval(self.Pos)
1170
MainWindow.move(self.Pos[0][0], self.Pos[0][1])
1171
MainWindow.resize(self.Pos[1][0], self.Pos[1][1])
921
1174
MainWindow.present()
922
1175
self.main_hidden = False
928
1181
self.main_hidden = True
930
1183
def StatusPopup(self,obj,v1,v2):
931
self.pop = gtk.Menu()
933
self.show_win = gtk.CheckMenuItem(_("Show main window on screen"), True)
934
self.show_win.set_active(self.main_hidden == False)
936
self.add_alarm = gtk.ImageMenuItem(_("Add new alarm..."), False)
937
self.add_image = gtk.Image()
938
self.add_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
939
self.add_alarm.set_image(self.add_image)
941
self.add_counter = gtk.ImageMenuItem(_("Add new counter..."), False)
942
self.add_cntr_image = gtk.Image()
943
self.add_cntr_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
944
self.add_counter.set_image(self.add_cntr_image)
1187
show_win = gtk.CheckMenuItem(_("Show main window on screen"), True)
1188
show_win.set_active(self.main_hidden == False)
1190
add_alarm = gtk.ImageMenuItem(_("Add new alarm..."), False)
1191
add_image = gtk.Image()
1192
add_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
1193
add_alarm.set_image(add_image)
1195
add_counter = gtk.ImageMenuItem(_("Add new counter..."), False)
1196
add_cntr_image = gtk.Image()
1197
add_cntr_image.set_from_stock("gtk-add", gtk.ICON_SIZE_MENU)
1198
add_counter.set_image(add_cntr_image)
948
self.sep1 = gtk.SeparatorMenuItem()
949
self.sep2 = gtk.SeparatorMenuItem()
950
self.quit_a = gtk.ImageMenuItem("gtk-quit", False)
952
self.pop.add(self.show_win)
953
self.pop.add(self.sep1)
954
self.pop.add(self.add_alarm)
955
self.pop.add(self.add_counter)
956
self.pop.add(self.sep2)
957
self.pop.add(self.quit_a)
960
self.quit_a.connect("activate", self.QuitApplication)
961
self.add_alarm.connect("activate", self.AddAlarmDialog)
962
self.show_win.connect("activate", self.StatusClicked)
963
self.add_counter.connect("activate", self.AddSimpleCounterDialog)
966
self.pop.popup(None, None, gtk.status_icon_position_menu, v1, v2, StatusIcon)
1202
sep1 = gtk.SeparatorMenuItem()
1203
sep2 = gtk.SeparatorMenuItem()
1204
quit_a = gtk.ImageMenuItem("gtk-quit", False)
1209
pop.add(add_counter)
1214
quit_a.connect("activate", self.QuitApplication)
1215
add_alarm.connect("activate", self.AddAlarmDialog)
1216
show_win.connect("activate", self.StatusClicked)
1217
add_counter.connect("activate", self.AddSimpleCounterDialog)
1220
pop.popup(None, None, gtk.status_icon_position_menu, v1, v2, StatusIcon)
968
1222
def ShowAboutDialog(self,obj):
969
self.AboutDialog = gtk.AboutDialog()
970
self.AboutDialog.set_name (_("Alarm Clock"))
971
self.AboutDialog.set_version(Version.get_version())
972
self.AboutDialog.set_copyright(_("(c) 2008 Tomasz SaÅaciÅski\n"
1223
AboutDialog = gtk.AboutDialog()
1224
AboutDialog.set_name (_("Alarm Clock"))
1225
AboutDialog.set_version(Version.get_version())
1226
AboutDialog.set_copyright(_("(c) 2008 Tomasz SaÅaciÅski\n"
973
1227
"<tsalacinski@gmail.com>\n"
975
1229
"For Kamila:)"))
976
self.AboutDialog.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
977
self.AboutDialog.set_transient_for(MainWindow)
978
self.AboutDialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
979
self.AboutDialog.set_website("http://www.alarm-clock.54.pl")
980
self.Authors = [_("Programming"), "\tTomasz SaÅaciÅski", _("Packaging and a lot of help"), "\tMarco Rodrigues"]
981
self.AboutDialog.set_authors(self.Authors)
982
self.LogoPixbuf = gtk.gdk.pixbuf_new_from_file(PREFIX + '/scalable/alarm-clock.svg')
983
self.AboutDialog.set_logo(self.LogoPixbuf)
1230
AboutDialog.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
1231
AboutDialog.set_transient_for(MainWindow)
1232
AboutDialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
1233
AboutDialog.set_website("http://www.alarm-clock.54.pl")
1234
Authors = [_("Programming"), "\tTomasz SaÅaciÅski", _("Packaging and a lot of help"), "\tMarco Rodrigues"]
1235
AboutDialog.set_authors(Authors)
1236
LogoPixbuf = gtk.gdk.pixbuf_new_from_file(PREFIX + '/scalable/alarm-clock.svg')
1237
AboutDialog.set_logo(LogoPixbuf)
986
1240
Alarm Clock is free software; you can redistribute it and/or modify
987
1241
it under the terms of the GNU General Public License as published by
988
1242
the Free Software Foundation; either version 2 of the License, or
1019
1272
def QuitApplication(self,obj):
1020
1273
self.fc = file(os.getenv("HOME") + "/.config/alarm-clock/configuration", "w")
1021
1274
print >> self.fc, [MainWindow.get_position(), MainWindow.get_size()]
1275
self.SizesFile = file(os.getenv("HOME") + "/.config/alarm-clock/columns", "w")
1277
# print >> self.SizesFile, [self.summary_column.get_width(), self.type_column.get_width(),
1278
# self.date_column.get_width(), self.time_remaining_column.get_width()]
1280
print >> self.SizesFile, [self.summary_column.get_width(), self.type_column.get_width(),
1281
self.date_column.get_width(), 0]
1283
self.SizesFile.close()
1285
os.remove(os.getenv("HOME") + "/.config/alarm-clock/lock")
1022
1289
self.fc.close()
1291
TerminalFile = file(os.getenv("HOME") + "/.config/alarm-clock/terminal", "w")
1292
TerminalFile.write(self.TerminalCommand)
1293
TerminalFile.close()
1023
1297
PlayerInstance.set_state(gst.STATE_NULL)
1024
1298
gtk.gdk.threads_leave()
1025
1299
gtk.main_quit()
1027
def ChangeAlarmPrefs(self,obj):
1301
def ChangeAlarmPrefs(self,obj, HaveNumber = None):
1028
1302
self.LoadCurrentAlarm()
1029
1303
self.value = self.AlarmPrefs().run()
1032
1306
# Saving changes!
1034
1308
self.AlarmBuffer[0] = self.NameEntry.get_text()
1035
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1310
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1311
AMPM = self.TimeCombo.get_active()
1312
Hour = self.AlarmProps.get_widget('alarm_props_hour_spin').get_value()
1313
Min = self.AlarmProps.get_widget('alarm_props_minute_spin').get_value()
1316
self.AlarmBuffer[1] = "%i:%i" % (12, Min)
1318
self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
1321
self.AlarmBuffer[1] = "%i:%i" % (0, Min)
1323
self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
1326
if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1327
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1036
1331
if self.SingleRadio.get_active():
1037
1332
self.AlarmBuffer[2] = 0
1038
1333
if self.ScheduleRadio.get_active():
1162
1462
self.f = file(os.getenv("HOME") + "/.config/alarm-clock/templates", "r")
1163
1463
self.line = self.f.readlines()
1164
1464
self.AlarmBuffer = eval(self.line[self.AddAlarmTemplateCombo.get_active()])
1166
self.value = self.AlarmPrefs().run()
1167
if self.value == gtk.RESPONSE_OK:
1170
self.f = file(os.getenv("HOME") + "/.config/alarm-clock/alarms", "a")
1171
self.AlarmBuffer[0] = self.NameEntry.get_text()
1172
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1173
if self.SingleRadio.get_active():
1174
self.AlarmBuffer[2] = 0
1175
if self.ScheduleRadio.get_active():
1176
self.AlarmBuffer[2] = 1
1178
if self.TodayRadio.get_active():
1179
self.AlarmBuffer[2] = 0
1180
self.AlarmBuffer[3] = "%s/%s/%s" % (datetime.datetime.now().year,
1181
datetime.datetime.now().month - 1, datetime.datetime.now().day)
1183
if self.TomorrowRadio.get_active():
1184
self.AlarmBuffer[2] = 0
1185
self.Today = datetime.datetime.now() + datetime.timedelta(days=1)
1186
self.AlarmBuffer[3] = "%s/%s/%s" % (self.Today.year,
1187
self.Today.month - 1, self.Today.day)
1189
if self.SoundCheck.get_active():
1190
self.AlarmBuffer[7] = True
1192
self.AlarmBuffer[7] = False
1193
if self.PassiveCheck.get_active():
1194
self.AlarmBuffer[15] = True
1196
self.AlarmBuffer[15] = False
1197
if self.DialogCheck.get_active():
1198
self.AlarmBuffer[19] = True
1200
self.AlarmBuffer[19] = False
1201
if self.CmdCheck.get_active():
1202
self.AlarmBuffer[27] = True
1204
self.AlarmBuffer[27] = False
1205
if self.StdCheck.get_active():
1206
self.AlarmBuffer[32] = True
1208
self.AlarmBuffer[32] = False
1211
print >> self.f, self.AlarmBuffer
1217
self.LoadConfigFiles()
1219
self.MainTreeViewSelection.select_path(self.row)
1220
self.AlarmPropsWidget.destroy()
1466
self.AlarmPrefs().connect("response", self.ResponseDialog)
1225
1468
if self.AddAlarmNew.get_active():
1226
1469
self.AddDialogWidget.destroy()
1227
1470
self.ClearAlarmValues()
1229
1471
self.AlarmPrefs().connect("response", self.ResponseDialog)
1231
1473
if self.AddCounter.get_active():
1232
1474
self.AddDialogWidget.destroy()
1233
1475
self.AddSimpleCounterDialog()
1240
1478
self.AddDialogWidget.destroy()
1247
1485
# Saving changes!
1248
1486
self.f = file(os.getenv("HOME") + "/.config/alarm-clock/alarms", "a")
1249
1487
self.AlarmBuffer[0] = self.NameEntry.get_text()
1250
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1489
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1490
AMPM = self.TimeCombo.get_active()
1491
Hour = self.AlarmProps.get_widget('alarm_props_hour_spin').get_value()
1492
Min = self.AlarmProps.get_widget('alarm_props_minute_spin').get_value()
1495
self.AlarmBuffer[1] = "%i:%i" % (12, Min)
1497
self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
1500
self.AlarmBuffer[1] = "%i:%i" % (0, Min)
1502
self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
1503
if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
1504
self.AlarmBuffer[1] = "%i:%i" % (self.AlarmProps.get_widget('alarm_props_hour_spin').get_value(), self.AlarmProps.get_widget('alarm_props_minute_spin').get_value())
1251
1509
if self.SingleRadio.get_active():
1252
1510
self.AlarmBuffer[2] = 0
1253
1511
if self.ScheduleRadio.get_active():
1496
1755
self.AlarmBuffer[10] = self.sp_Glade.get_widget('constant_volume_radio').get_active()
1498
self.AlarmBuffer[11] = self.sp_Glade.get_widget('constant_volume_scale').get_value()
1499
self.AlarmBuffer[12] = self.sp_Glade.get_widget('vol_init_scale').get_value()
1500
self.AlarmBuffer[13] = self.sp_Glade.get_widget('vol_final_scale').get_value()
1501
self.AlarmBuffer[14] = self.sp_Glade.get_widget('vol_duration_scale').get_value()
1502
self.AlarmBuffer[40] = self.sp_Glade.get_widget('after_fade_scale').get_value()
1503
self.AlarmBuffer[41] = self.sp_Glade.get_widget('repeat_volume_scale').get_value()
1758
self.AlarmBuffer[12] = self.sp_Glade.get_widget('initial_volume_spin').get_value()
1759
self.AlarmBuffer[13] = self.sp_Glade.get_widget('final_volume_spin').get_value()
1760
self.AlarmBuffer[14] = self.sp_Glade.get_widget('duration_sec_spin').get_value()
1761
self.AlarmBuffer[40] = self.sp_Glade.get_widget('duration_fade_spin').get_value()
1762
self.AlarmBuffer[11] = self.sp_Glade.get_widget('constant_volume_spin').get_value()
1764
Times = self.sp_Glade.get_widget('repeat_value_spin').get_value()
1766
self.AlarmBuffer[41] = -1
1768
self.AlarmBuffer[41] = Times
1504
1769
self.sp.destroy()
1772
# 7 - Boolean - whatever to play sound
1773
# 8 - Boolean - Use custom sound file
1774
# 9 - String - path to sound file
1775
# 10 - Boolean - Constant (True) or Fade (False)
1776
# 11 - Integer - Constant volume value
1777
# 12 - Integer - Fade (Initial volume)
1778
# 13 - Integer - Fade (Final volume)
1779
# 14 - Integer - Fade (Duration in seconds)
1780
# 40 - Integer - Fade (Duration after fade)
1781
# 41 - Integer - Repeat times
1508
1788
self.sp.destroy()
1791
def CheckSpinButtons(self, Spin):
1792
self.sp_Glade.get_widget('constant_volume_scale').set_value(self.sp_Glade.get_widget('constant_volume_spin').get_value())
1793
self.sp_Glade.get_widget('repeat_volume_scale').set_value(self.sp_Glade.get_widget('repeat_value_spin').get_value())
1794
self.sp_Glade.get_widget('vol_init_scale').set_value(self.sp_Glade.get_widget('initial_volume_spin').get_value())
1795
self.sp_Glade.get_widget('vol_final_scale').set_value(self.sp_Glade.get_widget('final_volume_spin').get_value())
1796
self.sp_Glade.get_widget('vol_duration_scale').set_value(self.sp_Glade.get_widget('duration_sec_spin').get_value())
1797
self.sp_Glade.get_widget('after_fade_scale').set_value(self.sp_Glade.get_widget('duration_fade_spin').get_value())
1510
1799
def CheckSoundPrefsWindow(self,obj):
1511
1800
self.buf = self.sp_Glade.get_widget('custom_sound_file_check').get_active()
1512
1801
self.sp_Glade.get_widget('soundfile_label').set_sensitive(self.buf)
1514
1803
self.buf = self.sp_Glade.get_widget('constant_volume_radio').get_active()
1515
1804
self.sp_Glade.get_widget('constant_volume_label').set_sensitive(self.buf)
1516
1805
self.sp_Glade.get_widget('constant_volume_scale').set_sensitive(self.buf)
1517
self.sp_Glade.get_widget('constant_volume_percent').set_sensitive(self.buf)
1806
self.sp_Glade.get_widget('constant_volume_spin').set_sensitive(self.buf)
1519
1808
self.sp_Glade.get_widget('repeat_volume_label').set_sensitive(self.buf)
1520
1809
self.sp_Glade.get_widget('repeat_volume_scale').set_sensitive(self.buf)
1521
self.sp_Glade.get_widget('repeat_volume_secs').set_sensitive(self.buf)
1810
self.sp_Glade.get_widget('repeat_value_spin').set_sensitive(self.buf)
1523
1812
self.buf = self.sp_Glade.get_widget('fade_volume_radio').get_active()
1525
1814
self.sp_Glade.get_widget('vol_init_label').set_sensitive(self.buf)
1526
1815
self.sp_Glade.get_widget('vol_init_scale').set_sensitive(self.buf)
1527
self.sp_Glade.get_widget('vol_init_percent').set_sensitive(self.buf)
1816
self.sp_Glade.get_widget('initial_volume_spin').set_sensitive(self.buf)
1528
1817
self.sp_Glade.get_widget('vol_final_label').set_sensitive(self.buf)
1529
1818
self.sp_Glade.get_widget('vol_final_scale').set_sensitive(self.buf)
1530
self.sp_Glade.get_widget('vol_final_percent').set_sensitive(self.buf)
1819
self.sp_Glade.get_widget('final_volume_spin').set_sensitive(self.buf)
1531
1820
self.sp_Glade.get_widget('vol_duration_label').set_sensitive(self.buf)
1532
1821
self.sp_Glade.get_widget('vol_duration_scale').set_sensitive(self.buf)
1533
self.sp_Glade.get_widget('vol_duration_secs').set_sensitive(self.buf)
1822
self.sp_Glade.get_widget('duration_sec_spin').set_sensitive(self.buf)
1534
1823
self.sp_Glade.get_widget('after_fade_label').set_sensitive(self.buf)
1535
1824
self.sp_Glade.get_widget('after_fade_scale').set_sensitive(self.buf)
1536
self.sp_Glade.get_widget('after_fade_secs').set_sensitive(self.buf)
1825
self.sp_Glade.get_widget('duration_fade_spin').set_sensitive(self.buf)
1538
1827
def CheckSoundPrefsSliders(self,obj,val1, val2):
1539
self.sp_Glade.get_widget('constant_volume_percent').set_text("%i %%" % self.sp_Glade.get_widget('constant_volume_scale').get_value())
1541
self.sp_Glade.get_widget('repeat_volume_secs').set_text("%i" % self.sp_Glade.get_widget('repeat_volume_scale').get_value())
1543
if self.sp_Glade.get_widget('repeat_volume_scale').get_value() == 0:
1544
self.sp_Glade.get_widget('repeat_volume_secs').set_text(_("Unlimited"))
1546
self.sp_Glade.get_widget('vol_init_percent').set_text("%i %%" % self.sp_Glade.get_widget('vol_init_scale').get_value())
1547
self.sp_Glade.get_widget('vol_final_percent').set_text("%i %%" % self.sp_Glade.get_widget('vol_final_scale').get_value())
1548
self.sp_Glade.get_widget('vol_duration_secs').set_text("%i s" % self.sp_Glade.get_widget('vol_duration_scale').get_value())
1549
self.sp_Glade.get_widget('after_fade_secs').set_text("%i s" % self.sp_Glade.get_widget('after_fade_scale').get_value())
1829
self.sp_Glade.get_widget('constant_volume_spin').set_value(self.sp_Glade.get_widget('constant_volume_scale').get_value())
1831
self.sp_Glade.get_widget('repeat_value_spin').set_value(self.sp_Glade.get_widget('repeat_volume_scale').get_value())
1833
self.sp_Glade.get_widget('initial_volume_spin').set_value(self.sp_Glade.get_widget('vol_init_scale').get_value())
1834
self.sp_Glade.get_widget('final_volume_spin').set_value(self.sp_Glade.get_widget('vol_final_scale').get_value())
1835
self.sp_Glade.get_widget('duration_sec_spin').set_value(self.sp_Glade.get_widget('vol_duration_scale').get_value())
1836
self.sp_Glade.get_widget('duration_fade_spin').set_value(self.sp_Glade.get_widget('after_fade_scale').get_value())
1551
1838
def PassivePrefsActive(self,obj):
1552
1839
self.pw_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'passive_window_properties')
2152
2436
self.AlarmBuffer[4] = self.Final
2438
def CheckMonths(self):
2439
self.Tuplet2 = [self.ScheduleProps.get_widget('m1').get_active(),
2440
self.ScheduleProps.get_widget('m2').get_active(),
2441
self.ScheduleProps.get_widget('m3').get_active(),
2442
self.ScheduleProps.get_widget('m4').get_active(),
2443
self.ScheduleProps.get_widget('m5').get_active(),
2444
self.ScheduleProps.get_widget('m6').get_active(),
2445
self.ScheduleProps.get_widget('m7').get_active(),
2446
self.ScheduleProps.get_widget('m8').get_active(),
2447
self.ScheduleProps.get_widget('m9').get_active(),
2448
self.ScheduleProps.get_widget('m10').get_active(),
2449
self.ScheduleProps.get_widget('m11').get_active(),
2450
self.ScheduleProps.get_widget('m12').get_active()]
2454
for Item in self.Tuplet2:
2460
def CheckDays(self):
2461
self.Tuplet2 = [self.ScheduleProps.get_widget('w1').get_active(),
2462
self.ScheduleProps.get_widget('w2').get_active(),
2463
self.ScheduleProps.get_widget('w3').get_active(),
2464
self.ScheduleProps.get_widget('w4').get_active(),
2465
self.ScheduleProps.get_widget('w5').get_active(),
2466
self.ScheduleProps.get_widget('w6').get_active(),
2467
self.ScheduleProps.get_widget('w7').get_active()]
2471
for Item in self.Tuplet2:
2154
2480
def SchedulePrefsActive(self,obj):
2155
2481
self.Al = self.AlarmBuffer[5]
2156
2482
self.ScheduleProps = gtk.glade.XML(PREFIX + '/glade/main.glade', 'schedule_dialog')
2180
2506
self.RefreshExceptionList()
2182
self.SchedSignals = { "add_exception" : self.AddExceptionDialog,
2508
SchedSignals = { "add_exception" : self.AddExceptionDialog,
2183
2509
"remove_exception" : self.RemoveExceptionDialog,
2184
2510
"load_exc_click" : self.LoadExceptionList,
2185
2511
"save_exc_click" : self.SaveExceptionList,
2186
2512
"SelectAllWeekdays" : self.SelectAllWeekdays,
2187
2513
"DeselectAllWeekdays" : self.DeselectAllWeekdays,
2188
2514
"SelectAllMonths" : self.SelectAllMoths,
2189
"DeselectAllMonths" : self.DeselectAllMonhts, }
2191
self.ScheduleProps.signal_autoconnect(self.SchedSignals)
2196
self.result = self.SchedulePropsWidget.run()
2198
if self.result == gtk.RESPONSE_OK:
2199
self.AlarmBuffer[5] = self.Al
2203
self.SchedulePropsWidget.destroy()
2515
"DeselectAllMonths" : self.DeselectAllMonhts,
2516
"SchedCancel" : self.SchedCancel,
2517
"SchedOK" : self.SchedOK }
2519
self.ScheduleProps.signal_autoconnect(SchedSignals)
2524
self.result = self.SchedulePropsWidget.show()
2526
def SchedCancel(self, obj):
2527
self.SchedulePropsWidget.destroy()
2529
def SchedOK(self, obj):
2530
if self.CheckMonths() == False:
2531
Dialog = gtk.MessageDialog(self.SchedulePropsWidget,
2532
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING,
2533
gtk.BUTTONS_OK, None)
2534
Dialog.set_markup(_("<b>Month list is empty</b>"))
2535
Dialog.format_secondary_text(_("You need to select at least one month to proceed."))
2540
if self.CheckDays() == False:
2541
Dialog = gtk.MessageDialog(self.SchedulePropsWidget,
2542
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING,
2543
gtk.BUTTONS_OK, None)
2544
Dialog.set_markup(_("<b>Days list is empty</b>"))
2545
Dialog.format_secondary_text(_("You need to select at least one day to proceed."))
2550
self.AlarmBuffer[5] = self.Al
2552
self.SchedulePropsWidget.destroy()
2207
2554
def SelectAllWeekdays(self, Button):
2208
2555
for x in range(1,8):
2265
2627
self.SingleRadio.set_active(True)
2266
2628
self.PrefsSchedule.set_sensitive(False)
2630
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
2631
HBox = self.AlarmProps.get_widget('alarm_time_hbox')
2632
self.TimeCombo = gtk.combo_box_new_text()
2633
self.TimeCombo.append_text(_("AM"))
2634
self.TimeCombo.append_text(_("PM"))
2635
HBox.pack_start(self.TimeCombo, False, False, 0)
2636
self.TimeCombo.set_active(0)
2637
self.TimeCombo.show()
2638
self.AlarmHourSpin.set_range(1, 12)
2269
2640
# Setting values
2270
2641
self.time_data = re.search('(\d+):(\d+)', self.AlarmBuffer[1])
2271
self.AlarmProps.get_widget('alarm_props_hour_spin').set_value(int (self.time_data.group(1)))
2272
self.AlarmProps.get_widget('alarm_props_minute_spin').set_value(int (self.time_data.group(2)))
2642
time_hour = int (self.time_data.group(1))
2643
time_min = int (self.time_data.group(2))
2645
if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
2647
time_hour = time_hour - 12
2648
self.TimeCombo.set_active(1)
2650
self.TimeCombo.set_active(0)
2652
self.AlarmProps.get_widget('alarm_props_hour_spin').set_value(time_hour)
2653
self.AlarmProps.get_widget('alarm_props_minute_spin').set_value(time_min)
2273
2654
self.AlarmProps.get_widget('alarm_props_short_name_entry').set_text(self.AlarmBuffer[0])
2275
2656
if self.AlarmBuffer[2] == 0:
2402
2783
# 36 - Integer - Confirmation timeout in seconds
2788
# Checking for the current time of day and week
2790
Month = datetime.datetime.now().month
2791
Weekday = datetime.datetime.now().weekday()
2405
2794
self.AlarmBuffer = [_("Untitled"),
2406
2795
"%s:%s" % (time.localtime().tm_hour, time.localtime().tm_min + 1),
2408
2797
"%i/%i/%i" % (time.localtime().tm_year, time.localtime().tm_mon - 1, time.localtime().tm_mday),
2409
[[False, False, False, False, False, False, False], [False, False, False, False, False, False, False, False, False, False, False, False]],
2798
[[False, False, False, False, False, False, False],
2799
[False, False, False, False, False, False, False, False, False, False, False, False]],
2838
self.AlarmBuffer[4][0][Weekday] = True
2839
self.AlarmBuffer[4][1][Month - 1] = True
2448
2841
def SingleDayPrefs(self,obj):
2449
self.SingleDate = gtk.glade.XML(PREFIX + '/glade/main.glade', 'single_day_dialog')
2450
self.SingleDateWidget = self.SingleDate.get_widget('single_day_dialog')
2451
self.SingleDateWidget.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
2452
self.date_data = re.search('(\d+)/(\d+)/(\d+)', self.AlarmBuffer[3])
2453
self.SingleDate.get_widget('calendar').select_month(int (self.date_data.group(2)), int (self.date_data.group(1)))
2454
self.SingleDate.get_widget('calendar').select_day(int (self.date_data.group(3)))
2457
if self.SingleDateWidget.run() == gtk.RESPONSE_CANCEL:
2458
self.SingleDateWidget.destroy()
2842
SingleDate = gtk.glade.XML(PREFIX + '/glade/main.glade', 'single_day_dialog')
2843
SingleDateWidget = SingleDate.get_widget('single_day_dialog')
2844
SingleDateWidget.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
2845
date_data = re.search('(\d+)/(\d+)/(\d+)', self.AlarmBuffer[3])
2846
SingleDate.get_widget('calendar').select_month(int (self.date_data.group(2)), int (self.date_data.group(1)))
2847
SingleDate.get_widget('calendar').select_day(int (self.date_data.group(3)))
2850
if SingleDateWidget.run() == gtk.RESPONSE_CANCEL:
2851
SingleDateWidget.destroy()
2461
self.AlarmBuffer[3] = "%s/%s/%s" % self.SingleDate.get_widget('calendar').get_date()
2462
self.SingleDateWidget.destroy()
2854
self.AlarmBuffer[3] = "%s/%s/%s" % SingleDate.get_widget('calendar').get_date()
2855
SingleDateWidget.destroy()
2468
2861
def LoadConfigFiles(self):
2862
if self.UpdateList == False:
2470
2865
if os.path.isdir(os.getenv("HOME") + "/.config/alarm-clock/") == False:
2471
2866
os.mkdir (os.getenv("HOME") + "/.config/alarm-clock")
2473
2869
if os.path.isfile(os.getenv("HOME") + "/.config/alarm-clock/configuration") == False:
2474
2870
self.fc = file(os.getenv("HOME") + "/.config/alarm-clock/configuration", "w")
2475
2871
print >> self.fc, [MainWindow.get_position(), MainWindow.get_size()]
2530
def ParseTupletToList(self,line):
2531
self.string = eval(line)
2533
self.weekdays = self.string[4][0]
2534
self.months = self.string[4][1]
2536
self.t_weekday = time.localtime().tm_wday
2537
self.t_month = time.localtime().tm_mon
2538
self.t_day = time.localtime().tm_mday
2541
self.t = re.search('(\d+):(\d+)', self.string[1])
2543
self.h = "%s" % self.t.group(1)
2545
if int (self.t.group(2)) < 10:
2546
self.m = "0%s" % self.t.group(2)
2548
self.m = "%s" % self.t.group(2)
2557
self.weekdays = self.string[4][0]
2558
self.months = self.string[4][1]
2560
if self.weekdays[self.t_weekday] == True and self.months[self.t_month - 1] == True:
2563
for t in self.string[5]:
2564
if t[0] == self.t_month and t[1] == self.t_day:
2571
if self.Good == True and self.string[2] == 1:
2572
self.time = _("%s:%s - Today") % (self.h, self.m)
2575
self.time = _("%s:%s - Cancelled") % (self.h, self.m)
2929
def ParseTupletToList(self,line, model = None):
2931
model = self.alarm_model
2934
weekdays = string[4][0]
2935
months = string[4][1]
2937
t_weekday = time.localtime().tm_wday
2938
t_month = time.localtime().tm_mon
2939
t_day = time.localtime().tm_mday
2942
t = re.search('(\d+):(\d+)', string[1])
2944
h = "%s" % t.group(1)
2946
if int (t.group(2)) < 10:
2947
m = "0%s" % t.group(2)
2949
m = "%s" % t.group(2)
2958
weekdays = string[4][0]
2959
months = string[4][1]
2961
if weekdays[t_weekday] == True and months[t_month - 1] == True:
2965
if x[0] == t_month and x[1] == t_day:
2969
if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
2970
TimeData = "%s:%s" % (h, m)
2975
# Playing with 12-hour clock...
2989
TimeData = "%i:%s %s" % (Hour, m, Addition)
2994
if Good and string[2] == 1:
2995
ttime = _("%s - Today") % TimeData
2998
ttime = _("%s- Cancelled") % TimeData
2577
self.time = "%s:%s" % (self.h, self.m)
2591
if self.string[2] == 1:
2592
self.AlarmType = _("Scheduled")
2593
self.datetime = "%s" % self.time
3006
AlarmType = _("Scheduled")
3007
ddatetime = "%s" % ttime
2594
3008
icon = MainWindow.render_icon('gtk-refresh', gtk.ICON_SIZE_SMALL_TOOLBAR)
2596
self.AlarmType = _("Single")
2597
self.date_data = re.search('(\d+)/(\d+)/(\d+)', self.string[3])
3010
AlarmType = _("Single")
3011
self.date_data = re.search('(\d+)/(\d+)/(\d+)', string[3])
2598
3012
icon = MainWindow.render_icon('gtk-jump-to', gtk.ICON_SIZE_SMALL_TOOLBAR)
2601
3015
if int(self.date_data.group(3)) < 10:
2602
self.day = "0%s" % self.date_data.group(3)
3016
day = "0%s" % self.date_data.group(3)
2604
self.day = self.date_data.group(3)
3018
day = self.date_data.group(3)
2606
3020
if int (self.date_data.group(2)) < 9:
2608
self.month = "0%i" % (int(self.date_data.group(2)) + 1)
3022
month = "0%i" % (int(self.date_data.group(2)) + 1)
2610
self.month = "%i" % (int(self.date_data.group(2)) + 1)
2611
self.datetime = "%s %s/%s/%s" % (self.time, self.day, self.month, self.date_data.group(1))
2613
self.alarm_model.append([self.AlarmType, icon, self.datetime, self.string[0]])
3024
month = "%i" % (int(self.date_data.group(2)) + 1)
3027
LocaleDate = time.strftime("%x", (int(self.date_data.group(1)), int(month), int(day), 0, 0, 0, 0, 0, 0))
3029
ddatetime = "%s %s" % (ttime, LocaleDate)
3032
model.append([AlarmType, icon, ddatetime, string[0]])
2749
3168
self.LoadCurrentAlarm()
2750
3169
self.RunAlarm(self.AlarmBuffer)
2752
def RunAlarm(self,Al):
3171
def RunAlarm(self,Al, Count = False, Remover = False, Loader = False, Prefs = False, UpdateList = None):
3172
StatusIcon.set_blinking(True)
2758
3178
self.sndfile = Al[9]
2760
3180
self.sndfile = "%s/sound/ring.wav" % PREFIX
2763
PlayerInstance.set_property('uri', "file://" + self.sndfile)
2764
MainWindowGlade.get_widget('stop_sound').set_sensitive(True)
2771
self.thread = RepeatSoundThread.RepeatSound(Times, MainWindowGlade.get_widget('stop_sound'), Al[11], PlayerInstance)
3192
if not PlayerInstance.get_state()[1] == gst.STATE_NULL:
3193
self.Info = _("Cannot play sound, because other alarm is playing!")
3194
self.msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,
3195
gtk.BUTTONS_CLOSE, _("Error"))
3196
self.msgDialog.format_secondary_text(self.Info)
3197
self.msgDialog.run()
3198
self.msgDialog.destroy()
3202
self.WhatPlaying = "R"
3203
PlayerInstance.set_property('uri', "file://" + self.sndfile)
3204
MainWindowGlade.get_widget('stop_sound').set_sensitive(True)
3205
thread = RepeatSoundThread.RepeatSound(Times, MainWindowGlade.get_widget('stop_sound'), Al[11], PlayerInstance, self, self.sndfile)
2777
3211
RepeatAfter = Al[40]
2779
3213
RepeatAfter = 0
2780
FadingVolumeThread = VolumeFadeThread.VolumeFade(Al[12], Al[13], Al[14], MainWindowGlade.get_widget('stop_sound'), RepeatAfter, PlayerInstance)
2781
FadingVolumeThread.start()
2784
# 7 - Boolean - whatever to play sound
2785
# 8 - Boolean - Use custom sound file
2786
# 9 - String - path to sound file
2787
# 10 - Boolean - Constant (True) or Fade (False)
2788
# 11 - Integer - Constant volume value
2789
# 12 - Integer - Fade (Initial volume)
2790
# 13 - Integer - Fade (Final volume)
2791
# 14 - Integer - Fade (Duration in seconds)
3218
if not PlayerInstance.get_state()[1] == gst.STATE_NULL:
3219
self.Info = _("Cannot play sound, because other alarm is playing!")
3220
self.msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,
3221
gtk.BUTTONS_CLOSE, _("Error"))
3222
self.msgDialog.format_secondary_text(self.Info)
3223
self.msgDialog.run()
3224
self.msgDialog.destroy()
3228
self.WhatPlaying = "F"
3229
PlayerInstance.set_property('uri', "file://" + self.sndfile)
3230
MainWindowGlade.get_widget('stop_sound').set_sensitive(True)
3231
FadingVolumeThread = VolumeFadeThread.VolumeFade(Al[12], Al[13], Al[14], MainWindowGlade.get_widget('stop_sound'), RepeatAfter, PlayerInstance, self)
3232
FadingVolumeThread.start()
2804
3235
# PASSIVE WINDOW START
2807
self.n = pynotify.Notification (Al[37], Al[18])
3238
self.n = pynotify.Notification (Al[37], Al[18], "dialog-warning")
2808
3239
if Al[16] == 0:
2809
3240
self.n.set_urgency(pynotify.URGENCY_LOW)
2810
3241
if Al[16] == 1:
2828
3265
# DIALOG WINDOW START
3271
try: UpdateList(False)
2834
self.dlg_G = gtk.glade.XML(Al[21], 'alarm_dialog')
2835
self.dl = self.dlg_G.get_widget('alarm_dialog')
2836
self.dl.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
2837
self.dl.set_title(Al[38])
2838
self.dlg_G.get_widget('alarm_label').set_text(Al[25])
3276
dlg_G = gtk.glade.XML(Al[21], 'alarm_dialog')
3277
dl = dlg_G.get_widget('alarm_dialog')
3278
dl.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
3279
dl.set_title(Al[38])
3280
dlg_G.get_widget('alarm_label').set_text(Al[25])
2842
self.msg = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "")
2843
self.msg.set_markup(_("The GLADE file <b>%s</b> is incorrect. It should contain a dialog called \"alarm_dialog\" and a label called \"alarm_label\".") % Al[21])
3284
msg = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "")
3285
msg.set_markup(_("The GLADE file <b>%s</b> is incorrect. It should contain a dialog called \"alarm_dialog\" and a label called \"alarm_label\".") % Al[21])
2851
self.dl_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'alarm_dialog')
2853
self.dc = { "close_dialog" : self.CloseDialogPopup,
2854
"snooze_clicked" : self.SnoozeClicked, }
2856
self.dl_Glade.signal_autoconnect(self.dc)
2858
self.dl = self.dl_Glade.get_widget('alarm_dialog')
2859
self.dl.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
2860
self.text = self.dl_Glade.get_widget('text_label')
2861
self.color = gtk.gdk.Color()
2863
self.alarm_event = self.dl_Glade.get_widget('alarm_event')
2864
self.colors = re.search("(\d+),(\d+),(\d+)", Al[23])
2865
self.color.red = int (self.colors.group(1))
2866
self.color.green = int (self.colors.group(2))
2867
self.color.blue = int (self.colors.group(3))
2868
self.alarm_event.modify_bg(gtk.STATE_NORMAL, self.color)
2870
self.colors = re.search("(\d+),(\d+),(\d+)", Al[22])
2871
self.color.red = int (self.colors.group(1))
2872
self.color.green = int (self.colors.group(2))
2873
self.color.blue = int (self.colors.group(3))
3293
dl_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'alarm_dialog')
3294
snoozebutton = dl_Glade.get_widget('snooze_button')
3297
self.SnoozeClicked(Al, Count, Remover, Loader, Prefs, UpdateList)
3316
Remover(Count, True)
3321
dc = { "snooze_clicked" : Snooze,
3322
"edit_clicked" : Edit,
3323
"stop_clicked" : Stop }
3325
dl_Glade.signal_autoconnect(dc)
3327
dl = dl_Glade.get_widget('alarm_dialog')
3328
dl.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
3329
text = dl_Glade.get_widget('text_label')
3330
color = gtk.gdk.Color()
3332
alarm_event = dl_Glade.get_widget('alarm_event')
3333
colors = re.search("(\d+),(\d+),(\d+)", Al[23])
3334
color.red = int (colors.group(1))
3335
color.green = int (colors.group(2))
3336
color.blue = int (colors.group(3))
3337
alarm_event.modify_bg(gtk.STATE_NORMAL, color)
3339
colors = re.search("(\d+),(\d+),(\d+)", Al[22])
3340
color.red = int (colors.group(1))
3341
color.green = int (colors.group(2))
3342
color.blue = int (colors.group(3))
2877
3346
if Al[24] >= 1:
2878
self.val = Al[24] - 1
2879
self.tin = "<big>" * self.val
2880
self.tout = "</big>" * self.val
3349
tout = "</big>" * val
2883
self.tin = "<small>"
2884
self.tout = "</small>"
2886
self.text_to_enter = "<span foreground='%s'>%s%s%s</span>" % (self.color.to_string(), self.tin, Al[25], self.tout)
2888
self.text.set_markup(self.text_to_enter)
2889
self.dl.set_title(Al[38])
3355
text_to_enter = "<span foreground='%s'>%s%s%s</span>" % (color.to_string(), tin, Al[25], tout)
3357
text.set_markup(text_to_enter)
3358
dl.set_title(Al[38])
2891
3360
if Al[39] == 0:
2892
self.dl_Glade.get_widget('snooze_button').hide()
3361
dl_Glade.get_widget('snooze_button').hide()
3363
snoozebutton.grab_default()
3366
dl.set_keep_above(True)
2897
3367
if Al[26] == True:
2898
self.dl.fullscreen()
3370
dl.set_focus_on_map(True)
3371
dl.set_urgency_hint(True)
2900
3375
print _("Error: cannot create dialog window.")
3378
try: UpdateList(True)
2904
3381
# COMMAND START