[gnome-clocks] Add Stop and Snooze buttons
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Add Stop and Snooze buttons
- Date: Thu, 30 Aug 2012 08:50:12 +0000 (UTC)
commit ad60156de4fafbbec2129d2a977bec909c0ef3bb
Author: Paolo Borelli <pborelli gnome org>
Date: Thu Aug 30 10:46:35 2012 +0200
Add Stop and Snooze buttons
Show stop and snooze buttons when the alarm is ringing. At the moment
they do not do anything, I fear we may not be able to stop the ringing
with pycanberra...
gnomeclocks/alarm.py | 55 +++++++++++++++++++++++++++++++++++++++++++------
gnomeclocks/app.py | 1 -
gnomeclocks/world.py | 2 +
3 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index 4764d09..2acf774 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -369,6 +369,10 @@ class Alarm(Clock):
if alarm.check_expired():
alert = self.liststore.get_value(i.iter, 4)
alert.show()
+ widget = self.liststore.get_value(i.iter, 3)
+ standalone = widget.get_standalone_widget()
+ standalone.set_ringing(True)
+ self.emit("show-standalone", widget)
return True
def _on_notification_activated(self, notif, action, data):
@@ -467,30 +471,67 @@ class StandaloneAlarm(Gtk.Box):
self.timebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.alarm_label = Gtk.Label()
- self.alarm_label.set_alignment(0.0, 0.5)
+ self.alarm_label.set_alignment(0.5, 0.5)
self.timebox.pack_start(self.alarm_label, True, True, 0)
self.repeat_label = Gtk.Label()
self.repeat_label.set_alignment(0.5, 0.5)
self.timebox.pack_start(self.repeat_label, True, True, 0)
- self.hbox = Gtk.Box()
- self.hbox.set_homogeneous(False)
+ self.buttons = Gtk.Box()
+ self.leftButton = Gtk.Button()
+ self.leftButton.get_style_context().add_class("clocks-stop")
+ self.leftButton.set_size_request(200, -1)
+ self.leftLabel = Gtk.Label()
+ self.leftButton.add(self.leftLabel)
+ self.rightButton = Gtk.Button()
+ self.rightButton.set_size_request(200, -1)
+ self.rightLabel = Gtk.Label()
+ self.rightButton.add(self.rightLabel)
- self.hbox.pack_start(Gtk.Label(), True, True, 0)
- self.hbox.pack_start(self.timebox, False, False, 0)
- self.hbox.pack_start(Gtk.Label(), True, True, 0)
+ self.buttons.pack_start(self.leftButton, True, True, 0)
+ self.buttons.pack_start(Gtk.Box(), True, True, 24)
+ self.buttons.pack_start(self.rightButton, True, True, 0)
+
+ self.leftLabel.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Stop")))
+ self.leftLabel.set_padding(6, 0)
+ self.rightLabel.set_markup("<span font_desc=\"18.0\">%s</span>" % (_("Snooze")))
+ self.rightLabel.set_padding(6, 0)
+
+ self.leftButton.connect('clicked', self._on_stop_clicked)
+ self.rightButton.connect('clicked', self._on_snooze_clicked)
+
+ self.timebox.pack_start(self.buttons, True, True, 48)
+
+ hbox = Gtk.Box()
+ hbox.set_homogeneous(False)
+
+ hbox.pack_start(Gtk.Label(), True, True, 0)
+ hbox.pack_start(self.timebox, False, False, 0)
+ hbox.pack_start(Gtk.Label(), True, True, 0)
self.pack_start(Gtk.Label(), True, True, 0)
- self.pack_start(self.hbox, False, False, 0)
+ self.pack_start(hbox, False, False, 0)
self.pack_start(Gtk.Label(), True, True, 0)
self.update()
+ self.show_all()
+ self.set_ringing(False)
+
+ def _on_stop_clicked(self, button):
+ pass
+
+ def _on_snooze_clicked(self, button):
+ pass
+
def get_name(self):
name = self.alarm.get_alarm_name()
return GLib.markup_escape_text(name)
+ def set_ringing(self, show):
+ self.buttons.set_visible(show)
+
def update(self):
timestr = self.alarm.get_time_as_string()
repeat = self.alarm.get_alarm_repeat_string()
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index 10e76e7..d322bbb 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -93,7 +93,6 @@ class Window(Gtk.ApplicationWindow):
widget = d.get_standalone_widget()
self.toolbar.show_standalone_toolbar(widget)
self.single_evbox.add(widget)
- self.single_evbox.show_all()
self.notebook.set_current_page(-1)
self.embed.spotlight(show_standalone_page)
diff --git a/gnomeclocks/world.py b/gnomeclocks/world.py
index 216acaa..b7c0564 100644
--- a/gnomeclocks/world.py
+++ b/gnomeclocks/world.py
@@ -427,6 +427,8 @@ class StandaloneClock(Gtk.Box):
hbox.pack_start(Gtk.Label(), True, True, 0)
self.pack_end(hbox, False, False, 30)
+ self.show_all()
+
def get_name(self):
return GLib.markup_escape_text(self.location.get_city_name())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]