summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-01-17 16:37:22 +0000
committerPhilip Withnall <withnall@endlessm.com>2019-12-11 14:23:36 +0000
commitb2d607df4444638ca27aa229304f56013ec8b2a4 (patch)
tree9bfe6b8bc5bfa0a6976aa4bb011b66e633a3ec1b
parentf529519c28ebf0c6a9525ae7c8f7bba5d9b09faf (diff)
downloadgnome-control-center-b2d607df4444638ca27aa229304f56013ec8b2a4.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>
-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 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);