- self = g_new0(Menu, 1);
- self->label = g_strdup(label);
- self->name = g_strdup(name);
- self->parent = parent;
-
- self->entries = NULL;
- self->shown = FALSE;
- self->invalid = FALSE;
- /* default controllers? */
-
- self->show = show;
- self->hide = NULL;
- self->update = update;
- self->mouseover = NULL;
- self->selected = NULL;
-
- attrib.override_redirect = TRUE;
- attrib.event_mask = FRAME_EVENTMASK;
- self->frame = createWindow(ob_root, CWOverrideRedirect|CWEventMask, &attrib);
- attrib.event_mask = TITLE_EVENTMASK;
- self->title = createWindow(self->frame, CWEventMask, &attrib);
- self->items = createWindow(self->frame, 0, &attrib);
-
- XSetWindowBorderWidth(ob_display, self->frame, theme_bwidth);
- XSetWindowBorderWidth(ob_display, self->title, theme_bwidth);
- XSetWindowBorder(ob_display, self->frame, theme_b_color->pixel);
- XSetWindowBorder(ob_display, self->title, theme_b_color->pixel);
-
- XMapWindow(ob_display, self->title);
- XMapWindow(ob_display, self->items);
-
- self->a_title = appearance_copy(theme_a_menu_title);
- self->a_items = appearance_copy(theme_a_menu);
-
- g_hash_table_insert(menu_map, &self->frame, self);
- g_hash_table_insert(menu_map, &self->title, self);
- g_hash_table_insert(menu_map, &self->items, self);
- g_hash_table_insert(menu_hash, g_strdup(name), self);
+ if (!self->execute)
+ return;
+ if (self->entries) /* the entries are already created and cached */
+ return;
+
+ if (!g_spawn_command_line_sync(self->execute, &output, NULL, NULL, &err)) {
+ g_message(_("Failed to execute command for pipe-menu \"%s\": %s"),
+ self->execute, err->message);
+ g_error_free(err);
+ return;
+ }
+
+ if (parse_load_mem(output, strlen(output),
+ "openbox_pipe_menu", &doc, &node))
+ {
+ menu_parse_state.pipe_creator = self;
+ menu_parse_state.parent = self;
+ parse_tree(menu_parse_inst, doc, node->children);
+ xmlFreeDoc(doc);
+ } else {
+ g_message(_("Invalid output from pipe-menu \"%s\""), self->execute);
+ }
+
+ g_free(output);
+}
+
+static ObMenu* menu_from_name(gchar *name)
+{
+ ObMenu *self = NULL;
+
+ g_assert(name != NULL);
+
+ if (!(self = g_hash_table_lookup(menu_hash, name)))
+ g_message(_("Attempted to access menu \"%s\" but it does not exist"),
+ name);