summaryrefslogtreecommitdiffstats
path: root/chrome/common/gtk_tree.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:47:00 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:47:00 +0000
commit868fa750bc04355bbcefd774f301b910d5d1ae4d (patch)
treeae0e567380e0b13adf36c33fda1c08164bdb0010 /chrome/common/gtk_tree.cc
parent4728aab62e1076e58ccd756200719b9babd7ed9b (diff)
downloadchromium_src-868fa750bc04355bbcefd774f301b910d5d1ae4d.zip
chromium_src-868fa750bc04355bbcefd774f301b910d5d1ae4d.tar.gz
chromium_src-868fa750bc04355bbcefd774f301b910d5d1ae4d.tar.bz2
Rename namespace gtk_tree_util to gtk_tree which is shorter.
BUG=none TEST=none Review URL: http://codereview.chromium.org/160431 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/gtk_tree.cc')
-rw-r--r--chrome/common/gtk_tree.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/common/gtk_tree.cc b/chrome/common/gtk_tree.cc
new file mode 100644
index 0000000..fafee0f
--- /dev/null
+++ b/chrome/common/gtk_tree.cc
@@ -0,0 +1,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