libglade custom properties

Hi Jacob,

Sorry for not getting round to going over your patch earlier. I ended up with a slightly different API to your suggestion. The API in CVS now is:

typedef void (* GladeApplyCustomPropFunc)(GladeXML *xml,
                                         GtkWidget *widget,
                                         const gchar *propname,
                                         const gchar *value);

void glade_register_custom_prop(GType type,
                               const gchar *prop_name,
                               GladeApplyCustomPropFunc apply_prop);

Any properties registered with this function are not handled as standard GObject properties in glade_standard_build_widget, but instead the the given handler gets called. The apply_prop function gets called after the widget has been constructed. Handlers registered for a particular GType applies to all subtypes.

Note that this API addition is a "semi public" API -- a normal app wouldn't use it, but a library implementing libglade support may need it.

As an example of its use, I added the following code to glade-gtk.c, so that tooltips work in libglade again:

static void
set_tooltip(GladeXML *xml, GtkWidget *widget,
       const gchar *prop_name, const gchar *prop_value)
   gtk_tooltips_set_tip(xml->priv->tooltips, widget, prop_value, NULL);

   glade_register_custom_prop (GTK_TYPE_WIDGET, "tooltip", set_tooltip);

I will probably use this to fix up the "visible" property handling (which really needs to be applied after adding all children in order to get correct behaviour with some widgets).

Does this API cover what you needed? Again, sorry for being a bit unresponsive about your patch.


Email: james daa com au

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