# HG changeset patch # User Olaf Wintermann # Date 1731529818 -3600 # Node ID aad99285865c867ea72050cb8c4574927f2054aa # Parent 958bae3722711d5e62f608c225afabb25061c47d make table column sizes adjustable (GTK) diff -r 958bae372271 -r aad99285865c ui/common/types.c --- 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); diff -r 958bae372271 -r aad99285865c ui/gtk/list.c --- 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); } diff -r 958bae372271 -r aad99285865c ui/ui/tree.h --- 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