[gtkmm] How to derive from Gtk::Toolbar_Helpers::ToggleElem ??



I didn't think this would work when I typed it in, and sure nuf, it don't.  I'm trying to pass arguments to the constructor of my base class (a ToggleElem), but I can't figure out how to pass in the slot (Callback0). 15 lines of code is worth a million words:

class ToolbarMenuElem : public Gtk::Toolbar_Helpers::ToggleElem {
  public:
    ToolbarMenuElem(
      Gtk::Menu * menu_, const Glib::ustring & text, Gtk::Widget & content,
      const Glib::ustring & tooltip_text=Glib::ustring(),
      const Glib::ustring & tooltip_private_text=Glib::ustring());
}

ToolbarMenuElem::ToolbarMenuElem(
  Gtk::Menu * menu_, const Glib::ustring & text, Gtk::Widget & content,
  const Glib::ustring & tooltip_text,
  const Glib::ustring & tooltip_private_text)
  :
  Gtk::Toolbar_Helpers::ToggleElem(text, content, SigC::slot(*this, &ToolbarMenuElem::on_toggled),
    tooltip_text, tooltip_private_text) {

...

}


I'm getting a very odd compiler error that points to header files in SigC++, but I'm pretty sure it comes back to me trying to use *this in the argument list for the base class constructor call.
Questions:

1) Is there any way to accomplish what I'm trying to do?
2) If not, how do I generate a NULL slot to appease compilation? I think I can hook up the the toggled signal after I'm off and running. I tried like hell, but couldn't come up with the magic string of greek C++ to make the compiler happy.
3) When does 'this' come into existence? Shouldn't it be the first argument in the call to ToolbarMenuElem::ToolbarMenuElem(...), and therefore, available for use in the base class constructor call? i.e., at the time of the call to the ToolbarMenuElem constructor, the memory has been allocated and a pointer to it should exist, right?
4) Is this a bug/feature-request for gtk/gtkmm? Am I doing something I shouldn't be trying to do? Gtkmm brags about the ability to derive from Gtk objects. What gives? Maybe we just need a constructor that doesn't require a Callback0. Trust me, I'll hook one up later (if I feel the need)!
5) Why can't anything ever go smoothly :( ?

Much appreciation in advance! I'm at a brick wall here. Work-arounds in my head right now totally defeat the purpose of C++.

Here's the (un-intelligible?) compiler error message:

|| In file included from /usr/include/sigc++-1.2/sigc++/object_slot.h:73:
|| /usr/include/sigc++-1.2/sigc++/object_slot.h: In constructor
||    `SigC::ObjectSlotNode::ObjectSlotNode(void (*)(void*), T*, void*, T2) [with
||    T = ToolbarMenuElem, T2 = void (ToolbarMenuElem::*)()]':
/usr/include/sigc++-1.2/sigc++/slot.h|211| instantiated from `SigC::Slot0<R>::Slot0(SigC::SlotNode*) [with R = void]'
/usr/include/sigc++-1.2/sigc++/object_slot.h|73| instantiated from `SigC::Slot0<R> SigC::slot(O1&, R (O2::*)()) [with R = void, O1 = ToolbarMenuElem, O2 = ToolbarMenuElem]'
ToolbarMenuElem.cc|14| instantiated from here
/usr/include/sigc++-1.2/sigc++/object_slot.h|45| no matching function for call
||    to `SigC::ObjectSlotNode::init(ToolbarMenuElem*&, void*&, void
||    (SigC::Object::*&)())'
/usr/include/sigc++-1.2/sigc++/object_slot.h|46| candidates are: void
||    SigC::ObjectSlotNode::init(SigC::Object*, void*, void (SigC::Object::*)())
|| In file included from /usr/include/sigc++-1.2/sigc++/object_slot.h:187:
|| /usr/include/sigc++-1.2/sigc++/object_slot.h: In constructor
||    `SigC::ObjectSlotNode::ObjectSlotNode(void (*)(void*), T*, void*, T2) [with
||    T = ToolbarMenuElem, T2 = void (ToolbarMenuElem::*)(int&, int&, bool&)]':
/usr/include/sigc++-1.2/sigc++/slot.h|343| instantiated from `SigC::Slot3<R, P1, P2, P3>::Slot3(SigC::SlotNode*) [with R = void, P1 = int&, P2 = int&, P3 = bool&]'
/usr/include/sigc++-1.2/sigc++/object_slot.h|187| instantiated from `SigC::Slot3<R, P1, P2, P3> SigC::slot(O1&, R (O2::*)(P1, P2, P3)) [with R = void, P1 = int&, P2 = int&, P3 = bool&, O1 = ToolbarMenuElem, O2 = ToolbarMenuElem]'
ToolbarMenuElem.cc|28| instantiated from here
/usr/include/sigc++-1.2/sigc++/object_slot.h|45| no matching function for call
||    to `SigC::ObjectSlotNode::init(ToolbarMenuElem*&, void*&, void
||    (SigC::Object::*&)())'
/usr/include/sigc++-1.2/sigc++/object_slot.h|46| candidates are: void
||    SigC::ObjectSlotNode::init(SigC::Object*, void*, void (SigC::Object::*)())
|| make: *** [ToolbarMenuElem.o] Error 1



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