# HG changeset patch # User Olaf Wintermann # Date 1731529195 -3600 # Node ID 1a908b060122e8a4610228208e1617c854ac0498 # Parent 483d7342b439d2937f4f63b335d2326eb5c7401a adjust browser columns diff -r 483d7342b439 -r 1a908b060122 application/window.c --- a/application/window.c Tue Nov 12 15:05:57 2024 +0100 +++ b/application/window.c Wed Nov 13 21:19:55 2024 +0100 @@ -72,6 +72,8 @@ // main content UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING_FREE, "Last Modified", UI_STRING_FREE, "Size", -1); + model->columnsize[0] = -1; + model->columnsize[1] = 150; model->getvalue = (ui_getvaluefunc) window_resource_table_getvalue; ui_table(obj, .fill = UI_ON, .model = model, .onselection = action_list_selection, .onactivate = action_list_activate, .ondrop = action_dnd_drop, .varname = "reslist", .multiselection = TRUE); diff -r 483d7342b439 -r 1a908b060122 ui/common/types.c --- a/ui/common/types.c Tue Nov 12 15:05:57 2024 +0100 +++ b/ui/common/types.c Wed Nov 13 21:19:55 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 483d7342b439 -r 1a908b060122 ui/gtk/list.c --- a/ui/gtk/list.c Tue Nov 12 15:05:57 2024 +0100 +++ b/ui/gtk/list.c Wed Nov 13 21:19:55 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 483d7342b439 -r 1a908b060122 ui/ui/tree.h --- a/ui/ui/tree.h Tue Nov 12 15:05:57 2024 +0100 +++ b/ui/ui/tree.h Wed Nov 13 21:19:55 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