[Vala] Genie syntax for connect



Hi Phil,

Correct code is:
[indent=4]

uses
    Gtk

init
    Gtk.init (ref args)
    var test = new TestWindow ()
    test.show_all ()
    Gtk.main ()

class TestWindow : Window
    slider: HScale
    spin_box : SpinButton
    init
        title = "Test Window"
        default_height = 20
        default_width = 300
        window_position = WindowPosition.CENTER
        destroy.connect(Gtk.main_quit)
        spin_box = new SpinButton.with_range (0, 130, 1)
        spin_box.value = 35
        slider = new HScale.with_range (0, 130, 1)
        spin_box.value_changed.connect(spinbox_value)
        slider.value_changed.connect (slider_value)
        var hbox = new HBox (true, 5)
        var button = new Button.with_label("Exit")
        button.clicked.connect(Gtk.main_quit)
        hbox.add (spin_box)
        hbox.add (slider)
        hbox.add (button)
        add (hbox)

    def slider_value()
        spin_box.set_value(slider.get_value())

    def spinbox_value()
        slider.set_value(spin_box.get_value())

I also update the "[Genie] Synchronizing Widgets" in code.valaide.org
See you,
Nicolas.




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