[gnome-photos] tool-crop: Handle size-allocate after the correct zoom factor is known



commit cf7fe5c3c62d90b7fd48982990520020d06d9898
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Feb 11 10:49:51 2016 +0100

    tool-crop: Handle size-allocate after the correct zoom factor is known
    
    For the same reasons as the previous commit.

 src/photos-tool-crop.c |   66 ++++++++++++++++++++++++++---------------------
 1 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/src/photos-tool-crop.c b/src/photos-tool-crop.c
index 51d186e..7bd2a72 100644
--- a/src/photos-tool-crop.c
+++ b/src/photos-tool-crop.c
@@ -852,6 +852,30 @@ photos_tool_crop_set_active (PhotosToolCrop *self, gint active)
 
 
 static void
+photos_tool_crop_size_allocate (PhotosToolCrop *self, GdkRectangle *allocation)
+{
+  gdouble crop_height_ratio;
+  gdouble crop_width_ratio;
+  gdouble crop_x_ratio;
+  gdouble crop_y_ratio;
+
+  crop_height_ratio = self->crop_height / (gdouble) self->bbox_zoomed.height;
+  crop_width_ratio = self->crop_width / (gdouble) self->bbox_zoomed.width;
+  crop_x_ratio = self->crop_x / (gdouble) self->bbox_zoomed.width;
+  crop_y_ratio = self->crop_y / (gdouble) self->bbox_zoomed.height;
+
+  photos_tool_crop_surface_create (self);
+
+  self->crop_height = crop_height_ratio * (gdouble) self->bbox_zoomed.height;
+  self->crop_width = crop_width_ratio * (gdouble) self->bbox_zoomed.width;
+  self->crop_x = crop_x_ratio * (gdouble) self->bbox_zoomed.width;
+  self->crop_y = crop_y_ratio * (gdouble) self->bbox_zoomed.height;
+
+  photos_tool_crop_surface_draw (self);
+}
+
+
+static void
 photos_tool_crop_process (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
   PhotosToolCrop *self = PHOTOS_TOOL_CROP (user_data);
@@ -882,6 +906,12 @@ photos_tool_crop_process (GObject *source_object, GAsyncResult *res, gpointer us
 
   photos_tool_crop_surface_draw (self);
 
+  self->size_allocate_id = g_signal_connect_object (self->view,
+                                                    "size-allocate",
+                                                    G_CALLBACK (photos_tool_crop_size_allocate),
+                                                    self,
+                                                    G_CONNECT_SWAPPED);
+
  out:
   gtk_widget_queue_draw (self->view);
   g_object_unref (self);
@@ -898,30 +928,6 @@ photos_tool_crop_reset_clicked (PhotosToolCrop *self)
 
 
 static void
-photos_tool_crop_size_allocate (PhotosToolCrop *self, GdkRectangle *allocation)
-{
-  gdouble crop_height_ratio;
-  gdouble crop_width_ratio;
-  gdouble crop_x_ratio;
-  gdouble crop_y_ratio;
-
-  crop_height_ratio = self->crop_height / (gdouble) self->bbox_zoomed.height;
-  crop_width_ratio = self->crop_width / (gdouble) self->bbox_zoomed.width;
-  crop_x_ratio = self->crop_x / (gdouble) self->bbox_zoomed.width;
-  crop_y_ratio = self->crop_y / (gdouble) self->bbox_zoomed.height;
-
-  photos_tool_crop_surface_create (self);
-
-  self->crop_height = crop_height_ratio * (gdouble) self->bbox_zoomed.height;
-  self->crop_width = crop_width_ratio * (gdouble) self->bbox_zoomed.width;
-  self->crop_x = crop_x_ratio * (gdouble) self->bbox_zoomed.width;
-  self->crop_y = crop_y_ratio * (gdouble) self->bbox_zoomed.height;
-
-  photos_tool_crop_surface_draw (self);
-}
-
-
-static void
 photos_tool_crop_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *view)
 {
   PhotosToolCrop *self = PHOTOS_TOOL_CROP (tool);
@@ -971,13 +977,13 @@ photos_tool_crop_activate (PhotosTool *tool, PhotosBaseItem *item, GeglGtkView *
     {
       photos_tool_crop_surface_create (self);
       photos_tool_crop_init_crop (self);
-    }
 
-  self->size_allocate_id = g_signal_connect_object (self->view,
-                                                    "size-allocate",
-                                                    G_CALLBACK (photos_tool_crop_size_allocate),
-                                                    self,
-                                                    G_CONNECT_SWAPPED);
+      self->size_allocate_id = g_signal_connect_object (self->view,
+                                                        "size-allocate",
+                                                        G_CALLBACK (photos_tool_crop_size_allocate),
+                                                        self,
+                                                        G_CONNECT_SWAPPED);
+    }
 
   self->activated = TRUE;
   self->reset = FALSE;


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