Re: list of goocanvas items



On Tue, Jul 17, 2012 at 11:55 AM, Damon Chaplin
<damon karuna eclipse co uk> wrote:
> 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

Ok thanks, I'll try it.


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