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/)
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to