Re: [Vala] Can not connect Gtk.Action to a function



I also tried the following to connect the activate signal to sample_func:

  test.activate.connect (sample_func);

And the old syntax:

  test.activate += sample_func;

But nothing happens in both when I click testitem in the menubar.
Is it possible that activate signal couldn't be emitted on click?
Or should sample_func have an special defenition?
How could i test that the signal is really emitted?

On Wed, Feb 3, 2010 at 5:04 PM, Rodrigo Cares <rcares gmail com> wrote:

hi, you will try some like this:
...
test.activate.connect (sample_func);
...

2010/2/3 Hadi Aminzadeh <hadi60 gmail com>

I'm using vala 0.7.9 and have got stuck in using menuitem signals.
Here is a sample code I wrote:


 var actiongroup = new Gtk.ActionGroup("MainActions");

 Gtk.MenuItem menuitem = new Gtk.MenuItem.with_mnemonic("_Actions");
 Gtk.Menu actionmenu = new Gtk.Menu();
 Gtk.Action test = new Gtk.Action ("Test", "Test", null, null);
 actiongroup.add_action (test);
 test.activate.connect ((source) => {
      sample_func();
 });

 Gtk.MenuItem testitem = (Gtk.MenuItem) factoraction.create_menu_item();
 actionmenu.append(testitem);
 menuitem.set_submenu(actionmenu);
 menubar.append (menuitem);

 ....

 public void sample_func()
 {
     debug ("sample function executed");
 }


I the above piece of code i have created an action and try to connect its
menuitem to a function.
After compilation I can see the menu item in the form, but my_function
doesn't print anything in the teminal.
Any suggestion?

_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




--
Rodrigo Esteban Cares Guarda
Alumno Ingeniería Civil Informática
Universidad Austral de Chile
2º GUP Taekwondo WTF
Fono: (09) 98364117



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