On Mon, 3 Jun 2019 22:46:49 +0200, Mike Wey wrote:

On 03-06-2019 01:45, Alex X wrote:

There are many getXXX methods in gtkD that simply get a specific type.

Obviously with D it can all be simplified.

I imagine it wouldn't be too hard to add a method

E.g., if KeyFile

public double getDouble(string groupName, string key)
public string getComment(string groupName, string key)
public bool[] getBooleanList(string groupName, string key)
public bool getBoolean(string groupName, string key)
...

I imagine a single get(T, K)(string groupName, K key)

can be used and it could just map to all the others...

There is a relatively straight forward conversion between so it might be possible to write a generic get routine that dispatches by using a direct mapping.

Comment -> string,
Boolean -> bool,
List -> [],

etc...

Just do some CT reflection on the class or create mapping table. Should be relatively simple and would provide a singular routine.

If it's generic enough it could just be template mixed in to any class and it would automatically figure out the mapping.

There is ObjectG.getProperty but being a simple wrapper around the GTK
version it's not easy to use.

Value val;
obj.getProperty("key", val);
val.get!Widget();

Could this then not be wrapped? I guess I could wrap it myself.