[gnome-photos/wip/rishi/edit-mode: 29/30] crop



commit 45653d57ec71cee439ec7248a686a69b7db822a7
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Jun 13 01:19:19 2015 +0200

    crop

 src/photos-tool-crop.c |   36 ++++++++++++++++++++++++++++++++++--
 1 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-tool-crop.c b/src/photos-tool-crop.c
index 4eaf1f8..fe791e1 100644
--- a/src/photos-tool-crop.c
+++ b/src/photos-tool-crop.c
@@ -77,6 +77,27 @@ static PhotosToolCropConstraint CONSTRAINTS[] =
 };
 
 
+static void
+photos_tool_crop_draw (PhotosTool *tool, cairo_t *cr, GdkRectangle *rect)
+{
+  cairo_t *cr1;
+  cairo_surface_t *surface;
+
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, rect->width, rect->height);
+  cr1 = cairo_create (surface);
+  cairo_set_source_rgba (cr1, 0.0, 0.0, 0.0, 0.5);
+  cairo_paint (cr1);
+
+  cairo_save (cr);
+  cairo_set_source_surface (cr, surface, rect->x, rect->y);
+  cairo_paint (cr);
+  cairo_restore (cr);
+
+  cairo_destroy (cr1);
+  cairo_surface_destroy (surface);
+}
+
+
 static const gchar *
 photos_tool_crop_get_icon_name (PhotosTool *tool)
 {
@@ -94,7 +115,8 @@ photos_tool_crop_get_name (PhotosTool *tool)
 static GtkWidget *
 photos_tool_crop_get_widget (PhotosTool *tool)
 {
-  return NULL;
+  PhotosToolCrop *self = PHOTOS_TOOL_CROP (tool);
+  return self->combo_box;
 }
 
 
@@ -104,6 +126,7 @@ photos_tool_crop_dispose (GObject *object)
   PhotosToolCrop *self = PHOTOS_TOOL_CROP (object);
 
   g_clear_object (&self->model);
+  g_clear_object (&self->combo_box);
 
   G_OBJECT_CLASS (photos_tool_crop_parent_class)->dispose (object);
 }
@@ -114,13 +137,14 @@ photos_tool_crop_finalize (GObject *object)
 {
   PhotosToolCrop *self = PHOTOS_TOOL_CROP (object);
 
-  G_OBJECT_CLASS (photos_tool_crop_parent_class)->dispose (object);
+  G_OBJECT_CLASS (photos_tool_crop_parent_class)->finalize (object);
 }
 
 
 static void
 photos_tool_crop_init (PhotosToolCrop *self)
 {
+  GtkCellRenderer *renderer;
   guint i;
 
   self->model = gtk_list_store_new (4, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT);
@@ -138,6 +162,13 @@ photos_tool_crop_init (PhotosToolCrop *self)
                           CONSTRAINT_COLUMN_BASIS_WIDTH, CONSTRAINTS[i].basis_width,
                           -1);
     }
+
+  self->combo_box = g_object_ref_sink (gtk_combo_box_new_with_model (GTK_TREE_MODEL (self->model)));
+  gtk_combo_box_set_active (GTK_COMBO_BOX (self->combo_box), 0);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (self->combo_box), renderer, TRUE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (self->combo_box), renderer, "text", 
CONSTRAINT_COLUMN_NAME);
 }
 
 
@@ -149,6 +180,7 @@ photos_tool_crop_class_init (PhotosToolCropClass *class)
 
   object_class->dispose = photos_tool_crop_dispose;
   object_class->finalize = photos_tool_crop_finalize;
+  tool_class->draw = photos_tool_crop_draw;
   tool_class->get_icon_name = photos_tool_crop_get_icon_name;
   tool_class->get_name = photos_tool_crop_get_name;
   tool_class->get_widget = photos_tool_crop_get_widget;


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