int evolve_widget_list_sort_cb(void *d1, void *d2) { Evolve_Widget *w1; Evolve_Widget *w2; w1 = d1; w2 = d2; /* no parents, both are top level */ if (!w1->parent && !w2->parent) return 0; /* w1 needs to go to the top */ if (!w1->parent) return -1; /* w2 needs to go to the top */ if (!w2->parent) return 1; /* w2 has parent w1, w1 goes to top */ if (!strcmp(w2->parent, w1->name)) return -1; /* w1 has parent w2, w2 goes to top */ if (!strcmp(w1->parent, w2->name)) return 1; }