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


#include <glibmm.h>

#include <gtkmm/listbox.h>
#include <gtkmm/private/listbox_p.h>


/* Copyright (C) 2013 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>
#include <gtkmm/adjustment.h>

namespace
{

gboolean SignalProxy_Filter_gtk_callback(GtkListBoxRow* row, void* data)
{
  auto the_slot = static_cast<Gtk::ListBox::SlotFilter*>(data);

  try
  {
    return (*the_slot)(Glib::wrap(row));
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
    return FALSE;
  }
}

void SignalProxy_Filter_gtk_callback_destroy(void* data)
{
  delete static_cast<Gtk::ListBox::SlotFilter*>(data);
}

int SignalProxy_Sort_gtk_callback(GtkListBoxRow* row1, GtkListBoxRow* row2, void* data)
{
  auto the_slot = static_cast<Gtk::ListBox::SlotSort*>(data);

  try
  {
    return (*the_slot)(Glib::wrap(row1), Glib::wrap(row2));
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
    return 0;
  }
}

void SignalProxy_Sort_gtk_callback_destroy(void* data)
{
  delete static_cast<Gtk::ListBox::SlotSort*>(data);
}

void SignalProxy_UpdateHeader_gtk_callback(GtkListBoxRow* row, GtkListBoxRow* before, void* data)
{
  auto the_slot = static_cast<Gtk::ListBox::SlotUpdateHeader*>(data);

  try
  {
    (*the_slot)(Glib::wrap(row), Glib::wrap(before));
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }
}

void SignalProxy_UpdateHeader_gtk_callback_destroy(void* data)
{
  delete static_cast<Gtk::ListBox::SlotUpdateHeader*>(data);
}


static void proxy_foreach_callback(GtkListBox* /* list_box */, GtkListBoxRow* row, void* data)
{
  typedef Gtk::ListBox::SlotForeach SlotType;
  auto& slot = *static_cast<SlotType*>(data);

  try
  {
    slot(Glib::wrap(row, true));
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }
}

static GtkWidget* proxy_bind_model_create_widget_callback(void* item, void* data)
{
  auto& slot = *static_cast<Gtk::ListBox::SlotCreateWidget<Glib::Object>*>(data);
  auto cobject = static_cast<GObject*>(item);

  try
  {
    // take_copy is true here, because wrap() returns a Glib::RefPtr<Glib::Object>.
    // cobject will be unreferenced when the RefPtr is deleted.
    Gtk::Widget* widget = slot(Glib::wrap(cobject, true));
    if (widget)
      return widget->gobj();
  }
  catch(...)
  {
    Glib::exception_handlers_invoke();
  }
  return nullptr;
}

} // anonymous namespace

namespace Gtk
{

void ListBox::unselect_row()
{
  gtk_list_box_select_row(gobj(), nullptr);
}

void ListBox::unset_placeholder()
{
  gtk_list_box_set_placeholder(gobj(), nullptr);
}

void ListBox::set_filter_func(const SlotFilter& slot)
{
  // Create a copy of the slot object. A pointer to this will be passed
  // through the callback's data parameter. It will be deleted
  // when SignalProxy_Filter_gtk_callback_destroy() is called.
  auto slot_copy = new SlotFilter(slot);

  gtk_list_box_set_filter_func(gobj(),
    &SignalProxy_Filter_gtk_callback, slot_copy,
    &SignalProxy_Filter_gtk_callback_destroy);
}

void ListBox::unset_filter_func()
{
  gtk_list_box_set_filter_func(gobj(), nullptr, nullptr, nullptr);
}

void ListBox::set_sort_func(const SlotSort& slot)
{
  // Create a copy of the slot object. A pointer to this will be passed
  // through the callback's data parameter. It will be deleted
  // when SignalProxy_Sort_gtk_callback_destroy() is called.
  auto slot_copy = new SlotSort(slot);

  gtk_list_box_set_sort_func(gobj(),
    &SignalProxy_Sort_gtk_callback, slot_copy,
    &SignalProxy_Sort_gtk_callback_destroy);
}

void ListBox::unset_sort_func()
{
  gtk_list_box_set_sort_func(gobj(), nullptr, nullptr, nullptr);
}

void ListBox::set_header_func(const SlotUpdateHeader& slot)
{
  // Create a copy of the slot object. A pointer to this will be passed
  // through the callback's data parameter. It will be deleted
  // when SignalProxy_Sort_gtk_callback_destroy() is called.
  auto slot_copy = new SlotUpdateHeader(slot);

  gtk_list_box_set_header_func(gobj(),
    &SignalProxy_UpdateHeader_gtk_callback, slot_copy,
    &SignalProxy_UpdateHeader_gtk_callback_destroy);
}

void ListBox::unset_header_func()
{
  gtk_list_box_set_header_func(gobj(), nullptr, nullptr, nullptr);
}

void ListBox::selected_foreach(const SlotForeach& slot)
{
  SlotForeach slot_copy(slot); //TODO: Is this necessary?
  gtk_list_box_selected_foreach(gobj(), &proxy_foreach_callback, &slot_copy);
}

void ListBox::bind_model(const Glib::RefPtr<Gio::ListModel>& model,
  const SlotCreateWidget<Glib::Object>& slot_create_widget)
{
  // Create a copy of the slot.
  // It will be deleted by Glib::destroy_notify_delete<SlotCreateWidget>.
  auto slot_copy = new SlotCreateWidget<Glib::Object>(slot_create_widget);

  gtk_list_box_bind_model(gobj(), Glib::unwrap(model), &proxy_bind_model_create_widget_callback,
    slot_copy, &Glib::destroy_notify_delete<SlotCreateWidget<Glib::Object>>);
}

} //namespace Gtk

namespace
{


static void ListBox_signal_row_selected_callback(GtkListBox* self, GtkListBoxRow* p0,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(ListBoxRow*)>;

  auto obj = dynamic_cast<ListBox*>(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)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo ListBox_signal_row_selected_info =
{
  "row-selected",
  (GCallback) &ListBox_signal_row_selected_callback,
  (GCallback) &ListBox_signal_row_selected_callback
};


static void ListBox_signal_row_activated_callback(GtkListBox* self, GtkListBoxRow* p0,void* data)
{
  using namespace Gtk;
  using SlotType = sigc::slot<void(ListBoxRow*)>;

  auto obj = dynamic_cast<ListBox*>(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)
);
    }
    catch(...)
    {
       Glib::exception_handlers_invoke();
    }
  }
}

static const Glib::SignalProxyInfo ListBox_signal_row_activated_info =
{
  "row-activated",
  (GCallback) &ListBox_signal_row_activated_callback,
  (GCallback) &ListBox_signal_row_activated_callback
};


static const Glib::SignalProxyInfo ListBox_signal_selected_rows_changed_info =
{
  "selected-rows-changed",
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback,
  (GCallback) &Glib::SignalProxyNormal::slot0_void_callback
};


} // anonymous namespace


namespace Glib
{

Gtk::ListBox* wrap(GtkListBox* object, bool take_copy)
{
  return dynamic_cast<Gtk::ListBox *> (Glib::wrap_auto ((GObject*)(object), take_copy));
}

} /* namespace Glib */

namespace Gtk
{


/* The *_Class implementation: */

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

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

  }

  return *this;
}


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


}


Glib::ObjectBase* ListBox_Class::wrap_new(GObject* o)
{
  return manage(new ListBox((GtkListBox*)(o)));

}


/* The implementation: */

ListBox::ListBox(const Glib::ConstructParams& construct_params)
:
  Gtk::Widget(construct_params)
{
  }

ListBox::ListBox(GtkListBox* castitem)
:
  Gtk::Widget((GtkWidget*)(castitem))
{
  }


ListBox::ListBox(ListBox&& src) noexcept
: Gtk::Widget(std::move(src))
{}

ListBox& ListBox::operator=(ListBox&& src) noexcept
{
  Gtk::Widget::operator=(std::move(src));
  return *this;
}

ListBox::~ListBox() noexcept
{
  destroy_();
}

ListBox::CppClassType ListBox::listbox_class_; // initialize static member

GType ListBox::get_type()
{
  return listbox_class_.init().get_type();
}


GType ListBox::get_base_type()
{
  return gtk_list_box_get_type();
}


ListBox::ListBox()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(nullptr),
  Gtk::Widget(Glib::ConstructParams(listbox_class_.init()))
{
  

}

void ListBox::prepend(Widget& child)
{
  gtk_list_box_prepend(gobj(), (child).gobj());
}

void ListBox::append(Widget& child)
{
  gtk_list_box_append(gobj(), (child).gobj());
}

void ListBox::insert(Widget& child, int position)
{
  gtk_list_box_insert(gobj(), (child).gobj(), position);
}

void ListBox::remove(Widget& child)
{
  gtk_list_box_remove(gobj(), (child).gobj());
}

ListBoxRow* ListBox::get_selected_row()
{
  return Glib::wrap(gtk_list_box_get_selected_row(gobj()));
}

const ListBoxRow* ListBox::get_selected_row() const
{
  return const_cast<ListBox*>(this)->get_selected_row();
}

ListBoxRow* ListBox::get_row_at_index(int index)
{
  return Glib::wrap(gtk_list_box_get_row_at_index(gobj(), index));
}

const ListBoxRow* ListBox::get_row_at_index(int index) const
{
  return const_cast<ListBox*>(this)->get_row_at_index(index);
}

ListBoxRow* ListBox::get_row_at_y(int y)
{
  return Glib::wrap(gtk_list_box_get_row_at_y(gobj(), y));
}

const ListBoxRow* ListBox::get_row_at_y(int y) const
{
  return const_cast<ListBox*>(this)->get_row_at_y(y);
}

void ListBox::select_row(ListBoxRow& row)
{
  gtk_list_box_select_row(gobj(), (row).gobj());
}

void ListBox::set_placeholder(Widget& placeholder)
{
  gtk_list_box_set_placeholder(gobj(), (placeholder).gobj());
}

void ListBox::set_adjustment(const Glib::RefPtr<Adjustment>& adjustment)
{
  gtk_list_box_set_adjustment(gobj(), Glib::unwrap(adjustment));
}

Glib::RefPtr<Adjustment> ListBox::get_adjustment()
{
  auto retvalue = Glib::wrap(gtk_list_box_get_adjustment(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

Glib::RefPtr<const Adjustment> ListBox::get_adjustment() const
{
  return const_cast<ListBox*>(this)->get_adjustment();
}

std::vector<ListBoxRow*> ListBox::get_selected_rows()
{
  return Glib::ListHandler<ListBoxRow*>::list_to_vector(gtk_list_box_get_selected_rows(gobj()), Glib::OWNERSHIP_SHALLOW);
}

std::vector<ListBoxRow*> ListBox::get_selected_rows() const
{
  return Glib::ListHandler<ListBoxRow*>::list_to_vector(gtk_list_box_get_selected_rows(const_cast<GtkListBox*>(gobj())), Glib::OWNERSHIP_SHALLOW);
}

void ListBox::unselect_row(ListBoxRow* row)
{
  gtk_list_box_unselect_row(gobj(), (GtkListBoxRow*)Glib::unwrap(row));
}

void ListBox::select_all()
{
  gtk_list_box_select_all(gobj());
}

void ListBox::unselect_all()
{
  gtk_list_box_unselect_all(gobj());
}

void ListBox::set_selection_mode(SelectionMode mode)
{
  gtk_list_box_set_selection_mode(gobj(), static_cast<GtkSelectionMode>(mode));
}

SelectionMode ListBox::get_selection_mode() const
{
  return static_cast<SelectionMode>(gtk_list_box_get_selection_mode(const_cast<GtkListBox*>(gobj())));
}

void ListBox::invalidate_filter()
{
  gtk_list_box_invalidate_filter(gobj());
}

void ListBox::invalidate_sort()
{
  gtk_list_box_invalidate_sort(gobj());
}

void ListBox::invalidate_headers()
{
  gtk_list_box_invalidate_headers(gobj());
}

void ListBox::set_activate_on_single_click(bool single)
{
  gtk_list_box_set_activate_on_single_click(gobj(), static_cast<int>(single));
}

bool ListBox::get_activate_on_single_click() const
{
  return gtk_list_box_get_activate_on_single_click(const_cast<GtkListBox*>(gobj()));
}

void ListBox::drag_unhighlight_row()
{
  gtk_list_box_drag_unhighlight_row(gobj());
}

void ListBox::drag_highlight_row(ListBoxRow& row)
{
  gtk_list_box_drag_highlight_row(gobj(), (row).gobj());
}

void ListBox::set_show_separators(bool show_separators)
{
  gtk_list_box_set_show_separators(gobj(), static_cast<int>(show_separators));
}

bool ListBox::get_show_separators() const
{
  return gtk_list_box_get_show_separators(const_cast<GtkListBox*>(gobj()));
}


Glib::SignalProxy<void(ListBoxRow*)> ListBox::signal_row_selected()
{
  return Glib::SignalProxy<void(ListBoxRow*) >(this, &ListBox_signal_row_selected_info);
}


Glib::SignalProxy<void(ListBoxRow*)> ListBox::signal_row_activated()
{
  return Glib::SignalProxy<void(ListBoxRow*) >(this, &ListBox_signal_row_activated_info);
}


Glib::SignalProxy<void()> ListBox::signal_selected_rows_changed()
{
  return Glib::SignalProxy<void() >(this, &ListBox_signal_selected_rows_changed_info);
}


static_assert(Glib::Traits::ValueCompatibleWithWrapProperty<SelectionMode>::value,
  "Type SelectionMode cannot be used in _WRAP_PROPERTY. "
  "There is no suitable template specialization of Glib::Value<>.");

Glib::PropertyProxy< SelectionMode > ListBox::property_selection_mode() 
{
  return Glib::PropertyProxy< SelectionMode >(this, "selection-mode");
}

Glib::PropertyProxy_ReadOnly< SelectionMode > ListBox::property_selection_mode() const
{
  return Glib::PropertyProxy_ReadOnly< SelectionMode >(this, "selection-mode");
}

Glib::PropertyProxy< bool > ListBox::property_activate_on_single_click() 
{
  return Glib::PropertyProxy< bool >(this, "activate-on-single-click");
}

Glib::PropertyProxy_ReadOnly< bool > ListBox::property_activate_on_single_click() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "activate-on-single-click");
}

Glib::PropertyProxy< bool > ListBox::property_accept_unpaired_release() 
{
  return Glib::PropertyProxy< bool >(this, "accept-unpaired-release");
}

Glib::PropertyProxy_ReadOnly< bool > ListBox::property_accept_unpaired_release() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "accept-unpaired-release");
}

Glib::PropertyProxy< bool > ListBox::property_show_separators() 
{
  return Glib::PropertyProxy< bool >(this, "show-separators");
}

Glib::PropertyProxy_ReadOnly< bool > ListBox::property_show_separators() const
{
  return Glib::PropertyProxy_ReadOnly< bool >(this, "show-separators");
}


} // namespace Gtk


