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

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

Issue 14262009: Add support for multi-line GlobalError messages to Views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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/global_error_bubble.h" 5 #include "chrome/browser/ui/gtk/global_error_bubble.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 GtkThemeService::GetFrom(browser_->profile()); 48 GtkThemeService::GetFrom(browser_->profile());
49 49
50 int resource_id = error_->GetBubbleViewIconResourceID(); 50 int resource_id = error_->GetBubbleViewIconResourceID();
51 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 51 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
52 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(resource_id).ToGdkPixbuf(); 52 GdkPixbuf* pixbuf = rb.GetNativeImageNamed(resource_id).ToGdkPixbuf();
53 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf); 53 GtkWidget* image_view = gtk_image_new_from_pixbuf(pixbuf);
54 54
55 GtkWidget* title_label = theme_service->BuildLabel( 55 GtkWidget* title_label = theme_service->BuildLabel(
56 UTF16ToUTF8(error_->GetBubbleViewTitle()), 56 UTF16ToUTF8(error_->GetBubbleViewTitle()),
57 ui::kGdkBlack); 57 ui::kGdkBlack);
58 // TODO(yoz): Support multi-line messages.
59 string16 message;
60 if (!error_->GetBubbleViewMessages().empty())
61 message = error_->GetBubbleViewMessages()[0];
58 message_label_ = theme_service->BuildLabel( 62 message_label_ = theme_service->BuildLabel(
59 UTF16ToUTF8(error_->GetBubbleViewMessage()), 63 UTF16ToUTF8(message),
60 ui::kGdkBlack); 64 ui::kGdkBlack);
61 gtk_util::ForceFontSizePixels(message_label_, kMessageTextSize); 65 gtk_util::ForceFontSizePixels(message_label_, kMessageTextSize);
62 // Message label will be sized later in "realize" callback because we need 66 // Message label will be sized later in "realize" callback because we need
63 // to now the width of buttons group. 67 // to now the width of buttons group.
64 GtkWidget* accept_button = gtk_button_new_with_label( 68 GtkWidget* accept_button = gtk_button_new_with_label(
65 UTF16ToUTF8(error_->GetBubbleViewAcceptButtonLabel()).c_str()); 69 UTF16ToUTF8(error_->GetBubbleViewAcceptButtonLabel()).c_str());
66 string16 cancel_string = error_->GetBubbleViewCancelButtonLabel(); 70 string16 cancel_string = error_->GetBubbleViewCancelButtonLabel();
67 GtkWidget* cancel_button = NULL; 71 GtkWidget* cancel_button = NULL;
68 if (!cancel_string.empty()) { 72 if (!cancel_string.empty()) {
69 cancel_button = 73 cancel_button =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 Browser* browser, 155 Browser* browser,
152 const base::WeakPtr<GlobalError>& error) { 156 const base::WeakPtr<GlobalError>& error) {
153 BrowserWindowGtk* browser_window = 157 BrowserWindowGtk* browser_window =
154 BrowserWindowGtk::GetBrowserWindowForNativeWindow( 158 BrowserWindowGtk::GetBrowserWindowForNativeWindow(
155 browser->window()->GetNativeWindow()); 159 browser->window()->GetNativeWindow());
156 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton(); 160 GtkWidget* anchor = browser_window->GetToolbar()->GetAppMenuButton();
157 161
158 // The bubble will be automatically deleted when it's closed. 162 // The bubble will be automatically deleted when it's closed.
159 return new GlobalErrorBubble(browser, error, anchor); 163 return new GlobalErrorBubble(browser, error, anchor);
160 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698