[clocks] Fix timer continue bug, now it switches to welcome screen after time reaches 0



commit 8d2c642812a388539afaa484d3c95ae50d5a381d
Author: Eslam Mostafa <cseslam gmail com>
Date:   Fri Jul 6 19:05:36 2012 +0200

    Fix timer continue bug, now it switches to welcome screen after time reaches 0
    
    Apply Notifications on Timer
    
    removing extra commented lines
    
    Check button
    
    Signed-off-by: Seif Lotfy <seif lotfy com>

 clocks.py |   25 ++++++++++++++++++++++++-
 main.py   |   14 ++++++++++++--
 2 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/clocks.py b/clocks.py
index bd9dc79..00569bf 100644
--- a/clocks.py
+++ b/clocks.py
@@ -18,7 +18,7 @@
  Author: Seif Lotfy <seif lotfy collabora co uk>
 """
 
-from gi.repository import Gtk, GObject, Gio, Gdk
+from gi.repository import Gtk, GObject, Gio, Gdk, Gst, Notify
 from gi.repository.GdkPixbuf import Pixbuf
 
 from widgets import NewWorldClockDialog, DigitalClock, NewAlarmDialog
@@ -293,6 +293,7 @@ class Timer (Clock):
         self.state = 0
         self.g_id = 0
         #
+        self.alert = Alert()
         self.vbox = Gtk.Box (orientation = Gtk.Orientation.VERTICAL)
         box = Gtk.Box ()
         self.add (box)
@@ -361,6 +362,28 @@ class Timer (Clock):
 
         self.timer_screen.timerLabel.set_markup (TIMER_LABEL_MARKUP%(hours, minutes, seconds))
         if hours == 00 and minutes == 00 and seconds == 00:
+            self.alert.do_alert("Ta Da !")
+            self.state = 0
+            self.timerbox.remove(self.timer_screen)
+            self.show_timer_welcome_screen()
+            if self.g_id != 0:
+                GObject.source_remove(self.g_id)
+            self.g_id = 0
             return False
         else:
             return True
+
+class Alert:
+    def __init__(self):
+        Gst.init('gst') 
+
+    def do_alert(self, msg):
+        if Notify.init("GNOME Clocks"):
+            Alert = Notify.Notification.new("Clocks", msg, 'test')
+            Alert.show()    
+            playbin = Gst.ElementFactory.make('playbin', None)
+            playbin.set_property('uri', 'file:///usr/share/sounds/gnome/default/alerts/glass.ogg')
+            playbin.set_state(Gst.State.PLAYING)
+        else:
+            print "error"
+
diff --git a/main.py b/main.py
index fcb2b04..e30d692 100644
--- a/main.py
+++ b/main.py
@@ -184,10 +184,11 @@ class ClocksToolbar (Gtk.Toolbar):
         
         self.applyButton = Gtk.Button ()
         #self.applyButton.get_style_context ().add_class ('raised');
-        icon = Gio.ThemedIcon.new_with_default_fallbacks ("action-unavailable-symbolic")
+        icon = Gio.ThemedIcon.new_with_default_fallbacks ("emblem-default-symbolic")
         image = Gtk.Image ()
-        image.set_from_gicon (icon, Gtk.IconSize.LARGE_TOOLBAR)
+        image.set_from_gicon (icon, Gtk.IconSize.SMALL_TOOLBAR)
         self.applyButton.add (image)
+        self.applyButton.connect('clicked', self._on_selection_mode)
         self.rightBox = box = Gtk.Box ()
         box.pack_end (self.applyButton, False, False, 3)
         toolbox.pack_start (box, True, True, 0)
@@ -254,6 +255,15 @@ class ClocksToolbar (Gtk.Toolbar):
             self._busy = False
             self.emit ("view-clock", self._buttonMap[widget])
 
+    def _on_selection_mode(self, button):
+        self.set_selection_mode(True)
+
+    def set_selection_mode(self, val):
+        if val == True:
+            pass
+        else:
+            self.set_single_toolbar()
+
     def _delete_clock (self, button):
          pass
 



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