gergelypolonkai-web-jekyll/_posts/2013-01-06-registering-an-enum-type-in-glib-s-type-system.markdown
2016-02-26 16:26:26 +01:00

1.4 KiB
Raw Blame History

layout title date tags permalink published author
post Registering an enum type in GLibs type system 2013-01-06 02:34:03
c
development
glib
/blog/2013/1/6/registering-an-enum-type-in-glib-s-type-system true
name email
Gergely Polonkai gergely@polonkai.eu

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:

{% gist gergelypolonkai/47794b6fb94484f8160b client-state.h %}

{% gist gergelypolonkai/47794b6fb94484f8160b client-state.c %}

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]({% post_url 2014-08-16-registering-an-enum-type-in-glib-glib-mkenums-magic %}).