8 # define _(s) gettext (s)
9 # define N_(s) gettext_noop (s)
16 extern GtkWidget *about;
17 extern GtkWidget *GUI_Window;
19 extern char *programVersion;
20 extern int errorExitStatus;
21 extern int promotionUp;
28 QuitProc (object, user_data)
37 void InfoProc(object, user_data)
42 snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &",
48 void ManProc(object, user_data)
53 snprintf(buf, sizeof(buf), "xterm -e man xboard &");
58 void HintProc(object, user_data)
66 void BookProc(object, user_data)
74 void AboutProc (object, user_data)
80 const gchar *authors[] = {"Tim Mann <tim@tim-mann.org>",
82 "Evan Welsh <Evan.Welsh@msdw.com>",
83 "Elmar Bartel <bartel@informatik.tu-muenchen.de>",
86 "Hugh Fisher <Hugh.Fisher@cs.anu.edu.au>",
88 "H.G. Muller <h.g.muller AT hccnet DOT nl>",
89 "Eric Mullins <emwine AT earthlink DOT net>",
90 "Arun Persaud <arun@nubati.net>"};
92 /* set up about window */
93 about = GTK_WIDGET(gtk_about_dialog_new());
95 /* fill in some information */
98 char *zippy = " (with Zippy code)";
102 sprintf(buf, "%s%s", programVersion, zippy);
104 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(about),buf);
106 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(about),
107 "Copyright 1991 Digital Equipment Corporation\n"
108 "Enhancements Copyright 1992-2009 Free Software Foundation\n"
109 "Enhancements Copyright 2005 Alessandro Scotti");
110 gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(about),"http://www.gnu.org/software/xboard/");
111 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(about),authors);
112 gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(about),
113 " A. Alper (turkish)\n"
114 " A. Persaud (german)\n");
116 /* end set up about window */
117 gtk_dialog_run(GTK_DIALOG (about));
118 gtk_widget_destroy(about);
123 void IcsClientProc(object, user_data)
131 void LoadNextGameProc(object, user_data)
139 void LoadPrevGameProc(object, user_data)
147 void ReloadGameProc(object, user_data)
155 void MachineWhiteProc(object, user_data)
163 void MachineBlackProc(object, user_data)
171 void TwoMachinesProc(object, user_data)
179 void AcceptProc(object, user_data)
187 void DeclineProc(object, user_data)
195 void RematchProc(object, user_data)
203 void CallFlagProc(object, user_data)
211 void DrawProc(object, user_data)
219 void AbortProc(object, user_data)
227 void AdjournProc(object, user_data)
235 void ResignProc(object, user_data)
243 void StopObservingProc(object, user_data)
247 StopObservingEvent();
251 void StopExaminingProc(object, user_data)
255 StopExaminingEvent();
259 void AdjuWhiteProc(object, user_data)
263 UserAdjudicationEvent(+1);
267 void AdjuBlackProc(object, user_data)
271 UserAdjudicationEvent(-1);
275 void AdjuDrawProc(object, user_data)
279 UserAdjudicationEvent(0);
283 void BackwardProc(object, user_data)
291 void ForwardProc(object, user_data)
299 void ToStartProc(object, user_data)
307 void ToEndProc(object, user_data)
315 void RevertProc(object, user_data)
323 void TruncateGameProc(object, user_data)
331 void MoveNowProc(object, user_data)
339 void RetractMoveProc(object, user_data)
348 void ShowThinkingProc(object, user_data)
352 appData.showThinking = !appData.showThinking;
358 void HideThinkingProc(object, user_data)
362 appData.hideThinkingFromHuman = !appData.hideThinkingFromHuman;
368 void FlipViewProc(object, user_data)
372 flipView = !flipView;
373 DrawPosition(True, NULL);
378 gboolean CloseWindowProc(GtkWidget *button)
380 gtk_widget_destroy(gtk_widget_get_toplevel(button));
385 ResetProc (object, user_data)
393 void WhiteClockProc(object, user_data)
397 if (gameMode == EditPosition || gameMode == IcsExamining) {
398 SetWhiteToPlayEvent();
399 } else if (gameMode == IcsPlayingBlack || gameMode == MachinePlaysWhite) {
404 void BlackClockProc(object, user_data)
408 if (gameMode == EditPosition || gameMode == IcsExamining) {
409 SetBlackToPlayEvent();
410 } else if (gameMode == IcsPlayingWhite || gameMode == MachinePlaysBlack) {
416 void ShowCoordsProc(object, user_data)
420 appData.showCoords = !appData.showCoords;
422 DrawPosition(True, NULL);
425 void ErrorPopDownProc(object, user_data)
429 gtk_widget_destroy(GTK_WIDGET(object));
433 void PauseProc(object, user_data)
437 // todo this toggling of the pause button doesn't seem to work?
438 // e.g. select pause from buttonbar doesn't activate menumode.pause
443 void LoadGameProc(object, user_data)
448 dialog = gtk_file_chooser_dialog_new (_("Load game file name?"),
449 GTK_WINDOW(GUI_Window),
450 GTK_FILE_CHOOSER_ACTION_OPEN,
451 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
452 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
454 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
459 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
462 f = fopen(filename, "rb");
465 DisplayError(_("Failed to open file"), errno);
470 (void) LoadGamePopUp(f, 0, filename);
475 gtk_widget_destroy (dialog);
486 void EventProc(window, event, data)
491 /* todo do we still need this?
492 if (!XtIsRealized(widget))
496 switch (event->type) {
498 if (event->expose.count > 0) return; /* no clipping is done */
499 DrawPosition(True, NULL);
508 * event handler for parsing user moves
510 void UserMoveProc(window, event, data)
517 static int second = 0;
519 if (errorExitStatus != -1) return;
521 if (event->type == GDK_BUTTON_PRESS) ErrorPopDown();
525 if (event->type == GDK_BUTTON_PRESS)
527 /* todo add promotionshellwidget
528 XtPopdown(promotionShell);
529 XtDestroyWidget(promotionShell); */
540 x = EventToSquare( (int)event->button.x, BOARD_WIDTH );
541 y = EventToSquare( (int)event->button.y, BOARD_HEIGHT );
542 if (!flipView && y >= 0)
544 y = BOARD_HEIGHT - 1 - y;
546 if (flipView && x >= 0)
548 x = BOARD_WIDTH - 1 - x;
553 if (event->type == ButtonPress)
556 if (OKToStartUserMove(x, y))
561 DragPieceBegin(event->button.x, event->button.y);
562 if (appData.highlightDragging)
564 SetHighlights(x, y, -1, -1);
572 if (event->type == GDK_BUTTON_PRESS && gameMode != EditPosition &&
576 /* Check if clicking again on the same color piece */
577 fromP = boards[currentMove][fromY][fromX];
578 toP = boards[currentMove][y][x];
579 if ((WhitePawn <= fromP && fromP <= WhiteKing &&
580 WhitePawn <= toP && toP <= WhiteKing) ||
581 (BlackPawn <= fromP && fromP <= BlackKing &&
582 BlackPawn <= toP && toP <= BlackKing)) {
583 /* Clicked again on same color piece -- changed his mind */
584 second = (x == fromX && y == fromY);
585 if (appData.highlightDragging) {
586 SetHighlights(x, y, -1, -1);
590 if (OKToStartUserMove(x, y)) {
593 DragPieceBegin(event->button.x, event->button.y);
599 if (event->type == GDK_BUTTON_RELEASE && x == fromX && y == fromY)
601 DragPieceEnd(event->button.x, event->button.y);
602 if (appData.animateDragging)
604 /* Undo animation damage if any */
605 DrawPosition(FALSE, NULL);
609 /* Second up/down in same square; just abort move */
614 ClearPremoveHighlights();
618 /* First upclick in same square; start click-click mode */
619 SetHighlights(x, y, -1, -1);
627 saveAnimate = appData.animate;
629 if (event->type == GDK_BUTTON_PRESS)
631 /* Finish clickclick move */
632 if (appData.animate || appData.highlightLastMove)
634 SetHighlights(fromX, fromY, toX, toY);
643 /* Finish drag move */
644 if (appData.highlightLastMove)
646 SetHighlights(fromX, fromY, toX, toY);
652 DragPieceEnd(event->button.x, event->button.y);
653 /* Don't animate move and drag both */
654 appData.animate = FALSE;
657 if (IsPromotion(fromX, fromY, toX, toY))
659 if (appData.alwaysPromoteToQueen)
661 UserMoveEvent(fromX, fromY, toX, toY, 'q');
662 if (!appData.highlightLastMove || gotPremove) ClearHighlights();
663 if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY);
668 SetHighlights(fromX, fromY, toX, toY);
674 UserMoveEvent(fromX, fromY, toX, toY, NULLCHAR);
676 if (!appData.highlightLastMove || gotPremove) ClearHighlights();
677 if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY);
681 appData.animate = saveAnimate;
682 if (appData.animate || appData.animateDragging) {
683 /* Undo animation damage if needed */
684 DrawPosition(FALSE, NULL);
690 void GetMoveListProc(object, user_data)
694 appData.getMoveList = !appData.getMoveList;
696 if (appData.getMoveList)
701 // gets set automatically? if we set it with set_active we end up in an endless loop switching between 0 and 1
702 // gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (object),(gboolean) appData.getMoveList );