X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=6dd6d072d797ccb59548e29eb43f8fc0ec754840;hb=0e3ce9e407ed8e3fb554c0b25b65c0e8146bd1c6;hp=a78cd6129cc93617f8c0ab04ae56ace68a121232;hpb=b06b684589a618a2481ccc2745d5e03abb6bd5e0;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index a78cd612..6dd6d072 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -269,18 +269,48 @@ static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; + gchar *icon; + ObMenuEntry *e; if (state->parent) { + /* Don't try to extract "icon" attribute if icons in user-defined + menus are not enabled. */ + if (obt_xml_attr_string(node, "label", &label)) { + xmlNodePtr c; GSList *acts = NULL; - for (node = node->children; node; node = node->next) - if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) { - ObActionsAct *a = actions_parse(node); - if (a) - acts = g_slist_append(acts, a); + c = obt_xml_find_node(node->children, "action"); + while (c) { + ObActionsAct *action = actions_parse(c); + if (action) + acts = g_slist_append(acts, action); + c = obt_xml_find_node(node->next, "action"); + } + e = menu_add_normal(state->parent, -1, label, acts, TRUE); + + if (config_menu_show_icons && + obt_xml_attr_string(node, "icon", &icon)) + { + RrImage *ic; + + ic = RrImageCacheFindName(ob_rr_icons, icon); + if (ic) + RrImageRef(ic); + else { + ic = RrImageNew(ob_rr_icons); + if (!RrImageAddPictureName(ic, icon)) { + RrImageUnref(ic); /* no need to keep it around */ + ic = NULL; + } } - menu_add_normal(state->parent, -1, label, acts, TRUE); + e->data.normal.icon = ic; + + if (e->data.normal.icon) + e->data.normal.icon_alpha = 0xff; + + g_free(icon); + } g_free(label); } }