Commit af8af6ac authored by Vincent Geddes's avatar Vincent Geddes

Fix some mishandled dgettext operations (#453105).

	* gladeui/glade-property-class.c
	  (glade_property_class_update_from_node), (gpc_get_displayable_values_from_node):
	  Fix some mishandled dgettext operations (#453105).

svn path=/trunk/; revision=1434
parent 741d228a
2007-07-04 Vincent Geddes <vgeddes@gnome.org>
* gladeui/glade-property-class.c
(glade_property_class_update_from_node), (gpc_get_displayable_values_from_node):
Fix some mishandled dgettext operations (#453105).
2007-07-03 Vincent Geddes <vgeddes@gnome.org>
* gladeui/glade-binding.c: Upgrade to g_slice_new().
......
......@@ -297,13 +297,15 @@ glade_property_class_free (GladePropertyClass *property_class)
gchar *name, *nick;
name = (gchar *) g_array_index (disp_val, GEnumValue, i).value_name;
if (name) g_free(name);
if (name)
g_free (name);
nick = (gchar *) g_array_index (disp_val, GEnumValue, i).value_nick;
if (nick) g_free(nick);
if (nick)
g_free (nick);
}
g_array_free(disp_val, TRUE);
g_array_free (disp_val, TRUE);
}
g_free (property_class);
......@@ -1379,14 +1381,14 @@ gpc_get_displayable_values_from_node (GladeXmlNode *node,
GladePropertyClass *klass,
const gchar *domain)
{
gpointer the_class = g_type_class_ref(klass->pspec->value_type);
gpointer the_class = g_type_class_ref (klass->pspec->value_type);
GArray *array;
GladeXmlNode *child;
GEnumValue *values;
gint n_values, n = 0;
gboolean first_not_found = TRUE;
if (G_IS_PARAM_SPEC_ENUM(klass->pspec))
if (G_IS_PARAM_SPEC_ENUM (klass->pspec))
{
GEnumClass *eclass = the_class;
values = eclass->values;
......@@ -1419,25 +1421,41 @@ gpc_get_displayable_values_from_node (GladeXmlNode *node,
{
if(strcmp (id, values[i].value_name) == 0)
{
gchar *translated;
val=values[i];
/* Tedious memory handleing; if gettext doesn't return
/* Tedious memory handling; if dgettext doesn't return
* a translation, dont free the untranslated string.
*/
if(name)
if (name)
{
val.value_name = dgettext (domain, name);
if (name != val.value_name)
translated = dgettext (domain, name);
if (name != translated)
{
val.value_name = g_strdup (translated);
g_free (name);
}
else
{
val.value_name = name;
}
}
if(nick)
if (nick)
{
val.value_nick = dgettext (domain, nick);
if (nick != val.value_nick)
translated = dgettext (domain, nick);
if (nick != translated)
{
val.value_nick = g_strdup (translated);
g_free (nick);
}
else
{
val.value_nick = nick;
}
}
g_array_append_val(array, val);
g_array_append_val (array, val);
break;
}
}
......@@ -1486,7 +1504,7 @@ gpc_get_displayable_values_from_node (GladeXmlNode *node,
}
}
g_type_class_unref(the_class);
g_type_class_unref (the_class);
return array;
}
......@@ -1586,7 +1604,7 @@ glade_property_class_update_from_node (GladeXmlNode *node,
const gchar *domain)
{
GladePropertyClass *klass;
gchar *buff;
gchar *buf, *translated;
GladeXmlNode *child;
g_return_val_if_fail (property_class != NULL, FALSE);
......@@ -1598,10 +1616,10 @@ glade_property_class_update_from_node (GladeXmlNode *node,
g_return_val_if_fail (glade_xml_node_verify (node, GLADE_TAG_PROPERTY), FALSE);
/* check the id */
buff = glade_xml_get_property_string_required (node, GLADE_TAG_ID, NULL);
if (!buff)
buf = glade_xml_get_property_string_required (node, GLADE_TAG_ID, NULL);
if (!buf)
return FALSE;
g_free (buff);
g_free (buf);
/* If Disabled="TRUE" we set *property_class to NULL, but we return TRUE.
......@@ -1615,11 +1633,11 @@ glade_property_class_update_from_node (GladeXmlNode *node,
}
/* ...the spec... */
buff = glade_xml_get_value_string (node, GLADE_TAG_SPEC);
if (buff)
buf = glade_xml_get_value_string (node, GLADE_TAG_SPEC);
if (buf)
{
/* ... get the tooltip from the pspec ... */
if ((klass->pspec = glade_utils_get_pspec_from_funcname (buff)) != NULL)
if ((klass->pspec = glade_utils_get_pspec_from_funcname (buf)) != NULL)
{
/* Make sure we can tell properties apart by there
* owning class.
......@@ -1647,7 +1665,7 @@ glade_property_class_update_from_node (GladeXmlNode *node,
}
g_free (buff);
g_free (buf);
}
else if (!klass->pspec)
{
......@@ -1662,28 +1680,50 @@ glade_property_class_update_from_node (GladeXmlNode *node,
}
/* Get the default */
if ((buff = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT)) != NULL)
if ((buf = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT)) != NULL)
{
if (klass->def) {
g_value_unset (klass->def);
g_free (klass->def);
}
klass->def = glade_property_class_make_gvalue_from_string (klass, buff, NULL);
g_free (buff);
klass->def = glade_property_class_make_gvalue_from_string (klass, buf, NULL);
g_free (buf);
}
/* If needed, update the name... */
if ((buff = glade_xml_get_property_string (node, GLADE_TAG_NAME)) != NULL)
if ((buf = glade_xml_get_property_string (node, GLADE_TAG_NAME)) != NULL)
{
g_free (klass->name);
klass->name = g_strdup (dgettext (domain, buff));
translated = dgettext (domain, buf);
if (buf != translated)
{
/* translated is owned by gettext */
klass->name = g_strdup (translated);
g_free (buf);
}
else
{
klass->name = buf;
}
}
/* ...and the tooltip */
if ((buff = glade_xml_get_value_string (node, GLADE_TAG_TOOLTIP)) != NULL)
if ((buf = glade_xml_get_value_string (node, GLADE_TAG_TOOLTIP)) != NULL)
{
g_free (klass->tooltip);
klass->tooltip = g_strdup (dgettext (domain, buff));
translated = dgettext (domain, buf);
if (buf != translated)
{
/* translated is owned by gettext */
klass->tooltip = g_strdup (translated);
g_free (buf);
}
else
{
klass->tooltip = buf;
}
}
/* Visible lines */
......
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