On 1 February 2011 00:39, James Morris <jwm.art....@gmail.com> wrote:
> On 31 January 2011 13:32, Jannis Pohlmann <jan...@xfce.org> wrote:
>
>>> Can anyone point me in the direction of code examples where the
>>> construction of the g object requires a parameter so I can see how to
>>> do it please? - I can't make sense of the documentation.
>>
>> I usually do this by adding a construct or construct-only property to
>> the object class and creating a my_object_new() function that takes a
>> parameter for this property that I can then pass to g_object_new().
>>
>> Here's a simple example from Xfce's XDG menu library garcon: GarconMenu
>> is the object and it needs a menu file (a GFile object) to be
>> constructed properly. So what we did is to to install a construct-only
>> property like this:
>>
>>  http://git.xfce.org/libs/garcon/tree/garcon/garcon-menu.c#n246
>
> It looks straight forward at first glance but soon becomes apparent
> it's not at all :/
>
> I want to pass a const char** null terminated list of C strings -
> which is obviously not a G_TYPE_FILE!
> I thought maybe I could use G_TYPE_ARRAY but that results in:
>
> GLib-GObject-CRITICAL **: g_param_spec_object: assertion `g_type_is_a
> (object_type, G_TYPE_OBJECT)' failed
>
> So I've no idea what to do there. It's as clear as mud; I'm a GObject newb.

I've solved it in a way. Have gone back to using a parameter-less
constructor, and a much simplified init function. Instead the code to
generate the widgets is in an 'add' style function in which I do all
the things intended. It works.

Thanks,
James.

-- 
_
: http://jwm-art.net/
-audio/image/text/code/
_______________________________________________
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