Registering an enum type in GLib’s type system

Gergely Polonkai
Jan 6, 2013 :: 02:34

I faced a problem in my GLib self-teaching project, wMUD today. I wanted to register a signal for a GObject, whose handler should accept two enum parameters for which I had to register a new GEnum type in the GObject type system. However, the documentation on this feature (thanks for pointing out goes to hashem on #gnome-hackers) is not… uhm… obvious. Making the long story short, I have checked with the GIO sources for an example, and using that, I have created this small, working chunk:

Still, it can be made more perfect by using the glib-mkenums tool. I will read through the GLib Makefiles tomorrow for some hints on this.

Edit: you can find the glib-mkenums solution here.

comments powered by Disqus

Gergely Polonkai is a systems engineer of a telco company, and also a freelancer self- and software developer.

He is learning about different IT subjects since the late 1990s. These include web development, application building, systems engineering, IT security and many others. He also dug his nose deeply into free software, dealing with different types of Linux and its applications, while also writing and contributing to some open source projects.

On this site he is writing posts about different stuff he faces during work (oh my, yet another IT solutions blog), hoping they can help others with their job, or just to get along with their brand new netbook that shipped with Linux.

“I believe one can only achieve success if they follow their own instincts and listen to, but not bend under others’ opinions. If you change your course just because someone says so, you are following their instincts, not yours.”