Re: help......SEGMENTATION FAULT ERROR...
- From: John Cupitt <john cupitt ng-london org uk>
- To: nimeesh patel <nimeesh24 yahoo com>
- Cc: gtk-list gnome org
- Subject: Re: help......SEGMENTATION FAULT ERROR...
- Date: Mon, 06 Aug 2001 13:40:31 +0100
nimeesh patel wrote:
> i'm giving my simple source code below ..In that code if i make my Button
> References as a global ..it gives segmentation fault error ..I'm not getting
> why this is happening..because if button references are local then it work
> properly..
Hi Nimeesh, make a struct, put your dialog widgets in that, and pass the struct
address about. Like this:
#include <gtk/gtk.h>
typedef struct
{
GtkWidget *window;
GtkWidget *table;
GtkWidget *connect;
GtkWidget *disconnect;
}
MyDialog;
static void
start_connection (GtkWidget * wid, MyDialog * mydia)
{
gtk_widget_set_sensitive (mydia->connect, FALSE);
gtk_widget_set_sensitive (mydia->disconnect, TRUE);
}
void
end_connection (GtkWidget * wid, MyDialog * mydia)
{
gtk_widget_set_sensitive (mydia->connect, TRUE);
gtk_widget_set_sensitive (mydia->disconnect, FALSE);
}
int
main (int argc, char *argv[])
{
MyDialog mydia;
gtk_init (&argc, &argv);
mydia.window = gtk_window_new (GTK_WINDOW_DIALOG);
gtk_window_set_policy (GTK_WINDOW (mydia.window), FALSE, FALSE, FALSE);
gtk_window_set_title (GTK_WINDOW (mydia.window), "PPPoE for LINUX...");
gtk_signal_connect (GTK_OBJECT (mydia.window), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
gtk_widget_set_usize (mydia.window, 300, 300);
mydia.table = gtk_table_new (6, 3, TRUE);
gtk_container_add (GTK_CONTAINER (mydia.window), mydia.table);
mydia.connect = gtk_button_new_with_label ("Connect");
gtk_table_attach (GTK_TABLE (mydia.table), GTK_WIDGET (mydia.connect),
1, 2, 5, 6,
GTK_FILL, GTK_FILL,
5, 4);
gtk_signal_connect (GTK_OBJECT (mydia.connect), "clicked",
GTK_SIGNAL_FUNC (start_connection), &mydia);
mydia.disconnect = gtk_button_new_with_label ("Cancel");
gtk_table_attach (GTK_TABLE (mydia.table), GTK_WIDGET (mydia.disconnect),
2, 3, 5, 6,
GTK_FILL, GTK_FILL,
5, 4);
gtk_signal_connect (GTK_OBJECT (mydia.disconnect), "clicked",
GTK_SIGNAL_FUNC (end_connection), &mydia);
gtk_widget_set_sensitive (GTK_WIDGET (mydia.disconnect), FALSE);
gtk_widget_show_all (mydia.window);
gtk_main ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]