Re: drag/drop after sort



muppet <scott asofyet org> writes:

On Dec 31, 2004, at 1:32 PM, Dan Espen wrote:

Torsten Schoenfeld <kaffeetisch gmx de> writes:
So, manually reordering a sorted list with d'n'd
wouldn't have any effect, since moved rows would automatically jump  
back
to their original position -- hence d'n'd reordering is disabled when
sorting is enabled.

If that is the design, I think its a bad design.  I sort on one or 2  
columns to get the approximate order I need and then drag/drop the  
remaining rows that didn't land where I wanted them to.

I think that's entirely normal for a list of things without unique  
keys.

Not necessarily bad design --- in 90% of use cases for a sortable list  
or tree, you want completely automatic sorting, and this works very  
well.  What you're wanting is to use the sorting functions as  
single-shot helpers for manual sorting, which is a special case.

It may be good for 90% of the cases, but I've written 2 apps
using GTK1, and both of them require this functionality.
So for me, it's bad in 100% of the cases.
I have no problem with the default behavior, its the inability
to turn it off that I consider bad design.

I take it, there is no way to clear this "sorted" indicator?
I'm searching the sources and I don't see the indicator, let
alone a way to clear it.

According to the TreeSortable iface docs, it looks like you either set  
a sort func or set the sort column id to "default":

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeSortable.html#gtk- 
tree-sortable-set-default-sort-func

"If sort_func is NULL, then there will be no default comparison  
function. This means that once the model has been sorted, it can't go  
back to the default state. In this case, when the current sort column  
id of sortable is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, the model  
will be unsorted."

Are you saying this will clear the sorted status?
I tried:

  $slist->get_model->set_default_sort_func(FALSE);
  $ctree->set_sort_column_id(-1);

Neither of which helps.

The -1 is GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
and I took a wild guess on the default sort func.

There's also the column's set_sort_indicator() and set_sort_order()  
methods --- set_sort_indicator() tells the column whether to show the  
sort direction indicator, while set_sort_order() tells the column  
whether to sort up or down.

http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeViewColumn.html#gtk- 
tree-view-column-set-sort-order

I've been able to clear the arrow, but it didn't help with the
problem I have.  Setting the sort order to ascending or descending
doesn't help either.  It doesn't look like it will accept a
sort order of 'none' or 'unsorted'.
 
After reading the first part of this, my first inclination was to copy  
the SimpleList data somewhere else, destroy the SimpleList and  
recreate it.

If you don't have huge amounts of data, this can be done easily by  
simply populating a new model with the contents of the old model, then  
swapping out the models and destroying the old one; that way the view  
doesn't have to be recreated.  This won't work with SimpleList, though  
-- SimpleList caches a reference to the model in the TiedRow class and  
connects some signals to the model when setting up the view, so  
swapping the model would be bad.

Well I have a SimpleList.  I know how to get the data out of it,
but it looks like it doesn't have a 'delete' method.
I just tried:

$slist = Gtk2::SimpleList->new (@colTitles);

but that didn't seem to do anything.
I guess you are saying there is no way to kill off a SimpleList
and create a new one?

This is a small amount of data.

I did find the "test.pl" sample in the gtk perl package which
has a button for ctree which brings up a Ctree that lets you
sort columns and rearrange freely.  I couldn't figure out
how mimic what it does with SimpleList.
Nor could I identify what it does to allow dnd after
a column sort.

-- 
Dan Espen                           E-mail: dane mk telcordia com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]