8 # define _(s) gettext (s)
9 # define N_(s) gettext_noop (s)
15 extern GtkWidget *about;
16 extern GtkWidget *GUI_Window;
17 extern GtkWidget *GUI_Aspect;
18 extern GtkWidget *GUI_Menubar;
19 extern GtkWidget *GUI_Timer;
20 extern GtkWidget *GUI_Buttonbar;
21 extern GtkWidget *GUI_Board;
23 extern char *programVersion;
24 extern int errorExitStatus;
25 extern int promotionUp;
30 extern int squareSize,lineGap;
32 extern int LoadGamePopUp P((FILE *f, int gameNumber, char *title));
33 extern int LoadPosition P((FILE *f, int gameNumber, char *title));
34 extern int SaveGame P((FILE *f, int gameNumber, char *title));
35 extern int SavePosition P((FILE *f, int gameNumber, char *title));
38 ExposeProc(object, user_data)
42 /* do resizing to a fixed aspect ratio */
46 int boardWidth,boardHeight,old,new;
48 nw=GTK_WIDGET(object)->allocation.width;
49 nh=GTK_WIDGET(object)->allocation.height;
52 squareSize = nw/(BOARD_WIDTH*1.05+0.05);
56 lineGap = squareSize*0.05;
58 boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap);
59 boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap);
61 /* get the height of the menus, etc. and calculate the aspect ratio */
62 gtk_widget_size_request(GTK_WIDGET(GUI_Menubar), &w);
64 gtk_widget_size_request(GTK_WIDGET(GUI_Timer), &w);
66 gtk_widget_size_request(GTK_WIDGET(GUI_Buttonbar), &w);
69 ratio = ((float)totalh+boardHeight)/((float)boardWidth) ;
71 gtk_widget_set_size_request(GTK_WIDGET(GUI_Board),
72 boardWidth,boardHeight);
74 gtk_aspect_frame_set (GTK_ASPECT_FRAME(GUI_Aspect),0,0,ratio,TRUE);
76 /* recreate pieces with new size... TODO: keep svg in memory and just recreate pixmap instead of reloading files */
79 return FALSE; /* return false, so that other expose events are called too */
83 QuitProc (object, user_data)
92 void InfoProc(object, user_data)
97 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
103 void ManProc(object, user_data)
108 snprintf(buf, sizeof(buf), "xterm -e man xboard &");
113 void HintProc(object, user_data)
121 void BookProc(object, user_data)
129 void AboutProc (object, user_data)
135 const gchar *authors[] = {"Tim Mann <tim@tim-mann.org>",
137 "Evan Welsh <Evan.Welsh@msdw.com>",
138 "Elmar Bartel <bartel@informatik.tu-muenchen.de>",
141 "Hugh Fisher <Hugh.Fisher@cs.anu.edu.au>",
142 "Allessandro Scotti",
143 "H.G. Muller <h.g.muller AT hccnet DOT nl>",
144 "Eric Mullins <emwine AT earthlink DOT net>",
145 "Arun Persaud <arun@nubati.net>"};
147 /* set up about window */
148 about = GTK_WIDGET(gtk_about_dialog_new());
150 /* fill in some information */
153 char *zippy = " (with Zippy code)";
157 sprintf(buf, "%s%s", programVersion, zippy);
159 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),buf);
161 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about),
162 "Copyright 1991 Digital Equipment Corporation\n"
163 "Enhancements Copyright 1992-2009 Free Software Foundation\n"
164 "Enhancements Copyright 2005 Alessandro Scotti");
165 gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),"http://www.gnu.org/software/xboard/");
166 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about),authors);
167 gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about),
168 " A. Alper (turkish)\n"
169 " A. Persaud (german)\n");
171 /* end set up about window */
172 gtk_dialog_run(GTK_DIALOG (about));
173 gtk_widget_destroy(about);
180 void MachineWhiteProc(object, user_data)
188 void MachineBlackProc(object, user_data)
196 void TwoMachinesProc(object, user_data)
204 void IcsClientProc(object, user_data)
213 AnalyzeFileProc(object, user_data)
217 if (!first.analysisSupport)
220 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
221 DisplayError(buf, 0);
226 if (!appData.showThinking)
227 ShowThinkingProc(NULL,NULL);
230 FileNamePopUp(_("File to analyze"), "", LoadGamePopUp, "rb");
231 AnalysisPeriodicEvent(1);
236 AnalyzeModeProc(object, user_data)
242 if (!first.analysisSupport)
244 snprintf(buf, sizeof(buf), _("%s does not support analysis"), first.tidy);
245 DisplayError(buf, 0);
248 /* [DM] icsEngineAnalyze [HGM] This is horrible code; reverse the gameMode and isEngineAnalyze tests! */
249 if (appData.icsActive)
251 if (gameMode != IcsObserving)
253 sprintf(buf,_("You are not observing a game"));
254 DisplayError(buf, 0);
256 if (appData.icsEngineAnalyze)
258 if (appData.debugMode)
259 fprintf(debugFP, _("Found unexpected active ICS engine analyze \n"));
265 /* if enable, use want disable icsEngineAnalyze */
266 if (appData.icsEngineAnalyze)
272 appData.icsEngineAnalyze = TRUE;
273 if (appData.debugMode)
274 fprintf(debugFP, _("ICS engine analyze starting... \n"));
276 if (!appData.showThinking)
277 ShowThinkingProc(NULL,NULL);
284 EditGameProc(object, user_data)
293 EditPositionProc(object, user_data)
302 TrainingProc(object, user_data)
319 LoadNextGameProc(object, user_data)
328 LoadPrevGameProc(object, user_data)
337 ReloadGameProc(object, user_data)
346 LoadNextPositionProc(object, user_data)
355 LoadPrevPositionProc(object, user_data)
364 ReloadPositionProc(object, user_data)
373 LoadPositionProc(object, user_data)
377 if (gameMode == AnalyzeMode || gameMode == AnalyzeFile)
382 FileNamePopUp(_("Load position file name?"), "", LoadPosition, "rb");
387 SaveGameProc(object, user_data)
391 FileNamePopUp(_("Save game file name?"),
392 DefaultFileName(appData.oldSaveStyle ? "game" : "pgn"),
398 SavePositionProc(object, user_data)
402 FileNamePopUp(_("Save position file name?"),
403 DefaultFileName(appData.oldSaveStyle ? "pos" : "fen"),
411 void AcceptProc(object, user_data)
419 void DeclineProc(object, user_data)
427 void RematchProc(object, user_data)
435 void CallFlagProc(object, user_data)
443 void DrawProc(object, user_data)
451 void AbortProc(object, user_data)
459 void AdjournProc(object, user_data)
467 void ResignProc(object, user_data)
475 void StopObservingProc(object, user_data)
479 StopObservingEvent();
483 void StopExaminingProc(object, user_data)
487 StopExaminingEvent();
491 void AdjuWhiteProc(object, user_data)
495 UserAdjudicationEvent(+1);
499 void AdjuBlackProc(object, user_data)
503 UserAdjudicationEvent(-1);
507 void AdjuDrawProc(object, user_data)
511 UserAdjudicationEvent(0);
515 void BackwardProc(object, user_data)
523 void ForwardProc(object, user_data)
531 void ToStartProc(object, user_data)
539 void ToEndProc(object, user_data)
547 void RevertProc(object, user_data)
555 void TruncateGameProc(object, user_data)
563 void MoveNowProc(object, user_data)
571 void RetractMoveProc(object, user_data)
581 AutocommProc(object, user_data)
585 appData.autoComment = !appData.autoComment;
590 AutoflagProc(object, user_data)
594 appData.autoCallFlag = !appData.autoCallFlag;
599 AutoflipProc(object, user_data)
603 appData.autoFlipView = !appData.autoFlipView;
608 ShowThinkingProc(object, user_data)
612 appData.showThinking = !appData.showThinking;
619 HideThinkingProc(object, user_data)
623 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman;
630 FlipViewProc(object, user_data)
634 flipView = !flipView;
635 DrawPosition(True, NULL);
640 AlwaysQueenProc(object, user_data)
644 appData.alwaysPromoteToQueen = !appData.alwaysPromoteToQueen;
649 AnimateDraggingProc(object, user_data)
653 appData.animateDragging = !appData.animateDragging;
655 if (appData.animateDragging)
657 // TODO convert to gtk
665 AnimateMovingProc(object, user_data)
669 appData.animate = !appData.animate;
673 // TODO convert to gtk
681 AutobsProc(object, user_data)
685 appData.autoObserve = !appData.autoObserve;
690 AutoraiseProc(object, user_data)
694 appData.autoRaiseBoard = !appData.autoRaiseBoard;
699 AutosaveProc(object, user_data)
703 appData.autoSaveGames = !appData.autoSaveGames;
708 BlindfoldProc(object, user_data)
712 appData.blindfold = !appData.blindfold;
713 DrawPosition(True, NULL);
718 TestLegalityProc(object, user_data)
722 appData.testLegality = !appData.testLegality;
727 FlashMovesProc(object, user_data)
731 if (appData.flashCount == 0)
733 appData.flashCount = 3;
737 appData.flashCount = -appData.flashCount;
740 // TODO: check if this is working correct*/
746 HighlightDraggingProc(object, user_data)
750 /* TODO: connect to option menu */
751 appData.highlightDragging = !appData.highlightDragging;
757 HighlightLastMoveProc(object, user_data)
761 appData.highlightLastMove = !appData.highlightLastMove;
766 IcsAlarmProc(object, user_data)
770 appData.icsAlarm = !appData.icsAlarm;
775 MoveSoundProc(object, user_data)
779 appData.ringBellAfterMoves = !appData.ringBellAfterMoves;
784 OldSaveStyleProc(object, user_data)
788 appData.oldSaveStyle = !appData.oldSaveStyle;
793 PeriodicUpdatesProc(object, user_data)
797 PeriodicUpdatesEvent(!appData.periodicUpdates);
802 PremoveProc(object, user_data)
806 appData.premove = !appData.premove;
811 QuietPlayProc(object, user_data)
815 appData.quietPlay = !appData.quietPlay;
821 PonderNextMoveProc(object, user_data)
825 PonderNextMoveEvent(!appData.ponderNextMove);
830 PopupExitMessageProc(object, user_data)
834 appData.popupExitMessage = !appData.popupExitMessage;
839 PopupMoveErrorsProc(object, user_data)
843 appData.popupMoveErrors = !appData.popupMoveErrors;
849 /* end option menu */
851 gboolean CloseWindowProc(GtkWidget *button)
853 gtk_widget_destroy(gtk_widget_get_toplevel(button));
858 ResetProc (object, user_data)
866 void WhiteClockProc(object, user_data)
870 if (gameMode == EditPosition || gameMode == IcsExamining) {
871 SetWhiteToPlayEvent();
872 } else if (gameMode == IcsPlayingBlack || gameMode == MachinePlaysWhite) {
877 void BlackClockProc(object, user_data)
881 if (gameMode == EditPosition || gameMode == IcsExamining) {
882 SetBlackToPlayEvent();
883 } else if (gameMode == IcsPlayingWhite || gameMode == MachinePlaysBlack) {
889 void ShowCoordsProc(object, user_data)
893 appData.showCoords = !appData.showCoords;
895 DrawPosition(True, NULL);
898 void ErrorPopDownProc(object, user_data)
902 gtk_widget_destroy(GTK_WIDGET(object));
906 void PauseProc(object, user_data)
910 // todo this toggling of the pause button doesn't seem to work?
911 // e.g. select pause from buttonbar doesn't activate menumode.pause
916 void LoadGameProc(object, user_data)
920 FileNamePopUp(_("Load game file name?"),"",LoadGamePopUp,"rb");
929 void EventProc(window, event, data)
934 /* todo do we still need this?
935 if (!XtIsRealized(widget))
939 switch (event->type) {
941 if (event->expose.count > 0) return; /* no clipping is done */
942 DrawPosition(True, NULL);
951 * event handler for parsing user moves
953 void UserMoveProc(window, event, data)
958 if (errorExitStatus != -1) return;
962 if (event->type == GDK_BUTTON_PRESS)
974 // [HGM] mouse: the rest of the mouse handler is moved to the backend, and called here
975 if(event->type == GDK_BUTTON_PRESS) LeftClick(Press, (int)event->button.x, (int)event->button.y);
976 if(event->type == GDK_BUTTON_RELEASE) LeftClick(Release, (int)event->button.x, (int)event->button.y);
981 void GetMoveListProc(object, user_data)
985 appData.getMoveList = !appData.getMoveList;
987 if (appData.getMoveList)
992 // gets set automatically? if we set it with set_active we end up in an endless loop switching between 0 and 1
993 // gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (object),(gboolean) appData.getMoveList );