GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how can i get widgets from a container?

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
firebat
Familiar Face


Joined: 19 Aug 2008
Posts: 11
Location: CD,Sichuan,China

PostPosted: Wed Aug 27, 2008 3:59 am    Post subject: how can i get widgets from a container? Reply with quote

i used a hbox for the label of notebook, and the hbox widget contains a label and a button.

now i need to modify the label text in the hbox

i can get the hbox by gtk_notebook_get_tab_label
but how can i get the label widget from the hbox?
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 505
Location: Portland, OR USA

PostPosted: Wed Aug 27, 2008 3:27 pm    Post subject: Reply with quote

Since you know that the label is the 2nd child of the HBox (assuming that's how you packed them) then you can use gtk_container_get_children () on the GtkHBox and then g_list_nth_data () to get the 1st element (0-indexed I think) to get a pointer to that widget. Something like this maybe:

Code: (C)
1
2
3
4
5
GList *children = gtk_container_get_children (hbox);
GtkWidget *label = g_list_nth_data (children, 1);
g_list_free (children);
g_assert (label);
Back to top
firebat
Familiar Face


Joined: 19 Aug 2008
Posts: 11
Location: CD,Sichuan,China

PostPosted: Thu Aug 28, 2008 12:34 am    Post subject: Reply with quote

i've already found this function, thanks
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP