Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / liststore.cc
1 // Generated by gtkmmproc -- DO NOT MODIFY!
2
3
4 #include <gtkmm/liststore.h>
5 #include <gtkmm/private/liststore_p.h>
6
7 // -*- c++ -*-
8 /* $Id$ */
9
10 /* Copyright 1998-2002 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <gtk/gtkliststore.h>
28
29
30 namespace Gtk
31 {
32
33 ListStore::ListStore(const TreeModelColumnRecord& columns)
34 :
35   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
36   Glib::ObjectBase(0),
37   Glib::Object(Glib::ConstructParams(liststore_class_.init()))
38 {
39   gtk_list_store_set_column_types(gobj(), columns.size(), const_cast<GType*>(columns.types()));
40 }
41
42 void ListStore::set_column_types(const TreeModelColumnRecord& columns)
43 {
44    gtk_list_store_set_column_types(gobj(), columns.size(), const_cast<GType*>(columns.types()));
45 }
46   
47
48 TreeModel::iterator ListStore::erase(const iterator& iter)
49 {
50   g_assert(iter.get_gobject_if_not_end() != 0);
51
52   iterator next(iter);
53   ++next;
54
55   GtkTreeIter tmp = *iter.gobj();
56   gtk_list_store_remove(gobj(), &tmp);
57
58   return next;
59 }
60
61 TreeModel::iterator ListStore::insert(const iterator& iter)
62 {
63   iterator new_pos(this);
64
65   // get_gobject_if_not_end() returns 0 if iter is an end iterator, which
66   // is in turn interpreted by gtk_list_store_insert_before() as a request to
67   // insert at the end of the list.
68
69   gtk_list_store_insert_before(
70       gobj(), new_pos.gobj(),
71       const_cast<GtkTreeIter*>(iter.get_gobject_if_not_end()));
72
73   // GtkTreeIter::stamp should always have a value if it's valid.
74   // For end iterators, we need to remember the iter's parent, and
75   // this is what setup_end_iterator() does.
76
77   if(new_pos.gobj()->stamp == 0)
78     new_pos.setup_end_iterator(iter);
79
80   return new_pos;
81 }
82
83 TreeModel::iterator ListStore::insert_after(const iterator& iter)
84 {
85   iterator new_pos(this);
86
87   // get_gobject_if_not_end() returns 0 if iter is an end iterator, which
88   // is in turn interpreted by gtk_list_store_insert_after() as a request to
89   // insert at the beginning of the list.
90
91   gtk_list_store_insert_after(
92       gobj(), new_pos.gobj(),
93       const_cast<GtkTreeIter*>(iter.get_gobject_if_not_end()));
94
95   // GtkTreeIter::stamp should always have a value if it's valid.
96   // For end iterators, we need to remember the iter's parent, and
97   // this is what setup_end_iterator() does.
98
99   if(new_pos.gobj()->stamp == 0)
100     new_pos.setup_end_iterator(iter);
101
102   return new_pos;
103 }
104
105 TreeModel::iterator ListStore::prepend()
106 {
107   iterator new_pos(this);
108   gtk_list_store_prepend(gobj(), new_pos.gobj());
109   return new_pos;
110 }
111
112 TreeModel::iterator ListStore::append()
113 {
114   iterator new_pos(this);
115   gtk_list_store_append(gobj(), new_pos.gobj());
116   return new_pos;
117 }
118
119 void ListStore::move(const iterator& source, const iterator& destination)
120 {
121   gtk_list_store_move_before(gobj(),
122       const_cast<GtkTreeIter*>(source.get_gobject_if_not_end()),
123       const_cast<GtkTreeIter*>(destination.get_gobject_if_not_end()));
124 }
125
126 void ListStore::reorder(const Glib::ArrayHandle<int>& new_order)
127 {
128   gtk_list_store_reorder(gobj(), const_cast<int*>(new_order.data()));
129 }
130
131 void ListStore::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value)
132 {
133   gtk_list_store_set_value(
134       gobj(), const_cast<GtkTreeIter*>(row.gobj()),
135       column, const_cast<GValue*>(value.gobj()));
136 }
137
138 } // namespace Gtk
139
140
141 namespace
142 {
143 } // anonymous namespace
144
145
146 namespace Glib
147 {
148
149 Glib::RefPtr<Gtk::ListStore> wrap(GtkListStore* object, bool take_copy)
150 {
151   return Glib::RefPtr<Gtk::ListStore>( dynamic_cast<Gtk::ListStore*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
152   //We use dynamic_cast<> in case of multiple inheritance.
153 }
154
155 } /* namespace Glib */
156
157
158 namespace Gtk
159 {
160
161
162 /* The *_Class implementation: */
163
164 const Glib::Class& ListStore_Class::init()
165 {
166   if(!gtype_) // create the GType if necessary
167   {
168     // Glib::Class has to know the class init function to clone custom types.
169     class_init_func_ = &ListStore_Class::class_init_function;
170
171     // This is actually just optimized away, apparently with no harm.
172     // Make sure that the parent type has been created.
173     //CppClassParent::CppObjectType::get_type();
174
175     // Create the wrapper type, with the same class/instance size as the base type.
176     register_derived_type(gtk_list_store_get_type());
177
178     // Add derived versions of interfaces, if the C type implements any interfaces:
179   TreeModel::add_interface(get_type());
180   TreeSortable::add_interface(get_type());
181   TreeDragSource::add_interface(get_type());
182   TreeDragDest::add_interface(get_type());
183   }
184
185   return *this;
186 }
187
188 void ListStore_Class::class_init_function(void* g_class, void* class_data)
189 {
190   BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
191   CppClassParent::class_init_function(klass, class_data);
192
193 #ifdef GLIBMM_VFUNCS_ENABLED
194 #endif //GLIBMM_VFUNCS_ENABLED
195
196 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
197 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
198 }
199
200 #ifdef GLIBMM_VFUNCS_ENABLED
201 #endif //GLIBMM_VFUNCS_ENABLED
202
203 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
204 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
205
206
207 Glib::ObjectBase* ListStore_Class::wrap_new(GObject* object)
208 {
209   return new ListStore((GtkListStore*)object);
210 }
211
212
213 /* The implementation: */
214
215 GtkListStore* ListStore::gobj_copy()
216 {
217   reference();
218   return gobj();
219 }
220
221 ListStore::ListStore(const Glib::ConstructParams& construct_params)
222 :
223   Glib::Object(construct_params)
224 {}
225
226 ListStore::ListStore(GtkListStore* castitem)
227 :
228   Glib::Object((GObject*)(castitem))
229 {}
230
231 ListStore::~ListStore()
232 {}
233
234
235 ListStore::CppClassType ListStore::liststore_class_; // initialize static member
236
237 GType ListStore::get_type()
238 {
239   return liststore_class_.init().get_type();
240 }
241
242 GType ListStore::get_base_type()
243 {
244   return gtk_list_store_get_type();
245 }
246
247
248 ListStore::ListStore()
249 :
250   // Mark this class as non-derived to allow C++ vfuncs to be skipped.
251   Glib::ObjectBase(0),
252   Glib::Object(Glib::ConstructParams(liststore_class_.init()))
253 {
254   }
255
256 Glib::RefPtr<ListStore> ListStore::create(const TreeModelColumnRecord& columns)
257 {
258   return Glib::RefPtr<ListStore>( new ListStore(columns) );
259 }
260 void ListStore::iter_swap(const iterator& a, const iterator& b)
261 {
262 gtk_list_store_swap(gobj(), const_cast<GtkTreeIter*>((a).gobj()), const_cast<GtkTreeIter*>((b).gobj())); 
263 }
264
265 void ListStore::clear()
266 {
267 gtk_list_store_clear(gobj()); 
268 }
269
270 bool ListStore::iter_is_valid(const iterator& iter) const
271 {
272   return gtk_list_store_iter_is_valid(const_cast<GtkListStore*>(gobj()), const_cast<GtkTreeIter*>((iter).gobj()));
273 }
274
275
276 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
277 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
278
279 #ifdef GLIBMM_VFUNCS_ENABLED
280 #endif //GLIBMM_VFUNCS_ENABLED
281
282
283 } // namespace Gtk
284
285