static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); if ((n = obt_xml_find_node(node, "command")) || (n = obt_xml_find_node(node, "execute"))) { gchar *s = obt_xml_node_string(n); o->cmd = obt_paths_expand_tilde(s); g_free(s); } if ((n = obt_xml_find_node(node, "prompt"))) o->prompt = obt_xml_node_string(n); if ((n = obt_xml_find_node(node, "startupnotify"))) { xmlNodePtr m; if ((m = obt_xml_find_node(n->children, "enabled"))) o->sn = obt_xml_node_bool(m); if ((m = obt_xml_find_node(n->children, "name"))) o->sn_name = obt_xml_node_string(m); if ((m = obt_xml_find_node(n->children, "icon"))) o->sn_icon = obt_xml_node_string(m); if ((m = obt_xml_find_node(n->children, "wmclass"))) o->sn_wmclass = obt_xml_node_string(m); } return o; }
static void parse_menu(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *name = NULL, *title = NULL, *script = NULL; ObMenu *menu; if (!obt_xml_attr_string(node, "id", &name)) goto parse_menu_fail; if (!g_hash_table_lookup(menu_hash, name)) { if (!obt_xml_attr_string(node, "label", &title)) goto parse_menu_fail; if ((menu = menu_new(name, title, TRUE, NULL))) { menu->pipe_creator = state->pipe_creator; if (obt_xml_attr_string(node, "execute", &script)) { menu->execute = obt_paths_expand_tilde(script); } else { ObMenu *old; old = state->parent; state->parent = menu; obt_xml_tree(menu_parse_inst, node->children); state->parent = old; } } } if (state->parent) menu_add_submenu(state->parent, -1, name); parse_menu_fail: g_free(name); g_free(title); g_free(script); }