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

Side by Side Diff: chrome/browser/ui/gtk/instant_confirm_dialog_gtk.cc

Issue 9113033: GTK: More raw struct access removal, this time focusing on GtkDialog. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 11 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) 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/instant_confirm_dialog_gtk.h" 5 #include "chrome/browser/ui/gtk/instant_confirm_dialog_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "chrome/browser/instant/instant_confirm_dialog.h" 9 #include "chrome/browser/instant/instant_confirm_dialog.h"
10 #include "chrome/browser/instant/instant_controller.h" 10 #include "chrome/browser/instant/instant_controller.h"
(...skipping 19 matching lines...) Expand all
30 GtkWindow* parent, Profile* profile) : profile_(profile) { 30 GtkWindow* parent, Profile* profile) : profile_(profile) {
31 dialog_ = gtk_dialog_new_with_buttons( 31 dialog_ = gtk_dialog_new_with_buttons(
32 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_TITLE).c_str(), 32 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_TITLE).c_str(),
33 parent, 33 parent,
34 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), 34 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
35 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, 35 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
36 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, 36 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
37 NULL); 37 NULL);
38 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this); 38 g_signal_connect(dialog_, "response", G_CALLBACK(OnResponseThunk), this);
39 39
40 GtkBox* vbox = GTK_BOX(GTK_DIALOG(dialog_)->vbox); 40 GtkBox* vbox = GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog_)));
41 gtk_box_set_spacing(vbox, ui::kControlSpacing); 41 gtk_box_set_spacing(vbox, ui::kControlSpacing);
42 42
43 GtkWidget* label = gtk_label_new( 43 GtkWidget* label = gtk_label_new(
44 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_MESSAGE).c_str()); 44 l10n_util::GetStringUTF8(IDS_INSTANT_OPT_IN_MESSAGE).c_str());
45 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 45 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
46 gtk_box_pack_start(vbox, label, FALSE, FALSE, 0); 46 gtk_box_pack_start(vbox, label, FALSE, FALSE, 0);
47 47
48 GtkWidget* link_button = gtk_chrome_link_button_new( 48 GtkWidget* link_button = gtk_chrome_link_button_new(
49 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); 49 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
50 g_signal_connect(link_button, "clicked", 50 g_signal_connect(link_button, "clicked",
51 G_CALLBACK(OnLinkButtonClickedThunk), this); 51 G_CALLBACK(OnLinkButtonClickedThunk), this);
52 52
53 GtkWidget* action_area = GTK_DIALOG(dialog_)->action_area; 53 GtkWidget* action_area = gtk_dialog_get_action_area(GTK_DIALOG(dialog_));
54 gtk_container_add(GTK_CONTAINER(action_area), link_button); 54 gtk_container_add(GTK_CONTAINER(action_area), link_button);
55 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(action_area), 55 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(action_area),
56 link_button, 56 link_button,
57 TRUE); 57 TRUE);
58 58
59 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT); 59 gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
60 gtk_widget_show_all(dialog_); 60 gtk_widget_show_all(dialog_);
61 } 61 }
62 62
63 InstantConfirmDialogGtk::~InstantConfirmDialogGtk() { 63 InstantConfirmDialogGtk::~InstantConfirmDialogGtk() {
64 gtk_widget_destroy(dialog_); 64 gtk_widget_destroy(dialog_);
65 } 65 }
66 66
67 void InstantConfirmDialogGtk::OnResponse(GtkWidget* dialog, int response_id) { 67 void InstantConfirmDialogGtk::OnResponse(GtkWidget* dialog, int response_id) {
68 if (response_id == GTK_RESPONSE_ACCEPT) 68 if (response_id == GTK_RESPONSE_ACCEPT)
69 InstantController::Enable(profile_); 69 InstantController::Enable(profile_);
70 70
71 delete this; 71 delete this;
72 } 72 }
73 73
74 void InstantConfirmDialogGtk::OnLinkButtonClicked(GtkWidget* button) { 74 void InstantConfirmDialogGtk::OnLinkButtonClicked(GtkWidget* button) {
75 // We open a new browser window so the Options dialog doesn't get lost behind 75 // We open a new browser window so the Options dialog doesn't get lost behind
76 // other windows. 76 // other windows.
77 Browser* browser = Browser::Create(profile_); 77 Browser* browser = Browser::Create(profile_);
78 browser->AddSelectedTabWithURL(browser::InstantLearnMoreURL(), 78 browser->AddSelectedTabWithURL(browser::InstantLearnMoreURL(),
79 content::PAGE_TRANSITION_LINK); 79 content::PAGE_TRANSITION_LINK);
80 browser->window()->Show(); 80 browser->window()->Show();
81 } 81 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_gtk.cc ('k') | chrome/browser/ui/gtk/task_manager_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698