[nautilus/wip/exalm/spinner: 10/10] floating-bar: Don't start spinner if it's not visible
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/exalm/spinner: 10/10] floating-bar: Don't start spinner if it's not visible
- Date: Tue, 1 Jun 2021 19:48:17 +0000 (UTC)
commit 1134d86886747f87806a2d90057dc2b398e66dd4
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Feb 8 19:22:14 2021 +0500
floating-bar: Don't start spinner if it's not visible
Animating unmapped widgets can still change their size, so they have to
be measured every time. https://gitlab.gnome.org/GNOME/gtk/-/issues/1025
As a workaround, ensure the spinner doesn't animate while it's not shown,
to reduce CPU usage.
src/nautilus-floating-bar.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index 30fbf5779..fdb76fb95 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -399,7 +399,12 @@ nautilus_floating_bar_constructed (GObject *obj)
w = gtk_spinner_new ();
gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
gtk_widget_set_visible (w, self->show_spinner);
- gtk_spinner_start (GTK_SPINNER (w));
+ /* As a workaround for https://gitlab.gnome.org/GNOME/gtk/-/issues/1025,
+ * ensure the spinner animates if and only if it's visible, to reduce CPU
+ * usage. */
+ g_object_bind_property (obj, "show-spinner",
+ w, "active",
+ G_BINDING_SYNC_CREATE);
self->spinner = w;
gtk_widget_set_size_request (w, 16, 16);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]