[Vala] MX Stylable / Gtk install_style_property



Hi all,

I'm trying to find out how I can subclass an mx widget and add to the
stylable properties. It seems that to do so requires declaring a specific
new kind of property in C, and unfortunately only in C. After some more
investigation (due to lack of experience) I find that the pattern they have
used was probably copied from Gtk, where there is a clear distinction
between object properties and style properties.

So, in gtk_widget_class_init I find code blocks like:
    gtk_widget_class_install_style_property (klass,
                                           g_param_spec_int
("scroll-arrow-hlength",
                                                             P_("Horizontal
Scroll Arrow Length"),
                                                             P_("The length
of horizontal scroll arrows"),
                                                             1, G_MAXINT,
16,

 GTK_PARAM_READABLE));

And in mx_stylable_iface_init I find code blocks like:
      pspec = clutter_param_spec_color ("background-color",
                                        "Background Color",
                                        "The background color of an actor",
                                        &bg_color,
                                        G_PARAM_READWRITE);
      mx_stylable_iface_install_property (iface, MX_TYPE_BUTTON, pspec);

In both cases there is no explicitly declared getter/setter or field to
store the value. It's all handled by the UI framework, so it's purely a
declaration.


So, my question is this: How does one subclass either an Mx Widget or a Gtk
Widget and declare new style properties in Vala?

My approach would either be to:
  1. Have language support, and detect the UI toolkit being extended. The
code gen can then emit the additional class setup method.
  2. Have a new attribute that we can use to mark a static class method as
being a part of the class init for gobject. Then it's possible to
programatically declare the new properties. This has the benefit that it's
not toolkit specific.

Or am I missing something?

-- 
Michael Brown


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