Re: list of goocanvas items
- From: Damon Chaplin <damon karuna eclipse co uk>
- To: control H <control h gmail com>
- Cc: goocanvas-list gnome org
- Subject: Re: list of goocanvas items
- Date: Tue, 17 Jul 2012 10:55:53 +0100
On Tue, 2012-07-17 at 11:27 +0200, control H wrote:
> Dear list,
>
> I try to find all items belonging to a canvas. The function which
> comes close to what I'm looking for is goo_canvas_get_items_in_area()
> however, it doesn't allow me to find _all_ items, regardless whether
> they're inside or outside some area. I could use an "infinite" big
> area to capture all items but I don't like to put in some magic
> numbers. Is there another way to find all items?
I think you'll have to write your own function to traverse the tree,
something like this (this is untested and probably buggy!):
GList*
visit_item (GooCanvasItem *item, GList *item_list)
{
int n_children, i;
// Add the item to the list here if desired.
item_list = g_list_prepend (item_list, item);
n_children = goo_canvas_item_get_n_children (item);
for (i = 0; i < n_children; i++)
{
GooCanvasItem *child = goo_canvas_item_get_child (item, i);
item_list = visit_item (child, item_list);
}
return item_list;
}
then call it like this:
GList *item_list = visit_item (root_item, NULL);
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]