summaryrefslogtreecommitdiff
path: root/gladeui
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-07-18 13:41:16 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-07-18 13:41:16 -0300
commit34fd642a0591bfa4b2cb32151b88569d86a48e69 (patch)
tree0e77e5b46fc9dbefee4f92f3b10d1a56859338f1 /gladeui
parent238ec80d11c9482dc25d2970985028ef72fe5075 (diff)
downloadglade-34fd642a0591bfa4b2cb32151b88569d86a48e69.tar.gz
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.
Diffstat (limited to 'gladeui')
-rw-r--r--gladeui/glade-xml-utils.c19
1 files 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
@@ -858,6 +858,13 @@ glade_xml_node_is_comment (GladeXmlNode *node_in)
}
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)
{
xmlNodePtr node = (xmlNodePtr) 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 *