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



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?


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