13
0
livetrax/libs/gtkmm2/gtk/src/treestore.ccg
Paul Davis 449aab3c46 rollback to 3428, before the mysterious removal of libs/* at 3431/3432
git-svn-id: svn://localhost/ardour2/branches/3.0@3435 d708f5d6-7413-0410-9779-e7cbd77b26cf
2008-06-02 21:41:35 +00:00

141 lines
3.7 KiB
C++

// -*- c++ -*-
/* $Id: treestore.ccg,v 1.3 2004/04/03 12:53:49 murrayc Exp $ */
/* Copyright 1998-2002 The gtkmm Development Team
*
* 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 <gtk/gtktreestore.h>
namespace Gtk
{
TreeStore::TreeStore(const TreeModelColumnRecord& columns)
:
_CONSTRUCT()
{
gtk_tree_store_set_column_types(gobj(), columns.size(), const_cast<GType*>(columns.types()));
}
void TreeStore::set_column_types(const TreeModelColumnRecord& columns)
{
gtk_tree_store_set_column_types(gobj(), columns.size(), const_cast<GType*>(columns.types()));
}
TreeModel::iterator TreeStore::erase(const iterator& iter)
{
g_assert(iter.get_gobject_if_not_end() != 0);
iterator next (iter);
++next;
GtkTreeIter tmp = *iter.gobj();
gtk_tree_store_remove(gobj(), &tmp);
return next;
}
TreeModel::iterator TreeStore::insert(const iterator& iter)
{
iterator new_pos (this);
gtk_tree_store_insert_before(
gobj(), new_pos.gobj(),
const_cast<GtkTreeIter*>(iter.get_parent_gobject_if_end()),
const_cast<GtkTreeIter*>(iter.get_gobject_if_not_end()));
if(new_pos.gobj()->stamp == 0)
new_pos.setup_end_iterator(iter);
return new_pos;
}
TreeModel::iterator TreeStore::insert_after(const iterator& iter)
{
iterator new_pos (this);
gtk_tree_store_insert_after(
gobj(), new_pos.gobj(),
const_cast<GtkTreeIter*>(iter.get_parent_gobject_if_end()),
const_cast<GtkTreeIter*>(iter.get_gobject_if_not_end()));
if(new_pos.gobj()->stamp == 0)
new_pos.setup_end_iterator(iter);
return new_pos;
}
TreeModel::iterator TreeStore::prepend()
{
iterator new_pos (this);
gtk_tree_store_prepend(gobj(), new_pos.gobj(), 0);
return new_pos;
}
TreeModel::iterator TreeStore::prepend(const TreeNodeChildren& node)
{
iterator new_pos (this);
gtk_tree_store_prepend(
gobj(), new_pos.gobj(),
const_cast<GtkTreeIter*>(node.get_parent_gobject()));
return new_pos;
}
TreeModel::iterator TreeStore::append()
{
iterator new_pos (this);
gtk_tree_store_append(gobj(), new_pos.gobj(), 0);
return new_pos;
}
TreeModel::iterator TreeStore::append(const TreeNodeChildren& node)
{
iterator new_pos (this);
gtk_tree_store_append(
gobj(), new_pos.gobj(),
const_cast<GtkTreeIter*>(node.get_parent_gobject()));
return new_pos;
}
void TreeStore::move(const iterator& source, const iterator& destination)
{
gtk_tree_store_move_before(gobj(),
const_cast<GtkTreeIter*>(source.get_gobject_if_not_end()),
const_cast<GtkTreeIter*>(destination.get_gobject_if_not_end()));
}
void TreeStore::reorder(const TreeNodeChildren& node, const Glib::ArrayHandle<int>& new_order)
{
gtk_tree_store_reorder(gobj(),
const_cast<GtkTreeIter*>(node.get_parent_gobject()),
const_cast<int*>(new_order.data()));
}
void TreeStore::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value)
{
gtk_tree_store_set_value(
gobj(), const_cast<GtkTreeIter*>(row.gobj()),
column, const_cast<GValue*>(value.gobj()));
}
} // namespace Gtk