Maybe a good improving of GTK would be to offer some methods that will simply transformed an IList, ICollection and datatable to a ListStore/TreeStore.

My two cents.

Thierry

Miguel de Icaza wrote:

Hello,



Some things I find annoying :
- It seems we had to use ListStore for TreeView.Model, and it seems
ListStore is a simple another list object... There is always many
lists types in System.Collections, why should we use another lis type
for treeview for instance ? An IList would be better, no ?



Actually the ListStore is not a simple list object, it is a fairly elaborate "storage" for treemodels that happens to be flat.

The list/tree widget in Gtk# is actually always a tree.  But depending
on the model implementation it can behave as either a tree or a list.
ListStore is what makes the TreeView behave like a list of elements.

But I see what you want: you want to reuse the same IList API there.
Do you have a sample program that you could share with us that you would
like transformed into an IList-based sample?  That would help us.



- I find some things very weird. To get the entry selected in a
TreeView, it seems we have to write an overcomplicated-for-the-job
code :
TreeIter iter;
TreeModel model;
TreeSelection sel = myTreeView.Selection;
if(sel.GetSelected(out model, out iter)) {
   int thing = (int)model.GetValue( iter, 5 );

And so on.

A simple thing like that could not be possible ? :
int thing = (int) myTreeView.EntrySelected(5);

or, even better, a thing like that :
MyObject my = (MyObject) myTreeView.EntrySelected();



This sounds like a useful addition, we could file a feature request, but but there are two problems with your example:

        * What happens if there is nothing selected?  Should
          we throw an exception?  I think that would be a bad idea.

        * What happens if you have multiple-selection enabled?

Perhaps the solution would be to have a method like this:

class TreeView {

        // Return an array of objects for each row.
        object [] GetSelected () {...}

        // Return the array of objects for a specific column
        object [] GetSelected (int column) { }
}

Miguel
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list





_______________________________________________ Gtk-sharp-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to