Re: custom widget with custom property
- From: dexter <dexter balabit hu>
- To: gtkmm-list gnome org
- Subject: Re: custom widget with custom property
- Date: Wed, 26 Aug 2009 14:46:03 +0200
Answering to my question the solution so far is to create my own
property_set callback, and in it:
1. call Glib::wrap to instantiate the class
2. call the original Glib::custom_set_property_callback
----- Original Message -----
From: dexter <dexter balabit hu>
To: gtkmm-list gnome org
Sent: Thu, Aug 13, 2009 10:48:21 AM +0200
Subject: custom widget with custom property
Debugging further it seems that the custom widget is instantiated when
it gets to the </child> tag in this xml:
<object class="gtkmm__CustomObject_bbvbox" id="bbvbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="gtkmm__CustomObject_hbuttonboxstock"
id="hbuttonboxstock1">
<property name="visible">True</property>
<property name="Buttons">add-remove-edit</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
So here is what happens:
1. Gtkbuilder parses the xml file
2. it gets to the property "Buttons" but it cannot set it because the
custom widget "gtkmm__CustomObject_hbuttonboxstock" not yet
instantiated: Glib::ObjectBase::_get_current_wrapper(object) == NULL
3. it gets to the </child> tag, calls gtk_container_add which calls our
own hbuttonboxstock_parent_set(GtkWidget *widget, GtkWidget
*previous_parent) function, which calls wrap_new and that is where the
hbuttonboxstock is instantiated
Somehow the order is wrong. I just don't know yet, how to change the
order or why the C property setting is working and the C++ one is not.
----- Original Message -----
From: dexter <dexter balabit hu>
To: gtkmm-list gnome org
Sent: Wed, Aug 12, 2009 2:43:05 PM +0200
Subject: custom widget with custom property
Hi,
I'm trying to create a custom widget with a custom enum property.
I managed to do that, and it appears in glade, I can choose from the
property values, and it saves it correctly to the .glade file.
(actually it's a gtkbuilder file just with .glade extension.. whatever).
But when I start my program, it sets all the properties correctly from
the .glade file except mine.
Debugging shows, that this function:
void custom_set_property_callback(GObject* object, unsigned int
property_id, const GValue* value, GParamSpec* param_spec) property.cc:121
is called when the property is being set. When it gets to my custom
property, in this line:
if(Glib::ObjectBase *const wrapper =
Glib::ObjectBase::_get_current_wrapper(object)) property.cc:124
Glib::ObjectBase::_get_current_wrapper(object) will return NULL, so it
won't set the property. And as I realized the custom widget is only
instantiated _AFTER_ it tries to set the property (This can be the
main cause of not setting it).
Have you got any idea why is this happening?
Thx,
Balazs
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]