[Vala] signal cascade blocking in Gtk+



Hi all,

I just started learning Vala and I must say this project is great. :)

Today I started testing Gtk+ module and I came across a misbehaviour. I
am slowly reading mailing list archives (just hit March 2007) and till
now I can't find a reference to my bug.

I am trying to open a window after clicking on a button, then closing it
with close-button and then reopening it.
This is the code:

using GLib;
using Gtk;

public class MyWin : Gtk.Window
{
        public TwoWin win2;

        construct
        {
                this.title = "Window title";
                this.prepare();
        }

        public void prepare()
        {

                this.win2 = new TwoWin();

                this.destroy += Gtk.main_quit;

                var button = new Button.with_label("Open");
                button.clicked += btn => {
                        this.win2.show();
                };

                this.add(button);
        }
}

public class TwoWin : Gtk.Window
{
        construct
        {
                this.title = "Second window title";
                this.prepare();
        }

        private bool nascondi(Gtk.Widget w)
        {
                this.hide();
                return false;
        }

        public void prepare()
        {
                this.destroy += this.nascondi;

                var button = new Button.with_label("Ciao mondo");
                button.show();

                button.clicked += btn => {
                        this.title = btn.label;
                };

                this.add(button);
        }
}


public class Test : GLib.Object
{
        public static int main(string[] args)
        {
                Gtk.init(out args);

                var mywin = new MyWin();
                mywin.show_all();

                Gtk.main();

                return 0;
        }
}

The problem is that when I re-open the second window (TwoWin) clicking
on the button on the first window, it comes up empty. It seems like the
"return false" in the callback doesn't block signal passing, and it
destroys the second window.

I don't understand if it is a bug in my code or in vala code generation.
I'm using valac 0.1.5.

Thank you very much.
Bye.





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