Re: Binding run-time data
- From: Armin Burgmeier <armin arbur net>
- To: Germán Diago <germandiago gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Binding run-time data
- Date: Sat, 19 May 2007 13:36:04 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Germán Diago wrote:
> Hello. I'm using gtkmm to make a little program.
>
> The program has some entries and a button.
>
> When the button is clicked, I'd like to get the data inside the entries.
>
> So I'd like my on_button_clicked slot to be like this:
>
> void on_button_clicked(int data1, int data2);
>
> If I use bind, the data is bound at compile-time, so I can't. I don't want
> to use Gtk::Entry * as arguments, because I want the slots to be
> independent of the gui toolkit.
> Any help here? Thanks.
You can use sigc::compose() which is like sigc::bind() but takes a
functor to call instead of static data. It would look like this
(assuming your entries are actually SpinButtons because your
on_button_clicked function takes integers as arguments):
button.signal_clicked().connect(
sigc::compose(
sigc::ptr_fun(&on_button_clicked),
sigc::mem_fun(entry1, &Gtk::SpinButton::get_value_as_int),
sigc::mem_fun(entry2, &Gtk::SpinButton::get_value_as_int)
)
);
Greetings,
Armin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGTuEkhOtxKlDYm6cRAuf8AJ0ekd8Vy2EymA4wkL6Ke/gVPJfIFgCgsQ3E
SWXmfqSE1lgr9afe856YrsE=
=MNbD
-----END PGP SIGNATURE-----
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]