mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-02 00:51:14 +00:00
app, libgimp, pdb, plug-ins: improve and rename gimp_file_save_thumbnail() to…
… gimp_file_create_thumbnail(). One more case where "save" is misleading, and even more as it's not a procedure where we control where an image is stored. We only say basically "make a thumbnail which maps to this file according to my platform's rules". As a side fix, I also improved a bit the logic so that it allows @file to be the exported or — as last fallback — the imported file. And finally improve the function's docs.
This commit is contained in:
parent
66aacf9633
commit
6dfc9f96c5
9 changed files with 68 additions and 51 deletions
|
@ -222,6 +222,10 @@ file_utils_save_thumbnail (GimpImage *image,
|
|||
g_return_val_if_fail (G_IS_FILE (file), FALSE);
|
||||
|
||||
image_file = gimp_image_get_file (image);
|
||||
if (! image_file)
|
||||
image_file = gimp_image_get_exported_file (image);
|
||||
if (! image_file)
|
||||
image_file = gimp_image_get_imported_file (image);
|
||||
|
||||
if (image_file)
|
||||
{
|
||||
|
|
|
@ -338,12 +338,12 @@ file_load_thumbnail_invoker (GimpProcedure *procedure,
|
|||
}
|
||||
|
||||
static GimpValueArray *
|
||||
file_save_thumbnail_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
file_create_thumbnail_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *image;
|
||||
|
@ -577,14 +577,17 @@ register_file_procs (GimpPDB *pdb)
|
|||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-file-save-thumbnail
|
||||
* gimp-file-create-thumbnail
|
||||
*/
|
||||
procedure = gimp_procedure_new (file_save_thumbnail_invoker, TRUE, FALSE);
|
||||
procedure = gimp_procedure_new (file_create_thumbnail_invoker, TRUE, FALSE);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-file-save-thumbnail");
|
||||
"gimp-file-create-thumbnail");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Saves a thumbnail for the given image",
|
||||
"This procedure saves a thumbnail for the given image according to the Free Desktop Thumbnail Managing Standard. The thumbnail is saved so that it belongs to the given file. This means you have to save the image under this name first, otherwise this procedure will fail. This procedure may become useful if you want to explicitly save a thumbnail with a file.",
|
||||
"Creates a thumbnail of @image for the given @file",
|
||||
"This procedure creates a thumbnail for the given @file and stores it according to relevant standards.\n"
|
||||
"In particular, it will follow the [Free Desktop Thumbnail Managing Standard](https://specifications.freedesktop.org/thumbnail-spec/latest/thumbsave.html) when relevant.\n"
|
||||
"\n"
|
||||
"The thumbnail is stored so that it belongs to the given @file. This means you have to save @image under this name first. As a fallback, the call will work if @image was exported or imported as @file. In any other case, this procedure will fail.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Josh MacDonald",
|
||||
|
|
|
@ -314,6 +314,7 @@ EXPORTS
|
|||
gimp_export_procedure_set_support_xmp
|
||||
gimp_export_thumbnail
|
||||
gimp_export_xmp
|
||||
gimp_file_create_thumbnail
|
||||
gimp_file_load
|
||||
gimp_file_load_layer
|
||||
gimp_file_load_layers
|
||||
|
@ -333,7 +334,6 @@ EXPORTS
|
|||
gimp_file_procedure_set_prefixes
|
||||
gimp_file_procedure_set_priority
|
||||
gimp_file_save
|
||||
gimp_file_save_thumbnail
|
||||
gimp_floating_sel_anchor
|
||||
gimp_floating_sel_attach
|
||||
gimp_floating_sel_remove
|
||||
|
|
|
@ -214,24 +214,28 @@ gimp_file_save (GimpRunMode run_mode,
|
|||
}
|
||||
|
||||
/**
|
||||
* gimp_file_save_thumbnail:
|
||||
* gimp_file_create_thumbnail:
|
||||
* @image: The image.
|
||||
* @file: The file the thumbnail belongs to.
|
||||
*
|
||||
* Saves a thumbnail for the given image
|
||||
* Creates a thumbnail of @image for the given @file
|
||||
*
|
||||
* This procedure saves a thumbnail for the given image according to
|
||||
* the Free Desktop Thumbnail Managing Standard. The thumbnail is saved
|
||||
* so that it belongs to the given file. This means you have to save
|
||||
* the image under this name first, otherwise this procedure will fail.
|
||||
* This procedure may become useful if you want to explicitly save a
|
||||
* thumbnail with a file.
|
||||
* This procedure creates a thumbnail for the given @file and stores it
|
||||
* according to relevant standards.
|
||||
* In particular, it will follow the [Free Desktop Thumbnail Managing
|
||||
* Standard](https://specifications.freedesktop.org/thumbnail-spec/late
|
||||
* st/thumbsave.html) when relevant.
|
||||
*
|
||||
* The thumbnail is stored so that it belongs to the given @file. This
|
||||
* means you have to save @image under this name first. As a fallback,
|
||||
* the call will work if @image was exported or imported as @file. In
|
||||
* any other case, this procedure will fail.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
**/
|
||||
gboolean
|
||||
gimp_file_save_thumbnail (GimpImage *image,
|
||||
GFile *file)
|
||||
gimp_file_create_thumbnail (GimpImage *image,
|
||||
GFile *file)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
|
@ -243,7 +247,7 @@ gimp_file_save_thumbnail (GimpImage *image,
|
|||
G_TYPE_NONE);
|
||||
|
||||
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
"gimp-file-save-thumbnail",
|
||||
"gimp-file-create-thumbnail",
|
||||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
|
|
|
@ -32,20 +32,20 @@ G_BEGIN_DECLS
|
|||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
GimpImage* gimp_file_load (GimpRunMode run_mode,
|
||||
GFile *file);
|
||||
GimpLayer* gimp_file_load_layer (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file);
|
||||
GimpLayer** gimp_file_load_layers (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file);
|
||||
gboolean gimp_file_save (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file,
|
||||
GimpExportOptions *options);
|
||||
gboolean gimp_file_save_thumbnail (GimpImage *image,
|
||||
GFile *file);
|
||||
GimpImage* gimp_file_load (GimpRunMode run_mode,
|
||||
GFile *file);
|
||||
GimpLayer* gimp_file_load_layer (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file);
|
||||
GimpLayer** gimp_file_load_layers (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file);
|
||||
gboolean gimp_file_save (GimpRunMode run_mode,
|
||||
GimpImage *image,
|
||||
GFile *file,
|
||||
GimpExportOptions *options);
|
||||
gboolean gimp_file_create_thumbnail (GimpImage *image,
|
||||
GFile *file);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -268,7 +268,7 @@ gimp_thumb_get_thumb_dir_local (const gchar *dirname,
|
|||
* do this for you.
|
||||
*
|
||||
* Returns: %TRUE is the directory exists, %FALSE if it could not
|
||||
* be created
|
||||
* be created
|
||||
**/
|
||||
gboolean
|
||||
gimp_thumb_ensure_thumb_dir (GimpThumbSize size,
|
||||
|
|
|
@ -1116,8 +1116,8 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
* to the global thumbnail repository.
|
||||
*
|
||||
* The caller is responsible for setting the image file location, it's
|
||||
* filesize, modification time. One way to set this info is to is to
|
||||
* call gimp_thumbnail_set_uri() followed by gimp_thumbnail_peek_image().
|
||||
* filesize, modification time. One way to set this info is to call
|
||||
* gimp_thumbnail_set_uri() followed by gimp_thumbnail_peek_image().
|
||||
* Since this won't work for remote images, it is left to the user of
|
||||
* gimp_thumbnail_save_thumb() to do this or to set the information
|
||||
* using the @thumbnail object properties.
|
||||
|
@ -1126,7 +1126,7 @@ gimp_thumbnail_load_thumb (GimpThumbnail *thumbnail,
|
|||
* set in order to be stored with the preview image.
|
||||
*
|
||||
* Returns: %TRUE if a thumbnail was successfully written,
|
||||
* %FALSE otherwise
|
||||
* %FALSE otherwise
|
||||
**/
|
||||
gboolean
|
||||
gimp_thumbnail_save_thumb (GimpThumbnail *thumbnail,
|
||||
|
|
|
@ -363,16 +363,22 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub file_save_thumbnail {
|
||||
$blurb = 'Saves a thumbnail for the given image';
|
||||
sub file_create_thumbnail {
|
||||
$blurb = 'Creates a thumbnail of @image for the given @file';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure saves a thumbnail for the given image according to the
|
||||
Free Desktop Thumbnail Managing Standard. The thumbnail is saved so
|
||||
that it belongs to the given file. This means you have to save the image
|
||||
under this name first, otherwise this procedure will fail. This
|
||||
procedure may become useful if you want to explicitly save a thumbnail
|
||||
with a file.
|
||||
This procedure creates a thumbnail for the given @file and stores it
|
||||
according to relevant standards.
|
||||
|
||||
In particular, it will follow the [Free Desktop Thumbnail Managing
|
||||
Standard](https://specifications.freedesktop.org/thumbnail-spec/latest/thumbsave.html)
|
||||
when relevant.
|
||||
|
||||
|
||||
The thumbnail is stored so that it belongs to the given @file. This
|
||||
means you have to save @image under this name first. As a fallback, the
|
||||
call will work if @image was exported or imported as @file. In any other
|
||||
case, this procedure will fail.
|
||||
HELP
|
||||
|
||||
&josh_pdb_misc('1997');
|
||||
|
@ -405,7 +411,7 @@ CODE
|
|||
file_load_layers
|
||||
file_save
|
||||
file_load_thumbnail
|
||||
file_save_thumbnail);
|
||||
file_create_thumbnail);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs[0..3,5]]);
|
||||
|
||||
|
|
|
@ -482,7 +482,7 @@ export_image (const CompressorEntry *compressor,
|
|||
|
||||
/* ask the core to save a thumbnail for compressed XCF files */
|
||||
if (strcmp (ext, ".xcf") == 0)
|
||||
gimp_file_save_thumbnail (image, file);
|
||||
gimp_file_create_thumbnail (image, file);
|
||||
|
||||
return GIMP_PDB_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue