GtkD - how to list 0..100K strings

mark mark at qtrac.eu
Sun Apr 26 08:06:53 UTC 2020


I'm trying to develop an application in GtkD.

I need a widget to display a list of strings: there could be 
anything from 0 to 100K strings, but typically a few hundred or 
thousand.

Using the DemoCustomList as a model I have created this code:

// Note: DebNames is an AAset!string (AAset is a wrapper around a 
D AA, so in this case a set of strings)

// namestore.d
import gtk.ListStore: ListStore;

class NameStore : ListStore {

     this(DebNames names) {
         import gobject.c.types: GType;
         import gtk.TreeIter: TreeIter;

         super([GType.STRING]);

         TreeIter iter;
         foreach (name; names) {
             append(iter);
             setValue(iter, 0, name);
         }
     }
}

// appwindow.d
final class AppWindow: ApplicationWindow {
     TreeView debsTreeView;
     NameStore nameStore;
     // ...
     private void populateNames(DebNames names) {
         import gtk.CellRendererText: CellRendererText;
         import gtk.TreeViewColumn: TreeViewColumn;

         nameStore = new NameStore(names);
         auto column = new TreeViewColumn;
         auto renderer = new CellRendererText;
         column.packStart(renderer, true);
         column.addAttribute(renderer, "text", 0);
         column.setTitle("Names");
         debsTreeView.appendColumn(column);
     }
}

When populateNames() is called the treeview expands horizontally 
but shows nothing, so I'm stuck.

Can anyone help?

Note that I don't have to use a tree widget if there's a better 
one for this use case. I did see ListBox but that seemed to be a 
list of widgets which would be a bit heavy for 100K strings?


More information about the Digitalmars-d-learn mailing list