gnome-software/0003-carousel-animation.patch

144 lines
4.3 KiB
Diff
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 4a357593a4979b422044794185c1e3bd4291c719 Mon Sep 17 00:00:00 2001
Date: Tue, 2 Sep 2025 18:41:29 +0200
Subject: [PATCH 1/2] gs-featured-carousel: Don't rotate banner when animations
are disabled
There are accessibility issues related to moving, blinking, and
auto-scrolling information on the screen.
The WCAG 2.0 guidelines have a success criterion for having a way, such
as a setting, to Pause, Stop, or Hide, moving information.
See https://www.w3.org/TR/UNDERSTANDING-WCAG20/time-limits-pause.html
---
src/gs-featured-carousel.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/gs-featured-carousel.c b/src/gs-featured-carousel.c
index 151005e79..6e8c4fbd7 100644
--- a/src/gs-featured-carousel.c
+++ b/src/gs-featured-carousel.c
@@ -112,14 +112,6 @@ start_rotation_timer (GsFeaturedCarousel *self)
}
}
-static void
-maybe_start_rotation_timer (GsFeaturedCarousel *self)
-{
- if (self->apps != NULL && gs_app_list_length (self->apps) > 0 &&
- gtk_widget_get_mapped (GTK_WIDGET (self)))
- start_rotation_timer (self);
-}
-
static void
stop_rotation_timer (GsFeaturedCarousel *self)
{
@@ -129,12 +121,25 @@ stop_rotation_timer (GsFeaturedCarousel *self)
}
}
+static void
+maybe_start_rotation_timer (GsFeaturedCarousel *self)
+{
+ if (!adw_get_enable_animations (GTK_WIDGET (self))) {
+ stop_rotation_timer (self);
+ return;
+ }
+
+ if (self->apps != NULL && gs_app_list_length (self->apps) > 0 &&
+ gtk_widget_get_mapped (GTK_WIDGET (self)))
+ start_rotation_timer (self);
+}
+
static void
carousel_notify_position_cb (GsFeaturedCarousel *self)
{
/* Reset the rotation timer in case its about to fire. */
stop_rotation_timer (self);
- start_rotation_timer (self);
+ maybe_start_rotation_timer (self);
}
static void
--
GitLab
From 0ae3a506fc97f3919be4251678009b73ff5801f1 Mon Sep 17 00:00:00 2001
Date: Fri, 5 Sep 2025 14:40:37 +0100
Subject: [PATCH 2/2] gs-featured-carousel: Update animations when GTK settings
change
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Further to the previous commit, lets update whether animations are
enabled/disabled when the GTK settings change, so gnome-software doesnt
have to be restarted to see the difference.
---
src/gs-featured-carousel.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/gs-featured-carousel.c b/src/gs-featured-carousel.c
index 6e8c4fbd7..3e3eaae95 100644
--- a/src/gs-featured-carousel.c
+++ b/src/gs-featured-carousel.c
@@ -43,6 +43,7 @@ struct _GsFeaturedCarousel
GsAppList *apps; /* (nullable) (owned) */
guint rotation_timer_id;
+ unsigned long settings_notify_id;
AdwCarousel *carousel;
GtkButton *next_button;
@@ -142,6 +143,17 @@ carousel_notify_position_cb (GsFeaturedCarousel *self)
maybe_start_rotation_timer (self);
}
+static void
+carousel_notify_settings_cb (GObject *object,
+ GParamSpec *pspec,
+ void *user_data)
+{
+ GsFeaturedCarousel *self = GS_FEATURED_CAROUSEL (user_data);
+
+ /* this will also stop the timer if animations are disabled */
+ maybe_start_rotation_timer (self);
+}
+
static void
next_button_clicked_cb (GtkButton *button,
gpointer user_data)
@@ -174,11 +186,19 @@ tile_clicked_cb (GsFeatureTile *tile,
static void
gs_featured_carousel_init (GsFeaturedCarousel *self)
{
+ GtkSettings *settings;
+
gtk_widget_init_template (GTK_WIDGET (self));
/* Disable scrolling through the carousel, as its typically used
* in app pages which are themselves scrollable. */
adw_carousel_set_allow_scroll_wheel (self->carousel, FALSE);
+
+ /* Connect to settings notifications so we can enable/disable animations */
+ settings = gtk_widget_get_settings (GTK_WIDGET (self));
+ self->settings_notify_id = g_signal_connect (settings, "notify::gtk-enable-animations",
+ G_CALLBACK (carousel_notify_settings_cb),
+ self);
}
static void
@@ -223,6 +243,7 @@ gs_featured_carousel_dispose (GObject *object)
GsFeaturedCarousel *self = GS_FEATURED_CAROUSEL (object);
stop_rotation_timer (self);
+ g_clear_signal_handler (&self->settings_notify_id, gtk_widget_get_settings (GTK_WIDGET (self)));
g_clear_object (&self->apps);
G_OBJECT_CLASS (gs_featured_carousel_parent_class)->dispose (object);
--
GitLab