From 415006b6df43896bf343ff8770de40cadbcd9000 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Tue, 10 Feb 2004 05:37:59 +0000 Subject: [PATCH] Fixed savedir bug. Made 'Open' auto-highlight currently-loaded image, if applicable. --- docs/CHANGES.txt | 6 +++++ docs/TODO.txt | 5 +++- src/tuxpaint.c | 67 ++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 64 insertions(+), 14 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index c396e48cd..7ad63dd13 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -41,6 +41,12 @@ http://www.newbreedsoftware.com/tuxpaint/ * Updated punctuation in many text strings. Karl Ove Hufthammer + * Keywords ("Title" and "Software") now written into PNGs. + + * Fixed 'savedir' bug. (Was dropping filenames) + + * Made current image the selected image on Open screen, if applicable. + 2003.Dec.23 (0.9.13) * Translated into Basque (eu_ES) diff --git a/docs/TODO.txt b/docs/TODO.txt index 7a16d07f0..14c0800c8 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -6,7 +6,7 @@ Copyright (c) 2004 by Bill Kendrick bill@newbreedsoftware.com http://www.newbreedsoftware.com/tuxpaint/ -January 14, 2004 +February 9, 2004 LOW-PRIORITY DOCUMENTATION CHANGES: @@ -31,6 +31,9 @@ HIGH-PRIORITY IMPLEMENTATION CHANGES: * Get Mac OS X to look for stamps, brushes, etc. in /Library/Preferences/tuxpaint first, then ~/Library/Preferences/tuxpaint + * Only use "savedir" for saved files, not to look for stamps/brushes. + Added "datadir" option to override where to look for local stamps/brushes. + LOW-PRIORITY IMPLEMENTATION CHANGES: ------------------------------------ diff --git a/src/tuxpaint.c b/src/tuxpaint.c index ff2966e14..d35963c33 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -21,12 +21,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - June 14, 2002 - January 14, 2004 + June 14, 2002 - February 9, 2004 */ #define VER_VERSION "0.9.14" -#define VER_DATE "2004.01.14" +#define VER_DATE "2004.02.09" /* #define DEBUG */ @@ -8234,7 +8234,7 @@ void save_current(void) fprintf(stderr, "\nError: Can't keep track of current image.\n" "%s\n" - "The error that occred was:\n" + "The error that occurred was:\n" "%s\n\n", fname, strerror(errno)); draw_tux_text(TUX_OOPS, strerror(errno), 0, 0, 0); @@ -8321,7 +8321,7 @@ char * get_fname(char * name) { /* User had overridden save directory with "--savedir" option: */ - if (*name == '\0') + if (*name != '\0') { /* (Some mkdir()'s don't like trailing slashes) */ @@ -8436,7 +8436,8 @@ int do_prompt(char * text, char * btn_yes, char * btn_no) /* Draw the question: */ wordwrap_text(font, text, black, - 166 + PROMPTOFFSETX, 100 + PROMPTOFFSETY, 475 + PROMPTOFFSETX, 1, 0, 1); + 166 + PROMPTOFFSETX, 100 + PROMPTOFFSETY, 475 + PROMPTOFFSETX, + 1, 0, 1); /* Draw yes button: */ @@ -8523,7 +8524,8 @@ int do_prompt(char * text, char * btn_yes, char * btn_no) { if (key == SDLK_ESCAPE) { - /* ESCAPE also simply dismisses if there's no Yes/No choice: */ + /* ESCAPE also simply dismisses if there's no Yes/No + choice: */ ans = 1; done = 1; @@ -9313,9 +9315,10 @@ int do_png_save(FILE * fi, char * fname, SDL_Surface * surf) { png_structp png_ptr; png_infop info_ptr; + png_text text_ptr[4]; unsigned char ** png_rows; Uint8 r, g, b; - int x, y; + int x, y, count; png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -9361,9 +9364,34 @@ int do_png_save(FILE * fi, char * fname, SDL_Surface * surf) info_ptr->interlace_type = 1; info_ptr->valid = 0; + + /* Set headers */ + + count = 0; + + /* + if (title != NULL && strlen(title) > 0) + { + text_ptr[count].key = "Title"; + text_ptr[count].text = title; + text_ptr[count].compression = PNG_TEXT_COMPRESSION_NONE; + count++; + } + */ + + text_ptr[count].key = "Software"; + text_ptr[count].text = + "Tux Paint " VER_VERSION " (" VER_DATE ")"; + text_ptr[count].compression = PNG_TEXT_COMPRESSION_NONE; + count++; + + + png_set_text(png_ptr, info_ptr, text_ptr, count); + png_write_info(png_ptr, info_ptr); + /* Save the picture: */ png_rows = malloc(sizeof(char *) * surf->h); @@ -9518,6 +9546,8 @@ int do_open(int want_new_tool) /* Read directory of images and build thumbnails: */ num_files = 0; + cur = 0; + which = 0; if (d != NULL) { @@ -9536,8 +9566,8 @@ int do_open(int want_new_tool) d_exts[num_files_in_dir] = strdup(dot); *dot = 0; d_names[num_files_in_dir] = strdup(f->d_name); - - + + /* Try to load thumbnail first: */ snprintf(fname, sizeof(fname), "%s/%s-t%s", @@ -9716,7 +9746,17 @@ int do_open(int want_new_tool) d_names[num_files] = strdup(fname); - + + /* Is it the 'current' file we just loaded? + We'll make it the current selection! */ + + if (strcmp(d_names[num_files], file_id) == 0) + { + which = num_files; + cur = (which / 4) * 4; + } + + /* Try to load thumbnail first: */ snprintf(fname, sizeof(fname), "%s/.thumbs/%s-t.png", @@ -9884,13 +9924,14 @@ int do_open(int want_new_tool) draw_tux_text(TUX_BORED, textdir(gettext_noop("Choose the picture you want, " "then click 'Open'.")), 1, 0, 1); - - cur = 0; + + /* NOTE: cur is now set above; if file_id'th file is found, it's + set to that file's index; otherwise, we default to '0' */ + update_list = 1; want_erase = 0; done = 0; - which = 0; last_click_which = -1; last_click_time = 0;