blob: fafee0fcaa6433bdb4beeb43c8dbdd00d4bc3fdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/gtk_tree.h"
#include "base/logging.h"
namespace gtk_tree {
gint GetRowNumForPath(GtkTreePath* path) {
gint* indices = gtk_tree_path_get_indices(path);
if (!indices) {
NOTREACHED();
return -1;
}
return indices[0];
}
gint GetRowNumForIter(GtkTreeModel* model, GtkTreeIter* iter) {
GtkTreePath* path = gtk_tree_model_get_path(model, iter);
int row = GetRowNumForPath(path);
gtk_tree_path_free(path);
return row;
}
gint GetTreeSortChildRowNumForPath(GtkTreeModel* sort_model,
GtkTreePath* sort_path) {
GtkTreePath *child_path = gtk_tree_model_sort_convert_path_to_child_path(
GTK_TREE_MODEL_SORT(sort_model), sort_path);
int row = GetRowNumForPath(child_path);
gtk_tree_path_free(child_path);
return row;
}
} // namespace gtk_tree
|