RE: Dynamically adding a wiget to a container created by glade



On Thu, 2008-12-11 at 04:38 +0530, Ravee Kondrakunta wrote:
Yes,

I had set it. Any other input. Is this the right way to do. Becase I am getting the instance created by 
glade and using that I was trying to add new widget.

The instance created by glade is nothing more mysterious than an
instance created by yourself.

I was adding some misc widgets to a Glade-created container. There was
no problem, expect i always forget to do a gtk_widget_show_all for the
child widget to be added.

My suggestion for you on this problem is to make a window by yourself
with a HBox in it, and see if your newly added widget shows up with your
code.

Do a g_assert(((GtkWidget*)lab)->parent == hbox)) to see if the widget
is added to the parent before you show_all on the hbox.

Best,

- Yu

-Ravee
________________________________________
From: Yu Feng [rainwoodman gmail com]
Sent: Wednesday, December 10, 2008 2:57 PM
To: Ravee Kondrakunta
Cc: gtk-app-devel-list gnome org
Subject: Re: Dynamically adding a wiget to a container created by glade

On Thu, 2008-12-11 at 03:52 +0530, Ravee Kondrakunta wrote:
Hi,

I created a dialog with glade. In this dialog, I have a HBox with two widgets, one is the label and the 
other widget will be determined at the runtime.

In the code I got the reference to the HBox using get_widget after loading the glade file and then I am 
adding my widget to the HBox using the reference from the XML. The code compiles properly, but the widget 
is never shown.

Here is sample code for that...

xmlRef = Gnome::Glade::create("myglade.glade");
Gtk::HBox *pMyHBox;
xmlRef->get_widget("myHBox", pMyHBox);

Lets us assume I need to add one more label the the "myHBox"

Gtk::Label lab("new");
pMyHBox->add(lab); or
pMyHBox->pack_start(lab); or
pMyHBox->pack_end(lab); etc..

I tried all possible ways to show it.. Unfortunately, I couldn't see it on my dialog.

Please help me where I was wrong...

you have to set the 'visible' property of your new widget to 'true'.

-Ravee
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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