[gnome-clocks/wip/vala] Alarm save
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/wip/vala] Alarm save
- Date: Sun, 17 Feb 2013 15:54:56 +0000 (UTC)
commit 0c190fe9f7e9ab985fc9667ab48276d2859a3e7d
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Feb 17 16:45:24 2013 +0100
Alarm save
src/alarm.vala | 19 +++++++++++++++----
src/world.vala | 6 +++---
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 24620c0..60e9b68 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -217,10 +217,19 @@ private class Item : Object {
builder.add ("{sv}", "active", new GLib.Variant.boolean (active));
builder.add ("{sv}", "hour", new GLib.Variant.int32 (hour));
builder.add ("{sv}", "minute", new GLib.Variant.int32 (minute));
-// builder.add ("{sv}", "days", new GLib.Variant.string ("name"));
+ builder.add ("{sv}", "days", days_variant ());
builder.close ();
}
+ // GLib.Variant.fixed_array is broken in vala for now, so roll our own
+ private GLib.Variant days_variant () {
+ var builder = new GLib.VariantBuilder (new VariantType ("ai"));
+ foreach (var i in days) {
+ builder.add ("i", new GLib.Variant.int32 (i));
+ }
+ return builder.end ();
+ }
+
public static Item? deserialize (GLib.Variant alarm_variant) {
string? name = null;
bool active = true;
@@ -517,7 +526,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
foreach (var a in settings.get_value ("alarms")) {
Item alarm = Item.deserialize (a);
alarms.prepend (alarm);
- add_alarm (alarm);
+ add_alarm_to_store (alarm);
}
alarms.reverse ();
}
@@ -530,7 +539,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
settings.set_value ("alarms", builder.end ());
}
- private void add_alarm (Item alarm) {
+ private void add_alarm_to_store (Item alarm) {
var label = "<b>%s</b>".printf (GLib.Markup.escape_text (alarm.name));
Gtk.TreeIter i;
list_store.append (out i);
@@ -543,8 +552,10 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
if (response == 1) {
var alarm = new Item ();
((SetupDialog) dialog).apply_to_alarm (alarm);
- add_alarm (alarm);
+ alarms.append (alarm);
+ add_alarm_to_store (alarm);
alarm.reset();
+ save ();
}
dialog.destroy ();
});
diff --git a/src/world.vala b/src/world.vala
index d722069..1b6daa2 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -318,7 +318,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
foreach (var l in settings.get_value ("world-clocks")) {
Item location = Item.deserialize (l);
locations.prepend (location);
- add_location (location);
+ add_location_to_store (location);
}
locations.reverse ();
}
@@ -331,7 +331,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
settings.set_value ("world-clocks", builder.end ());
}
- private void add_location (Item location) {
+ private void add_location_to_store (Item location) {
var label = "<b>%s</b>".printf (GLib.Markup.escape_text (location.name));
Gtk.TreeIter i;
list_store.append (out i);
@@ -345,7 +345,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
if (response == 1) {
var location = ((LocationDialog) dialog).get_location ();
locations.append (location);
- add_location (location);
+ add_location_to_store (location);
save ();
}
dialog.destroy ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]