diff options
| author | Dana Jansens <danakj@orodu.net> | 2012-09-30 15:50:26 -0400 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2012-09-30 15:53:35 -0400 |
| commit | dff52764822f68596134c2548966eb78777b6d2a (patch) | |
| tree | 08fed8a4bec1aee59d5b7d63a5616b838f31b8a0 | |
| parent | 3aee1ac3a199a40020e204e42ed9a48e2f4e1404 (diff) | |
Don't strip leading whitespace from menu labels (Fix bug 4782)
| -rw-r--r-- | obt/xml.c | 24 | ||||
| -rw-r--r-- | obt/xml.h | 3 | ||||
| -rw-r--r-- | openbox/menu.c | 6 |
3 files changed, 25 insertions, 8 deletions
@@ -321,16 +321,22 @@ void obt_xml_tree_from_root(ObtXmlInst *i) obt_xml_tree(i, i->root->children); } -gchar *obt_xml_node_string(xmlNodePtr node) +gchar *obt_xml_node_string_unstripped(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); gchar *s; - if (c) g_strstrip((char*)c); /* strip leading/trailing whitespace */ s = g_strdup(c ? (gchar*)c : ""); xmlFree(c); return s; } +gchar *obt_xml_node_string(xmlNodePtr node) +{ + gchar* result = obt_xml_node_string_unstripped(node); + g_strstrip(result); /* strip leading/trailing whitespace */ + return result; +} + gint obt_xml_node_int(xmlNodePtr node) { xmlChar *c = xmlNodeGetContent(node); @@ -413,13 +419,12 @@ gboolean obt_xml_attr_int(xmlNodePtr node, const gchar *name, gint *value) return r; } -gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, - gchar **value) +gboolean obt_xml_attr_string_unstripped(xmlNodePtr node, const gchar *name, + gchar **value) { xmlChar *c = xmlGetProp(node, (const xmlChar*) name); gboolean r = FALSE; if (c) { - g_strstrip((char*)c); /* strip leading/trailing whitespace */ *value = g_strdup((gchar*)c); r = TRUE; } @@ -427,6 +432,15 @@ gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, return r; } +gboolean obt_xml_attr_string(xmlNodePtr node, const gchar *name, + gchar **value) +{ + gboolean result = obt_xml_attr_string_unstripped(node, name, value); + if (result) + g_strstrip(*value); /* strip leading/trailing whitespace */ + return result; +} + gboolean obt_xml_attr_contains(xmlNodePtr node, const gchar *name, const gchar *val) { @@ -72,12 +72,15 @@ void obt_xml_tree_from_root(ObtXmlInst *i); xmlNodePtr obt_xml_find_node (xmlNodePtr node, const gchar *name); gboolean obt_xml_node_contains (xmlNodePtr node, const gchar *val); +gchar *obt_xml_node_string_unstripped(xmlNodePtr node); gchar *obt_xml_node_string (xmlNodePtr node); gint obt_xml_node_int (xmlNodePtr node); gboolean obt_xml_node_bool (xmlNodePtr node); gboolean obt_xml_attr_contains (xmlNodePtr node, const gchar *name, const gchar *val); +gboolean obt_xml_attr_string_unstripped(xmlNodePtr node, const gchar *name, + gchar **value); gboolean obt_xml_attr_string (xmlNodePtr node, const gchar *name, gchar **value); gboolean obt_xml_attr_int (xmlNodePtr node, const gchar *name, diff --git a/openbox/menu.c b/openbox/menu.c index 7d8f0ba2..eaf081d9 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -279,7 +279,7 @@ static void parse_menu_item(xmlNodePtr node, gpointer data) /* Don't try to extract "icon" attribute if icons in user-defined menus are not enabled. */ - if (obt_xml_attr_string(node, "label", &label)) { + if (obt_xml_attr_string_unstripped(node, "label", &label)) { xmlNodePtr c; GSList *acts = NULL; @@ -314,7 +314,7 @@ static void parse_menu_separator(xmlNodePtr node, gpointer data) if (state->parent) { gchar *label; - if (!obt_xml_attr_string(node, "label", &label)) + if (!obt_xml_attr_string_unstripped(node, "label", &label)) label = NULL; menu_add_separator(state->parent, -1, label); @@ -334,7 +334,7 @@ static void parse_menu(xmlNodePtr node, gpointer data) goto parse_menu_fail; if (!g_hash_table_lookup(menu_hash, name)) { - if (!obt_xml_attr_string(node, "label", &title)) + if (!obt_xml_attr_string_unstripped(node, "label", &title)) goto parse_menu_fail; if ((menu = menu_new(name, title, TRUE, NULL))) { |
