Re: Template Widgets inside another GtkBuilder file



Hi;

On 3 October 2015 at 02:14, Victor Aurélio Santos
<victoraur santos gmail com> wrote:
How can I do that ?
Just build all together results in this warning:

(ajami:3475): Gtk-CRITICAL **: Error building template class 'AjamiMainWindow' for an instance of type 
'AjamiMainWindow': Invalid object type 'HVMeter' on line 2

I've asked on SO[1] and got only one answer.

I stick at "_get_type" workaround/hack but I didn't like it and I
can't do the same thing in Vala (I've not found how to do the same
thing).

More details can be found on SO question.

So, what I really want to know is what is the best option to
accomplish this in Vala and in C too.

[1]: http://stackoverflow.com/questions/24235937/custom-gtk-widget-with-template-ui

If you have an internal, private widget that you use as a child in a
template, you'll need to ensure that the type system knows about the
child widget's type before initializing the template that references
it.

In order to do that, you should use `g_type_ensure()` inside the
instance initialization function of the parent's widget class, right
before calling `gtk_widget_init_template()`; for instance:

  g_type_ensure (hv_meter_get_type ());

This is also what GTK+ itself does:
https://git.gnome.org/browse/gtk+/tree/gtk/gtkfilechooserwidget.c#n8598

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[ ] ebassi [ gmail com]


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