Navigation C API Pages Python bindings Applications

Table widget

Table widget is a widget that shows a table possibly sortable by its elements.

The table content is not stored in the widget, instead there are two callbacks that are called by the widget table code when rendering.

Table widget callbacks
enum gp_widget_table_row_op {

        /* iterator based API */
        union {
                void *row_priv;
                unsigned long row_idx;
        int (*row)(struct gp_widget *self, int op, unsigned int pos);
        const char *(*get)(struct gp_widget *self, unsigned int col);

        void (*sort)(struct gp_widget *self, unsigned int col, int desc);
Table 1. row() callback ops
enum gp_widget_table_row_op Description


This op has to reset the current row to 0, it has to return non-zero if the row is valid i.e. exists, and zero otherwise. The pos parameter is not used in this case.


This op moves the current row by the op elements forward. The return value is the same as for GP_TABLE_ROW_RESET, i.e. non-zero if resulting row is valid and zero if not.


This op is used to request current number of elements. The return value is either number of rows, or -1. If -1 is returned the number of rows is counted in the widget code.

The row() callback is called by the table code to set the current row, then the get() callback is used to get content for each column.


If any of the table columns is sortable, the sort() function must be implemented.