summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-01-17 16:37:22 +0000
committerOndrej Holy <oholy@redhat.com>2019-12-12 07:17:19 +0000
commit976983c9aad205ac0642a5524f4e4908d9e1cb1b (patch)
tree386cd86b5caac7bd1e394702652897cc6fd47d2e
parentc47830c24cfb7817e249d4518a9174369088be72 (diff)
downloadgnome-control-center-976983c9aad205ac0642a5524f4e4908d9e1cb1b.tar.gz
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)
-rw-r--r--panels/user-accounts/cc-carousel.c29
1 files 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);