[Vala] Action signals



Hello everyone,

I'm still playing around with Vala and GTK+, and trying to port my little
application to this language.

Today I experimented with key bindings, but I encountered a problem I'm not
able to solve. The following code

    using GLib;
    class BindingTest : Gtk.Window {

        public signal void do_something ();

        public BindingTest () {}
        construct {

            title = "Binding Test";
            set_default_size (200, 150);

            Gtk.Label label = new Gtk.Label ("Control-d does something.");
            add (label);

            delete_event += Gtk.main_quit;
            do_something += () => { stdout.printf ("Done something.\n"); };
        }

        public static int main (string[] args) {

            Gtk.init (ref args);
            Gtk.rc_parse_string ("binding \"Test\" {" +
                                 "  bind \"<control>d\" {" +
                                 "    \"do_something\" ()" +
                                 "  }" +
                                 "}" +
                                 "class \"BindingTest\" binding \"Test\"");

            BindingTest window = new BindingTest ();
            window.show_all ();

            Gtk.main ();
            return 0;
        }
    }

compiles and runs perfectly, but when I press Control-d I get the following
warning message,

    (bindingtest:9485): Gtk-WARNING **: gtk_binding_entry_activate():
    binding "TestBinding::<Control>d": signal "do_something" in the
    `BindingTest' class ancestry cannot be used for action emissions

which is caused by the fact that the do_something signal is not declared
as an action signal (G_SIGNAL_ACTION) in the generated C file, and as such
GTK+ refuses to emit it directly.

Is there any way to declare a signal as an action signal? I grep'd a bit
around the valac source code but I couldn't find anything.

-- 
KiyuKo <eof AT kiyuko DOT org>
Resistance is futile, you will be garbage collected.

Attachment: pgphfhwh6SVFP.pgp
Description: PGP signature



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