initialize gnome and fir up the main window */
| 571 | |
| 572 | /* initialize gnome and fir up the main window */ |
| 573 | void |
| 574 | ghack_init_main_window(int argc, char **argv) |
| 575 | { |
| 576 | int i; |
| 577 | struct timeval tv; |
| 578 | uid_t uid, euid; |
| 579 | |
| 580 | /* It seems that the authors of gnome_score_init() drop group |
| 581 | * priveledges. We need group priveledges, so until we change the |
| 582 | * way we save games to do things the gnome way(???), this stays |
| 583 | * commented out. (after hours of frusteration...) |
| 584 | * -Erik |
| 585 | */ |
| 586 | /* gnome_score_init("gnomehack"); */ |
| 587 | |
| 588 | gettimeofday(&tv, NULL); |
| 589 | srand(tv.tv_usec); |
| 590 | |
| 591 | uid = getuid(); |
| 592 | euid = geteuid(); |
| 593 | if (uid != euid) |
| 594 | setuid(uid); |
| 595 | hide_privileges(TRUE); |
| 596 | /* XXX gnome_init must print nethack options for --help, but does not */ |
| 597 | gnome_init("nethack", VERSION_STRING, argc, argv); |
| 598 | hide_privileges(FALSE); |
| 599 | parse_args(argc, argv); |
| 600 | |
| 601 | /* Initialize the i18n stuff (not that gnomehack supperts it yet...) */ |
| 602 | #if 0 |
| 603 | textdomain (PACKAGE); |
| 604 | #endif |
| 605 | gdk_imlib_init(); |
| 606 | |
| 607 | /* Main window */ |
| 608 | mainWindow = |
| 609 | gnome_app_new((char *) "nethack", (char *) N_("Nethack for Gnome")); |
| 610 | gtk_widget_realize(mainWindow); |
| 611 | if (restarted) { |
| 612 | gtk_widget_set_uposition(mainWindow, os_x, os_y); |
| 613 | gtk_widget_set_usize(mainWindow, os_w, os_h); |
| 614 | } |
| 615 | gtk_window_set_default_size(GTK_WINDOW(mainWindow), 800, 600); |
| 616 | gtk_window_set_policy(GTK_WINDOW(mainWindow), FALSE, TRUE, TRUE); |
| 617 | gnome_app_create_menus(GNOME_APP(mainWindow), mainmenu); |
| 618 | gtk_signal_connect(GTK_OBJECT(mainWindow), "key_press_event", |
| 619 | GTK_SIGNAL_FUNC(ghack_main_window_key_press), NULL); |
| 620 | gtk_signal_connect(GTK_OBJECT(mainWindow), "delete_event", |
| 621 | GTK_SIGNAL_FUNC(ghack_quit_game_cb), NULL); |
| 622 | |
| 623 | /* Put some stuff into our main window */ |
| 624 | vBoxMain = gtk_vbox_new(FALSE, 0); |
| 625 | hBoxFirstRow = gtk_hbox_new(FALSE, 0); |
| 626 | |
| 627 | /* pack Boxes into other boxes to produce the right structure */ |
| 628 | gtk_box_pack_start(GTK_BOX(vBoxMain), hBoxFirstRow, FALSE, TRUE, 0); |
| 629 | |
| 630 | /* pack vBoxMain which contains all our widgets into the main window. */ |
no test coverage detected