---------- Forwarded message ----------
From: Hadi Aminzadeh <[email protected]>
Date: Thu, Feb 4, 2010 at 11:01 AM
Subject: Re: [Vala] Can not connect Gtk.Action to a function
To: Nor Jaidi Tuah <[email protected]>
Sorry, It was a typo in pasting the code in my email.
But the problem still exists with the code below:
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) test.create_menu_item();
actionmenu.append(testitem);
menuitem.set_submenu(actionmenu);
menubar.append (menuitem);
....
public void sample_func()
{
debug ("sample function executed");
}
I also used these lines to connect signals to sample_func, but it made no
difference:
test.activate.connect (sample_func);
And:
test.activate += sample_func;
On Thu, Feb 4, 2010 at 10:06 AM, Nor Jaidi Tuah <[email protected]>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");
> > >> }
>
> Could this be the elusive bug?
> Gtk.MenuItem testitem = (Gtk.MenuItem) factoraction.create_menu_item();
>
> i.e. you visual doesn't correspond to your internal.
>
> hand
> Nor Jaidi Tuah
>
>
> _______________________________________________
> Vala-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/vala-list
>
_______________________________________________
Vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list