Index: libglade/src/xml.hg
===================================================================
--- libglade/src/xml.hg	(revision 2071)
+++ libglade/src/xml.hg	(working copy)
@@ -44,6 +44,116 @@
 };
 
 
+#define _STR(x) #x
+#define STR(x) _STR(x)
+#define GLADEMM_SLOT(n, s) __register_slot(STR(s), &n::s)
+#define GLADEMM_DECLARE_SLOTS(...) \
+virtual void __init_slots(void) \
+{ \
+    __VA_ARGS__; \
+}
+
+class NoSlotException : public Glib::Exception
+{
+public:
+  NoSlotException(const Glib::ustring& name) { str = name; }
+  virtual ~NoSlotException(void) throw() {}
+  virtual Glib::ustring what() const
+  {
+    return str;
+  }
+
+protected:
+  Glib::ustring str;
+};
+
+class Slots : public Glib::Object
+{
+public:
+
+  virtual ~Slots(void)
+  {
+    for (std::map<Glib::ustring, sigc::slot_base*>::iterator it =
+	    slot_map.begin(); it != slot_map.end(); it++) {
+	delete it->second;
+    }
+    slot_map.clear();
+  }
+
+  template <class T_class>
+  void get_slot(const Glib::ustring name, T_class *slotret)
+  {
+    if (slot_map.empty())
+	__init_slots();
+    std::map<Glib::ustring, sigc::slot_base*>::iterator it =
+	    slot_map.find(name);
+    if (it == slot_map.end())
+	throw NoSlotException(name);
+    T_class *sl = dynamic_cast<T_class*>(it->second);
+    if (!sl)
+	throw Glib::Error(g_quark_from_static_string("wrong_handler_type"), 0,
+		"Wrong handler type");
+    *slotret = *sl;
+  }
+
+protected:
+  virtual void __init_slots(void) = 0;
+  template <typename T_ret, class T_class>
+  void __register_slot(const Glib::ustring& name,
+	T_ret(T_class::*handler)(void))
+  {
+    T_class *self = dynamic_cast<T_class*>(this);
+    g_assert(self);
+    slot_map[name] = new sigc::slot<T_ret>(sigc::mem_fun(*self, handler));
+  }
+  template <typename T_ret, class T_class, typename T_arg>
+  void __register_slot(const Glib::ustring& name,
+	T_ret(T_class::*handler)(T_arg))
+  {
+    T_class *self = dynamic_cast<T_class*>(this);
+    g_assert(self);
+    slot_map[name] = new sigc::slot<T_ret, T_arg>(sigc::mem_fun(*self, handler));
+  }
+  std::map<Glib::ustring, sigc::slot_base*> slot_map;
+};
+
+/* getter templates, for convenience */
+class get_slot_void
+{
+public:
+  get_slot_void(Slots& slots_)
+  {
+    slots = &slots_;
+  }
+  sigc::slot<void> operator()(const Glib::ustring& name)
+  {
+    sigc::slot<void> slot;
+    slots->get_slot(name, &slot);
+    return slot;
+  }
+
+private:
+  Slots *slots;
+};
+template <typename T_ret, typename T_arg>
+class get_slot
+{
+public:
+  get_slot(Slots& slots_)
+  {
+    slots = &slots_;
+  }
+  sigc::slot<T_ret, T_arg> operator()(const Glib::ustring& name)
+  {
+    sigc::slot<T_ret, T_arg> slot;
+    slots->get_slot(name, &slot);
+    return slot;
+  }
+
+private:
+  Slots *slots;
+};
+
 class Xml : public Glib::Object
 {
   _CLASS_GOBJECT(Xml, GladeXML, GLADE_XML, Glib::Object, GObject)
Index: examples/basic/basic.cc
===================================================================
--- examples/basic/basic.cc	(revision 2071)
+++ examples/basic/basic.cc	(working copy)
@@ -4,15 +4,31 @@
 
 Gtk::Dialog* pDialog = 0;
 
+class MySlots : public Gnome::Glade::Slots
+{
+private:
+GLADEMM_DECLARE_SLOTS(
+  GLADEMM_SLOT(MySlots, on_button_clicked),
+  GLADEMM_SLOT(MySlots, test_slot)
+);
+
 void on_button_clicked()
 {
   if(pDialog)
     pDialog->hide(); //hide() will cause main::run() to end.
 }
 
+void test_slot(const Glib::ustring& msg)
+{
+  std::cout << msg << std::endl;
+}
+
+};
+
 int main (int argc, char **argv)
 {
   Gtk::Main kit(argc, argv);
+  MySlots slots;
 
   //Load the Glade file and instiate its widgets:
   Glib::RefPtr<Gnome::Glade::Xml> refXml;
@@ -37,18 +53,15 @@
 #endif
 
   //Get the Glade-instantiated Dialog:
-  
   refXml->get_widget("DialogBasic", pDialog);
   if(pDialog)
   {
-    //Get the Glade-instantiated Button, and connect a signal handler:
-    Gtk::Button* pButton = 0;
-    refXml->get_widget("quit_button", pButton);
-    if(pButton)
-    {
-      pButton->signal_clicked().connect( sigc::ptr_fun(on_button_clicked) );
-    }
+    refXml->connect_clicked("quit_button",
+	    Gnome::Glade::get_slot_void(slots)("on_button_clicked"));
 
+    (Gnome::Glade::get_slot<void, const Glib::ustring&>
+	(slots)("test_slot"))("Works!!!");
+
     kit.run(*pDialog);
   }
 
