| 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_gtk.h" |    5 #include "chrome/browser/ui/gtk/confirm_bubble_gtk.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/strings/utf_string_conversions.h" |   10 #include "base/strings/utf_string_conversions.h" | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   74   gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); |   74   gtk_container_set_border_width(GTK_CONTAINER(content), kContentBorder); | 
|   75   g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this); |   75   g_signal_connect(content, "destroy", G_CALLBACK(OnDestroyThunk), this); | 
|   76  |   76  | 
|   77   // Add the icon, the title label and the close button to the first row. |   77   // Add the icon, the title label and the close button to the first row. | 
|   78   GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); |   78   GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); | 
|   79   GtkWidget* icon_view = |   79   GtkWidget* icon_view = | 
|   80       gtk_image_new_from_pixbuf(model_->GetIcon()->ToGdkPixbuf()); |   80       gtk_image_new_from_pixbuf(model_->GetIcon()->ToGdkPixbuf()); | 
|   81   gtk_box_pack_start(GTK_BOX(row), icon_view, FALSE, FALSE, 0); |   81   gtk_box_pack_start(GTK_BOX(row), icon_view, FALSE, FALSE, 0); | 
|   82  |   82  | 
|   83   GtkWidget* title_label = theme_service->BuildLabel( |   83   GtkWidget* title_label = theme_service->BuildLabel( | 
|   84       UTF16ToUTF8(model_->GetTitle()), ui::kGdkBlack); |   84       base::UTF16ToUTF8(model_->GetTitle()), ui::kGdkBlack); | 
|   85   gtk_box_pack_start(GTK_BOX(row), title_label, FALSE, FALSE, 0); |   85   gtk_box_pack_start(GTK_BOX(row), title_label, FALSE, FALSE, 0); | 
|   86   gtk_box_pack_start(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); |   86   gtk_box_pack_start(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); | 
|   87  |   87  | 
|   88   close_button_.reset(CustomDrawButton::CloseButtonBubble(theme_service)); |   88   close_button_.reset(CustomDrawButton::CloseButtonBubble(theme_service)); | 
|   89   g_signal_connect(close_button_->widget(), "clicked", |   89   g_signal_connect(close_button_->widget(), "clicked", | 
|   90                    G_CALLBACK(OnCloseButtonThunk), this); |   90                    G_CALLBACK(OnCloseButtonThunk), this); | 
|   91   gtk_box_pack_end(GTK_BOX(row), close_button_->widget(), FALSE, FALSE, 0); |   91   gtk_box_pack_end(GTK_BOX(row), close_button_->widget(), FALSE, FALSE, 0); | 
|   92   gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); |   92   gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); | 
|   93  |   93  | 
|   94   // Add the message label to the second row. |   94   // Add the message label to the second row. | 
|   95   GtkWidget* message_label = theme_service->BuildLabel( |   95   GtkWidget* message_label = theme_service->BuildLabel( | 
|   96       UTF16ToUTF8(model_->GetMessageText()), ui::kGdkBlack); |   96       base::UTF16ToUTF8(model_->GetMessageText()), ui::kGdkBlack); | 
|   97   gtk_util::ForceFontSizePixels(message_label, kMessageTextSize); |   97   gtk_util::ForceFontSizePixels(message_label, kMessageTextSize); | 
|   98   gtk_util::SetLabelWidth(message_label, kMaxMessageWidth); |   98   gtk_util::SetLabelWidth(message_label, kMaxMessageWidth); | 
|   99   gtk_box_pack_start(GTK_BOX(content), message_label, FALSE, FALSE, 0); |   99   gtk_box_pack_start(GTK_BOX(content), message_label, FALSE, FALSE, 0); | 
|  100  |  100  | 
|  101   // Add the the link label to the third row if it exists. |  101   // Add the the link label to the third row if it exists. | 
|  102   const base::string16 link_text = model_->GetLinkText(); |  102   const base::string16 link_text = model_->GetLinkText(); | 
|  103   if (!link_text.empty()) { |  103   if (!link_text.empty()) { | 
|  104     GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); |  104     GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); | 
|  105     GtkWidget* link_button = gtk_chrome_link_button_new( |  105     GtkWidget* link_button = gtk_chrome_link_button_new( | 
|  106         UTF16ToUTF8(link_text).c_str()); |  106         base::UTF16ToUTF8(link_text).c_str()); | 
|  107     g_signal_connect(link_button, "clicked", G_CALLBACK(OnLinkButtonThunk), |  107     g_signal_connect(link_button, "clicked", G_CALLBACK(OnLinkButtonThunk), | 
|  108                      this); |  108                      this); | 
|  109     gtk_util::ForceFontSizePixels(link_button, kMessageTextSize); |  109     gtk_util::ForceFontSizePixels(link_button, kMessageTextSize); | 
|  110     gtk_box_pack_start(GTK_BOX(row), link_button, FALSE, FALSE, 0); |  110     gtk_box_pack_start(GTK_BOX(row), link_button, FALSE, FALSE, 0); | 
|  111     gtk_box_pack_end(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); |  111     gtk_box_pack_end(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); | 
|  112     gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); |  112     gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); | 
|  113   } |  113   } | 
|  114  |  114  | 
|  115   bool has_ok_button = !!(model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK); |  115   bool has_ok_button = !!(model_->GetButtons() & ConfirmBubbleModel::BUTTON_OK); | 
|  116   bool has_cancel_button = |  116   bool has_cancel_button = | 
|  117       !!(model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL); |  117       !!(model_->GetButtons() & ConfirmBubbleModel::BUTTON_CANCEL); | 
|  118   if (has_ok_button || has_cancel_button) { |  118   if (has_ok_button || has_cancel_button) { | 
|  119     GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); |  119     GtkWidget* row = gtk_hbox_new(FALSE, kImageViewSpacing); | 
|  120     gtk_box_pack_start(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); |  120     gtk_box_pack_start(GTK_BOX(row), gtk_label_new(NULL), TRUE, TRUE, 0); | 
|  121     if (has_cancel_button) { |  121     if (has_cancel_button) { | 
|  122       GtkWidget* cancel_button = gtk_button_new_with_label(UTF16ToUTF8( |  122       GtkWidget* cancel_button = gtk_button_new_with_label(base::UTF16ToUTF8( | 
|  123           model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL)).c_str()); |  123           model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_CANCEL)).c_str()); | 
|  124       g_signal_connect(cancel_button, "clicked", |  124       g_signal_connect(cancel_button, "clicked", | 
|  125                        G_CALLBACK(OnCancelButtonThunk), this); |  125                        G_CALLBACK(OnCancelButtonThunk), this); | 
|  126       gtk_box_pack_start(GTK_BOX(row), cancel_button, FALSE, FALSE, 0); |  126       gtk_box_pack_start(GTK_BOX(row), cancel_button, FALSE, FALSE, 0); | 
|  127     } |  127     } | 
|  128     if (has_ok_button) { |  128     if (has_ok_button) { | 
|  129       GtkWidget* ok_button = gtk_button_new_with_label(UTF16ToUTF8( |  129       GtkWidget* ok_button = gtk_button_new_with_label(base::UTF16ToUTF8( | 
|  130           model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)).c_str()); |  130           model_->GetButtonLabel(ConfirmBubbleModel::BUTTON_OK)).c_str()); | 
|  131       g_signal_connect(ok_button, "clicked", G_CALLBACK(OnOkButtonThunk), this); |  131       g_signal_connect(ok_button, "clicked", G_CALLBACK(OnOkButtonThunk), this); | 
|  132       gtk_box_pack_start(GTK_BOX(row), ok_button, FALSE, FALSE, 0); |  132       gtk_box_pack_start(GTK_BOX(row), ok_button, FALSE, FALSE, 0); | 
|  133     } |  133     } | 
|  134     gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); |  134     gtk_box_pack_start(GTK_BOX(content), row, FALSE, FALSE, 0); | 
|  135   } |  135   } | 
|  136  |  136  | 
|  137   // Show a bubble consisting of the above widgets under the anchor point. |  137   // Show a bubble consisting of the above widgets under the anchor point. | 
|  138   gfx::Rect rect = ui::GetWidgetScreenBounds(anchor_); |  138   gfx::Rect rect = ui::GetWidgetScreenBounds(anchor_); | 
|  139   rect.set_x(anchor_point_.x() - rect.x()); |  139   rect.set_x(anchor_point_.x() - rect.x()); | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  185 namespace chrome { |  185 namespace chrome { | 
|  186  |  186  | 
|  187 void ShowConfirmBubble(gfx::NativeView view, |  187 void ShowConfirmBubble(gfx::NativeView view, | 
|  188                        const gfx::Point& origin, |  188                        const gfx::Point& origin, | 
|  189                        ConfirmBubbleModel* model) { |  189                        ConfirmBubbleModel* model) { | 
|  190   ConfirmBubbleGtk* bubble = new ConfirmBubbleGtk(view, origin, model); |  190   ConfirmBubbleGtk* bubble = new ConfirmBubbleGtk(view, origin, model); | 
|  191   bubble->Show(); |  191   bubble->Show(); | 
|  192 } |  192 } | 
|  193  |  193  | 
|  194 }  // namespace chrome |  194 }  // namespace chrome | 
| OLD | NEW |