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

Side by Side Diff: chrome/browser/gtk/options/geolocation_content_exceptions_window.cc

Issue 2838037: Introduce RemoveRowTableModel interface, let GeolocationExceptionsTableModel derive from it. (Closed)
Patch Set: '' Created 10 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/gtk/options/geolocation_content_exceptions_window.h" 5 #include "chrome/browser/gtk/options/geolocation_content_exceptions_window.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" 10 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 gtk_list_store_set(list_store_, iter, COL_ACTION, 134 gtk_list_store_set(list_store_, iter, COL_ACTION,
135 WideToUTF8(action).c_str(), -1); 135 WideToUTF8(action).c_str(), -1);
136 } 136 }
137 137
138 void GeolocationContentExceptionsWindow::UpdateButtonState() { 138 void GeolocationContentExceptionsWindow::UpdateButtonState() {
139 int row_count = gtk_tree_model_iter_n_children( 139 int row_count = gtk_tree_model_iter_n_children(
140 GTK_TREE_MODEL(list_store_), NULL); 140 GTK_TREE_MODEL(list_store_), NULL);
141 141
142 GeolocationExceptionsTableModel::Rows rows; 142 GeolocationExceptionsTableModel::Rows rows;
143 GetSelectedRows(&rows); 143 GetSelectedRows(&rows);
144 gtk_widget_set_sensitive(remove_button_, model_->CanRemoveExceptions(rows)); 144 gtk_widget_set_sensitive(remove_button_, model_->CanRemoveRows(rows));
145 gtk_widget_set_sensitive(remove_all_button_, row_count > 0); 145 gtk_widget_set_sensitive(remove_all_button_, row_count > 0);
146 } 146 }
147 147
148 void GeolocationContentExceptionsWindow::GetSelectedRows( 148 void GeolocationContentExceptionsWindow::GetSelectedRows(
149 GeolocationExceptionsTableModel::Rows* rows) { 149 GeolocationExceptionsTableModel::Rows* rows) {
150 std::set<int> indices; 150 std::set<int> indices;
151 gtk_tree::GetSelectedIndices(treeview_selection_, &indices); 151 gtk_tree::GetSelectedIndices(treeview_selection_, &indices);
152 for (std::set<int>::iterator i = indices.begin(); i != indices.end(); ++i) 152 for (std::set<int>::iterator i = indices.begin(); i != indices.end(); ++i)
153 rows->insert(*i); 153 rows->insert(*i);
154 } 154 }
155 155
156 void GeolocationContentExceptionsWindow::Remove(GtkWidget* widget) { 156 void GeolocationContentExceptionsWindow::Remove(GtkWidget* widget) {
157 GeolocationExceptionsTableModel::Rows rows; 157 GeolocationExceptionsTableModel::Rows rows;
158 GetSelectedRows(&rows); 158 GetSelectedRows(&rows);
159 model_->RemoveExceptions(rows); 159 model_->RemoveRows(rows);
160 UpdateButtonState(); 160 UpdateButtonState();
161 } 161 }
162 162
163 void GeolocationContentExceptionsWindow::RemoveAll(GtkWidget* widget) { 163 void GeolocationContentExceptionsWindow::RemoveAll(GtkWidget* widget) {
164 model_->RemoveAll(); 164 model_->RemoveAll();
165 UpdateButtonState(); 165 UpdateButtonState();
166 } 166 }
167 167
168 void GeolocationContentExceptionsWindow::OnWindowDestroy(GtkWidget* widget) { 168 void GeolocationContentExceptionsWindow::OnWindowDestroy(GtkWidget* widget) {
169 instance = NULL; 169 instance = NULL;
170 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 170 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
171 } 171 }
172 172
173 void GeolocationContentExceptionsWindow::OnTreeSelectionChanged( 173 void GeolocationContentExceptionsWindow::OnTreeSelectionChanged(
174 GtkWidget* selection) { 174 GtkWidget* selection) {
175 UpdateButtonState(); 175 UpdateButtonState();
176 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc ('k') | chrome/browser/remove_rows_table_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698