+static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
+ gchar **strippedlabel, guint *position,
+ gboolean *always_show)
+{
+ gunichar shortcut = 0;
+
+ *position = 0;
+ *always_show = FALSE;
+
+ g_assert(strippedlabel != NULL);
+
+ if (label == NULL) {
+ *strippedlabel = NULL;
+ } else {
+ gchar *i;
+
+ *strippedlabel = g_strdup(label);
+
+ /* if allow_shortcut is false, then you can't use the '_', instead you
+ have to just use the first valid character
+ */
+
+ i = strchr(*strippedlabel, '_');
+ if (allow_shortcut && i != NULL) {
+ /* there is an underscore in the string */
+
+ /* you have to use a printable ascii character for shortcuts
+ don't allow space either, so you can have like "a _ b"
+ */
+ if (VALID_SHORTCUT(*(i+1))) {
+ shortcut = g_unichar_tolower(g_utf8_get_char(i+1));
+ *position = i - *strippedlabel;
+ *always_show = TRUE;
+
+ /* remove the '_' from the string */
+ for (; *i != '\0'; ++i)
+ *i = *(i+1);
+ } else if (*(i+1) == '\0') {
+ /* no default shortcut if the '_' is the last character
+ (eg. "Exit_") for menu entries that you don't want
+ to be executed by mistake
+ */
+ *i = '\0';
+ }
+ } else {
+ /* there is no underscore, so find the first valid character to use
+ instead */
+
+ for (i = *strippedlabel; *i != '\0'; ++i)
+ if (VALID_SHORTCUT(*i)) {
+ *position = i - *strippedlabel;
+ shortcut = g_unichar_tolower(g_utf8_get_char(i));
+ break;
+ }
+ }
+ }
+ return shortcut;
+}
+
+static void parse_menu_item(xmlNodePtr node, gpointer data)