~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/gtkmm2/gtk/gtkmm/treepath.cc

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Generated by gtkmmproc -- DO NOT MODIFY!
 
2
 
 
3
#include <gtkmm/treepath.h>
 
4
#include <gtkmm/private/treepath_p.h>
 
5
 
 
6
// -*- c++ -*-
 
7
/* $Id$ */
 
8
 
 
9
/* Copyright 1998-2002 The gtkmm Development Team
 
10
 *
 
11
 * This library is free software; you can redistribute it and/or
 
12
 * modify it under the terms of the GNU Library General Public
 
13
 * License as published by the Free Software Foundation; either
 
14
 * version 2 of the License, or (at your option) any later version.
 
15
 *
 
16
 * This library is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
 * Library General Public License for more details.
 
20
 *
 
21
 * You should have received a copy of the GNU Library General Public
 
22
 * License along with this library; if not, write to the Free
 
23
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
24
 */
 
25
 
 
26
#include <gtkmm/treemodel.h>
 
27
#include <glibmm/utility.h>
 
28
#include <gtk/gtktreemodel.h>
 
29
#include <gtk/gtktreednd.h>
 
30
 
 
31
 
 
32
namespace Gtk
 
33
{
 
34
 
 
35
TreePath::TreePath(TreePath::size_type n, TreePath::value_type value)
 
36
:
 
37
  gobject_ (gtk_tree_path_new())
 
38
{
 
39
  for(; n > 0; --n)
 
40
    gtk_tree_path_append_index(gobject_, value);
 
41
}
 
42
 
 
43
TreePath::TreePath(const Glib::ustring& path)
 
44
:
 
45
  gobject_ (gtk_tree_path_new_from_string(path.c_str()))
 
46
{}
 
47
 
 
48
TreePath::TreePath(const TreeModel::iterator& iter)
 
49
:
 
50
  // The GtkTreePath* is always newly created.
 
51
  gobject_ (gtk_tree_model_get_path(iter.get_model_gobject(), const_cast<GtkTreeIter*>(iter.gobj())))
 
52
{}
 
53
 
 
54
TreePath& TreePath::operator=(const TreeModel::iterator& iter)
 
55
{
 
56
  TreePath temp (iter);
 
57
  swap(temp);
 
58
  return *this;
 
59
}
 
60
 
 
61
void TreePath::clear()
 
62
{
 
63
  TreePath empty_path;
 
64
  swap(empty_path);
 
65
}
 
66
 
 
67
TreePath::size_type TreePath::size() const
 
68
{
 
69
  return gtk_tree_path_get_depth(gobject_);
 
70
}
 
71
 
 
72
bool TreePath::empty() const
 
73
{
 
74
  return (gtk_tree_path_get_depth(gobject_) == 0);
 
75
}
 
76
 
 
77
TreePath::reference TreePath::operator[](TreePath::size_type i)
 
78
{
 
79
  int *const indices = gtk_tree_path_get_indices(gobject_);
 
80
  return indices[i];
 
81
}
 
82
 
 
83
TreePath::const_reference TreePath::operator[](TreePath::size_type i) const
 
84
{
 
85
  const int *const indices = gtk_tree_path_get_indices(gobject_);
 
86
  return indices[i];
 
87
}
 
88
 
 
89
TreePath::iterator TreePath::begin()
 
90
{
 
91
  return gtk_tree_path_get_indices(gobject_);
 
92
}
 
93
 
 
94
TreePath::iterator TreePath::end()
 
95
{
 
96
  return gtk_tree_path_get_indices(gobject_) + gtk_tree_path_get_depth(gobject_);
 
97
}
 
98
 
 
99
TreePath::const_iterator TreePath::begin() const
 
100
{
 
101
  return gtk_tree_path_get_indices(gobject_);
 
102
}
 
103
 
 
104
TreePath::const_iterator TreePath::end() const
 
105
{
 
106
  return gtk_tree_path_get_indices(gobject_) + gtk_tree_path_get_depth(gobject_);
 
107
}
 
108
 
 
109
bool TreePath::get_from_selection_data(const SelectionData& selection_data, Glib::RefPtr<TreeModel>& model, TreePath& path) //static 
 
110
{
 
111
  GtkTreeModel* src_model = 0;
 
112
  GtkTreePath* src_path = 0;
 
113
  gboolean result = gtk_tree_get_row_drag_data(const_cast<GtkSelectionData*>(selection_data.gobj()), &src_model, &src_path);
 
114
 
 
115
  model = Glib::wrap(src_model, true /* take_copy=true */);
 
116
  
 
117
  //gtk_tree_get_row_drag_data gives us ownership of src_path.
 
118
  path = Glib::wrap(src_path, false /* take_copy=false */);
 
119
 
 
120
  return result;
 
121
}
 
122
 
 
123
bool TreePath::get_from_selection_data(const SelectionData& selection_data, TreePath& path) //static
 
124
{
 
125
  GtkTreePath* src_path = 0;
 
126
  gboolean result = gtk_tree_get_row_drag_data(const_cast<GtkSelectionData*>(selection_data.gobj()), 0, &src_path);
 
127
 
 
128
  //gtk_tree_get_row_drag_data gives us ownership of src_path.
 
129
  path = Glib::wrap(src_path, false /* take_copy=false */);
 
130
 
 
131
  return result;
 
132
}
 
133
 
 
134
 
 
135
bool TreePath::set_in_selection_data(SelectionData& selection_data, const Glib::RefPtr<const TreeModel>& model) const
 
136
{
 
137
  return gtk_tree_set_row_drag_data(selection_data.gobj(), const_cast<GtkTreeModel*>(model->gobj()), const_cast<GtkTreePath*>(gobj()));  
 
138
}
 
139
 
 
140
//deprecated:
 
141
Glib::ArrayHandle<int> TreePath::get_indices() const
 
142
{
 
143
  // gtk_tree_path_get_indices() returns a pointer to an internal array,
 
144
  // similar to std::string::data().  Thus the OWNERSHIP_NONE flag.
 
145
 
 
146
  return Glib::ArrayHandle<int>(gtk_tree_path_get_indices(gobject_),
 
147
                                gtk_tree_path_get_depth(gobject_),
 
148
                                Glib::OWNERSHIP_NONE);
 
149
}
 
150
  
 
151
} // namespace Gtk
 
152
 
 
153
 
 
154
namespace
 
155
{
 
156
} // anonymous namespace
 
157
 
 
158
 
 
159
namespace Glib
 
160
{
 
161
 
 
162
Gtk::TreePath wrap(GtkTreePath* object, bool take_copy)
 
163
{
 
164
  return Gtk::TreePath(object, take_copy);
 
165
}
 
166
 
 
167
} // namespace Glib
 
168
 
 
169
 
 
170
namespace Gtk
 
171
{
 
172
 
 
173
 
 
174
// static
 
175
GType TreePath::get_type()
 
176
{
 
177
  return gtk_tree_path_get_type();
 
178
}
 
179
 
 
180
TreePath::TreePath()
 
181
:
 
182
  gobject_ (gtk_tree_path_new())
 
183
{}
 
184
 
 
185
TreePath::TreePath(const TreePath& other)
 
186
:
 
187
  gobject_ ((other.gobject_) ? gtk_tree_path_copy(other.gobject_) : 0)
 
188
{}
 
189
 
 
190
TreePath::TreePath(GtkTreePath* gobject, bool make_a_copy)
 
191
:
 
192
  // For BoxedType wrappers, make_a_copy is true by default.  The static
 
193
  // BoxedType wrappers must always take a copy, thus make_a_copy = true
 
194
  // ensures identical behaviour if the default argument is used.
 
195
  gobject_ ((make_a_copy && gobject) ? gtk_tree_path_copy(gobject) : gobject)
 
196
{}
 
197
 
 
198
TreePath& TreePath::operator=(const TreePath& other)
 
199
{
 
200
  TreePath temp (other);
 
201
  swap(temp);
 
202
  return *this;
 
203
}
 
204
 
 
205
TreePath::~TreePath()
 
206
{
 
207
  if(gobject_)
 
208
    gtk_tree_path_free(gobject_);
 
209
}
 
210
 
 
211
void TreePath::swap(TreePath& other)
 
212
{
 
213
  GtkTreePath *const temp = gobject_;
 
214
  gobject_ = other.gobject_;
 
215
  other.gobject_ = temp;
 
216
}
 
217
 
 
218
GtkTreePath* TreePath::gobj_copy() const
 
219
{
 
220
  return gtk_tree_path_copy(gobject_);
 
221
}
 
222
 
 
223
 
 
224
void TreePath::push_back(int index)
 
225
{
 
226
  gtk_tree_path_append_index(gobj(), index);
 
227
}
 
228
 
 
229
void TreePath::push_front(int index)
 
230
{
 
231
  gtk_tree_path_prepend_index(gobj(), index);
 
232
}
 
233
 
 
234
void TreePath::next()
 
235
{
 
236
  gtk_tree_path_next(gobj());
 
237
}
 
238
 
 
239
bool TreePath::prev()
 
240
{
 
241
  return gtk_tree_path_prev(gobj());
 
242
}
 
243
 
 
244
bool TreePath::up()
 
245
{
 
246
  return gtk_tree_path_up(gobj());
 
247
}
 
248
 
 
249
void TreePath::down()
 
250
{
 
251
  gtk_tree_path_down(gobj());
 
252
}
 
253
 
 
254
bool TreePath::is_ancestor(const TreePath& descendant) const
 
255
{
 
256
  return gtk_tree_path_is_ancestor(const_cast<GtkTreePath*>(gobj()), const_cast<GtkTreePath*>((descendant).gobj()));
 
257
}
 
258
 
 
259
bool TreePath::is_descendant(const TreePath& ancestor) const
 
260
{
 
261
  return gtk_tree_path_is_descendant(const_cast<GtkTreePath*>(gobj()), const_cast<GtkTreePath*>((ancestor).gobj()));
 
262
}
 
263
 
 
264
Glib::ustring TreePath::to_string() const
 
265
{
 
266
  return Glib::convert_return_gchar_ptr_to_ustring(gtk_tree_path_to_string(const_cast<GtkTreePath*>(gobj())));
 
267
}
 
268
 
 
269
 
 
270
bool operator==(const TreePath& lhs, const TreePath& rhs)
 
271
{
 
272
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) == 0);
 
273
}
 
274
 
 
275
bool operator!=(const TreePath& lhs, const TreePath& rhs)
 
276
{
 
277
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) != 0);
 
278
}
 
279
 
 
280
bool operator<(const TreePath& lhs, const TreePath& rhs)
 
281
{
 
282
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) < 0);
 
283
}
 
284
 
 
285
bool operator>(const TreePath& lhs, const TreePath& rhs)
 
286
{
 
287
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) > 0);
 
288
}
 
289
 
 
290
bool operator<=(const TreePath& lhs, const TreePath& rhs)
 
291
{
 
292
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) <= 0);
 
293
}
 
294
 
 
295
bool operator>=(const TreePath& lhs, const TreePath& rhs)
 
296
{
 
297
  return (gtk_tree_path_compare(lhs.gobj(), rhs.gobj()) >= 0);
 
298
}
 
299
 
 
300
 
 
301
void TreePath::append_index(int index)
 
302
{
 
303
  gtk_tree_path_append_index(gobj(), index);
 
304
}
 
305
 
 
306
void TreePath::prepend_index(int index)
 
307
{
 
308
  gtk_tree_path_prepend_index(gobj(), index);
 
309
}
 
310
 
 
311
int TreePath::get_depth() const
 
312
{
 
313
  return gtk_tree_path_get_depth(const_cast<GtkTreePath*>(gobj()));
 
314
}
 
315
 
 
316
 
 
317
} // namespace Gtk
 
318
 
 
319