[gtk+/wip/baedert/gtkimageview] imageview: Fix size request



commit 071c4a7bf01f2222a0f6f846fc964e48151feed0
Author: Timm Bäder <mail baedert org>
Date:   Sat May 14 08:39:38 2016 +0200

    imageview: Fix size request

 gtk/gtkimageview.c |   57 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkimageview.c b/gtk/gtkimageview.c
index 142ec45..4b1530b 100644
--- a/gtk/gtkimageview.c
+++ b/gtk/gtkimageview.c
@@ -91,17 +91,17 @@ struct _GtkImageViewPrivate
   double   scale;
   double   angle;
 
-  gboolean fit_allocation      : 1;
-  gboolean scale_set           : 1;
-  gboolean snap_angle          : 1;
-  gboolean rotatable           : 1;
-  gboolean zoomable            : 1;
-  gboolean in_rotate           : 1;
-  gboolean in_zoom             : 1;
-  gboolean size_valid          : 1;
-  gboolean transitions_enabled : 1;
-  gboolean in_angle_transition : 1;
-  gboolean in_scale_transition : 1;
+  guint fit_allocation      : 1;
+  guint scale_set           : 1;
+  guint snap_angle          : 1;
+  guint rotatable           : 1;
+  guint zoomable            : 1;
+  guint in_rotate           : 1;
+  guint in_zoom             : 1;
+  guint size_valid          : 1;
+  guint transitions_enabled : 1;
+  guint in_angle_transition : 1;
+  guint in_scale_transition : 1;
 
   GtkProgressTracker scale_tracker;
   GtkProgressTracker angle_tracker;
@@ -264,7 +264,10 @@ gtk_image_view_transitions_enabled (GtkImageView *image_view)
                 "gtk-enable-animations", &animations_enabled,
                 NULL);
 
-  return priv->transitions_enabled && animations_enabled && priv->image;
+  return priv->transitions_enabled &&
+         animations_enabled &&
+         priv->image &&
+         gtk_widget_get_mapped (GTK_WIDGET (image_view));
 }
 
 static void
@@ -1787,19 +1790,20 @@ gtk_image_view_get_preferred_height (GtkWidget *widget,
   GtkImageView *image_view  = GTK_IMAGE_VIEW (widget);
   GtkImageViewPrivate *priv = gtk_image_view_get_instance_private (image_view);
 
-  double width, height;
-  gtk_image_view_compute_bounding_box (image_view,
-                                       &width,
-                                       &height,
-                                       NULL);
 
-  if (priv->fit_allocation)
+
+  if (priv->fit_allocation && priv->image)
     {
       *minimal = 0;
-      *natural = height;
+      *natural = gtk_abstract_image_get_height (priv->image);
     }
   else
     {
+      double width, height;
+      gtk_image_view_compute_bounding_box (image_view,
+                                           &width,
+                                           &height,
+                                           NULL);
       *minimal = height;
       *natural = height;
     }
@@ -1812,19 +1816,20 @@ gtk_image_view_get_preferred_width (GtkWidget *widget,
 {
   GtkImageView *image_view  = GTK_IMAGE_VIEW (widget);
   GtkImageViewPrivate *priv = gtk_image_view_get_instance_private (image_view);
-  double width, height;
 
-  gtk_image_view_compute_bounding_box (image_view,
-                                       &width,
-                                       &height,
-                                       NULL);
-  if (priv->fit_allocation)
+  if (priv->fit_allocation && priv->image)
     {
       *minimal = 0;
-      *natural = width;
+      *natural = gtk_abstract_image_get_width (priv->image);
     }
   else
     {
+      double width, height;
+
+      gtk_image_view_compute_bounding_box (image_view,
+                                           &width,
+                                           &height,
+                                           NULL);
       *minimal = width;
       *natural = width;
     }


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