Re: help on gtk.
- From: Michael Ott <michael king-coder de>
- To: sameer tandra <sameer tandra gmail com>
- Cc: gtk-list gnome org
- Subject: Re: help on gtk.
- Date: Wed, 13 Sep 2006 14:42:30 +0200
Hello Sameer!
> Hi I am Sameer.
> I am working on GTK. I have a problem when running the
> program i.e "Segmentation Fault".
>
> I am trying to add two buttons to the container window.First the window is
> displayed but when i tried to append the buttons to container it is giving
> runtime error.
>
> The program is as follows:
>
> #include <gtk/gtk.h>
>
> static void callback( GtkWidget *widget,
> gpointer data )
> {
> g_print ("Hello again - %s was pressed\n", (char *) data);
> }
>
> int main( int argc,
> char *argv[] )
> {
> GtkWidget *window;
> GtkWidget *button;
> GtkWidget *table;
>
> gtk_init (&argc, &argv);
>
> window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> gtk_window_set_title (GTK_WINDOW (window), "Table");
> g_signal_connect (G_OBJECT (window), "delete_event",
> G_CALLBACK (delete_event), NULL);
I missed the delete_event function. With that one it works for me
static gboolean delete_event(GtkWidget * widget,
GdkEvent * event, gpointer data)
{
return FALSE;
}
> gtk_container_set_border_width (GTK_CONTAINER (window), 20);
> table = gtk_table_new (2, 2, TRUE);
> gtk_container_add (GTK_CONTAINER (window), table);
> button = gtk_button_new_with_label ("button 1")
> g_signal_connect (G_OBJECT (button), "clicked",
> G_CALLBACK (callback), (gpointer) "button 1")
> gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1);
> gtk_widget_show (button);
> button = gtk_button_new_with_label ("button 2");
> g_signal_connect (G_OBJECT (button), "clicked",
> G_CALLBACK (callback), (gpointer) "button 2");
> gtk_table_attach_defaults (GTK_TABLE (table), button, 1, 2, 0, 1);
> gtk_widget_show (button);
> gtk_widget_show (table);
> gtk_widget_show (window);
> gtk_main ();
> return 0;
> }
>
> please help me.
>
> thanks in advance.
>
>
> regards,
>
>
> Sameer.T
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
CU
Michael
--
,''`. Michael Ott, e-mail: michael at zolnott dot de
: :' : Debian SID on Thinkpad T43:
`. `' http://www.zolnott.de/laptop/ibm-t43-uc34nge.html
`-
Jeden Mittwoch von 21 - 24 Uhr. Zosh! auf Radio Z.
Das Härteste, was der Musikmarkt zu bieten hat. http://www.zosh.de
Online hören: http://www.radio-z.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]