| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/clear_browsing_data_dialog_gtk.h" | 5 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/browser/browsing_data_remover.h" | 9 #include "chrome/browser/browsing_data_remover.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| 11 #include "chrome/common/gtk_util.h" | 11 #include "chrome/common/gtk_util.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/pref_service.h" | 13 #include "chrome/common/pref_service.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/locale_settings.h" |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 void ClearBrowsingDataDialogGtk::Show(GtkWindow* parent, Profile* profile) { | 18 void ClearBrowsingDataDialogGtk::Show(GtkWindow* parent, Profile* profile) { |
| 18 new ClearBrowsingDataDialogGtk(parent, profile); | 19 new ClearBrowsingDataDialogGtk(parent, profile); |
| 19 } | 20 } |
| 20 | 21 |
| 21 ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, | 22 ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, |
| 22 Profile* profile) : | 23 Profile* profile) : |
| 23 profile_(profile), remover_(NULL) { | 24 profile_(profile), remover_(NULL) { |
| 24 // Build the dialog. | 25 // Build the dialog. |
| 25 GtkWidget* dialog = gtk_dialog_new_with_buttons( | 26 GtkWidget* dialog = gtk_dialog_new_with_buttons( |
| 26 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_TITLE).c_str(), | 27 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_TITLE).c_str(), |
| 27 parent, | 28 parent, |
| 28 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 29 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 29 GTK_STOCK_CLOSE, | 30 GTK_STOCK_CLOSE, |
| 30 GTK_RESPONSE_REJECT, | 31 GTK_RESPONSE_REJECT, |
| 31 NULL); | 32 NULL); |
| 33 gtk_widget_realize(dialog); |
| 34 gtk_util::SetWindowWidthFromResources(GTK_WINDOW(dialog), |
| 35 IDS_CLEARDATA_DIALOG_WIDTH_CHARS, |
| 36 /* resizable */ false); |
| 32 gtk_util::AddButtonToDialog(dialog, | 37 gtk_util::AddButtonToDialog(dialog, |
| 33 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), | 38 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), |
| 34 GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); | 39 GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); |
| 35 | 40 |
| 36 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; | 41 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; |
| 37 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); | 42 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); |
| 38 | 43 |
| 39 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 44 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 40 gtk_container_add(GTK_CONTAINER(content_area), vbox); | 45 gtk_container_add(GTK_CONTAINER(content_area), vbox); |
| 41 | 46 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 gtk_box_pack_start(GTK_BOX(combo_hbox), | 125 gtk_box_pack_start(GTK_BOX(combo_hbox), |
| 121 time_period_combobox_, FALSE, FALSE, 0); | 126 time_period_combobox_, FALSE, FALSE, 0); |
| 122 g_signal_connect(time_period_combobox_, "changed", | 127 g_signal_connect(time_period_combobox_, "changed", |
| 123 G_CALLBACK(HandleOnClickedWidget), this); | 128 G_CALLBACK(HandleOnClickedWidget), this); |
| 124 | 129 |
| 125 // Add the combo/label time period box to the vertical layout. | 130 // Add the combo/label time period box to the vertical layout. |
| 126 gtk_box_pack_start(GTK_BOX(vbox), combo_hbox, FALSE, FALSE, 0); | 131 gtk_box_pack_start(GTK_BOX(vbox), combo_hbox, FALSE, FALSE, 0); |
| 127 | 132 |
| 128 g_signal_connect(dialog, "response", | 133 g_signal_connect(dialog, "response", |
| 129 G_CALLBACK(HandleOnResponseDialog), this); | 134 G_CALLBACK(HandleOnResponseDialog), this); |
| 130 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | |
| 131 gtk_widget_show_all(dialog); | 135 gtk_widget_show_all(dialog); |
| 132 } | 136 } |
| 133 | 137 |
| 134 void ClearBrowsingDataDialogGtk::OnDialogResponse(GtkWidget* widget, | 138 void ClearBrowsingDataDialogGtk::OnDialogResponse(GtkWidget* widget, |
| 135 int response) { | 139 int response) { |
| 136 if (response == GTK_RESPONSE_ACCEPT) { | 140 if (response == GTK_RESPONSE_ACCEPT) { |
| 137 int period_selected = gtk_combo_box_get_active( | 141 int period_selected = gtk_combo_box_get_active( |
| 138 GTK_COMBO_BOX(time_period_combobox_)); | 142 GTK_COMBO_BOX(time_period_combobox_)); |
| 139 | 143 |
| 140 int items = 0; | 144 int items = 0; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 true : false); | 195 true : false); |
| 192 } else if (widget == del_form_data_checkbox_) { | 196 } else if (widget == del_form_data_checkbox_) { |
| 193 profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData, | 197 profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData, |
| 194 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? | 198 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? |
| 195 true : false); | 199 true : false); |
| 196 } else if (widget == time_period_combobox_) { | 200 } else if (widget == time_period_combobox_) { |
| 197 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, | 201 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, |
| 198 gtk_combo_box_get_active(GTK_COMBO_BOX(widget))); | 202 gtk_combo_box_get_active(GTK_COMBO_BOX(widget))); |
| 199 } | 203 } |
| 200 } | 204 } |
| OLD | NEW |