only save a thumbnail if we are saving as XCF. Fixes bug #25272.

2006-11-05  Sven Neumann  <sven@gimp.org>

	* app/file/file-save.c (file_save): only save a thumbnail if we
	are saving as XCF.  Fixes bug #25272.

	* tools/pdbgen/pdb/fileops.pdb: create a libgimp wrapper for the
	"gimp-file-save-thumbnail" procedure.

	* libgimp/gimpfileops_pdb.[ch]: regenerated.

	* plug-ins/common/compressor.c (save_image): ask the core to
save
	a thumbnail for compressed XCF files.
This commit is contained in:
Sven Neumann 2006-11-06 08:12:37 +00:00 committed by Sven Neumann
parent 007e9c6d8f
commit f544132ca5
7 changed files with 183 additions and 117 deletions

View File

@ -40,6 +40,25 @@
* app/tools/gimpcroptool.c
* app/tools/gimprectangleoptions.c: whitespace stuff.
2006-11-05 Sven Neumann <sven@gimp.org>
* app/dialogs/file-save-dialog.c (file_save_dialog_check_uri): use
file_utils_uri_display_basename() instead of g_path_get_basename()
to get an uri's basename.
2006-11-05 Sven Neumann <sven@gimp.org>
* app/file/file-save.c (file_save): only save a thumbnail if we
are saving as XCF. Fixes bug #25272.
* tools/pdbgen/pdb/fileops.pdb: create a libgimp wrapper for the
"gimp-file-save-thumbnail" procedure.
* libgimp/gimpfileops_pdb.[ch]: regenerated.
* plug-ins/common/compressor.c (save_image): ask the core to save
a thumbnail for compressed XCF files.
2006-11-05 Sven Neumann <sven@gimp.org>
* plug-ins/common/tileit.c: applied patch from Saul Goode to fix

View File

@ -178,7 +178,9 @@ file_save (GimpImage *image,
uri,
file_proc->mime_type);
gimp_imagefile_save_thumbnail (imagefile, file_proc->mime_type, image);
/* only save a thumbnail if we are saving as XCF, see bug #25272 */
if (GIMP_PROCEDURE (file_proc)->proc_type == GIMP_INTERNAL)
gimp_imagefile_save_thumbnail (imagefile, file_proc->mime_type, image);
if (image->gimp->config->save_document_history)
gimp_recent_list_add_uri (uri, file_proc->mime_type);

View File

@ -205,6 +205,7 @@ EXPORTS
gimp_file_load_layer
gimp_file_load_layers
gimp_file_save
gimp_file_save_thumbnail
gimp_fill_type_get_type
gimp_flip
gimp_floating_sel_anchor

View File

@ -205,6 +205,43 @@ gimp_file_save (GimpRunMode run_mode,
return success;
}
/**
* gimp_file_save_thumbnail:
* @image_ID: The image.
* @filename: The name of the file the thumbnail belongs to.
*
* 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 file with the given filename. 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
* explicitely save a thumbnail with a file.
*
* Returns: TRUE on success.
*/
gboolean
gimp_file_save_thumbnail (gint32 image_ID,
const gchar *filename)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-file-save-thumbnail",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, filename,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_temp_name:
* @extension: The extension the file will have.

View File

@ -44,6 +44,8 @@ gboolean gimp_file_save (GimpRunMode run_mode,
gint32 drawable_ID,
const gchar *filename,
const gchar *raw_filename);
gboolean gimp_file_save_thumbnail (gint32 image_ID,
const gchar *filename);
gchar* gimp_temp_name (const gchar *extension);
gboolean gimp_register_magic_load_handler (const gchar *procedure_name,
const gchar *extensions,

View File

@ -370,7 +370,7 @@ save_image (const Compressor *compressor,
if (! ext)
{
g_message (_("No sensible extension, saving as compressed XCF."));
g_message (_("No sensible file extension, saving as compressed XCF."));
ext = ".xcf";
}
@ -494,6 +494,10 @@ save_image (const Compressor *compressor,
g_unlink (tmpname);
g_free (tmpname);
/* ask the core to save a thumbnail for compressed XCF files */
if (strcmp (ext, ".xcf") == 0)
gimp_file_save_thumbnail (image_ID, filename);
return GIMP_PDB_SUCCESS;
}
@ -511,8 +515,8 @@ load_image (const Compressor *compressor,
if (! ext)
{
g_message (_("No sensible extension, attempting to load "
"with file magic."));
g_message (_("No sensible file extension, "
"attempting to load with file magic."));
ext = ".foo";
}

View File

@ -33,23 +33,23 @@ HELP
&josh_pdb_misc('1997');
@inargs = (
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' },
{ name => 'raw_filename', type => 'string', no_validate => 1,
desc => 'The name as entered by the user' }
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' },
{ name => 'raw_filename', type => 'string', no_validate => 1,
desc => 'The name as entered by the user' }
);
@outargs = (
{ name => 'image', type => 'image',
desc => 'The output image' }
{ name => 'image', type => 'image',
desc => 'The output image' }
);
%invoke = (
no_marshalling => 1,
code => <<'CODE'
no_marshalling => 1,
code => <<'CODE'
{
GValueArray *new_args;
GValueArray *return_vals;
@ -81,13 +81,14 @@ HELP
g_value_transform (&args->values[i], &new_args->values[i]);
for (i = 3; i < proc->num_args; i++)
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
if (G_IS_PARAM_SPEC_STRING (proc->args[i]))
g_value_set_static_string (&new_args->values[i], "");
return_vals = gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
context, progress,
GIMP_OBJECT (proc)->name,
new_args);
return_vals =
gimp_pdb_execute_procedure_by_name_args (gimp->pdb,
context, progress,
GIMP_OBJECT (proc)->name,
new_args);
g_value_array_free (new_args);
@ -109,22 +110,22 @@ HELP
&neo_pdb_misc('2005', '2.4');
@inargs = (
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' }
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' }
);
@outargs = (
{ name => 'layer', type => 'layer',
desc => 'The layer created when loading the image file' }
{ name => 'layer', type => 'layer',
desc => 'The layer created when loading the image file' }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *uri = file_utils_filename_to_uri (gimp->plug_in_manager->load_procs,
filename, NULL);
@ -165,24 +166,24 @@ HELP
&mitch_pdb_misc('2006', '2.4');
@inargs = (
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' }
{ name => 'run_mode',
type => 'enum GimpRunMode (no GIMP_RUN_WITH_LAST_VALS)',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Destination image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to load' }
);
@outargs = (
{ name => 'layer_ids', type => 'int32array',
desc => 'The list of loaded layers',
array => { name => 'num_layers',
desc => 'The number of loaded layers' } }
{ name => 'layer_ids', type => 'int32array',
desc => 'The list of loaded layers',
array => { name => 'num_layers',
desc => 'The number of loaded layers' } }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *uri = file_utils_filename_to_uri (gimp->plug_in_manager->load_procs,
filename, NULL);
@ -237,22 +238,22 @@ HELP
&josh_pdb_misc('1997');
@inargs = (
{ name => 'run_mode', type => 'enum GimpRunMode',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Input image' },
{ name => 'drawable', type => 'drawable',
desc => 'Drawable to save' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to save the image in' },
{ name => 'raw_filename', type => 'string', no_validate => 1,
desc => 'The name as entered by the user' }
{ name => 'run_mode', type => 'enum GimpRunMode',
desc => 'The run mode' },
{ name => 'image', type => 'image',
desc => 'Input image' },
{ name => 'drawable', type => 'drawable',
desc => 'Drawable to save' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file to save the image in' },
{ name => 'raw_filename', type => 'string', no_validate => 1,
desc => 'The name as entered by the user' }
);
%invoke = (
headers => [ qw(<string.h>) ],
no_marshalling => 1,
code => <<'CODE'
headers => [ qw(<string.h>) ],
no_marshalling => 1,
code => <<'CODE'
{
GValueArray *new_args;
GValueArray *return_vals;
@ -316,23 +317,23 @@ HELP
$date = '1999-2003';
@inargs = (
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file that owns the thumbnail to load' }
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file that owns the thumbnail to load' }
);
@outargs = (
{ name => 'width', type => 'int32',
desc => 'The width of the thumbnail' },
{ name => 'height', type => 'int32',
desc => 'The height of the thumbnail' },
{ name => 'thumb_data', type => 'int8array',
desc => 'The thumbnail data',
{ name => 'width', type => 'int32',
desc => 'The width of the thumbnail' },
{ name => 'height', type => 'int32',
desc => 'The height of the thumbnail' },
{ name => 'thumb_data', type => 'int8array',
desc => 'The thumbnail data',
array => { name => 'thumb_data_count',
desc => 'The number of bytes in thumbnail data' } }
desc => 'The number of bytes in thumbnail data' } }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
GdkPixbuf *pixbuf = file_utils_load_thumbnail (filename);
@ -368,14 +369,14 @@ HELP
&josh_pdb_misc('1997');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file the thumbnail belongs to' },
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'filename', type => 'string', no_validate => 1,
desc => 'The name of the file the thumbnail belongs to' },
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
success = file_utils_save_thumbnail (image, filename);
}
@ -393,17 +394,17 @@ HELP
&josh_pdb_misc('1997');
@inargs = (
{ name => 'extension', type => 'string', no_validate => 1,
desc => 'The extension the file will have' }
{ name => 'extension', type => 'string', no_validate => 1,
desc => 'The extension the file will have' }
);
@outargs = (
{ name => 'name', type => 'string',
desc => 'The new temp filename' }
{ name => 'name', type => 'string',
desc => 'The new temp filename' }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
name = gimp_get_temp_filename (gimp, extension);
}
@ -422,21 +423,21 @@ HELP
&std_pdb_misc;
@inargs = (
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for loading' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can load (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can load (i.e. "http:,ftp:")' },
{ name => 'magics', type => 'string', no_success => 1,
desc => 'comma separated list of magic file information
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for loading' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can load (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can load (i.e. "http:,ftp:")' },
{ name => 'magics', type => 'string', no_success => 1,
desc => 'comma separated list of magic file information
this handler can load (i.e. "0,string,GIF")' }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
@ -461,19 +462,19 @@ HELP
&std_pdb_misc;
@inargs = (
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for loading' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can load (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can load (i.e. "http:,ftp:")' }
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for loading' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can load (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can load (i.e. "http:,ftp:")' }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
@ -498,18 +499,18 @@ HELP
&std_pdb_misc;
@inargs = (
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for saving' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can save (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can save (i.e. "http:,ftp:")' }
{ name => 'procedure_name', type => 'string',
desc => 'The name of the procedure to be used for saving' },
{ name => 'extensions', type => 'string', no_success => 1,
desc => 'comma separated list of extensions this handler
can save (i.e. "jpg,jpeg")' },
{ name => 'prefixes', type => 'string', no_success => 1,
desc => 'comma separated list of prefixes this handler
can save (i.e. "http:,ftp:")' }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
@ -535,14 +536,14 @@ HELP
&neo_pdb_misc('2004', '2.2');
@inargs = (
{ name => 'procedure_name', type => 'string',
desc => "The name of the procedure to associate a MIME type with." },
{ name => 'mime_type', type => 'string',
desc => "A single MIME type, like for example \"image/jpeg\"." }
{ name => 'procedure_name', type => 'string',
desc => "The name of the procedure to associate a MIME type with." },
{ name => 'mime_type', type => 'string',
desc => "A single MIME type, like for example \"image/jpeg\"." }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *canonical = gimp_canonicalize_identifier (procedure_name);
@ -570,13 +571,13 @@ HELP
&neo_pdb_misc('2004', '2.2');
@inargs = (
{ name => 'load_proc', type => 'string',
desc => "The name of the procedure the thumbnail loader with." },
{ name => 'thumb_proc', type => 'string',
desc => "The name of the thumbnail load procedure." }
{ name => 'load_proc', type => 'string',
desc => "The name of the procedure the thumbnail loader with." },
{ name => 'thumb_proc', type => 'string',
desc => "The name of the thumbnail load procedure." }
);
%invoke = (
code => <<'CODE'
code => <<'CODE'
{
gchar *canonical = gimp_canonicalize_identifier (load_proc);
@ -603,13 +604,13 @@ CODE
@procs = qw(file_load file_load_layer file_load_layers
file_save
file_load_thumbnail file_save_thumbnail
temp_name
temp_name
register_magic_load_handler register_load_handler
register_save_handler
register_save_handler
register_file_handler_mime
register_thumbnail_loader);
%exports = (app => [@procs], lib => [@procs[0..3,6..11]]);
%exports = (app => [@procs], lib => [@procs[0..3,5..11]]);
$desc = 'File Operations';