[gnome-control-center/gnome-3-34] user-accounts: Fix carousel arrow location when animations are disabled
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-34] user-accounts: Fix carousel arrow location when animations are disabled
- Date: Thu, 12 Dec 2019 07:17:29 +0000 (UTC)
commit 976983c9aad205ac0642a5524f4e4908d9e1cb1b
Author: Philip Withnall <withnall endlessm com>
Date: Thu Jan 17 16:37:22 2019 +0000
user-accounts: Fix carousel arrow location when animations are disabled
When animations are disabled, the @keyframes CSS rule doesn’t work, and
neither does animation-name — so we need to set the margin-left to the
arrow’s final location directly.
Signed-off-by: Philip Withnall <withnall endlessm com>
(cherry picked from commit b2d607df4444638ca27aa229304f56013ec8b2a4)
panels/user-accounts/cc-carousel.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/panels/user-accounts/cc-carousel.c b/panels/user-accounts/cc-carousel.c
index 94f2e4979..f9b8bb8b7 100644
--- a/panels/user-accounts/cc-carousel.c
+++ b/panels/user-accounts/cc-carousel.c
@@ -111,6 +111,8 @@ cc_carousel_move_arrow (CcCarousel *self)
GtkStyleContext *context;
gchar *css;
gint end_x;
+ GtkSettings *settings;
+ gboolean animations;
if (!self->selected_item)
return;
@@ -122,13 +124,26 @@ cc_carousel_move_arrow (CcCarousel *self)
gtk_style_context_remove_provider (context, self->provider);
g_clear_object (&self->provider);
- css = g_strdup_printf ("@keyframes arrow_keyframes-%d {\n"
- " from { margin-left: %dpx; }\n"
- " to { margin-left: %dpx; }\n"
- "}\n"
- "* {\n"
- " animation-name: arrow_keyframes-%d;\n"
- "}\n", end_x, self->arrow_start_x, end_x, end_x);
+ settings = gtk_widget_get_settings (GTK_WIDGET (self));
+ g_object_get (settings, "gtk-enable-animations", &animations, NULL);
+
+ /* Animate the arrow movement if animations are enabled. Otherwise,
+ * jump the arrow to the right location instantly. */
+ if (animations)
+ {
+ css = g_strdup_printf ("@keyframes arrow_keyframes-%d {\n"
+ " from { margin-left: %dpx; }\n"
+ " to { margin-left: %dpx; }\n"
+ "}\n"
+ "* {\n"
+ " animation-name: arrow_keyframes-%d;\n"
+ "}\n",
+ end_x, self->arrow_start_x, end_x, end_x);
+ }
+ else
+ {
+ css = g_strdup_printf ("* { margin-left: %dpx }", end_x);
+ }
self->provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_data (GTK_CSS_PROVIDER (self->provider), css, -1, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]