]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
Some style changes, less ifdefs.
[chaz/openbox] / openbox / menu.c
index a78cd6129cc93617f8c0ab04ae56ace68a121232..77d9548c0da34069884a41d57042230849f9751a 100644 (file)
@@ -36,6 +36,7 @@
 #include "gettext.h"
 #include "obt/xml.h"
 #include "obt/paths.h"
+#include "imageload.h"
 
 typedef struct _ObMenuParseState ObMenuParseState;
 
@@ -269,18 +270,36 @@ 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 (!(config_menu_user_show_icons &&
+            obt_xml_attr_string(node, "icon", &icon)))
+        {
+            icon = NULL;
+        }
+
         if (obt_xml_attr_string(node, "label", &label)) {
             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);
-                }
-            menu_add_normal(state->parent, -1, label, acts, TRUE);
+            node = obt_xml_find_node(node->children, "action");
+            while (node) {
+                ObActionsAct *action = actions_parse(node);
+                if (action)
+                    acts = g_slist_append(acts, action);
+                node = obt_xml_find_node(node->next, "action");
+            }
+            e = menu_add_normal(state->parent, -1, label, acts, TRUE);
+            
+            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);
+            }
             g_free(label);
         }
     }
This page took 0.022045 seconds and 4 git commands to generate.