[gnome-software/1790-allow-scrolling-screenshots-by-clicking-on-next-and-previous-screenshots: 4/4] gs-screenshot-carousel: Scroll to image on click of it




commit c49fe583e89f7003bf1d7e622b835418b0aa2a22
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 7 18:43:30 2022 +0200

    gs-screenshot-carousel: Scroll to image on click of it
    
    Let it scroll to an image also when clicking on it, not only
    by using the arrows or gestures.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1790

 src/gs-screenshot-carousel.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/gs-screenshot-carousel.c b/src/gs-screenshot-carousel.c
index 9a59a2a90..828a741cc 100644
--- a/src/gs-screenshot-carousel.c
+++ b/src/gs-screenshot-carousel.c
@@ -78,6 +78,14 @@ _set_state (GsScreenshotCarousel *self, guint length, gboolean allow_fallback, g
        }
 }
 
+static void
+gs_screenshot_carousel_img_clicked_cb (GtkWidget *ssimg,
+                                      gpointer user_data)
+{
+       GsScreenshotCarousel *self = user_data;
+       adw_carousel_scroll_to (ADW_CAROUSEL (self->carousel), ssimg, TRUE);
+}
+
 /**
  * gs_screenshot_carousel_load_screenshots:
  * @self: a #GsScreenshotCarousel
@@ -148,6 +156,9 @@ gs_screenshot_carousel_load_screenshots (GsScreenshotCarousel *self, GsApp *app,
                        continue;
                }
 
+               g_signal_connect_object (ssimg, "clicked",
+                       G_CALLBACK (gs_screenshot_carousel_img_clicked_cb), self, 0);
+
                adw_carousel_append (ADW_CAROUSEL (self->carousel), ssimg);
                gtk_widget_show (ssimg);
                gs_screenshot_image_set_description (GS_SCREENSHOT_IMAGE (ssimg),


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