// Generated by gmmproc 2.43.3 -- DO NOT MODIFY!


#include <glibmm.h>

#include <gtkmm/colorchooser.h>
#include <gtkmm/private/colorchooser_p.h>


/* Copyright 2012 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <gtk/gtk.h>

namespace Gtk
{

Gdk::RGBA ColorChooser::get_rgba() const
{
  GdkRGBA crgba;
  gtk_color_chooser_get_rgba(const_cast<GtkColorChooser*>(gobj()), &crgba);
  return Glib::wrap(&crgba, true);
}

void ColorChooser::add_palette(Orientation orientation, int colors_per_line, const std::vector<Gdk::RGBA>& colors)
{
  gtk_color_chooser_add_palette(gobj(), (GtkOrientation)orientation, colors_per_line, colors.size(),
    Glib::ArrayHandler<Gdk::RGBA, Gdk::RGBATraits>::vector_to_array(colors).data() );
}

} //namespace Gtk

namespace
{


static void ColorChooser_signal_color_activated_callback(GtkColorChooser* self, const GdkRGBA* p0,void* data)
{
  using namespace Gtk;
  typedef sigc::slot< void,const Gdk::RGBA& > SlotType;

  ColorChooser* obj = dynamic_cast<ColorChooser*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
    #endif //GLIBMM_EXCEPTIONS_ENABLED
      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(Glib::wrap(const_cast<GdkRGBA*>(p0), true)
);
    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED
  }
}

static const Glib::SignalProxyInfo ColorChooser_signal_color_activated_info =
{
  "color-activated",
  (GCallback) &ColorChooser_signal_color_activated_callback,
  (GCallback) &ColorChooser_signal_color_activated_callback
};


} // anonymous namespace


namespace Glib
{

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

} // namespace Glib


namespace Gtk
{


/* The *_Class implementation: */

const Glib::Interface_Class& ColorChooser_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_ = &ColorChooser_Class::iface_init_function;

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

  return *this;
}

void ColorChooser_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); 


  klass->color_activated = &color_activated_callback;
}


void ColorChooser_Class::color_activated_callback(GtkColorChooser* self, const GdkRGBA* p0)
{
  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_color_activated(Glib::wrap(const_cast<GdkRGBA*>(p0), true)
);
        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->color_activated)
    (*base->color_activated)(self, p0);
}


Glib::ObjectBase* ColorChooser_Class::wrap_new(GObject* object)
{
  return new ColorChooser((GtkColorChooser*)(object));
}


/* The implementation: */

ColorChooser::ColorChooser()
:
  Glib::Interface(colorchooser_class_.init())
{}

ColorChooser::ColorChooser(GtkColorChooser* castitem)
:
  Glib::Interface((GObject*)(castitem))
{}

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

ColorChooser::~ColorChooser()
{}

// static
void ColorChooser::add_interface(GType gtype_implementer)
{
  colorchooser_class_.init().add_interface(gtype_implementer);
}

ColorChooser::CppClassType ColorChooser::colorchooser_class_; // initialize static member

GType ColorChooser::get_type()
{
  return colorchooser_class_.init().get_type();
}


GType ColorChooser::get_base_type()
{
  return gtk_color_chooser_get_type();
}


void ColorChooser::set_rgba(const Gdk::RGBA& color)
{
  gtk_color_chooser_set_rgba(gobj(), (color).gobj());
}

bool ColorChooser::get_use_alpha() const
{
  return gtk_color_chooser_get_use_alpha(const_cast<GtkColorChooser*>(gobj()));
}

void ColorChooser::set_use_alpha(bool use_alpha)
{
  gtk_color_chooser_set_use_alpha(gobj(), static_cast<int>(use_alpha));
}


Glib::SignalProxy1< void,const Gdk::RGBA& > ColorChooser::signal_color_activated()
{
  return Glib::SignalProxy1< void,const Gdk::RGBA& >(this, &ColorChooser_signal_color_activated_info);
}


#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy< Gdk::RGBA > ColorChooser::property_rgba() 
{
  return Glib::PropertyProxy< Gdk::RGBA >(this, "rgba");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< Gdk::RGBA > ColorChooser::property_rgba() const
{
  return Glib::PropertyProxy_ReadOnly< Gdk::RGBA >(this, "rgba");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy< bool > ColorChooser::property_use_alpha() 
{
  return Glib::PropertyProxy< bool >(this, "use-alpha");
}
#endif //GLIBMM_PROPERTIES_ENABLED

#ifdef GLIBMM_PROPERTIES_ENABLED
Glib::PropertyProxy_ReadOnly< bool > ColorChooser::property_use_alpha() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "use-alpha");
}
#endif //GLIBMM_PROPERTIES_ENABLED


void Gtk::ColorChooser::on_color_activated(const Gdk::RGBA& color)
{
  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->color_activated)
    (*base->color_activated)(gobj(),(color).gobj());
}


} // namespace Gtk


