// -*- c++ -*-
//  Generated by gtkmmproc from ./../list.gen_h -- DO NOT MODIFY!
#include <gtk--/list.h>
#include <gtk--/private/list_p.h>
namespace Gtk
{

List_Helpers::ItemList::iterator
List_Helpers::ItemList::insert(iterator pos, ListItem& e)
  {
   GList* items=g_list_append(0,e.gtkobj());
   if (pos==begin())
     parent_->prepend_items(items);
   else if (pos==end())
     parent_->append_items(items);
   else
     parent_->insert_items(items,parent_->child_position(**pos));
   return --pos;
  };

}

namespace Gtk {
Gtk::List *wrap (GtkList *o)
  {
    return static_cast<Gtk::List *> (Gtk::wrap_auto ((GtkObject *) (o)));
  }
}

namespace Gtk {
List_Class List::list_class = {0};

Object* List_Class::wrap_new(GtkObject* o)
  {
    Object* cpp=manage(new List((GtkList*)(o)));
    return cpp;
  }

bool List::isA( Object *checkcast)
  {
    return GTK_IS_LIST(checkcast->gtkobj());
  }

GtkType List::get_type()
  {
    return list_class.get_type();
  }

GtkType List_Class::get_type()
  {
    if (!type)
      {
        CppClassParent::CppObjectType::get_type();
        GtkTypeInfo info =
          {
            "Gtk__List",
            sizeof(BaseObjectType),
            sizeof(BaseClassType),
            (GtkClassInitFunc) class_init_function,
            (GtkObjectInitFunc) object_init_function,
            /* reserved_1 */ NULL,
            /* reserved_2 */ NULL,
            /*base_class_init_func */ (GtkClassInitFunc) NULL
          };
        type=gtk_type_unique(gtk_list_get_type(), &info);
      }
    return type;
  }

const char* const List::signal_names[]={
   "selection_changed",
   "select_child",
   "unselect_child",
   0};

void List::initialize_class()
  {

     list_self=this;

  }

void List_Class::class_init_function(GtkListClass *klass)
  {
    CppClassParent::class_init_function((BaseClassParent*)klass);
    klass->selection_changed=selection_changed_callback;
    klass->select_child=select_child_callback;
    klass->unselect_child=unselect_child_callback;
  }

void List_Class::object_init_function(GtkList *)
  {}

}

void Gtk::List_Helpers::ItemList::remove(const_reference child)
{
  g_return_if_fail(child!=0);
  gtk_container_remove(parent_->Container::gtkobj(),
                       (GtkWidget*)(child->gtkobj()));
}

void Gtk::List_Helpers::ItemList::remove(Widget &w)
{
  gtk_container_remove(parent_->Container::gtkobj(),(GtkWidget*)(w.gtkobj()));
}

Gtk::List_Helpers::ItemList::iterator Gtk::List_Helpers::ItemList::erase(iterator position)
{
  if (!position.node||position==end()) return end();
  iterator next=position;
  next++;

  gtk_container_remove(parent_->Container::gtkobj(),
      (GtkWidget*)((*position)->gtkobj()));
  return next;
}

GList*& Gtk::List_Helpers::ItemList::glist() const
{ return parent_->gtkobj()->children; }

Gtk::List_Helpers::ItemList::iterator Gtk::List_Helpers::ItemList::begin_() const
{return iterator(glist(),glist());}

Gtk::List_Helpers::ItemList::iterator Gtk::List_Helpers::ItemList::end_() const
{return iterator(glist(),(GList*)0);}

Gtk::List_Helpers::ItemList::size_type Gtk::List_Helpers::ItemList::size() const
  { return g_list_length(glist()); }

void Gtk::List_Helpers::ItemList::clear()
{ erase(begin(),end()); }

void Gtk::List_Helpers::ItemList::erase(iterator start, iterator stop)
{ while(start != stop) start=erase(start); }


GList*& Gtk::List_Helpers::SelectionList::glist() const
{ return parent_->gtkobj()->selection; }

Gtk::List_Helpers::SelectionList::iterator Gtk::List_Helpers::SelectionList::begin_() const
{return iterator(glist(),glist());}

Gtk::List_Helpers::SelectionList::iterator Gtk::List_Helpers::SelectionList::end_() const
{return iterator(glist(),(GList*)0);}

Gtk::List_Helpers::SelectionList::size_type Gtk::List_Helpers::SelectionList::size() const
  { return g_list_length(glist()); }



Gtk::List::List()
  :     Gtk::Container((GtkContainer*)(gtk_object_new(get_type(),0)))
  {
    initialize_class();
  }

Gtk::List::List(GtkList *castitem)
  :     Gtk::Container((GtkContainer*)(castitem))
  {
    initialize_class();
  }

Gtk::List::~List() { destroy_(); }

void Gtk::List::insert_items(GList* items,gint position)
  {
    gtk_list_insert_items(gtkobj(),items,position);
  }

void Gtk::List::append_items(GList* items)
  {
    gtk_list_append_items(gtkobj(),items);
  }

void Gtk::List::prepend_items(GList* items)
  {
    gtk_list_prepend_items(gtkobj(),items);
  }

void Gtk::List::remove_items(GList* items)
  {
    gtk_list_remove_items(gtkobj(),items);
  }

void Gtk::List::remove_items_no_unref(GList* items)
  {
    gtk_list_remove_items_no_unref(gtkobj(),items);
  }

void Gtk::List::clear_items(gint start,gint end)
  {
    gtk_list_clear_items(gtkobj(),start,end);
  }

void Gtk::List::select_item(gint item)
  {
    gtk_list_select_item(gtkobj(),item);
  }

void Gtk::List::unselect_item(gint item)
  {
    gtk_list_unselect_item(gtkobj(),item);
  }

gint Gtk::List::child_position(Gtk::Widget& child)
  {
    return gtk_list_child_position(gtkobj(),child.gtkobj());
  }

void Gtk::List::set_selection_mode(GtkSelectionMode mode)
  {
    gtk_list_set_selection_mode(gtkobj(),mode);
  }

void Gtk::List_Class::selection_changed_callback(GtkList* o_)
  {
    CppObjectType *obj=
      static_cast<CppObjectType *>(static_cast<Gtk::Object *>(
        gtk_object_get_data_by_id((GtkObject*)o_,Gtk::quark_)));

    if (obj)
      obj->selection_changed_impl();
    else
      {
        BaseClassType* base=
          static_cast<BaseClassType*>(
            gtk_type_parent_class(((GtkObject*)o_)->klass->type));
        if (base->selection_changed)
          (base->selection_changed)(o_);
      }

  }

void Gtk::List::selection_changed_impl()
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->selection_changed)
      (base->selection_changed)(gtkobj());

  }

void Gtk::List_Class::select_child_callback(GtkList* p0,GtkWidget* p1)
  {
    CppObjectType *obj=
      static_cast<CppObjectType *>(static_cast<Gtk::Object *>(
        gtk_object_get_data_by_id((GtkObject*)p0,Gtk::quark_)));

    g_return_if_fail(p1!=0);
    if (obj)
      obj->select_child_impl(*Gtk::wrap(p1));
    else
      {
        BaseClassType* base=
          static_cast<BaseClassType*>(
            gtk_type_parent_class(((GtkObject*)p0)->klass->type));
        if (base->select_child)
          (base->select_child)(p0,p1);
      }

  }

void Gtk::List::select_child_impl(Gtk::Widget& p0)
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->select_child)
      (base->select_child)(gtkobj(),p0.gtkobj());

  }

namespace {
static void select_child_convert_func(SigC::Callback1<void,Gtk::Widget&> *s,GtkWidget* p1)
  {
     s->call(*Gtk::wrap(p1));
  }

}

SigC::Connection
Gtk::List::Proxy_select_child::connect(const SigC::Slot1<void,Gtk::Widget&> &s)
   {
    return BaseType::connect(SigC::convert(s,&select_child_convert_func));
   }

void Gtk::List::Proxy_select_child::operator()(Gtk::Widget& p0)
  {
     BaseType::emit(p0.gtkobj());
  }

void Gtk::List::Proxy_select_child::emit(Gtk::Widget& p0)
  {
     BaseType::emit(p0.gtkobj());
  }

void Gtk::List_Class::unselect_child_callback(GtkList* p0,GtkWidget* p1)
  {
    CppObjectType *obj=
      static_cast<CppObjectType *>(static_cast<Gtk::Object *>(
        gtk_object_get_data_by_id((GtkObject*)p0,Gtk::quark_)));

    g_return_if_fail(p1!=0);
    if (obj)
      obj->unselect_child_impl(*Gtk::wrap(p1));
    else
      {
        BaseClassType* base=
          static_cast<BaseClassType*>(
            gtk_type_parent_class(((GtkObject*)p0)->klass->type));
        if (base->unselect_child)
          (base->unselect_child)(p0,p1);
      }

  }

void Gtk::List::unselect_child_impl(Gtk::Widget& p0)
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->unselect_child)
      (base->unselect_child)(gtkobj(),p0.gtkobj());

  }

namespace {
static void unselect_child_convert_func(SigC::Callback1<void,Gtk::Widget&> *s,GtkWidget* p1)
  {
     s->call(*Gtk::wrap(p1));
  }

}

SigC::Connection
Gtk::List::Proxy_unselect_child::connect(const SigC::Slot1<void,Gtk::Widget&> &s)
   {
    return BaseType::connect(SigC::convert(s,&unselect_child_convert_func));
   }

void Gtk::List::Proxy_unselect_child::operator()(Gtk::Widget& p0)
  {
     BaseType::emit(p0.gtkobj());
  }

void Gtk::List::Proxy_unselect_child::emit(Gtk::Widget& p0)
  {
     BaseType::emit(p0.gtkobj());
  }
