Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5182)

Unified Diff: chrome/browser/gtk/options/content_exceptions_window_gtk.cc

Issue 2876034: Sorry, this is making the Heapcheck bot unhappy. http://build.chromium.org/b... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/gtk/options/content_exceptions_window_gtk.cc
===================================================================
--- chrome/browser/gtk/options/content_exceptions_window_gtk.cc (revision 51474)
+++ chrome/browser/gtk/options/content_exceptions_window_gtk.cc (working copy)
@@ -47,14 +47,11 @@
GtkWindow* parent,
HostContentSettingsMap* map,
ContentSettingsType type) {
- // Build the list backing that GTK uses, along with an adapter which will
- // sort stuff without changing the underlying backing store.
+ // Build the model adapters that translate views and TableModels into
+ // something GTK can use.
list_store_ = gtk_list_store_new(COL_COUNT, G_TYPE_STRING, G_TYPE_STRING);
- sort_list_store_ = gtk_tree_model_sort_new_with_model(
- GTK_TREE_MODEL(list_store_));
- treeview_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(sort_list_store_));
+ treeview_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store_));
g_object_unref(list_store_);
- g_object_unref(sort_list_store_);
// Set up the properties of the treeview
gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview_), TRUE);
@@ -188,7 +185,7 @@
int num_selected = gtk_tree_selection_count_selected_rows(
treeview_selection_);
int row_count = gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(sort_list_store_), NULL);
+ GTK_TREE_MODEL(list_store_), NULL);
// TODO(erg): http://crbug.com/34177 , support editing of more than one entry
// at a time.
@@ -205,10 +202,10 @@
}
void ContentExceptionsWindowGtk::Edit(GtkWidget* widget) {
- std::set<std::pair<int, int> > indices;
- GetSelectedModelIndices(&indices);
+ std::set<int> indices;
+ gtk_tree::GetSelectedIndices(treeview_selection_, &indices);
DCHECK_GT(indices.size(), 0u);
- int index = indices.begin()->first;
+ int index = *indices.begin();
const HostContentSettingsMap::PatternSettingPair& entry =
model_->entry_at(index);
new ContentExceptionEditor(GTK_WINDOW(dialog_), this, model_.get(), index,
@@ -216,16 +213,14 @@
}
void ContentExceptionsWindowGtk::Remove(GtkWidget* widget) {
- std::set<std::pair<int, int> > model_selected_indices;
- GetSelectedModelIndices(&model_selected_indices);
+ std::set<int> selected_indices;
+ gtk_tree::GetSelectedIndices(treeview_selection_, &selected_indices);
- int selected_row = gtk_tree_model_iter_n_children(
- GTK_TREE_MODEL(sort_list_store_), NULL);
- for (std::set<std::pair<int, int> >::reverse_iterator i =
- model_selected_indices.rbegin();
- i != model_selected_indices.rend(); ++i) {
- model_->RemoveException(i->first);
- selected_row = std::min(selected_row, i->second);
+ int selected_row = 0;
+ for (std::set<int>::reverse_iterator i = selected_indices.rbegin();
+ i != selected_indices.rend(); ++i) {
+ model_->RemoveException(*i);
+ selected_row = *i;
}
int row_count = model_->RowCount();
@@ -262,25 +257,6 @@
return std::string();
}
-void ContentExceptionsWindowGtk::GetSelectedModelIndices(
- std::set<std::pair<int, int> >* indices) {
- GtkTreeModel* model;
- GList* paths = gtk_tree_selection_get_selected_rows(treeview_selection_,
- &model);
- for (GList* item = paths; item; item = item->next) {
- GtkTreePath* sorted_path = reinterpret_cast<GtkTreePath*>(item->data);
- int sorted_row = gtk_tree::GetRowNumForPath(sorted_path);
- GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path(
- GTK_TREE_MODEL_SORT(sort_list_store_), sorted_path);
- int row = gtk_tree::GetRowNumForPath(path);
- gtk_tree_path_free(path);
- indices->insert(std::make_pair(row, sorted_row));
- }
-
- g_list_foreach(paths, (GFunc)gtk_tree_path_free, NULL);
- g_list_free(paths);
-}
-
void ContentExceptionsWindowGtk::OnTreeViewRowActivate(
GtkWidget* sender,
GtkTreePath* path,

Powered by Google App Engine
This is Rietveld 408576698