Wed, 13 Nov 2024 21:30:18 +0100
make table column sizes adjustable (GTK)
ui/common/types.c | file | annotate | diff | comparison | revisions | |
ui/gtk/list.c | file | annotate | diff | comparison | revisions | |
ui/ui/tree.h | file | annotate | diff | comparison | revisions |
--- a/ui/common/types.c Tue Nov 12 14:58:03 2024 +0100 +++ b/ui/common/types.c Wed Nov 13 21:30:18 2024 +0100 @@ -204,6 +204,7 @@ info->columns = len; info->types = ui_calloc(ctx, len, sizeof(UiModelType)); info->titles = ui_calloc(ctx, len, sizeof(char*)); + info->columnsize = ui_calloc(ctx, len, sizeof(int)); int i = 0; CxIterator iter = cxListIterator(cols);
--- a/ui/gtk/list.c Tue Nov 12 14:58:03 2024 +0100 +++ b/ui/gtk/list.c Wed Nov 13 21:30:18 2024 +0100 @@ -325,6 +325,14 @@ i + addi, NULL); } + + int colsz = model->columnsize[i]; + if(colsz > 0) { + gtk_tree_view_column_set_fixed_width(column, colsz); + } else if(colsz < 0) { + gtk_tree_view_column_set_expand(column, TRUE); + } + gtk_tree_view_column_set_resizable(column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); }
--- a/ui/ui/tree.h Tue Nov 12 14:58:03 2024 +0100 +++ b/ui/ui/tree.h Wed Nov 13 21:30:18 2024 +0100 @@ -69,6 +69,11 @@ char **titles; /* + * array of column size hints + */ + int *columnsize; + + /* * function for translating model data to view data * first argument is the pointer returned by UiList->get or UiTree->get * second argument is the column index