Updating to master 2019/6/6

This commit is contained in:
Pere Pujal i Carabantes 2019-06-06 20:22:55 +02:00
commit 4d3ef642da
22 changed files with 2104 additions and 1960 deletions

View file

@ -21,7 +21,7 @@
$Id$
*/
/* Jan. 17, 2003 */
#include "BeOS_print.h"
@ -36,117 +36,122 @@
#include "string.h"
class PrintView : public BView
class PrintView:public BView
{
public:
PrintView( BBitmap *bitmap)
: BView( bitmap->Bounds(), "TuxPaint Print", B_FOLLOW_NONE, B_WILL_DRAW)
{
b = bitmap;
};
~PrintView()
{
delete b;
};
void Draw( BRect updateRect)
{
DrawBitmap( b);
}
private:
BBitmap *b;
public:
PrintView(BBitmap * bitmap):BView(bitmap->Bounds(), "TuxPaint Print", B_FOLLOW_NONE, B_WILL_DRAW)
{
b = bitmap;
};
~PrintView()
{
delete b;
};
void Draw(BRect updateRect)
{
DrawBitmap(b);
}
private:
BBitmap * b;
};
BBitmap *SurfaceToBBitmap( SDL_Surface *surf)
BBitmap *SurfaceToBBitmap(SDL_Surface * surf)
{
BBitmap *bitmap = new BBitmap( BRect( 0, 0, surf->w, surf->h), B_RGBA32);
SDL_PixelFormat pixfmt;
SDL_Surface *surf32;
Uint8 *src,*dst;
Uint32 linesize;
int i;
BBitmap *bitmap = new BBitmap(BRect(0, 0, surf->w, surf->h), B_RGBA32);
SDL_PixelFormat pixfmt;
SDL_Surface *surf32;
Uint8 *src, *dst;
Uint32 linesize;
int i;
memset( &pixfmt, 0, sizeof(pixfmt) );
pixfmt.palette = NULL;
pixfmt.BitsPerPixel = 32;
pixfmt.BytesPerPixel= 4;
pixfmt.Rmask = 0x00FF0000;
pixfmt.Gmask = 0x0000FF00;
pixfmt.Bmask = 0x000000FF;
pixfmt.Amask = 0xFF000000;
pixfmt.Rshift = 16;
pixfmt.Gshift = 8;
pixfmt.Bshift = 0;
pixfmt.Ashift = 24;
pixfmt.Rloss = 0;
pixfmt.Gloss = 0;
pixfmt.Bloss = 0;
pixfmt.Aloss = 0;
pixfmt.colorkey = 0;
pixfmt.alpha = 0;
memset(&pixfmt, 0, sizeof(pixfmt));
pixfmt.palette = NULL;
pixfmt.BitsPerPixel = 32;
pixfmt.BytesPerPixel = 4;
pixfmt.Rmask = 0x00FF0000;
pixfmt.Gmask = 0x0000FF00;
pixfmt.Bmask = 0x000000FF;
pixfmt.Amask = 0xFF000000;
pixfmt.Rshift = 16;
pixfmt.Gshift = 8;
pixfmt.Bshift = 0;
pixfmt.Ashift = 24;
pixfmt.Rloss = 0;
pixfmt.Gloss = 0;
pixfmt.Bloss = 0;
pixfmt.Aloss = 0;
pixfmt.colorkey = 0;
pixfmt.alpha = 0;
surf32 = SDL_ConvertSurface( surf, &pixfmt, SDL_SWSURFACE );
linesize = surf32->w*sizeof(Uint32);
dst = (Uint8*)bitmap->Bits();
src = (Uint8*)surf32->pixels;
for ( i = 0; i < surf32->h; i++ )
surf32 = SDL_ConvertSurface(surf, &pixfmt, SDL_SWSURFACE);
linesize = surf32->w * sizeof(Uint32);
dst = (Uint8 *) bitmap->Bits();
src = (Uint8 *) surf32->pixels;
for (i = 0; i < surf32->h; i++)
{
memcpy( dst, src, linesize );
src += surf32->pitch-4;
dst += linesize;
memcpy(dst, src, linesize);
src += surf32->pitch - 4;
dst += linesize;
}
SDL_FreeSurface( surf32 ); /* Free temp surface */
SDL_FreeSurface(surf32); /* Free temp surface */
return bitmap;
return bitmap;
}
int IsPrinterAvailable( void )
int IsPrinterAvailable(void)
{
// this code is a little hack, i don't like such hardcoded things
// but i have no choice ;]
DIR *d;
struct dirent *f = NULL;
int num_files = 0;
d = opendir("/boot/home/config/settings/printers");
if( d != NULL)
{
while( (f = readdir(d)) != NULL)
num_files++;
closedir( d);
if( num_files > 2)
return 1;
}
return 0;
// this code is a little hack, i don't like such hardcoded things
// but i have no choice ;]
DIR *d;
struct dirent *f = NULL;
int num_files = 0;
d = opendir("/boot/home/config/settings/printers");
if (d != NULL)
{
while ((f = readdir(d)) != NULL)
num_files++;
closedir(d);
if (num_files > 2)
return 1;
}
return 0;
}
int SurfacePrint( SDL_Surface *surf )
int SurfacePrint(SDL_Surface * surf)
{
BWindow *window = new BWindow( BRect( 0, 0, surf->w, surf->h), "TuxPaint Print", B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS);
PrintView *view = new PrintView( SurfaceToBBitmap( surf));
window->AddChild(view);
window->Run();
BWindow *window =
new BWindow(BRect(0, 0, surf->w, surf->h), "TuxPaint Print", B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS);
PrintView *view = new PrintView(SurfaceToBBitmap(surf));
BPrintJob job("TuxPaint");
if( job.ConfigPage() == B_OK)
{
if( job.ConfigJob() == B_OK)
{
job.BeginJob();
if( job.CanContinue())
{
job.DrawView(view, BRect( 0, 0, surf->w, surf->h), BPoint( 0, 0));
job.SpoolPage();
}
if( job.CanContinue())
job.CommitJob();
}
}
window->AddChild(view);
window->Run();
BMessenger( window).SendMessage( B_QUIT_REQUESTED);
BPrintJob job("TuxPaint");
return 0;
if (job.ConfigPage() == B_OK)
{
if (job.ConfigJob() == B_OK)
{
job.BeginJob();
if (job.CanContinue())
{
job.DrawView(view, BRect(0, 0, surf->w, surf->h), BPoint(0, 0));
job.SpoolPage();
}
if (job.CanContinue())
job.CommitJob();
}
}
BMessenger(window).SendMessage(B_QUIT_REQUESTED);
return 0;
}

View file

@ -32,11 +32,11 @@
extern "C"
{
#endif /* __cplusplus */
#endif /* __cplusplus */
extern int SurfacePrint(SDL_Surface * surf);
extern int IsPrinterAvailable();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __BEOS_PRINT__ */
#endif /* __BEOS_PRINT__ */

View file

@ -44,7 +44,6 @@
#define DEBUG_PRINTF(...)
#endif
#ifdef __ANDROID__
#include <android/log.h>
#define LOG_TAG "TuxPaint"

View file

@ -1003,7 +1003,9 @@ static void mysetenv(const char *name, const char *value)
* @param loc Locale
* @return The Y-nudge value for font rendering in the language.
*/
/* *INDENT-OFF* */
static int set_current_language(const char *restrict locale_choice) MUST_CHECK;
/* *INDENT-ON* */
static int set_current_language(const char *restrict loc)
{

View file

@ -1006,7 +1006,7 @@ static int im_event_zh_tw(IM_DATA * im, SDL_Event event)
/* Left-Alt & Right-Alt mapped to mode-switch */
case SDLK_RALT:
case SDLK_LALT:
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
im_softreset(im); /* Soft reset */
/* Set tip text */
@ -1229,7 +1229,7 @@ static int im_event_th(IM_DATA * im, SDL_Event event)
/* Right-Alt mapped to mode-switch */
case SDLK_RALT:
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
im_softreset(im); /* Soft reset */
/* Set tip text */
@ -1449,7 +1449,7 @@ static int im_event_ja(IM_DATA * im, SDL_Event event)
/* Right-Alt mapped to mode-switch */
case SDLK_RALT:
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
im_softreset(im); /* Soft reset */
/* Set tip text */
@ -1699,7 +1699,7 @@ static int im_event_ko(IM_DATA * im, SDL_Event event)
/* Right-Alt mapped to mode-switch */
case SDLK_LALT:
case SDLK_RALT:
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
cm.section = ((cm.section + 1) % SEC_TOTAL); /* Change section */
im_softreset(im); /* Soft reset */
/* Set tip text */

View file

@ -12,18 +12,21 @@
/**
* FIXME
*/
const char* macos_fontsPath()
const char *macos_fontsPath()
{
static char* p = NULL;
static char *p = NULL;
if(!p) {
const char* home = getenv("HOME");
if (!p)
{
const char *home = getenv("HOME");
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
p = malloc(strlen(home) + strlen(MACOS_FONTS_PATH) + 1);
if(p) sprintf(p, MACOS_FONTS_PATH, getenv("HOME"));
else perror("macos_fontsPath");
}
if (p)
sprintf(p, MACOS_FONTS_PATH, getenv("HOME"));
else
perror("macos_fontsPath");
}
return p;
}
@ -32,18 +35,21 @@ const char* macos_fontsPath()
/**
* FIXME
*/
const char* macos_preferencesPath()
const char *macos_preferencesPath()
{
static char* p = NULL;
static char *p = NULL;
if(!p) {
const char* home = getenv("HOME");
if (!p)
{
const char *home = getenv("HOME");
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
p = malloc(strlen(home) + strlen(MACOS_PREFERENCES_PATH) + 1);
if(p) sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME"));
else perror("macos_preferencesPath");
}
if (p)
sprintf(p, MACOS_PREFERENCES_PATH, getenv("HOME"));
else
perror("macos_preferencesPath");
}
return p;
}
@ -52,7 +58,7 @@ const char* macos_preferencesPath()
/**
* FIXME
*/
const char* macos_globalPreferencesPath()
const char *macos_globalPreferencesPath()
{
return MACOS_GLOBAL_PREFERENCES_PATH;
}

View file

@ -1,9 +1,9 @@
#ifndef __MACOS_H__
#define __MACOS_H__
const char* macos_fontsPath();
const char* macos_preferencesPath();
const char* macos_globalPreferencesPath();
const char *macos_fontsPath();
const char *macos_preferencesPath();
const char *macos_globalPreferencesPath();
#endif /* __MACOS_H__ */

View file

@ -37,4 +37,4 @@ int DisplayPageSetup(const SDL_Surface * surface);
}
-@end
#endif /* OBJECTIVEC */
#endif /* OBJECTIVEC */

View file

@ -55,8 +55,9 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y
if (!mute && use_sound && s != SND_NONE)
{
#ifdef DEBUG
printf("playsound #%d in channel %d, pos (%d,%d), %soverride, ptr=%p\n", s, chan, x, y, override ? "" : "no ", sounds[s]);
fflush(stdout);
printf("playsound #%d in channel %d, pos (%d,%d), %soverride, ptr=%p\n", s, chan, x, y, override ? "" : "no ",
sounds[s]);
fflush(stdout);
#endif
if (override || !Mix_Playing(chan))
{
@ -96,8 +97,8 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y
}
#ifdef DEBUG
printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255-dist)-left);
fflush(stdout);
printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255 - dist) - left);
fflush(stdout);
#endif
Mix_SetPanning(chan, left, (255 - dist) - left);
}

View file

@ -306,8 +306,10 @@ int do_ps_save(FILE * fi,
child_pid = pclose(fi);
#ifdef DEBUG
printf("pclose returned %d\n", child_pid); fflush(stdout);
printf("errno = %d\n", errno); fflush(stdout);
printf("pclose returned %d\n", child_pid);
fflush(stdout);
printf("errno = %d\n", errno);
fflush(stdout);
#endif
if (child_pid < 0 || (errno != 0 && errno != EAGAIN))
@ -324,15 +326,26 @@ int do_ps_save(FILE * fi,
w = waitpid(child_pid, &status, 0);
#ifdef DEBUG
if (w == -1) { perror("waitpid"); exit(EXIT_FAILURE); }
if (WIFEXITED(status)) {
printf("exited, status=%d\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
printf("killed by signal %d\n", WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
printf("stopped by signal %d\n", WSTOPSIG(status));
} else if (WIFCONTINUED(status)) {
printf("continued\n");
if (w == -1)
{
perror("waitpid");
exit(EXIT_FAILURE);
}
if (WIFEXITED(status))
{
printf("exited, status=%d\n", WEXITSTATUS(status));
}
else if (WIFSIGNALED(status))
{
printf("killed by signal %d\n", WTERMSIG(status));
}
else if (WIFSTOPPED(status))
{
printf("stopped by signal %d\n", WSTOPSIG(status));
}
else if (WIFCONTINUED(status))
{
printf("continued\n");
}
#endif
}

View file

@ -3,7 +3,7 @@
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2018
Copyright (c) 2002-2019
by various contributors; see AUTHORS.txt
http://www.tuxpaint.org/
@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - December 18, 2018
June 14, 2002 - April 3, 2019
*/
@ -38,6 +38,8 @@
/* Color depth for Tux Paint to run in, and store canvases in: */
/* *INDENT-OFF* */
#if defined(NOKIA_770)
#define VIDEO_BPP 16
#endif
@ -47,22 +49,19 @@
#endif
#ifndef VIDEO_BPP
/*# define VIDEO_BPP 15 *//* saves memory */
/*# define VIDEO_BPP 16 *//* causes discoloration */
/*# define VIDEO_BPP 24 *//* compromise */
#define VIDEO_BPP 32 /* might be fastest, if conversion funcs removed */
/*# define VIDEO_BPP 15 *//* saves memory */
/*# define VIDEO_BPP 16 *//* causes discoloration */
/*# define VIDEO_BPP 24 *//* compromise */
#define VIDEO_BPP 32 /* might be fastest, if conversion funcs removed */
#endif
/* #define CORNER_SHAPES *//* need major work! */
/* #define CORNER_SHAPES *//* need major work! */
/* Method for printing images: */
#define PRINTMETHOD_PS /* Direct to PostScript */
/*#define PRINTMETHOD_PNM_PS *//* Output PNM, assuming it gets printed */
/*#define PRINTMETHOD_PNG_PNM_PS *//* Output PNG, assuming it gets printed */
/*#define PRINTMETHOD_PNM_PS *//* Output PNM, assuming it gets printed */
/*#define PRINTMETHOD_PNG_PNM_PS *//* Output PNG, assuming it gets printed */
#define MAX_PATH 256
@ -111,6 +110,8 @@
#define TPAINT_AMASK 0x000000ff
#endif
/* *INDENT-ON* */
static unsigned draw_colors(unsigned action);
@ -579,7 +580,9 @@ static void mtw(wchar_t * wtok, char *tok)
int TP_EventFilter(void *data, const SDL_Event * event);
/* #define fmemopen_alternative *//* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
/* *INDENT-OFF* */
/* #define fmemopen_alternative *//* Uncomment this to test the fmemopen alternative in systems were fmemopen exists */
/* *INDENT-ON* */
#if defined (WIN32) || defined (__APPLE__) || defined(__NetBSD__) || defined(__sun) || defined(__ANDROID__) /* MINGW/MSYS, NetBSD, and MacOSX need it, at least for now */
#define fmemopen_alternative
@ -707,7 +710,10 @@ typedef struct
Uint8 rows, cols;
} grid_dims;
/* static SDL_Rect r_screen; *//* was 640x480 @ 0,0 -- but this isn't so useful */
/* *INDENT-OFF* */
/* static SDL_Rect r_screen; *//* was 640x480 @ 0,0 -- but this isn't so useful */
/* *INDENT-ON* */
static SDL_Rect r_canvas; /* was 448x376 @ 96,0 */
static SDL_Rect r_tools; /* was 96x336 @ 0,40 */
static SDL_Rect r_sfx;
@ -734,7 +740,9 @@ static grid_dims gd_tools; /* was 2x7 */
static grid_dims gd_sfx;
static grid_dims gd_toolopt; /* was 2x7 */
/* static grid_dims gd_open; *//* was 4x4 */
/* *INDENT-OFF* */
/* static grid_dims gd_open; *//* was 4x4 */
/* *INDENT-ON* */
static grid_dims gd_colors; /* was 17x1 */
#define HEIGHTOFFSET (((WINDOW_HEIGHT - 480) / 48) * 48)
@ -1287,6 +1295,7 @@ static int disable_save;
static int ok_to_use_lockfile = 1;
static int start_blank;
static int autosave_on_quit;
static int no_prompt_on_quit = 0;
static int dont_do_xor;
static int dont_load_stamps;
@ -2060,7 +2069,8 @@ static void get_new_file_id(void);
static int do_quit(int tool);
static int do_open(void);
static int do_new_dialog(void);
static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette);
static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d_places, char * *d_names,
char * *d_exts, int *white_in_palette);
static int do_color_picker(void);
static int do_color_sel(void);
static int do_slideshow(void);
@ -6672,6 +6682,7 @@ void show_usage(int exitcode)
{
FILE *f = exitcode ? stderr : stdout;
/* *INDENT-OFF* */
fprintf(f,
"\n"
"Usage: %s {--usage | --help | --version | --verbose-version | --copying}\n"
@ -6757,6 +6768,7 @@ void show_usage(int exitcode)
/* FIXME: "--joystick-btn-help" to list available commands, like "--lang help" */
"\n",
progname);
/* *INDENT-ON* */
}
@ -7819,10 +7831,11 @@ static void loadstamp_callback(SDL_Surface * screen,
#endif
/*
* Showing the progress bar across the screen can be CPU-intensive, so
* update infrequently.
*/
if((i % 32) == 0) show_progress_bar(screen);
* Showing the progress bar across the screen can be CPU-intensive, so
* update infrequently.
*/
if ((i % 32) == 0)
show_progress_bar(screen);
if (dotext > files[i].str && !strcasecmp(dotext, ext)
&& (dotext - files[i].str + 1 + dirlen < (int)(sizeof fname))
@ -8019,13 +8032,23 @@ static int generate_fontconfig_cache(void *vp)
((c) >= 'a' && (c) <= 'f') ? ((c) - 'a' + 10) : 0)
#ifndef WIN32
/**
* FIXME
*/
static void signal_handler(int sig)
{
(void)sig;
// It is not legal to call printf or most other functions here!
if (sig == SIGUSR1 || sig == SIGUSR2)
{
autosave_on_quit = 1;
no_prompt_on_quit = 1;
if (sig == SIGUSR1)
{
promptless_save = SAVE_OVER_NO;
}
else
{
promptless_save = SAVE_OVER_ALWAYS;
}
raise(SIGTERM);
}
}
#endif
@ -12218,14 +12241,16 @@ static int do_prompt_image_flash_snd(const char *const text,
int valhat_x, valhat_y, hatmotioner;
#ifdef DEBUG
if(snd >= 0) {
printf("Prompt and play sound #%d: %s\n", snd, sound_fnames[snd]);
fflush(stdout);
}
else {
printf("Prompt without sound\n");
fflush(stdout);
}
if (snd >= 0)
{
printf("Prompt and play sound #%d: %s\n", snd, sound_fnames[snd]);
fflush(stdout);
}
else
{
printf("Prompt without sound\n");
fflush(stdout);
}
#endif
val_x = val_y = motioner = 0;
@ -13939,12 +13964,11 @@ static void do_png_embed_data(png_structp png_ptr)
for (x = 0; x < current_node->save_width; x++)
for (y = 0; y < current_node->save_height; y++)
{
pix =
getpixels[current_node->label_node_surface->format->BytesPerPixel] (current_node->
label_node_surface, x, y);
/* *INDENT-OFF* */
pix = getpixels[current_node->label_node_surface->format->BytesPerPixel](current_node->label_node_surface, x, y);
/* *INDENT-ON* */
SDL_GetRGBA(pix, current_label_node->label_node_surface->format, &r, &g, &b, &a);
fwrite(&a, alpha_size, 1, lfi);
}
SDL_UnlockSurface(current_node->label_node_surface);
fprintf(lfi, "\n\n");
@ -14179,9 +14203,16 @@ static int do_quit(int tool)
{
int done, tmp_tool;
done = do_prompt_snd(PROMPT_QUIT_TXT,
PROMPT_QUIT_YES, PROMPT_QUIT_NO, SND_AREYOUSURE,
(TOOL_QUIT % 2) * 48 + 24, (TOOL_QUIT / 2) * 48 + 40 + 24);
if (!no_prompt_on_quit)
{
done = do_prompt_snd(PROMPT_QUIT_TXT,
PROMPT_QUIT_YES, PROMPT_QUIT_NO, SND_AREYOUSURE,
(TOOL_QUIT % 2) * 48 + 24, (TOOL_QUIT / 2) * 48 + 40 + 24);
}
else
{
done = 1;
}
if (done && !been_saved && !disable_save)
{
@ -19017,7 +19048,7 @@ static int do_new_dialog(void)
int last_click_which, last_click_button;
int places_to_look;
int tot;
int first_starter, first_template;
int first_color, first_starter, first_template;
int white_in_palette;
int val_x, val_y, motioner;
int valhat_x, valhat_y, hatmotioner;
@ -19159,9 +19190,11 @@ static int do_new_dialog(void)
white_in_palette = -1;
if (!new_colors_last) {
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
if (!new_colors_last)
{
first_color = 0;
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
first_starter = num_files;
first_template = -1; /* In case there are none... */
@ -19466,14 +19499,18 @@ static int do_new_dialog(void)
/* Throw the color palette at the end (alternative option): */
if (new_colors_last) {
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
if (new_colors_last)
{
first_color = num_files;
num_files = do_new_dialog_add_colors(thumbs, num_files, d_places, d_names, d_exts, &white_in_palette);
}
#ifdef DEBUG
printf("%d files and colors were found!\n", num_files);
#endif
printf("first_color = %d\nfirst_starter = %d\nfirst_template = %d\nnum_files = %d\n\n", first_color, first_starter,
first_template, num_files);
/* Let user choose a color or image: */
@ -19931,7 +19968,8 @@ static int do_new_dialog(void)
label_node_to_edit = NULL;
have_to_rec_label_node = FALSE;
if (which >= first_starter && (first_template == -1 || which < first_template))
if (which >= first_starter && (first_template == -1 || which < first_template)
&& (!new_colors_last || which < first_color))
{
/* Load a starter: */
@ -19990,7 +20028,7 @@ static int do_new_dialog(void)
SDL_BlitSurface(img_starter, NULL, canvas, NULL);
}
}
else if (first_template != -1 && which >= first_template)
else if (first_template != -1 && which >= first_template && (!new_colors_last || which < first_color))
{
/* Load a template: */
@ -20055,6 +20093,8 @@ static int do_new_dialog(void)
starter_personal = 0;
starter_modified = 0;
which = which - first_color;
/* Launch color picker if they chose that: */
if (which == NUM_COLORS - 1)
@ -20134,7 +20174,9 @@ static int do_new_dialog(void)
normally appears at the beginning (above Starts & Templates),
but may be placed at the end with the "--newcolorslast" option.
*/
static int do_new_dialog_add_colors(SDL_Surface * * thumbs, int num_files, int * d_places, char * * d_names, char * * d_exts, int * white_in_palette) {
static int do_new_dialog_add_colors(SDL_Surface * *thumbs, int num_files, int *d_places, char * *d_names,
char * *d_exts, int *white_in_palette)
{
int j;
int added;
Uint8 r, g, b;
@ -24835,6 +24877,10 @@ static void setup(void)
instead of 'Ok') */
signal(SIGPIPE, signal_handler);
/* Set up signal for no-questions-asked remote closing of app */
signal(SIGUSR1, signal_handler);
signal(SIGUSR2, signal_handler);
#endif
}

View file

@ -1,16 +1,16 @@
/****************************************************/
/* */
/* For Win32 that lacks Unix direct support. */
/* - avoids including "windows.h" */
/* */
/* Copyright (c) 2002 John Popplewell */
/* john@johnnypops.demon.co.uk */
/* */
/* Version 1.0.1 - fixed bug in opendir() */
/* Version 1.0.0 - initial version */
/* */
/****************************************************/
/****************************************************/
/* */
/* For Win32 that lacks Unix direct support. */
/* - avoids including "windows.h" */
/* */
/* Copyright (c) 2002 John Popplewell */
/* john@johnnypops.demon.co.uk */
/* */
/* Version 1.0.1 - fixed bug in opendir() */
/* Version 1.0.0 - initial version */
/* */
/****************************************************/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -25,14 +25,14 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
*/
/* $Id$ */
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "win32_dirent.h"
#include "debug.h"
@ -42,11 +42,12 @@
* @param pSpec Path of directory to open
* @return Opened directory, or NULL on failure
*/
DIR * opendir(const char *pSpec)
DIR *opendir(const char *pSpec)
{
char pathname[MAX_PATH + 2];
DIR * pDir = calloc(1, sizeof(DIR));
DIR *pDir = calloc(1, sizeof(DIR));
if (!pDir)
return NULL;
strcpy(pathname, pSpec);
@ -65,7 +66,7 @@ DIR * opendir(const char *pSpec)
*
* @param pDir Opened directory to close.
*/
void closedir(DIR * pDir)
void closedir(DIR * pDir)
{
assert(pDir != NULL);
free(pDir);
@ -77,15 +78,15 @@ void closedir(DIR * pDir)
* @param pDir Opened directory from which to read.
* @return The next entry from the directory
*/
struct dirent *readdir(struct DIR *pDir)
struct dirent *readdir(struct DIR *pDir)
{
assert(pDir != NULL);
if (pDir->hFind)
{
strcpy(pDir->de.d_name, (const char *)pDir->wfd.cFileName);
if (!FindNextFile(pDir->hFind, &pDir->wfd))
{
FindClose(pDir->hFind);
pDir->hFind = NULL;
@ -104,7 +105,7 @@ struct dirent *readdir(struct DIR *pDir)
* filename of dir entry 'a' is found, respectively, to be less than,
* to match, or be greater than that of 'b'.
*/
int alphasort(const void *a, const void *b)
int alphasort(const void *a, const void *b)
{
return (strcmp((*(const struct dirent **)a)->d_name, (*(const struct dirent **)b)->d_name));
}
@ -118,7 +119,7 @@ int alphasort(const void *a, const void *b)
* @param entry The directory entry to add to 'namelist'
* @return New count of items, or -1 on error (e.g., failed malloc())
*/
static int addToList(int i, struct dirent ***namelist, struct dirent *entry)
static int addToList(int i, struct dirent ***namelist, struct dirent *entry)
{
int size;
struct dirent *block;
@ -144,9 +145,9 @@ static int addToList(int i, struct dirent ***namelist, struct dirent *entry)
* @param compar Callback for sorting items in the list (via qsort()).
* @return Count of items, or -1 on error.
*/
int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar)
int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar)
{
DIR * pDir;
DIR *pDir;
int count;
struct dirent *entry;

View file

@ -1,13 +1,13 @@
/****************************************************/
/* */
/* For Win32 that lacks Unix direct support. */
/* - avoids including "windows.h" */
/* */
/* Copyright (c) 2002 John Popplewell */
/* john@johnnypops.demon.co.uk */
/* */
/****************************************************/
/* $Id$ */
/****************************************************/
/* */
/* For Win32 that lacks Unix direct support. */
/* - avoids including "windows.h" */
/* */
/* Copyright (c) 2002 John Popplewell */
/* john@johnnypops.demon.co.uk */
/* */
/****************************************************/
/* $Id$ */
typedef long BOOL;
typedef unsigned int DWORD;
typedef wchar_t TCHAR;
@ -17,12 +17,12 @@ typedef void *HANDLE;
#define MAX_PATH 256
#define INVALID_HANDLE_VALUE ((HANDLE)(-1))
#define WINAPI __stdcall
typedef struct
typedef struct
{
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
typedef struct
typedef struct
{
DWORD dwFileAttributes;
FILETIME ftCreationTime;
@ -40,26 +40,26 @@ typedef struct
#define FindFirstFile FindFirstFileA
#define FindNextFile FindNextFileA
#define FindClose FindClose
#ifdef __cplusplus
extern "C"
{
#endif /* */
extern HANDLE WINAPI FindFirstFile(const char *, WIN32_FIND_DATA *);
extern BOOL WINAPI FindNextFile(HANDLE, WIN32_FIND_DATA *);
extern BOOL WINAPI FindClose(HANDLE);
#ifdef __cplusplus
};
#endif /* */
struct dirent
struct dirent
{
char d_name[MAX_PATH];
};
typedef struct
typedef struct
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
@ -72,5 +72,3 @@ typedef int (*selectCB) (const struct dirent *);
typedef int (*comparCB) (const void *, const void *);
extern int alphasort(const void *a, const void *b);
extern int scandir(const char *dir, struct dirent ***namelist, selectCB select, comparCB compar);