GTK+ 3: Restore TreeViewColumn widths without making them behave as if manually sized - gtk

I have a TreeView whose columns are all expandable with fixed-mode sizing. I would like to restore the widths of the columns when the user restarts the app. It seems that calling set_fixed_size is the way to do this, but:
If I set only the widths of the columns that the user resized, then the actual column widths end up different from what they were before.
If instead I set all column widths explicitly, then all columns behave as though they had been resized by the user, which is not ideal.
Is there a way to restore the column widths that gets around these problems?

It turns out that expand interferes with fixed_width. In my case, the solution was to set fixed_width and expand=false on columns that the user resized, and expand=true on the others.

Related

Does ag-grid supports column virtualization?

Its specially important in scenarios with lots of columns which most of them are not in viewable area.
Yes, as stated on the documentation,
By default the grid uses virtualisation; a technique whereby the grid
draws columns and rows as the user scrolls.
However, if you wish to disable column virtualization, you may choose to set the suppressColumnVirtualisation input property as true. You may refer to the column/row properties over here.
There may be 2 scenarios when you may wish to disable column virtualization.
1) Auto-sizing of all columns. This will ensure that all columns, and not just the columns which are rendered on the screen, will be resized.
2) Support for a11y. This is to prevent any potential issues for keyboard navigation and screen readers.

How to achieve auto width Column in sap.ui.table.Table?

I am using sap.ui.table.Table. This table has some very good feature but I am having a tough time to figure out how to set the column to auto width.
Currently, all the columns are fixed size but I want something if column A value is small, then auto adjust it rather than having fixed size. Same for if the column value is large, then adjust it to show the value.
I saw the other question sap.ui.table.Table how to optimize column widths but the answers there are to get column layout with fixed sizes, not auto width.
The control sap.ui.table.Column offers a property called autoResizable by which the user can resize the column width depending on the content of the column's template.
<Column
autoResizable="true"
...
From API Reference:
Enables auto-resizing of the column on double clicking the resize bar. The width is determined on the widest currently displayed content. It does not consider rows which are currently not scrolled into view.
However, as you can see, it requires user interaction. Doing it without user interaction programmatically can be achieved by using the (currently experimental) API autoResizeColumn from sap.ui.table.Table.
myTable.autoResizeColumn(/*ColumnIndex*/); // experimental!
Here is an example of both approaches: https://embed.plnkr.co/NQpkJo/.

gtk treeview column resizing and horizontal scrollbar

I have a gtk treeview (inside a GtkScrolledWindow) with two columns.
If I set both columns to the default sizing policy, I have a horizontal scrollbar for the treeview but the columns can't be sized down by the user, which is impractical.
If I set both columns to setSizing Fixed, fixed width 120, I get a nice display and the columns can be resized, but there is no horizontal scrollbar in the treeview (since the columns size down to fit in the width of the treeview I guess).
If I set the first column to setSizing fixed, fixed width 120, the second one to automatic, only the second column is displayed (???).
I would like that by default the first column takes let's say at most 60% of the display, the second column can go all the way and I have a horizontal scrollbar. Certainly I want the user to be able to resize them up or down, not as with the default policy, that you can resize them down!
That's why I tried the first column fixed, the second automatic, it was promessing but I don't understand why the first column is not displayed at all in that configuration.
I add the cell renderers with packstart true, I tried false but it didn't change anything, also I tried setting the expand for the columns to true or false, which didn't have any effect.
Note I'm using the gtk2hs haskell bindings but I'm certain it would be the same in any other gtk binding. Just mentioning if people will ask for code samples.
I'm pretty sure this is a common problem... I'd say nautilus is fixing it the way I'd like to fix it, but I think digging in the nautilus source is going to be quite long...
EDIT well i've discovered the cell renderer's ellipsize setting also has an effect. Setting it to end for the first column and none for the second should be what i want but then the first column is very small and cannot be expanded through resize...
EDIT2 well for now i've moved to word wrapping for the cell renderer, that way i don't have to bother with a horizontal scrollbar... Still curious for the solution to that question though.

Crystal Reports fields won't align

I have several items that I want to line up. The Width and Height of all fields match. Usually I just use the Align, but it's making it worse. My out of line field which is slighly lower, moves way up, way out of line (with align tops)
So I tried using the Size and Position to set it manually. Several objects have a Y of 0.056, but my last one has 0.061. I change the last one to 0.056 and save it. It doesn't appear to be different, and when I look at it again, it's still 0.061. (When I used align, it went up to 0.028!)
I do NOT have Snap to Grid set (my grid size is 0.083). (Nor does turning on Snap to Grid make them align.) The fields have exactly the same formatting. But unless I can magically make them align by hand, they refuse to align. Why?
You've already done a lot of the regular troubleshooting steps. One more ting that I sometimes do is to select all the fields I want to align, then use the arrow keys and move them up into the section above and then back down into their original section. That usually puts them all into the 0 position. If it dosn't work with all of them selected, try each one separately.

GtkTreeViewColumn resizing based on contents

So it turns out that we'd like to use fixed height mode, because it's faster and it doesn't constantly try to update the treeview — we saw a significant decrease in CPU use with a table that, unfortunately, may contain a few thousand rows and some 20-ish columns.
Oddly enough, merely turning off autosizing on all the columns doesn't help, one needs to set fixed height mode too.
But of course, the cell contents are of varying length (they're text and numbers), and it would be nice to update the column size time to time (ie. when I know they should be updated, and not all the time like autosizing unfortunately does).
So what I need is being able to figure out that the newly inserted row / cell has insufficient size (I guess something to do with the GtkCellRendererText and Pango will come handy), and then resize the affected GtkTreeViewColumn using set_fixed_width. I've looked at the source of GTK+ to see what they do when autosizing, but couldn't really make head or tails of it. My main problem here is getting to the text layout and/or the cell size requirements from a given TreeView/ListStore/iter combination.
I use perl-Gtk2, but answers are welcome in any commonly used language.