~ubuntu-branches/ubuntu/gutsy/goocanvas/gutsy

« back to all changes in this revision

Viewing changes to src/goocanvasimage.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-20 18:25:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070220182558-tjofc7wdzkzlxzor
Tags: 0.6-0ubuntu1
* New upstream version (UVF exception #86533):
  - Major rewrite to make the model optional, so people can choose to have
    either a simple canvas or a model/view canvas. The standard items can be
    used in either scenario.
  - Added support for cascading style properties (things like fill color, 
    stroke width, font etc.). Properties use a GQuark for a unique 
    identifier, and a GValue for the property value, so they are very 
    flexible.
  - Added GooCanvasTable item to layout child items.
  - Made it much easier to create new items, by subclassing 
    GooCanvasItemSimple which handles most of the work. See demo/demo-item.c 
    for a simple item.
  - Added support for different units - pixels, points, inches or 
    millimeters, and allow setting of vertical 
    and horizontal resolution (dpi).
  - Added workaround for cairo's 16-bit limit, to support large canvases.
  - Added demo/scalability-demo which creates 100,000 items over a large 
    canvas. It takes a few seconds to create all the items, but once created 
    it seems to work fast enough.
  - Improved the animation code, supporting relative or absolute values for
    the x, y, scale and rotation.
  - Added "clip-path" and "clip-fill-rule" to specify a clip path 
    for an item.
* debian/control:
  - updated GTK requirement to 2.10
* debian/control, debian/libgoocanvas0.install, debian/libgoocanvas1.install,
  debian/rules:
  - updated for soname change

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 *
24
24
 * To get or set the properties of an existing #GooCanvasImage, use
25
25
 * g_object_get() and g_object_set().
26
 
 *
27
 
 * To respond to events such as mouse clicks on the image you must connect
28
 
 * to the signal handlers of the corresponding #GooCanvasImageView objects.
29
 
 * (See goo_canvas_view_get_item_view() and #GooCanvasView::item-view-created.)
30
26
 */
31
27
#include <config.h>
32
28
#include <glib/gi18n-lib.h>
33
29
#include <gtk/gtk.h>
34
30
#include "goocanvasprivate.h"
35
31
#include "goocanvasimage.h"
36
 
#include "goocanvasimageview.h"
 
32
#include "goocanvas.h"
37
33
#include "goocanvasutils.h"
38
34
 
39
35
 
50
46
  PROP_PIXBUF
51
47
};
52
48
 
53
 
static void goo_canvas_image_finalize (GObject *object);
54
 
static void item_interface_init (GooCanvasItemIface *iface);
 
49
static void goo_canvas_image_finalize     (GObject            *object);
 
50
static void canvas_item_interface_init    (GooCanvasItemIface *iface);
55
51
static void goo_canvas_image_get_property (GObject            *object,
56
52
                                           guint               param_id,
57
53
                                           GValue             *value,
64
60
G_DEFINE_TYPE_WITH_CODE (GooCanvasImage, goo_canvas_image,
65
61
                         GOO_TYPE_CANVAS_ITEM_SIMPLE,
66
62
                         G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM,
67
 
                                                item_interface_init))
 
63
                                                canvas_item_interface_init))
68
64
 
69
65
 
70
66
static void
71
 
goo_canvas_image_class_init (GooCanvasImageClass *klass)
 
67
goo_canvas_image_install_common_properties (GObjectClass *gobject_class)
72
68
{
73
 
  GObjectClass *gobject_class = (GObjectClass*) klass;
74
 
 
75
 
  gobject_class->finalize = goo_canvas_image_finalize;
76
 
 
77
 
  gobject_class->get_property = goo_canvas_image_get_property;
78
 
  gobject_class->set_property = goo_canvas_image_set_property;
79
 
 
80
69
  g_object_class_install_property (gobject_class, PROP_PATTERN,
81
70
                                   g_param_spec_boxed ("pattern",
82
71
                                                       _("Pattern"),
124
113
 
125
114
 
126
115
static void
127
 
goo_canvas_image_init (GooCanvasImage *canvas_image)
 
116
goo_canvas_image_init (GooCanvasImage *image)
128
117
{
129
 
 
 
118
  image->image_data = g_slice_new0 (GooCanvasImageData);
130
119
}
131
120
 
132
121
 
138
127
 * @pixbuf: the #GdkPixbuf containing the image data, or %NULL.
139
128
 * @x: the x coordinate of the image.
140
129
 * @y: the y coordinate of the image.
141
 
 * @first_property: the name of the first property to set, or %NULL.
142
 
 * @...: the remaining property names and values to set, terminated with a
143
 
 *  %NULL.
 
130
 * @...: optional pairs of property names and values, and a terminating %NULL.
144
131
 * 
145
132
 * Creates a new image item.
146
133
 * 
161
148
                      GdkPixbuf     *pixbuf,
162
149
                      gdouble        x,
163
150
                      gdouble        y,
164
 
                      const gchar   *first_property,
165
151
                      ...)
166
152
{
167
153
  GooCanvasItem *item;
168
154
  GooCanvasImage *image;
169
 
  va_list args;
 
155
  GooCanvasImageData *image_data;
 
156
  const char *first_property;
 
157
  va_list var_args;
170
158
 
171
159
  item = g_object_new (GOO_TYPE_CANVAS_IMAGE, NULL);
172
 
  image = GOO_CANVAS_IMAGE (item);
173
 
 
174
 
  image->x = x;
175
 
  image->y = y;
176
 
 
177
 
  va_start (args, first_property);
178
 
  g_object_set_valist (G_OBJECT (item), first_property, args);
179
 
  va_end (args);
 
160
  image = (GooCanvasImage*) item;
 
161
 
 
162
  image_data = image->image_data;
 
163
  image_data->x = x;
 
164
  image_data->y = y;
180
165
 
181
166
  if (pixbuf)
182
167
    {
183
 
      image->pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
184
 
      image->width = gdk_pixbuf_get_width (pixbuf);
185
 
      image->height = gdk_pixbuf_get_height (pixbuf);
 
168
      image_data->pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
 
169
      image_data->width = gdk_pixbuf_get_width (pixbuf);
 
170
      image_data->height = gdk_pixbuf_get_height (pixbuf);
186
171
    }
187
172
 
 
173
  va_start (var_args, y);
 
174
  first_property = va_arg (var_args, char*);
 
175
  if (first_property)
 
176
    g_object_set_valist ((GObject*) item, first_property, var_args);
 
177
  va_end (var_args);
 
178
 
188
179
  if (parent)
189
180
    {
190
181
      goo_canvas_item_add_child (parent, item, -1);
198
189
static void
199
190
goo_canvas_image_finalize (GObject *object)
200
191
{
 
192
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) object;
201
193
  GooCanvasImage *image = (GooCanvasImage*) object;
202
194
 
203
 
  cairo_pattern_destroy (image->pattern);
 
195
  if (!simple->model)
 
196
    {
 
197
      cairo_pattern_destroy (image->image_data->pattern);
 
198
      g_slice_free (GooCanvasImageData, image->image_data);
 
199
    }
 
200
  image->image_data = NULL;
204
201
 
205
202
  G_OBJECT_CLASS (goo_canvas_image_parent_class)->finalize (object);
206
203
}
207
204
 
208
205
 
209
 
static GooCanvasItemView*
210
 
goo_canvas_image_create_view (GooCanvasItem     *item,
211
 
                              GooCanvasView     *canvas_view,
212
 
                              GooCanvasItemView *parent_view)
213
 
{
214
 
  return goo_canvas_image_view_new (canvas_view, parent_view,
215
 
                                    (GooCanvasImage*) item);
216
 
}
217
 
 
218
 
 
219
206
static void
220
 
item_interface_init (GooCanvasItemIface *iface)
 
207
goo_canvas_image_get_common_property (GObject              *object,
 
208
                                      GooCanvasImageData   *image_data,
 
209
                                      guint                 prop_id,
 
210
                                      GValue               *value,
 
211
                                      GParamSpec           *pspec)
221
212
{
222
 
  iface->create_view = goo_canvas_image_create_view;
 
213
  switch (prop_id)
 
214
    {
 
215
    case PROP_PATTERN:
 
216
      g_value_set_boxed (value, image_data->pattern);
 
217
      break;
 
218
    case PROP_X:
 
219
      g_value_set_double (value, image_data->x);
 
220
      break;
 
221
    case PROP_Y:
 
222
      g_value_set_double (value, image_data->y);
 
223
      break;
 
224
    case PROP_WIDTH:
 
225
      g_value_set_double (value, image_data->width);
 
226
      break;
 
227
    case PROP_HEIGHT:
 
228
      g_value_set_double (value, image_data->height);
 
229
      break;
 
230
    default:
 
231
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 
232
      break;
 
233
  }
223
234
}
 
235
 
224
236
 
225
237
 
226
238
static void
231
243
{
232
244
  GooCanvasImage *image = (GooCanvasImage*) object;
233
245
 
234
 
  switch (prop_id)
235
 
    {
236
 
    case PROP_PATTERN:
237
 
      g_value_set_boxed (value, image->pattern);
238
 
      break;
239
 
    case PROP_X:
240
 
      g_value_set_double (value, image->x);
241
 
      break;
242
 
    case PROP_Y:
243
 
      g_value_set_double (value, image->y);
244
 
      break;
245
 
    case PROP_WIDTH:
246
 
      g_value_set_double (value, image->width);
247
 
      break;
248
 
    case PROP_HEIGHT:
249
 
      g_value_set_double (value, image->height);
250
 
      break;
251
 
    default:
252
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
253
 
      break;
254
 
  }
 
246
  goo_canvas_image_get_common_property (object, image->image_data, prop_id,
 
247
                                        value, pspec);
255
248
}
256
249
 
257
250
 
258
 
 
259
251
static void
260
 
goo_canvas_image_set_property (GObject              *object,
261
 
                               guint                 prop_id,
262
 
                               const GValue         *value,
263
 
                               GParamSpec           *pspec)
 
252
goo_canvas_image_set_common_property (GObject              *object,
 
253
                                      GooCanvasImageData   *image_data,
 
254
                                      guint                 prop_id,
 
255
                                      const GValue         *value,
 
256
                                      GParamSpec           *pspec)
264
257
{
265
 
  GooCanvasImage *image = (GooCanvasImage*) object;
266
258
  GdkPixbuf *pixbuf;
267
259
 
268
260
  switch (prop_id)
269
261
    {
270
262
    case PROP_PATTERN:
271
 
      cairo_pattern_destroy (image->pattern);
272
 
      image->pattern = g_value_get_boxed (value);
273
 
      cairo_pattern_reference (image->pattern);
 
263
      cairo_pattern_destroy (image_data->pattern);
 
264
      image_data->pattern = g_value_get_boxed (value);
 
265
      cairo_pattern_reference (image_data->pattern);
274
266
      break;
275
267
    case PROP_X:
276
 
      image->x = g_value_get_double (value);
 
268
      image_data->x = g_value_get_double (value);
277
269
      break;
278
270
    case PROP_Y:
279
 
      image->y = g_value_get_double (value);
 
271
      image_data->y = g_value_get_double (value);
280
272
      break;
281
273
    case PROP_WIDTH:
282
 
      image->width = g_value_get_double (value);
 
274
      image_data->width = g_value_get_double (value);
283
275
      break;
284
276
    case PROP_HEIGHT:
285
 
      image->height = g_value_get_double (value);
 
277
      image_data->height = g_value_get_double (value);
286
278
      break;
287
279
    case PROP_PIXBUF:
288
 
      cairo_pattern_destroy (image->pattern);
 
280
      cairo_pattern_destroy (image_data->pattern);
289
281
      pixbuf = g_value_get_object (value);
290
 
      image->pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
291
 
      image->width = gdk_pixbuf_get_width (pixbuf);
292
 
      image->height = gdk_pixbuf_get_height (pixbuf);
 
282
      image_data->pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
 
283
      image_data->width = gdk_pixbuf_get_width (pixbuf);
 
284
      image_data->height = gdk_pixbuf_get_height (pixbuf);
293
285
      break;
294
286
    default:
295
287
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
296
288
      break;
297
289
  }
298
 
 
299
 
  g_signal_emit_by_name (image, "changed", TRUE);
300
 
}
 
290
}
 
291
 
 
292
 
 
293
static void
 
294
goo_canvas_image_set_property (GObject              *object,
 
295
                               guint                 prop_id,
 
296
                               const GValue         *value,
 
297
                               GParamSpec           *pspec)
 
298
{
 
299
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) object;
 
300
  GooCanvasImage *image = (GooCanvasImage*) object;
 
301
 
 
302
  if (simple->model)
 
303
    {
 
304
      g_warning ("Can't set property of a canvas item with a model - set the model property instead");
 
305
      return;
 
306
    }
 
307
 
 
308
  goo_canvas_image_set_common_property (object, image->image_data, prop_id,
 
309
                                        value, pspec);
 
310
  goo_canvas_item_simple_changed (simple, TRUE);
 
311
}
 
312
 
 
313
 
 
314
static GooCanvasItem*
 
315
goo_canvas_image_get_item_at (GooCanvasItemSimple *simple,
 
316
                              gdouble              x,
 
317
                              gdouble              y,
 
318
                              cairo_t             *cr,
 
319
                              gboolean             is_pointer_event)
 
320
{
 
321
  GooCanvasImage *image = (GooCanvasImage*) simple;
 
322
  GooCanvasImageData *image_data = image->image_data;
 
323
 
 
324
  if (x < image_data->x || (x > image_data->x + image_data->width)
 
325
      || y < image_data->y || (y > image_data->y + image_data->height))
 
326
    return NULL;
 
327
 
 
328
  return (GooCanvasItem*) simple;
 
329
}
 
330
 
 
331
 
 
332
static void
 
333
goo_canvas_image_update  (GooCanvasItemSimple  *simple,
 
334
                          cairo_t              *cr)
 
335
{
 
336
  GooCanvasImage *image = (GooCanvasImage*) simple;
 
337
  GooCanvasImageData *image_data = image->image_data;
 
338
 
 
339
  /* Compute the new bounds. */
 
340
  simple->bounds.x1 = image_data->x;
 
341
  simple->bounds.y1 = image_data->y;
 
342
  simple->bounds.x2 = image_data->x + image_data->width;
 
343
  simple->bounds.y2 = image_data->y + image_data->height;
 
344
}
 
345
 
 
346
 
 
347
static void
 
348
goo_canvas_image_paint (GooCanvasItemSimple *simple,
 
349
                        cairo_t             *cr,
 
350
                        GooCanvasBounds     *bounds)
 
351
{
 
352
  GooCanvasImage *image = (GooCanvasImage*) simple;
 
353
  GooCanvasImageData *image_data = image->image_data;
 
354
  cairo_matrix_t matrix;
 
355
 
 
356
  if (!image_data->pattern)
 
357
    return;
 
358
 
 
359
  goo_canvas_style_set_fill_options (simple->simple_data->style, cr);
 
360
  cairo_set_source (cr, image_data->pattern);
 
361
  cairo_matrix_init_translate (&matrix, -image_data->x, -image_data->y);
 
362
  cairo_pattern_set_matrix (image_data->pattern, &matrix);
 
363
  cairo_rectangle (cr, image_data->x, image_data->y,
 
364
                   image_data->width, image_data->height);
 
365
  cairo_fill (cr);
 
366
 
 
367
  /* Using cairo_paint() is much slower, so I guess we shouldn't. */
 
368
  /*cairo_paint (cr);*/
 
369
}
 
370
 
 
371
 
 
372
static void
 
373
goo_canvas_image_set_model    (GooCanvasItem      *item,
 
374
                               GooCanvasItemModel *model)
 
375
{
 
376
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
 
377
  GooCanvasImage *image = (GooCanvasImage*) item;
 
378
  GooCanvasImageModel *imodel = (GooCanvasImageModel*) model;
 
379
 
 
380
  /* If our data was allocated, free it. */
 
381
  if (!simple->model)
 
382
    {
 
383
      cairo_pattern_destroy (image->image_data->pattern);
 
384
      g_slice_free (GooCanvasImageData, image->image_data);
 
385
    }
 
386
 
 
387
  /* Now use the new model's data instead. */
 
388
  image->image_data = &imodel->image_data;
 
389
 
 
390
  /* Let the parent GooCanvasItemSimple code do the rest. */
 
391
  goo_canvas_item_simple_set_model (simple, model);
 
392
}
 
393
 
 
394
 
 
395
static void
 
396
canvas_item_interface_init (GooCanvasItemIface *iface)
 
397
{
 
398
  iface->set_model   = goo_canvas_image_set_model;
 
399
}
 
400
 
 
401
 
 
402
static void
 
403
goo_canvas_image_class_init (GooCanvasImageClass *klass)
 
404
{
 
405
  GObjectClass *gobject_class = (GObjectClass*) klass;
 
406
  GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
 
407
 
 
408
  gobject_class->finalize = goo_canvas_image_finalize;
 
409
 
 
410
  gobject_class->get_property = goo_canvas_image_get_property;
 
411
  gobject_class->set_property = goo_canvas_image_set_property;
 
412
 
 
413
  simple_class->simple_update      = goo_canvas_image_update;
 
414
  simple_class->simple_paint       = goo_canvas_image_paint;
 
415
  simple_class->simple_get_item_at = goo_canvas_image_get_item_at;
 
416
 
 
417
  goo_canvas_image_install_common_properties (gobject_class);
 
418
}
 
419
 
 
420
 
 
421
 
 
422
/**
 
423
 * SECTION:goocanvasimagemodel
 
424
 * @Title: GooCanvasImageModel
 
425
 * @Short_Description: a model for image items.
 
426
 *
 
427
 * GooCanvasImageModel represent a model for image items.
 
428
 *
 
429
 * It is a subclass of #GooCanvasItemModelSimple and so inherits all of the
 
430
 * style properties such as "operator" and "pointer-events".
 
431
 *
 
432
 * It also implements the #GooCanvasItemModel interface, so you can use the
 
433
 * #GooCanvasItemModel functions such as goo_canvas_item_model_raise() and
 
434
 * goo_canvas_item_model_rotate().
 
435
 *
 
436
 * To create a #GooCanvasImageModel use goo_canvas_image_model_new().
 
437
 *
 
438
 * To get or set the properties of an existing #GooCanvasImageModel, use
 
439
 * g_object_get() and g_object_set().
 
440
 *
 
441
 * To respond to events such as mouse clicks on the image you must connect
 
442
 * to the signal handlers of the corresponding #GooCanvasImage objects.
 
443
 * (See goo_canvas_get_item() and #GooCanvas::item-created.)
 
444
 */
 
445
 
 
446
static void item_model_interface_init (GooCanvasItemModelIface *iface);
 
447
static void goo_canvas_image_model_finalize     (GObject            *object);
 
448
static void goo_canvas_image_model_get_property (GObject            *object,
 
449
                                                 guint               param_id,
 
450
                                                 GValue             *value,
 
451
                                                 GParamSpec         *pspec);
 
452
static void goo_canvas_image_model_set_property (GObject            *object,
 
453
                                                 guint               param_id,
 
454
                                                 const GValue       *value,
 
455
                                                 GParamSpec         *pspec);
 
456
 
 
457
G_DEFINE_TYPE_WITH_CODE (GooCanvasImageModel, goo_canvas_image_model,
 
458
                         GOO_TYPE_CANVAS_ITEM_MODEL_SIMPLE,
 
459
                         G_IMPLEMENT_INTERFACE (GOO_TYPE_CANVAS_ITEM_MODEL,
 
460
                                                item_model_interface_init))
 
461
 
 
462
 
 
463
static void
 
464
goo_canvas_image_model_class_init (GooCanvasImageModelClass *klass)
 
465
{
 
466
  GObjectClass *gobject_class = (GObjectClass*) klass;
 
467
 
 
468
  gobject_class->finalize     = goo_canvas_image_model_finalize;
 
469
 
 
470
  gobject_class->get_property = goo_canvas_image_model_get_property;
 
471
  gobject_class->set_property = goo_canvas_image_model_set_property;
 
472
 
 
473
  goo_canvas_image_install_common_properties (gobject_class);
 
474
}
 
475
 
 
476
 
 
477
static void
 
478
goo_canvas_image_model_init (GooCanvasImageModel *emodel)
 
479
{
 
480
 
 
481
}
 
482
 
 
483
 
 
484
/**
 
485
 * goo_canvas_image_model_new:
 
486
 * @parent: the parent model, or %NULL. If a parent is specified, it will
 
487
 *  assume ownership of the item, and the item will automatically be freed when
 
488
 *  it is removed from the parent. Otherwise call g_object_unref() to free it.
 
489
 * @pixbuf: the #GdkPixbuf containing the image data, or %NULL.
 
490
 * @x: the x coordinate of the image.
 
491
 * @y: the y coordinate of the image.
 
492
 * @...: optional pairs of property names and values, and a terminating %NULL.
 
493
 * 
 
494
 * Creates a new image model.
 
495
 * 
 
496
 * <!--PARAMETERS-->
 
497
 *
 
498
 * Here's an example showing how to create an image at (100.0, 100.0), using
 
499
 * the given pixbuf at its natural width and height:
 
500
 *
 
501
 * <informalexample><programlisting>
 
502
 *  GooCanvasItemModel *image = goo_canvas_image_model_new (mygroup, pixbuf, 100.0, 100.0,
 
503
 *                                                          NULL);
 
504
 * </programlisting></informalexample>
 
505
 *
 
506
 * Returns: a new image model.
 
507
 **/
 
508
GooCanvasItemModel*
 
509
goo_canvas_image_model_new (GooCanvasItemModel *parent,
 
510
                            GdkPixbuf          *pixbuf,
 
511
                            gdouble             x,
 
512
                            gdouble             y,
 
513
                            ...)
 
514
{
 
515
  GooCanvasItemModel *model;
 
516
  GooCanvasImageModel *imodel;
 
517
  GooCanvasImageData *image_data;
 
518
  const char *first_property;
 
519
  va_list var_args;
 
520
 
 
521
  model = g_object_new (GOO_TYPE_CANVAS_IMAGE_MODEL, NULL);
 
522
  imodel = (GooCanvasImageModel*) model;
 
523
 
 
524
  image_data = &imodel->image_data;
 
525
  image_data->x = x;
 
526
  image_data->y = y;
 
527
 
 
528
  if (pixbuf)
 
529
    {
 
530
      image_data->pattern = goo_canvas_cairo_pattern_from_pixbuf (pixbuf);
 
531
      image_data->width = gdk_pixbuf_get_width (pixbuf);
 
532
      image_data->height = gdk_pixbuf_get_height (pixbuf);
 
533
    }
 
534
 
 
535
  va_start (var_args, y);
 
536
  first_property = va_arg (var_args, char*);
 
537
  if (first_property)
 
538
    g_object_set_valist ((GObject*) model, first_property, var_args);
 
539
  va_end (var_args);
 
540
 
 
541
  if (parent)
 
542
    {
 
543
      goo_canvas_item_model_add_child (parent, model, -1);
 
544
      g_object_unref (model);
 
545
    }
 
546
 
 
547
  return model;
 
548
}
 
549
 
 
550
 
 
551
static void
 
552
goo_canvas_image_model_finalize (GObject *object)
 
553
{
 
554
  GooCanvasImageModel *imodel = (GooCanvasImageModel*) object;
 
555
 
 
556
  cairo_pattern_destroy (imodel->image_data.pattern);
 
557
 
 
558
  G_OBJECT_CLASS (goo_canvas_image_model_parent_class)->finalize (object);
 
559
}
 
560
 
 
561
 
 
562
static void
 
563
goo_canvas_image_model_get_property (GObject              *object,
 
564
                                     guint                 prop_id,
 
565
                                     GValue               *value,
 
566
                                     GParamSpec           *pspec)
 
567
{
 
568
  GooCanvasImageModel *imodel = (GooCanvasImageModel*) object;
 
569
 
 
570
  goo_canvas_image_get_common_property (object, &imodel->image_data, prop_id,
 
571
                                        value, pspec);
 
572
}
 
573
 
 
574
 
 
575
static void
 
576
goo_canvas_image_model_set_property (GObject              *object,
 
577
                                     guint                 prop_id,
 
578
                                     const GValue         *value,
 
579
                                     GParamSpec           *pspec)
 
580
{
 
581
  GooCanvasImageModel *imodel = (GooCanvasImageModel*) object;
 
582
 
 
583
  goo_canvas_image_set_common_property (object, &imodel->image_data, prop_id,
 
584
                                        value, pspec);
 
585
  g_signal_emit_by_name (imodel, "changed", TRUE);
 
586
}
 
587
 
 
588
 
 
589
static GooCanvasItem*
 
590
goo_canvas_image_model_create_item (GooCanvasItemModel *model,
 
591
                                    GooCanvas          *canvas)
 
592
{
 
593
  GooCanvasItem *item;
 
594
 
 
595
  item = g_object_new (GOO_TYPE_CANVAS_IMAGE, NULL);
 
596
  goo_canvas_item_set_model (item, model);
 
597
 
 
598
  return item;
 
599
}
 
600
 
 
601
 
 
602
static void
 
603
item_model_interface_init (GooCanvasItemModelIface *iface)
 
604
{
 
605
  iface->create_item    = goo_canvas_image_model_create_item;
 
606
}
 
607