Re: [glade--] glademm auto-connect feature?



On Wed, 2006-02-22 at 20:29 +0100, Markus wrote:
> I don't use the code generation of glade.

We thought that you did because you used the glademm mailing list.
glademm does code generation.

I've changed this email thread to the gtkmm-list, which is relevant for
libglademm.

> But libglade doesn't offers a auto connect feature for C++

I have generally not bothered with this, because there's no way for you
to specify in Glade what object the signal handler should be a member
method of. However, see below.

>  like it did for
> C,

It's simpler in C because there are no classes in C, so the signal
handler can only be a global function. That also makes it quite useless,
because any signal handler also needs state information about other
instances.

And, of course, if the signal handler takes different parameters than
the signal provides then you get interesting crashes.

>  C#

I looked at an example that did this recently. I think the equivalent in
C++ would look something like this:

Something::example_thing()
{
...
  Gtk::Dialog* pDialog = 0;
  refXml->get_widget("DialogBasic", pDialog);

  refXml->autoconnect(*this); //Doesn't exist yet.
...
}

So, if you had specified on_ok_clicked() as the signal handler for the 
clicked signal of an OK button, then it would look for a 
Something::on_ok_clicked() method and connect it with the this instance. 
That would be equivalent to doing
  button_ok->signal_clicked().connect(sigc::mem_fun(*this, &Something::on_something_clicked));

However, the autoconnect() method would need to know, or discover, what
C++ parameters the signal handler takes and know how to convert from the
C types to the C++ types. And back again, if there is a return type or
output parameters (rare).

I don't know how they deal with this in Gtk#, but I am generally not
impressed with the Gtk# API and I suspect that the autoconnect system is
not as reliable or useful as it is presented to be.

We also have the problem that it's probably very difficult to introspect
member methods and call them dynamically. But maybe it's possible with
the Glib::Module stuff. Anyone is free to try.

>  and Java. At least i couldn't find it.

I don't know what this does, but maybe it's similar to Gtk#. It would be
worth looking at pygtk too.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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