[gnome-software: 1/2] featured-carousel: Reset the timer on any position change




commit 3a5071413531f41f973b6bd0341a3f024609f94f
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Mar 1 15:44:39 2022 +0100

    featured-carousel: Reset the timer on any position change
    
    This ensures the timer is reset when swiping with the touchpad or
    touchscreen.

 src/gs-featured-carousel.c  | 17 +++++++++--------
 src/gs-featured-carousel.ui |  1 +
 2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/src/gs-featured-carousel.c b/src/gs-featured-carousel.c
index c0af48922..4ce56871e 100644
--- a/src/gs-featured-carousel.c
+++ b/src/gs-featured-carousel.c
@@ -132,6 +132,14 @@ stop_rotation_timer (GsFeaturedCarousel *self)
        }
 }
 
+static void
+carousel_notify_position_cb (GsFeaturedCarousel *self)
+{
+       /* Reset the rotation timer in case it’s about to fire. */
+       stop_rotation_timer (self);
+       start_rotation_timer (self);
+}
+
 static void
 next_button_clicked_cb (GtkButton *button,
                         gpointer   user_data)
@@ -139,10 +147,6 @@ next_button_clicked_cb (GtkButton *button,
        GsFeaturedCarousel *self = GS_FEATURED_CAROUSEL (user_data);
 
        show_relative_page (self, +1);
-
-       /* Reset the rotation timer in case it’s about to fire. */
-       stop_rotation_timer (self);
-       start_rotation_timer (self);
 }
 
 static void
@@ -152,10 +156,6 @@ previous_button_clicked_cb (GtkButton *button,
        GsFeaturedCarousel *self = GS_FEATURED_CAROUSEL (user_data);
 
        show_relative_page (self, -1);
-
-       /* Reset the rotation timer in case it’s about to fire. */
-       stop_rotation_timer (self);
-       start_rotation_timer (self);
 }
 
 static void
@@ -303,6 +303,7 @@ gs_featured_carousel_class_init (GsFeaturedCarouselClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsFeaturedCarousel, carousel);
        gtk_widget_class_bind_template_child (widget_class, GsFeaturedCarousel, next_button);
        gtk_widget_class_bind_template_child (widget_class, GsFeaturedCarousel, previous_button);
+       gtk_widget_class_bind_template_callback (widget_class, carousel_notify_position_cb);
        gtk_widget_class_bind_template_callback (widget_class, next_button_clicked_cb);
        gtk_widget_class_bind_template_callback (widget_class, previous_button_clicked_cb);
        gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb);
diff --git a/src/gs-featured-carousel.ui b/src/gs-featured-carousel.ui
index 6298534c3..3348686b8 100644
--- a/src/gs-featured-carousel.ui
+++ b/src/gs-featured-carousel.ui
@@ -20,6 +20,7 @@
         <property name="valign">fill</property>
         <child>
           <object class="AdwCarousel" id="carousel">
+            <signal name="notify::position" handler="carousel_notify_position_cb" swapped="yes"/>
             <style>
               <class name="card"/>
             </style>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]