From acc84675a5f1375a075683af9efd8dbf6a082001 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 30 Mar 2006 10:17:41 +0000 Subject: [PATCH] added gimp_get_temp_filename(). 2006-03-30 Sven Neumann * app/core/gimp-utils.[ch]: added gimp_get_temp_filename(). * tools/pdbgen/pdb/fileops.pdb (temp_name): removed the implementation here and call gimp_get_temp_filename() instead. * app/pdb/fileops_cmds.c: regenerated. --- ChangeLog | 9 ++++++++ app/core/gimp-utils.c | 43 ++++++++++++++++++++++++++++++++++++ app/core/gimp-utils.h | 3 +++ app/pdb/fileops_cmds.c | 36 ++---------------------------- tools/pdbgen/pdb/fileops.pdb | 25 +++------------------ 5 files changed, 60 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 327a27d13b..b8a2de838d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-03-30 Sven Neumann + + * app/core/gimp-utils.[ch]: added gimp_get_temp_filename(). + + * tools/pdbgen/pdb/fileops.pdb (temp_name): removed the + implementation here and call gimp_get_temp_filename() instead. + + * app/pdb/fileops_cmds.c: regenerated. + 2006-03-30 Michael Natterer * app/pdb/procedural_db.h (structs Argument and ProcArg): renamed diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c index 4b774ca049..f6ed83718c 100644 --- a/app/core/gimp-utils.c +++ b/app/core/gimp-utils.c @@ -26,6 +26,16 @@ #include #endif +#include + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef G_OS_WIN32 +#include +#endif + #include #include @@ -34,6 +44,9 @@ #include "core-types.h" +#include "config/gimpbaseconfig.c" + +#include "gimp.h" #include "gimp-utils.h" @@ -326,3 +339,33 @@ gimp_parameters_free (GParameter *params, g_free (params); } } + +gchar * +gimp_get_temp_filename (Gimp *gimp, + const gchar *extension) +{ + static gint id = 0; + static gint pid; + gchar *filename; + gchar *basename; + gchar *path; + + g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); + g_return_val_if_fail (extension != NULL, NULL); + + if (id == 0) + pid = getpid (); + + basename = g_strdup_printf ("gimp-temp-%d%d.%s", + pid, id++, extension); + + path = gimp_config_path_expand (GIMP_BASE_CONFIG (gimp->config)->temp_path, + TRUE, NULL); + + filename = g_build_filename (path, basename, NULL); + + g_free (path); + g_free (basename); + + return filename; +} diff --git a/app/core/gimp-utils.h b/app/core/gimp-utils.h index 898ed127b1..e2977b5887 100644 --- a/app/core/gimp-utils.h +++ b/app/core/gimp-utils.h @@ -60,5 +60,8 @@ GParameter * gimp_parameters_append_valist (GType object_type, void gimp_parameters_free (GParameter *params, gint n_params); +gchar * gimp_get_temp_filename (Gimp *gimp, + const gchar *extension); + #endif /* __APP_GIMP_UTILS_H__ */ diff --git a/app/pdb/fileops_cmds.c b/app/pdb/fileops_cmds.c index 0719113b7b..454c134ca0 100644 --- a/app/pdb/fileops_cmds.c +++ b/app/pdb/fileops_cmds.c @@ -21,20 +21,7 @@ #include "config.h" #include - -#include - -#ifdef G_OS_WIN32 -#include -#endif - #include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - #include @@ -46,7 +33,7 @@ #include "procedural_db.h" #include "core/gimpparamspecs.h" -#include "config/gimpbaseconfig.h" +#include "core/gimp-utils.h" #include "core/gimp.h" #include "core/gimpimage.h" #include "core/gimpimagefile.h" @@ -838,26 +825,7 @@ temp_name_invoker (ProcRecord *proc_record, extension = (gchar *) g_value_get_string (&args[0].value); if (success) - { - static gint id = 0; - static gint pid; - gchar *filename; - gchar *path; - - if (id == 0) - pid = getpid (); - - filename = g_strdup_printf ("gimp_temp_%d%d.%s", - pid, id++, extension); - - path = gimp_config_path_expand (GIMP_BASE_CONFIG (gimp->config)->temp_path, - TRUE, NULL); - - name = g_build_filename (path, filename, NULL); - - g_free (path); - g_free (filename); - } + name = gimp_get_temp_filename (gimp, extension); return_vals = procedural_db_return_values (proc_record, success); diff --git a/tools/pdbgen/pdb/fileops.pdb b/tools/pdbgen/pdb/fileops.pdb index e6e0f3c62a..68bd5217cb 100644 --- a/tools/pdbgen/pdb/fileops.pdb +++ b/tools/pdbgen/pdb/fileops.pdb @@ -386,28 +386,9 @@ HELP ); %invoke = ( - headers => [ qw( "config/gimpbaseconfig.h") ], + headers => [ qw("core/gimp-utils.h") ], code => <<'CODE' -{ - static gint id = 0; - static gint pid; - gchar *filename; - gchar *path; - - if (id == 0) - pid = getpid (); - - filename = g_strdup_printf ("gimp_temp_%d%d.%s", - pid, id++, extension); - - path = gimp_config_path_expand (GIMP_BASE_CONFIG (gimp->config)->temp_path, - TRUE, NULL); - - name = g_build_filename (path, filename, NULL); - - g_free (path); - g_free (filename); -} + name = gimp_get_temp_filename (gimp, extension); CODE ); } @@ -671,7 +652,7 @@ done: CODE -@headers = qw( +@headers = qw( "libgimpbase/gimpbase.h" "libgimpconfig/gimpconfig.h" "libgimpthumb/gimpthumb.h" "core/gimp.h" "core/gimpimagefile.h"