X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gtk%2Fxboard.c;h=7abd7cefc35eb7209072a74dbb42242da9c4fdf5;hb=51e9503489f2cee28a076bf52c56185a5283b069;hp=b76faef23a48e9a9f5b6d4c4b8207b38ad3356e9;hpb=6ff0cf268749094e92bdcdbdd2490993c9a4dcd5;p=xboard.git diff --git a/gtk/xboard.c b/gtk/xboard.c index b76faef..7abd7ce 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -167,16 +167,20 @@ extern char *getenv(); #include "gettext.h" #include "draw.h" -#ifdef OSX -# include "gtkmacintegration/gtkosxapplication.h" - // prevent pathname of positional file argument provided by OSx being be mistaken for option name +#ifdef __APPLE__ +# include + // prevent pathname of positional file argument provided by OS X being be mistaken for option name // (price is that we won't recognize Windows option format anymore). # define SLASH '-' // redefine some defaults # undef ICS_LOGON -# undef SYSCONFDIR +# undef DATADIR +# undef SETTINGS_FILE # define ICS_LOGON "Library/Preferences/XboardICS.conf" -# define SYSCONFDIR "../etc" +# define DATADIR dataDir +# define SETTINGS_FILE masterSettings + char dataDir[MSG_SIZ]; // for expanding ~~ + char masterSettings[MSG_SIZ]; #else # define SLASH '/' #endif @@ -519,6 +523,12 @@ GetActualPlacement (GtkWidget *shell, WindowPlacement *wp) } void +GetPlacement (DialogClass dlg, WindowPlacement *wp) +{ // wrapper to shield back-end from widget type + if(shellUp[dlg]) GetActualPlacement(shells[dlg], wp); +} + +void GetWindowCoords () { // wrapper to shield use of window handles from back-end (make addressible by number?) // In XBoard this will have to wait until awareness of window parameters is implemented @@ -529,6 +539,7 @@ GetWindowCoords () if(shellUp[GameListDlg]) GetActualPlacement(shells[GameListDlg], &wpGameList); if(shellUp[CommentDlg]) GetActualPlacement(shells[CommentDlg], &wpComment); if(shellUp[TagsDlg]) GetActualPlacement(shells[TagsDlg], &wpTags); + GetPlacement(ChatDlg, &wpConsole); if(appData.icsActive) wpConsole.visible = shellUp[ChatDlg]; } void @@ -676,6 +687,7 @@ PrintArg (ArgType t) case ArgTwo: case ArgNone: case ArgCommSettings: + default: break; } return p; @@ -725,7 +737,7 @@ SlaveResize (Option *opt) gtk_window_resize(GTK_WINDOW(shells[DummyDlg]), slaveW + opt->max, slaveH + opt->value); } -#ifdef OSX +#ifdef __APPLE__ static char clickedFile[MSG_SIZ]; static int suppress; @@ -747,7 +759,7 @@ int main (int argc, char **argv) { int i, clockFontPxlSize, coordFontPxlSize, fontPxlSize; - int boardWidth, boardHeight, w, h; + int boardWidth, w, h; //, boardHeight; char *p; int forceMono = False; @@ -758,7 +770,7 @@ main (int argc, char **argv) debugFP = stderr; if(argc > 1 && (!strcmp(argv[1], "-v" ) || !strcmp(argv[1], "--version" ))) { - printf("%s version %s\n", PACKAGE_NAME, PACKAGE_VERSION); + printf("%s version %s\n\n configure options: %s\n", PACKAGE_NAME, PACKAGE_VERSION, CONFIGURE_OPTIONS); exit(0); } @@ -769,9 +781,12 @@ main (int argc, char **argv) /* set up GTK */ gtk_init (&argc, &argv); -#ifdef OSX +#ifdef __APPLE__ { // prepare to catch OX OpenFile signal, which will tell us the clicked file GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); + char *path = gtkosx_application_get_bundle_path(); + strncpy(dataDir, path, MSG_SIZ); + snprintf(masterSettings, MSG_SIZ, "%s/Contents/Resources/etc/xboard.conf", path); g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), NULL); // we must call application ready before we can get the signal, // and supply a (dummy) menu bar before that, to avoid problems with dual apples in it @@ -792,6 +807,23 @@ main (int argc, char **argv) } #endif + if(argc > 1 && !strcmp(argv[1], "--show-config")) { // [HGM] install: called to print config info + typedef struct {char *name, *value; } Config; + static Config configList[] = { + { "Datadir", DATADIR }, + { "Sysconfdir", SYSCONFDIR }, + { NULL } + }; + int i; + + for(i=0; configList[i].name; i++) { + if(argc > 2 && strcmp(argv[2], configList[i].name)) continue; + if(argc > 2) printf("%s", configList[i].value); + else printf("%-12s: %s\n", configList[i].name, configList[i].value); + } + exit(0); + } + /* set up keyboard accelerators group */ GtkAccelerators = gtk_accel_group_new(); @@ -823,6 +855,8 @@ main (int argc, char **argv) { // [HGM] initstring: kludge to fix bad bug. expand '\n' characters in init string and computer string. static char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, appData.sysOpen, DATADIR); + ASSIGN(appData.sysOpen, buf); // expand %s in -openCommand to DATADIR (usefull for OS X configuring) EscapeExpand(buf, appData.firstInitString); appData.firstInitString = strdup(buf); EscapeExpand(buf, appData.secondInitString); @@ -940,7 +974,7 @@ main (int argc, char **argv) /* [HR] height treated separately (hacked) */ boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap); - boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); +// boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); /* * Determine what fonts to use. @@ -1094,6 +1128,11 @@ main (int argc, char **argv) EngineOutputPopUp(); } + if( wpConsole.visible && appData.icsActive ) { + ChatProc(); + BoardToTop(); + } + InitBackEnd2(); if (errorExitStatus == -1) { @@ -1332,7 +1371,7 @@ EnableNamedMenuItem (char *menuRef, int state) { MenuItem *item = MenuNameToItem(menuRef); - if(item) gtk_widget_set_sensitive(item->handle, state); + if(item && item->handle) gtk_widget_set_sensitive(item->handle, state); } void @@ -1533,6 +1572,7 @@ DragProc () if(shellUp[HistoryDlg]) CoDrag(shells[HistoryDlg], &wpMoveHistory); if(shellUp[EvalGraphDlg]) CoDrag(shells[EvalGraphDlg], &wpEvalGraph); if(shellUp[GameListDlg]) CoDrag(shells[GameListDlg], &wpGameList); + if(shellUp[ChatDlg]) CoDrag(shells[ChatDlg], &wpConsole); } wpMain = wpNew; DrawPosition(True, NULL); @@ -1776,26 +1816,17 @@ TempForwardProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) ForwardEvent(); TempBackwardActive = False; } - -void -ManInner (Widget w, XEvent *event, String *prms, Cardinal *nprms) -{ // called as key binding - char buf[MSG_SIZ]; - String name; - if (nprms && *nprms > 0) - name = prms[0]; - else - name = "xboard"; - snprintf(buf, sizeof(buf), "xterm -e man %s &", name); - system(buf); -} #endif void ManProc () { // called from menu -#ifdef TODO_GTK - ManInner(NULL, NULL, NULL, NULL); +#ifdef __APPLE__ + char buf[MSG_SIZ]; + snprintf(buf, MSG_SIZ, "%s ./man.command", appData.sysOpen); + system(buf); +#else + system("xterm -e man xboard &"); #endif }