Commits

Damián Nohales committed 115f354

Show notification in a timeout.

This is because when user press repeatedly the previous and next button, the notifications going crazy.

Comments (0)

Files changed (1)

         self.windowstate = 1
         self.current_song = None
         self.play_thread = None
+        self.notify_timeout_id = None
         
         init_thread = InitThread(self)
         init_thread.start()
                                          title = glib.markup_escape_text(song.get_title()))
             )
             if int(config()['show_notification']) == 1 and env().HAVE_NOTIFY:
-                n = pynotify.Notification(_("Now playing"),
-                    "%s - %s" % (glib.markup_escape_text(song.get_artist()),
-                                 glib.markup_escape_text(song.get_title())),
-                    "audio-x-generic")
-                n.set_timeout(50)
-                n.show()
+                if self.notify_timeout_id != None:
+                    gobject.source_remove(self.notify_timeout_id)
+                self.notify_timeout_id = gobject.timeout_add(1000, self.show_playing_song_notification)
                 
             self.player.set_state(gst.STATE_NULL)
             
             self.play_button.set_stock_id(gtk.STOCK_MEDIA_PLAY)
             self.songinfo.set_markup("")
     
+    def show_playing_song_notification(self):
+        song = self.get_playing_song()
+        n = pynotify.Notification(_("Now playing"),
+            "%s - %s" % (glib.markup_escape_text(song.get_artist()),
+                         glib.markup_escape_text(song.get_title())),
+            "audio-x-generic")
+        n.set_timeout(50)
+        n.show()
+    
     def play_first_song(self):
         if len(self.playlist) > 0:
             self.set_playing_song(self.playlist.get_song(0))