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

« back to all changes in this revision

Viewing changes to src/goocanvas.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:
117
117
  PROP_Y2,
118
118
  PROP_UNITS,
119
119
  PROP_RESOLUTION_X,
120
 
  PROP_RESOLUTION_Y
 
120
  PROP_RESOLUTION_Y,
 
121
  PROP_BACKGROUND_COLOR,
 
122
  PROP_BACKGROUND_COLOR_RGB
121
123
};
122
124
 
123
125
enum {
128
130
 
129
131
static guint canvas_signals[LAST_SIGNAL] = { 0 };
130
132
 
 
133
static void     goo_canvas_dispose         (GObject          *object);
131
134
static void     goo_canvas_finalize        (GObject          *object);
132
135
static void     goo_canvas_realize         (GtkWidget        *widget);
133
136
static void     goo_canvas_unrealize       (GtkWidget        *widget);
173
176
                                            guint             prop_id,
174
177
                                            const GValue     *value,
175
178
                                            GParamSpec       *pspec);
 
179
static void     goo_canvas_remove          (GtkContainer     *container,
 
180
                                            GtkWidget        *widget);
176
181
static void     goo_canvas_forall          (GtkContainer     *container,
177
182
                                            gboolean          include_internals,
178
183
                                            GtkCallback       callback,
198
203
  GtkWidgetClass *widget_class = (GtkWidgetClass*) klass;
199
204
  GtkContainerClass *container_class = (GtkContainerClass*) klass;
200
205
 
 
206
  gobject_class->dispose             = goo_canvas_dispose;
201
207
  gobject_class->finalize            = goo_canvas_finalize;
202
208
  gobject_class->get_property        = goo_canvas_get_property;
203
209
  gobject_class->set_property        = goo_canvas_set_property;
222
228
  widget_class->focus_out_event      = goo_canvas_focus_out;
223
229
  widget_class->grab_broken_event    = goo_canvas_grab_broken;
224
230
 
 
231
  container_class->remove            = goo_canvas_remove;
225
232
  container_class->forall            = goo_canvas_forall;
226
233
 
227
234
  klass->set_scroll_adjustments      = goo_canvas_set_adjustments;
306
313
                                                        96.0,
307
314
                                                        G_PARAM_READWRITE));
308
315
 
 
316
  /* Convenience properties - writable only. */
 
317
  g_object_class_install_property (gobject_class, PROP_BACKGROUND_COLOR,
 
318
                                   g_param_spec_string ("background-color",
 
319
                                                        _("Background Color"),
 
320
                                                        _("The color to use for the canvas background"),
 
321
                                                        NULL,
 
322
                                                        G_PARAM_WRITABLE));
 
323
 
 
324
  g_object_class_install_property (gobject_class, PROP_BACKGROUND_COLOR_RGB,
 
325
                                   g_param_spec_uint ("background-color-rgb",
 
326
                                                      _("Background Color RGB"),
 
327
                                                      _("The color to use for the canvas background, specified as a 24-bit integer value, 0xRRGGBB"),
 
328
                                                      0, G_MAXUINT, 0,
 
329
                                                      G_PARAM_WRITABLE));
309
330
 
310
331
  /**
311
332
   * GooCanvas::set-scroll-adjustments
412
433
  return GTK_WIDGET (g_object_new (GOO_TYPE_CANVAS, NULL));
413
434
}
414
435
 
415
 
 
416
436
static void
417
 
goo_canvas_finalize (GObject *object)
 
437
goo_canvas_dispose (GObject *object)
418
438
{
419
439
  GooCanvas *canvas = (GooCanvas*) object;
420
440
 
 
441
  if (canvas->model_to_item)
 
442
    {
 
443
      g_hash_table_destroy (canvas->model_to_item);
 
444
      canvas->model_to_item = NULL;
 
445
    }
 
446
 
421
447
  if (canvas->root_item)
422
 
    g_object_unref (canvas->root_item);
 
448
    {
 
449
      g_object_unref (canvas->root_item);
 
450
      canvas->root_item = NULL;
 
451
    }
423
452
 
424
453
  if (canvas->root_item_model)
425
 
    g_object_unref (canvas->root_item_model);
 
454
    {
 
455
      g_object_unref (canvas->root_item_model);
 
456
      canvas->root_item_model = NULL;
 
457
    }
426
458
 
427
459
  if (canvas->idle_id)
428
 
    g_source_remove (canvas->idle_id);
 
460
    {
 
461
      g_source_remove (canvas->idle_id);
 
462
      canvas->idle_id = 0;
 
463
    }
429
464
 
430
465
  /* Release any references we hold to items. */
431
466
  set_item_pointer (&canvas->pointer_item, NULL);
434
469
  set_item_pointer (&canvas->focused_item, NULL);
435
470
  set_item_pointer (&canvas->keyboard_grab_item, NULL);
436
471
 
437
 
  g_object_unref (canvas->hadjustment);
438
 
  g_object_unref (canvas->vadjustment);
439
 
 
440
 
  g_hash_table_destroy (canvas->model_to_item);
 
472
  if (canvas->hadjustment)
 
473
    {
 
474
      g_object_unref (canvas->hadjustment);
 
475
      canvas->hadjustment = NULL;
 
476
    }
 
477
 
 
478
  if (canvas->vadjustment)
 
479
    {
 
480
      g_object_unref (canvas->vadjustment);
 
481
      canvas->vadjustment = NULL;
 
482
    }
 
483
 
 
484
  G_OBJECT_CLASS (goo_canvas_parent_class)->dispose (object);
 
485
}
 
486
 
 
487
 
 
488
static void
 
489
goo_canvas_finalize (GObject *object)
 
490
{
 
491
  /*GooCanvas *canvas = (GooCanvas*) object;*/
441
492
 
442
493
  G_OBJECT_CLASS (goo_canvas_parent_class)->finalize (object);
443
494
}
478
529
}
479
530
 
480
531
 
481
 
static cairo_t*
482
 
goo_canvas_create_cairo (GooCanvas *canvas)
 
532
/**
 
533
 * goo_canvas_create_cairo_context:
 
534
 * @canvas: a #GooCanvas.
 
535
 * 
 
536
 * Creates a cairo context, initialized with the default canvas settings.
 
537
 * 
 
538
 * Returns: a new cairo context. It should be freed with cairo_destroy().
 
539
 **/
 
540
cairo_t*
 
541
goo_canvas_create_cairo_context (GooCanvas *canvas)
483
542
{
484
543
  cairo_t *cr;
485
544
 
487
546
 
488
547
  cr = gdk_cairo_create (canvas->canvas_window);
489
548
 
490
 
  /*cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);*/
 
549
  /* We use CAIRO_ANTIALIAS_GRAY as the default antialiasing mode, as that is
 
550
     what is recommended when using unhinted text. */
 
551
  cairo_set_antialias (cr, CAIRO_ANTIALIAS_GRAY);
491
552
 
492
553
  /* Set the default line width based on the current units setting. */
493
554
  cairo_set_line_width (cr, goo_canvas_get_default_line_width (canvas));
548
609
                            GParamSpec         *pspec)
549
610
{
550
611
  GooCanvas *canvas = (GooCanvas*) object;
 
612
  GdkColor color = { 0, 0, 0, 0, };
551
613
  gboolean need_reconfigure = FALSE;
 
614
  guint rgb;
552
615
 
553
616
  switch (prop_id)
554
617
    {
587
650
      canvas->resolution_y = g_value_get_double (value);
588
651
      need_reconfigure = TRUE;
589
652
      break;
 
653
    case PROP_BACKGROUND_COLOR:
 
654
      if (!g_value_get_string (value))
 
655
        gtk_widget_modify_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, NULL);
 
656
      else if (gdk_color_parse (g_value_get_string (value), &color))
 
657
        gtk_widget_modify_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, &color);
 
658
      else
 
659
        g_warning ("Unknown color: %s", g_value_get_string (value));
 
660
      break;
 
661
    case PROP_BACKGROUND_COLOR_RGB:
 
662
      rgb = g_value_get_uint (value);
 
663
      color.red   = ((rgb >> 16) & 0xFF) * 257;
 
664
      color.green = ((rgb >> 8)  & 0xFF) * 257;
 
665
      color.blue  = ((rgb)       & 0xFF) * 257;
 
666
      gtk_widget_modify_base ((GtkWidget*) canvas, GTK_STATE_NORMAL, &color);
 
667
      break;
590
668
 
591
669
    default:
592
670
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
630
708
                                GooCanvasItemModel *model)
631
709
{
632
710
  g_return_if_fail (GOO_IS_CANVAS (canvas));
 
711
  g_return_if_fail (GOO_IS_CANVAS_ITEM_MODEL (model));
633
712
 
634
713
  if (canvas->root_item_model == model)
635
714
    return;
698
777
                             GooCanvasItem      *item)
699
778
{
700
779
  g_return_if_fail (GOO_IS_CANVAS (canvas));
 
780
  g_return_if_fail (GOO_IS_CANVAS_ITEM (item));
701
781
 
702
782
  if (canvas->root_item == item)
703
783
    return;
754
834
{
755
835
  GooCanvasItem *item;
756
836
 
757
 
  item = g_hash_table_lookup (canvas->model_to_item, model);
 
837
  g_return_val_if_fail (GOO_IS_CANVAS (canvas), NULL);
 
838
  g_return_val_if_fail (GOO_IS_CANVAS_ITEM_MODEL (model), NULL);
 
839
 
 
840
  if (canvas->model_to_item)
 
841
    item = g_hash_table_lookup (canvas->model_to_item, model);
758
842
 
759
843
  /* If the item model has a canvas item check it is valid. */
760
844
  g_return_val_if_fail (!item || GOO_IS_CANVAS_ITEM (item), NULL);
773
857
 * 
774
858
 * Gets the item at the given point.
775
859
 * 
776
 
 * Returns: the item found at the given point, or %NULL if no item  was found.
 
860
 * Returns: the item found at the given point, or %NULL if no item was found.
777
861
 **/
778
862
GooCanvasItem*
779
863
goo_canvas_get_item_at (GooCanvas     *canvas,
782
866
                        gboolean       is_pointer_event)
783
867
{
784
868
  cairo_t *cr;
785
 
  GooCanvasItem *found;
786
 
 
787
 
  /* If no canvas model is set, just return NULL. */
788
 
  if (!canvas->root_item)
789
 
    return NULL;
790
 
 
791
 
  cr = goo_canvas_create_cairo (canvas);
792
 
  found = goo_canvas_item_get_item_at (canvas->root_item, x, y, cr,
793
 
                                       is_pointer_event, TRUE);
794
 
  cairo_destroy (cr);
795
 
 
796
 
  return found;
 
869
  GooCanvasItem *result = NULL;
 
870
  GList *list;
 
871
 
 
872
  g_return_val_if_fail (GOO_IS_CANVAS (canvas), NULL);
 
873
 
 
874
  /* If no root item is set, just return NULL. */
 
875
  if (!canvas->root_item)
 
876
    return NULL;
 
877
 
 
878
  cr = goo_canvas_create_cairo_context (canvas);
 
879
  list = goo_canvas_item_get_items_at (canvas->root_item, x, y, cr,
 
880
                                       is_pointer_event, TRUE, NULL);
 
881
  cairo_destroy (cr);
 
882
 
 
883
  /* We just return the top item in the list. */
 
884
  if (list)
 
885
    result = list->data;
 
886
 
 
887
  g_list_free (list);
 
888
 
 
889
  return result;
 
890
}
 
891
 
 
892
 
 
893
/**
 
894
 * goo_canvas_get_items_at:
 
895
 * @canvas: a #GooCanvas.
 
896
 * @x: the x coordinate of the point.
 
897
 * @y: the y coordinate of the point
 
898
 * @is_pointer_event: %TRUE if the "pointer-events" property of
 
899
 *  items should be used to determine which parts of the item are tested.
 
900
 * 
 
901
 * Gets all items at the given point.
 
902
 * 
 
903
 * Returns: a list of items found at the given point, with the top item at
 
904
 *  the start of the list, or %NULL if no items were found. The list must be
 
905
 *  freed with g_list_free().
 
906
 **/
 
907
GList*
 
908
goo_canvas_get_items_at (GooCanvas     *canvas,
 
909
                         gdouble        x,
 
910
                         gdouble        y,
 
911
                         gboolean       is_pointer_event)
 
912
{
 
913
  cairo_t *cr;
 
914
  GList *result;
 
915
 
 
916
  g_return_val_if_fail (GOO_IS_CANVAS (canvas), NULL);
 
917
 
 
918
  /* If no root item is set, just return NULL. */
 
919
  if (!canvas->root_item)
 
920
    return NULL;
 
921
 
 
922
  cr = goo_canvas_create_cairo_context (canvas);
 
923
  result = goo_canvas_item_get_items_at (canvas->root_item, x, y, cr,
 
924
                                         is_pointer_event, TRUE, NULL);
 
925
  cairo_destroy (cr);
 
926
 
 
927
  return result;
 
928
}
 
929
 
 
930
 
 
931
static GList*
 
932
goo_canvas_get_items_in_area_recurse (GooCanvas             *canvas,
 
933
                                      GooCanvasItem         *item,
 
934
                                      const GooCanvasBounds *area,
 
935
                                      gboolean               inside_area,
 
936
                                      gboolean               allow_overlaps,
 
937
                                      gboolean               include_containers,
 
938
                                      GList                 *found_items)
 
939
{
 
940
  GooCanvasBounds bounds;
 
941
  gboolean completely_inside = FALSE, completely_outside = FALSE;
 
942
  gboolean is_container, add_item = FALSE;
 
943
  gint n_children, i;
 
944
 
 
945
  /* First check the item/container itself. */
 
946
  goo_canvas_item_get_bounds (item, &bounds);
 
947
 
 
948
  is_container = goo_canvas_item_is_container (item);
 
949
 
 
950
  if (bounds.x1 >= area->x1 && bounds.x2 <= area->x2
 
951
      && bounds.y1 >= area->y1 && bounds.y2 <= area->y2)
 
952
    completely_inside = TRUE;
 
953
 
 
954
  if (bounds.x1 > area->x2 || bounds.x2 < area->x1
 
955
      || bounds.y1 > area->y2 || bounds.y2 < area->y1)
 
956
    completely_outside = TRUE;
 
957
 
 
958
  if (inside_area)
 
959
    {
 
960
      if (completely_inside
 
961
          || (allow_overlaps && !completely_outside))
 
962
        add_item = TRUE;
 
963
    }
 
964
  else
 
965
    {
 
966
      if (completely_outside
 
967
          || (allow_overlaps && !completely_inside))
 
968
        add_item = TRUE;
 
969
    }
 
970
 
 
971
  if (add_item && (!is_container || include_containers))
 
972
    found_items = g_list_prepend (found_items, item);
 
973
 
 
974
  /* Now check any children, if appropriate. */
 
975
  if ((inside_area && !completely_outside)
 
976
      || (!inside_area && !completely_inside))
 
977
    {
 
978
      n_children = goo_canvas_item_get_n_children (item);
 
979
      for (i = 0; i < n_children; i++)
 
980
        {
 
981
          GooCanvasItem *child = goo_canvas_item_get_child (item, i);
 
982
          found_items = goo_canvas_get_items_in_area_recurse (canvas, child,
 
983
                                                              area,
 
984
                                                              inside_area,
 
985
                                                              allow_overlaps,
 
986
                                                              include_containers,
 
987
                                                              found_items);
 
988
        }
 
989
    }
 
990
 
 
991
  return found_items;
 
992
}
 
993
 
 
994
 
 
995
/**
 
996
 * goo_canvas_get_items_in_area:
 
997
 * @canvas: a #GooCanvas.
 
998
 * @area: the area to compare with each item's bounds.
 
999
 * @inside_area: %TRUE if items inside @area should be returned, or %FALSE if
 
1000
 *  items outside @area should be returned.
 
1001
 * @allow_overlaps: %TRUE if items which are partly inside and partly outside
 
1002
 *  should be returned.
 
1003
 * @include_containers: %TRUE if containers should be checked as well as
 
1004
 *  normal items.
 
1005
 * 
 
1006
 * Gets a list of items inside or outside a given area.
 
1007
 * 
 
1008
 * Returns: a list of items in the given area, or %NULL if no items are found.
 
1009
 *  The list should be freed with g_list_free().
 
1010
 **/
 
1011
GList*
 
1012
goo_canvas_get_items_in_area (GooCanvas             *canvas,
 
1013
                              const GooCanvasBounds *area,
 
1014
                              gboolean               inside_area,
 
1015
                              gboolean               allow_overlaps,
 
1016
                              gboolean               include_containers)
 
1017
{
 
1018
  g_return_val_if_fail (GOO_IS_CANVAS (canvas), NULL);
 
1019
 
 
1020
  /* If no root item is set, just return NULL. */
 
1021
  if (!canvas->root_item)
 
1022
    return NULL;
 
1023
 
 
1024
  return goo_canvas_get_items_in_area_recurse (canvas, canvas->root_item,
 
1025
                                               area, inside_area,
 
1026
                                               allow_overlaps,
 
1027
                                               include_containers, NULL);
797
1028
}
798
1029
 
799
1030
 
1587
1818
 * @canvas: a #GooCanvas.
1588
1819
 * @model: the item model whose canvas item is being finalized.
1589
1820
 * 
1590
 
 * This function should be called in the finalize method of #GooCanvasItem
 
1821
 * This function is only intended to be used when implementing new canvas
 
1822
 * items.
 
1823
 *
 
1824
 * It should be called in the finalize method of #GooCanvasItem
1591
1825
 * objects, to remove the canvas item from the #GooCanvas's hash table.
1592
1826
 **/
1593
1827
void
1594
1828
goo_canvas_unregister_item (GooCanvas          *canvas,
1595
1829
                            GooCanvasItemModel *model)
1596
1830
{
1597
 
  g_hash_table_remove (canvas->model_to_item, model);
 
1831
  if (canvas->model_to_item)
 
1832
    g_hash_table_remove (canvas->model_to_item, model);
1598
1833
}
1599
1834
 
1600
1835
 
1603
1838
 * @canvas: a #GooCanvas.
1604
1839
 * @model: the item model to create a canvas item for.
1605
1840
 * 
1606
 
 * Creates a new canvas item for the given item model, and recursively creates
1607
 
 * items for any children.
 
1841
 * This function is only intended to be used when implementing new canvas
 
1842
 * items, typically container items such as #GooCanvasGroup.
 
1843
 *
 
1844
 * It creates a new canvas item for the given item model, and recursively
 
1845
 * creates items for any children.
1608
1846
 *
1609
1847
 * It uses the create_item() virtual method if it has been set.
1610
1848
 * Subclasses of #GooCanvas can define this method if they want to use
1630
1868
    item = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model)->create_item (model,
1631
1869
                                                                 canvas);
1632
1870
 
1633
 
  g_hash_table_insert (canvas->model_to_item, model, item);
 
1871
  if (canvas->model_to_item)
 
1872
    g_hash_table_insert (canvas->model_to_item, model, item);
1634
1873
 
1635
1874
  /* Emit a signal so apps can hook up signal handlers if they want. */
1636
1875
  g_signal_emit (canvas, canvas_signals[ITEM_CREATED], 0, item, model);
1664
1903
 * goo_canvas_update:
1665
1904
 * @canvas: a #GooCanvas.
1666
1905
 * 
1667
 
 * Updates any items that need updating.
1668
 
 *
1669
 
 * This is only intended to be used by subclasses of #GooCanvas or
 
1906
 * This function is only intended to be used by subclasses of #GooCanvas or
1670
1907
 * #GooCanvasItem implementations.
1671
1908
 *
 
1909
 * It updates any items that need updating.
 
1910
 *
1672
1911
 * If the bounds of items change, they will request a redraw of the old and
1673
1912
 * new bounds so the display is updated correctly.
1674
1913
 **/
1675
1914
void
1676
1915
goo_canvas_update (GooCanvas *canvas)
1677
1916
{
1678
 
  cairo_t *cr = goo_canvas_create_cairo (canvas);
 
1917
  cairo_t *cr = goo_canvas_create_cairo_context (canvas);
1679
1918
  goo_canvas_update_internal (canvas, cr);
1680
1919
  cairo_destroy (cr);
1681
1920
}
1703
1942
 * goo_canvas_request_update:
1704
1943
 * @canvas: a #GooCanvas.
1705
1944
 * 
1706
 
 * Schedules an update of the #GooCanvas. This will be performed in
 
1945
 * This function is only intended to be used by subclasses of #GooCanvas or
 
1946
 * #GooCanvasItem implementations.
 
1947
 *
 
1948
 * It schedules an update of the #GooCanvas. This will be performed in
1707
1949
 * the idle loop, after all pending events have been handled, but before
1708
1950
 * the canvas has been repainted.
1709
1951
 **/
1729
1971
 * @canvas: a #GooCanvas.
1730
1972
 * @bounds: the bounds to redraw.
1731
1973
 * 
 
1974
 * This function is only intended to be used by subclasses of #GooCanvas or
 
1975
 * #GooCanvasItem implementations.
 
1976
 *
1732
1977
 * Requests that the given bounds be redrawn.
1733
1978
 **/
1734
1979
void
1735
 
goo_canvas_request_redraw (GooCanvas       *canvas,
1736
 
                           GooCanvasBounds *bounds)
 
1980
goo_canvas_request_redraw (GooCanvas             *canvas,
 
1981
                           const GooCanvasBounds *bounds)
1737
1982
{
1738
1983
  GdkRectangle rect;
1739
1984
 
1773
2018
  if (event->window != canvas->canvas_window)
1774
2019
    return FALSE;
1775
2020
 
1776
 
  cr = goo_canvas_create_cairo (canvas);
 
2021
  cr = goo_canvas_create_cairo_context (canvas);
1777
2022
 
1778
2023
  if (canvas->need_update)
1779
2024
    goo_canvas_update_internal (canvas, cr);
1817
2062
 * Renders all or part of a canvas to the given cairo context.
1818
2063
 **/
1819
2064
void
1820
 
goo_canvas_render (GooCanvas       *canvas,
1821
 
                   cairo_t         *cr,
1822
 
                   GooCanvasBounds *bounds,
1823
 
                   gdouble          scale)
 
2065
goo_canvas_render (GooCanvas             *canvas,
 
2066
                   cairo_t               *cr,
 
2067
                   const GooCanvasBounds *bounds,
 
2068
                   gdouble                scale)
1824
2069
{
1825
2070
  /* Set the default line width based on the current units setting. */
1826
2071
  cairo_set_line_width (cr, goo_canvas_get_default_line_width (canvas));
1827
2072
 
1828
2073
  if (bounds)
1829
 
    goo_canvas_item_paint (canvas->root_item, cr, bounds, scale);
 
2074
    {
 
2075
      /* Clip to the given bounds. */
 
2076
      cairo_new_path (cr);
 
2077
      cairo_move_to (cr, bounds->x1, bounds->y1);
 
2078
      cairo_line_to (cr, bounds->x2, bounds->y1);
 
2079
      cairo_line_to (cr, bounds->x2, bounds->y2);
 
2080
      cairo_line_to (cr, bounds->x1, bounds->y2);
 
2081
      cairo_close_path (cr);
 
2082
      cairo_clip (cr);
 
2083
 
 
2084
      goo_canvas_item_paint (canvas->root_item, cr, bounds, scale);
 
2085
    }
1830
2086
  else
1831
 
    goo_canvas_item_paint (canvas->root_item, cr, &canvas->bounds, scale);
 
2087
    {
 
2088
      goo_canvas_item_paint (canvas->root_item, cr, &canvas->bounds, scale);
 
2089
    }
1832
2090
}
1833
2091
 
1834
2092
 
2036
2294
    {
2037
2295
      double x = canvas->crossing_event.x;
2038
2296
      double y = canvas->crossing_event.y;
2039
 
      cairo_t *cr;
2040
2297
 
2041
2298
      goo_canvas_convert_from_pixels (canvas, &x, &y);
2042
 
 
2043
 
      cr = goo_canvas_create_cairo (canvas);
2044
 
      new_item = goo_canvas_item_get_item_at (canvas->root_item, x, y, cr,
2045
 
                                              TRUE, TRUE);
2046
 
      cairo_destroy (cr);
 
2299
      new_item = goo_canvas_get_item_at (canvas, x, y, TRUE);
2047
2300
    }
2048
2301
 
2049
2302
  /* If the current item hasn't changed, just return. */
3175
3428
 * @canvas: a #GooCanvas.
3176
3429
 * @witem: a #GooCanvasWidget item.
3177
3430
 * 
3178
 
 * Registers a widget item with the canvas, so that the canvas can do the
 
3431
 * This function should only be used by #GooCanvasWidget and subclass
 
3432
 * implementations.
 
3433
 *
 
3434
 * It registers a widget item with the canvas, so that the canvas can do the
3179
3435
 * necessary actions to move and resize the widget as needed.
3180
 
 *
3181
 
 * This function should only be used by #GooCanvasWidget and subclass
3182
 
 * implementations.
3183
3436
 **/
3184
3437
void
3185
3438
goo_canvas_register_widget_item   (GooCanvas          *canvas,
3197
3450
 * @canvas: a #GooCanvas.
3198
3451
 * @witem: a #GooCanvasWidget item.
3199
3452
 * 
3200
 
 * Unregisters a widget item from the canvas, when the item is no longer in
 
3453
 * This function should only be used by #GooCanvasWidget and subclass
 
3454
 * implementations.
 
3455
 *
 
3456
 * It unregisters a widget item from the canvas, when the item is no longer in
3201
3457
 * the canvas.
3202
 
 *
3203
 
 * This function should only be used by #GooCanvasWidget and subclass
3204
 
 * implementations.
3205
3458
 **/
3206
3459
void
3207
3460
goo_canvas_unregister_widget_item (GooCanvas          *canvas,
3256
3509
        (* callback) (witem->widget, callback_data);
3257
3510
    }
3258
3511
}
 
3512
 
 
3513
 
 
3514
static void
 
3515
goo_canvas_remove (GtkContainer *container, 
 
3516
                   GtkWidget    *widget)
 
3517
{
 
3518
  GooCanvas *canvas;
 
3519
  GList *tmp_list;
 
3520
  GooCanvasWidget *witem;
 
3521
  GooCanvasItem *parent;
 
3522
  gint child_num;
 
3523
  
 
3524
  g_return_if_fail (GOO_IS_CANVAS (container));
 
3525
  
 
3526
  canvas = GOO_CANVAS (container);
 
3527
 
 
3528
  tmp_list = canvas->widget_items;
 
3529
  while (tmp_list)
 
3530
    {
 
3531
      witem = tmp_list->data;
 
3532
      tmp_list = tmp_list->next;
 
3533
 
 
3534
      if (witem->widget == widget)
 
3535
        {
 
3536
          parent = goo_canvas_item_get_parent ((GooCanvasItem*) witem);
 
3537
          child_num = goo_canvas_item_find_child (parent,
 
3538
                                                  (GooCanvasItem*) witem);
 
3539
          goo_canvas_item_remove_child (parent, child_num);
 
3540
 
 
3541
          break;
 
3542
        }
 
3543
    }
 
3544
}