Hi (this is a re-post, the first one didn't reach the list..)

I want a TreeView to be always ordered and also allow the user to move
rows from a "folder" to an other.

The problem is : 

        - If I set a TreeSortable.DefaultSortFunc, it seem that the TreeView is
not accepting drop's anymore.

Are TreeSortable.DefaultSortFunc and TreeView.Reorderable attribute
incompatible ?

I have attached an example that show what I'm trying to do.

### use case 1 with the two lines commented (see attached the file): 

        1) With the mouse, drag and drop the row named "Item 4" directly (not
just before or just after) on "Group 2"

Expected results :

        - The row "Item 4" is now under "Group 2" and correctly ordered between
"Item 1" and "Item 5"

Actual result : 

        - The row "Item 4" is now the top most row in "Group 2"


### use case with the two lines uncommented (see attached the file): 

        1) With the mouse, drag and drop the row named "Item 4" directly (not
just before or just after) on "Group 2"

Expected results :

        - The row "Item 4" is now under "Group 2" and correctly ordered between
"Item 1" and "Item 5"

Actual result : 

        - The drop seem to be refused the dragged row stay at the original
position in "Group 1"



David
using System;
using Gtk;

public class SampleTreeView : TreeView {
	
	public SampleTreeView() {
		
		TreeViewColumn treeViewColumn = new TreeViewColumn();
		treeViewColumn.Title = "Column 1";
		
		CellRendererText cellRendererText = new CellRendererText();
		treeViewColumn.PackStart(cellRendererText, false);
		treeViewColumn.AddAttribute(cellRendererText, "text", 0);
		
		this.AppendColumn(treeViewColumn);
		
		this.Model = new TreeStore(typeof(string));
		
		TreeIter group1TreeIter = ((TreeStore)this.Model).AppendValues("Group 1");
		TreeIter group2TreeIter = ((TreeStore)this.Model).AppendValues("Group 2");
		
		((TreeStore)this.Model).AppendValues(group1TreeIter, "Item 4");
		((TreeStore)this.Model).AppendValues(group1TreeIter, "Item 3");
		((TreeStore)this.Model).AppendValues(group1TreeIter, "Item 2");
		((TreeStore)this.Model).AppendValues(group2TreeIter, "Item 1");
		((TreeStore)this.Model).AppendValues(group2TreeIter, "Item 5");
		
		this.ExpandAll();
		
		this.Reorderable = true;
		
		// Drag and drop is working when those two lines are commented
		//((TreeStore) this.Model).DefaultSortFunc = SortFunc;
		//((TreeStore) this.Model).SetSortColumnId(-1, SortType.Ascending);
	}

	int SortFunc(TreeModel model, TreeIter iterA, TreeIter iterB){
		return String.Compare(
			(string) model.GetValue(iterA, 0),
			(string) model.GetValue(iterB, 0)
		);
	}
	
}
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list

Reply via email to