Emmanuele,

> In order to do that, you should use `g_type_ensure()` inside the
instance initialization function of the parent's widget class

Since using Vala, from what I can see in case of using [GtkTemplate]
the g_type_ensure is generated, but when just subclassing a GtkWidget
it doesn't exists in the generated .c, am I right ?

And what I can do to g_type_ensure be present in generated .c in the
second case ?

Thanks.

2015-10-04 10:40 GMT-03:00 Emmanuele Bassi <eba...@gmail.com>:
> Hi;
>
> On 3 October 2015 at 02:14, Victor Aurélio Santos
> <victoraur.san...@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]



-- 
Victor Aurélio Santos
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to