[gnome-clocks] Keep the alarm ringing
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Keep the alarm ringing
- Date: Tue, 19 Feb 2013 09:32:55 +0000 (UTC)
commit c37e37ba3ed1bac9fa11c137ed2866dad2949a89
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Feb 19 10:29:09 2013 +0100
Keep the alarm ringing
Use canberra play_full to keep the alarm ringing. Default duration is
now 3 minutes. I am not sure if it is a good value and if we should
make this configurable.
Also, there is a small pause each time the sound loop, I do not know if
this depends on the sound or if it is due to requeing the idle.
src/timer.vala | 2 +-
src/utils.vala | 38 +++++++++++++++++++++++++++++++++-----
2 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/src/timer.vala b/src/timer.vala
index 111442c..a97b9c9 100644
--- a/src/timer.vala
+++ b/src/timer.vala
@@ -110,7 +110,7 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
}
public virtual signal void ring () {
- bell.ring ();
+ bell.ring_once ();
}
private bool show_leading_zeros (Gtk.SpinButton spin_button) {
diff --git a/src/utils.vala b/src/utils.vala
index 62d82eb..afd07ce 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -302,12 +302,32 @@ public class Bell : Object {
}
}
- public void ring () {
+ private bool keep_ringing () {
+ Canberra.Proplist pl;
+ Canberra.Proplist.create (out pl);
+ pl.sets (Canberra.PROP_EVENT_ID, sound);
+ pl.sets (Canberra.PROP_CANBERRA_XDG_THEME_NAME, soundtheme);
+ pl.sets (Canberra.PROP_MEDIA_ROLE, "alarm");
+
+ canberra.play_full (1, pl, (c, id, code) => {
+ if (code == Canberra.SUCCESS) {
+ GLib.Idle.add (keep_ringing);
+ }
+ });
+
+ return false;
+ }
+
+ private void ring_real (bool once) {
if (canberra != null) {
- canberra.play (1,
- Canberra.PROP_EVENT_ID, sound,
- Canberra.PROP_CANBERRA_XDG_THEME_NAME, soundtheme,
- Canberra.PROP_MEDIA_ROLE, "alarm");
+ if (once) {
+ canberra.play (1,
+ Canberra.PROP_EVENT_ID, sound,
+ Canberra.PROP_CANBERRA_XDG_THEME_NAME, soundtheme,
+ Canberra.PROP_MEDIA_ROLE, "alarm");
+ } else {
+ GLib.Idle.add (keep_ringing);
+ }
}
if (notification != null) {
@@ -319,6 +339,14 @@ public class Bell : Object {
}
}
+ public void ring_once () {
+ ring_real (true);
+ }
+
+ public void ring () {
+ ring_real (false);
+ }
+
public void stop () {
if (canberra != null) {
canberra.cancel (1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]