| 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/confirm_bubble_view.h" | 5 #include "chrome/browser/ui/gtk/confirm_bubble_view.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/confirm_bubble_model.h" | 12 #include "chrome/browser/ui/confirm_bubble_model.h" |
| 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 13 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 14 #include "chrome/browser/ui/gtk/custom_button.h" | 14 #include "chrome/browser/ui/gtk/custom_button.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 15 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 17 #include "chrome/browser/ui/gtk/theme_service_gtk.h" | 17 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
| 18 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 19 #include "ui/base/gtk/gtk_hig_constants.h" | 19 #include "ui/base/gtk/gtk_hig_constants.h" |
| 20 #include "ui/base/gtk/gtk_screen_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Padding between content and edge of bubble. | 26 // Padding between content and edge of bubble. |
| 26 const int kContentBorder = 7; | 27 const int kContentBorder = 7; |
| 27 | 28 |
| 28 // Horizontal spacing between the image view and the label. | 29 // Horizontal spacing between the image view and the label. |
| 29 const int kImageViewSpacing = 5; | 30 const int kImageViewSpacing = 5; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 if (has_ok_button) { | 130 if (has_ok_button) { |
| 130 GtkWidget* ok_button = gtk_button_new_with_label(UTF16ToUTF8( | 131 GtkWidget* ok_button = gtk_button_new_with_label(UTF16ToUTF8( |
| 131 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)).c_str()); | 132 model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)).c_str()); |
| 132 g_signal_connect(ok_button, "clicked", G_CALLBACK(OnOkButtonThunk), this); | 133 g_signal_connect(ok_button, "clicked", G_CALLBACK(OnOkButtonThunk), this); |
| 133 gtk_box_pack_start(GTK_BOX(row), ok_button, FALSE, FALSE, 0); | 134 gtk_box_pack_start(GTK_BOX(row), ok_button, FALSE, FALSE, 0); |
| 134 } | 135 } |
| 135 gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); | 136 gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Show a bubble consisting of the above widgets under the anchor point. | 139 // Show a bubble consisting of the above widgets under the anchor point. |
| 139 gfx::Rect rect = gtk_util::GetWidgetScreenBounds(anchor_); | 140 gfx::Rect rect = ui::GetWidgetScreenBounds(anchor_); |
| 140 rect.set_x(anchor_point_.x() - rect.x()); | 141 rect.set_x(anchor_point_.x() - rect.x()); |
| 141 rect.set_y(anchor_point_.y() - rect.y()); | 142 rect.set_y(anchor_point_.y() - rect.y()); |
| 142 rect.set_width(0); | 143 rect.set_width(0); |
| 143 rect.set_height(0); | 144 rect.set_height(0); |
| 144 bubble_ = BubbleGtk::Show(anchor_, | 145 bubble_ = BubbleGtk::Show(anchor_, |
| 145 &rect, | 146 &rect, |
| 146 content, | 147 content, |
| 147 BubbleGtk::ARROW_LOCATION_NONE, | 148 BubbleGtk::ARROW_LOCATION_NONE, |
| 148 true, // match_system_theme | 149 true, // match_system_theme |
| 149 true, // grab_input | 150 true, // grab_input |
| (...skipping 24 matching lines...) Expand all Loading... |
| 174 // click this button. We should ask the model if we can close this view. | 175 // click this button. We should ask the model if we can close this view. |
| 175 bubble_->Close(); | 176 bubble_->Close(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void ConfirmBubbleView::OnLinkButton(GtkWidget* sender) { | 179 void ConfirmBubbleView::OnLinkButton(GtkWidget* sender) { |
| 179 model_->LinkClicked(); | 180 model_->LinkClicked(); |
| 180 // TODO(hbono): this code prevents the model from updating this view when we | 181 // TODO(hbono): this code prevents the model from updating this view when we |
| 181 // click this link. We should ask the model if we can close this view. | 182 // click this link. We should ask the model if we can close this view. |
| 182 bubble_->Close(); | 183 bubble_->Close(); |
| 183 } | 184 } |
| OLD | NEW |