state_t pback_getnew(node_t **node, int8_t dir) { state_t state; node_t *tmp = *node, *last; while (true) { last = tmp; tmp = node_traverse(tmp, dir, 1); if ((tmp == NULL) /* no more tracks */ || (tmp == last)) /* no more visible tracks */ break; if (node_isleaf(tmp)) { if (tmp->t->avail && tmp->t->sane) /* found a playable track */ break; info("pback_getnew(): ignoring %s%s%s track %s.\n", !tmp->t->avail ? "unavailable" : "", !(tmp->t->avail || tmp->t->sane) ? " and " : "", !tmp->t->sane ? "insane" : "", tmp->t->fn); } else /* found a branch -- always 'playable' */ break; } if (tmp == *node) /* nowhere visible to go */ state = ERR_VIS; else if (tmp == NULL) /* nowhere at all to go */ state = ERR_NULL; else /* got a new track */ { if (pback_should_cont(tmp, g_opts.tr.cont)) { *node = tmp; state = OK; } else state = ERR_RULES; } return state; }
static void wire_traverse (Wire *wire) { GSList *iter; g_return_if_fail (wire != NULL); g_return_if_fail (IS_WIRE (wire)); if (wire_is_visited (wire)) return; wire_set_visited (wire, TRUE); g_signal_emit_by_name (wire, "highlight"); for (iter = wire_get_nodes (wire); iter; iter = iter->next) { Node *node = iter->data; node_traverse (node); } }
void node_traverse (node_t* node, void(*traverse_cb)(node_t*, gpointer), gpointer user_data) { GHashTableIter iter; gpointer value; g_assert(traverse_cb); if (node == NULL) { node = ROOT; } if (node) { traverse_cb(node, user_data); } g_hash_table_iter_init (&iter, node->children); while (g_hash_table_iter_next (&iter, NULL, &value)) { node_traverse((node_t *)value, traverse_cb, user_data); } }
static void wire_traverse (Wire *wire) { GSList *nodes; g_return_if_fail (wire != NULL); g_return_if_fail (IS_WIRE (wire)); if (wire_is_visited (wire)) return; wire_set_visited (wire, TRUE); g_signal_emit_by_name (wire, "highlight"); for (nodes = wire_get_nodes (wire); nodes; nodes = nodes->next) { Node *node = nodes->data; node_traverse (node); } g_slist_free_full (nodes, g_object_unref); }