[glade] Utils: ignore text nodes in prev/next functions with comments
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Utils: ignore text nodes in prev/next functions with comments
- Date: Sat, 18 Jul 2020 16:51:01 +0000 (UTC)
commit 34fd642a0591bfa4b2cb32151b88569d86a48e69
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Sat Jul 18 13:41:16 2020 -0300
Utils: ignore text nodes in prev/next functions with comments
Ignore text nodes (whitespaces) in glade_xml_node_prev_with_comments() and
glade_xml_node_next_with_comments() functions to make it easier to get
comments nodes.
gladeui/glade-xml-utils.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gladeui/glade-xml-utils.c b/gladeui/glade-xml-utils.c
index 16b438b4..219b60a9 100644
--- a/gladeui/glade-xml-utils.c
+++ b/gladeui/glade-xml-utils.c
@@ -857,6 +857,13 @@ glade_xml_node_is_comment (GladeXmlNode *node_in)
return (node) ? node->type == XML_COMMENT_NODE : FALSE;
}
+static inline gboolean
+glade_xml_node_is_text (GladeXmlNode *node_in)
+{
+ xmlNodePtr node = (xmlNodePtr) node_in;
+ return (node) ? node->type == XML_TEXT_NODE : FALSE;
+}
+
static inline gboolean
glade_xml_node_is_comment_or_text (GladeXmlNode *node_in)
{
@@ -911,7 +918,11 @@ glade_xml_node_next_with_comments (GladeXmlNode *node_in)
{
xmlNodePtr node = (xmlNodePtr) node_in;
- return (GladeXmlNode *) node->next;
+ node = node->next;
+ while (glade_xml_node_is_text ((GladeXmlNode *) node))
+ node = node->next;
+
+ return (GladeXmlNode *) node;
}
GladeXmlNode *
@@ -919,7 +930,11 @@ glade_xml_node_prev_with_comments (GladeXmlNode *node_in)
{
xmlNodePtr node = (xmlNodePtr) node_in;
- return (GladeXmlNode *) node->prev;
+ node = node->prev;
+ while (glade_xml_node_is_text ((GladeXmlNode *) node))
+ node = node->prev;
+
+ return (GladeXmlNode *) node;
}
const gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]