Logo Search packages:      
Sourcecode: mathwar version File versions  Download package

GtkWidget* create_mainwin ( void   ) 

Create the main window for the application.

Returns:
A pointer to the created main widget.

Definition at line 415 of file mainwin.c.

{
  GtkWidget   *app1;
  GtkWidget   *dock1;
  GtkWidget   *vbox1;
  GtkWidget   *drawingarea;
  GtkWidget   *hbox1;
  GtkWidget   *hbox2;
  GtkWidget   *entry1;
  GtkWidget   *submit_btn;
  GtkWidget   *yes_btn;
  GtkWidget   *no_btn;
  GtkWidget   *pause_btn;
  GtkWidget   *appbar1;
  GtkWidget   *hsep;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new();

  app1 = gnome_app_new (PACKAGE, _(PACKAGE));
  gtk_object_set_data (GTK_OBJECT (app1), MAINWIN, app1);
  gtk_signal_connect (GTK_OBJECT (app1), "show",
                      GTK_SIGNAL_FUNC (on_mainwin_show),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (app1), "destroy",
                      GTK_SIGNAL_FUNC (on_mainwin_destroy),
                      NULL);
  gtk_window_set_policy (GTK_WINDOW (app1), FALSE, FALSE, TRUE);

  dock1 = GNOME_APP (app1)->dock;
  gtk_widget_ref (dock1);
  gtk_object_set_data_full (GTK_OBJECT (app1), "dock1", dock1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (dock1);

  gnome_app_create_menus (GNOME_APP (app1), menubar1_uiinfo);

  gtk_widget_ref (menubar1_uiinfo[0].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "game",
                            menubar1_uiinfo[0].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (game_menu_uiinfo[0].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), NEW_GAME_MENU,
                            game_menu_uiinfo[0].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (game_menu_uiinfo[1].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "separator1",
                            game_menu_uiinfo[1].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (game_menu_uiinfo[2].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "exit1",
                            game_menu_uiinfo[2].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (menubar1_uiinfo[1].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "settings1",
                            menubar1_uiinfo[1].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (settings1_menu_uiinfo[0].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "preferences1",
                            settings1_menu_uiinfo[0].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (menubar1_uiinfo[2].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "help1",
                            menubar1_uiinfo[2].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  gtk_widget_ref (help1_menu_uiinfo[2].widget);
  gtk_object_set_data_full (GTK_OBJECT (app1), "about1",
                            help1_menu_uiinfo[2].widget,
                            (GtkDestroyNotify) gtk_widget_unref);

  vbox1 = gtk_vbox_new (FALSE, 5);
  gtk_widget_ref (vbox1);
  gtk_object_set_data_full (GTK_OBJECT (app1), "vbox1", vbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (vbox1);
  gnome_app_set_contents (GNOME_APP (app1), vbox1);
  gtk_container_set_border_width (GTK_CONTAINER (vbox1), 0);

  drawingarea = gtk_drawing_area_new ();
  gtk_widget_ref (drawingarea);
  gtk_object_set_data_full (GTK_OBJECT (app1), DRAWING_AREA, drawingarea,
                            (GtkDestroyNotify)gtk_widget_unref);
  gtk_widget_show (drawingarea);
  gtk_box_pack_start (GTK_BOX (vbox1), drawingarea, TRUE, TRUE, 0);
  main_drawing_area = GTK_DRAWING_AREA (drawingarea);
  gtk_widget_set_usize (GTK_WIDGET (main_drawing_area),
                        board_width(), board_height());
  
  hsep = gtk_hseparator_new ();
  gtk_widget_ref (hsep);
  gtk_object_set_data_full (GTK_OBJECT (hsep), "hsep2", hsep,
                            (GtkDestroyNotify)gtk_widget_unref);
  gtk_widget_show (hsep);
  gtk_box_pack_start (GTK_BOX (vbox1), hsep, FALSE, FALSE, 0);

  hbox1 = gtk_hbox_new (FALSE, 10);
  gtk_widget_ref (hbox1);
  gtk_object_set_data_full (GTK_OBJECT (app1), "hbox1", hbox1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);

  entry1 = gtk_entry_new ();
  gtk_widget_ref (entry1);
  gtk_object_set_data_full (GTK_OBJECT (app1), ANSWER_ENTRY, entry1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (entry1);
  gtk_box_pack_start (GTK_BOX (hbox1), entry1, TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT (entry1), "insert_text",
                      GTK_SIGNAL_FUNC (limit_input_to_nums),
                      NULL);
  gtk_signal_connect (GTK_OBJECT (entry1), "key_press_event",
                      GTK_SIGNAL_FUNC (on_answer_entry_key_press_event),
                      NULL);

  hbox2 = gtk_hbox_new (TRUE, 0);
  gtk_widget_ref (hbox2);
  gtk_object_set_data_full (GTK_OBJECT (app1), "hbox2", hbox2,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (hbox1), hbox2, FALSE, TRUE, 0);

  submit_btn = gtk_button_new_with_label (_("Submit"));
  gtk_widget_ref (submit_btn);
  gtk_object_set_data_full (GTK_OBJECT (app1), SUBMIT_BUTTON, submit_btn,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (submit_btn);
  gtk_box_pack_start (GTK_BOX (hbox2), submit_btn, FALSE, TRUE, 0);
  gtk_widget_set_sensitive (submit_btn, FALSE);
  GTK_WIDGET_SET_FLAGS (submit_btn, GTK_CAN_DEFAULT);
  gtk_signal_connect (GTK_OBJECT (submit_btn), "clicked",
                      GTK_SIGNAL_FUNC (on_submit_clicked),
                      NULL);

  pause_btn = gtk_toggle_button_new_with_label (_("Pause"));
  gtk_widget_ref (pause_btn);
  gtk_object_set_data_full (GTK_OBJECT (app1), PAUSE_BUTTON, pause_btn,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (pause_btn);
  gtk_box_pack_start (GTK_BOX (hbox2), pause_btn, FALSE, TRUE, 0);
  GTK_WIDGET_SET_FLAGS (pause_btn, GTK_CAN_DEFAULT);
  gtk_widget_set_sensitive (pause_btn, FALSE);
  gtk_signal_connect (GTK_OBJECT (pause_btn), "toggled",
                      GTK_SIGNAL_FUNC (on_pause_toggled),
                      NULL);

  yes_btn = gnome_stock_button (GNOME_STOCK_BUTTON_YES);
  gtk_widget_ref (yes_btn);
  gtk_object_set_data_full (GTK_OBJECT (app1), YES_BUTTON, yes_btn,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (yes_btn);
  gtk_box_pack_start (GTK_BOX (hbox2), yes_btn, FALSE, TRUE, 0);
  GTK_WIDGET_SET_FLAGS (yes_btn, GTK_CAN_DEFAULT);
  gtk_widget_set_sensitive (yes_btn, FALSE);
  gtk_signal_connect (GTK_OBJECT (yes_btn), "clicked",
                      GTK_SIGNAL_FUNC (on_yes_clicked),
                      NULL);

  no_btn = gnome_stock_button (GNOME_STOCK_BUTTON_NO);
  gtk_widget_ref (no_btn);
  gtk_object_set_data_full (GTK_OBJECT (app1), NO_BUTTON, no_btn,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (no_btn);
  gtk_box_pack_start (GTK_BOX (hbox2), no_btn, FALSE, TRUE, 0);
  GTK_WIDGET_SET_FLAGS (no_btn, GTK_CAN_DEFAULT);
  gtk_widget_set_sensitive (no_btn, FALSE);
  gtk_signal_connect (GTK_OBJECT (no_btn), "clicked",
                      GTK_SIGNAL_FUNC (on_no_clicked),
                      NULL);

  appbar1 = gnome_appbar_new (TRUE, TRUE, GNOME_PREFERENCES_NEVER);
  gtk_widget_ref (appbar1);
  gtk_object_set_data_full (GTK_OBJECT (app1), MAIN_APPBAR, appbar1,
                            (GtkDestroyNotify) gtk_widget_unref);
  gtk_widget_show (appbar1);
  gnome_app_set_statusbar (GNOME_APP (app1), appbar1);

  gnome_app_install_menu_hints (GNOME_APP (app1), menubar1_uiinfo);

  gtk_widget_grab_default (submit_btn);

  gtk_object_set_data (GTK_OBJECT (app1), "tooltips", tooltips);

  return app1;
}


Generated by  Doxygen 1.6.0   Back to index