Re: GtkBuildable type resolver



Hi,

I faced similar scenario while writing a tiny gobject code generator. 
I ended up to use similar techinique than your second alternative. It
works nicely in 99% of the cases, but cannot handle cases like:

  GtkIMContext => gtk_i_m_context_get_type != gtk_im_context_get_type

Otherwise this would be a nice way to force everybody to use GObject
naming conventions ;)

But you had a nice idea described in the bug #172535 (to use separate
get_type attribute in the xml). This technique would save the day if
the automatic classname => function mapping failed.

The bad thing is that somebody still needs to know howto turn
"GtkIMContext" (for example) into "gtk_im_context_get_type". UI builders
can detect when they cannot find get_type function with expected name,
but how they actually form the final result? Perhaps the widget catalog
that the UI builders use will contain this information.

Just my 2 cents.

-Markku-

On Mon, 2007-06-04 at 16:04 -0300, Johan Dahlin wrote:
> One of the problems pointed out by Matthias in the GtkBuilder bug[1] is how
> a third-party library can define a type name mapping to get type function.
> 
> First, let me try explain a bit more about the problem;
> 
> Matthias suggested a couple of alternatives, which you can read in comment
> 51[2]:
> 
> - if you play games with __attribute__(constructor),
>   that gets executed before main()
> 
> - if you try to heuristically guess the mapping from type name to get_type()
>   function name, it is going to fail sometimes
> 
> - you could try to dump that mapping into some files somewhere in the
> filesystem
>   and parse those at gtk_init() time - that might be the least evil option
> 
> I went ahead and implemented the second alternative using g_module_symbol),
> that code can be found in this patch[3], inside _gtk_resolve_type_lazily.
> 
> Does anyone have any other suggestions on how to solve the
> problem, or comments on my solution?
> 
> [1]: http://bugzilla.gnome.org/show_bug.cgi?id=172535
> [2]: http://bugzilla.gnome.org/show_bug.cgi?id=172535#c51
> [3]: http://bugzilla.gnome.org/attachment.cgi?id=89349
> 




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