Wed, 13 Nov 2024 21:19:55 +0100
adjust browser columns
application/window.c | file | annotate | diff | comparison | revisions | |
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/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);
--- 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);
--- 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); }
--- 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