// 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 '-'
+# define IMG ".png"
// redefine some defaults
# undef ICS_LOGON
# undef DATADIR
# define ICS_LOGON "Library/Preferences/XboardICS.conf"
# define DATADIR dataDir
# define SETTINGS_FILE masterSettings
+# define SYNC_MENUBAR gtkosx_application_sync_menubar(theApp)
char dataDir[MSG_SIZ]; // for expanding ~~
char masterSettings[MSG_SIZ];
#else
# define SLASH '/'
+# define IMG ".svg"
+# define SYNC_MENUBAR
#endif
#ifdef __EMX__
// defer processing it until we know if it matches our board size
if(!strstr(name, "-*-") && // ignore X-fonts
size >= 0 && size<MAX_SIZE) { // for now, fixed limit
- fontTable[number][size] = name = strdup(strchr(name, ':')+1);
+ fontTable[number][size] = strdup(strchr(name, ':')+1);
fontValid[number][size] = True;
- } else return;
+ }
+ return;
}
switch(number) {
case 0: // CLOCK_FONT
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 *
appData.coordFont = fontTable[COORD_FONT][squareSize];
if(!fontIsSet[CONSOLE_FONT] && fontValid[CONSOLE_FONT][squareSize])
appData.icsFont = fontTable[CONSOLE_FONT][squareSize];
+ if(!fontIsSet[EDITTAGS_FONT] && fontValid[EDITTAGS_FONT][squareSize])
+ appData.tagsFont = fontTable[EDITTAGS_FONT][squareSize];
if(!fontIsSet[COMMENT_FONT] && fontValid[COMMENT_FONT][squareSize])
appData.commentFont = fontTable[COMMENT_FONT][squareSize];
+ if(!fontIsSet[MOVEHISTORY_FONT] && fontValid[MOVEHISTORY_FONT][squareSize])
+ appData.historyFont = fontTable[MOVEHISTORY_FONT][squareSize];
+ if(!fontIsSet[GAMELIST_FONT] && fontValid[GAMELIST_FONT][squareSize])
+ appData.gameListFont = fontTable[GAMELIST_FONT][squareSize];
- appData.font = InsertPxlSize(appData.font, fontPxlSize);
+ appData.font = InsertPxlSize(appData.font, coordFontPxlSize);
appData.clockFont = InsertPxlSize(appData.clockFont, clockFontPxlSize);
appData.coordFont = InsertPxlSize(appData.coordFont, coordFontPxlSize);
- appData.icsFont = InsertPxlSize(appData.icsFont, fontPxlSize);
- appData.tagsFont = InsertPxlSize(appData.tagsFont, fontPxlSize);
- appData.commentFont = InsertPxlSize(appData.commentFont, fontPxlSize);
- appData.historyFont = InsertPxlSize(appData.historyFont, fontPxlSize);
- appData.gameListFont = InsertPxlSize(appData.gameListFont, fontPxlSize);
+ appData.icsFont = InsertPxlSize(appData.icsFont, coordFontPxlSize);
+ appData.tagsFont = InsertPxlSize(appData.tagsFont, coordFontPxlSize);
+ appData.commentFont = InsertPxlSize(appData.commentFont, coordFontPxlSize);
+ appData.historyFont = InsertPxlSize(appData.historyFont, coordFontPxlSize);
+ appData.gameListFont = InsertPxlSize(appData.gameListFont, coordFontPxlSize);
#ifdef TODO_GTK
XrmValue vTo;
gtk_window_resize(GTK_WINDOW(shells[DummyDlg]), slaveW + opt->max, slaveH + opt->value);
}
+GdkPixbuf *
+LoadIconFile (gchar *svgFilename)
+{
+ char buf[MSG_SIZ];
+
+ snprintf(buf, MSG_SIZ, "%s/%s" IMG, svgDir, svgFilename);
+ return gdk_pixbuf_new_from_file(buf, NULL);
+}
+
#ifdef __APPLE__
static char clickedFile[MSG_SIZ];
static int suppress;
}
return TRUE;
}
+
+GtkosxApplication *theApp;
#endif
int
gtk_init (&argc, &argv);
#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();
+ theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
strncpy(dataDir, path, MSG_SIZ);
snprintf(masterSettings, MSG_SIZ, "%s/Contents/Resources/etc/xboard.conf", path);
+ snprintf(svgDir, MSG_SIZ, "%s/Contents/Resources/share/xboard/themes/default", path);
suppress = (argc == 1 || argc > 1 && argv[1][00] != '-'); // OSX sends signal even if name was already argv[1]!
g_signal_connect(theApp, "NSApplicationOpenFile", G_CALLBACK(StartNewXBoard), NULL);
// we must call application ready before we can get the signal,
} else {
SizeDefaults *szd = sizeDefaults;
if (*appData.boardSize == NULLCHAR) {
- GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(mainwindow)); // TODO: this does not work, as no mainwindow yet
+// GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(mainwindow)); // TODO: this does not work, as no mainwindow yet
+ GdkScreen *screen = gdk_screen_get_default();
guint screenwidth = gdk_screen_get_width(screen);
guint screenheight = gdk_screen_get_height(screen);
while (screenwidth < (szd->minScreenSize*BOARD_WIDTH + 4)/8 ||
/*
* Create an icon. (Use two icons, to indicate whther it is white's or black's turn.)
*/
- WhiteIcon = gdk_pixbuf_new_from_file(SVGDIR "/icon_white.svg", NULL);
- BlackIcon = gdk_pixbuf_new_from_file(SVGDIR "/icon_black.svg", NULL);
- mainwindowIcon = WhiteIcon;
- gtk_window_set_icon(GTK_WINDOW(shellWidget), mainwindowIcon);
+ WhiteIcon = LoadIconFile("icon_white");
+ BlackIcon = LoadIconFile("icon_black");
+ SetClockIcon(0); // sets white icon
/*
marginH = h - a.height - hc; // subtract current clock height, so it can be added back dynamically
}
- CreateAnyPieces();
+ CreateAnyPieces(1);
CreateGrid();
if(appData.logoSize)
#endif
void
+MarkMenuItem (char *menuRef, int state)
+{
+ MenuItem *item = MenuNameToItem(menuRef);
+
+ if(item && item->handle) {
+ ((GtkCheckMenuItem *) (item->handle))->active = state;
+ }
+ SYNC_MENUBAR;
+}
+
+void
EnableNamedMenuItem (char *menuRef, int state)
{
MenuItem *item = MenuNameToItem(menuRef);
if(item && item->handle) gtk_widget_set_sensitive(item->handle, state);
+ SYNC_MENUBAR;
}
void
void
CoDrag (GtkWidget *sh, WindowPlacement *wp)
{
- int touch=0, fudge = 2, f = 2;
+ int touch=0, fudge = 4, f = 3;
GetActualPlacement(sh, wp);
if(abs(wpMain.x + wpMain.width + 2*frameX - f - wp->x) < fudge) touch = 1; else // right touch
- if(abs(wp->x + wp->width + 2*frameX + f - wpMain.x) < fudge) touch = 2; else // left touch
+ if(abs(wp->x + wp->width + 2*frameX - f - wpMain.x) < fudge) touch = 2; else // left touch
if(abs(wpMain.y + wpMain.height + frameX - f + frameY - wp->y) < fudge) touch = 3; else // bottom touch
- if(abs(wp->y + wp->height + frameX + frameY + f - wpMain.y) < fudge) touch = 4; // top touch
+ if(abs(wp->y + wp->height + frameX + frameY - f - wpMain.y) < fudge) touch = 4; // top touch
//printf("CoDrag: touch = %d x=%d w=%d x2=%d w2=%d fx=%d\n", touch, wpMain.x, wpMain.width, wp->x, wp->width, frameX);
if(!touch ) return; // only windows that touch co-move
if(touch < 3 && wpNew.height != wpMain.height) { // left or right and height changed
GdkPixbuf *pm = *clockIcons[color];
if (mainwindowIcon != pm) {
mainwindowIcon = pm;
- gtk_window_set_icon(GTK_WINDOW(shellWidget), mainwindowIcon);
+#ifdef __APPLE__
+ gtkosx_application_set_dock_icon_pixbuf(theApp, mainwindowIcon);
+#else
+ gtk_window_set_icon(GTK_WINDOW(shellWidget), mainwindowIcon);
+#endif
}
}
LoadLogo (ChessProgramState *cps, int n, Boolean ics)
{
char buf[MSG_SIZ], *logoName = buf;
+ FILE *f;
if(appData.logo[n][0]) {
logoName = appData.logo[n];
} 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.directory[n] && appData.directory[n][0]) {
- sprintf(buf, "%s/%s.png", appData.logoDir, cps->tidy);
+ } else { // engine; look in engine-dir (if any) first
+ snprintf(buf, MSG_SIZ, "%s/logo.png", appData.directory[n]);
+ if(appData.directory[n] && appData.directory[n][0]
+ && strcmp(appData.directory[n], ".") && (f = fopen(buf, "r")) )
+ fclose(f);
+ else // no engine dir or no logo.png in it: look in logo dir
+ if(appData.logoDir && appData.logoDir[0])
+ sprintf(buf, "%s/%s.png", appData.logoDir, cps->tidy);
}
}
if(logoName[0])