Re: GtkTreeView comments



James Henstridge <james daa com au> writes:

> On Mon, 11 Jun 2001, Brian Cameron wrote:
> 
> >
> > Gtk Experts:
> >
> > I am now working on the ATK interfaces for the GtkTreeView widget when
> > it is displaying as a GtkListStore.
> >
> > The interface that I am workin on returns the cell value given the
> > row/column table coordinates (of the GtkTreeView, not the coordinates
> > of the GtkTreeModel).
> >
> > I found that there is no easy way to get the GtkTreeModel column number
> > given the GtkTreeView column number.  I found that I had to get the
> > GtkTreeViewColumn structure and dig through its "attributes" to get
> > this information.  It seemed like there should be an access function for
> > returning this information.  Or am I wrong here?
> 
> There isn't a 1-1 mapping between view columns and model columns.  One
> column in the view may depend on many model columns (one giving the text,
> one giving the forground colour, one saying whether to use boldface or
> not, etc).  You can also use one model column as an attribute of multiple
> view columns.
> 
> I suppose that the following prototype would do what you want (this hasn't
> been implemented yet!):
>   gint gtk_tree_view_column_lookup_attribute(GtkTreeViewColumn *column,
>                                              const gchar *attribute);
> 
> With a function like this you could lookup what model column is used to
> calculate the "text" attribute of a column, which seems to be what you
> want.  You may need some special cases for other cell renderers though (eg
> GtkCellRendererToggle).

This actually won't work.  The cellrenderer could be initialized through
use of a GtkTreeCellDataFunc, which means that you basically wouldn't
have any idea how a cell's properties were set.  I think your best bet
is to do something like:

{
...
  gtk_tree_view_column_cell_set_cell_data (tree_column, tree_model, iter);
  cell_renderer = gtk_tree_view_column_get_cell_renderer (tree_column);
  if (GTK_IS_CELL_RENDERER_TEXT (cell_renderer))
    g_object_get (G_OBJECT (cell_renderer), "text", &text, NULL);
...
}

etc....

-Jonathan






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