GtkD - how to list 0..100K strings
mark
mark at qtrac.eu
Mon Apr 27 10:07:30 UTC 2020
I've now got it to work but it is unusable!
It can show small numbers of rows with no problem.
However, if it has to show 100s of rows it expands the tree
vertically way beyond the bottom of the screen and is impossible
to navigate.
However, if it has to show 1000s of rows it goes into an infinite
loop producing endless error messages:
(DebFind:6615): Gtk-WARNING **: 10:57:04.275: infinite
surface size not supported
I suppose I was expecting scrollbars to appear, but maybe with
Gtk you have do add them separately?
// Here's the view I'm now using
class View : TreeView {
import gtk.CellRendererText: CellRendererText;
import gtk.TreeViewColumn: TreeViewColumn;
import qtrac.debfind.modelutil: NameAndDescription;
import qtrac.debfind.viewdata: ViewData;
ViewData viewData;
TreeViewColumn nameColumn;
TreeViewColumn descriptionColumn;
this() {
super();
setActivateOnSingleClick(true);
viewData = new ViewData;
setModel(viewData);
auto renderer = new CellRendererText;
nameColumn = new TreeViewColumn("Name", renderer, "text",
0);
nameColumn.setResizable(true);
appendColumn(nameColumn);
renderer = new CellRendererText;
descriptionColumn = new TreeViewColumn("Description",
renderer,
"text", 1);
descriptionColumn.setResizable(true);
appendColumn(descriptionColumn);
}
void clear() {
viewData.clear;
}
void populate(NameAndDescription[] namesAndDescriptions) {
viewData.populate(namesAndDescriptions);
}
}
// Here's the ListStore I'm using:
class ViewData : ListStore {
import qtrac.debfind.modelutil: NameAndDescription;
this() {
import gobject.c.types: GType;
super([GType.STRING, GType.STRING]);
}
void populate(NameAndDescription[] namesAndDescriptions) {
import gtk.TreeIter: TreeIter;
clear;
TreeIter iter;
foreach (i, nameAndDescription; namesAndDescriptions) {
append(iter);
setValue(iter, 0, nameAndDescription.name);
setValue(iter, 1,
nameAndDescription.description);
}
}
}
// I have the TreeView side-by-side with a TextView: here're
snippets:
Paned splitter;
View debsView;
TextView debTextView;
...
splitter = new Paned(GtkOrientation.HORIZONTAL);
splitter.setWideHandle(true);
debsView = new View;
debsView.setHexpand(true);
debsView.setVexpand(true);
debTextView = new TextView;
...
auto grid = new Grid;
...
splitter.pack1(debsView, false, true);
splitter.pack2(debTextView, true, true);
grid.attach(splitter, 0, 3, 6, 1);
More information about the Digitalmars-d-learn
mailing list