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


#include <glibmm.h>

#include <gtksourceviewmm/completion.h>
#include <gtksourceviewmm/private/completion_p.h>


/* completion.cc
 *
 * Copyright (C) 2009, 2010, 2011 Krzesimir Nowak
 *
 * 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 <gtksourceview/gtksourcecompletion.h>

#include <glibmm/vectorutils.h>

namespace Gsv
{

Glib::RefPtr<CompletionContext>
Completion::create_context()
{
  return Glib::wrap(gtk_source_completion_create_context(gobj(), 0));
}

} // namespace Gsv

namespace
{


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


static void Completion_signal_populate_context_callback(GtkSourceCompletion* self, GtkSourceCompletionContext* p0,void* data)
{
  using namespace Gsv;
  typedef sigc::slot< void,const Glib::RefPtr<CompletionContext>& > SlotType;

  auto obj = dynamic_cast<Completion*>(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))(Glib::wrap(p0, true)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo Completion_signal_populate_context_info =
{
  "populate-context",
  (GCallback) &Completion_signal_populate_context_callback,
  (GCallback) &Completion_signal_populate_context_callback
};


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


} // anonymous namespace


Gsv::SourceCompletionError::SourceCompletionError(Gsv::SourceCompletionError::Code error_code, const Glib::ustring& error_message)
:
  Glib::Error (GTK_SOURCE_COMPLETION_ERROR, error_code, error_message)
{}

Gsv::SourceCompletionError::SourceCompletionError(GError* gobject)
:
  Glib::Error (gobject)
{}

Gsv::SourceCompletionError::Code Gsv::SourceCompletionError::code() const
{
  return static_cast<Code>(Glib::Error::code());
}

void Gsv::SourceCompletionError::throw_func(GError* gobject)
{
  throw Gsv::SourceCompletionError(gobject);
}

// static
GType Glib::Value<Gsv::SourceCompletionError::Code>::value_type()
{
  return gtk_source_completion_error_get_type();
}


namespace Glib
{

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

} /* namespace Glib */


namespace Gsv
{


/* The *_Class implementation: */

const Glib::Class& Completion_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_ = &Completion_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_source_completion_get_type());

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

  }

  return *this;
}


void Completion_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->hide = &hide_callback;
  klass->populate_context = &populate_context_callback;
  klass->show = &show_callback;
}


void Completion_Class::hide_callback(GtkSourceCompletion* 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.
        obj->on_hide();
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->hide)
    (*base->hide)(self);
}
void Completion_Class::populate_context_callback(GtkSourceCompletion* self, GtkSourceCompletionContext* p0)
{
  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.
        obj->on_populate_context(Glib::wrap(p0, true)
);
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->populate_context)
    (*base->populate_context)(self, p0);
}
void Completion_Class::show_callback(GtkSourceCompletion* 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.
        obj->on_show();
        return;
      }
      catch(...)
      {
        Glib::exception_handlers_invoke();
      }
    }
  }

  const auto 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->show)
    (*base->show)(self);
}


Glib::ObjectBase* Completion_Class::wrap_new(GObject* object)
{
  return new Completion((GtkSourceCompletion*)object);
}


/* The implementation: */

GtkSourceCompletion* Completion::gobj_copy()
{
  reference();
  return gobj();
}

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

}

Completion::Completion(GtkSourceCompletion* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


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

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

Completion::~Completion() noexcept
{}


Completion::CppClassType Completion::completion_class_; // initialize static member

GType Completion::get_type()
{
  return completion_class_.init().get_type();
}


GType Completion::get_base_type()
{
  return gtk_source_completion_get_type();
}


bool Completion::add_provider(const Glib::RefPtr<CompletionProvider>& provider)
{
  GError* gerror = nullptr;
  bool retvalue = gtk_source_completion_add_provider(gobj(), Glib::unwrap(provider), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

bool Completion::remove_provider(const Glib::RefPtr<CompletionProvider>& provider)
{
  GError* gerror = nullptr;
  bool retvalue = gtk_source_completion_remove_provider(gobj(), Glib::unwrap(provider), &(gerror));
  if(gerror)
    ::Glib::Error::throw_exception(gerror);
  return retvalue;
}

std::vector<Glib::RefPtr<CompletionProvider> > Completion::get_providers() const
{
  return Glib::ListHandler<Glib::RefPtr<CompletionProvider> >::list_to_vector(gtk_source_completion_get_providers(const_cast<GtkSourceCompletion*>(gobj())), Glib::OWNERSHIP_NONE);
}

bool Completion::show(const std::vector<Glib::RefPtr<CompletionProvider> >& providers, const Glib::RefPtr<CompletionContext>& context)
{
  return gtk_source_completion_show(gobj(), Glib::ListHandler<Glib::RefPtr<CompletionProvider> >::vector_to_list(providers).data(), Glib::unwrap(context));
}

void Completion::hide()
{
  gtk_source_completion_hide(gobj());
}

CompletionInfo* Completion::get_info_window()
{
  return Glib::wrap(gtk_source_completion_get_info_window(gobj()));
}

const CompletionInfo* Completion::get_info_window() const
{
  return const_cast<Completion*>(this)->get_info_window();
}

View* Completion::get_view()
{
  return Glib::wrap(gtk_source_completion_get_view(gobj()));
}

const View* Completion::get_view() const
{
  return const_cast<Completion*>(this)->get_view();
}

Glib::RefPtr<CompletionContext> Completion::create_context(const Gtk::TextIter& position)
{
  return Glib::wrap(gtk_source_completion_create_context(gobj(), const_cast<GtkTextIter*>((position).gobj())));
}

#ifndef GTKSOURCEVIEWMM_DISABLE_DEPRECATED
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
void Completion::move_window(const Gtk::TextIter& iter)
{
  gtk_source_completion_move_window(gobj(), const_cast<GtkTextIter*>((iter).gobj()));
}
G_GNUC_END_IGNORE_DEPRECATIONS
#endif // GTKSOURCEVIEWMM_DISABLE_DEPRECATED

void Completion::block_interactive()
{
  gtk_source_completion_block_interactive(gobj());
}

void Completion::unblock_interactive()
{
  gtk_source_completion_unblock_interactive(gobj());
}


Glib::SignalProxy0< void > Completion::signal_hide()
{
  return Glib::SignalProxy0< void >(this, &Completion_signal_hide_info);
}


Glib::SignalProxy1< void,const Glib::RefPtr<CompletionContext>& > Completion::signal_populate_context()
{
  return Glib::SignalProxy1< void,const Glib::RefPtr<CompletionContext>& >(this, &Completion_signal_populate_context_info);
}


Glib::SignalProxy0< void > Completion::signal_show()
{
  return Glib::SignalProxy0< void >(this, &Completion_signal_show_info);
}


Glib::PropertyProxy< guint > Completion::property_accelerators() 
{
  return Glib::PropertyProxy< guint >(this, "accelerators");
}

Glib::PropertyProxy_ReadOnly< guint > Completion::property_accelerators() const
{
  return Glib::PropertyProxy_ReadOnly< guint >(this, "accelerators");
}

Glib::PropertyProxy< guint > Completion::property_auto_complete_delay() 
{
  return Glib::PropertyProxy< guint >(this, "auto-complete-delay");
}

Glib::PropertyProxy_ReadOnly< guint > Completion::property_auto_complete_delay() const
{
  return Glib::PropertyProxy_ReadOnly< guint >(this, "auto-complete-delay");
}

Glib::PropertyProxy< guint > Completion::property_proposal_page_size() 
{
  return Glib::PropertyProxy< guint >(this, "proposal-page-size");
}

Glib::PropertyProxy_ReadOnly< guint > Completion::property_proposal_page_size() const
{
  return Glib::PropertyProxy_ReadOnly< guint >(this, "proposal-page-size");
}

Glib::PropertyProxy< guint > Completion::property_provider_page_size() 
{
  return Glib::PropertyProxy< guint >(this, "provider-page-size");
}

Glib::PropertyProxy_ReadOnly< guint > Completion::property_provider_page_size() const
{
  return Glib::PropertyProxy_ReadOnly< guint >(this, "provider-page-size");
}

Glib::PropertyProxy< bool > Completion::property_remember_info_visibility() 
{
  return Glib::PropertyProxy< bool >(this, "remember-info-visibility");
}

Glib::PropertyProxy_ReadOnly< bool > Completion::property_remember_info_visibility() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "remember-info-visibility");
}

Glib::PropertyProxy< bool > Completion::property_select_on_show() 
{
  return Glib::PropertyProxy< bool >(this, "select-on-show");
}

Glib::PropertyProxy_ReadOnly< bool > Completion::property_select_on_show() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "select-on-show");
}

Glib::PropertyProxy< bool > Completion::property_show_headers() 
{
  return Glib::PropertyProxy< bool >(this, "show-headers");
}

Glib::PropertyProxy_ReadOnly< bool > Completion::property_show_headers() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "show-headers");
}

Glib::PropertyProxy< bool > Completion::property_show_icons() 
{
  return Glib::PropertyProxy< bool >(this, "show-icons");
}

Glib::PropertyProxy_ReadOnly< bool > Completion::property_show_icons() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "show-icons");
}

Glib::PropertyProxy_ReadOnly< View* > Completion::property_view() const
{
  return Glib::PropertyProxy_ReadOnly< View* >(this, "view");
}


void Gsv::Completion::on_hide()
{
  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->hide)
    (*base->hide)(gobj());
}
void Gsv::Completion::on_populate_context(const Glib::RefPtr<CompletionContext>& context)
{
  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->populate_context)
    (*base->populate_context)(gobj(),Glib::unwrap(context));
}
void Gsv::Completion::on_show()
{
  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->show)
    (*base->show)(gobj());
}


} // namespace Gsv


