X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xaw%2Fxboard.c;h=1c3ffc76607715fa075e7454d7c18fca5373d65a;hb=HEAD;hp=86d42836d7b200751f622366edc3e5e11ca72d0b;hpb=85164e1c15746506744f2ff807d7f39228a8b2f4;p=xboard.git diff --git a/xaw/xboard.c b/xaw/xboard.c index 86d4283..1c3ffc7 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -5,7 +5,8 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -148,6 +149,7 @@ extern char *getenv(); #include #endif +#include #include #include #include @@ -204,7 +206,6 @@ extern char *getenv(); #include "draw.h" #define SLASH '/' -#define DATADIR "~~" #ifdef __EMX__ #ifndef HAVE_USLEEP @@ -257,6 +258,7 @@ void ManInner P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void DisplayMove P((int moveNumber)); void update_ics_width P(()); int CopyMemoProc P(()); +static int FindLogo P((char *place, char *name, char *buf)); /* * XBoard depends on Xt R4 or higher @@ -536,7 +538,7 @@ CreateFonts () void ParseColor (int n, char *name) { // in XBoard, just copy the color-name string - if(colorVariable[n]) *(char**)colorVariable[n] = strdup(name); + if(colorVariable[n] && *name == '#') *(char**)colorVariable[n] = strdup(name); } char * @@ -1232,7 +1234,7 @@ main (int argc, char **argv) boardWidget = optList[W_BOARD].handle; menuBarWidget = optList[W_MENU].handle; dropMenu = optList[W_DROP].handle; - titleWidget = optList[optList[W_TITLE].type != -1 ? W_TITLE : W_SMALL].handle; + titleWidget = optList[optList[W_TITLE].type != Skip ? W_TITLE : W_SMALL].handle; formWidget = XtParent(boardWidget); XtSetArg(args[0], XtNbackground, &timerBackgroundPixel); XtSetArg(args[1], XtNforeground, &timerForegroundPixel); @@ -1288,13 +1290,15 @@ main (int argc, char **argv) CatchDeleteWindow(shellWidget, "QuitProc"); - CreateAnyPieces(); + CreateAnyPieces(1); CreateGrid(); if(appData.logoSize) { // locate and read user logo - char buf[MSG_SIZ]; - snprintf(buf, MSG_SIZ, "%s/%s.png", appData.logoDir, UserName()); + char buf[MSG_SIZ], name[MSG_SIZ]; + snprintf(name, MSG_SIZ, "/home/%s", UserName()); + if(!FindLogo(name, ".logo", buf)) + FindLogo(appData.logoDir, name + 6, buf); ASSIGN(userLogo, buf); } @@ -1705,7 +1709,7 @@ ReSize (WindowPlacement *wp) if(sqy < sqx) sqx = sqy; if(sqx != squareSize) { squareSize = sqx; // adopt new square size - CreatePNGPieces(); // make newly scaled pieces + CreatePNGPieces(appData.pieceDirectory); // make newly scaled pieces InitDrawingSizes(0, 0); // creates grid etc. } else ResizeBoardWindow(BOARD_WIDTH * (squareSize + lineGap) + lineGap, BOARD_HEIGHT * (squareSize + lineGap) + lineGap, 0); w = BOARD_WIDTH * (squareSize + lineGap) + lineGap; @@ -1815,7 +1819,7 @@ ModeHighlight () { Arg args[16]; static int oldPausing = FALSE; - static GameMode oldmode = (GameMode) -1; + static GameMode oldMode = (GameMode) -1; char *wname; if (!boardWidget || !XtIsRealized(boardWidget)) return; @@ -1841,7 +1845,7 @@ ModeHighlight () } } - wname = ModeToWidgetName(oldmode); + wname = ModeToWidgetName(oldMode); if (wname != NULL) { MarkMenuItem(wname, False); } @@ -1849,8 +1853,9 @@ ModeHighlight () if (wname != NULL) { MarkMenuItem(wname, True); } - oldmode = gameMode; + if(oldMode == TwoMachinesPlay) EnableNamedMenuItem("Mode.MachineMatch", True); MarkMenuItem("Mode.MachineMatch", matchMode && matchGame < appData.matchGames); + oldMode = gameMode; /* Maybe all the enables should be handled here, not just this one */ EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile); @@ -1993,6 +1998,7 @@ PasteGameCB (Widget w, XtPointer client_data, Atom *selection, Atom *type, XtPointer value, unsigned long *len, int *format) { FILE* f; + int flip = appData.flipView; if (value == NULL || *len == 0) { return; /* nothing had been selected to copy */ } @@ -2004,7 +2010,9 @@ PasteGameCB (Widget w, XtPointer client_data, Atom *selection, fwrite(value, 1, *len, f); fclose(f); XtFree(value); + if(!appData.autoFlipView) appData.flipView = flipView; LoadGameFromFile(gamePasteFilename, 0, gamePasteFilename, TRUE); + appData.flipView = flip; } /* called when Paste Game button is pressed, @@ -2121,6 +2129,15 @@ ManProc () } void +InfoProc () +{ + char buf[MSG_SIZ]; + snprintf(buf, sizeof(buf), "xterm -e info --directory %s --directory . -f %s &", + INFODIR, INFOFILE); + system(buf); +} + +void SetWindowTitle (char *text, char *title, char *icon) { Arg args[16]; @@ -2493,6 +2510,19 @@ FrameDelay (int time) #endif +static int +FindLogo (char *place, char *name, char *buf) +{ // check if file exists in given place + FILE *f; + if(!place) return 0; + snprintf(buf, MSG_SIZ, "%s/%s.png", place, name); + if(*place && strcmp(place, ".") && (f = fopen(buf, "r")) ) { + fclose(f); + return 1; + } + return 0; +} + static void LoadLogo (ChessProgramState *cps, int n, Boolean ics) { @@ -2502,8 +2532,11 @@ LoadLogo (ChessProgramState *cps, int n, Boolean ics) } else if(appData.autoLogo) { if(ics) { // [HGM] logo: in ICS mode second can be used for ICS sprintf(buf, "%s/%s.png", appData.logoDir, appData.icsHost); - } else if(appData.logoDir && appData.logoDir[0]) { - sprintf(buf, "%s/%s.png", appData.logoDir, cps->tidy); + } else { // engine; cascade + if(!FindLogo(appData.logoDir, cps->tidy, buf) && // first try user log folder + !FindLogo(appData.directory[n], "logo", buf) && // then engine directory + !FindLogo("/usr/local/share/games/plugins/logos", cps->tidy, buf) ) // then system folders + FindLogo("/usr/share/games/plugins/logos", cps->tidy, buf); } } if(logoName[0])