summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options/passwords_page_gtk.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 23:28:10 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-29 23:28:10 +0000
commit650e6918651545098d70fc85d37336bca49c74bf (patch)
tree65ba9756282a57c3b1033edbc3c3ae106de1a232 /chrome/browser/gtk/options/passwords_page_gtk.cc
parent7e9c5769dd8aaa4a72f2d272d17fbe57703cd143 (diff)
downloadchromium_src-650e6918651545098d70fc85d37336bca49c74bf.zip
chromium_src-650e6918651545098d70fc85d37336bca49c74bf.tar.gz
chromium_src-650e6918651545098d70fc85d37336bca49c74bf.tar.bz2
Linux: factor out some shared GTK tree utility code.
BUG=none TEST=none Review URL: http://codereview.chromium.org/160356 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22019 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options/passwords_page_gtk.cc')
-rw-r--r--chrome/browser/gtk/options/passwords_page_gtk.cc44
1 files changed, 9 insertions, 35 deletions
diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc
index 4d6692c..7a3ef2e 100644
--- a/chrome/browser/gtk/options/passwords_page_gtk.cc
+++ b/chrome/browser/gtk/options/passwords_page_gtk.cc
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/gfx/gtk_util.h"
+#include "chrome/common/gtk_tree_util.h"
#include "chrome/common/gtk_util.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
@@ -28,35 +29,6 @@ enum {
COL_COUNT,
};
-// Get the row number corresponding to |path|.
-gint GetRowNumForPath(GtkTreePath* path) {
- gint* indices = gtk_tree_path_get_indices(path);
- if (!indices) {
- NOTREACHED();
- return -1;
- }
- return indices[0];
-}
-
-// Get the row number corresponding to |iter|.
-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;
-}
-
-// Get the row number in the child tree model corresponding to |sort_path| in
-// the parent tree model.
-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;
-}
-
} // anonymous namespace
///////////////////////////////////////////////////////////////////////////////
@@ -206,7 +178,8 @@ void PasswordsPageGtk::OnRemoveButtonClicked(GtkButton* widget,
GtkTreePath* path = gtk_tree_model_get_path(
GTK_TREE_MODEL(page->password_list_sort_), &iter);
- gint index = GetTreeSortChildRowNumForPath(page->password_list_sort_, path);
+ gint index = GtkTreeUtil::GetTreeSortChildRowNumForPath(
+ page->password_list_sort_, path);
gtk_tree_path_free(path);
GtkTreeIter child_iter;
@@ -286,7 +259,8 @@ void PasswordsPageGtk::OnShowPasswordButtonClicked(GtkButton* widget,
}
GtkTreePath* path = gtk_tree_model_get_path(
GTK_TREE_MODEL(page->password_list_sort_), &iter);
- gint index = GetTreeSortChildRowNumForPath(page->password_list_sort_, path);
+ gint index = GtkTreeUtil::GetTreeSortChildRowNumForPath(
+ page->password_list_sort_, path);
gtk_tree_path_free(path);
std::string pass = WideToUTF8(page->password_list_[index].password_value);
gtk_label_set_text(GTK_LABEL(page->password_), pass.c_str());
@@ -317,8 +291,8 @@ void PasswordsPageGtk::OnPasswordSelectionChanged(GtkTreeSelection* selection,
gint PasswordsPageGtk::CompareSite(GtkTreeModel* model,
GtkTreeIter* a, GtkTreeIter* b,
gpointer window) {
- int row1 = GetRowNumForIter(model, a);
- int row2 = GetRowNumForIter(model, b);
+ int row1 = GtkTreeUtil::GetRowNumForIter(model, a);
+ int row2 = GtkTreeUtil::GetRowNumForIter(model, b);
PasswordsPageGtk* page = reinterpret_cast<PasswordsPageGtk*>(window);
return page->password_list_[row1].origin.spec().compare(
page->password_list_[row2].origin.spec());
@@ -328,8 +302,8 @@ gint PasswordsPageGtk::CompareSite(GtkTreeModel* model,
gint PasswordsPageGtk::CompareUsername(GtkTreeModel* model,
GtkTreeIter* a, GtkTreeIter* b,
gpointer window) {
- int row1 = GetRowNumForIter(model, a);
- int row2 = GetRowNumForIter(model, b);
+ int row1 = GtkTreeUtil::GetRowNumForIter(model, a);
+ int row2 = GtkTreeUtil::GetRowNumForIter(model, b);
PasswordsPageGtk* page = reinterpret_cast<PasswordsPageGtk*>(window);
return page->password_list_[row1].username_value.compare(
page->password_list_[row2].username_value);