📄 login_window.c
字号:
/*login_window.c - login window widget configCopyright (C) 2006 Obada Denis (obadadenis@gmail.com)Project home page : http://tictactoegtk.sourceforge.netThis program is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/#ifndef login_window_c#define login_window_c//Data structures GSList *Lgrup; //Login groupGtkWidget *radio1,*radio2; //Radio itemsgchar username[10];//Player Namegchar usr_win[20];//User win string//Codevoid setX(GtkWidget *widget,gpointer data){//Set X Char for Playerusrchar='X';cpuchar='O';}void setO(GtkWidget *widget, gpointer data){//Set O char for Playerusrchar='O';cpuchar='X';}void login(void){//Login Dialog widgetsGtkWidget *Ldialog; //Login dialogGtkWidget *Llabel,*Llabel2; //Login dialog labelsGtkWidget *Ledit;//Edit boxGtkWidget *Ltable;//Login table//Login MessageGtkWidget *msg;int ok=1;Ldialog = gtk_dialog_new_with_buttons (login_title,GTK_WINDOW(window),GTK_DIALOG_MODAL,GTK_STOCK_OK,GTK_RESPONSE_ACCEPT,NULL);gtk_window_set_policy(GTK_WINDOW(Ldialog),FALSE,FALSE,FALSE);gtk_widget_set_size_request(Ldialog,200,150);gtk_container_set_border_width (GTK_CONTAINER (Ldialog), 5);Llabel = gtk_label_new (name_msg);Llabel2 = gtk_label_new(choice_msg);Ledit=gtk_entry_new_with_max_length(10);gtk_entry_set_text(GTK_ENTRY(Ledit),"NoName");radio1 = gtk_radio_button_new_with_label (NULL, "X");Lgrup = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio1));radio2 = gtk_radio_button_new_with_label( Lgrup, "O");g_signal_connect(G_OBJECT(radio1),"clicked",G_CALLBACK(setX),NULL);g_signal_connect(G_OBJECT(radio2),"clicked",G_CALLBACK(setO),NULL);Ltable=gtk_table_new(3,3,FALSE);gtk_table_attach_defaults (GTK_TABLE (Ltable), Llabel, 0, 1, 0, 1);gtk_table_attach_defaults (GTK_TABLE (Ltable), Llabel2,0,1, 1, 2);gtk_table_attach_defaults (GTK_TABLE (Ltable), Ledit, 1, 2, 0, 1);gtk_table_attach_defaults (GTK_TABLE (Ltable), radio1, 0, 1, 2, 3);gtk_table_attach_defaults (GTK_TABLE (Ltable), radio2, 1, 2, 2, 3);gtk_container_add (GTK_CONTAINER (GTK_DIALOG(Ldialog)->vbox),Ltable);//Show dialog gtk_widget_show_all(Ldialog);//Process events form dialogdo{ ok=0;//Run dialogwhile( gtk_dialog_run (GTK_DIALOG (Ldialog))!=GTK_RESPONSE_ACCEPT) ;//Get infor from Dialogstrcpy(username,gtk_entry_get_text(GTK_ENTRY(Ledit)));#if debugprintf("User Name : %s\n",username);#endif//If UserName is Emptyif (strlen(username)==0) { //Show Warning Message msg=gtk_message_dialog_new (GTK_WINDOW(window) ,GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, error_name_msg); gtk_dialog_run(GTK_DIALOG(msg)); gtk_widget_destroy(msg); ok=1; //Loop will not stop } else { //Register user name strcpy(usr_win,"Winer : "); strcat(usr_win,username); }}while(ok);//Destroy dialoggtk_widget_destroy(Ldialog);}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -