Re: GtkAllocation accessor
- From: Patrick Welche <prlw1 cam ac uk>
- To: Tadej Borov??ak <tadeboro gmail com>
- Cc: gtk-list gnome org
- Subject: Re: GtkAllocation accessor
- Date: Tue, 1 Jun 2010 15:28:31 +0100
On Tue, Jun 01, 2010 at 04:21:40PM +0200, Tadej Borov??ak wrote:
> You don't need to free a because it's allocated on a stack.
OK!
> 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).
I was worrying about a code snippet which looks like:
CCanvas::CCanvas(GtkWidget *pCanvas, CPangoCache *pPangoCache)
: CDasherScreen(pCanvas->allocation.width, pCanvas->allocation.height) {
...
}
With "my" method, it would become
CCanvas::CCanvas(GtkWidget *pCanvas, CPangoCache *pPangoCache)
: CDasherScreen(gtk_widget_get_allocation(pCanvas)->width,
gtk_widget_get_allocation(pCanvas)->height) {
...
}
The work-around with the current definition doesn't look so pretty...
Cheers,
Patrick
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]