Large bundle of OS X tweaks by Eric P. (basis of the 10.9-compatible

pre-release made in Dec. 2013):
 * Fix OS X 10.9 issue of current directory set by Finder
   to something else than folder where app bundle resides.
 * Some Mac OS X build / project changes & updates.
 * Adjustments to Mac OS X fontconfig config file, to avoid warnings
   and make things more robust.
 * Updates to some #include's to catch up with newer library revisions.
 * Tweaks to pixel read/write on Apple.
 * Introduction of 'intprt_t' casting to avoid warnings on x64.
 * Some additional debugging output.
 * Logging stderr & stdout to /tmp/tuxpaint.log
Untested (I don't have a Mac!)
This commit is contained in:
William Kendrick 2014-03-19 23:39:17 +00:00
parent e5b2182c0a
commit e990b48de7
14 changed files with 982 additions and 817 deletions

View file

@ -74,9 +74,27 @@ $Id$
Produced by Eric Poncet <http://www.linguasoft.com/> Produced by Eric Poncet <http://www.linguasoft.com/>
Commissioned by Harvey Ginter <harveyginter@gmail.com> Commissioned by Harvey Ginter <harveyginter@gmail.com>
* Fix OS X 10.9 issue of current directory set by Finder
to something else than folder where app bundle resides.
* Customization support for Mac OS X (automatic, under XCode) * Customization support for Mac OS X (automatic, under XCode)
and Windows (manual). and Windows (manual).
* Some Mac OS X build / project changes & updates.
* Adjustments to Mac OS X fontconfig config file, to avoid warnings
and make things more robust.
* Updates to some #include's to catch up with newer library revisions.
* Tweaks to pixel read/write on Apple.
* Introduction of 'intprt_t' casting to avoid warnings on x64.
* Some additional debugging output.
* Logging stderr & stdout to /tmp/tuxpaint.log
* Accessibility Improvements: * Accessibility Improvements:
--------------------------- ---------------------------
* Added a mouse accessibility mode to avoid the need to drag the mouse. * Added a mouse accessibility mode to avoid the need to drag the mouse.

View file

@ -74,8 +74,7 @@ This library will already have been built and installed by MacPorts, but will no
% tar xzf fontconfig*.tar.gz % tar xzf fontconfig*.tar.gz
% cd fontconfig* % cd fontconfig*
% sudo port deactivate fontconfig % sudo port deactivate fontconfig
% ./configure --prefix=/Users/Shared/tuxpaint --enable-static --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint --enable-static --disable-shared --disable-docs --with-confdir="/Library/Application Support/TuxPaint/fontconfig/fonts" --with-cache-dir="/Library/Application Support/TuxPaint/fontconfig/cache" CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib
% --disable-docs --with-confdir="/Library/Application Support/TuxPaint/fontconfig/fonts" --with-cache-dir="/Library/Application Support/TuxPaint/fontconfig/cache" CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib
% sudo make install % sudo make install
% sudo port activate fontconfig % sudo port activate fontconfig
@ -102,6 +101,7 @@ MacPorts only installs the dynamic libraries for Pango. We need to reconfigure
% cd pango* % cd pango*
% sudo port deactivate pango % sudo port deactivate pango
% ./configure --prefix=/Users/Shared/tuxpaint --enable-static CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib --with-included-modules=yes --with-dynamic-modules=no --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint --enable-static CPPFLAGS=-I/opt/local/include LDFLAGS=-L/opt/local/lib --with-included-modules=yes --with-dynamic-modules=no --disable-shared
//EP pas de "make" ?
% sudo make install % sudo make install
% sudo find . -name "*.a" -exec cp {} /Users/Shared/tuxpaint/lib/ \; % sudo find . -name "*.a" -exec cp {} /Users/Shared/tuxpaint/lib/ \;
% sudo port activate pango % sudo port activate pango
@ -116,6 +116,7 @@ Assuming you place the sources in /Users/Shared/tuxpaint/src/libsvg, you can con
% cd /Users/Shared/tuxpaint/src/libsvg % cd /Users/Shared/tuxpaint/src/libsvg
% ./autogen.sh % ./autogen.sh
% ./configure --prefix=/Users/Shared/tuxpaint LIBSVG_CFLAGS=-I/usr/include LIBSVG_LIBS=-L/usr/lib --disable-shared % ./configure --prefix=/Users/Shared/tuxpaint LIBSVG_CFLAGS=-I/usr/include LIBSVG_LIBS=-L/usr/lib --disable-shared
//EP pas de "make" ?
% make install % make install
SVG Cairo: SVG Cairo:

View file

@ -131,7 +131,7 @@ static NSString *getApplicationName(void)
mainBundle = [NSBundle mainBundle]; mainBundle = [NSBundle mainBundle];
path = [mainBundle pathForResource:@"data" ofType:nil]; path = [mainBundle pathForResource:@"data" ofType:nil];
[path getCString:(macosx.dataPath)]; [path getCString:(macosx.dataPath) maxLength:sizeof(macosx.dataPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
-(void) preferencesPath; -(void) preferencesPath;
@ -139,10 +139,11 @@ static NSString *getApplicationName(void)
NSString *path; NSString *path;
path = [@"~/Library/Application Support/TuxPaint" stringByExpandingTildeInPath]; path = [@"~/Library/Application Support/TuxPaint" stringByExpandingTildeInPath];
[path getCString:(macosx.preferencesPath)]; [path getCString:(macosx.preferencesPath) maxLength:sizeof(macosx.preferencesPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
path = @"/Library/Application Support/TuxPaint"; path = @"/Library/Application Support/TuxPaint";
[path getCString:(macosx.globalPreferencesPath)]; [path getCString:(macosx.globalPreferencesPath) maxLength:sizeof(macosx.globalPreferencesPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
-(void) fontsPath; -(void) fontsPath;
@ -150,7 +151,7 @@ static NSString *getApplicationName(void)
NSString *path; NSString *path;
path = [@"~/Library/Fonts" stringByExpandingTildeInPath]; path = [@"~/Library/Fonts" stringByExpandingTildeInPath];
[path getCString:(macosx.fontsPath)]; [path getCString:(macosx.fontsPath) maxLength:sizeof(macosx.fontsPath) encoding:NSUTF8StringEncoding]; //EP added maxLength: and encoding: to avoid deprecation warning for 10.6
} }
@end @end
@ -330,7 +331,7 @@ static NSString *getApplicationName(void)
if ([menuItem hasSubmenu]) if ([menuItem hasSubmenu])
[self fixMenu:[menuItem submenu] withAppName:appName]; [self fixMenu:[menuItem submenu] withAppName:appName];
} }
[aMenu sizeToFit]; //EP commented line to avoid deprecation warning for 10.6: [aMenu sizeToFit];
} }
#else #else
@ -488,7 +489,8 @@ static void CustomApplicationMain (argc, argv)
NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)]; NSString *arguments = [NSString stringWithCString:(macosx.globalPreferencesPath)];
char command[4096]; char command[4096];
sprintf(command, "\"%s\" \"%s\"", [executable cString], [arguments cString]); //EP commented to avoid deprecation warning for 10.6: sprintf(command, "\"%s\" \"%s\"", [executable cString], [arguments cString]);
sprintf(command, "\"%@\" \"%@\"", executable, arguments);
int result = system(command); int result = system(command);
@ -520,7 +522,7 @@ static void CustomApplicationMain (argc, argv)
char *arguments[] = { "/Library/Application Support/TuxPaint", NULL }; char *arguments[] = { "/Library/Application Support/TuxPaint", NULL };
FILE *communicationsPipe = NULL; FILE *communicationsPipe = NULL;
strcpy(executable, [fcInstallerPath cString]); strcpy(executable, [fcInstallerPath cStringUsingEncoding:NSUTF8StringEncoding]); //EP replaced cString by cStringUsingEncoding: to avoid deprecation warning for 10.6
flags = kAuthorizationFlagDefaults; flags = kAuthorizationFlagDefaults;
status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe); status = AuthorizationExecuteWithPrivileges(authorizationRef, executable, flags, arguments, &communicationsPipe);
@ -547,7 +549,7 @@ static void CustomApplicationMain (argc, argv)
- (void) setupFontconfig - (void) setupFontconfig
{ {
/* Tell Fontconfig to use font configuration file in application bundle */ /* Tell Fontconfig to use font configuration file in application bundle */
setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cString], 1); setenv ("FONTCONFIG_PATH", [[[NSBundle mainBundle] resourcePath] cStringUsingEncoding:NSUTF8StringEncoding], 1); //EP replaced cString by cStringUsingEncoding: to avoid deprecation warning for 10.6
/* Install font configuration file */ /* Install font configuration file */
/* /*

File diff suppressed because it is too large Load diff

View file

@ -19,20 +19,30 @@
--> -->
<!-- Font directory list configured on Sun Sep 14 17:12:54 PDT 2003 --> <!-- Font directory list configured on Sun Sep 14 17:12:54 PDT 2003 -->
<!--
//EP
//commented out paths that prevented Inuktitut from rendering
-->
<dir>/Library/Fonts</dir>
<dir>/Network/Library/Fonts</dir>
<!--dir>/System/Library/Fonts</dir-->
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir>
<dir>/usr/X11R6/lib/X11/fonts/TTF</dir>
<dir>/usr/share/fonts</dir>
<dir>~/Library/Fonts</dir>
<dir>~/.fonts</dir>
<dir>/Library/Fonts</dir> <!--
<dir>/Network/Library/Fonts</dir> //EP
<dir>/System/Library/Fonts</dir> //<cache> was ignored and every program init was slow
<dir>/usr/X11R6/lib/X11/fonts/Type1</dir> //replaced it by <cachedir> which reenabled the cache font and sped up further program inits
<dir>/usr/X11R6/lib/X11/fonts/TTF</dir> <cache>~/.fontconfig</cache>
<dir>/usr/share/fonts</dir> -->
<dir>~/Library/Fonts</dir> <cachedir>~/.fontconfig</cachedir>
<dir>~/.fonts</dir>
<cache>~/.fontconfig</cache>
<!-- <!--
Enable sub-pixel rendering Enable sub-pixel rendering
<match target="font"> <match target="font">
<test qual="all" name="rgba"> <test qual="all" name="rgba">
<const>unknown</const> <const>unknown</const>
</test> </test>
@ -84,49 +94,179 @@
<!-- <!--
Serif faces Serif faces
--> -->
<alias> <!--
<family>Times</family> //EP
<family>Times New Roman</family> //this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
<family>Nimbus Roman No9 L</family> //fixed by splitting alias so as to get only one family per alias
<family>Luxi Serif</family> <alias>
<family>Kochi Mincho</family> <family>Times</family>
<family>AR PL SungtiL GB</family> <family>Times New Roman</family>
<family>AR PL Mingti2L Big5</family> <family>Nimbus Roman No9 L</family>
<family>Baekmuk Batang</family> <family>Luxi Serif</family>
<default><family>serif</family></default> <family>Kochi Mincho</family>
</alias> <family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
<default><family>serif</family></default>
</alias>
-->
<alias>
<family>Times</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Times New Roman</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Nimbus Roman No9 L</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Luxi Serif</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Kochi Mincho</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>AR PL SungtiL GB</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>AR PL Mingti2L Big5</family>
<default><family>serif</family></default>
</alias>
<alias>
<family>Baekmuk Batang</family>
<default><family>serif</family></default>
</alias>
<!-- <!--
Sans-serif faces Sans-serif faces
--> -->
<alias> <!--
<family>Lucida Grande</family> //EP
<family>Geneva</family> //this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
<family>Helvetica</family> //fixed by splitting alias so as to get only one family per alias
<family>Arial</family> <alias>
<family>Verdana</family> <family>Lucida Grande</family>
<family>Nimbus Sans L</family> <family>Geneva</family>
<family>Luxi Sans</family> <family>Helvetica</family>
<family>Osaka</family> <family>Arial</family>
<family>Kochi Gothic</family> <family>Verdana</family>
<family>AR PL KaitiM GB</family> <family>Nimbus Sans L</family>
<family>AR PL KaitiM Big5</family> <family>Luxi Sans</family>
<family>Baekmuk Dotum</family> <family>Osaka</family>
<family>SimSun</family> <family>Kochi Gothic</family>
<default><family>sans-serif</family></default> <family>AR PL KaitiM GB</family>
</alias> <family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
<family>SimSun</family>
<default><family>sans-serif</family></default>
</alias>
-->
<alias>
<family>Lucida Grande</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Geneva</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Helvetica</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Arial</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Verdana</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Nimbus Sans L</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Luxi Sans</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Osaka</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Kochi Gothic</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>AR PL KaitiM GB</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>AR PL KaitiM Big5</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>Baekmuk Dotum</family>
<default><family>sans-serif</family></default>
</alias>
<alias>
<family>SimSun</family>
<default><family>sans-serif</family></default>
</alias>
<!-- <!--
Monospace faces Monospace faces
--> -->
<alias> <!--
<family>Monaco</family> //EP
<family>Courier</family> //this generated Fontconfig warning: line XXX: Having multiple <family> in <alias> isn't supported and may not work as expected
<family>Courier New</family> //fixed by splitting alias so as to get only one family per alias
<family>Andale Mono</family> <alias>
<family>Luxi Mono</family> <family>Monaco</family>
<family>Nimbus Mono L</family> <family>Courier</family>
<family>NSimSun</family> <family>Courier New</family>
<default><family>monospace</family></default> <family>Andale Mono</family>
</alias> <family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>NSimSun</family>
<default><family>monospace</family></default>
</alias>
-->
<alias>
<family>Monaco</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Courier</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Courier New</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Andale Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Luxi Mono</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>Nimbus Mono L</family>
<default><family>monospace</family></default>
</alias>
<alias>
<family>NSimSun</family>
<default><family>monospace</family></default>
</alias>
<!-- <!--
If the font still has no generic name, add sans-serif If the font still has no generic name, add sans-serif
--> -->

View file

@ -140,11 +140,16 @@ static void do_alien_pixel(void * ptr, int which ATTRIBUTE_UNUSED,
double temp2[3]; double temp2[3];
int k; int k;
SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]); SDL_GetRGB(api->getpixel(canvas,x, y), canvas->format, &temp[0], &temp[1], &temp[2]);
for (k =0;k<3;k++){ for (k =0;k<3;k++){
temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255); //EP temp2[k] = clamp(0,127.5 * (1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)),255);
temp2[k] = clamp(0.0,
127.5 * (
1.0 + sin (((temp[k] / 127.5 - 1.0) * alien_FREQUENCY[k] + alien_ANGLE[k] / 180.0) * M_PI)
),
255.0);
} }
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2])); api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, temp2[0], temp2[1], temp2[2]));
} }

View file

@ -107,13 +107,13 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
char fname[512]; char fname[512];
TuxPaint_Font *font; TuxPaint_Font *font;
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str); snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
/* printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); */ /* */printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); /**/ //EP
if (locale && strstr(fname, "locale") && !all_locale_fonts) if (locale && strstr(fname, "locale") && !all_locale_fonts)
{ {
char fname_check[512]; char fname_check[512];
/* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */ /* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */
snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale); snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale);
/* printf("checking vs \"%s\" vs \"%s\"\n", fname_check, fname); */ /* */printf("checking vs \"%s\" vs \"%s\"\n", fname_check, fname); /**/ //EP
if (strcmp(fname, fname_check) == 0) if (strcmp(fname, fname_check) == 0)
font = TuxPaint_Font_OpenFont("", fname, text_sizes[text_size]); font = TuxPaint_Font_OpenFont("", fname, text_sizes[text_size]);
else else
@ -136,7 +136,7 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
family, style); family, style);
printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n", printf("success: tpf: 0x%x tpf->ttf_font: 0x%x\n",
(unsigned int) font, (unsigned int) font->ttf_font); (unsigned int)(intptr_t) font, (unsigned int)(intptr_t) font->ttf_font); //EP added (intptr_t) to avoid warning on x64
#endif #endif
// These fonts crash Tux Paint via a library bug. // These fonts crash Tux Paint via a library bug.

View file

@ -259,15 +259,24 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf) void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
{ {
printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP
if (!tpf) return; //EP
#ifndef NO_SDLPANGO #ifndef NO_SDLPANGO
printf("TuxPaint_Font_CloseFont step 2 (%p, %d)\n", tpf->pango_context, tpf->typ); //EP
if (tpf->typ == FONT_TYPE_PANGO) if (tpf->typ == FONT_TYPE_PANGO)
if (tpf->pango_context) //EP
{ {
SDLPango_FreeContext(tpf->pango_context); #ifndef __APPLE__ //EP added ifdef because SDLPango_FreeContext sometimes crashed with "pointer being freed was not allocated"
tpf->pango_context = NULL; SDLPango_FreeContext(tpf->pango_context);
#endif
tpf->pango_context = NULL;
} }
#endif #endif
printf("TuxPaint_Font_CloseFont step 3 (%p, %d)\n", tpf->ttf_font, tpf->typ); //EP
if (tpf->typ == FONT_TYPE_TTF) if (tpf->typ == FONT_TYPE_TTF)
if (tpf->ttf_font) //EP
{ {
TTF_CloseFont(tpf->ttf_font); TTF_CloseFont(tpf->ttf_font);
tpf->ttf_font = NULL; tpf->ttf_font = NULL;
@ -956,6 +965,8 @@ static void loadfonts(SDL_Surface * screen, const char *const dir)
status_t result; status_t result;
result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_SYSTEM_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer); loadfonts(screen, buffer);
result = find_directory(B_COMMON_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer);
result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer)); result = find_directory(B_USER_FONTS_DIRECTORY, volume, false, buffer, sizeof(buffer));
loadfonts(screen, buffer); loadfonts(screen, buffer);
#elif defined(__APPLE__) #elif defined(__APPLE__)
@ -1286,7 +1297,7 @@ TuxPaint_Font *getfonthandle(int desire)
} }
else else
{ {
#ifdef DBEUG #ifdef DEBUG //EP fixed typo: replaced DBEUG with DEBUG
printf("fi->filename is NULL\n"); printf("fi->filename is NULL\n");
fflush(stdout); fflush(stdout);
#endif #endif
@ -1297,7 +1308,8 @@ TuxPaint_Font *getfonthandle(int desire)
if (fi->handle) if (fi->handle)
{ {
#ifdef DEBUG #ifdef DEBUG
printf("fi->handle was set (0x%x)\n", (int) fi->handle); printf("fi->handle was set (0x%x)\n", (int)(intptr_t) fi->handle); //EP added (intptr_t) to avoid warning on x64
fflush(stdout); fflush(stdout);
#endif #endif
return fi->handle; return fi->handle;

View file

@ -481,7 +481,7 @@ static void show_lang_usage(int exitcode)
/* xh */ " xhosa\n" /* xh */ " xhosa\n"
/* zam */" zapotec miahuatlan-zapotec\n" /* zam */" zapotec miahuatlan-zapotec\n"
/* zu */ " zulu\n" /* zu */ " zulu\n"
"\n", prg); "\n", prg);
exit(exitcode); exit(exitcode);
} }
@ -500,15 +500,15 @@ static void show_locale_usage(FILE * f, const char *const prg)
" af_ZA (Afrikaans)\n" " af_ZA (Afrikaans)\n"
" ak_GH (Akan Twi-Fante)\n" " ak_GH (Akan Twi-Fante)\n"
" am_ET (Amharic)\n" " am_ET (Amharic)\n"
" ar_SA (Arabic)\n" " ar_SA (Arabic)\n"
" an_ES (Aragones)\n" " an_ES (Aragones)\n"
" hy_AM (Armenian)\n" " hy_AM (Armenian)\n"
" ast_ES (Asturian)\n" " ast_ES (Asturian)\n"
" az_AZ (Azerbaijani)\n" " az_AZ (Azerbaijani)\n"
" bm_ML (Bambara)\n" " bm_ML (Bambara)\n"
" eu_ES (Basque Euskara)\n" " eu_ES (Basque Euskara)\n"
" be_BY (Belarusian Bielaruskaja)\n" " be_BY (Belarusian Bielaruskaja)\n"
" nb_NO (Bokmal)\n" " nb_NO (Bokmal)\n"
" pt_BR (Brazilian Brazilian Portuguese Portugues Brazilian)\n" " pt_BR (Brazilian Brazilian Portuguese Portugues Brazilian)\n"
" br_FR (Breton Brezhoneg)\n" " br_FR (Breton Brezhoneg)\n"
" en_AU (Australian English)\n" " en_AU (Australian English)\n"
@ -546,19 +546,19 @@ static void show_locale_usage(FILE * f, const char *const prg)
" id_ID (Indonesian Bahasa Indonesia)\n" " id_ID (Indonesian Bahasa Indonesia)\n"
" it_IT (Italian Italiano)\n" " it_IT (Italian Italiano)\n"
" iu_CA (Inuktitut)\n" " iu_CA (Inuktitut)\n"
" ja_JP (Japanese)\n" " ja_JP (Japanese)\n"
" ka_GE (Georgian)\n" " ka_GE (Georgian)\n"
" km_KH (Khmer)\n" " km_KH (Khmer)\n"
" ko_KR (Korean)\n" " ko_KR (Korean)\n"
" ku_TR (Kurdish)\n" " ku_TR (Kurdish)\n"
" ms_MY (Malay)\n" " ms_MY (Malay)\n"
" ml_IN (Malayalam)\n" " ml_IN (Malayalam)\n"
" lg_UG (Luganda)\n" " lg_UG (Luganda)\n"
" lb_LU (Luxembourgish Letzebuergesch)\n" " lb_LU (Luxembourgish Letzebuergesch)\n"
" lv_LV (Latvian)\n" " lv_LV (Latvian)\n"
" lt_LT (Lithuanian Lietuviu)\n" " lt_LT (Lithuanian Lietuviu)\n"
" mk_MK (Macedonian)\n" " mk_MK (Macedonian)\n"
" mn_MN (Mongolian)\n" " mn_MN (Mongolian)\n"
" mr_IN (Marathi)\n" " mr_IN (Marathi)\n"
" nr_ZA (Ndebele)\n" " nr_ZA (Ndebele)\n"
" nso_ZA (Northern Sotho Sotho sa Leboa)\n" " nso_ZA (Northern Sotho Sotho sa Leboa)\n"
@ -576,31 +576,31 @@ static void show_locale_usage(FILE * f, const char *const prg)
" sl_SI (Slovenian)\n" " sl_SI (Slovenian)\n"
" son (Songhay)\n" " son (Songhay)\n"
" sq_AL (Albanian)\n" " sq_AL (Albanian)\n"
" sr_YU (Serbian (cyrillic))\n" " sr_YU (Serbian (cyrillic))\n"
" sr_RS@latin (Serbian (latin))\n" " sr_RS@latin (Serbian (latin))\n"
" es_ES (Spanish Espanol)\n" " es_ES (Spanish Espanol)\n"
" su_ID (Sundanese)\n" " su_ID (Sundanese)\n"
" es_MX (Mexican Mexican Spanish Espanol Mejicano)\n" " es_MX (Mexican Mexican Spanish Espanol Mejicano)\n"
" sw_TZ (Swahili)\n" " sw_TZ (Swahili)\n"
" sv_SE (Swedish Svenska)\n" " sv_SE (Swedish Svenska)\n"
" ta_IN (Tamil)\n" " ta_IN (Tamil)\n"
" te_IN (Telugu)\n" " te_IN (Telugu)\n"
" tl_PH (Tagalog)\n" " tl_PH (Tagalog)\n"
" bo_CN (Tibetan)\n" " bo_CN (Tibetan)\n"
" th_TH (Thai)\n" " th_TH (Thai)\n"
" tr_TR (Turkish)\n" " tr_TR (Turkish)\n"
" twi_GH (Twi)\n" " twi_GH (Twi)\n"
" uk_UA (Ukrainian)\n" " uk_UA (Ukrainian)\n"
" ve_ZA (Venda)\n" " ve_ZA (Venda)\n"
" vec (Venetian)\n" " vec (Venetian)\n"
" vi_VN (Vietnamese)\n" " vi_VN (Vietnamese)\n"
" wa_BE (Walloon)\n" " wa_BE (Walloon)\n"
" wo_SN (Wolof)\n" " wo_SN (Wolof)\n"
" cy_GB (Welsh Cymraeg)\n" " cy_GB (Welsh Cymraeg)\n"
" xh_ZA (Xhosa)\n" " xh_ZA (Xhosa)\n"
" zam (Zapoteco-Miahuatlan)\n" " zam (Zapoteco-Miahuatlan)\n"
" zu_ZA (Zulu)\n" " zu_ZA (Zulu)\n"
"\n", prg); "\n", prg);
} }
@ -730,9 +730,12 @@ static int set_current_language(const char *restrict loc)
/* First set the locale according to the environment, then try to overwrite with loc, /* First set the locale according to the environment, then try to overwrite with loc,
after that, ctype_utf8() call will test the compatibility with utf8 and try to load after that, ctype_utf8() call will test the compatibility with utf8 and try to load
a different locale if the resulting one is not compatible. */ a different locale if the resulting one is not compatible. */
printf ("Locale BEFORE is: %s\n", setlocale(LC_ALL,NULL));//EP
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
setlocale(LC_ALL, loc); setlocale(LC_ALL, loc);
ctype_utf8(); ctype_utf8();
printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
bindtextdomain("tuxpaint", LOCALEDIR); bindtextdomain("tuxpaint", LOCALEDIR);
/* Old version of glibc does not have bind_textdomain_codeset() */ /* Old version of glibc does not have bind_textdomain_codeset() */
@ -841,7 +844,7 @@ int setup_i18n(const char *restrict lang, const char *restrict locale)
if(lang) if(lang)
locale = language_to_locale(lang); locale = language_to_locale(lang);
patch_i18n(locale); //EP
return set_current_language(locale); return set_current_language(locale);
} }

View file

@ -484,7 +484,7 @@ static int charmap_add(CHARMAP* cm, int section, char* seq, const wchar_t* unico
/* For now, we only utilize one-character flags */ /* For now, we only utilize one-character flags */
if(strlen(flag) > 1) { if(strlen(flag) > 1) {
fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int)unicode); fprintf(stderr, "%04X: Multi-character flag, truncated.\n", (int)(intptr_t)unicode); //EP added (intptr_t) to avoid warning on x64
} }
return sm_add(&cm->sections[section], seq, unicode, flag[0]); return sm_add(&cm->sections[section], seq, unicode, flag[0]);

View file

@ -308,7 +308,7 @@ const char* SurfacePrint( SDL_Surface *surface, int showDialog )
// run printing // run printing
printOperation = [ NSPrintOperation printOperationWithView:printView printInfo:printInfo ]; printOperation = [ NSPrintOperation printOperationWithView:printView printInfo:printInfo ];
[ printOperation setShowPanels:showDialog ]; [ printOperation setShowsPrintPanel:showDialog ]; //EP replaced setShowPanels by setShowsPrintPanel
macosx.cocoaKeystrokes = 1; macosx.cocoaKeystrokes = 1;
delegate = [ [ [ ModalDelegate alloc ] init ] autorelease ]; delegate = [ [ [ ModalDelegate alloc ] init ] autorelease ];

View file

@ -1,3 +1,4 @@
#include "patch.h" //EP
#include "onscreen_keyboard.h" #include "onscreen_keyboard.h"
//#define DEBUG_OSK_COMPOSEMAP //#define DEBUG_OSK_COMPOSEMAP

View file

@ -13,6 +13,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdint.h> #include <stdint.h>
#include "../src/parse.h" #include "../src/parse.h"
#include "debug.h"
const char PARSE_YES[] = "yes"; const char PARSE_YES[] = "yes";
const char PARSE_NO[] = "no"; const char PARSE_NO[] = "no";
@ -189,7 +190,9 @@ void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const ch
char *dupecheck; char *dupecheck;
const struct cfg *cfg; const struct cfg *cfg;
//printf("parsing: <%s> <%s>\n",str,arg); #ifdef DEBUG
printf("parsing %s: <%s> <%s>\n", src, str, opt);
#endif
if(isdigit(*str)) if(isdigit(*str))
{ {

View file

@ -181,6 +181,7 @@ static scaleparams scaletable[] = {
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#include <libgen.h> //EP added this include for basename()
/* On Linux, we can use 'wordexp()' to expand env. vars. in settings /* On Linux, we can use 'wordexp()' to expand env. vars. in settings
pulled from config. files */ pulled from config. files */
@ -255,6 +256,7 @@ char *strcasestr(const char *haystack, const char *needle)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
#undef gettext //EP to avoid warning on following line
#define gettext(String) debug_gettext(String) #define gettext(String) debug_gettext(String)
#endif #endif
@ -448,7 +450,7 @@ static void mtw(wchar_t * wtok, char * tok)
#else #else
#include <librsvg/rsvg.h> #include <librsvg/rsvg.h>
#include <librsvg/rsvg-cairo.h> //#include <librsvg/rsvg-cairo.h> //EP to avoid warning "Including <librsvg/rsvg-cairo.h> directly is deprecated."
/* #include "rsvg.h" */ /* #include "rsvg.h" */
/* #include "rsvg-cairo.h" */ /* #include "rsvg-cairo.h" */
#if !defined(RSVG_H) || !defined(RSVG_CAIRO_H) #if !defined(RSVG_H) || !defined(RSVG_CAIRO_H)
@ -463,6 +465,7 @@ static void mtw(wchar_t * wtok, char * tok)
#endif #endif
#include <zlib.h> //EP added for PNG upgrade from 1.2 to 1.5
#define PNG_INTERNAL #define PNG_INTERNAL
#include <png.h> #include <png.h>
#define FNAME_EXTENSION ".png" #define FNAME_EXTENSION ".png"
@ -507,6 +510,8 @@ static void mtw(wchar_t * wtok, char * tok)
#include "compiler.h" #include "compiler.h"
//EP added #ifndef __APPLE__ because macros are buggy (shifted by 1 byte), plus the function exists in SDL
#ifndef __APPLE__
#if VIDEO_BPP==32 #if VIDEO_BPP==32
#ifdef __GNUC__ #ifdef __GNUC__
#define SDL_GetRGBA(p,f,rp,gp,bp,ap) ({ \ #define SDL_GetRGBA(p,f,rp,gp,bp,ap) ({ \
@ -540,6 +545,7 @@ static void mtw(wchar_t * wtok, char * tok)
(((b) & 0xffu) << 0) \ (((b) & 0xffu) << 0) \
) )
#endif #endif
#endif
//#define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */ //#define fmemopen_alternative */ /* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
@ -4674,17 +4680,17 @@ static void mainloop(void)
/* Time to replace "Great!" with old tip text: */ /* Time to replace "Great!" with old tip text: */
if (event.user.data1 != NULL) if (event.user.data1 != NULL)
{ {
if (((unsigned char *) event.user.data1)[0] == '=') if (((unsigned char *) event.user.data1)[0] == '=')
{ {
draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1 + 1, 1, (int)event.user.data2); draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1 + 1, 1, (int)(intptr_t)event.user.data2); //EP added (intptr_t) to avoid warning on x64
} }
else else
{ {
draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1, 0, (int)event.user.data2); draw_tux_text_ex(TUX_GREAT, (char *) event.user.data1, 0, (int)(intptr_t)event.user.data2); //EP added (intptr_t) to avoid warning on x64
} }
} }
else else
draw_tux_text(TUX_GREAT, "", 1); draw_tux_text(TUX_GREAT, "", 1);
} }
else if (event.user.code == USEREVENT_PLAYDESCSOUND) else if (event.user.code == USEREVENT_PLAYDESCSOUND)
@ -4698,15 +4704,15 @@ static void mainloop(void)
#ifndef NOSOUND #ifndef NOSOUND
Mix_ChannelFinished(NULL); /* Kill the callback, so we don't get stuck in a loop! */ Mix_ChannelFinished(NULL); /* Kill the callback, so we don't get stuck in a loop! */
if (event.user.data1 != NULL) if (event.user.data1 != NULL)
{ {
if ((int) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... */ if ((int)(intptr_t) event.user.data1 == cur_stamp[stamp_group]) /* Don't play old stamp's sound... */ //EP added (intptr_t) to avoid warning on x64
{ {
if (!mute && stamp_data[stamp_group][(int) event.user.data1]->sdesc != NULL) if (!mute && stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc != NULL) //EP added (intptr_t) to avoid warning on x64
Mix_PlayChannel(2, stamp_data[stamp_group][(int) event.user.data1]->sdesc, Mix_PlayChannel(2, stamp_data[stamp_group][(int)(intptr_t) event.user.data1]->sdesc, //EP added (intptr_t) to avoid warning on x64
0); 0);
} }
} }
#endif #endif
} }
} }
@ -5974,10 +5980,10 @@ static void tint_surface(SDL_Surface * tmp_surf, SDL_Surface * surf_ptr)
#endif #endif
key_color_ptr = find_most_saturated(initial_hue, work, key_color_ptr = find_most_saturated(initial_hue, work,
width * height, &hue_range); width * height, &hue_range);
#ifdef DEBUG #ifdef DEBUG
printf("key_color_ptr = %d\n", (int) key_color_ptr); printf("key_color_ptr = %d\n", (int)(intptr_t) key_color_ptr); //EP added (intptr_t) to avoid warning on x64
#endif #endif
if (key_color_ptr) if (key_color_ptr)
@ -9309,14 +9315,31 @@ static SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h)
one_minus_y = 1.0 - fraction_y; one_minus_y = 1.0 - fraction_y;
#if VIDEO_BPP==32 #if VIDEO_BPP==32
{ //EP added local block to avoid warning "Passing arg 3 from incompatible pointer type" of section below block
Uint8 r, g, b, a;
SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format, SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format,
&r1, &g1, &b1, &a1); &r, &g, &b, &a);
r1 = (float)r; g1=(float)g; b1 = (float)b; a1 = (float)a;
SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format, SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format,
&r2, &g2, &b2, &a2); &r, &g, &b, &a);
r2 = (float)r; g2=(float)g; b2 = (float)b; a2 = (float)a;
SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format, SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format,
&r3, &g3, &b3, &a3); &r, &g, &b, &a);
r3 = (float)r; g3=(float)g; b3 = (float)b; a3 = (float)a;
SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format, SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format,
&r4, &g4, &b4, &a4); &r, &g, &b, &a);
r4 = (float)r; g4=(float)g; b4 = (float)b; a4 = (float)a;
}
/*
SDL_GetRGBA(getpixel(src, floor_x, floor_y), src->format,
&r1, &g1, &b1, &a1);
SDL_GetRGBA(getpixel(src, ceil_x, floor_y), src->format,
&r2, &g2, &b2, &a2);
SDL_GetRGBA(getpixel(src, floor_x, ceil_y), src->format,
&r3, &g3, &b3, &a3);
SDL_GetRGBA(getpixel(src, ceil_x, ceil_y), src->format,
&r4, &g4, &b4, &a4);
*/
#else #else
{ {
Uint8 r, g, b, a; Uint8 r, g, b, a;
@ -10517,7 +10540,7 @@ static void playstampdesc(int chan)
playsound_event.type = SDL_USEREVENT; playsound_event.type = SDL_USEREVENT;
playsound_event.user.code = USEREVENT_PLAYDESCSOUND; playsound_event.user.code = USEREVENT_PLAYDESCSOUND;
playsound_event.user.data1 = (void *) cur_stamp[stamp_group]; playsound_event.user.data1 = (void *)(intptr_t) cur_stamp[stamp_group]; //EP added (intptr_t) to avoid warning on x64
SDL_PushEvent(&playsound_event); SDL_PushEvent(&playsound_event);
} }
@ -11421,16 +11444,17 @@ static void load_current(void)
if (file_id[0] != '\0') if (file_id[0] != '\0')
{ {
start_label_node=NULL;
current_label_node=NULL;
first_label_node_in_redo_stack=NULL;
highlighted_label_node = NULL;
label_node_to_edit = NULL;
have_to_rec_label_node = FALSE;
snprintf(ftmp, sizeof(ftmp), "saved/%s%s", start_label_node=NULL;
file_id, FNAME_EXTENSION); current_label_node=NULL;
fname = get_fname(ftmp, DIR_SAVE); first_label_node_in_redo_stack=NULL;
highlighted_label_node = NULL;
label_node_to_edit = NULL;
have_to_rec_label_node = FALSE;
snprintf(ftmp, sizeof(ftmp), "saved/%s%s",
file_id, FNAME_EXTENSION);
fname = get_fname(ftmp, DIR_SAVE);
tmp = myIMG_Load_RWops(fname); tmp = myIMG_Load_RWops(fname);
@ -12173,18 +12197,21 @@ static void cleanup(void)
if (medium_font != NULL) if (medium_font != NULL)
{ {
printf("cleanup: medium font\n"); //EP
TuxPaint_Font_CloseFont(medium_font); TuxPaint_Font_CloseFont(medium_font);
medium_font = NULL; medium_font = NULL;
} }
if (small_font != NULL) if (small_font != NULL)
{ {
printf("cleanup: small font\n"); //EP
TuxPaint_Font_CloseFont(small_font); TuxPaint_Font_CloseFont(small_font);
small_font = NULL; small_font = NULL;
} }
if (large_font != NULL) if (large_font != NULL)
{ {
printf("cleanup: large font\n"); //EP
TuxPaint_Font_CloseFont(large_font); TuxPaint_Font_CloseFont(large_font);
large_font = NULL; large_font = NULL;
} }
@ -12313,22 +12340,26 @@ static void cleanup(void)
SDL_Quit(); SDL_Quit();
/* Call this once only, at exit */ /* Call this once only, at exit */
//EP now deprecated
/*
#if !defined(NOSVG) && !defined(OLD_SVG) #if !defined(NOSVG) && !defined(OLD_SVG)
#ifdef DEBUG #ifdef DEBUG
printf("rsvg_term()\n"); fflush(stdout); printf("rsvg_term()\n"); fflush(stdout);
#endif #endif
rsvg_term(); rsvg_term();
#endif #endif
*/
} }
static void free_surface(SDL_Surface ** surface_array) static void free_surface(SDL_Surface ** surface_array)
{ {
if (*surface_array) if (surface_array) //EP added this line to avoid app crash
{ if (*surface_array)
SDL_FreeSurface(*surface_array); {
*surface_array = NULL; SDL_FreeSurface(*surface_array);
} *surface_array = NULL;
}
} }
@ -12336,10 +12367,11 @@ static void free_surface_array(SDL_Surface * surface_array[], int count)
{ {
int i; int i;
for (i = 0; i < count; ++i) if (surface_array) //EP added this line to avoid app crash
{ for (i = 0; i < count; ++i)
free_surface(&surface_array[i]); {
} free_surface(&surface_array[i]);
}
} }
@ -12962,7 +12994,7 @@ static void do_png_embed_data(png_structp png_ptr)
/* Starter foreground */ /* Starter foreground */
if (img_starter) if (img_starter)
{ {
printf("Saving starter... %d\n", (int) img_starter); printf("Saving starter... %d\n", (int)(intptr_t) img_starter); //EP added (intptr_t) to avoid warning on x64
sbk_pixs = malloc(img_starter->h * img_starter->w * 4); sbk_pixs = malloc(img_starter->h * img_starter->w * 4);
compressedLen = compressBound(img_starter->h * img_starter->w * 4); compressedLen = compressBound(img_starter->h * img_starter->w * 4);
@ -14523,8 +14555,8 @@ static int do_open(void)
snprintf(fname, sizeof(fname), "%s/%s%s", snprintf(fname, sizeof(fname), "%s/%s%s",
dirname[d_places[which]], d_names[which], d_exts[which]); dirname[d_places[which]], d_names[which], d_exts[which]);
fi = fopen(fname, "r"); fi = fopen(fname, "r");
if (fi == NULL) if (fi == NULL)
{ {
fprintf(stderr, fprintf(stderr,
"\nWarning: Couldn't load the saved image! (1)\n" "\nWarning: Couldn't load the saved image! (1)\n"
"%s\n" "%s\n"
@ -14759,20 +14791,20 @@ static int do_slideshow(void)
|| strcasestr(f->d_name, ".bmp") != NULL || strcasestr(f->d_name, ".bmp") != NULL
) )
{ {
strcpy(fname, f->d_name); strcpy(fname, f->d_name);
if (strcasestr(fname, FNAME_EXTENSION) != NULL) if (strcasestr(fname, FNAME_EXTENSION) != NULL)
{ {
d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION)); d_exts[num_files] = strdup(strcasestr(fname, FNAME_EXTENSION));
strcpy((char *) strcasestr(fname, FNAME_EXTENSION), ""); strcpy((char *) strcasestr(fname, FNAME_EXTENSION), "");
} }
if (strcasestr(fname, ".bmp") != NULL) if (strcasestr(fname, ".bmp") != NULL)
{ {
d_exts[num_files] = strdup(strcasestr(fname, ".bmp")); d_exts[num_files] = strdup(strcasestr(fname, ".bmp"));
strcpy((char *) strcasestr(fname, ".bmp"), ""); strcpy((char *) strcasestr(fname, ".bmp"), "");
} }
d_names[num_files] = strdup(fname); d_names[num_files] = strdup(fname);
/* FIXME: Try to center list on whatever was selected /* FIXME: Try to center list on whatever was selected
@ -16145,7 +16177,8 @@ static void do_render_cur_text(int do_blit)
{ {
#if defined(_FRIBIDI_H) || defined(FRIBIDI_H) #if defined(_FRIBIDI_H) || defined(FRIBIDI_H)
//FriBidiCharType baseDir = FRIBIDI_TYPE_LTR; //FriBidiCharType baseDir = FRIBIDI_TYPE_LTR;
FriBidiCharType baseDir = FRIBIDI_TYPE_WL; /* Per: Shai Ayal <shaiay@gmail.com>, 2009-01-14 */ //FriBidiCharType baseDir = FRIBIDI_TYPE_WL; /* Per: Shai Ayal <shaiay@gmail.com>, 2009-01-14 */
FriBidiParType baseDir = FRIBIDI_TYPE_WL; //EP to avoid warning on types in now commented line above
FriBidiChar *unicodeIn, *unicodeOut; FriBidiChar *unicodeIn, *unicodeOut;
unsigned int i; unsigned int i;
@ -16500,7 +16533,7 @@ static void control_drawtext_timer(Uint32 interval, const char *const text, Uint
drawtext_event.type = SDL_USEREVENT; drawtext_event.type = SDL_USEREVENT;
drawtext_event.user.code = USEREVENT_TEXT_UPDATE; drawtext_event.user.code = USEREVENT_TEXT_UPDATE;
drawtext_event.user.data1 = (void *) text; drawtext_event.user.data1 = (void *) text;
drawtext_event.user.data2 = (void *) ((int) locale_text); drawtext_event.user.data2 = (void *) (intptr_t)((int) locale_text); //EP added (intptr_t) to avoid warning on x64
/* Add new timer */ /* Add new timer */
@ -17623,7 +17656,7 @@ static SDL_Surface * myIMG_Load(char * file)
#endif #endif
} else { } else {
return(myIMG_Load_RWops(file)); return(myIMG_Load_RWops(file));
} }
} }
static SDL_Surface * load_kpx(char * file) static SDL_Surface * load_kpx(char * file)
@ -17828,42 +17861,43 @@ static void load_magic_plugins(void)
snprintf(funcname, sizeof(funcname), "%s_%s", objname, snprintf(funcname, sizeof(funcname), "%s_%s", objname,
"switchout"); "switchout");
magic_funcs[num_plugin_files].switchout = magic_funcs[num_plugin_files].switchout =
SDL_LoadFunction(magic_handle[num_plugin_files], funcname); SDL_LoadFunction(magic_handle[num_plugin_files], funcname);
#ifdef DEBUG #ifdef DEBUG
printf("get_tool_count = 0x%x\n", //EP added (intptr_t) to avoid warning on x64 on all lines below
(int) magic_funcs[num_plugin_files].get_tool_count); printf("get_tool_count = 0x%x\n",
printf("get_name = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_tool_count);
(int) magic_funcs[num_plugin_files].get_name); printf("get_name = 0x%x\n",
printf("get_icon = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_name);
(int) magic_funcs[num_plugin_files].get_icon); printf("get_icon = 0x%x\n",
printf("get_description = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_icon);
(int) magic_funcs[num_plugin_files].get_description); printf("get_description = 0x%x\n",
printf("requires_colors = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].get_description);
(int) magic_funcs[num_plugin_files].requires_colors); printf("requires_colors = 0x%x\n",
printf("modes = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].requires_colors);
(int) magic_funcs[num_plugin_files].modes); printf("modes = 0x%x\n",
printf("set_color = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].modes);
(int) magic_funcs[num_plugin_files].set_color); printf("set_color = 0x%x\n",
printf("init = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].set_color);
(int) magic_funcs[num_plugin_files].init); printf("init = 0x%x\n",
printf("api_version = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].init);
(int) magic_funcs[num_plugin_files].api_version); printf("api_version = 0x%x\n",
printf("shutdown = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].api_version);
(int) magic_funcs[num_plugin_files].shutdown); printf("shutdown = 0x%x\n",
printf("click = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].shutdown);
(int) magic_funcs[num_plugin_files].click); printf("click = 0x%x\n",
printf("drag = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].click);
(int) magic_funcs[num_plugin_files].drag); printf("drag = 0x%x\n",
printf("release = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].drag);
(int) magic_funcs[num_plugin_files].release); printf("release = 0x%x\n",
printf("switchin = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].release);
(int) magic_funcs[num_plugin_files].switchin); printf("switchin = 0x%x\n",
printf("switchout = 0x%x\n", (int)(intptr_t) magic_funcs[num_plugin_files].switchin);
(int) magic_funcs[num_plugin_files].switchout); printf("switchout = 0x%x\n",
(int)(intptr_t) magic_funcs[num_plugin_files].switchout);
#endif #endif
err = 0; err = 0;
if (magic_funcs[num_plugin_files].get_tool_count == NULL) if (magic_funcs[num_plugin_files].get_tool_count == NULL)
{ {
@ -18567,101 +18601,101 @@ static int do_new_dialog(void)
if (skip) { if (skip) {
free(d_exts[num_files]); free(d_exts[num_files]);
} else { } else {
d_names[num_files] = strdup(fname); d_names[num_files] = strdup(fname);
d_places[num_files] = place; d_places[num_files] = place;
/* Try to load thumbnail first: */ /* Try to load thumbnail first: */
snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png",
dirname[d_places[num_files]], d_names[num_files]);
debug(fname);
img = IMG_Load(fname);
if (img == NULL)
{
/* No thumbnail in the new location ("saved/.thumbs"),
try the old location ("saved/"): */
snprintf(fname, sizeof(fname), "%s/%s-t.png",
dirname[d_places[num_files]], d_names[num_files]); dirname[d_places[num_files]], d_names[num_files]);
debug(fname); debug(fname);
img = IMG_Load(fname); img = IMG_Load(fname);
}
if (img == NULL) if (img != NULL)
{
/* Loaded the thumbnail from one or the other location */
show_progress_bar(screen);
img1 = SDL_DisplayFormat(img);
SDL_FreeSurface(img);
/* if too big, or too small in both dimensions, rescale it
(for now: using old thumbnail as source for high speed,
low quality) */
if (img1->w > THUMB_W - 20 || img1->h > THUMB_H - 20
|| (img1->w < THUMB_W - 20 && img1->h < THUMB_H - 20))
{ {
/* No thumbnail in the new location ("saved/.thumbs"), img2 = thumbnail(img1, THUMB_W - 20, THUMB_H - 20, 0);
try the old location ("saved/"): */ SDL_FreeSurface(img1);
img1 = img2;
snprintf(fname, sizeof(fname), "%s/%s-t.png",
dirname[d_places[num_files]], d_names[num_files]);
debug(fname);
img = IMG_Load(fname);
} }
if (img != NULL) thumbs[num_files] = img1;
if (thumbs[num_files] == NULL)
{ {
/* Loaded the thumbnail from one or the other location */ fprintf(stderr,
show_progress_bar(screen); "\nError: Couldn't create a thumbnail of "
"saved image!\n" "%s\n", fname);
img1 = SDL_DisplayFormat(img);
SDL_FreeSurface(img);
/* if too big, or too small in both dimensions, rescale it
(for now: using old thumbnail as source for high speed,
low quality) */
if (img1->w > THUMB_W - 20 || img1->h > THUMB_H - 20
|| (img1->w < THUMB_W - 20 && img1->h < THUMB_H - 20))
{
img2 = thumbnail(img1, THUMB_W - 20, THUMB_H - 20, 0);
SDL_FreeSurface(img1);
img1 = img2;
}
thumbs[num_files] = img1;
if (thumbs[num_files] == NULL)
{
fprintf(stderr,
"\nError: Couldn't create a thumbnail of "
"saved image!\n" "%s\n", fname);
}
num_files++;
} }
else
num_files++;
}
else
{
/* No thumbnail - load original: */
/* Make sure we have a ~/.tuxpaint/saved directory: */
if (make_directory("saved", "Can't create user data directory"))
{ {
/* No thumbnail - load original: */ /* (Make sure we have a .../saved/.thumbs/ directory:) */
make_directory("saved/.thumbs", "Can't create user data thumbnail directory");
}
/* Make sure we have a ~/.tuxpaint/saved directory: */ img = NULL;
if (make_directory("saved", "Can't create user data directory"))
{
/* (Make sure we have a .../saved/.thumbs/ directory:) */
make_directory("saved/.thumbs", "Can't create user data thumbnail directory");
}
img = NULL; if (d_places[num_files] == PLACE_STARTERS_DIR ||
d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR)
{
/* Try to load a starter's background image, first!
If it exists, it should give a better idea of what the
starter looks like, compared to the overlay image... */
if (d_places[num_files] == PLACE_STARTERS_DIR || /* FIXME: Add .jpg support -bjk 2007.03.22 */
d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR)
{
/* Try to load a starter's background image, first!
If it exists, it should give a better idea of what the
starter looks like, compared to the overlay image... */
/* FIXME: Add .jpg support -bjk 2007.03.22 */ /* (Try JPEG first) */
/* (Try JPEG first) */
snprintf(fname, sizeof(fname), "%s/%s-back", snprintf(fname, sizeof(fname), "%s/%s-back",
dirname[d_places[num_files]], d_names[num_files]); dirname[d_places[num_files]], d_names[num_files]);
img = load_starter_helper(fname, "jpeg", &IMG_Load); img = load_starter_helper(fname, "jpeg", &IMG_Load);
if (img == NULL) if (img == NULL)
{ {
snprintf(fname, sizeof(fname), "%s/%s-back", snprintf(fname, sizeof(fname), "%s/%s-back",
dirname[d_places[num_files]], d_names[num_files]); dirname[d_places[num_files]], d_names[num_files]);
img = load_starter_helper(fname, "jpg", &IMG_Load); img = load_starter_helper(fname, "jpg", &IMG_Load);
} }
#ifndef NOSVG #ifndef NOSVG
if (img == NULL) if (img == NULL)
{ {
/* (Try SVG next) */ /* (Try SVG next) */
snprintf(fname, sizeof(fname), "%s/%s-back", snprintf(fname, sizeof(fname), "%s/%s-back",
dirname[d_places[num_files]], d_names[num_files]); dirname[d_places[num_files]], d_names[num_files]);
img = load_starter_helper(fname, "svg", &load_svg); img = load_starter_helper(fname, "svg", &load_svg);
} }
#endif #endif
if (img == NULL) if (img == NULL)
{ {
@ -18670,102 +18704,102 @@ static int do_new_dialog(void)
dirname[d_places[num_files]], d_names[num_files]); dirname[d_places[num_files]], d_names[num_files]);
img = load_starter_helper(fname, "png", &IMG_Load); img = load_starter_helper(fname, "png", &IMG_Load);
} }
} }
if (img == NULL) if (img == NULL)
{ {
/* Didn't load a starter background (or didn't try!), /* Didn't load a starter background (or didn't try!),
try loading the actual image... */ try loading the actual image... */
snprintf(fname, sizeof(fname), "%s/%s", snprintf(fname, sizeof(fname), "%s/%s",
dirname[d_places[num_files]], f->d_name); dirname[d_places[num_files]], f->d_name);
debug(fname); debug(fname);
img = myIMG_Load(fname); img = myIMG_Load(fname);
} }
show_progress_bar(screen);
if (img == NULL)
{
fprintf(stderr,
"\nWarning: I can't open one of the saved files!\n"
"%s\n"
"The Simple DirectMedia Layer error that "
"occurred was:\n" "%s\n\n", fname, SDL_GetError());
free(d_names[num_files]);
free(d_exts[num_files]);
}
else
{
/* Turn it into a thumbnail: */
img1 = SDL_DisplayFormatAlpha(img);
img2 = thumbnail2(img1, THUMB_W - 20, THUMB_H - 20, 0, 0);
SDL_FreeSurface(img1);
show_progress_bar(screen); show_progress_bar(screen);
if (img == NULL) thumbs[num_files] = SDL_DisplayFormat(img2);
SDL_FreeSurface(img2);
if (thumbs[num_files] == NULL)
{ {
fprintf(stderr, fprintf(stderr,
"\nWarning: I can't open one of the saved files!\n" "\nError: Couldn't create a thumbnail of "
"%s\n" "saved image!\n" "%s\n", fname);
"The Simple DirectMedia Layer error that "
"occurred was:\n" "%s\n\n", fname, SDL_GetError());
free(d_names[num_files]);
free(d_exts[num_files]);
} }
else
SDL_FreeSurface(img);
show_progress_bar(screen);
/* Let's save this thumbnail, so we don't have to
create it again next time 'Open' is called: */
/* if (d_places[num_files] == PLACE_SAVED_DIR) */ /* <-- FIXME: This test should probably go...? -bjk 2009.10.15 */
if (d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR || /* We must check to not try to write to system wide dirs Pere 2010.3.25 */
d_places[num_files] == PLACE_PERSONAL_TEMPLATES_DIR)
{ {
/* Turn it into a thumbnail: */ debug("Saving thumbnail for this one!");
img1 = SDL_DisplayFormatAlpha(img); snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png",
img2 = thumbnail2(img1, THUMB_W - 20, THUMB_H - 20, 0, 0); dirname[d_places[num_files]], d_names[num_files]);
SDL_FreeSurface(img1);
show_progress_bar(screen); if (!make_directory("starters", "Can't create user data directory") ||
!make_directory("templates", "Can't create user data directory") ||
thumbs[num_files] = SDL_DisplayFormat(img2); !make_directory("starters/.thumbs", "Can't create user data directory") ||
SDL_FreeSurface(img2); !make_directory("templates/.thumbs", "Can't create user data directory"))
if (thumbs[num_files] == NULL) fprintf(stderr, "Cannot save any pictures! SORRY!\n\n");
else
{ {
fprintf(stderr, fi = fopen(fname, "wb");
"\nError: Couldn't create a thumbnail of " if (fi == NULL)
"saved image!\n" "%s\n", fname); {
} fprintf(stderr,
"\nError: Couldn't save thumbnail of "
SDL_FreeSurface(img); "saved image!\n"
"%s\n"
show_progress_bar(screen); "The error that occurred was:\n"
"%s\n\n", fname, strerror(errno));
}
/* Let's save this thumbnail, so we don't have to
create it again next time 'Open' is called: */
/* if (d_places[num_files] == PLACE_SAVED_DIR) */ /* <-- FIXME: This test should probably go...? -bjk 2009.10.15 */
if (d_places[num_files] == PLACE_PERSONAL_STARTERS_DIR || /* We must check to not try to write to system wide dirs Pere 2010.3.25 */
d_places[num_files] == PLACE_PERSONAL_TEMPLATES_DIR)
{
debug("Saving thumbnail for this one!");
snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png",
dirname[d_places[num_files]], d_names[num_files]);
if (!make_directory("starters", "Can't create user data directory") ||
!make_directory("templates", "Can't create user data directory") ||
!make_directory("starters/.thumbs", "Can't create user data directory") ||
!make_directory("templates/.thumbs", "Can't create user data directory"))
fprintf(stderr, "Cannot save any pictures! SORRY!\n\n");
else else
{ {
fi = fopen(fname, "wb"); do_png_save(fi, fname, thumbs[num_files], 0);
if (fi == NULL)
{
fprintf(stderr,
"\nError: Couldn't save thumbnail of "
"saved image!\n"
"%s\n"
"The error that occurred was:\n"
"%s\n\n", fname, strerror(errno));
}
else
{
do_png_save(fi, fname, thumbs[num_files], 0);
}
} }
show_progress_bar(screen);
} }
show_progress_bar(screen);
num_files++;
} }
num_files++;
} }
} }
} }
} }
}
else else
{ {
/* It was a thumbnail file ("...-t.png") or immutable scene starter's /* It was a thumbnail file ("...-t.png") or immutable scene starter's
@ -21594,7 +21628,15 @@ static void setup_config(char *argv[])
parse_argv_options(&tmpcfg_cmd, argv); parse_argv_options(&tmpcfg_cmd, argv);
/* Set default options: */ #if defined(__APPLE__) //EP added this conditional section for Mac to allow for a config in the current directory, that supersedes sys and user configs
/* Mac OS X: Use a "tuxpaint.cfg" file in the current folder */
struct cfginfo tmpcfg_curdir;
memset(&tmpcfg_curdir, '\0', sizeof tmpcfg_curdir);
parse_file_options(&tmpcfg_curdir, "./tuxpaint.cfg");
tmpcfg_merge(&tmpcfg_curdir, &tmpcfg_cmd);
#endif
/* Set default options: */
#ifndef _WIN32 #ifndef _WIN32
if(!home) if(!home)
@ -21648,7 +21690,11 @@ static void setup_config(char *argv[])
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_cmd); #if defined(__APPLE__) //EP added this conditional section for Mac
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_curdir);
#else
tmpcfg_merge(&tmpcfg_usr, &tmpcfg_cmd);
#endif
if (tmpcfg_usr.parsertmp_sysconfig != PARSE_NO) if (tmpcfg_usr.parsertmp_sysconfig != PARSE_NO)
{ {
@ -21657,6 +21703,10 @@ static void setup_config(char *argv[])
#ifdef _WIN32 #ifdef _WIN32
// global config file in the application directory // global config file in the application directory
parse_file_options(&tmpcfg_sys, "tuxpaint.cfg"); parse_file_options(&tmpcfg_sys, "tuxpaint.cfg");
#elif defined(__APPLE__) //EP added this conditional section for Mac to fix folder&extension inconsistency with Tux Paint Config application)
/* Mac OS X: Use a "tuxpaint.cfg" file in the *global* Tux Paint application support folder */
snprintf(str, sizeof(str), "%s/tuxpaint.cfg", macosx.globalPreferencesPath);
parse_file_options(&tmpcfg_sys, str);
#else #else
// normally /etc/tuxpaint/tuxpaint.conf // normally /etc/tuxpaint/tuxpaint.conf
parse_file_options(&tmpcfg_sys, CONFDIR "tuxpaint.conf"); parse_file_options(&tmpcfg_sys, CONFDIR "tuxpaint.conf");
@ -21665,7 +21715,7 @@ static void setup_config(char *argv[])
} }
tmpcfg_merge(&tmpcfg, &tmpcfg_usr); tmpcfg_merge(&tmpcfg, &tmpcfg_usr);
if(tmpcfg.savedir) if(tmpcfg.savedir)
{ {
free((char*)savedir); free((char*)savedir);
savedir = tmpcfg.savedir; savedir = tmpcfg.savedir;
@ -22029,7 +22079,11 @@ static void setup_config(char *argv[])
static void chdir_to_binary(char *argv0) static void chdir_to_binary(char *argv0)
{ {
#if defined(__BEOS__) || defined(WIN32) char curdir[256]; //EP added this block to print out of current directory
getcwd(curdir, sizeof(curdir));
printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir);
#if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__) //EP added __APPLE__
/* if run from gui, like OpenTracker in BeOS or Explorer in Windows, /* if run from gui, like OpenTracker in BeOS or Explorer in Windows,
find path from which binary was run and change dir to it find path from which binary was run and change dir to it
so all files will be local :) */ so all files will be local :) */
@ -22044,16 +22098,28 @@ static void chdir_to_binary(char *argv0)
char *app_path = strdup(argv0); char *app_path = strdup(argv0);
char *slash = strrchr(app_path, '/'); char *slash = strrchr(app_path, '/');
if (!slash) #if defined(__APPLE__) //EP added to fix 10.9 issue of current directory set by Finder to something else than folder where app bundle resides
// typical path of app's binary on Mac OS : /Applications/Tux Paint.app/Contents/MacOS/Tux Paint
int levels = 3; // we need to back up 3 levels
while ((levels-- > 0) && (slash))
{
*slash = '\0'; // this overwrites the \0 at end of string
slash = strrchr(app_path, '/'); // so we can carry on our back-pedaling...
}
#endif
if (!slash)
{ {
slash = strrchr(app_path, '\\'); slash = strrchr(app_path, '\\');
} }
if (slash) if (slash)
{ {
*(slash + 1) = '\0'; *(slash + 1) = '\0';
chdir(app_path); chdir(app_path);
} }
free(app_path); free(app_path);
getcwd(curdir, sizeof(curdir));
printf("New current directory for runtime: %s\n", curdir);
} }
#else #else
(void)argv0; (void)argv0;
@ -23265,12 +23331,15 @@ static void setup(void)
#endif #endif
/* Call this once */ /* Call this once */
//EP now deprecated
/*
#if !defined(NOSVG) && !defined(OLD_SVG) #if !defined(NOSVG) && !defined(OLD_SVG)
#ifdef DEBUG #ifdef DEBUG
printf("rsvg_init()\n"); fflush(stdout); printf("rsvg_init()\n"); fflush(stdout);
#endif #endif
rsvg_init(); rsvg_init();
#endif #endif
*/
} }
@ -23394,6 +23463,19 @@ int main(int argc, char *argv[])
// do not add code (slowness) here unless required for scanning fonts // do not add code (slowness) here unless required for scanning fonts
progname = argv[0]; progname = argv[0];
#if defined(DEBUG) && defined(__APPLE__) //EP added block to log messages
freopen("/tmp/tuxpaint.log", "w", stdout); // redirect stdout to a file
dup2(fileno(stdout), fileno(stderr)); // redirect stderr to stdout
setvbuf(stdout, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
setvbuf(stderr, NULL, _IONBF, 0); // we don't want buffering to avoid de-sync'ing stdout and stderr
char logTime[100];
time_t t = time(NULL);
strftime(logTime, sizeof(logTime), "%A %d/%m/%Y %H:%M:%S", localtime(&t));
printf("Tux Paint log - %s\n", logTime);
#endif
chdir_to_binary(argv[0]); chdir_to_binary(argv[0]);
setup_config(argv); setup_config(argv);
@ -23490,6 +23572,8 @@ static int trash(char * path) {
debug("Can't get basename! Deleting instead."); debug("Can't get basename! Deleting instead.");
return(unlink(path)); return(unlink(path));
} }
printf("trash: basename=%s", basename(path)); //EP
strcpy(fname, basename(path)); strcpy(fname, basename(path));
if (!file_exists(path)) { if (!file_exists(path)) {