/***************************************************************************
* main.c
*
* Fri Sep 23 08:46:05 2005
* Copyright 2005 Alpher
* Email: alpher_zmx@yahoo.com.cn
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../config.h"
#include "main.h"
/*
creat menus
*/
void
get_main_menu( GtkWidget *window, GtkWidget **menubar)
{
GtkAccelGroup *accel_group;
GtkWidget *menu1,*menu2,*menu3,*menuitem,*rootmenu;
accel_group = gtk_accel_group_new();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
*menubar = gtk_menu_bar_new();
menu1 = gtk_menu_new(); /*Game*/
menu2 = gtk_menu_new(); /*Single*/
menuitem = gtk_menu_item_new_with_mnemonic(_("_Easy"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F1, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_begin),(gpointer)1);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Normal"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F2, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_begin),(gpointer)2);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Hard"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F3, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_begin),(gpointer)3);
menuitem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Resume"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F4, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_begin),(gpointer)4);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Single"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),menu2);
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
menu2 = gtk_menu_new();
menuitem = gtk_menu_item_new_with_mnemonic(_("_Easy"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)1);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Normal"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)2);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Hard"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)3);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Two"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),menu2);
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
/* Two not available*/
gtk_widget_set_sensitive (GTK_WIDGET (menuitem), FALSE);
menu2 = gtk_menu_new();
menu3 = gtk_menu_new();
menuitem = gtk_menu_item_new_with_mnemonic(_("_Easy"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu3),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)1);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Normal"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu3),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)2);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Hard"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu3),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)3);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Server"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),menu3);
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Client"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu2),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(print_hello),(gpointer)0);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Network"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),menu2);
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
/* Network not available */
gtk_widget_set_sensitive (GTK_WIDGET (menuitem), FALSE);
menuitem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Giveup"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F12, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_giveup),(gpointer)0);
menuitem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
menuitem = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT,accel_group);
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(gtk_main_quit),(gpointer)0);
rootmenu = gtk_menu_item_new_with_mnemonic(_("_Game"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(rootmenu),menu1);
gtk_menu_shell_append(GTK_MENU_SHELL(*menubar),rootmenu);
g_signal_connect (G_OBJECT (menu1), "show", G_CALLBACK (ui_game_on_show), NULL);
/*============================================================*/
menu1 = gtk_menu_new();
menuitem = gtk_menu_item_new_with_mnemonic(_("_Hint"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F5, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_hint),(gpointer)0);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Shuffle"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F6, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_shuffle),(gpointer)0);
menuitem = gtk_menu_item_new_with_mnemonic(_("_Pause/Proceed"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_F7, 0, GTK_ACCEL_VISIBLE);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_pause),(gpointer)0);
menuitem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
menuitem = gtk_menu_item_new_with_mnemonic(_("H_ide"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
gtk_widget_add_accelerator (menuitem, "activate", accel_group,GDK_Escape, 0, GTK_ACCEL_VISIBLE);
/*
Hide menuitem's activeate event is connected in the main function, not here.
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_game_giveup),(gpointer)0);
*/
menuitem = gtk_menu_item_new_with_mnemonic(_("_Theme Edit Tools"));
gtk_menu_shell_append(GTK_MENU_SHELL(menu1),menuitem);
g_signal_connect(G_OBJECT(menuitem),"activate",G_CALLBACK(ui_theme_editor),(gpointer)0);
rootmenu = gtk_menu_item_new_with_mnemonic(_("_Functions"));
gtk_menu_item_set_submenu(GTK_MENU_ITEM(rootmenu),menu1);
gtk_menu_shell_append(GTK_MENU_SHELL(*menubar),rootmenu);
g_signal_connect (G_OBJECT