]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
Parse all the actions in a single menu item
[chaz/openbox] / openbox / menu.c
index a4f62f6c7301f87778dbf571dc3e36556a96911f..1294c4c95600d7b4bd18b79e7545bb0f575efdac 100644 (file)
@@ -287,26 +287,14 @@ static void parse_menu_item(xmlNodePtr node,  gpointer data)
                 ObActionsAct *action = actions_parse(c);
                 if (action)
                     acts = g_slist_append(acts, action);
-                c = obt_xml_find_node(node->next, "action");
+                c = obt_xml_find_node(c->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;
-                    }
-                }
-                e->data.normal.icon = ic;
+                e->data.normal.icon = RrImageNewFromName(ob_rr_icons, icon);
 
                 if (e->data.normal.icon)
                     e->data.normal.icon_alpha = 0xff;
@@ -338,6 +326,8 @@ static void parse_menu(xmlNodePtr node, gpointer data)
     ObMenuParseState *state = data;
     gchar *name = NULL, *title = NULL, *script = NULL;
     ObMenu *menu;
+    ObMenuEntry *e;
+    gchar *icon;
 
     if (!obt_xml_attr_string(node, "id", &name))
         goto parse_menu_fail;
@@ -361,8 +351,20 @@ static void parse_menu(xmlNodePtr node, gpointer data)
         }
     }
 
-    if (state->parent)
-        menu_add_submenu(state->parent, -1, name);
+    if (state->parent) {
+        e = menu_add_submenu(state->parent, -1, name);
+
+        if (config_menu_show_icons &&
+            obt_xml_attr_string(node, "icon", &icon))
+        {
+            e->data.submenu.icon = RrImageNewFromName(ob_rr_icons, icon);
+
+            if (e->data.submenu.icon)
+                e->data.submenu.icon_alpha = 0xff;
+
+            g_free(icon);
+        }
+    }
 
 parse_menu_fail:
     g_free(name);
@@ -546,6 +548,7 @@ void menu_entry_unref(ObMenuEntry *self)
             }
             break;
         case OB_MENU_ENTRY_TYPE_SUBMENU:
+            RrImageUnref(self->data.submenu.icon);
             g_free(self->data.submenu.name);
             break;
         case OB_MENU_ENTRY_TYPE_SEPARATOR:
This page took 0.02447 seconds and 4 git commands to generate.