[Vala] Gtk keybindings cannot be bound to Vala signals: G_SIGNAL_ACTION-flag missing



Hey!

The long version of the following code compiles (with valac 0.7.10) and
runs, but doesn't behave like intended:

--- simplified code ---
public class TestClass : Gtk.Window {
        public signal void action_enter_signal ();

        private string keybindings = 
        """ 
        binding "TestClassBinding"
        {
                bind "<Control>c" {
                        "action_enter_signal" () }
        }
        
        class "TestClass" binding "TestClassBaseBinding"
        """;

        TestClass()
        {
            action_enter_signal.connect((source) => printf("<Control>c
has been pressed\n"));  
            Gtk.rc_parse_string(this.keybindings);
        }
}
--- end simplified code ---

Pressing <Control>c gives the following error:
Gtk-WARNING **: gtk_binding_entry_activate(): binding
"TestClassBaseBinding::<Control>c": signal "action_enter_signal" in the
`TestClass' class ancestry cannot be used for action emissions

A little search brought up the following fact:
http://faq.pygtk.org/index.py?req=show&file=faq06.002.htp
It seems like the G_SIGNAL_ACTION-flag has to be set to for the signals
to use with Gtk keybindings.
This currently seems not to be possible within Vala.

There are two bugs open who address the problem how signals could be
enhanced:
https://bugzilla.gnome.org/show_bug.cgi?id=571685
https://bugzilla.gnome.org/show_bug.cgi?id=577623

However, they seem to be pending for some time now.

This is a real pain, since I would really like to enhance my program
with keybindings that don't necessarily connect to a (clicked-, ..)
signal of existing widgets.
Is there some way around this problem until the patches land? Have I
missed some GLib functionality that can be applied to the Vala signals?

Best regards,

Julius



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