Made templates say "ppi" instead of "dpi". Fixes bug #376990:

2007-02-10  Michael Natterer  <mitch@gimp.org>

	Made templates say "ppi" instead of "dpi". Fixes bug #376990:

	* app/core/gimp-templates.c
	(gimp_templates_migrate_get_child_by_name): find the child also
	if the name differs only in the substrings "dpi" and "ppi".

	* app/core/gimpcontainer.c (gimp_container_deserialize): if we
	found a child, give it the deserialized name if it isn't the same
	as its old name.

	* etc/templaterc: applied patch from Michael Schumacher that
	replaces "dpi" by "ppi".


svn path=/trunk/; revision=21888
This commit is contained in:
Michael Natterer 2007-02-10 10:37:20 +00:00 committed by Michael Natterer
parent 4f871da32b
commit 8cffeb0689
4 changed files with 75 additions and 23 deletions

View File

@ -1,3 +1,18 @@
2007-02-10 Michael Natterer <mitch@gimp.org>
Made templates say "ppi" instead of "dpi". Fixes bug #376990:
* app/core/gimp-templates.c
(gimp_templates_migrate_get_child_by_name): find the child also
if the name differs only in the substrings "dpi" and "ppi".
* app/core/gimpcontainer.c (gimp_container_deserialize): if we
found a child, give it the deserialized name if it isn't the same
as its old name.
* etc/templaterc: applied patch from Michael Schumacher that
replaces "dpi" by "ppi".
2007-02-10 Michael Natterer <mitch@gimp.org> 2007-02-10 Michael Natterer <mitch@gimp.org>
* modules/controller_linux_input.c: added some code stolen from * modules/controller_linux_input.c: added some code stolen from

View File

@ -114,23 +114,47 @@ gimp_templates_save (Gimp *gimp)
} }
/* just like gimp_list_get_child_by_name() but matches case-insensitive */ /* just like gimp_list_get_child_by_name() but matches case-insensitive
* and dpi/ppi-insensitive
*/
static GimpObject * static GimpObject *
gimp_templates_migrate_get_child_by_name (const GimpContainer *container, gimp_templates_migrate_get_child_by_name (const GimpContainer *container,
const gchar *name) const gchar *name)
{ {
GimpList *list = GIMP_LIST (container); GimpList *list = GIMP_LIST (container);
GList *glist; GimpObject *retval = NULL;
GList *glist;
for (glist = list->list; glist; glist = g_list_next (glist)) for (glist = list->list; glist; glist = g_list_next (glist))
{ {
GimpObject *object = glist->data; GimpObject *object = glist->data;
gchar *str1 = g_ascii_strdown (object->name, -1);
gchar *str2 = g_ascii_strdown (name, -1);
if (! g_ascii_strcasecmp (object->name, name)) if (! strcmp (str1, str2))
return object; {
retval = object;
}
else
{
gchar *dpi = strstr (str1, "dpi");
if (dpi)
{
strncpy (dpi, "ppi", 3);
g_print ("replaced: %s\n", str1);
if (! strcmp (str1, str2))
retval = object;
}
}
g_free (str1);
g_free (str2);
} }
return NULL; return retval;
} }
/** /**
@ -154,10 +178,12 @@ gimp_templates_migrate (const gchar *olddir)
gchar *tmp = g_build_filename (gimp_sysconf_directory (), gchar *tmp = g_build_filename (gimp_sysconf_directory (),
"templaterc", NULL); "templaterc", NULL);
if (olddir && strstr (olddir, "2.0")) if (olddir && (strstr (olddir, "2.0") || strstr (olddir, "2.2")))
{ {
/* We changed the spelling of a couple of template names /* We changed the spelling of a couple of template names:
* from upper to lower case between 2.0 and 2.2. *
* - from upper to lower case between 2.0 and 2.2
* - from "dpi" to "ppi" between 2.2 and 2.4
*/ */
GimpContainerClass *class = GIMP_CONTAINER_GET_CLASS (templates); GimpContainerClass *class = GIMP_CONTAINER_GET_CLASS (templates);
gpointer func = class->get_child_by_name; gpointer func = class->get_child_by_name;

View File

@ -444,8 +444,19 @@ gimp_container_deserialize (GimpConfig *config,
add_child = TRUE; add_child = TRUE;
} }
else if (strcmp (name, gimp_object_get_name (child)))
g_free (name); {
/* we found the child by name, but the name isn't the same?
* this must be an obscure case like template migration,
* so set the deserialized name on the already existing
* object.
*/
gimp_object_take_name (child, name);
}
else
{
g_free (name);
}
if (! GIMP_CONFIG_GET_INTERFACE (child)->deserialize (GIMP_CONFIG (child), if (! GIMP_CONFIG_GET_INTERFACE (child)->deserialize (GIMP_CONFIG (child),
scanner, scanner,

View File

@ -38,7 +38,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "A3 (300dpi)" (GimpTemplate "A3 (300ppi)"
(width 3508) (width 3508)
(height 4960) (height 4960)
(unit millimeters) (unit millimeters)
@ -47,7 +47,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "A4 (300dpi)" (GimpTemplate "A4 (300ppi)"
(width 2480) (width 2480)
(height 3508) (height 3508)
(unit millimeters) (unit millimeters)
@ -56,7 +56,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "A5 (300dpi)" (GimpTemplate "A5 (300ppi)"
(width 1754) (width 1754)
(height 2480) (height 2480)
(unit millimeters) (unit millimeters)
@ -65,7 +65,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "A6 (300dpi)" (GimpTemplate "A6 (300ppi)"
(width 1240) (width 1240)
(height 1754) (height 1754)
(unit millimeters) (unit millimeters)
@ -74,7 +74,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "B4 (300dpi)" (GimpTemplate "B4 (300ppi)"
(width 2953) (width 2953)
(height 4169) (height 4169)
(unit millimeters) (unit millimeters)
@ -83,7 +83,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "B5 (300dpi)" (GimpTemplate "B5 (300ppi)"
(width 2079) (width 2079)
(height 2953) (height 2953)
(unit millimeters) (unit millimeters)
@ -92,7 +92,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "B5-Japan (300dpi)" (GimpTemplate "B5-Japan (300ppi)"
(width 2150) (width 2150)
(height 3035) (height 3035)
(unit millimeters) (unit millimeters)
@ -101,7 +101,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "US-Letter (300dpi)" (GimpTemplate "US-Letter (300ppi)"
(width 2550) (width 2550)
(height 3300) (height 3300)
(unit inches) (unit inches)
@ -110,7 +110,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "US-Legal (300dpi)" (GimpTemplate "US-Legal (300ppi)"
(width 2550) (width 2550)
(height 4200) (height 4200)
(unit inches) (unit inches)
@ -119,7 +119,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "Toilet paper (US, 300dpi)" (GimpTemplate "Toilet paper (US, 300ppi)"
(stock-id "gimp-toilet-paper") (stock-id "gimp-toilet-paper")
(width 1350) (width 1350)
(height 1350) (height 1350)
@ -129,7 +129,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "CD cover (300dpi)" (GimpTemplate "CD cover (300ppi)"
(stock-id "gtk-cdrom") (stock-id "gtk-cdrom")
(width 1429) (width 1429)
(height 1417) (height 1417)
@ -139,7 +139,7 @@
(resolution-unit inches) (resolution-unit inches)
(image-type rgb) (image-type rgb)
(fill-type background-fill)) (fill-type background-fill))
(GimpTemplate "Floppy label (300dpi)" (GimpTemplate "Floppy label (300ppi)"
(stock-id "gtk-floppy") (stock-id "gtk-floppy")
(width 825) (width 825)
(height 825) (height 825)