X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gtk%2Fxboard.c;h=88d6557a040899cf5d44f96336ceba648f303473;hb=36c7e09704a7ef2229f316e8e70e423d4f0fa93b;hp=fed6aa3d12f5697db34864f13f78430792937429;hpb=a009a27e8c1e0bfa818f12fdcae675d0babc510a;p=xboard.git diff --git a/gtk/xboard.c b/gtk/xboard.c index fed6aa3..88d6557 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -226,6 +226,9 @@ static GdkPixbuf *mainwindowIcon=NULL; static GdkPixbuf *WhiteIcon=NULL; static GdkPixbuf *BlackIcon=NULL; +/* key board accelerators */ +GtkAccelGroup *GtkAccelerators; + typedef unsigned int BoardSize; BoardSize boardSize; Boolean chessProgram; @@ -282,73 +285,10 @@ XtResource clientResources[] = { }; #endif +/* keyboard shortcuts not yet transistioned int menuitem @ menu.c */ char globalTranslations[] = - ":F9: MenuItem(Actions.Resign) \n \ - :Ctrln: MenuItem(File.NewGame) \n \ - :MetaV: MenuItem(File.NewVariant) \n \ - :Ctrlo: MenuItem(File.LoadGame) \n \ - :MetaNext: MenuItem(LoadNextGameProc) \n \ - :MetaPrior: MenuItem(LoadPrevGameProc) \n \ - :CtrlDown: LoadSelectedProc(3) \n \ + ":CtrlDown: LoadSelectedProc(3) \n \ :CtrlUp: LoadSelectedProc(-3) \n \ - :Ctrls: MenuItem(File.SaveGame) \n \ - :Ctrlc: MenuItem(Edit.CopyGame) \n \ - :Ctrlv: MenuItem(Edit.PasteGame) \n \ - :CtrlO: MenuItem(File.LoadPosition) \n \ - :ShiftNext: MenuItem(LoadNextPositionProc) \n \ - :ShiftPrior: MenuItem(LoadPrevPositionProc) \n \ - :CtrlS: MenuItem(File.SavePosition) \n \ - :CtrlC: MenuItem(Edit.CopyPosition) \n \ - :CtrlV: MenuItem(Edit.PastePosition) \n \ - :Ctrlq: MenuItem(File.Quit) \n \ - :Ctrlw: MenuItem(Mode.MachineWhite) \n \ - :Ctrlb: MenuItem(Mode.MachineBlack) \n \ - :Ctrlt: MenuItem(Mode.TwoMachines) \n \ - :Ctrla: MenuItem(Mode.AnalysisMode) \n \ - :Ctrlg: MenuItem(Mode.AnalyzeFile) \n \ - :Ctrle: MenuItem(Mode.EditGame) \n \ - :CtrlE: MenuItem(Mode.EditPosition) \n \ - :MetaO: MenuItem(View.EngineOutput) \n \ - :MetaE: MenuItem(View.EvaluationGraph) \n \ - :MetaG: MenuItem(View.GameList) \n \ - :MetaH: MenuItem(View.MoveHistory) \n \ - :Pause: MenuItem(Mode.Pause) \n \ - :F3: MenuItem(Action.Accept) \n \ - :F4: MenuItem(Action.Decline) \n \ - :F12: MenuItem(Action.Rematch) \n \ - :F5: MenuItem(Action.CallFlag) \n \ - :F6: MenuItem(Action.Draw) \n \ - :F7: MenuItem(Action.Adjourn) \n \ - :F8: MenuItem(Action.Abort) \n \ - :F10: MenuItem(Action.StopObserving) \n \ - :F11: MenuItem(Action.StopExamining) \n \ - :Ctrld: MenuItem(DebugProc) \n \ - :Meta CtrlF12: MenuItem(DebugProc) \n \ - :MetaEnd: MenuItem(Edit.ForwardtoEnd) \n \ - :MetaRight: MenuItem(Edit.Forward) \n \ - :MetaHome: MenuItem(Edit.BacktoStart) \n \ - :MetaLeft: MenuItem(Edit.Backward) \n \ - :Left: MenuItem(Edit.Backward) \n \ - :Right: MenuItem(Edit.Forward) \n \ - :Home: MenuItem(Edit.Revert) \n \ - :End: MenuItem(Edit.TruncateGame) \n \ - :Ctrlm: MenuItem(Engine.MoveNow) \n \ - :Ctrlx: MenuItem(Engine.RetractMove) \n \ - :MetaJ: MenuItem(Options.Adjudications) \n \ - :MetaU: MenuItem(Options.CommonEngine) \n \ - :MetaT: MenuItem(Options.TimeControl) \n \ - :CtrlP: MenuItem(PonderNextMove) \n " -#ifndef OPTIONSDIALOG - "\ - :CtrlQ: MenuItem(AlwaysQueenProc) \n \ - :CtrlF: MenuItem(AutoflagProc) \n \ - :CtrlA: MenuItem(AnimateMovingProc) \n \ - :CtrlL: MenuItem(TestLegalityProc) \n \ - :CtrlH: MenuItem(HideThinkingProc) \n " -#endif - "\ - :F1: MenuItem(Help.ManXBoard) \n \ - :F2: MenuItem(View.FlipView) \n \ :Return: TempBackwardProc() \n \ :Return: TempForwardProc() \n"; @@ -371,7 +311,7 @@ String xboardResources[] = { void BoardToTop () { - gtk_window_present(GTK_WINDOW(mainwindow)); + gtk_window_present(GTK_WINDOW(shells[BoardWindow])); } //--------------------------------------------------------------------------------------------------------- @@ -777,6 +717,9 @@ main (int argc, char **argv) /* set up GTK */ gtk_init (&argc, &argv); + /* set up keyboard accelerators group */ + GtkAccelerators = gtk_accel_group_new(); + programName = strrchr(argv[0], '/'); if (programName == NULL) programName = argv[0]; @@ -994,6 +937,9 @@ main (int argc, char **argv) InitMenuMarkers(); + // add accelerators to main shell + gtk_window_add_accel_group(GTK_WINDOW(shellWidget), GtkAccelerators); + /* * Create an icon. (Use two icons, to indicate whther it is white's or black's turn.) */ @@ -1030,7 +976,7 @@ main (int argc, char **argv) //printf("start size (%d,%d), %dx%d\n", a.x, a.y, w, h); gtk_widget_get_allocation(boardWidget, &a); marginW = w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board - marginH = h - a.height - 25; // subtract 25, because GTK seems to insert this amount of extra empty space + marginH = h - a.height + 13; gtk_window_resize(GTK_WINDOW(shellWidget), marginW + boardWidth, marginH + boardHeight); //printf("margins h=%d v=%d\n", marginW, marginH); } @@ -1492,10 +1438,12 @@ DragProc () busy = 0; return; // false alarm } ReSize(&wpNew); - if(shellUp[EngOutDlg]) CoDrag(shells[EngOutDlg], &wpEngineOutput); - if(shellUp[HistoryDlg]) CoDrag(shells[HistoryDlg], &wpMoveHistory); - if(shellUp[EvalGraphDlg]) CoDrag(shells[EvalGraphDlg], &wpEvalGraph); - if(shellUp[GameListDlg]) CoDrag(shells[GameListDlg], &wpGameList); + if(appData.useStickyWindows) { + if(shellUp[EngOutDlg]) CoDrag(shells[EngOutDlg], &wpEngineOutput); + if(shellUp[HistoryDlg]) CoDrag(shells[HistoryDlg], &wpMoveHistory); + if(shellUp[EvalGraphDlg]) CoDrag(shells[EvalGraphDlg], &wpEvalGraph); + if(shellUp[GameListDlg]) CoDrag(shells[GameListDlg], &wpGameList); + } wpMain = wpNew; DrawPosition(True, NULL); if(delayedDragTag) g_source_remove(delayedDragTag); @@ -1521,8 +1469,7 @@ EventProc (GtkWidget *widget, GdkEvent *event, gpointer g) wpNew.y = event->configure.y; wpNew.width = event->configure.width; wpNew.height = event->configure.height; - if(appData.useStickyWindows) - DelayedDrag(); // as long as events keep coming in faster than 50 msec, they destroy each other + DelayedDrag(); // as long as events keep coming in faster than 50 msec, they destroy each other return FALSE; } @@ -1565,7 +1512,7 @@ ModeHighlight () /* Always toggle, don't set. Previous code messes up when invoked while the button is pressed, as releasing it toggles the state again. */ - GdkColor color; + GdkColor color; gdk_color_parse( pausing ? "#808080" : "#F0F0F0", &color ); gtk_widget_modify_bg ( GTK_WIDGET(optList[W_PAUSE].handle), GTK_STATE_NORMAL, &color ); } @@ -1618,7 +1565,7 @@ void CopyFileToClipboard(gchar *filename) return; } selection_tmp[len] = NULLCHAR; // file is now in selection_tmp - + // copy selection_tmp to clipboard GdkDisplay *gdisp = gdk_display_get_default(); if (!gdisp) { @@ -1627,7 +1574,7 @@ void CopyFileToClipboard(gchar *filename) } cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD); gtk_clipboard_set_text(cb, selection_tmp, -1); - g_free(selection_tmp); + g_free(selection_tmp); } void @@ -1649,9 +1596,9 @@ PastePositionProc () gchar *fenstr; if (gdisp == NULL) return; - cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD); + cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD); fenstr = gtk_clipboard_wait_for_text(cb); - if (fenstr==NULL) return; // nothing had been selected to copy + if (fenstr==NULL) return; // nothing had been selected to copy EditPositionPasteFEN(fenstr); return; } @@ -1667,14 +1614,14 @@ PasteGameProc () // get game from clipboard GdkDisplay *gdisp = gdk_display_get_default(); if (gdisp == NULL) return; - cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD); + cb = gtk_clipboard_get_for_display(gdisp, GDK_SELECTION_CLIPBOARD); text = gtk_clipboard_wait_for_text(cb); - if (text == NULL) return; // nothing to paste + if (text == NULL) return; // nothing to paste len = strlen(text); // write to temp file if (text == NULL || len == 0) { - return; //nothing to paste + return; //nothing to paste } f = fopen(gamePasteFilename, "w"); if (f == NULL) { @@ -1684,7 +1631,7 @@ PasteGameProc () fwrite(text, 1, len, f); fclose(f); - // load from file + // load from file LoadGameFromFile(gamePasteFilename, 0, gamePasteFilename, TRUE); return; } @@ -1710,7 +1657,7 @@ void MoveTypeInProc(eventkey) buf[0]=eventkey->keyval; buf[1]='\0'; - if (*buf >= 32) + if (*buf >= 32) BoxAutoPopUp (buf); } @@ -2060,7 +2007,7 @@ UpdateLogos (int displ) return; } -void FileNamePopUpGTK(label, def, filter, proc, pathFlag, openMode, name, fp) +void FileNamePopUpWrapper(label, def, filter, proc, pathFlag, openMode, name, fp) char *label; char *def; char *filter; @@ -2160,4 +2107,3 @@ void FileNamePopUpGTK(label, def, filter, proc, pathFlag, openMode, name, fp) return; } -