[RFC] Gtk2::Ex::GladeCustom



Hello All,

Writing custom widgets in Gtk2-perl is easy enough to be useful. What's
missing from the distribution is a way to include such widgets in
GladeXML files. Therefore I suggest a module to simplify this.

To create a glade-aware widget, a statement like:

    package MyNewWidget;

    use Gtk2::Ex::GladeCustom my_new_widget => sub { __PACKAGE__->new(@_); };

should be added to the package implementing the widget. Then it can be
called in several ways from the Glade file:

    * The constructor function can contain either:
        - my_new_widget
            The closure passed will be called. This works if the
            function was registered as above.
        - MyNewWidget::my_new_widget
            Fully qualified function is looked up in the perl namespace.
            No need to register it.
        - MyNewWidget
            A package-name. This will call MyNewWidget->new, if it
            exists.
    * The parameters can be:
        - The first string parameter is in parenthesis:
            Then it's expanded to a parameter list (using eval) and
            passed to the called function.
        - The four parameters -- string1, string2, int1 and int2 are
          passed.

This way if the widget itself is not glade-aware, the application still
can build it. Downside of this is, that once this module is used, custom
widgets implemented in C can no longer be called, because the default
widget-building function is not available (not even for C programs :-(
) to be used as a callback.

I have a code for this module here. I'd like to hear comments to the
interface and comments to it's name (Gtk2::Ex::GladeCustom,
Gtk2::Ex::GladeXML::Custom, Gtk2::GladeXML::Custom, ... other ideas?).

PS: Can I hope to see central distribution for Gtk2::Ex* one day?

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



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