| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/keyword_editor_view.h" | 5 #include "chrome/browser/ui/gtk/keyword_editor_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 G_CALLBACK(OnMakeDefaultButtonClicked), this); | 190 G_CALLBACK(OnMakeDefaultButtonClicked), this); |
| 191 gtk_box_pack_start(GTK_BOX(button_box), make_default_button_, FALSE, FALSE, | 191 gtk_box_pack_start(GTK_BOX(button_box), make_default_button_, FALSE, FALSE, |
| 192 0); | 192 0); |
| 193 | 193 |
| 194 controller_->url_model()->AddObserver(this); | 194 controller_->url_model()->AddObserver(this); |
| 195 table_model_->SetObserver(this); | 195 table_model_->SetObserver(this); |
| 196 table_model_->Reload(); | 196 table_model_->Reload(); |
| 197 | 197 |
| 198 EnableControls(); | 198 EnableControls(); |
| 199 | 199 |
| 200 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this); | 200 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); |
| 201 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this); | 201 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void KeywordEditorView::EnableControls() { | 204 void KeywordEditorView::EnableControls() { |
| 205 bool can_edit = false; | 205 bool can_edit = false; |
| 206 bool can_make_default = false; | 206 bool can_make_default = false; |
| 207 bool can_remove = false; | 207 bool can_remove = false; |
| 208 int model_row = GetSelectedModelRow(); | 208 int model_row = GetSelectedModelRow(); |
| 209 if (model_row != -1) { | 209 if (model_row != -1) { |
| 210 const TemplateURL* selected_url = controller_->GetTemplateURL(model_row); | 210 const TemplateURL* selected_url = controller_->GetTemplateURL(model_row); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 EnableControls(); | 389 EnableControls(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 // static | 392 // static |
| 393 void KeywordEditorView::OnWindowDestroy(GtkWidget* widget, | 393 void KeywordEditorView::OnWindowDestroy(GtkWidget* widget, |
| 394 KeywordEditorView* window) { | 394 KeywordEditorView* window) { |
| 395 instance_ = NULL; | 395 instance_ = NULL; |
| 396 MessageLoop::current()->DeleteSoon(FROM_HERE, window); | 396 MessageLoop::current()->DeleteSoon(FROM_HERE, window); |
| 397 } | 397 } |
| 398 | 398 |
| 399 // static | 399 void KeywordEditorView::OnResponse(GtkWidget* dialog, int response_id) { |
| 400 void KeywordEditorView::OnResponse(GtkDialog* dialog, int response_id, | 400 gtk_widget_destroy(dialog_); |
| 401 KeywordEditorView* window) { | |
| 402 gtk_widget_destroy(window->dialog_); | |
| 403 } | 401 } |
| 404 | 402 |
| 405 // static | 403 // static |
| 406 gboolean KeywordEditorView::OnCheckRowIsSeparator(GtkTreeModel* model, | 404 gboolean KeywordEditorView::OnCheckRowIsSeparator(GtkTreeModel* model, |
| 407 GtkTreeIter* iter, | 405 GtkTreeIter* iter, |
| 408 gpointer user_data) { | 406 gpointer user_data) { |
| 409 gboolean is_separator; | 407 gboolean is_separator; |
| 410 gtk_tree_model_get(model, iter, COL_IS_SEPARATOR, &is_separator, -1); | 408 gtk_tree_model_get(model, iter, COL_IS_SEPARATOR, &is_separator, -1); |
| 411 return is_separator; | 409 return is_separator; |
| 412 } | 410 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 int model_row = editor->GetSelectedModelRow(); | 486 int model_row = editor->GetSelectedModelRow(); |
| 489 if (model_row == -1) { | 487 if (model_row == -1) { |
| 490 NOTREACHED(); | 488 NOTREACHED(); |
| 491 return; | 489 return; |
| 492 } | 490 } |
| 493 int new_index = editor->controller_->MakeDefaultTemplateURL(model_row); | 491 int new_index = editor->controller_->MakeDefaultTemplateURL(model_row); |
| 494 if (new_index > 0) { | 492 if (new_index > 0) { |
| 495 editor->SelectModelRow(new_index); | 493 editor->SelectModelRow(new_index); |
| 496 } | 494 } |
| 497 } | 495 } |
| OLD | NEW |