problems displaying filesize in tree_view_column



Hello.

I'd like to display a filesize (1.34 Mb or something) in a tree_view
column. I used to have a column of type string but then the sorting was
broken. So i've set a custom sorting function for this column which uses
a data pointer (which is also stored in the tree model) to determine the
sort order. This works fine so far.

But i've read the reference of the tree_view_column again, and i noticed
that it is possible to set a cell_data function for a column.
So i no longer stored the filesize as string in the tree model but as
number, and i've set a cell data function:

  void
  cell_filesize(GtkTreeViewColumn* tree_column,
                GtkCellRenderer* cell, GtkTreeModel* model,
                GtkTreeIter* iter, gpointer data) {
    unsigned int size;
    gtk_tree_model_get(model, iter, GPOINTER_TO_INT(data), &size, -1);
    g_object_set(G_OBJECT(cell), "text", print_size(&size), NULL);
  }

The column is passed with the parameter 'data'. The values are displayed
fine but sorting no longer is possible. So here are a few questions:

[] As soon as i set the cell data function, the column is not sortable
anymore and the header is neither clickable nor resizeable. Why?
[] The above function uses 'data' to pass the column of the tree model
that is used by the cell renderer. Can i determine this value from
'cell' somehow, so i dont have to pass it explicitly?
[] Is there another simple solution to display filesizes (or other
stuff) that use an INT value from the tree model?

Markus.





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