[clocks] Alarm ics fix test



commit e3042a40d202c95912b90a9757180ad1626ba5cb
Author: Eslam Mostafa <cseslam gmail com>
Date:   Wed Jul 25 18:53:38 2012 +0200

    Alarm ics fix test
    
    Signed-off-by: Seif Lotfy <seif lotfy com>

 alarm.py   |   19 +++++++------------
 clocks.py  |    4 ++--
 widgets.py |   51 ++++++++++++++++++++++++++++++++++++---------------
 3 files changed, 45 insertions(+), 29 deletions(-)
---
diff --git a/alarm.py b/alarm.py
index 2366a64..a55000a 100644
--- a/alarm.py
+++ b/alarm.py
@@ -1,10 +1,12 @@
 import datetime, vobject, time
 
 class AlarmItem:
-    def __init__(self, name, time, repeat):
+    def __init__(self, name, time, repeat, h, m):
         self.name = name
         self.time = time
         self.repeat = repeat
+        self.h = h
+        self.m = m
 
     def set_alarm_time(self, time):
         self.time = time 
@@ -26,18 +28,11 @@ class AlarmItem:
     
     def get_vobject(self):                
         alarm = vobject.newFromBehavior('vevent')            
-        alarm.add('title').value = self.name        
-        alarm.add('dtstart').value = datetime.datetime.utcnow()        
-        t =  datetime.datetime.utcfromtimestamp(self.time)
-        alarm.add('dtend').value = t
+        alarm.add('summary').value = self.name                
+        #t = datetime.datetime.utcfromtimestamp(self.time)
+        alarm.add('dtstart').value = datetime.datetime.combine(datetime.date.today(), datetime.time(self.h, self.m))        
+        alarm.add('dtend').value = datetime.datetime.combine(datetime.date.today(), datetime.time(self.h+1, self.m))
         alarm.add('rrule').value = 'FREQ=WEEKLY;BYDAY=%s' % ','.join(self.repeat)
-        #alarm.add('enddate').value =       
-        #alarm.add('repeat').value = '4' #self.repeat
-        #alarm.add('duration').value = '15M'        
-        #date = datetime.date(datetime.date.today())
-        #print date
-        #alarm.add('trigger')#.value = datetime.datetime.utcnow() #fromtimestamp(self.time)
-        #datetime.datetime.combine(datetime.date.today(), self.time) #Convert self.time to datetime
         alarm.add('action').value = 'audio'
         alarm.add('attach').value = '/usr/share/sounds/gnome/default/alerts/glass.ogg'
         return alarm        
diff --git a/clocks.py b/clocks.py
index 263a1c5..27535d1 100644
--- a/clocks.py
+++ b/clocks.py
@@ -190,8 +190,8 @@ class Alarm (Clock):
         ah = AlarmsHandler()
         alarms = ah.load_alarms()        
         for alarm in alarms:         
-            name = alarm.title.value        
-            trigger = alarm.dtend.value                      
+            name = alarm.summary.value        
+            trigger = alarm.dtstart.value                      
             d = AlarmWidget(trigger)                        
             view_iter = self.liststore.append([d.drawing.pixbuf, "<b>" + name + "</b>", d])
             d.set_iter(self.liststore, view_iter)          
diff --git a/widgets.py b/widgets.py
index 8eb74ea..1bd6aad 100644
--- a/widgets.py
+++ b/widgets.py
@@ -418,32 +418,53 @@ class NewAlarmDialog (Gtk.Dialog):
             name = self.entry.get_text()  #Perfect
             time = self.hourselect.get_value_as_int() * 60 * 60 + self.minuteselect.get_value_as_int() * 60            
             repeat = self.repeat_days
-            new_alarm = AlarmItem(name, time, repeat)            
+            new_alarm = AlarmItem(name, time, repeat, self.hourselect.get_value_as_int(), self.minuteselect.get_value_as_int())            
             self.emit('add-alarm', new_alarm)
             self.destroy ()
         else:
             pass
 
-    def on_d1_clicked(self, buttond1):
-        self.repeat_days.append('SU')
+    def on_d1_clicked(self, btn):
+        if btn.get_active() == True:
+            self.repeat_days.append('SU')
+        if btn.get_active() == False:
+            self.repeat_days.remove('SU')
                   
-    def on_d2_clicked(self, buttond2):
-        self.repeat_days.append('MO')
+    def on_d2_clicked(self, btn):    
+        if btn.get_active() == True:
+            self.repeat_days.append('MO')
+        if btn.get_active() == False:
+            self.repeat_days.remove('MO')
     
-    def on_d3_clicked(self, buttond3):
-        self.repeat_days.append('TU')
+    def on_d3_clicked(self, btn):        
+        if btn.get_active() == True:
+            self.repeat_days.append('TU')
+        if btn.get_active() == False:
+            self.repeat_days.remove('TU')
     
-    def on_d4_clicked(self, buttond4):
-        self.repeat_days.append('WE')
+    def on_d4_clicked(self, btn):
+        if btn.get_active() == True:
+            self.repeat_days.append('WE')
+        if btn.get_active() == False:
+            self.repeat_days.remove('WE')
     
-    def on_d5_clicked(self, buttond5):
-        self.repeat_days.append('TH')
+    def on_d5_clicked(self, btn):        
+        if btn.get_active() == True:
+            self.repeat_days.append('TH')
+        if btn.get_active() == False:
+            self.repeat_days.remove('TH')
     
-    def on_d6_clicked(self, buttond6):
-        self.repeat_days.append('FR')
+    def on_d6_clicked(self, btn):        
+        if btn.get_active() == True:
+            self.repeat_days.append('FR')
+        if btn.get_active() == False:
+            self.repeat_days.remove('FR')
     
-    def on_d7_clicked(self, buttond7):
-        self.repeat_days.append('SA')
+    def on_d7_clicked(self, btn):        
+        if btn.get_active() == True:
+            self.repeat_days.append('SA')
+        if btn.get_active() == False:
+            self.repeat_days.remove('SA')
 
 """
 if text.startswith("0"):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]