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


#include <glibmm.h>

#include <gtkmm/filter.h>
#include <gtkmm/private/filter_p.h>


/* Copyright (C) 2020 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, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>

using Change = Gtk::Filter::Change;
using Match = Gtk::Filter::Match;

namespace
{


static void Filter_signal_changed_callback(GtkFilter* self, GtkFilterChange p0,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(Change)>;

  auto obj = dynamic_cast<Filter*>(Glib::ObjectBase::_get_current_wrapper((GObject*) self));
  // Do not try to call a signal on a disassociated wrapper.
  if(obj)
  {
    try
    {
      if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data))
        (*static_cast<SlotType*>(slot))(static_cast<Change>(p0)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo Filter_signal_changed_info =
{
  "changed",
  (GCallback) &Filter_signal_changed_callback,
  (GCallback) &Filter_signal_changed_callback
};


} // anonymous namespace

// static
GType Glib::Value<Gtk::Filter::Match>::value_type()
{
  return gtk_filter_match_get_type();
}

// static
GType Glib::Value<Gtk::Filter::Change>::value_type()
{
  return gtk_filter_change_get_type();
}


namespace Glib
{

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

} /* namespace Glib */


namespace Gtk
{


/* The *_Class implementation: */

const Glib::Class& Filter_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &Filter_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(gtk_filter_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void Filter_Class::class_init_function(void* g_class, void* class_data)
{
  const auto klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);

  klass->match = &match_vfunc_callback;
  klass->get_strictness = &get_strictness_vfunc_callback;

}

gboolean Filter_Class::match_vfunc_callback(GtkFilter* self, gpointer item)
{
  const auto 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_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        return static_cast<int>(obj->match_vfunc(Glib::wrap(G_OBJECT(item), true)
));
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->match)
    return (*base->match)(self, item);

  using RType = gboolean;
  return RType();
}
GtkFilterMatch Filter_Class::get_strictness_vfunc_callback(GtkFilter* self)
{
  const auto 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_())
  {
    const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
    if(obj) // This can be NULL during destruction.
    {
      try // Trap C++ exceptions which would normally be lost because this is a C callback.
      {
        // Call the virtual member method, which derived classes might override.
        return static_cast<GtkFilterMatch>(obj->get_strictness_vfunc());
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  BaseClassType *const base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
  );

  // Call the original underlying C function:
  if(base && base->get_strictness)
    return (*base->get_strictness)(self);

  using RType = GtkFilterMatch;
  return RType();
}


Glib::ObjectBase* Filter_Class::wrap_new(GObject* object)
{
  return new Filter((GtkFilter*)object);
}


/* The implementation: */

GtkFilter* Filter::gobj_copy()
{
  reference();
  return gobj();
}

Filter::Filter(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

Filter::Filter(GtkFilter* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


Filter::Filter(Filter&& src) noexcept
: Glib::Object(std::move(src))
{}

Filter& Filter::operator=(Filter&& src) noexcept
{
  Glib::Object::operator=(std::move(src));
  return *this;
}


Filter::~Filter() noexcept
{}


Filter::CppClassType Filter::filter_class_; // initialize static member

GType Filter::get_type()
{
  return filter_class_.init().get_type();
}


GType Filter::get_base_type()
{
  return gtk_filter_get_type();
}


Filter::Filter()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Glib::Object(Glib::ConstructParams(filter_class_.init()))
{
  

}

bool Filter::match(const Glib::RefPtr<Glib::ObjectBase>& item)
{
  return gtk_filter_match(gobj(), (item)->gobj());
}

Match Filter::get_strictness()
{
  return static_cast<Match>(gtk_filter_get_strictness(gobj()));
}

void Filter::changed(Change change)
{
  gtk_filter_changed(gobj(), static_cast<GtkFilterChange>(change));
}


Glib::SignalProxy<void(Change)> Filter::signal_changed()
{
  return Glib::SignalProxy<void(Change) >(this, &Filter_signal_changed_info);
}


bool Gtk::Filter::match_vfunc(const Glib::RefPtr<Glib::ObjectBase>& item) 
{
  const auto base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->match)
  {
    bool retval((*base->match)(gobj(),(item)->gobj()));
    return retval;
  }

  using RType = bool;
  return RType();
}
Match Gtk::Filter::get_strictness_vfunc() 
{
  const auto base = static_cast<BaseClassType*>(
      g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class).
  );

  if(base && base->get_strictness)
  {
    Match retval(static_cast<Match>((*base->get_strictness)(gobj())));
    return retval;
  }

  using RType = Match;
  return RType();
}


} // namespace Gtk


