diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gtk/options/cookies_view.cc | 44 | ||||
-rw-r--r-- | chrome/browser/gtk/options/exceptions_page_gtk.cc | 37 | ||||
-rw-r--r-- | chrome/browser/gtk/options/passwords_page_gtk.cc | 44 | ||||
-rw-r--r-- | chrome/browser/gtk/options/url_picker_dialog_gtk.cc | 41 |
4 files changed, 28 insertions, 138 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); } diff --git a/chrome/browser/gtk/options/exceptions_page_gtk.cc b/chrome/browser/gtk/options/exceptions_page_gtk.cc index c0b5597..ecdbf60 100644 --- a/chrome/browser/gtk/options/exceptions_page_gtk.cc +++ b/chrome/browser/gtk/options/exceptions_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" @@ -24,35 +25,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 /////////////////////////////////////////////////////////////////////////////// @@ -161,7 +133,8 @@ void ExceptionsPageGtk::OnRemoveButtonClicked(GtkButton* widget, GtkTreePath* path = gtk_tree_model_get_path( GTK_TREE_MODEL(page->exception_list_sort_), &iter); - gint index = GetTreeSortChildRowNumForPath(page->exception_list_sort_, path); + gint index = GtkTreeUtil::GetTreeSortChildRowNumForPath( + page->exception_list_sort_, path); gtk_tree_path_free(path); GtkTreeIter child_iter; @@ -205,8 +178,8 @@ void ExceptionsPageGtk::OnExceptionSelectionChanged(GtkTreeSelection* selection, gint ExceptionsPageGtk::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); ExceptionsPageGtk* page = reinterpret_cast<ExceptionsPageGtk*>(window); return page->exception_list_[row1].origin.spec().compare( page->exception_list_[row2].origin.spec()); 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); diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index d6bf0eb..3e4d9a6 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -11,6 +11,7 @@ #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/possible_url_model.h" #include "chrome/browser/profile.h" +#include "chrome/common/gtk_tree_util.h" #include "chrome/common/gtk_util.h" #include "chrome/common/pref_names.h" #include "googleurl/src/gurl.h" @@ -38,35 +39,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 UrlPickerDialogGtk::UrlPickerDialogGtk(UrlPickerCallback* callback, @@ -205,7 +177,8 @@ void UrlPickerDialogGtk::EnableControls() { } std::string UrlPickerDialogGtk::GetURLForPath(GtkTreePath* path) const { - gint row = GetTreeSortChildRowNumForPath(history_list_sort_, path); + gint row = GtkTreeUtil::GetTreeSortChildRowNumForPath(history_list_sort_, + path); if (row < 0) { NOTREACHED(); return std::string(); @@ -280,8 +253,8 @@ gint UrlPickerDialogGtk::CompareTitle(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<UrlPickerDialogGtk*>(window)->url_table_model_-> CompareValues(row1, row2, IDS_ASI_PAGE_COLUMN); } @@ -291,8 +264,8 @@ gint UrlPickerDialogGtk::CompareURL(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<UrlPickerDialogGtk*>(window)->url_table_model_-> CompareValues(row1, row2, IDS_ASI_URL_COLUMN); } |