aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-04-19 16:58:27 +0800
committerChris Lahey <clahey@src.gnome.org>2000-04-19 16:58:27 +0800
commit4780dd12ca591e0301f0d8eb173f8a4817b356d7 (patch)
tree29281e2c1b4c9c35f35f0f724dce8a9cc59d954c
parentd66dfd42ac4b8236f8a7f7b7fb015fc3d85aa7e3 (diff)
downloadgsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar.gz
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar.bz2
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar.lz
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar.xz
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.tar.zst
gsoc2013-evolution-4780dd12ca591e0301f0d8eb173f8a4817b356d7.zip
Added e_xml_get_child_by_name_by_lang.
2000-04-19 Christopher James Lahey <clahey@helixcode.com> * e-xml-utils.c, e-xml-utils.h: Added e_xml_get_child_by_name_by_lang. svn path=/trunk/; revision=2493
-rw-r--r--e-util/ChangeLog5
-rw-r--r--e-util/e-xml-utils.c31
-rw-r--r--e-util/e-xml-utils.c-5682631
-rw-r--r--e-util/e-xml-utils.h2
-rw-r--r--e-util/e-xml-utils.h-825482
5 files changed, 71 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 4cba63be98..e3d13ef2b3 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,8 @@
+2000-04-19 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-xml-utils.c, e-xml-utils.h: Added
+ e_xml_get_child_by_name_by_lang.
+
2000-04-16 Anders Carlsson <andersca@gnu.org>
* e-canvas.c (e_canvas_class_init): Add realize.
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c
index f0182d5167..250451f148 100644
--- a/e-util/e-xml-utils.c
+++ b/e-util/e-xml-utils.c
@@ -22,6 +22,7 @@
#include "e-xml-utils.h"
#include <gnome-xml/parser.h>
+#include <locale.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name)
{
@@ -38,6 +39,36 @@ xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name)
return NULL;
}
+/* Returns the first child with the name child_name and the "lang"
+ * attribute that matches the current LC_MESSAGES, or else, the first
+ * child with the name child_name and no "lang" attribute.
+ */
+xmlNode *
+e_xml_get_child_by_name_by_lang(xmlNode *parent, xmlChar *child_name, char *lang)
+{
+ xmlNode *child;
+ /* This is the default version of the string. */
+ xmlNode *C = NULL;
+
+ g_return_val_if_fail(parent != NULL, NULL);
+ g_return_val_if_fail(child_name != NULL, NULL);
+
+ if (lang == NULL)
+ lang = setlocale(LC_MESSAGES, NULL);
+
+ for (child = parent->childs; child; child = child->next) {
+ if ( !xmlStrcmp( child->name, child_name ) ) {
+ char *this_lang = xmlGetProp(child, "lang");
+ if ( this_lang == NULL ) {
+ C = child;
+ }
+ else if (!strcmp(this_lang, "lang"))
+ return child;
+ }
+ }
+ return C;
+}
+
int
e_xml_get_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name)
{
diff --git a/e-util/e-xml-utils.c-56826 b/e-util/e-xml-utils.c-56826
index f0182d5167..250451f148 100644
--- a/e-util/e-xml-utils.c-56826
+++ b/e-util/e-xml-utils.c-56826
@@ -22,6 +22,7 @@
#include "e-xml-utils.h"
#include <gnome-xml/parser.h>
+#include <locale.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name)
{
@@ -38,6 +39,36 @@ xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name)
return NULL;
}
+/* Returns the first child with the name child_name and the "lang"
+ * attribute that matches the current LC_MESSAGES, or else, the first
+ * child with the name child_name and no "lang" attribute.
+ */
+xmlNode *
+e_xml_get_child_by_name_by_lang(xmlNode *parent, xmlChar *child_name, char *lang)
+{
+ xmlNode *child;
+ /* This is the default version of the string. */
+ xmlNode *C = NULL;
+
+ g_return_val_if_fail(parent != NULL, NULL);
+ g_return_val_if_fail(child_name != NULL, NULL);
+
+ if (lang == NULL)
+ lang = setlocale(LC_MESSAGES, NULL);
+
+ for (child = parent->childs; child; child = child->next) {
+ if ( !xmlStrcmp( child->name, child_name ) ) {
+ char *this_lang = xmlGetProp(child, "lang");
+ if ( this_lang == NULL ) {
+ C = child;
+ }
+ else if (!strcmp(this_lang, "lang"))
+ return child;
+ }
+ }
+ return C;
+}
+
int
e_xml_get_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name)
{
diff --git a/e-util/e-xml-utils.h b/e-util/e-xml-utils.h
index 7b39ddac5f..77cc14bdd5 100644
--- a/e-util/e-xml-utils.h
+++ b/e-util/e-xml-utils.h
@@ -26,6 +26,8 @@
#include <gnome.h>
#include <gnome-xml/tree.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name);
+/* lang set to NULL means use the current locale. */
+xmlNode *e_xml_get_child_by_name_by_lang(xmlNode *parent, xmlChar *child_name, char *lang);
int e_xml_get_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name);
void e_xml_set_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name, int value);
diff --git a/e-util/e-xml-utils.h-82548 b/e-util/e-xml-utils.h-82548
index 7b39ddac5f..77cc14bdd5 100644
--- a/e-util/e-xml-utils.h-82548
+++ b/e-util/e-xml-utils.h-82548
@@ -26,6 +26,8 @@
#include <gnome.h>
#include <gnome-xml/tree.h>
xmlNode *e_xml_get_child_by_name(xmlNode *parent, xmlChar *child_name);
+/* lang set to NULL means use the current locale. */
+xmlNode *e_xml_get_child_by_name_by_lang(xmlNode *parent, xmlChar *child_name, char *lang);
int e_xml_get_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name);
void e_xml_set_integer_prop_by_name(xmlNode *parent, xmlChar *prop_name, int value);