Re: GtkAllocation accessor

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

 



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
_______________________________________________
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