sigsegv caught when I click a button.




Hi.. I appear to be having a problem with the button in gtk.  I only
started programming with it about two days ago, and for seom reason,
whenever I click on a button, it sigsegv's.  I've attached the code
and the machine that I am running on... Any help would be greatly
appreciated.

Here is the machine I am running it on:

# uname -a
OpenBSD envy 2.2 GENERIC#10 i386


-------
Here is the error I get when I run it:

# ./configsys 

** ERROR **: sigsegv caught

-------
Here is the code itself.  I can't find anything blatently wrong with it,
though I have changed the gtk_signal_connect a few times hoping it would
fix the problem.


#include "gtk/gtk.h"

int login (GtkWidget *widget, gpointer *data)
{

}

void destroy (void)
{
  gtk_exit (0);
}

void new_alias(GtkWidget *widget, gpointer *data)
{
   g_print("Clicked on new_alias: %s\n", (char *)data);
}


/******************************/
/* Print out the main screen. */
/******************************/
GtkWidget *printMain(void)
{
  GtkWidget *window, *table;
  GtkWidget *new_alias;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (destroy), NULL);
  gtk_window_set_title(GTK_WINDOW (window), "On Call Internet Services - User Configuration");
  gtk_container_border_width (GTK_CONTAINER (window), 10);
 
  /* Create a new table. */
  table = gtk_table_new(4,6,1);
  gtk_container_add(GTK_CONTAINER(window), table);

   /* Create the newalias button */
  new_alias = gtk_button_new_with_label ("New Alias");
  gtk_signal_connect(GTK_OBJECT(new_alias), "clicked", GTK_SIGNAL_FUNC (new_alias), (gpointer) "New Alias");
  gtk_table_attach_defaults(GTK_TABLE(table), new_alias, 0,1,0,1);
  gtk_widget_show(new_alias);

  gtk_widget_show (table);
  gtk_widget_show (window);

  return(window); 
}


/*******************************/
/* dologin shows login screen. */
/*******************************/

int dologin(void)
{
    GtkWidget *window, *table;
    GtkWidget *login, *cancel;
    GtkWidget *label, *username, *password;

    window = gtk_window_new(GTK_WINDOW_DIALOG);
    gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (destroy), NULL);

    gtk_window_set_title(GTK_WINDOW(window), "Login Dialog");
    gtk_container_border_width (GTK_CONTAINER (window), 10);
    gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);

    /* Create table in new dialog box. */
    table = gtk_table_new(4,6,1);
    gtk_container_add(GTK_CONTAINER(window), table);
   
    /* Create username label. */
    label = gtk_label_new("Username:  ");
    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
    gtk_widget_show(label);

    /* Create username text box. */
    username = gtk_entry_new_with_max_length(15);
    gtk_table_attach_defaults(GTK_TABLE(table), username, 2, 5, 0 , 1);

    /* Create password label. */
    label = gtk_label_new("Password:  ");
    gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2);
    gtk_widget_show(label);

    /* Create password text box. */
    password = gtk_entry_new_with_max_length(15);
    gtk_table_attach_defaults(GTK_TABLE(table), password, 2, 5, 1 , 2);

    /* Create the login button */
    login = gtk_button_new_with_label ("Login");
    gtk_signal_connect(GTK_OBJECT(login), "clicked", GTK_SIGNAL_FUNC(login), (gpointer) "Login");
    gtk_table_attach_defaults(GTK_TABLE(table), login, 1,2,3,4);

    /* Create the cancel button */
    cancel = gtk_button_new_with_label ("Cancel");
    gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(destroy), NULL);
    gtk_table_attach_defaults(GTK_TABLE(table), cancel, 4,5,3,4);

    /* Make the login button the default. */
//    GTK_WIDGET_SET_FLAGS(login, GTK_CAN_DEFAULT);
   
    gtk_widget_show(username);
    gtk_widget_show(password);
    gtk_widget_show(login);
    gtk_widget_show(cancel);
    gtk_widget_show (table);
    gtk_widget_show (window);
   
    return(0);
}

int
main (int argc, char **argv)
{ GtkWidget *window;
  int login = 0;

  gtk_init (&argc, &argv);

  window = printMain();
//  login = dologin();

  gtk_main ();

  return 0;
}





---
Michael Oswell
On Call Internet Services Ltd.




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