Created
June 15, 2023 03:23
-
-
Save mi11y/a2331c8788d4be5d3c79e765d3b4f9d5 to your computer and use it in GitHub Desktop.
Is this how I modify Properties with ParamSpecs?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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