// Generated by gtkmmproc -- DO NOT MODIFY!


#include <libgdamm/referer.h>
#include <libgdamm/private/referer_p.h>

// -*- C++ -*- // this is for the .ccg, I realize gensig puts one in

/* referer.cc
 * 
 * Copyright 2003 libgdamm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <libgdamm/referer.h>
#include <libgdamm/object.h>

namespace Gnome
{

namespace Gda
{

} /* namespace Gda */

} /* namespace Gnome */


namespace
{


static const Glib::SignalProxyInfo Referer_signal_activated_info =
{
  "activated",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


static const Glib::SignalProxyInfo Referer_signal_deactivated_info =
{
  "deactivated",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


} // anonymous namespace


namespace Glib
{

Glib::RefPtr<Gnome::Gda::Referer> wrap(GdaReferer* object, bool take_copy)
{
  return Glib::RefPtr<Gnome::Gda::Referer>( dynamic_cast<Gnome::Gda::Referer*> (Glib::wrap_auto_interface<Gnome::Gda::Referer> ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} // namespace Glib


namespace Gnome
{

namespace Gda
{


/* The *_Class implementation: */

const Glib::Interface_Class& Referer_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Interface_Class has to know the interface init function
    // in order to add interfaces to implementing types.
    class_init_func_ = &Referer_Class::iface_init_function;

    // We can not derive from another interface, and it is not necessary anyway.
    gtype_ = gda_referer_get_type();
  }

  return *this;
}

void Referer_Class::iface_init_function(void* g_iface, void*)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_iface);

  //This is just to avoid an "unused variable" warning when there are no vfuncs or signal handlers to connect.
  //This is a temporary fix until I find out why I can not seem to derive a GtkFileChooser interface. murrayc
  g_assert(klass != 0); 

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
  klass->activated = &activated_callback;
  klass->deactivated = &deactivated_callback;
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED

#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void Referer_Class::activated_callback(GdaReferer* self)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_activated();
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)    );

  // Call the original underlying C function:
  if(base && base->activated)
    (*base->activated)(self);
}
void Referer_Class::deactivated_callback(GdaReferer* self)
{
  Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
      Glib::ObjectBase::_get_current_wrapper((GObject*)self));

  // Non-gtkmmproc-generated custom classes implicitly call the default
  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
  // generated classes can use this optimisation, which avoids the unnecessary
  // parameter conversions if there is no possibility of the virtual function
  // being overridden:
  if(obj_base && obj_base->is_derived_())
  {
    CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
      #endif //GLIBMM_EXCEPTIONS_ENABLED
        // Call the virtual member method, which derived classes might override.
        obj->on_deactivated();
        return;
      #ifdef GLIBMM_EXCEPTIONS_ENABLED
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
      #endif //GLIBMM_EXCEPTIONS_ENABLED
    }
  }
  
  BaseClassType *const base = static_cast<BaseClassType*>(
        g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface.
)    );

  // Call the original underlying C function:
  if(base && base->deactivated)
    (*base->deactivated)(self);
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED


Glib::ObjectBase* Referer_Class::wrap_new(GObject* object)
{
  return new Referer((GdaReferer*)(object));
}


/* The implementation: */

Referer::Referer()
:
  Glib::Interface(referer_class_.init())
{}

Referer::Referer(GdaReferer* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

Referer::Referer(const Glib::Interface_Class& interface_class)
: Glib::Interface(interface_class)
{
}

Referer::~Referer()
{}

// static
void Referer::add_interface(GType gtype_implementer)
{
  referer_class_.init().add_interface(gtype_implementer);
}

Referer::CppClassType Referer::referer_class_; // initialize static member

GType Referer::get_type()
{
  return referer_class_.init().get_type();
}

GType Referer::get_base_type()
{
  return gda_referer_get_type();
}


bool Referer::activate()
{
  return gda_referer_activate(gobj());
}

void Referer::deactivate()
{
gda_referer_deactivate(gobj()); 
}

bool Referer::is_active() const
{
  return gda_referer_is_active(const_cast<GdaReferer*>(gobj()));
}

Glib::SListHandle<Glib::RefPtr<Object> > Referer::get_ref_objects()
{
  return Glib::SListHandle<Glib::RefPtr<Object> >(gda_referer_get_ref_objects(gobj()), Glib::OWNERSHIP_SHALLOW);
}

Glib::SListHandle<Glib::RefPtr<const Object> > Referer::get_ref_objects() const
{
  return Glib::SListHandle<Glib::RefPtr<const Object> >(gda_referer_get_ref_objects(const_cast<GdaReferer*>(gobj())), Glib::OWNERSHIP_SHALLOW);
}


Glib::SignalProxy0< void > Referer::signal_activated()
{
  return Glib::SignalProxy0< void >(this, &Referer_signal_activated_info);
}


Glib::SignalProxy0< void > Referer::signal_deactivated()
{
  return Glib::SignalProxy0< void >(this, &Referer_signal_deactivated_info);
}


#ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
void Gnome::Gda::Referer::on_activated()
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->activated)
    (*base->activated)(gobj());
}
void Gnome::Gda::Referer::on_deactivated()
{
  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface).
g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface.
)  );

  if(base && base->deactivated)
    (*base->deactivated)(gobj());
}
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED

#ifdef GLIBMM_VFUNCS_ENABLED
#endif //GLIBMM_VFUNCS_ENABLED


} // namespace Gda

} // namespace Gnome


