We have two buttons in our view (namely "Previous" and "Next"), their purpose is evident, the way it is done also (hem hem).
static void previous_clicked(GtkWidget *button, gabywindow *window) { record *r; view *v = window->view; int *id = &(window->id); r = get_record_no(v->subtable->table, *id); r = table_prev(v->subtable->table, r, -1); *id = ( r == NULL ) ? 0 : r->id; hello_fill(win); update_bound_windows(window); } |
FIXME: here is a few notes, they should be moved in a section with table_{first,last,next,prev} and get_record_no.
table_prev takes 3 arguments :
table which is the table in which the record is,
r which is the record we were at,
sort_by which is a number explaining with which kind of sorting we want to move (-1 means no sorting otherwise it is a field number).
Then we fill again the view and tell gaby about this change so bound windows are updated (with update_bound_windows).
next_clicked is the same with table_next instead of table_prev. Note that you don't need to check if you're on the first (or latest) record, it is handled by Gaby (previous when on first and you'll stay on it, same with next on latest).