Re: g_object_new



Hi,

Am Dienstag, den 08.12.2009, 11:12 +0000 schrieb Andy Chambers:
> I'm working on one of the lisp bindings to gtk and from reading the
> docs, it looks like we should
> be able to construct instances of all gtk types using just
> g_object_new.  Is that correct in
> principle?
> 
> If that is true, I need a way to get a GType dynamically.  The
> function g_type_from_name looks
> like it might do the job but I think the type needs to have been
> initialized by creating an
> instance first.  Is there any other way to initialize a type so that I
> don't have to create an instance?
> (since that's what I'm trying to avoid by using g_object_new).

Yes, there is. Just call the appropriate get_type() function for the
type and you're done. GTK+ has lots of macros like GTK_TYPE_LABEL which
expand to gtk_label_get_type(). And if you plan to hardcode a type to
some code passage in your bindings, you're advised to use GTK_TYPE_LABEL
in favor of the slower g_type_from_name("GtkLabel").

Kind regards,
  Sven Herzberg

--
www.lanedo.com -- the GTK+ experts



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]