From 1f623cbe369e9acfe7426f379e39262e4b32e2cf Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Thu, 8 Jun 2023 00:08:07 -0700 Subject: [PATCH] Finished exported template deletion feature --- docs/CHANGES.txt | 8 +++----- src/get_fname.h | 8 +++++--- src/tuxpaint.c | 15 +++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 0487b559d..312b0d640 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -6,7 +6,7 @@ Copyright (c) 2002-2023 Various contributors (see below, and AUTHORS.txt) https://tuxpaint.org/ -2023.June.7 (0.9.31) +2023.June.8 (0.9.31) * New Magic Tools: ---------------- * Loops - Draw loop-the-loops. @@ -37,7 +37,7 @@ https://tuxpaint.org/ * Other Improvements: ------------------- - * WIP Saved pictures can, from the Open dialog, be copied into + * Saved pictures can, from the Open dialog, be copied into the user's templates directory, and used as backgrounds for other drawings by selecting it from the New dialog. + If the original image has already been exported as a template, @@ -46,9 +46,7 @@ https://tuxpaint.org/ - identical file sizes (bytes) - identical image dimensions (pixels) - identical image data (CRC checksum) - + TODO Templates created from saved drawings in Tux Paint will - be flagged as such [TBD file sitting alongside it] - + TODO Templates created from saved drawings in Tux Paint can + + Templates created from saved drawings in Tux Paint can be removed via a new "Erase" option that will appear when such templates are selected from the "New" dialog. [See below] Closes https://sourceforge.net/p/tuxpaint/feature-requests/236/ diff --git a/src/get_fname.h b/src/get_fname.h index b18cda823..0a8e229e7 100644 --- a/src/get_fname.h +++ b/src/get_fname.h @@ -1,7 +1,7 @@ /* get_fname.h - Copyright (c) 2009-2022 + Copyright (c) 2009-2023 https://tuxpaint.org/ This program is free software; you can redistribute it and/or modify @@ -19,8 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - Last modified: December 11, 2022 - $Id$ + Last modified: June 8, 2023 */ #ifndef GET_FNAME_H @@ -41,5 +40,8 @@ enum char *get_fname(const char *const name, int kind); +/* Prefix for templates exported within Tux Paint (via Open dialog), + so we can delete them (via New dialog) */ +#define EXPORTED_TEMPLATE_PREFIX "exported" #endif diff --git a/src/tuxpaint.c b/src/tuxpaint.c index c8ff4804b..007af6736 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - June 6, 2023 + June 14, 2002 - June 8, 2023 */ #include "platform.h" @@ -22533,13 +22533,12 @@ static int do_new_dialog(void) if (which_changed) { erasable = 0; - if (!disable_erase) + + if (!disable_erase && + d_places[which] == PLACE_PERSONAL_TEMPLATES_DIR && + strstr(d_names[which], EXPORTED_TEMPLATE_PREFIX) == d_names[which]) { - if (d_places[which] == PLACE_PERSONAL_TEMPLATES_DIR) - { - /* FIXME: Check for fingerprint that it was one exported from Tux Paint */ - erasable = 1; - } + erasable = 1; } which_changed = 0; @@ -31699,7 +31698,7 @@ static int export_pict(char *fname, int where, char * orig_fname) t = time(NULL); strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&t)); pict_fname = (char *) malloc(sizeof(char) * len); - snprintf(pict_fname, len, "%s/%s-%s.png", dir, orig_fname, timestamp); + snprintf(pict_fname, len, "%s/%s-%s-%s.png", dir, EXPORTED_TEMPLATE_PREFIX, orig_fname, timestamp); } free(dir);