mirror of https://github.com/GNOME/gimp.git
pdb, libgimp: mode gimp_temp_name() from fileops.pdb to gimp.pdb
It has nothing to do with loading/saving images.
This commit is contained in:
parent
fdf7b24de4
commit
608070fde3
|
@ -407,39 +407,6 @@ file_save_thumbnail_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
temp_name_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *extension;
|
||||
gchar *name = NULL;
|
||||
|
||||
extension = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GFile *file = gimp_get_temp_file (gimp, extension);
|
||||
|
||||
name = g_file_get_path (file);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), name);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
register_magic_load_handler_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -898,37 +865,6 @@ register_fileops_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-temp-name
|
||||
*/
|
||||
procedure = gimp_procedure_new (temp_name_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-temp-name");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-temp-name",
|
||||
"Generates a unique filename.",
|
||||
"Generates a unique filename using the temp path supplied in the user's gimprc.",
|
||||
"Josh MacDonald",
|
||||
"Josh MacDonald",
|
||||
"1997",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("extension",
|
||||
"extension",
|
||||
"The extension the file will have",
|
||||
TRUE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("name",
|
||||
"name",
|
||||
"The new temp filename",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-register-magic-load-handler
|
||||
*/
|
||||
|
|
|
@ -200,6 +200,39 @@ get_parasite_list_invoker (GimpProcedure *procedure,
|
|||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
temp_name_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *extension;
|
||||
gchar *name = NULL;
|
||||
|
||||
extension = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
GFile *file = gimp_get_temp_file (gimp, extension);
|
||||
|
||||
name = g_file_get_path (file);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), name);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
void
|
||||
register_gimp_procs (GimpPDB *pdb)
|
||||
{
|
||||
|
@ -377,4 +410,35 @@ register_gimp_procs (GimpPDB *pdb)
|
|||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-temp-name
|
||||
*/
|
||||
procedure = gimp_procedure_new (temp_name_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-temp-name");
|
||||
gimp_procedure_set_static_strings (procedure,
|
||||
"gimp-temp-name",
|
||||
"Generates a unique filename.",
|
||||
"Generates a unique filename using the temp path supplied in the user's gimprc.",
|
||||
"Josh MacDonald",
|
||||
"Josh MacDonald",
|
||||
"1997",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_string ("extension",
|
||||
"extension",
|
||||
"The extension the file will have",
|
||||
TRUE, TRUE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("name",
|
||||
"name",
|
||||
"The new temp filename",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
|
|
@ -230,3 +230,34 @@ gimp_get_parasite_list (gint *num_parasites)
|
|||
|
||||
return parasites;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_temp_name:
|
||||
* @extension: The extension the file will have.
|
||||
*
|
||||
* Generates a unique filename.
|
||||
*
|
||||
* Generates a unique filename using the temp path supplied in the
|
||||
* user's gimprc.
|
||||
*
|
||||
* Returns: The new temp filename.
|
||||
**/
|
||||
gchar *
|
||||
gimp_temp_name (const gchar *extension)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *name = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-temp-name",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_STRING, extension,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
name = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ gboolean gimp_attach_parasite (const GimpParasite *parasite);
|
|||
gboolean gimp_detach_parasite (const gchar *name);
|
||||
GimpParasite* gimp_get_parasite (const gchar *name);
|
||||
gchar** gimp_get_parasite_list (gint *num_parasites);
|
||||
gchar* gimp_temp_name (const gchar *extension);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
/**
|
||||
* SECTION: gimpfileops
|
||||
* @title: gimpfileops
|
||||
* @short_description: File operations (load, save, etc.)
|
||||
* @short_description: Image file operations (load, save, etc.)
|
||||
*
|
||||
* File operations (load, save, etc.)
|
||||
* Image file operations (load, save, etc.)
|
||||
**/
|
||||
|
||||
|
||||
|
@ -253,37 +253,6 @@ gimp_file_save_thumbnail (gint32 image_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_temp_name:
|
||||
* @extension: The extension the file will have.
|
||||
*
|
||||
* Generates a unique filename.
|
||||
*
|
||||
* Generates a unique filename using the temp path supplied in the
|
||||
* user's gimprc.
|
||||
*
|
||||
* Returns: The new temp filename.
|
||||
**/
|
||||
gchar *
|
||||
gimp_temp_name (const gchar *extension)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *name = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-temp-name",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_STRING, extension,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
name = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_register_magic_load_handler:
|
||||
* @procedure_name: The name of the procedure to be used for loading.
|
||||
|
|
|
@ -49,7 +49,6 @@ gboolean gimp_file_save (GimpRunMode run_mode,
|
|||
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,
|
||||
const gchar *prefixes,
|
||||
|
|
|
@ -442,39 +442,6 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub temp_name {
|
||||
$blurb = 'Generates a unique filename.';
|
||||
|
||||
$help = <<'HELP';
|
||||
Generates a unique filename using the temp path supplied in the user's gimprc.
|
||||
HELP
|
||||
|
||||
&josh_pdb_misc('1997');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'extension', type => 'string',
|
||||
allow_non_utf8 => 1, null_ok => 1,
|
||||
desc => 'The extension the file will have' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'name', type => 'string',
|
||||
desc => 'The new temp filename' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GFile *file = gimp_get_temp_file (gimp, extension);
|
||||
|
||||
name = g_file_get_path (file);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub register_magic_load_handler {
|
||||
$blurb = 'Registers a file load handler procedure.';
|
||||
|
||||
|
@ -703,7 +670,6 @@ CODE
|
|||
file_save
|
||||
file_load_thumbnail
|
||||
file_save_thumbnail
|
||||
temp_name
|
||||
register_magic_load_handler
|
||||
register_load_handler
|
||||
register_save_handler
|
||||
|
@ -711,11 +677,11 @@ CODE
|
|||
register_file_handler_uri
|
||||
register_thumbnail_loader);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs[0..3,5..12]]);
|
||||
%exports = (app => [@procs], lib => [@procs[0..3,5..11]]);
|
||||
|
||||
$desc = 'File Operations';
|
||||
$doc_title = 'gimpfileops';
|
||||
$doc_short_desc = 'File operations (load, save, etc.)';
|
||||
$doc_long_desc = 'File operations (load, save, etc.)';
|
||||
$doc_short_desc = 'Image file operations (load, save, etc.)';
|
||||
$doc_long_desc = 'Image file operations (load, save, etc.)';
|
||||
|
||||
1;
|
||||
|
|
|
@ -189,6 +189,38 @@ sub get_parasite_list {
|
|||
CODE
|
||||
);
|
||||
}
|
||||
sub temp_name {
|
||||
$blurb = 'Generates a unique filename.';
|
||||
|
||||
$help = <<'HELP';
|
||||
Generates a unique filename using the temp path supplied in the user's gimprc.
|
||||
HELP
|
||||
|
||||
&josh_pdb_misc('1997');
|
||||
|
||||
@inargs = (
|
||||
{ name => 'extension', type => 'string',
|
||||
allow_non_utf8 => 1, null_ok => 1,
|
||||
desc => 'The extension the file will have' }
|
||||
);
|
||||
|
||||
@outargs = (
|
||||
{ name => 'name', type => 'string',
|
||||
desc => 'The new temp filename' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
code => <<'CODE'
|
||||
{
|
||||
GFile *file = gimp_get_temp_file (gimp, extension);
|
||||
|
||||
name = g_file_get_path (file);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@headers = qw("core/gimp.h"
|
||||
|
@ -199,9 +231,10 @@ CODE
|
|||
quit
|
||||
attach_parasite detach_parasite
|
||||
get_parasite
|
||||
get_parasite_list);
|
||||
get_parasite_list
|
||||
temp_name);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs[0..1,3..6]]);
|
||||
%exports = (app => [@procs], lib => [@procs[0..1,3..7]]);
|
||||
|
||||
$desc = 'Miscellaneous';
|
||||
$doc_title = 'gimp';
|
||||
|
|
Loading…
Reference in New Issue