Re: GtkAllocation accessor
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-list gnome org
- Subject: Re: GtkAllocation accessor
- Date: Tue, 01 Jun 2010 15:26:32 +0100
On Tue, 2010-06-01 at 14:37 +0100, Patrick Welche wrote:
> Currently, gtk_widget_get_allocation is defined as:
>
> void
> gtk_widget_get_allocation (GtkWidget *widget,
> GtkAllocation *allocation)
> {
> g_return_if_fail (GTK_IS_WIDGET (widget));
> g_return_if_fail (allocation != NULL);
>
> *allocation = widget->allocation;
> }
>
>
> 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?
no, wrong.
you're passing a pointer to a structure placed on the stack, so you
access its member using the point syntax, not the arrow one. and you
don't have to allocate/free memory.
you can use the heap as well:
GtkAllocation *alloc = g_new0 (GtkAllocation, 1);
gtk_widget_get_allocation (widget, alloc);
/* use the arrow syntax here */
g_free (alloc);
> 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?
this part doesn't make sense.
ciao,
Emmanuele.
--
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]