Blob Blame History Raw
// Generated by gmmproc 2.54.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);
}

gint 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::append(Widget& child)
{
  insert(child, -1);
}

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


  klass->row_selected = &row_selected_callback;
  klass->row_activated = &row_activated_callback;
}


void ListBox_Class::row_selected_callback(GtkListBox* self, GtkListBoxRow* 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_row_selected(Glib::wrap(p0)
);
        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->row_selected)
    (*base->row_selected)(self, p0);
}
void ListBox_Class::row_activated_callback(GtkListBox* self, GtkListBoxRow* 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_row_activated(Glib::wrap(p0)
);
        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->row_activated)
    (*base->row_activated)(self, p0);
}


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

}


/* The implementation: */

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

ListBox::ListBox(GtkListBox* castitem)
:
  Gtk::Container((GtkContainer*)(castitem))
{
  }


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

ListBox& ListBox::operator=(ListBox&& src) noexcept
{
  Gtk::Container::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::Container(Glib::ConstructParams(listbox_class_.init()))
{
  

}

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

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

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()
{
  Glib::RefPtr<Adjustment> 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(), ((GtkSelectionMode)(mode)));
}

SelectionMode ListBox::get_selection_mode() const
{
  return ((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());
}


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);
}


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");
}


void Gtk::ListBox::on_row_selected(ListBoxRow* row)
{
  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->row_selected)
    (*base->row_selected)(gobj(),(GtkListBoxRow*)Glib::unwrap(row));
}
void Gtk::ListBox::on_row_activated(ListBoxRow* row)
{
  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->row_activated)
    (*base->row_activated)(gobj(),(GtkListBoxRow*)Glib::unwrap(row));
}


} // namespace Gtk