[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [GObject, long] Gtype for enum + runtime init or by init function.
- From: Uzytkownik <uzytkownik2 poczta onet pl>
- To: Tristan Van Berkom <tvb gnome org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: [GObject, long] Gtype for enum + runtime init or by init function.
- Date: Thu, 23 Jun 2005 21:01:13 +0200
Dnia 22-06-2005, Åro o godzinie 18:25 -0400, Tristan Van Berkom
napisaÅ(a):
> Uzytkownik wrote:
>
> Hi,
> You should start off by reading:
>
> http://www.le-hacker.org/papers/gobject/
>
> > 1. In g_param_spec_enum I must have GType of this enum.
> > a) Why this function need it?
>
> Its needed to register metadata about the enum type
> to the type system, furthermore the object will refuse
> invalid values for the said enum.
>
> > b) How create for enum GType?
>
> Copy paste from my code:
>
> =========== header file ===========
> enum GtkTtScrollTypeEnum {
> GTKTT_SCROLL_JUMPY,
> GTKTT_SCROLL_CATCH
> };
>
>
> #define MY_PACKAGE_ENUM_TYPE (my_package_enum_type ())
>
> GType gtktt_scroll_type (void);
>
> ============= source file ==============
> GType
> gtktt_scroll_type (void)
> {
> static GType etype = 0;
> if (etype == 0) {
> static const GEnumValue values[] = {
> { GTKTT_SCROLL_JUMPY, "GTKTT_SCROLL_JUMPY", "jumpy" },
> { GTKTT_SCROLL_CATCH, "GTKTT_SCROLL_CATCH", "catch" },
> { 0, NULL, NULL }
> };
> etype = g_enum_register_static ("GtkTtScrollType", values);
> }
> return etype;
> }
>
Thanks
> > 2. I should register GType in package_name_get_type or
> > package_class_init:
>
> You must register the GType in the _get_type().
> (if the type is not registered, then the type system didnt
> get your GTypeInfo struct holding the pointer to the
> _class_init function).
>
> So, g_object_new (my_package_get_type())
> will construct the object using the information stored
> in the type system which was registered in my_package_get_type()
> the first time it was called.
>
> Cheers,
> -Tristan
>
I know.
I thinking about something else (don't checking in runtime if it is
initialised, but in _init() function caller at begining).
Regards,
--
Linux user: #376500 (patrz http://counter.li.org/)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]