gtk.gdk.color_parse() equivalent in vala
I'm trying to find an equivalent to the pyGtk function gtk.gdk.color_parse
in Vala. All I can find is Gdk.Color.parse
which is sort of similar, but returns a boolean instead of a Gdk.Color structure.开发者_运维知识库 It seems like I should be able to find the equivalent to the Python function, but I don't seem to be able to.
No, that's the one - it gives you the color as an "out parameter" instead of return value. Python doesn't have out parameters (well, Python has any feature if you try hard enough...) The boolean return value tells whether the parsing succeeded. PyGTK probably raises an exception if it doesn't.
Use it like this:
Gdk.Color fuchsia;
if (!Gdk.Color.parse("fuchsia", out fuchsia))
print("There was an error parsing, I must have spelled fuchsia wrong");
精彩评论