X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=f53e4f0b44661e23cc82f69c17750fd865750f93;hb=0352abfa88892bc17bdff2022745e3c1b312edd0;hp=fcf5d1689e904d71234f1fb43be0666420c999b0;hpb=63f748aa3fac4d3ed004a2c5343a51c3a046e21d;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index fcf5d168..f53e4f0b 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -36,6 +36,7 @@ #include "gettext.h" #include "obt/xml.h" #include "obt/paths.h" +#include "imageload.h" typedef struct _ObMenuParseState ObMenuParseState; @@ -269,8 +270,20 @@ static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; + #ifdef USE_IMLIB2 + gchar *icon; + #endif + ObMenuEntry *e; if (state->parent) { + #ifdef USE_IMLIB2 + /* Don't try to extract "icon" attribute if icons in user-defined + menus are not enabled. */ + if (!(config_menu_user_show_icons && + obt_xml_attr_string(node, "icon", &icon))) + icon = NULL; + #endif + if (obt_xml_attr_string(node, "label", &label)) { GSList *acts = NULL; @@ -281,8 +294,19 @@ static void parse_menu_item(xmlNodePtr node, gpointer data) acts = g_slist_append(acts, action); node = obt_xml_find_node(node->next, "action"); } + e = menu_add_normal(state->parent, -1, label, acts, TRUE); + + #ifdef USE_IMLIB2 + if (icon) { /* Icon will be used. */ + e->data.normal.icon = RrImageFetchFromFile(ob_rr_icons, icon); + if (e->data.normal.icon) { + e->data.normal.icon_alpha = 0xff; + } + g_free(icon); + } menu_add_normal(state->parent, -1, label, acts, TRUE); + #endif g_free(label); } }