Segementation 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 menu with. But if ends in 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 *New_Server;
    GtkWidget *New_Client;
    GtkWidget *Exit;
    GtkWidget *File_Menu;
    GtkWidget *menu_bar;
    GtkWidget *vbox;   
    gtk_init (&argc,&argv);
   
    file_menu_box=gtk_menu_new();
   
    New_Server=gtk_menu_item_new_with_label("New_Server");
    New_Client=gtk_menu_item_new_with_label("New_Client");
    Exit=gtk_menu_item_new_with_label("Exit");
   
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),New_Server);
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),New_Client);   
    gtk_menu_shell_append(GTK_MENU_SHELL(file_menu_box),Exit);
    gtk_widget_show(New_Server);
    gtk_widget_show(New_Client);
    gtk_widget_show(Exit);

    //gtk_widget_show(file_menu_box);
   
    File_Menu=gtk_menu_item_new_with_label("File");   
    gtk_widget_show(File_Menu);
   
    gtk_menu_item_set_submenu(GTK_MENU_ITEM(File_Menu),file_menu_box);
   
   
    menu_bar=gtk_menu_bar_new();
    gtk_container_add(GTK_CONTAINER(window),menu_bar);
    gtk_widget_show(menu_bar);
   
    gtk_menu_bar_append(GTK_MENU_SHELL(menu_bar),File_Menu);
   
    gtk_widget_show(window);
        
   
    gtk_main();
   
    return 0;
}
   
   
   
   

Regards,
Sulabh Bista



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