| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/gtk/instant_confirm_dialog_gtk.h" | |
| 6 | |
| 7 #include <gtk/gtk.h> | |
| 8 | |
| 9 #include "app/l10n_util.h" | |
| 10 #include "chrome/browser/gtk/gtk_chrome_link_button.h" | |
| 11 #include "chrome/browser/gtk/gtk_util.h" | |
| 12 #include "chrome/browser/instant/instant_confirm_dialog.h" | |
| 13 #include "chrome/browser/instant/instant_controller.h" | |
| 14 #include "chrome/browser/profiles/profile.h" | |
| 15 #include "chrome/browser/ui/options/show_options_url.h" | |
| 16 #include "googleurl/src/gurl.h" | |
| 17 #include "grit/chromium_strings.h" | |
| 18 #include "grit/generated_resources.h" | |
| 19 | |
| 20 namespace browser { | |
| 21 | |
| 22 void ShowInstantConfirmDialog(GtkWindow* parent, Profile* profile) { | |
| 23 new InstantConfirmDialogGtk(parent, profile); | |
| 24 } | |
| 25 | |
| 26 } // namespace browser | |
| 27 | |
| 28 InstantConfirmDialogGtk::InstantConfirmDialogGtk( | |
| 29 GtkWindow* parent, Profile* profile) : profile_(profile) { | |
| 30 dialog_ = gtk_dialog_new_with_buttons( | |
| 31 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_TITLE).c_str(), | |
| 32 parent, | |
| 33 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | |
| 34 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | |
| 35 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, | |
| 36 NULL); | |
| 37 g_signal_connect(dialog_, "response", | |
| 38 G_CALLBACK(OnDialogResponseThunk), this); | |
| 39 | |
| 40 GtkBox* vbox = GTK_BOX(GTK_DIALOG(dialog_)->vbox); | |
| 41 gtk_box_set_spacing(vbox, gtk_util::kControlSpacing); | |
| 42 | |
| 43 GtkWidget* label = gtk_label_new( | |
| 44 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_MESSAGE).c_str()); | |
| 45 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 46 gtk_box_pack_start(vbox, label, FALSE, FALSE, 0); | |
| 47 | |
| 48 GtkWidget* link_button = gtk_chrome_link_button_new( | |
| 49 l10n_util::GetStringUTF8(IDS_OPTIONS_LEARN_MORE_LABEL).c_str()); | |
| 50 g_signal_connect(link_button, "clicked", | |
| 51 G_CALLBACK(OnLinkButtonClickedThunk), this); | |
| 52 | |
| 53 GtkWidget* action_area = GTK_DIALOG(dialog_)->action_area; | |
| 54 gtk_container_add(GTK_CONTAINER(action_area), link_button); | |
| 55 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(action_area), | |
| 56 link_button, | |
| 57 TRUE); | |
| 58 | |
| 59 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); | |
| 60 gtk_widget_show_all(dialog_); | |
| 61 } | |
| 62 | |
| 63 InstantConfirmDialogGtk::~InstantConfirmDialogGtk() { | |
| 64 gtk_widget_destroy(dialog_); | |
| 65 } | |
| 66 | |
| 67 void InstantConfirmDialogGtk::OnDialogResponse(GtkWidget* dialog, | |
| 68 int response) { | |
| 69 if (response == GTK_RESPONSE_ACCEPT) | |
| 70 InstantController::Enable(profile_); | |
| 71 | |
| 72 delete this; | |
| 73 } | |
| 74 | |
| 75 void InstantConfirmDialogGtk::OnLinkButtonClicked(GtkWidget* button) { | |
| 76 browser::ShowOptionsURL(profile_, browser::InstantLearnMoreURL()); | |
| 77 } | |
| OLD | NEW |