On Wed, Sep 12, 2012 at 2:28 AM, Jonas Kulla <[email protected]> wrote:
> 2012/9/11 "Luis L. Rodríguez Oro" <[email protected]>
>
>> Hi all, please help me.
...
>
> in Clas2, then pass the "this" reference when you create your main_window
> object.
> Then you can call any public method on it from Clas2.
>

or if you don't want any reference of the main_window class inside the
class2 (loosing coupling) you can use a signal to implement a sort of
observer pattern [1].

class Clas2 {
    public signal void update_interface (args...);

    private void method2 (args...) {
        update_interface (args....);
    }
}

and on the main_window class you subscribe to the signal and then call method2:

class main_window:... {
    public Clas2 cl;

    public main_window () {
        cl = new Clas2 ();
        cl.update_interface.connect ((args...) => { method1 (); })
    }

    public void method1 () {
       ....
    }
}

HTH,
Andrea

[1] http://en.wikipedia.org/wiki/Observer_pattern
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to