Commit 173905b1 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

add gimp_tool_info_build_options_filename() which creates a filename under

2008-05-18  Michael Natterer  <mitch@gimp.org>

	* app/core/gimptoolinfo.[ch]: add
	gimp_tool_info_build_options_filename() which creates a filename
	under $GIMPDIR/tool-options/ with an optional suffix.

	* app/core/gimptooloptions.c
	* app/core/gimptoolpresets.c: use it and remove own build_filename()
	functions.


svn path=/trunk/; revision=25701
parent 9670b467
2008-05-18 Michael Natterer <mitch@gimp.org>
* app/core/gimptoolinfo.[ch]: add
gimp_tool_info_build_options_filename() which creates a filename
under $GIMPDIR/tool-options/ with an optional suffix.
* app/core/gimptooloptions.c
* app/core/gimptoolpresets.c: use it and remove own build_filename()
functions.
2008-05-18 Michael Natterer <mitch@gimp.org>
* app/core/gimpstrokeoptions.[ch]: renamed public function
......
......@@ -22,6 +22,7 @@
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "core-types.h"
......@@ -313,3 +314,29 @@ gimp_tool_info_get_standard (Gimp *gimp)
return gimp->standard_tool_info;
}
gchar *
gimp_tool_info_build_options_filename (GimpToolInfo *tool_info,
const gchar *suffix)
{
const gchar *name;
gchar *filename;
gchar *basename;
g_return_val_if_fail (GIMP_IS_TOOL_INFO (tool_info), NULL);
name = gimp_object_get_name (GIMP_OBJECT (tool_info));
if (suffix)
basename = g_strconcat (name, suffix, NULL);
else
basename = g_strdup (name);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
return filename;
}
......@@ -85,5 +85,9 @@ void gimp_tool_info_set_standard (Gimp *gimp,
GimpToolInfo *tool_info);
GimpToolInfo * gimp_tool_info_get_standard (Gimp *gimp);
gchar *
gimp_tool_info_build_options_filename (GimpToolInfo *tool_info,
const gchar *suffix);
#endif /* __GIMP_TOOL_INFO_H__ */
......@@ -150,17 +150,6 @@ gimp_tool_options_reset (GimpToolOptions *tool_options)
GIMP_TOOL_OPTIONS_GET_CLASS (tool_options)->reset (tool_options);
}
static gchar *
gimp_tool_options_build_filename (GimpToolOptions *tool_options)
{
const gchar *name;
name = gimp_object_get_name (GIMP_OBJECT (tool_options->tool_info));
return g_build_filename (gimp_directory (), "tool-options", name, NULL);
}
gboolean
gimp_tool_options_serialize (GimpToolOptions *tool_options,
GError **error)
......@@ -173,7 +162,8 @@ gimp_tool_options_serialize (GimpToolOptions *tool_options,
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
filename = gimp_tool_options_build_filename (tool_options);
filename = gimp_tool_info_build_options_filename (tool_options->tool_info,
NULL);
if (tool_options->tool_info->gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
......@@ -206,7 +196,8 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options,
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
filename = gimp_tool_options_build_filename (tool_options);
filename = gimp_tool_info_build_options_filename (tool_options->tool_info,
NULL);
if (tool_options->tool_info->gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
......@@ -231,7 +222,8 @@ gimp_tool_options_delete (GimpToolOptions *tool_options,
g_return_val_if_fail (GIMP_IS_TOOL_OPTIONS (tool_options), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
filename = gimp_tool_options_build_filename (tool_options);
filename = gimp_tool_info_build_options_filename (tool_options->tool_info,
NULL);
if (g_unlink (filename) != 0 && errno != ENOENT)
{
......
......@@ -200,25 +200,6 @@ gimp_tool_presets_notify (GimpToolPresets *presets)
g_signal_emit (presets, gimp_tool_presets_signals[CHANGED], 0);
}
static gchar *
gimp_tool_presets_build_filename (GimpToolPresets *presets)
{
const gchar *name;
gchar *filename;
gchar *basename;
name = gimp_object_get_name (GIMP_OBJECT (presets->tool_info));
basename = g_strconcat (name, ".presets", NULL);
filename = g_build_filename (gimp_directory (),
"tool-options",
basename,
NULL);
g_free (basename);
return filename;
}
GimpToolPresets *
gimp_tool_presets_new (GimpToolInfo *tool_info)
{
......@@ -264,7 +245,8 @@ gimp_tool_presets_save (GimpToolPresets *presets,
gimp = presets->tool_info->gimp;
filename = gimp_tool_presets_build_filename (presets);
filename = gimp_tool_info_build_options_filename (presets->tool_info,
".presets");
if (! gimp_container_is_empty (GIMP_CONTAINER (presets)))
{
......@@ -320,7 +302,8 @@ gimp_tool_presets_load (GimpToolPresets *presets,
gimp_container_clear (GIMP_CONTAINER (presets));
filename = gimp_tool_presets_build_filename (presets);
filename = gimp_tool_info_build_options_filename (presets->tool_info,
".presets");
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment