~ubuntu-branches/ubuntu/oneiric/alarm-clock/oneiric

« back to all changes in this revision

Viewing changes to alarm-clock/MainClass.py

  • Committer: Bazaar Package Importer
  • Author(s): Marco Rodrigues
  • Date: 2008-10-28 19:57:12 UTC
  • mto: (7.1.1 sid) (9.1.1 squeeze) (1.2.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20081028195712-e8kusg37fc1hnw0s
Tags: upstream-0.9.17
ImportĀ upstreamĀ versionĀ 0.9.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
14
14
 
15
15
# Copyright 2007-2008 Tomasz Salacinski <tsalacinski@gmail.com>
16
 
 
 
16
try:
 
17
        from gettext import gettext as _
 
18
except:
 
19
        print "Error loading gettext!"
 
20
        exit(1)
17
21
 
18
22
try:
19
23
        import gtk
21
25
        import gtk.glade
22
26
        import gobject
23
27
except:
24
 
        print _("Error loading GTK+ libraries. Check if they are properly")
25
 
        print _("installed on your system.")
 
28
        print _("Error loading GTK+ libraries. Check if they are properly installed")
 
29
        print _("on your system.")
26
30
        exit(1)
27
31
 
28
32
import Version
44
48
import os.path
45
49
import gettext
46
50
import locale
47
 
from gettext import gettext as _
48
51
import sys
49
52
import platform
50
53
 
 
54
try:
 
55
        import pynotify
 
56
except:
 
57
        Error (_("Error loading pynotify module!"))
 
58
 
 
59
try:
 
60
        from threading import Thread
 
61
except:
 
62
        Error (_("Cannot initialize threading library!"))
 
63
 
 
64
 
 
65
try:
 
66
        import gst
 
67
except:
 
68
        Error (_("Error loading GStreamer module!"))
 
69
 
 
70
import Prefix
51
71
import CheckAlarmThread
52
72
import SnoozeThread
53
73
import VolumeFadeThread
55
75
import RepeatSoundThread
56
76
 
57
77
 
58
 
 
59
 
try:
60
 
        import pynotify
61
 
except:
62
 
        Error (_("Error loading pynotify module!"))
63
 
 
64
 
try:
65
 
        from threading import Thread
66
 
except:
67
 
        Error (_("Cannot initialize threading library!"))
68
 
 
69
 
 
70
 
import gst
71
 
 
72
 
import Prefix
73
 
 
74
78
PREFIX = Prefix.GetPrefix() + '/share/alarm-clock'
75
79
 
76
80
LangPrefix = Prefix.GetPrefix() + '/share/locale/'
129
133
 
130
134
 
131
135
class StartGUI:
 
136
        def __init__(self):
 
137
                self.UpdateList = True
 
138
                try:
 
139
                        FileTerminal = file(os.getenv("HOME") + "/.config/alarm-clock/terminal" )
 
140
                        self.TerminalCommand = FileTerminal.readline()
 
141
                        FileTerminal.close()
 
142
                except:
 
143
                        self.TerminalCommand = 'gnome-terminal'
 
144
                
132
145
        def Initialize(self, Min = False):
133
146
                StartGUI().RunMe(Min)
 
147
                if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/old-alarms"):
 
148
                        msgDialog = gtk.MessageDialog(None,\
 
149
                        gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING,\
 
150
                        gtk.BUTTONS_CLOSE, _("You have old alarms"))
 
151
                        msgDialog.format_secondary_text(_("It seems you missed some alarms, because your old alarm list is not empty."))
 
152
                        msgDialog.run()
 
153
                        msgDialog.destroy()
 
154
 
134
155
                gtk.gdk.threads_init()
135
156
                gtk.gdk.threads_enter()
136
157
                try:
151
172
                        except:
152
173
                                self.IsMinimized = "0"
153
174
 
 
175
 
154
176
                if Min == True:
155
177
                        self.IsMinimized = 1
156
178
                        self.main_hidden = True
162
184
                MainWindow.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
163
185
                self.row = 0
164
186
                self.LoadConfigFiles()
165
 
                MainWindow.resize(self.configlist[1][0], self.configlist[1][1])
166
 
                MainWindow.move(self.configlist[0][0], self.configlist[0][1])
 
187
                try:
 
188
                        MainWindow.resize(self.configlist[1][0], self.configlist[1][1])
 
189
                        MainWindow.move(self.configlist[0][0], self.configlist[0][1])
 
190
                except:
 
191
                        pass
 
192
 
167
193
                if self.IsMinimized == "0":
168
194
                        MainWindow.show()
169
195
 
176
202
                self.Toolbar.unset_style()
177
203
 
178
204
                self.ConnectSignals()
179
 
 
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)
184
210
 
185
 
                AlarmThread.start()
 
211
                self.AlarmThread.start()
186
212
 
187
213
                pynotify.init("Alarm-Clock")
188
214
 
189
215
        def AddTree(self):
190
 
                
191
 
 
192
216
                self.alarm_model = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
193
217
 
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()
198
 
 
199
 
                self.MainTreeView.set_enable_search(True)
200
 
                self.MainTreeView.set_search_column(2)
201
 
 
202
 
 
203
 
 
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)
208
 
 
209
 
 
210
 
 
211
 
 
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)
 
221
                MainTreeView.show()
 
222
 
 
223
                MainTreeView.set_enable_search(True)
 
224
                MainTreeView.set_search_column(2)
 
225
 
 
226
 
 
227
 
 
228
                summary_renderer = gtk.CellRendererText()
 
229
                summary_renderer.set_property('editable', True)
 
230
                self.summary_column = gtk.TreeViewColumn(_("Name"), summary_renderer, text=3)
 
231
 
 
232
 
 
233
 
 
234
 
 
235
                type_renderer = gtk.CellRendererPixbuf()
 
236
                type_renderer_text = gtk.CellRendererText()
214
237
 
215
238
                self.type_column = gtk.TreeViewColumn(_("Type"))
216
239
 
217
 
                self.type_column.pack_start(self.type_renderer, expand=False)
218
 
                self.type_column.add_attribute(self.type_renderer, 'pixbuf', 1)
219
 
 
220
 
                self.type_column.pack_start(self.type_renderer_text, expand=True)
221
 
                self.type_column.add_attribute(self.type_renderer_text, 'text', 0)
222
 
 
223
 
 
224
 
 
225
 
                self.type_column.set_min_width(140)
226
 
 
227
 
 
228
 
 
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)
232
 
 
233
 
 
234
 
 
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)
 
242
 
 
243
                self.type_column.pack_start(type_renderer_text, expand=True)
 
244
                self.type_column.add_attribute(type_renderer_text, 'text', 0)
 
245
 
 
246
 
 
247
 
 
248
 
 
249
 
 
250
                date_renderer = gtk.CellRendererText()
 
251
                self.date_column = gtk.TreeViewColumn(_("Date and Time"), date_renderer, text=2)
 
252
 
 
253
 
 
254
 
 
255
 
 
256
 
 
257
#               time_remaining_renderer = gtk.CellRendererText()
 
258
#               self.time_remaining_column = gtk.TreeViewColumn(_("Time remaining"), time_remaining_renderer, text=3)
 
259
 
 
260
 
 
261
                Sizes = None
 
262
                try:
 
263
                        SizesFile = file(os.getenv("HOME") + "/.config/alarm-clock/columns", "r")
 
264
                        Sizes = eval(SizesFile.readlines()[0])
 
265
                        SizesFile.close()
 
266
                except:
 
267
                        Sizes = [150, 150, 100, 100]
 
268
                        self.summary_column.set_expand(True)
 
269
 
 
270
 
 
271
 
 
272
 
 
273
 
 
274
 
 
275
 
 
276
 
 
277
 
 
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)
 
283
 
 
284
 
 
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)
 
289
 
 
290
 
 
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)
 
295
 
 
296
 
 
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)
 
301
 
 
302
 
 
303
 
 
304
 
 
305
 
 
306
 
 
307
                self.MainTreeViewSelection = MainTreeView.get_selection()
239
308
                
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)
243
312
 
244
313
        def EditingCell(self, Widget, RowNumber, NewValue):
245
314
                AlarmsFile = file(os.getenv("HOME") + "/.config/alarm-clock/alarms", "r")
269
338
 
270
339
                        self.LoadConfigFiles()
271
340
 
272
 
                        #ASD1
273
 
 
274
341
                        self.MainTreeViewSelection.select_path(RowNumber)
275
342
 
276
343
                except Error:
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()
293
 
 
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)
298
 
 
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)
303
 
 
304
 
                        self.sep1 = gtk.SeparatorMenuItem()
305
 
                        self.sep2 = gtk.SeparatorMenuItem()
306
 
 
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)
311
 
 
312
 
                        self.alarm_properties = gtk.ImageMenuItem("gtk-properties", False)
313
 
 
314
 
 
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)
321
 
 
322
 
 
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)
327
 
 
328
 
                        self.pop.show_all()
329
 
                        self.pop.popup(None, None, None, button.button, button.time)
 
359
                        pop = gtk.Menu()
 
360
 
 
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)
 
365
 
 
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)
 
370
 
 
371
                        sep1 = gtk.SeparatorMenuItem()
 
372
                        sep2 = gtk.SeparatorMenuItem()
 
373
 
 
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)
 
378
 
 
379
                        alarm_properties = gtk.ImageMenuItem("gtk-properties", False)
 
380
 
 
381
 
 
382
                        pop.add(add_alarm)
 
383
                        pop.add(add_counter)
 
384
                        pop.add(sep1)
 
385
                        pop.add(remove_alarm)
 
386
                        pop.add(sep2)
 
387
                        pop.add(alarm_properties)
 
388
 
 
389
 
 
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)
 
394
 
 
395
                        pop.show_all()
 
396
                        pop.popup(None, None, None, button.button, button.time)
330
397
 
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)
338
405
 
 
406
        def ShowMissedAlarms(self, widget):
 
407
                AlarmModel = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING)
 
408
 
 
409
                try:
 
410
                        AlarmFile = file(os.getenv("HOME") + "/.config/alarm-clock/old-alarms", "r")
 
411
 
 
412
                        for line in AlarmFile:
 
413
                                self.i = self.i + 1
 
414
                                self.ParseTupletToList(line, AlarmModel)
 
415
                except:
 
416
                        pass
 
417
 
 
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')
 
421
 
 
422
                MissedWindow.set_transient_for(MainWindow)
 
423
 
 
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)
 
428
 
 
429
 
 
430
 
 
431
 
 
432
                self.type_renderer = gtk.CellRendererPixbuf()
 
433
                self.type_renderer_text = gtk.CellRendererText()
 
434
 
 
435
                self.type_column = gtk.TreeViewColumn(_("Type"))
 
436
 
 
437
                self.type_column.pack_start(self.type_renderer, expand=False)
 
438
                self.type_column.add_attribute(self.type_renderer, 'pixbuf', 1)
 
439
 
 
440
                self.type_column.pack_start(self.type_renderer_text, expand=True)
 
441
                self.type_column.add_attribute(self.type_renderer_text, 'text', 0)
 
442
 
 
443
 
 
444
 
 
445
                self.type_column.set_min_width(140)
 
446
 
 
447
 
 
448
 
 
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)
 
452
 
 
453
 
 
454
 
 
455
                MissedTree.append_column(self.summary_column)
 
456
                MissedTree.append_column(self.type_column)
 
457
                MissedTree.append_column(self.date_column)
 
458
 
 
459
 
 
460
 
 
461
 
 
462
 
 
463
 
 
464
 
 
465
 
 
466
 
 
467
 
 
468
 
 
469
 
 
470
 
 
471
 
 
472
 
 
473
 
 
474
                if len(AlarmModel) == 0:
 
475
                        MissedGlade.get_widget('clear_button').set_sensitive(False)
 
476
 
 
477
 
 
478
                MissedTree.set_model(AlarmModel)
 
479
 
 
480
                self.Model = AlarmModel
 
481
 
 
482
                MissedWindow.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
 
483
 
 
484
                Signals = { "clear_alarms" : self.ClearOld,
 
485
                                        "close_old" : self.CloseOld }
 
486
 
 
487
                MissedGlade.signal_autoconnect(Signals)
 
488
 
 
489
                MissedWindow.show()             
 
490
 
 
491
        def ClearOld(self, button):
 
492
                button.set_sensitive(False)
 
493
                self.Model.clear()
 
494
                try:
 
495
                        os.remove(os.getenv("HOME") + "/.config/alarm-clock/old-alarms")
 
496
                except:
 
497
                        pass
 
498
 
 
499
 
 
500
        def CloseOld(self, button):
 
501
                button.get_toplevel().destroy()
 
502
 
 
503
        def ReportBug(self, menu):
 
504
                os.system('xdg-open \"https://bugs.launchpad.net/alarmclock\"')
339
505
 
340
506
        def ConnectSignals(self):
341
507
                self.Signals =  { "show_about" : self.ShowAboutDialog,
352
518
                                  "birthdays_templates_manager_run" : self.BirthdaysnTemplates,
353
519
                                  "clicked_prefs" : self.PreferencesDialog,
354
520
                                  "show_completed_clicked" : self.ShowCompletedClicked,
 
521
                                  "show_missed_alarms" : self.ShowMissedAlarms,
 
522
                                  "start_feedback" : self.ReportBug
355
523
                                }
356
524
                
357
525
                MainWindowGlade.signal_autoconnect(self.Signals)
368
536
                self.Prefs_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'prefs_dialog')
369
537
                self.Prefs = self.Prefs_Glade.get_widget('prefs_dialog')
370
538
                self.Prefs.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
 
539
                self.Prefs.set_transient_for(MainWindow)
371
540
                try:
372
541
                        self.MinFil = file(os.getenv("HOME") + "/.config/alarm-clock/minimized", "r")
373
542
                except:
388
557
                if os.path.exists(os.getenv("HOME") + '/.config/autostart/alarm-clock.desktop'):
389
558
                        self.Prefs_Glade.get_widget('start_autologin').set_active(True)
390
559
 
 
560
                if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
 
561
                        self.Prefs_Glade.get_widget('12h_radio').set_active(True)
 
562
                        self.Prefs_Glade.get_widget('24h_radio').set_active(False)
 
563
                else:
 
564
                        self.Prefs_Glade.get_widget('12h_radio').set_active(False)
 
565
                        self.Prefs_Glade.get_widget('24h_radio').set_active(True)
 
566
 
 
567
 
 
568
 
 
569
                # Checking for terminal command
 
570
                
 
571
                self.Prefs_Glade.get_widget('terminal_command_entry').set_text(self.TerminalCommand)
391
572
 
392
573
                self.Prefs.run()
393
574
 
 
575
                self.TerminalCommand = self.Prefs_Glade.get_widget('terminal_command_entry').get_text()
 
576
 
394
577
                self.IsMinimizedStatusFile = file(os.getenv("HOME") + "/.config/alarm-clock/minimized", "w")
395
578
                if self.MinCheck.get_active():
396
579
                        print >> self.IsMinimizedStatusFile, "1"
417
600
                        except:
418
601
                                pass
419
602
 
 
603
                if self.Prefs_Glade.get_widget('12h_radio').get_active() == True:
 
604
                        a = file(os.getenv("HOME") + "/.config/alarm-clock/twelve", "w")
 
605
                        a.close()
 
606
                else:
 
607
                        try:
 
608
                                os.remove(os.getenv("HOME") + "/.config/alarm-clock/twelve")
 
609
                        except:
 
610
                                pass
 
611
 
 
612
                try:
 
613
                        CurrentRow = self.MainTreeViewSelection.get_selected_rows()[1][0][0]
 
614
                        self.LoadConfigFiles()
 
615
                        self.MainTreeViewSelection.select_path(CurrentRow)
 
616
                except:
 
617
                        pass
 
618
 
420
619
                self.Prefs.destroy()
421
620
 
422
621
        def BirthdaysnTemplates(self,obj):
554
753
                                self.om = "0" + str(self.om)
555
754
 
556
755
 
557
 
                        self.Store.append([self.d[1], ("%s/%s/%s") % (self.od, self.om, self.oy)])
 
756
 
 
757
 
 
758
                        self.Store.append([self.d[1],time.strftime("%x", (int(self.oy), int(self.om), int(self.od), 0, 0, 0, 0, 0, 0))])
558
759
                        self.count = self.count + 1
559
760
 
560
761
                if self.count == 0:
753
954
                # Saving changes!
754
955
 
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())
 
957
 
 
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()
 
962
                                if AMPM == 1:
 
963
                                        if Hour == 12:
 
964
                                                self.AlarmBuffer[1] = "%i:%i" % (12, Min)
 
965
                                        else:
 
966
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
 
967
                                if AMPM == 0:
 
968
                                        if Hour == 12:
 
969
                                                self.AlarmBuffer[1] = "%i:%i" % (0, Min)
 
970
                                        else:
 
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())
 
974
 
 
975
 
 
976
 
 
977
 
757
978
                        if self.SingleRadio.get_active():
758
979
                                self.AlarmBuffer[2] = 0
759
980
                        if self.ScheduleRadio.get_active():
855
1076
                # Saving changes!
856
1077
 
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())
 
1079
 
 
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()
 
1084
                                if AMPM == 1:
 
1085
                                        if Hour == 12:
 
1086
                                                self.AlarmBuffer[1] = "%i:%i" % (12, Min)
 
1087
                                        else:
 
1088
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
 
1089
                                if AMPM == 0:
 
1090
                                        if Hour == 12:
 
1091
                                                self.AlarmBuffer[1] = "%i:%i" % (0, Min)
 
1092
                                        else:
 
1093
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
 
1094
 
 
1095
 
 
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())
 
1098
 
 
1099
 
 
1100
 
 
1101
 
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,)
905
1148
 
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)
911
1155
 
912
1156
 
913
1157
        def StatusClicked(self,obj):
 
1158
                if StatusIcon.get_blinking() == True:
 
1159
                        StatusIcon.set_blinking(False)
 
1160
                        self.StopTheSound()
 
1161
                        return
 
1162
 
914
1163
                if self.main_hidden:
 
1164
 
915
1165
                        self.fc = file(os.getenv("HOME") + "/.config/alarm-clock/configuration", "r")
916
1166
                        self.Pos = self.fc.readline()
917
1167
                        self.fc.close()
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])
 
1168
                        try:
 
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])
 
1172
                        except:
 
1173
                                pass
921
1174
                        MainWindow.present()
922
1175
                        self.main_hidden = False
923
1176
                else:
928
1181
                        self.main_hidden = True
929
1182
 
930
1183
        def StatusPopup(self,obj,v1,v2):
931
 
                self.pop = gtk.Menu()
932
 
 
933
 
                self.show_win = gtk.CheckMenuItem(_("Show main window on screen"), True)
934
 
                self.show_win.set_active(self.main_hidden == False)
935
 
 
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)
940
 
 
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)
 
1184
                pop = gtk.Menu()
 
1185
 
 
1186
 
 
1187
                show_win = gtk.CheckMenuItem(_("Show main window on screen"), True)
 
1188
                show_win.set_active(self.main_hidden == False)
 
1189
 
 
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)
 
1194
 
 
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)
945
1199
 
946
1200
                
947
1201
 
948
 
                self.sep1 = gtk.SeparatorMenuItem()
949
 
                self.sep2 = gtk.SeparatorMenuItem()
950
 
                self.quit_a = gtk.ImageMenuItem("gtk-quit", False)
951
 
 
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)
958
 
 
959
 
 
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)
964
 
 
965
 
                self.pop.show_all()
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)
 
1205
 
 
1206
                pop.add(show_win)
 
1207
                pop.add(sep1)
 
1208
                pop.add(add_alarm)
 
1209
                pop.add(add_counter)
 
1210
                pop.add(sep2)
 
1211
                pop.add(quit_a)
 
1212
 
 
1213
 
 
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)
 
1218
 
 
1219
                pop.show_all()
 
1220
                pop.popup(None, None, gtk.status_icon_position_menu, v1, v2, StatusIcon)
967
1221
 
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"
974
1228
                "\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)
984
1238
 
985
 
                self.License = """
 
1239
                License = """
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
997
1251
along with Alarm Clock; if not, write to the Free Software Foundation,
998
1252
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA"""
999
1253
 
1000
 
                self.AboutDialog.set_license(self.License)
1001
 
 
1002
 
                self.Artists = ["""Alarm Clock icon come from the 
1003
 
Dropline Neu! icon theme"""]
1004
 
 
1005
 
                self.AboutDialog.set_artists(self.Artists)
1006
 
 
1007
 
 
1008
 
                self.AboutDialog.run()
1009
 
                self.AboutDialog.destroy()
 
1254
                AboutDialog.set_license(License)
 
1255
 
 
1256
                Artists = ["""Icons\n(c) Tango Desktop Project\nBased under Creative Commons Attribution Share-Alike license"""]
 
1257
 
 
1258
                AboutDialog.set_artists(Artists)
 
1259
 
 
1260
 
 
1261
                AboutDialog.run()
 
1262
                AboutDialog.destroy()
1010
1263
 
1011
1264
        def HideMainWindow(self,obj,v1):
1012
1265
                self.fc = file(os.getenv("HOME") + "/.config/alarm-clock/configuration", "w")
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")
 
1276
 
 
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()]
 
1279
 
 
1280
                print >> self.SizesFile, [self.summary_column.get_width(), self.type_column.get_width(),
 
1281
                                          self.date_column.get_width(), 0]
 
1282
 
 
1283
                self.SizesFile.close()
 
1284
                try:
 
1285
                        os.remove(os.getenv("HOME") + "/.config/alarm-clock/lock")
 
1286
                except:
 
1287
                        pass
 
1288
 
1022
1289
                self.fc.close()
 
1290
                
 
1291
                TerminalFile = file(os.getenv("HOME") + "/.config/alarm-clock/terminal", "w")
 
1292
                TerminalFile.write(self.TerminalCommand)
 
1293
                TerminalFile.close()
 
1294
                
 
1295
                
 
1296
                
1023
1297
                PlayerInstance.set_state(gst.STATE_NULL)
1024
1298
                gtk.gdk.threads_leave()
1025
1299
                gtk.main_quit()
1026
1300
 
1027
 
        def ChangeAlarmPrefs(self,obj):
 
1301
        def ChangeAlarmPrefs(self,obj, HaveNumber = None):
1028
1302
                self.LoadCurrentAlarm()
1029
1303
                self.value = self.AlarmPrefs().run()
1030
1304
 
1032
1306
                # Saving changes!
1033
1307
 
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())
 
1309
 
 
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()
 
1314
                                if AMPM == 1:
 
1315
                                        if Hour == 12:
 
1316
                                                self.AlarmBuffer[1] = "%i:%i" % (12, Min)
 
1317
                                        else:
 
1318
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
 
1319
                                if AMPM == 0:
 
1320
                                        if Hour == 12:
 
1321
                                                self.AlarmBuffer[1] = "%i:%i" % (0, Min)
 
1322
                                        else:
 
1323
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour, Min)
 
1324
 
 
1325
 
 
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())
 
1328
 
 
1329
 
 
1330
 
1036
1331
                        if self.SingleRadio.get_active():
1037
1332
                                self.AlarmBuffer[2] = 0
1038
1333
                        if self.ScheduleRadio.get_active():
1082
1377
                        self.fbuf.close()
1083
1378
                        self.f = file(os.getenv("HOME") + "/.config/alarm-clock/alarms", "w")
1084
1379
                        self.counter = 0
 
1380
                        if HaveNumber == None:
 
1381
                                Selection = self.MainTreeViewSelection.get_selected_rows()[1][0][0]
 
1382
                        else:
 
1383
                                Selection = HaveNumber
1085
1384
                        for line in self.lines:
1086
 
                                if self.counter == self.MainTreeViewSelection.get_selected_rows()[1][0][0]:
 
1385
                                if self.counter == Selection:
1087
1386
                                        print >> self.f, self.AlarmBuffer
1088
1387
                                        self.counter = self.counter + 1
1089
1388
                                        continue
1096
1395
                        self.LoadConfigFiles()
1097
1396
 
1098
1397
                self.AlarmPropsWidget.destroy()
 
1398
                self.UpdateList = True
 
1399
                return
1099
1400
 
1100
1401
 
1101
1402
        def LoadCurrentAlarm(self):
1116
1417
                self.AddDialogWidget = self.AddDialog.get_widget('add_alarm_dialog')
1117
1418
                self.AddDialogWidget.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
1118
1419
 
 
1420
                self.AddDialogWidget.set_transient_for(MainWindow)
 
1421
 
1119
1422
                self.AddAlarmSignals = { "new_alarm_radio_toggled" : self.NewAlarmRadioCheck, }
1120
1423
                self.AddDialog.signal_autoconnect(self.AddAlarmSignals)
1121
1424
 
1130
1433
                self.hbox.attach(self.AddAlarmTemplateCombo, 1, 2, 2, 3)
1131
1434
                self.AddAlarmTemplateCombo.show()
1132
1435
 
1133
 
 
1134
 
 
1135
 
 
1136
1436
                self.tmp_list = file(os.getenv("HOME") + "/.config/alarm-clock/templates", "r")
1137
1437
 
1138
1438
                self.count = 0
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()])
1165
 
                                
1166
 
                                self.value = self.AlarmPrefs().run()
1167
 
                                if self.value == gtk.RESPONSE_OK:
1168
 
                                        # Saving changes!
1169
 
 
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
1177
 
 
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)
1182
 
 
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)
1188
 
 
1189
 
                                        if self.SoundCheck.get_active():
1190
 
                                                self.AlarmBuffer[7] = True
1191
 
                                        else:
1192
 
                                                self.AlarmBuffer[7] = False
1193
 
                                        if self.PassiveCheck.get_active():
1194
 
                                                self.AlarmBuffer[15] = True
1195
 
                                        else:
1196
 
                                                self.AlarmBuffer[15] = False
1197
 
                                        if self.DialogCheck.get_active():
1198
 
                                                self.AlarmBuffer[19] = True
1199
 
                                        else:
1200
 
                                                self.AlarmBuffer[19] = False
1201
 
                                        if self.CmdCheck.get_active():
1202
 
                                                self.AlarmBuffer[27] = True
1203
 
                                        else:
1204
 
                                                self.AlarmBuffer[27] = False
1205
 
                                        if self.StdCheck.get_active():
1206
 
                                                self.AlarmBuffer[32] = True
1207
 
                                        else:
1208
 
                                                self.AlarmBuffer[32] = False
1209
 
 
1210
 
 
1211
 
                                        print >> self.f, self.AlarmBuffer
1212
 
                                        self.f.close()
1213
 
 
1214
 
 
1215
 
 
1216
 
 
1217
 
                                self.LoadConfigFiles()
1218
 
 
1219
 
                                self.MainTreeViewSelection.select_path(self.row)
1220
 
                                self.AlarmPropsWidget.destroy()
1221
 
 
1222
 
 
1223
 
 
 
1465
 
 
1466
                                self.AlarmPrefs().connect("response", self.ResponseDialog)
1224
1467
 
1225
1468
                        if self.AddAlarmNew.get_active():
1226
1469
                                self.AddDialogWidget.destroy()
1227
1470
                                self.ClearAlarmValues()
1228
 
 
1229
1471
                                self.AlarmPrefs().connect("response", self.ResponseDialog)
1230
1472
                                
1231
1473
                        if self.AddCounter.get_active():
1232
1474
                                self.AddDialogWidget.destroy()
1233
1475
                                self.AddSimpleCounterDialog()
1234
1476
 
1235
 
 
1236
 
 
1237
 
 
1238
 
 
1239
1477
                else:
1240
1478
                        self.AddDialogWidget.destroy()
1241
1479
 
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())
 
1488
        
 
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()
 
1493
                                if AMPM == 1:
 
1494
                                        if Hour == 12:
 
1495
                                                self.AlarmBuffer[1] = "%i:%i" % (12, Min)
 
1496
                                        else:
 
1497
                                                self.AlarmBuffer[1] = "%i:%i" % (Hour + 12, Min)
 
1498
                                if AMPM == 0:
 
1499
                                        if Hour == 12:
 
1500
                                                self.AlarmBuffer[1] = "%i:%i" % (0, Min)
 
1501
                                        else:
 
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())
 
1505
 
 
1506
 
 
1507
 
 
1508
 
1251
1509
                        if self.SingleRadio.get_active():
1252
1510
                                self.AlarmBuffer[2] = 0
1253
1511
                        if self.ScheduleRadio.get_active():
1317
1575
 
1318
1576
 
1319
1577
 
1320
 
 
1321
 
 
1322
1578
                        print >> self.f, self.AlarmBuffer
1323
1579
                        self.f.close()
1324
1580
 
1437
1693
                self.sp = self.sp_Glade.get_widget('sound_properties')
1438
1694
                self.sp.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
1439
1695
                self.dic = { "check_sound_prefs_window" : self.CheckSoundPrefsWindow,
1440
 
                             "check_sound_prefs_sliders" : self.CheckSoundPrefsSliders, }
 
1696
                             "check_sound_prefs_sliders" : self.CheckSoundPrefsSliders,
 
1697
                                 "check_spins" : self.CheckSpinButtons }
1441
1698
                self.sp_Glade.signal_autoconnect(self.dic)
1442
1699
 
1443
1700
 
1478
1735
                        self.buf = self.sp_Glade.get_widget('constant_volume_radio').set_active(False)
1479
1736
                        self.buf = self.sp_Glade.get_widget('fade_volume_radio').set_active(True)
1480
1737
 
1481
 
                self.sp_Glade.get_widget('constant_volume_scale').set_value(self.AlarmBuffer[11])
1482
 
                self.sp_Glade.get_widget('vol_init_scale').set_value(self.AlarmBuffer[12])
1483
 
                self.sp_Glade.get_widget('vol_final_scale').set_value(self.AlarmBuffer[13])
1484
 
                self.sp_Glade.get_widget('vol_duration_scale').set_value(self.AlarmBuffer[14])
1485
 
                self.sp_Glade.get_widget('after_fade_scale').set_value(self.AlarmBuffer[40])
 
1738
                self.sp_Glade.get_widget('constant_volume_spin').set_value(self.AlarmBuffer[11])
 
1739
                self.sp_Glade.get_widget('repeat_value_spin').set_value(self.AlarmBuffer[41])
 
1740
 
 
1741
                self.sp_Glade.get_widget('initial_volume_spin').set_value(self.AlarmBuffer[12])
 
1742
                self.sp_Glade.get_widget('final_volume_spin').set_value(self.AlarmBuffer[13])
 
1743
                self.sp_Glade.get_widget('duration_sec_spin').set_value(self.AlarmBuffer[14])
 
1744
                self.sp_Glade.get_widget('duration_fade_spin').set_value(self.AlarmBuffer[40])
1486
1745
                self.sp_Glade.get_widget('repeat_volume_scale').set_value(self.AlarmBuffer[41])
1487
1746
 
1488
1747
                self.CheckSoundPrefsWindow(self.sp)
1495
1754
 
1496
1755
                        self.AlarmBuffer[10] = self.sp_Glade.get_widget('constant_volume_radio').get_active()
1497
1756
 
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()
 
1757
 
 
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()
 
1763
 
 
1764
                        Times = self.sp_Glade.get_widget('repeat_value_spin').get_value()
 
1765
                        if Times == 0:
 
1766
                                self.AlarmBuffer[41] = -1
 
1767
                        else:
 
1768
                                self.AlarmBuffer[41] = Times
1504
1769
                        self.sp.destroy()
 
1770
 
 
1771
 
 
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
 
1782
 
 
1783
 
 
1784
 
1505
1785
                        return
1506
1786
 
1507
1787
 
1508
1788
                self.sp.destroy()
1509
1789
 
 
1790
 
 
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())
 
1798
 
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)
1518
1807
 
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)
1522
1811
 
1523
1812
                self.buf = self.sp_Glade.get_widget('fade_volume_radio').get_active()
1524
1813
 
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)
1537
1826
 
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())
1540
 
 
1541
 
                self.sp_Glade.get_widget('repeat_volume_secs').set_text("%i" % self.sp_Glade.get_widget('repeat_volume_scale').get_value())
1542
 
 
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"))
1545
 
 
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()) 
 
1828
 
 
1829
                self.sp_Glade.get_widget('constant_volume_spin').set_value(self.sp_Glade.get_widget('constant_volume_scale').get_value())
 
1830
 
 
1831
                self.sp_Glade.get_widget('repeat_value_spin').set_value(self.sp_Glade.get_widget('repeat_volume_scale').get_value())
 
1832
 
 
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())      
1550
1837
 
1551
1838
        def PassivePrefsActive(self,obj):
1552
1839
                self.pw_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'passive_window_properties')
1652
1939
 
1653
1940
                self.dw_Glade.get_widget('summary_textview').set_buffer(self.tb)
1654
1941
 
1655
 
                self.dw_Glade.get_widget('window_title_entry').set_text(self.AlarmBuffer[38])
 
1942
                self.dw_Glade.get_widget('window_title_entry1').set_text(self.AlarmBuffer[38])
1656
1943
 
1657
1944
                self.dw_Glade.get_widget('fs_check').set_active(self.AlarmBuffer[26])
1658
1945
 
1693
1980
 
1694
1981
                        self.AlarmBuffer[24] = self.dw_Glade.get_widget('text_size_combo').get_active()
1695
1982
 
1696
 
                        self.AlarmBuffer[38] = self.dw_Glade.get_widget('window_title_entry').get_text()
 
1983
                        self.AlarmBuffer[38] = self.dw_Glade.get_widget('window_title_entry1').get_text()
1697
1984
 
1698
1985
                        self.AlarmBuffer[25] = self.tb.get_text(self.tb.get_start_iter(), self.tb.get_end_iter())
1699
1986
 
1708
1995
                        if self.dw_Glade.get_widget('passive_check').get_active():
1709
1996
                                self.AlarmBuffer[18] = self.tb.get_text(self.tb.get_start_iter(), self.tb.get_end_iter())
1710
1997
                                self.AlarmBuffer[37] = self.dw_Glade.get_widget\
1711
 
                                ('window_title_entry').get_text()
1712
 
 
1713
 
 
1714
 
 
1715
 
                        self.dw.destroy()
1716
 
                        return
1717
 
 
 
1998
                                ('window_title_entry1').get_text()
1718
1999
 
1719
2000
                self.dw.destroy()
 
2001
                return
 
2002
 
 
2003
 
1720
2004
 
1721
2005
        def DialogPrefsSnooze(self,obj):
1722
2006
                if obj.get_active():
2151
2435
 
2152
2436
                self.AlarmBuffer[4] = self.Final
2153
2437
 
 
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()]
 
2451
 
 
2452
                GotIt = False
 
2453
 
 
2454
                for Item in self.Tuplet2:
 
2455
                        if Item == True:
 
2456
                                GotIt = True
 
2457
 
 
2458
                return GotIt
 
2459
 
 
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()]
 
2468
 
 
2469
                GotIt = False
 
2470
 
 
2471
                for Item in self.Tuplet2:
 
2472
                        if Item == True:
 
2473
                                GotIt = True
 
2474
 
 
2475
                return GotIt
 
2476
 
 
2477
 
 
2478
 
 
2479
 
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')
2179
2505
 
2180
2506
                self.RefreshExceptionList()
2181
2507
 
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, }
2190
 
 
2191
 
                self.ScheduleProps.signal_autoconnect(self.SchedSignals)
2192
 
 
2193
 
 
2194
 
 
2195
 
 
2196
 
                self.result = self.SchedulePropsWidget.run()
2197
 
 
2198
 
                if self.result == gtk.RESPONSE_OK:
2199
 
                        self.AlarmBuffer[5] = self.Al
2200
 
                        self.SaveMonths()
2201
 
 
2202
 
 
2203
 
                self.SchedulePropsWidget.destroy()
2204
 
 
2205
 
 
 
2515
                                          "DeselectAllMonths" : self.DeselectAllMonhts, 
 
2516
                                          "SchedCancel" : self.SchedCancel,
 
2517
                                          "SchedOK" : self.SchedOK }
 
2518
 
 
2519
                self.ScheduleProps.signal_autoconnect(SchedSignals)
 
2520
 
 
2521
 
 
2522
 
 
2523
 
 
2524
                self.result = self.SchedulePropsWidget.show()
 
2525
 
 
2526
        def SchedCancel(self, obj):
 
2527
                self.SchedulePropsWidget.destroy()
 
2528
 
 
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."))
 
2536
                        Dialog.run()
 
2537
                        Dialog.destroy()
 
2538
                        return
 
2539
 
 
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."))
 
2546
                        Dialog.run()
 
2547
                        Dialog.destroy()
 
2548
                        return
 
2549
 
 
2550
                self.AlarmBuffer[5] = self.Al
 
2551
                self.SaveMonths()
 
2552
                self.SchedulePropsWidget.destroy()
2206
2553
 
2207
2554
        def SelectAllWeekdays(self, Button):
2208
2555
                for x in range(1,8):
2224
2571
                        self.Deselect = self.ScheduleProps.get_widget("m%i" % x)
2225
2572
                        self.Deselect.set_active(False)
2226
2573
 
 
2574
        def CheckTimeSpins(self, obj):
 
2575
                HourVal = int(self.AlarmHourSpin.get_value())
 
2576
                MinVal = int(self.AlarmMinuteSpin.get_value())
 
2577
 
 
2578
                if HourVal < 10:
 
2579
                        self.AlarmHourSpin.set_text("0" + str(HourVal))
 
2580
 
 
2581
                if MinVal < 10:
 
2582
                        self.AlarmMinuteSpin.set_text("0" + str(MinVal))
 
2583
                        
 
2584
 
2227
2585
        def AlarmPrefs(self):
2228
2586
                self.AlarmProps = gtk.glade.XML(PREFIX + '/glade/main.glade', 'alarm_props_dialog')
2229
2587
                self.AlarmPropsWidget = self.AlarmProps.get_widget('alarm_props_dialog')
2230
2588
                self.AlarmPropsWidget.set_icon_from_file(PREFIX + '/scalable/alarm-clock.svg')
 
2589
                self.AlarmHourSpin = self.AlarmProps.get_widget('alarm_props_hour_spin')
 
2590
                self.AlarmMinuteSpin = self.AlarmProps.get_widget('alarm_props_minute_spin')
 
2591
                self.AlarmPropsWidget.set_transient_for(MainWindow)
2231
2592
 
2232
2593
                self.AlarmPropsSignals = { "date_radio_changed" : self.DateRadioChanged, 
2233
2594
                                           "notify_check_toggled" : self.NotifyCheckToggled,
2238
2599
                                           "command_activate" : self.CommandPrefsActive,
2239
2600
                                           "std_action_active" : self.StdPrefsActive,
2240
2601
                                           "show_schedule_prefs" : self.SchedulePrefsActive,
 
2602
                                           "check_time" : self.CheckTimeSpins,
2241
2603
                                         }
2242
2604
                self.AlarmProps.signal_autoconnect(self.AlarmPropsSignals)
2243
2605
 
2265
2627
                self.SingleRadio.set_active(True)
2266
2628
                self.PrefsSchedule.set_sensitive(False)
2267
2629
 
 
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)
2268
2639
 
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))
 
2644
 
 
2645
                if os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
 
2646
                        if time_hour > 12:
 
2647
                                time_hour = time_hour - 12
 
2648
                                self.TimeCombo.set_active(1)
 
2649
                        else:
 
2650
                                self.TimeCombo.set_active(0)
 
2651
 
 
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])
2274
2655
 
2275
2656
                if self.AlarmBuffer[2] == 0:
2402
2783
                # 36 - Integer - Confirmation timeout in seconds
2403
2784
 
2404
2785
 
 
2786
 
 
2787
 
 
2788
                # Checking for the current time of day and week
 
2789
 
 
2790
                Month = datetime.datetime.now().month
 
2791
                Weekday =  datetime.datetime.now().weekday()
 
2792
 
 
2793
 
2405
2794
                self.AlarmBuffer = [_("Untitled"),
2406
2795
                                    "%s:%s" % (time.localtime().tm_hour, time.localtime().tm_min + 1),
2407
2796
                                    0,
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]],
2410
2800
                                    [],
2411
2801
                                    None,
2412
2802
                                    False,
2445
2835
                                        30,
2446
2836
                                        0]
2447
2837
 
 
2838
                self.AlarmBuffer[4][0][Weekday] = True
 
2839
                self.AlarmBuffer[4][1][Month - 1] = True
 
2840
 
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)))
2455
 
 
2456
 
 
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)))
 
2848
 
 
2849
 
 
2850
                if SingleDateWidget.run() == gtk.RESPONSE_CANCEL:
 
2851
                        SingleDateWidget.destroy()
2459
2852
                        return
2460
2853
 
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()
2463
2856
 
2464
2857
 
2465
2858
 
2466
2859
 
2467
2860
 
2468
2861
        def LoadConfigFiles(self):
2469
 
 
 
2862
                if self.UpdateList == False:
 
2863
                        return
 
2864
                        
2470
2865
                if os.path.isdir(os.getenv("HOME") + "/.config/alarm-clock/") == False:
2471
2866
                        os.mkdir (os.getenv("HOME") + "/.config/alarm-clock")
2472
2867
 
 
2868
 
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()]
2498
2894
                        self.ParseTupletToList(line)
2499
2895
                
2500
2896
 
2501
 
 
 
2897
                if os.path.isfile(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
 
2898
                        self.TimeFormat = 12;
 
2899
                else:
 
2900
                        self.TimeFormat = 24;
2502
2901
 
2503
2902
 
2504
2903
                if self.i == 0:
2527
2926
 
2528
2927
 
2529
2928
 
2530
 
        def ParseTupletToList(self,line):
2531
 
                self.string = eval(line)
2532
 
 
2533
 
                self.weekdays = self.string[4][0]
2534
 
                self.months = self.string[4][1]
2535
 
 
2536
 
                self.t_weekday = time.localtime().tm_wday
2537
 
                self.t_month = time.localtime().tm_mon
2538
 
                self.t_day = time.localtime().tm_mday
2539
 
 
2540
 
 
2541
 
                self.t = re.search('(\d+):(\d+)', self.string[1])
2542
 
 
2543
 
                self.h = "%s" % self.t.group(1)
2544
 
 
2545
 
                if int (self.t.group(2)) < 10:
2546
 
                        self.m = "0%s" % self.t.group(2)
2547
 
                else:
2548
 
                        self.m = "%s" % self.t.group(2)
2549
 
 
2550
 
                self.time = "BAD"
2551
 
 
2552
 
 
2553
 
 
2554
 
 
2555
 
                self.Good = False
2556
 
                self.Ex = False
2557
 
                self.weekdays = self.string[4][0]
2558
 
                self.months = self.string[4][1]
2559
 
 
2560
 
                if self.weekdays[self.t_weekday] == True and self.months[self.t_month - 1] == True:
2561
 
                        self.Good = True
2562
 
 
2563
 
                for t in self.string[5]:
2564
 
                        if t[0] == self.t_month and t[1] == self.t_day:         
2565
 
                                self.Good = False
2566
 
                                self.Ex = True
2567
 
 
2568
 
 
2569
 
 
2570
 
 
2571
 
                if self.Good == True and self.string[2] == 1:
2572
 
                        self.time = _("%s:%s - Today") % (self.h, self.m)
2573
 
                else:
2574
 
                        if self.Ex == True:
2575
 
                                self.time = _("%s:%s - Cancelled") % (self.h, self.m)
 
2929
        def ParseTupletToList(self,line, model = None):
 
2930
                if model == None:
 
2931
                        model = self.alarm_model
 
2932
                string = eval(line)
 
2933
 
 
2934
                weekdays = string[4][0]
 
2935
                months = string[4][1]
 
2936
 
 
2937
                t_weekday = time.localtime().tm_wday
 
2938
                t_month = time.localtime().tm_mon
 
2939
                t_day = time.localtime().tm_mday
 
2940
 
 
2941
 
 
2942
                t = re.search('(\d+):(\d+)', string[1])
 
2943
 
 
2944
                h = "%s" % t.group(1)
 
2945
 
 
2946
                if int (t.group(2)) < 10:
 
2947
                        m = "0%s" % t.group(2)
 
2948
                else:
 
2949
                        m = "%s" % t.group(2)
 
2950
 
 
2951
#               time = "BAD"
 
2952
 
 
2953
 
 
2954
 
 
2955
 
 
2956
                Good = False
 
2957
                Ex = False
 
2958
                weekdays = string[4][0]
 
2959
                months = string[4][1]
 
2960
 
 
2961
                if weekdays[t_weekday] == True and months[t_month - 1] == True:
 
2962
                        Good = True
 
2963
 
 
2964
                for x in string[5]:
 
2965
                        if x[0] == t_month and x[1] == t_day:           
 
2966
                                Good = False
 
2967
                                Ex = True
 
2968
 
 
2969
                if not os.path.exists(os.getenv("HOME") + "/.config/alarm-clock/twelve"):
 
2970
                        TimeData = "%s:%s" % (h, m)
 
2971
                else:
 
2972
                        Addition = ""
 
2973
                        Hour = None
 
2974
 
 
2975
                        # Playing with 12-hour clock...
 
2976
                        if int(h) > 12:
 
2977
                                Hour = int(h) - 12
 
2978
                                Addition = _("PM")
 
2979
                        if int(h) == 12:
 
2980
                                Hour = 12
 
2981
                                Addition = _("PM")
 
2982
                        if int(h) < 12:
 
2983
                                Hour = int(h)
 
2984
                                Addition = _("AM")
 
2985
                        if int(h) == 0:
 
2986
                                Hour = 12
 
2987
                                Addition = _("AM")
 
2988
 
 
2989
                        TimeData = "%i:%s %s" % (Hour, m, Addition)
 
2990
 
 
2991
 
 
2992
 
 
2993
                ttime = ""
 
2994
                if Good and string[2] == 1:
 
2995
                        ttime = _("%s - Today") % TimeData
 
2996
                else:
 
2997
                        if Ex == True:
 
2998
                                ttime = _("%s- Cancelled") % TimeData
2576
2999
                        else:
2577
 
                                self.time = "%s:%s" % (self.h, self.m)
2578
 
 
2579
 
 
2580
 
 
2581
 
 
2582
 
 
2583
 
 
2584
 
 
2585
 
 
2586
 
 
 
3000
                                ttime = TimeData
2587
3001
 
2588
3002
                icon = None
2589
3003
                        
2590
3004
 
2591
 
                if self.string[2] == 1:
2592
 
                        self.AlarmType = _("Scheduled")
2593
 
                        self.datetime = "%s" % self.time
 
3005
                if string[2] == 1:
 
3006
                        AlarmType = _("Scheduled")
 
3007
                        ddatetime = "%s" % ttime
2594
3008
                        icon = MainWindow.render_icon('gtk-refresh', gtk.ICON_SIZE_SMALL_TOOLBAR)
2595
3009
                else:
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)
2599
3013
 
2600
3014
 
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)
2603
3017
                        else:
2604
 
                                self.day = self.date_data.group(3)
 
3018
                                day = self.date_data.group(3)
2605
3019
 
2606
3020
                        if int (self.date_data.group(2)) < 9:
2607
3021
 
2608
 
                                self.month = "0%i" % (int(self.date_data.group(2)) + 1)
 
3022
                                month = "0%i" % (int(self.date_data.group(2)) + 1)
2609
3023
                        else:
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))                      
2612
 
 
2613
 
                self.alarm_model.append([self.AlarmType, icon, self.datetime, self.string[0]])
 
3024
                                month = "%i" % (int(self.date_data.group(2)) + 1)
 
3025
 
 
3026
 
 
3027
                        LocaleDate = time.strftime("%x", (int(self.date_data.group(1)), int(month), int(day), 0, 0, 0, 0, 0, 0))
 
3028
 
 
3029
                        ddatetime = "%s %s" % (ttime, LocaleDate) 
 
3030
                                
 
3031
 
 
3032
                model.append([AlarmType, icon, ddatetime, string[0]])
2614
3033
 
2615
3034
 
2616
3035
 
2749
3168
                self.LoadCurrentAlarm()
2750
3169
                self.RunAlarm(self.AlarmBuffer)
2751
3170
 
2752
 
        def RunAlarm(self,Al):
2753
 
 
 
3171
        def RunAlarm(self,Al, Count = False, Remover = False, Loader = False, Prefs = False, UpdateList = None):
 
3172
                StatusIcon.set_blinking(True)
2754
3173
                self.c = Al
2755
3174
 
2756
3175
                if Al[7]:
 
3176
                        
2757
3177
                        if Al[8]:
2758
3178
                                self.sndfile = Al[9]
2759
3179
                        else:
2760
3180
                                self.sndfile = "%s/sound/ring.wav" % PREFIX
2761
3181
 
2762
3182
                        
2763
 
                        PlayerInstance.set_property('uri', "file://" + self.sndfile)
2764
 
                        MainWindowGlade.get_widget('stop_sound').set_sensitive(True)
 
3183
 
2765
3184
                        if Al[10]:
2766
3185
                                try:
2767
3186
                                        Times = Al[41]
2768
3187
                                except:
2769
3188
                                        Times = 1
2770
3189
 
2771
 
                                self.thread = RepeatSoundThread.RepeatSound(Times, MainWindowGlade.get_widget('stop_sound'), Al[11], PlayerInstance)
2772
 
                                self.thread.start()
 
3190
                                PlaySound = True
 
3191
 
 
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()
 
3199
                                        PlaySound = False
 
3200
 
 
3201
                                if PlaySound:
 
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)
 
3206
                                        thread.start()
2773
3207
 
2774
3208
 
2775
3209
                        else:
2777
3211
                                        RepeatAfter = Al[40]
2778
3212
                                except:
2779
3213
                                        RepeatAfter = 0
2780
 
                                FadingVolumeThread = VolumeFadeThread.VolumeFade(Al[12], Al[13], Al[14], MainWindowGlade.get_widget('stop_sound'), RepeatAfter, PlayerInstance)
2781
 
                                FadingVolumeThread.start()
2782
 
 
2783
 
 
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)
2792
 
 
2793
 
 
2794
 
 
2795
 
 
2796
 
 
2797
 
 
2798
 
 
2799
 
 
2800
 
 
2801
 
 
 
3214
                                
 
3215
 
 
3216
                                PlaySound = True
 
3217
 
 
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()
 
3225
                                        PlaySound = False
 
3226
 
 
3227
                                if PlaySound:
 
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()
2802
3233
 
2803
3234
 
2804
3235
                # PASSIVE WINDOW START
2805
3236
 
2806
3237
                if Al[15]:
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:
2815
3246
                        self.timeout = self.timeout * 1000
2816
3247
                        self.n.set_timeout(self.timeout)
2817
3248
 
 
3249
                        self.n.add_action("clicked", "Stop", self.StopTheSound, None)
 
3250
 
2818
3251
                        # Workaround for notify-python 0.1.1 bug, passive window will show only
2819
3252
                        # when attach_to_status_icon function is available
2820
3253
                        # See bug #193166 in Launchpad
2824
3257
                        except:
2825
3258
                                pass
2826
3259
                        self.n.show()
 
3260
                        try:
 
3261
                                dl.grab_focus()
 
3262
                        except:
 
3263
                                pass
2827
3264
 
2828
3265
                # DIALOG WINDOW START
2829
3266
 
2830
3267
 
 
3268
 
 
3269
 
2831
3270
                if Al[19]:
 
3271
                        try: UpdateList(False)
 
3272
                        except: pass
 
3273
                        
2832
3274
                        if Al[20]:
2833
3275
                                try:
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])
2839
 
                                        self.dl.run()
2840
 
                                        self.dl.destroy()
 
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])
 
3281
                                        dl.run()
 
3282
                                        dl.destroy()
2841
3283
                                except:
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])
2844
 
                                        self.msg.run()
2845
 
                                        self.msg.destroy()
 
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])
 
3286
                                        msg.run()
 
3287
                                        msg.destroy()
2846
3288
 
2847
3289
 
2848
3290
                                
2849
3291
                                
2850
3292
                        else:
2851
 
                                self.dl_Glade = gtk.glade.XML(PREFIX + '/glade/main.glade', 'alarm_dialog')
2852
 
 
2853
 
                                self.dc = { "close_dialog" : self.CloseDialogPopup, 
2854
 
                                            "snooze_clicked" : self.SnoozeClicked, }
2855
 
 
2856
 
                                self.dl_Glade.signal_autoconnect(self.dc)
2857
 
 
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()
2862
 
 
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)
2869
 
 
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')
 
3295
 
 
3296
                                def Snooze(obj):
 
3297
                                        self.SnoozeClicked(Al, Count, Remover, Loader, Prefs, UpdateList)
 
3298
                                        dl.destroy()
 
3299
                                        self.StopTheSound()
 
3300
                                def Edit(obj):
 
3301
                                        dl.destroy()
 
3302
                                        self.StopTheSound()
 
3303
                                        if not Count: 
 
3304
                                                UpdateList(True)
 
3305
                                        Prefs(self)
 
3306
                                        Loader()
 
3307
                                        Protected = None
 
3308
                                        UpdateList(True)
 
3309
                                        return
 
3310
 
 
3311
                                def Stop(obj):
 
3312
                                        self.StopTheSound()
 
3313
                                        dl.destroy()
 
3314
                                        if not Count:
 
3315
                                                return
 
3316
                                        Remover(Count, True)
 
3317
                                        UpdateList(True)
 
3318
                                        Loader()
 
3319
                                        return
 
3320
 
 
3321
                                dc = { "snooze_clicked" : Snooze,
 
3322
                                       "edit_clicked" : Edit,
 
3323
                                       "stop_clicked" : Stop }
 
3324
 
 
3325
                                dl_Glade.signal_autoconnect(dc)
 
3326
 
 
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()
 
3331
 
 
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)
 
3338
 
 
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))
2874
3343
 
2875
3344
 
2876
3345
                                
2877
3346
                                if Al[24] >= 1:
2878
 
                                        self.val = Al[24] - 1
2879
 
                                        self.tin = "<big>" * self.val
2880
 
                                        self.tout = "</big>" * self.val
 
3347
                                        val = Al[24] - 1
 
3348
                                        tin = "<big>" * val
 
3349
                                        tout = "</big>" * val
2881
3350
 
2882
3351
                                if Al[24] < 1:
2883
 
                                        self.tin = "<small>"
2884
 
                                        self.tout = "</small>"
2885
 
 
2886
 
                                self.text_to_enter = "<span foreground='%s'>%s%s%s</span>" % (self.color.to_string(), self.tin, Al[25], self.tout)
2887
 
 
2888
 
                                self.text.set_markup(self.text_to_enter)
2889
 
                                self.dl.set_title(Al[38])
 
3352
                                        tin = "<small>"
 
3353
                                        tout = "</small>"
 
3354
 
 
3355
                                text_to_enter = "<span foreground='%s'>%s%s%s</span>" % (color.to_string(), tin, Al[25], tout)
 
3356
 
 
3357
                                text.set_markup(text_to_enter)
 
3358
                                dl.set_title(Al[38])
2890
3359
 
2891
3360
                                if Al[39] == 0:
2892
 
                                        self.dl_Glade.get_widget('snooze_button').hide()
2893
 
 
 
3361
                                        dl_Glade.get_widget('snooze_button').hide()
 
3362
                                else:
 
3363
                                        snoozebutton.grab_default()
2894
3364
 
2895
3365
                                try:
2896
 
                                        self.dl.show()
 
3366
                                        dl.set_keep_above(True)
2897
3367
                                        if Al[26] == True:
2898
 
                                                self.dl.fullscreen()
 
3368
                                                dl.fullscreen()
 
3369
 
 
3370
                                        dl.set_focus_on_map(True)
 
3371
                                        dl.set_urgency_hint(True)
 
3372
                                        dl.grab_focus()
 
3373
                                        dl.show()
2899
3374
                                except:
2900
3375
                                        print _("Error: cannot create dialog window.")
2901
3376
 
2902
 
                                
 
3377
                else:
 
3378
                        try: UpdateList(True)
 
3379
                        except: pass
2903
3380
 
2904
3381
                # COMMAND START
2905
3382
 
2915
3392
                                self.f.write(Al[30])
2916
3393
                                self.f.close()
2917
3394
                                os.chmod(os.getenv("HOME") + "/.config/alarm-clock/runscript", 0777)
2918
 
                                
2919
3395
                        if Al[31]:      
2920
 
                                os.popen2("gnome-terminal -x %s" % (os.getenv("HOME") + "/.config/alarm-clock/runscript"), "r")
 
3396
                                os.popen2("%s -x %s" % (self.TerminalCommand, os.getenv("HOME") + "/.config/alarm-clock/runscript"), "r")
2921
3397
                        else:
2922
3398
                                os.popen2(os.getenv("HOME") + "/.config/alarm-clock/runscript", "r")
2923
3399
 
2946
3422
 
2947
3423
 
2948
3424
 
2949
 
 
2950
 
        def CloseDialogPopup(self, DialogWindow):
2951
 
                DialogWindow.get_parent_window().destroy()
2952
 
 
2953
 
        def SnoozeClicked(self,obj):
2954
 
                self.dl.destroy()
2955
 
 
2956
 
                SnoozeThreadObject = SnoozeThread.SnoozeThread(self.c, self.dl, StartGUI)
 
3425
        def SnoozeClicked(self, Al, Count = False, Remover = False, Loader = False, Prefs = False, UpdateList = None):
 
3426
                SnoozeThreadObject = SnoozeThread.SnoozeThread(Al, StartGUI, Count, Remover, Loader, Prefs, UpdateList)
2957
3427
                SnoozeThreadObject.start()
2958
3428
 
2959
3429