~ubuntu-branches/ubuntu/trusty/goocanvas/trusty-proposed

« back to all changes in this revision

Viewing changes to src/goocanvaswidget.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2007-05-14 22:49:11 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070514224911-vyv39khpicv46oe2
Tags: 0.8-2
Link gtk-doc to /usr/share/doc/libgoocanvas-dev (Closes: #423410)

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 
49
49
 
50
50
static void canvas_item_interface_init      (GooCanvasItemIface  *iface);
51
 
static void goo_canvas_widget_finalize      (GObject             *object);
 
51
static void goo_canvas_widget_dispose       (GObject             *object);
52
52
static void goo_canvas_widget_get_property  (GObject             *object,
53
53
                                             guint                param_id,
54
54
                                             GValue              *value,
124
124
  witem = (GooCanvasWidget*) item;
125
125
 
126
126
  witem->widget = widget;
 
127
  g_object_ref (witem->widget);
 
128
  g_object_set_data (G_OBJECT (witem->widget), "goo-canvas-item", witem);
 
129
 
127
130
  witem->x = x;
128
131
  witem->y = y;
129
132
  witem->width = width;
160
163
    {
161
164
      g_object_set_data (G_OBJECT (witem->widget), "goo-canvas-item", NULL);
162
165
      gtk_widget_unparent (witem->widget);
 
166
      g_object_unref (witem->widget);
163
167
      witem->widget = NULL;
164
168
    }
165
169
 
166
170
  if (widget)
167
171
    {
168
172
      witem->widget = widget;
 
173
      g_object_ref (witem->widget);
169
174
      g_object_set_data (G_OBJECT (witem->widget), "goo-canvas-item", witem);
170
175
 
171
176
      if (simple->simple_data->visibility <= GOO_CANVAS_ITEM_INVISIBLE)
186
191
 
187
192
 
188
193
static void
189
 
goo_canvas_widget_finalize (GObject *object)
 
194
goo_canvas_widget_dispose (GObject *object)
190
195
{
191
196
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) object;
192
197
  GooCanvasWidget *witem = (GooCanvasWidget*) object;
196
201
 
197
202
  goo_canvas_widget_set_widget (witem, NULL);
198
203
 
199
 
  G_OBJECT_CLASS (goo_canvas_widget_parent_class)->finalize (object);
 
204
  G_OBJECT_CLASS (goo_canvas_widget_parent_class)->dispose (object);
200
205
}
201
206
 
202
207
 
312
317
                                     GTK_WIDGET (simple->canvas));
313
318
            }
314
319
        }
 
320
      else
 
321
        {
 
322
          if (witem->widget)
 
323
            gtk_widget_unparent (witem->widget);
 
324
        }
315
325
    }
316
326
}
317
327
 
401
411
 
402
412
 
403
413
static void
404
 
goo_canvas_widget_allocate_area      (GooCanvasItem    *item,
405
 
                                      cairo_t          *cr,
406
 
                                      GooCanvasBounds  *requested_area,
407
 
                                      GooCanvasBounds  *allocated_area,
408
 
                                      gdouble           x_offset,
409
 
                                      gdouble           y_offset)
 
414
goo_canvas_widget_allocate_area      (GooCanvasItem         *item,
 
415
                                      cairo_t               *cr,
 
416
                                      const GooCanvasBounds *requested_area,
 
417
                                      const GooCanvasBounds *allocated_area,
 
418
                                      gdouble                x_offset,
 
419
                                      gdouble                y_offset)
410
420
{
411
421
  GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
412
422
  GooCanvasWidget *witem = (GooCanvasWidget*) item;
441
451
 
442
452
 
443
453
static void
444
 
goo_canvas_widget_paint (GooCanvasItemSimple *simple,
445
 
                         cairo_t             *cr,
446
 
                         GooCanvasBounds     *bounds)
 
454
goo_canvas_widget_paint (GooCanvasItemSimple   *simple,
 
455
                         cairo_t               *cr,
 
456
                         const GooCanvasBounds *bounds)
447
457
{
448
458
  /* Do nothing for now. Maybe render for printing in future. */
449
459
}
450
460
 
451
461
 
452
 
static GooCanvasItem*
453
 
goo_canvas_widget_get_item_at (GooCanvasItemSimple *simple,
454
 
                               gdouble              x,
455
 
                               gdouble              y,
456
 
                               cairo_t             *cr,
457
 
                               gboolean             is_pointer_event)
 
462
static gboolean
 
463
goo_canvas_widget_is_item_at (GooCanvasItemSimple *simple,
 
464
                              gdouble              x,
 
465
                              gdouble              y,
 
466
                              cairo_t             *cr,
 
467
                              gboolean             is_pointer_event)
458
468
{
459
 
  /* FIXME: Should we return the widget here? */
460
 
  return NULL;
 
469
  /* For now we just assume that the widget covers its entire bounds so we just
 
470
     return TRUE. In future if widget items support transforms we'll need to
 
471
     modify this. */
 
472
  return TRUE;
461
473
}
462
474
 
463
475
 
476
488
  GObjectClass *gobject_class = (GObjectClass*) klass;
477
489
  GooCanvasItemSimpleClass *simple_class = (GooCanvasItemSimpleClass*) klass;
478
490
 
479
 
  gobject_class->finalize = goo_canvas_widget_finalize;
 
491
  gobject_class->dispose = goo_canvas_widget_dispose;
480
492
 
481
493
  gobject_class->get_property = goo_canvas_widget_get_property;
482
494
  gobject_class->set_property = goo_canvas_widget_set_property;
483
495
 
484
496
  simple_class->simple_update        = goo_canvas_widget_update;
485
497
  simple_class->simple_paint         = goo_canvas_widget_paint;
486
 
  simple_class->simple_get_item_at   = goo_canvas_widget_get_item_at;
 
498
  simple_class->simple_is_item_at    = goo_canvas_widget_is_item_at;
487
499
 
488
500
  /* Register our accessible factory, but only if accessibility is enabled. */
489
501
  if (!ATK_IS_NO_OP_OBJECT_FACTORY (atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_WIDGET)))