X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gtk%2Fxboard.c;h=40e41c80ae1837043d7f79bfc1667f5a8aabfb3a;hb=0e604fd62231e9375a446a4891efa1ede735f4d2;hp=5befaa3e4b4d5d19a5b976b26c15357bd852b01e;hpb=24b15367908445cfb5c7bcce33587d2f666faf89;p=xboard.git diff --git a/gtk/xboard.c b/gtk/xboard.c index 5befaa3..40e41c8 100644 --- a/gtk/xboard.c +++ b/gtk/xboard.c @@ -172,6 +172,7 @@ extern char *getenv(); // 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 @@ -179,10 +180,13 @@ extern char *getenv(); # 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__ @@ -386,9 +390,10 @@ ParseFont (char *name, int number) // defer processing it until we know if it matches our board size if(!strstr(name, "-*-") && // ignore X-fonts size >= 0 && sizemax, 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; @@ -851,6 +871,7 @@ main (int argc, char **argv) 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, @@ -1118,8 +1139,8 @@ main (int argc, char **argv) /* * 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); + WhiteIcon = LoadIconFile("icon_white"); + BlackIcon = LoadIconFile("icon_black"); SetClockIcon(0); // sets white icon @@ -1161,7 +1182,7 @@ main (int argc, char **argv) marginH = h - a.height - hc; // subtract current clock height, so it can be added back dynamically } - CreateAnyPieces(); + CreateAnyPieces(1); CreateGrid(); if(appData.logoSize) @@ -1447,11 +1468,23 @@ FindFont (char *pattern, int targetPxlSize) #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 @@ -2011,7 +2044,11 @@ SetClockIcon (int color) 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 } } @@ -2191,13 +2228,20 @@ static void 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])