Re: drag/drop after sort




On Dec 31, 2004, at 4:52 PM, Dan Espen wrote:

muppet <scott asofyet org> writes:

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

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, ..."

Are you saying this will clear the sorted status?

i'm not sure what it will do, i was just quoting the docs.  ;-)


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.

I believe it would want undef rather than FALSE. They aren't exactly the same at the XS level -- FALSE is defined, and would pass the SvOK() check, so you'd still have a sort func installed. undef fails the SvOK() check, and goes down the branch that calls the C function with NULL.

Can you post some code so that i can play with something resembling what you have?


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.

You can replace all of the data in the SimpleList by doing

  @{ $slist->{data} } = @new_data;

if @new_data is an empty array (e.g., ()), then you've just cleared the model.

the dereference of $slist->{data} is important, of course, because without it you'll replace the tied array reference and let the magic smoke out.


I guess you are saying there is no way to kill off a SimpleList and create a new one?

Not quite -- i was saying that if you were using the treeview api directly, you could build up a new GtkTreeModel and replace the model used by a GtkTreeView without having the list visibly empty and re-fill, but with SimpleList you can't replace the model because of implementation details. this is the purpose of the freeze and thaw methods on the CList. (i guess i left out the "visible change" part. ;-)


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.

The CTree/CList and TreeView implementations are completely different. The TreeView's idea of sorting is "if it's going to be sorted, it's always going to be sorted", but the CList only sorts when you tell it to (if i remember correctly).

What you could do is just omit all the normal TreeView sorting stuff and fake it in your UI --- when the user clicks on the column header, sort your data manually by that column. You can use set_sort_indicator() to fake the sort direction for visual feedback.

  $column->set_clickable (TRUE);
$column->signal_connect (clicked => sub { manually sort data by this column });

--
The door is locked. I tried to open it, but the lock is harder to pick than a broken nose.
  -- Sensei, on 'I, Ninja'




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