Re: [gtk-list] Re: GTK--: Gtk_Notebook::append_page question
- From: Tero Pulkkinen <terop students cc tut fi>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: GTK--: Gtk_Notebook::append_page question
- Date: 15 Jul 1998 01:12:19 +0300
> > With all gtk-- containers, including notebooks, the ownership of the
> > items inserted to it are NOT transferred to the container. Thus you
> > must delete everything yourself what you allocate.
Ionut Borcoman at home <borco@mailbox.ro> writes:
> Than my style of appending is not good. :( And I have to keep a lot of
> variables, otherwise not needed. The biggest problem is how to name all
> this bunch of widgets ! :)
>
> And it means that the piece of code from bellow is also leaving some
> memory that cannot be freed, isn't it ?
Yuup.
I usually put the widgets embedded to some object. This gets rid of
extra memory allocation as all widgets embedded to one object only need
one "malloc()" call. LIke this:
class mainwindow : public Gtk_Window {
public:
Gtk_Button ok_button, cancel_button, red_button;
};
This way destroying them becomes easier too as their lifetime
is tied to the mainwindow's lifetime. Sometimes using pointer
there too is useful to limit the size of mainwindow object - this
way objects tend to become quite large. (but faster to create, not
that it really matters anything here)
> Gtk_Label *label;
> label = new Gtk_Label("xxx");
> table0.attach( label, 0, 1, row, row+1, GTK_FILL, GTK_FILL);
> label->set_alignment( 0.0, 0.5 );
> label->show();
hmm.. maybe I should add such support and add a specific
attach_and_move_ownership() method.. Anyone got good ideas for names
of such methods?. This way using this design becomes easier..
of course such version should be added also for other container add methods.
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]