added gimp_rc_migrate() which resets all GimpParamConfigPath properties to

2006-10-29  Michael Natterer  <mitch@gimp.org>

	* app/config/gimprc.[ch]: added gimp_rc_migrate() which resets
	all GimpParamConfigPath properties to default values.

	* app/core/gimp-user-install.c (user_install_migrate_files): use
	the function. Fixes bug #332620.
This commit is contained in:
Michael Natterer 2006-10-29 18:40:51 +00:00 committed by Michael Natterer
parent 655ac187a1
commit a1430913b1
4 changed files with 58 additions and 2 deletions

View File

@ -1,7 +1,15 @@
2006-10-29 Michael Natterer <mitch@gimp.org>
* app/config/gimprc.[ch]: added gimp_rc_migrate() which resets
all GimpParamConfigPath properties to default values.
* app/core/gimp-user-install.c (user_install_migrate_files): use
the function. Fixes bug #332620.
2006-10-29 Sven Neumann <sven@gimp.org>
* app/plug-in/plug-in-icc-profile.c
* plug-ins/common/lcms.c: the plug-in doesn't handle GRAY* images.
* app/plug-in/plug-in-icc-profile.c
* plug-ins/common/lcms.c: the plug-in doesn't handle GRAY* images.
2006-10-29 Michael Natterer <mitch@gimp.org>

View File

@ -530,3 +530,42 @@ gimp_rc_save (GimpRc *rc)
g_free (header);
g_object_unref (global);
}
/**
* gimp_rc_migrate:
* @rc: a #GimpRc object.
*
* Resets all GimpParamConfigPath properties of the passed rc object
* to their default values, in order to prevent paths in a migrated
* gimprc to refer to folders in the old GIMP's user directory.
**/
void
gimp_rc_migrate (GimpRc *rc)
{
GParamSpec **pspecs;
guint n_pspecs;
gint i;
g_return_if_fail (GIMP_IS_RC (rc));
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (rc), &n_pspecs);
for (i = 0; i < n_pspecs; i++)
{
GParamSpec *pspec = pspecs[i];
if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec))
{
GValue value = { 0, };
g_value_init (&value, pspec->value_type);
g_param_value_set_default (pspec, &value);
g_object_set_property (G_OBJECT (rc), pspec->name, &value);
g_value_unset (&value);
}
}
g_free (pspecs);
}

View File

@ -64,5 +64,7 @@ void gimp_rc_set_unknown_token (GimpRc *rc,
const gchar *token,
const gchar *value);
void gimp_rc_migrate (GimpRc *rc);
#endif /* GIMP_RC_H__ */

View File

@ -44,6 +44,7 @@
#include "core-types.h"
#include "config/gimpconfig-file.h"
#include "config/gimprc.h"
#include "gimp-templates.h"
#include "gimp-user-install.h"
@ -442,6 +443,7 @@ user_install_migrate_files (GimpUserInstall *install)
GDir *dir;
const gchar *basename;
gchar dest[1024];
GimpRc *gimprc;
GError *error = NULL;
dir = g_dir_open (install->old_dir, 0, &error);
@ -504,5 +506,10 @@ user_install_migrate_files (GimpUserInstall *install)
gimp_templates_migrate (install->old_dir);
gimprc = gimp_rc_new (NULL, NULL, FALSE);
gimp_rc_migrate (gimprc);
gimp_rc_save (gimprc);
g_object_unref (gimprc);
return TRUE;
}