I'm new to gtk+ and want to ask a newbie question, apologise if it has been asked before.
Suppose I create a toplevel gtkwindow, and add a gtkvbox to it. Then I add a menu, a toolbar, a gtkfixed, and a statusbar to the gtkvbox.
Code:
window=. 0{:: gtk_window_new <GTK_WINDOW_TOPLEVEL
gtk_window_set_title window ;< id
vbox1=. 0{:: gtk_vbox_new 0 ;< 0
gtk_widget_show <vbox1
gtk_container_add window ;< vbox1
NB. menubar
menubar1=. 0{:: gtk_menu_bar_new ''
gtk_box_pack_start vbox1 ; menubar1 ; 0 ; 0 ;< 0
NB. toolbar
toolbar1=. 0{:: gtk_toolbar_new ''
gtk_box_pack_start vbox1 ; toolbar1 ; 0 ; 0 ;< 0
NB. fixed
fixed1=. 0{:: gtk_fixed_new ''
gtk_widget_show <fixed1
gtk_box_pack_start vbox1 ; fixed1 ; 0 ; 0 ;< 0
NB. statusbar
statusbar1=. 0{:: gtk_statusbar_new ''
gtk_widget_show <statusbar1
gtk_statusbar_set_has_resize_grip statusbar1 ;< 0
gtk_box_pack_start vbox1 ; statusbar1 ; 0 ; 0 ;< 0
Then I want to get the pointer of each child using code
Code:
NB. get handle of child gtkfixed
g1=. 0{:: gtk_container_get_children <window
vbox1=. 0{:: g_list_nth_data g1 ;< 0
g2=. 0{:: gtk_container_get_children <vbox1
fixed1=. 0{:: g_list_nth_data g2 ;< 2 NB. menu toolbar fxied statusbar
g_list_free <g2
g_list_free <g1
Here fixed1 for g_list_nth_data is the 2 (index-0) child, but I might not create menu or toolbar so that the index method does not always work. What is the better way of finding fixed1?
PS. the programming language I used is not c/c++ but it directly call gtk+ api. Please interpret it as pseudo code for discussion.