Re: Question about GtkWidget pointer?

2002-07-31 Thread Sven Neumann

Hi,

"David Wang (Wang Xin-lu)" <[EMAIL PROTECTED]> writes:

> I wrote a function to create menu: 
> void setupMenu(GtkWidget *window, GtkWidget *menu_bar, GtkWidget *menu_vbox,
> GtkWidget *root_menu, GtkWidget *menu, char *labelname, gboolean boo)
> [...]
> why GtkWidget pointer can not take back value in a function?
> How can I do if I want to use the value initialized in a function?

this question is not at all GTK+ specific. Get yourself a book about C
and look for the subject "call by reference / call by value".


Salut, Sven
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list



Question about GtkWidget pointer?

2002-07-30 Thread David Wang (Wang Xin-lu)

Hi,

I wrote a function to create menu: 
void setupMenu(GtkWidget *window, GtkWidget *menu_bar, GtkWidget *menu_vbox,
GtkWidget *root_menu, GtkWidget *menu, char *labelname, gboolean boo)
{
if (menu_vbox == 0) {
menu_vbox = gtk_vbox_new(FALSE, 1);
gtk_container_border_width (GTK_CONTAINER(menu_vbox), 1);
gtk_container_add(GTK_CONTAINER (window), menu_vbox);
gtk_widget_show(menu_vbox);
printf("menu_vbox is 0\n");
printf("menu_vbox is %x\n", menu_vbox);
}

}

In the main function, I call it like this:
int main( int argc, char *argv[] )
{

...
GtkWidget *menu_vbox;
menu_vbox = 0;
...

setupMenu(window, menu_bar, menu_vbox,
root_menu, menu, "File", FALSE);
printf("after one menu_vbox is %x\n", menu_vbox);
..
}

I found that "menu_vbox" has value in setupMenu function, but it is "0" after
it.
If I call setupMenu more than 1 time, there has error:
: before menu_vbox is 0
menu_vbox is 0
menu_vbox is 3b090
menu_bar is 0
new root_menu with label
after one menu_vbox is 0

Gtk-CRITICAL **: file gtkbin.c: line 217 (gtk_bin_add): assertion `bin->child ==
NULL' failed.
menu_vbox is 0
menu_vbox is 3b320
menu_bar is 0
new root_menu with label
justify root_menu
after two menu_vbox is 0

why GtkWidget pointer can not take back value in a function?
How can I do if I want to use the value initialized in a function?

Thanks!
David
___
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list