Finished exported template deletion feature

This commit is contained in:
Bill Kendrick 2023-06-08 00:08:07 -07:00
parent 2260d66b4e
commit 1f623cbe36
3 changed files with 15 additions and 16 deletions

View file

@ -6,7 +6,7 @@ Copyright (c) 2002-2023
Various contributors (see below, and AUTHORS.txt) Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/ https://tuxpaint.org/
2023.June.7 (0.9.31) 2023.June.8 (0.9.31)
* New Magic Tools: * New Magic Tools:
---------------- ----------------
* Loops - Draw loop-the-loops. * Loops - Draw loop-the-loops.
@ -37,7 +37,7 @@ https://tuxpaint.org/
* Other Improvements: * 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 the user's templates directory, and used as backgrounds
for other drawings by selecting it from the New dialog. for other drawings by selecting it from the New dialog.
+ If the original image has already been exported as a template, + If the original image has already been exported as a template,
@ -46,9 +46,7 @@ https://tuxpaint.org/
- identical file sizes (bytes) - identical file sizes (bytes)
- identical image dimensions (pixels) - identical image dimensions (pixels)
- identical image data (CRC checksum) - identical image data (CRC checksum)
+ TODO Templates created from saved drawings in Tux Paint will + Templates created from saved drawings in Tux Paint can
be flagged as such [TBD file sitting alongside it]
+ TODO Templates created from saved drawings in Tux Paint can
be removed via a new "Erase" option that will appear when be removed via a new "Erase" option that will appear when
such templates are selected from the "New" dialog. [See below] such templates are selected from the "New" dialog. [See below]
Closes https://sourceforge.net/p/tuxpaint/feature-requests/236/ Closes https://sourceforge.net/p/tuxpaint/feature-requests/236/

View file

@ -1,7 +1,7 @@
/* /*
get_fname.h get_fname.h
Copyright (c) 2009-2022 Copyright (c) 2009-2023
https://tuxpaint.org/ https://tuxpaint.org/
This program is free software; you can redistribute it and/or modify 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 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
Last modified: December 11, 2022 Last modified: June 8, 2023
$Id$
*/ */
#ifndef GET_FNAME_H #ifndef GET_FNAME_H
@ -41,5 +40,8 @@ enum
char *get_fname(const char *const name, int kind); 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 #endif

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - June 6, 2023 June 14, 2002 - June 8, 2023
*/ */
#include "platform.h" #include "platform.h"
@ -22533,13 +22533,12 @@ static int do_new_dialog(void)
if (which_changed) if (which_changed)
{ {
erasable = 0; 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) erasable = 1;
{
/* FIXME: Check for fingerprint that it was one exported from Tux Paint */
erasable = 1;
}
} }
which_changed = 0; which_changed = 0;
@ -31699,7 +31698,7 @@ static int export_pict(char *fname, int where, char * orig_fname)
t = time(NULL); t = time(NULL);
strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&t)); strftime(timestamp, sizeof(timestamp), "%Y%m%d%H%M%S", localtime(&t));
pict_fname = (char *) malloc(sizeof(char) * len); 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); free(dir);