Re: a question about widgets...



Hi,

Adriano Bonat <adrianobonat yahoo com br> writes:

> This is my first message, then go there:
> Why this code bellow don't function?

there are a few mistakes; I'll outline them below...

>   button = gtk_button_new_with_label("Click here!");
>   gtk_container_add(GTK_CONTAINER(window), button);
>   gtk_signal_connect(GTK_OBJECT(button), "clicked",
> GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(0));
> 
>   button1 = gtk_button_new_with_label("Windows");
>   gtk_signal_connect(GTK_OBJECT(button1), "clicked",
> GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(1));
> 
>   button2 = gtk_button_new_with_label("Linux");
>   gtk_signal_connect(GTK_OBJECT(button1), "clicked",
> GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(2));

you don't connect the button2 at all, instead you connect button1 two
times.

> void button_click(GtkWidget *b, gpointer data)
> {
>   switch((int)data)

you should use GPOINTER_TO_INT() since the simple cast will not work
on some platforms (namely 64bit platforms).

Apart from that, you should consider to use the GTK+-2.x API. Your
code is using the deprecated 1.2 API which is not any longer
maintained.


Salut, Sven



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