[Xfce4-commits] <ristretto:ristretto-0.0> Improve thumbnail limits

Stephan Arts noreply at xfce.org
Sun Oct 23 19:22:57 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to 9586bf7474d834a12d6484c4eb03c35aaa91d152 (commit)
       from bc4001f617669450b7abca15db8e9d264c964aae (commit)

commit 9586bf7474d834a12d6484c4eb03c35aaa91d152
Author: Stephan Arts <stephan at xfce.org>
Date:   Sun Oct 25 23:39:05 2009 +0100

    Improve thumbnail limits

 ChangeLog           |    5 +++++
 src/thumbnail_bar.c |   31 ++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4480a7b..ee32a39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-10-25  Stephan Arts <stephan at xfce.org>
 
+	* src/thumbnail_bar.c: Limit scrolling offset so thumbs don't get
+	  lost outside the window.
+
+2009-10-25  Stephan Arts <stephan at xfce.org>
+
 	* src/xfce_wallpaper_manager.c: Add configure-dialog
 
 2009-10-25  Stephan Arts <stephan at xfce.org>
diff --git a/src/thumbnail_bar.c b/src/thumbnail_bar.c
index 6de645e..02f24d1 100644
--- a/src/thumbnail_bar.c
+++ b/src/thumbnail_bar.c
@@ -740,6 +740,13 @@ cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
     RsttoThumbnailBar *bar = RSTTO_THUMBNAIL_BAR(gtk_widget_get_parent(GTK_WIDGET(thumb)));
     gdouble x = event->x + GTK_WIDGET(thumb)->allocation.x;
     gdouble y = event->y + GTK_WIDGET(thumb)->allocation.y;
+    gint thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
+    gint border_width = 0;
+    gint spacing;
+    gint size = 0;
+
+	gtk_widget_style_get(GTK_WIDGET (bar), "spacing", &spacing, NULL);
+    size = thumb_size * g_list_length (bar->priv->thumbs) + spacing * (g_list_length (bar->priv->thumbs) - 1);
 
     if (event->state & GDK_BUTTON1_MASK)
     {
@@ -753,11 +760,21 @@ cb_rstto_thumbnail_bar_thumbnail_motion_notify_event (GtkWidget *thumb,
         if (bar->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
         {
             bar->priv->offset = bar->priv->motion.offset + (bar->priv->motion.current_x - x);
+            if ((thumb_size - GTK_WIDGET(bar)->allocation.width) >= bar->priv->offset)
+                bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.width + border_width;
+            if ((size - thumb_size) <= bar->priv->offset)
+                bar->priv->offset = size - thumb_size;
         }
         else
         {
             bar->priv->offset = bar->priv->motion.offset + (bar->priv->motion.current_y - y);
+            if ((thumb_size - GTK_WIDGET(bar)->allocation.height) >= bar->priv->offset)
+                bar->priv->offset = thumb_size - GTK_WIDGET(bar)->allocation.height + border_width;
+            if ((size - thumb_size) <= bar->priv->offset)
+                bar->priv->offset = size - thumb_size;
         }
+
+
         bar->priv->motion.offset = bar->priv->offset;
         bar->priv->motion.current_x = x;
         bar->priv->motion.current_y = y;
@@ -774,6 +791,10 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
     gint thumb_size;
     GList *thumb;
     gint border_width = GTK_CONTAINER(bar)->border_width;
+    gint spacing = 0;
+    GtkWidget *widget = GTK_WIDGET (bar);
+
+	gtk_widget_style_get(widget, "spacing", &spacing, NULL);
 
     switch(event->direction)
     {
@@ -811,9 +832,9 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
                         thumb_size = GTK_WIDGET(bar->priv->thumbs->data)->allocation.width;
                         for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
                         {
-                            size += GTK_WIDGET(thumb->data)->allocation.width;
-                            if (g_list_next(thumb))
-                                size += border_width;
+                            size += thumb_size * g_list_length (bar->priv->thumbs);
+                            if (g_list_next (thumb))
+                                size += spacing;
                         }
                         if ((size - thumb_size) <= bar->priv->offset)
                             bar->priv->offset = size - thumb_size;
@@ -823,8 +844,8 @@ cb_rstto_thumbnail_bar_scroll_event (RsttoThumbnailBar *bar,
                         for (thumb = bar->priv->thumbs; thumb != NULL; thumb = g_list_next(thumb))
                         {
                             size += GTK_WIDGET(thumb->data)->allocation.height;
-                            if (g_list_next(thumb))
-                                size += border_width;
+                            if (g_list_next (thumb))
+                                size += spacing;
                         }
                         if ((size - thumb_size) <= bar->priv->offset)
                             bar->priv->offset = size - thumb_size;


More information about the Xfce4-commits mailing list