Re: [gtkmm] Gtk::entry set_position() problem and workaround



Paul Davis wrote:

We cannot figure out how to fassion a 'Glib::signal_idle().connect' statement where we can pass the entry widget, the set_position method and the position parameter so we don't have to use global variables and our helper 'sp' function. I would love to improve our workaround.

    #include <sigc++/bind.h>

    class Object {
        ...
	 gint method (Gtk::Widget*, sometype_t pos);
	 ...
    }

    using namespace SigC;

  signal_idle().connect (bind (slot (*objectptr, &Object::method),
                               w, pos));

Awesome,

Your example didn't quite work because signal_idle().connect wants a function that returns a bool, but it triggered something in my brain that led me to the solution that I was looking for!!! Thank you! Here it is:

void set_position (Gtk::Entry * w, int n)
{
   Glib::signal_idle().connect
       (SigC::bind_return
           (SigC::bind<int>
               (SigC::slot (*w, &Gtk::Entry::set_position), n), false));
}

Wow! A 'connect' with nested binds. And it works just the way you would expect it to.

Thanks again,

Jeff






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