[Vala] Passing a callback function as an argument and connect to activate signal, cannot convert error....



Hi there,

I try to do the following in Vala without much success :

namespace Test {

    public class Popup {

        public void create (Callback action_callback) {

                Gtk.Action action = new Gtk.Action ("", "", "", null);

                action.activate.connect (action_callback);

        }
    }
}


Then :

Test.Popup test = new Test.Popup ();
test.create ((Callback) _test_template);

I get "Cannot convert from GLib.Callback to Gtk.Action.activate", I tried also with (void *), or Gtk.ActionCallback
but I also get compilation errors.

Any idea ?

If I'm doing this, of course it works :

namespace Test {

    public class Popup {

        public void create (Callback action_callback) {

                Gtk.Action action = new Gtk.Action ("", "", "", null);

                action.activate.connect (_test_template);

        }
        private void _test_template (Gtk.Action action) {
        }
    }
}

But I try to add some actions dynamically so I'd like to pass the callback as an argument.

What I'm doing wrong ?

:)

--
Axel FILMORE




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