From fff765dca2aa14b66bd9f1f4aaf4b2441ce2ced5 Mon Sep 17 00:00:00 2001 From: Alexander Vanhee <160625516+AlexanderVanhee@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:58:10 +0200 Subject: [PATCH] Snap to selection on map This fixes an issue where when you returned from the full view or whatever, it would show the carousel stopped somewhere in the middle between 2 featured tiles. --- bge/bge-carousel.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bge/bge-carousel.c b/bge/bge-carousel.c index 24af917b..0b307ce8 100644 --- a/bge/bge-carousel.c +++ b/bge/bge-carousel.c @@ -342,6 +342,36 @@ bge_carousel_size_allocate (GtkWidget *widget, } } +static void +bge_carousel_map (GtkWidget *widget) +{ + BgeCarousel *self = NULL; + guint selected = 0; + + self = BGE_CAROUSEL (widget); + + GTK_WIDGET_CLASS (bge_carousel_parent_class)->map (widget); + + if (self->model != NULL) + { + selected = gtk_single_selection_get_selected (self->model); + if (selected != G_MAXUINT) + { + for (guint i = 0; i < self->widgets->len; i++) + { + CarouselWidgetData *child = NULL; + + child = g_ptr_array_index (self->widgets, i); + if (child->cancellable != NULL) + g_cancellable_cancel (child->cancellable); + child->target = child->rect; + } + } + } + + gtk_widget_queue_allocate (GTK_WIDGET (self)); +} + static void bge_carousel_class_init (BgeCarouselClass *klass) { @@ -466,6 +496,7 @@ bge_carousel_class_init (BgeCarouselClass *klass) widget_class->measure = bge_carousel_measure; widget_class->size_allocate = bge_carousel_size_allocate; + widget_class->map = bge_carousel_map; } static void @@ -1378,3 +1409,4 @@ finish_horizontal_gesture (BgeCarousel *self, } /* End of bge-carousel.c */ +