[gnome-clocks] Add support for storing edited alarms
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Add support for storing edited alarms
- Date: Sat, 25 Aug 2012 21:26:00 +0000 (UTC)
commit a0182569f0546fdbfeede1c2a8342f4939260802
Author: Seif Lotfy <seif lotfy com>
Date: Sat Aug 25 23:25:08 2012 +0200
Add support for storing edited alarms
Finish implementation for editing alarms and storing them.
Please notice the FIXME
gnomeclocks/alarm.py | 18 ++++++++----------
gnomeclocks/clocks.py | 6 +++++-
gnomeclocks/widgets.py | 6 +++++-
3 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index c0bb3b5..6e3ab14 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -63,19 +63,14 @@ class ICSHandler():
ics.write(vcal.serialize())
ics.close()
- def delete_alarm(self, alarm_uid):
- # TODO: Add alarm deletion support
- pass
-
- def edit_alarm(self, alarm_uid, new_name=None, new_hour=None,
- new_mins=None, new_p=None, new_repeat=None):
+ def edit_alarm(self, alarm):
with open(self.ics_file, 'r+') as ics:
vcal = vobject.readOne(ics.read())
for event in vcal.vevent_list:
- if event.uid.value == alarm_uid:
- if new_name:
- del event.summary
- event.add('summary').value = new_name
+ if event.uid.value == alarm.uid:
+ #FIXME: Update instead of remove and add
+ self.remove_vevents((alarm.uid,))
+ self.add_vevent(alarm.get_vevent())
class AlarmItem:
@@ -84,6 +79,9 @@ class AlarmItem:
self.repeat = repeat
self.vevent = None
self.uid = None
+ self.h = h
+ self.m = m
+ self.p = p
if not h == None and not m == None:
if p:
t = datetime.strptime("%02i:%02i %s" % (h, m, p), "%H:%M %p")
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 4f20e3a..96271d7 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -296,7 +296,11 @@ class Alarm(Clock):
alarm])
def edit_alarm(self, alarm):
- print "To Do!"
+ handler = ICSHandler()
+ handler.edit_alarm(alarm)
+ self.iconview.unselect_all()
+ self.liststore.clear()
+ self.load_alarms()
def delete_alarms(self, alarms):
handler = ICSHandler()
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 1203df5..ced66bf 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -448,6 +448,7 @@ class AlarmWidget():
class AlarmDialog(Gtk.Dialog):
def __init__(self, alarm_view, parent, vevent=None):
+ self.vevent = vevent
if vevent:
Gtk.Dialog.__init__(self, _("Edit Alarm"), parent)
else:
@@ -574,7 +575,10 @@ class AlarmDialog(Gtk.Dialog):
for btn in self.day_buttons:
if btn.get_active():
repeat.append(btn.get_label()[:2])
- return AlarmItem(name, repeat, h, m, p)
+ alarm_item = AlarmItem(name, repeat, h, m, p)
+ if self.vevent:
+ alarm_item.uid = self.vevent.uid.value
+ return alarm_item
class EmptyPlaceholder(Gtk.Box):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]