[gtkmm] Slots from non-Gtk subclasses.



Hello,

  I have a class that isn't derived from any Gtk classes.  It does,
however, have member functions that will pop up Gtk windows, and
member functions that will handle callbacks from those windows.

  The problem is that the "SigC::slot(class, &member)" function seems
to require a class who's derived from Gtk.  I can't get the class to
compile unless I force my class to be a subclass of a Gtk class.

  My question is: How do I get this class to compile?  Is subclassing
"Gtk::Base" the safe/smart/insane thing to do?

  Below is a tiny, (non-functional), pedantic example.

  Any insight would be appreciated.

  This is attached to an existing project which uses Gtkmm 1.2.8.  I can't
switch to Gtkmm 2.0.

				      Dale
					dwiles buffalo veridian com

SHELL> g++ -DWORK -g -Wall `gtkmm-config --cflags` -c -o foo.o foo.cc
  ** All is well **

SHELL> g++ -g -Wall `gtkmm-config --cflags` -c -o foo.o foo.cc

  /usr/include/sigc++-1.0/sigc++/object_slot.h: In function `static struct SigC::SlotData * SigC::ObjectSlot0_<void,doesnt>::create(doesnt *, void (doesnt::*)())':
  /usr/include/sigc++-1.0/sigc++/object_slot.h:121:   instantiated from `SigC::slot<void, doesnt, doesnt>(doesnt *const &, void (doesnt::*)())'
foo.cc:18:   instantiated from here
  /usr/include/sigc++-1.0/sigc++/object_slot.h:67: no matching function for call to `doesnt::register_data (SigC::ScopeNode *)'

---------------------------------foo.cc--------------------------------------
#include <gtk--/button.h>

#ifdef WORK
// Compiles
class compiles : public Gtk::Base {
public:
  void butt() {
    Gtk::Button *button_remove = manage(new Gtk::Button("Works"));
    button_remove->clicked.connect(SigC::slot(this, &compiles::butt));
  }
};
#else
// Doesn't compile
class doesnt {
public:
  void butt() {
    Gtk::Button *button_remove = manage(new Gtk::Button("Nope"));
    button_remove->clicked.connect(SigC::slot(this, &doesnt::butt));
  }
};
#endif

int
main(int argc, char *argv[])
{
  return 0;
}

Attachment: pgp0zxCpBUEfV.pgp
Description: PGP signature



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