summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options/cookies_view.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/cookies_view.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/cookies_view.cc')
-rw-r--r--chrome/browser/gtk/options/cookies_view.cc44
1 files changed, 7 insertions, 37 deletions
diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc
index 4c784e4..12087ec 100644
--- a/chrome/browser/gtk/options/cookies_view.cc
+++ b/chrome/browser/gtk/options/cookies_view.cc
@@ -10,6 +10,7 @@
#include "base/string_util.h"
#include "base/time_format.h"
#include "chrome/browser/cookies_table_model.h"
+#include "chrome/common/gtk_tree_util.h"
#include "chrome/common/gtk_util.h"
#include "grit/generated_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -40,37 +41,6 @@ enum {
// The currently open cookie manager, if any.
CookiesView* instance_ = NULL;
-// TODO(mattm): These functions are also in url_picker_dialog_gtk. Move them to
-// some sort of gtk table model helper?
-// 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;
-}
-
} // namespace
CookiesView::~CookiesView() {
@@ -314,7 +284,7 @@ void CookiesView::PopulateCookieDetails() {
NOTREACHED();
return;
}
- int selected_index = GetTreeSortChildRowNumForPath(
+ int selected_index = GtkTreeUtil::GetTreeSortChildRowNumForPath(
list_sort_, static_cast<GtkTreePath*>(list->data));
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
g_list_free(list);
@@ -366,7 +336,7 @@ void CookiesView::RemoveSelectedCookies() {
GList* node;
size_t i;
for (i = 0, node = list; node != NULL; ++i, node = node->next) {
- selected_rows[i] = GetTreeSortChildRowNumForPath(
+ selected_rows[i] = GtkTreeUtil::GetTreeSortChildRowNumForPath(
list_sort_, static_cast<GtkTreePath*>(node->data));
}
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
@@ -446,8 +416,8 @@ void CookiesView::OnItemsRemoved(int start, int length) {
// static
gint CookiesView::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);
return reinterpret_cast<CookiesView*>(window)->cookies_table_model_->
CompareValues(row1, row2, IDS_COOKIES_DOMAIN_COLUMN_HEADER);
}
@@ -455,8 +425,8 @@ gint CookiesView::CompareSite(GtkTreeModel* model, GtkTreeIter* a,
// static
gint CookiesView::CompareCookieName(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);
return reinterpret_cast<CookiesView*>(window)->cookies_table_model_->
CompareValues(row1, row2, IDS_COOKIES_NAME_COLUMN_HEADER);
}