From b2d607df4444638ca27aa229304f56013ec8b2a4 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 17 Jan 2019 16:37:22 +0000 Subject: user-accounts: Fix carousel arrow location when animations are disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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 70009c240..e1878bb70 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); -- cgit v1.2.1