Segmentation Fault [Newbie]



Dear all:

I am new to GTK. I am learning the basics like buttons, packing, signals
etc. and along with it trying to write a Nibbles like worm game.

The rough structure of the game is ready. Now I want to add a menu bar to
the game interface. But I am having problem with menus. Below is the program
which is supposed to display a simple menu. It compiles but when I run it,
it gives a segmentation fault.

Please review the program and suggest some solution:

-------------------------------------------------------------------------------------------------

#include <gtk/gtk.h>

int main(int argc, char **argv)
{

    GtkWidget *window;
    GtkWidget *file_menu_box;
    GtkWidget *Server;
    GtkWidget *Client;
    GtkWidget *Quit;
    GtkWidget *File;
    GtkWidget *menu_bar;

    gtk_init (&argc,&argv);

    menu_bar=gtk_menu_bar_new();

    file_menu_box=gtk_menu_new();
    File=gtk_menu_item_new_with_label("File");
    Server=gtk_menu_item_new_with_label("Server");
    Client=gtk_menu_item_new_with_label("Client");
    Quit=gtk_menu_item_new_with_label("Quit");


    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Server);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Client);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Quit);

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(File),file_menu_box);

    gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar),File);

    gtk_container_add(GTK_CONTAINER(window),menu_bar);

    gtk_widget_show_all(window);


    gtk_main();

    return 0;
}

-------------------------------------------------------------------------------------------------



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