Skip to content

Instantly share code, notes, and snippets.

@mi11y
Created June 15, 2023 03:23
Show Gist options
  • Save mi11y/a2331c8788d4be5d3c79e765d3b4f9d5 to your computer and use it in GitHub Desktop.
Save mi11y/a2331c8788d4be5d3c79e765d3b4f9d5 to your computer and use it in GitHub Desktop.
Is this how I modify Properties with ParamSpecs?
public override (unowned ParamSpec)[] list_properties() {
Type type = typeof (TdLibParameters);
ObjectClass ocl = (ObjectClass) type.class_ref();
Gee.ArrayList<ParamSpec> converted_params = new Gee.ArrayList<ParamSpec>();
foreach (ParamSpec spec in ocl.list_properties()) {
string converted_name = spec.get_name().replace("-", "_");
switch(spec.value_type) {
case Type.BOOLEAN:
ParamSpec converted_spec = new ParamSpecBoolean(
converted_name,
converted_name,
converted_name,
(bool) spec.get_default_value(),
GLib.ParamFlags.READWRITE
);
converted_params.add(converted_spec);
break;
case Type.STRING:
ParamSpec converted_spec = new ParamSpecString(
converted_name,
converted_name,
converted_name,
(string) spec.get_default_value(),
GLib.ParamFlags.READWRITE
);
converted_params.add(converted_spec);
break;
default:
break;
}
}
return converted_params.to_array();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment