Re: GtkAllocation accessor

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

 



Hi.

> To use it, I need to
>
> GtkWidget *w = some_widget_new(some,properties);
> GtkAlloction a;
> gtk_widget_get_allocation(w, &a);
> make use of a->width and friends
> then free a?

You don't need to free a because it's allocated on a stack. Also, you
use a.width, not a->width when doing work.

> Wouldn't
>
> GtkAllocation * gtk_widget_get_allocation(GtkWidget *widget)
> {
>  return widget->allocation;
> }
>
> be easier to use / less of a memory management headache as the
> memory already is allocated and controlled by the widget?

Considering my previous comment, there is no memory management
involved here, so complexity is not increased.

This is how a code snippet looks now:

GtkAllocation a;
gtk_widget_get_allocation (w, &a);
do_some_calc (a.width, a.height);

and this is how it would look using your method:

GtkAllocation *a;
a = gtk_widget_get_allocation (a);
do_some_calc (a->width, a->height);

I fail to see much difference here, but the first method is definitely
safer (see my next comment).

> Any thoughts on why it was done this way / thoughts on the addition of
> say a gtk_widget_get_allocation_pointer()?

I'm not the GTK+ developer, but I would say that main reason for doing
this is making sure that application developer cannot inadvertently
change widget's allocation. With current access method, you're always
working with copies.


-- 
Tadej Borovšak
tadeboro.blogspot.com
tadeboro@xxxxxxxxx
tadej.borovsak@xxxxxxxxx
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux