| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tab_modal_confirm_dialog_gtk.h" | 5 #include "chrome/browser/ui/gtk/tab_modal_confirm_dialog_gtk.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/browser_dialogs.h" | 9 #include "chrome/browser/ui/browser_dialogs.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 10 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 12 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
| 14 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 15 #include "ui/base/gtk/gtk_hig_constants.h" | 14 #include "ui/base/gtk/gtk_hig_constants.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/gfx/image/image.h" | 16 #include "ui/gfx/image/image.h" |
| 18 | 17 |
| 19 TabModalConfirmDialog* TabModalConfirmDialog::Create( | 18 TabModalConfirmDialog* TabModalConfirmDialog::Create( |
| 20 TabModalConfirmDialogDelegate* delegate, | 19 TabModalConfirmDialogDelegate* delegate, |
| 21 TabContents* tab_contents) { | 20 content::WebContents* web_contents) { |
| 22 return new TabModalConfirmDialogGtk(delegate, tab_contents); | 21 return new TabModalConfirmDialogGtk(delegate, web_contents); |
| 23 } | 22 } |
| 24 | 23 |
| 25 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk( | 24 TabModalConfirmDialogGtk::TabModalConfirmDialogGtk( |
| 26 TabModalConfirmDialogDelegate* delegate, | 25 TabModalConfirmDialogDelegate* delegate, |
| 27 TabContents* tab_contents) | 26 content::WebContents* web_contents) |
| 28 : delegate_(delegate) { | 27 : delegate_(delegate) { |
| 29 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 28 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| 30 GtkWidget* label = gtk_label_new( | 29 GtkWidget* label = gtk_label_new( |
| 31 UTF16ToUTF8(delegate->GetMessage()).c_str()); | 30 UTF16ToUTF8(delegate->GetMessage()).c_str()); |
| 32 gfx::Image* icon = delegate->GetIcon(); | 31 gfx::Image* icon = delegate->GetIcon(); |
| 33 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf()) | 32 GtkWidget* image = icon ? gtk_image_new_from_pixbuf(icon->ToGdkPixbuf()) |
| 34 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, | 33 : gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION, |
| 35 GTK_ICON_SIZE_DIALOG); | 34 GTK_ICON_SIZE_DIALOG); |
| 36 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); | 35 gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); |
| 37 | 36 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 64 ok_ = gtk_button_new_with_label( | 63 ok_ = gtk_button_new_with_label( |
| 65 UTF16ToUTF8(delegate->GetAcceptButtonTitle()).c_str()); | 64 UTF16ToUTF8(delegate->GetAcceptButtonTitle()).c_str()); |
| 66 const char* accept_button_icon_id = delegate->GetAcceptButtonIcon(); | 65 const char* accept_button_icon_id = delegate->GetAcceptButtonIcon(); |
| 67 if (accept_button_icon_id) { | 66 if (accept_button_icon_id) { |
| 68 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock( | 67 gtk_button_set_image(GTK_BUTTON(ok_), gtk_image_new_from_stock( |
| 69 accept_button_icon_id, GTK_ICON_SIZE_BUTTON)); | 68 accept_button_icon_id, GTK_ICON_SIZE_BUTTON)); |
| 70 } | 69 } |
| 71 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this); | 70 g_signal_connect(ok_, "clicked", G_CALLBACK(OnAcceptThunk), this); |
| 72 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0); | 71 gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0); |
| 73 | 72 |
| 74 delegate->set_window( | 73 delegate->set_window(new ConstrainedWindowGtk(web_contents, this)); |
| 75 new ConstrainedWindowGtk(tab_contents->web_contents(), this)); | |
| 76 } | 74 } |
| 77 | 75 |
| 78 GtkWidget* TabModalConfirmDialogGtk::GetWidgetRoot() { | 76 GtkWidget* TabModalConfirmDialogGtk::GetWidgetRoot() { |
| 79 return dialog_; | 77 return dialog_; |
| 80 } | 78 } |
| 81 | 79 |
| 82 GtkWidget* TabModalConfirmDialogGtk::GetFocusWidget() { | 80 GtkWidget* TabModalConfirmDialogGtk::GetFocusWidget() { |
| 83 return cancel_; | 81 return cancel_; |
| 84 } | 82 } |
| 85 | 83 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 OnCancel(NULL); | 97 OnCancel(NULL); |
| 100 } | 98 } |
| 101 | 99 |
| 102 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) { | 100 void TabModalConfirmDialogGtk::OnAccept(GtkWidget* widget) { |
| 103 delegate_->Accept(); | 101 delegate_->Accept(); |
| 104 } | 102 } |
| 105 | 103 |
| 106 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) { | 104 void TabModalConfirmDialogGtk::OnCancel(GtkWidget* widget) { |
| 107 delegate_->Cancel(); | 105 delegate_->Cancel(); |
| 108 } | 106 } |
| OLD | NEW |