Sign up

TreeViewColumn.setAttributes() gone AWOL?

Hi Mike,
In the TreeViewColumn wrapper code, I'm seeing two constructors:

  • one that calls gtk_tree_view_column_new(), and
  • another that calls gtk_tree_view_column_new_with_attributes()

From the former, I'm inferring that I would later need to set the attributes, but there doesn't seem to be a way to do that. No function in TreeViewColumn.d calls gtk_tree_view_column_set_attributes(). The only place I can find any mention to this C function is in generated/gtkd/gtk/c/functions.d, but I'm unclear on the purpose of functions.d.

The reason I'm asking is that I'm attempting to add more than one CellRenderer to a single TreeViewColumn (which is mentioned in Foundations of GTK+ Development (2007) p. 272). But without a setAttributes() function, I'm thinking it's not possible. All I can find that's even close is addAttribute() in CellLayoutIF.d and CellLayoutT.d, but I'm assuming that's for adding rather than setting.

Was this functionality (stuffing multiple CellRenderers into a single TreeViewColumn) dropped in GTK 3.0?

Re: TreeViewColumn.setAttributes() gone AWOL?

On 20-04-2019 13:00, Ron Tarrant wrote:

Hi Mike,
In the TreeViewColumn wrapper code, I'm seeing two constructors:

  • one that calls gtk_tree_view_column_new(), and
  • another that calls gtk_tree_view_column_new_with_attributes()

From the former, I'm inferring that I would later need to set the attributes, but there doesn't seem to be a way to do that. No function in TreeViewColumn.d calls gtk_tree_view_column_set_attributes(). The only place I can find any mention to this C function is in generated/gtkd/gtk/c/functions.d, but I'm unclear on the purpose of functions.d.

The reason I'm asking is that I'm attempting to add more than one CellRenderer to a single TreeViewColumn (which is mentioned in Foundations of GTK+ Development (2007) p. 272). But without a setAttributes() function, I'm thinking it's not possible. All I can find that's even close is addAttribute() in CellLayoutIF.d and CellLayoutT.d, but I'm assuming that's for adding rather than setting.

Was this functionality (stuffing multiple CellRenderers into a single TreeViewColumn) dropped in GTK 3.0?

In GTK+ both the GtkTreeViewColumn and the GtkCellLayout have a
addattribute and setattributes functions. And both will call the same
implementation.

In C you would cast your object to the interface to call the functions
that are part of the interface, so defining the same function twice
isn't a issue, and they both have different names as well.

I D / GtkD we implement the CellLayout interface as a actual D
interface, the functions that are part of the interface are mixed in to
the class using a mixin template. This creates a problem for the
TreeViewColumn as the functions are now defined more than once for the
same class. So we purposely skip the functions for the TreeViewColumn as
the ones from the interface will do the same.

The difference between addAttributes and setAttributes is that
addAttributes allows you to set a single attribute, and setAttributes
will allow you to set more than one attribute with a single function call.
Only setAttributes is a variadic function and for now i don't know of a
good way to wrap them automatically, so they will have to be implemented
by hand, and thats why most of them are missing on the GtkD side.

The function definitions in */c/functions.d are there so GtkD can
actually call the GTK functions it's wrapping. Of course you can also
call them yourself if needed.

For a GtkD example of a TreeViewColumn with more that one attribute see:
https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/DemoMultiCellRenderer/DemoMultiCellRenderer.d#L108

Re: TreeViewColumn.setAttributes() gone AWOL?

On Sat, 20 Apr 2019 15:28:29 +0200, Mike Wey wrote:

I D / GtkD we implement the CellLayout interface as a actual D
interface, the functions that are part of the interface are mixed in to
the class using a mixin template. This creates a problem for the
TreeViewColumn as the functions are now defined more than once for the
same class. So we purposely skip the functions for the TreeViewColumn as
the ones from the interface will do the same.

The difference between addAttributes and setAttributes is that
addAttributes allows you to set a single attribute, and setAttributes
will allow you to set more than one attribute with a single function call.
Only setAttributes is a variadic function and for now i don't know of a
good way to wrap them automatically, so they will have to be implemented
by hand, and thats why most of them are missing on the GtkD side.

Ah! That explains it. Just curious... would it not have worked to do something like was done for ListStore with setValue() and set() wherein the latter uses arrays of columns and values? Or is that more a question for the Gnome guys? :)

The function definitions in */c/functions.d are there so GtkD can
actually call the GTK functions it's wrapping. Of course you can also
call them yourself if needed.

Good to know. I was thinking that might be the case, but wasn't feeling brave enough to just jump in.

For a GtkD example of a TreeViewColumn with more that one attribute see:
https://github.com/gtkd-developers/GtkD/blob/master/demos/gtkD/DemoMultiCellRenderer/DemoMultiCellRenderer.d#L108

Excellent! Thank you.