[gnome-music] window: Show loading notification after a small delay
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] window: Show loading notification after a small delay
- Date: Sat, 31 Dec 2016 12:49:58 +0000 (UTC)
commit 35f03930b4cdb91c095d86c4f9a583dd3231fc73
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Dec 21 20:22:17 2016 -0200
window: Show loading notification after a small delay
When loading e.g. an artists, the notification can show and
hide very quickly, causing a very bad impression since we didn't
really spend any time loading it.
Fix that by setting a small timeout of 500ms before showing
the notification.
https://bugzilla.gnome.org/show_bug.cgi?id=776157
gnomemusic/window.py | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/window.py b/gnomemusic/window.py
index 8e90ab4..b70788b 100644
--- a/gnomemusic/window.py
+++ b/gnomemusic/window.py
@@ -602,8 +602,16 @@ class Window(Gtk.ApplicationWindow):
running. If there is no notification is visible, the loading
notification is started.
"""
- if self._loading_counter == 0:
+ def show_notification_cb(self):
self._loading_notification.set_reveal_child(True)
+ self._show_notification_timeout_id = 0
+ return GLib.SOURCE_REMOVE
+
+ if self._loading_counter == 0:
+ # Only show the notification after a small delay, thus
+ # add a timeout. 500ms feels good enough.
+ self._show_notification_timeout_id = GLib.timeout_add(
+ 500, show_notification_cb, self)
self._loading_counter = self._loading_counter + 1
@@ -615,4 +623,9 @@ class Window(Gtk.ApplicationWindow):
self._loading_counter = self._loading_counter - 1
if self._loading_counter == 0:
+ # Remove the previously set timeout, if any
+ if self._show_notification_timeout_id > 0:
+ GLib.source_remove(self._show_notification_timeout_id)
+ self._show_notification_timeout_id = 0
+
self._loading_notification.set_reveal_child(False)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]