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

Tree_Helpers::ItemList::iterator
Tree_Helpers::ItemList::insert(iterator pos, TreeItem& e)
  {
   if (pos==begin())
     parent_->prepend(e);
   else if (pos==end())
     parent_->append(e);
   else
     parent_->insert(e,parent_->child_position(**pos));
   return --pos;
  };

}

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

namespace Gtk {
Tree_Class Tree::tree_class = {0};

Object* Tree_Class::wrap_new(GtkObject* o)
  {
    Object* cpp=manage(new Tree((GtkTree*)(o)));
    return cpp;
  }

bool Tree::isA( Object *checkcast)
  {
    return GTK_IS_TREE(checkcast->gtkobj());
  }

GtkType Tree::get_type()
  {
    return tree_class.get_type();
  }

GtkType Tree_Class::get_type()
  {
    if (!type)
      {
        CppClassParent::CppObjectType::get_type();
        GtkTypeInfo info =
          {
            "Gtk__Tree",
            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_tree_get_type(), &info);
      }
    return type;
  }

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

void Tree::initialize_class()
  {

     tree_self=this;

  }

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

void Tree_Class::object_init_function(GtkTree *)
  {}

}

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

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

Gtk::Tree_Helpers::ItemList::iterator Gtk::Tree_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::Tree_Helpers::ItemList::glist() const
{ return parent_->gtkobj()->children; }

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

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

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

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

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


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

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

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

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



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

Gtk::Tree::Tree(GtkTree *castitem)
  :     Gtk::Container((GtkContainer*)(castitem))
  {
    initialize_class();
  }

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

void Gtk::Tree::append(Gtk::TreeItem& widget)
  {
    gtk_tree_append(gtkobj(),widget.Widget::gtkobj());
  }

void Gtk::Tree::prepend(Gtk::TreeItem& widget)
  {
    gtk_tree_prepend(gtkobj(),widget.Widget::gtkobj());
  }

void Gtk::Tree::insert(Gtk::TreeItem& widget,gint position)
  {
    gtk_tree_insert(gtkobj(),widget.Widget::gtkobj(),position);
  }

void Gtk::Tree::clear_items(gint start,gint end)
  {
    gtk_tree_clear_items(gtkobj(),start,end);
  }

void Gtk::Tree::select_item(gint item)
  {
    gtk_tree_select_item(gtkobj(),item);
  }

void Gtk::Tree::unselect_item(gint item)
  {
    gtk_tree_unselect_item(gtkobj(),item);
  }

void Gtk::Tree::remove_item(Gtk::TreeItem& child)
  {
    gtk_tree_remove_item(gtkobj(),child.Widget::gtkobj());
  }

gint Gtk::Tree::child_position(Gtk::TreeItem& child) const
  {
    return gtk_tree_child_position(const_cast<GtkTree*>(gtkobj()),child.Widget::gtkobj());
  }

void Gtk::Tree::set_selection_mode(GtkSelectionMode mode)
  {
    gtk_tree_set_selection_mode(gtkobj(),mode);
  }

void Gtk::Tree::set_view_mode(GtkTreeViewMode mode)
  {
    gtk_tree_set_view_mode(gtkobj(),mode);
  }

void Gtk::Tree::set_view_lines(bool flag)
  {
    gtk_tree_set_view_lines(gtkobj(),flag);
  }

void Gtk::Tree_Class::select_child_callback(GtkTree* 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::Tree::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::Tree::Proxy_select_child::connect(const SigC::Slot1<void,Gtk::Widget&> &s)
   {
    return BaseType::connect(SigC::convert(s,&select_child_convert_func));
   }

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

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

void Gtk::Tree_Class::unselect_child_callback(GtkTree* 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::Tree::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::Tree::Proxy_unselect_child::connect(const SigC::Slot1<void,Gtk::Widget&> &s)
   {
    return BaseType::connect(SigC::convert(s,&unselect_child_convert_func));
   }

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

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

void Gtk::Tree_Class::selection_changed_callback(GtkTree* 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::Tree::selection_changed_impl()
  {
    BaseClassType* base=
      static_cast<BaseClassType*>(
        gtk_type_parent_class(gtkobject->klass->type));
    if (base->selection_changed)
      (base->selection_changed)(gtkobj());

  }

guint Gtk::Tree::get_level() const
  { return gtkobj()->level; }
