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

Side by Side Diff: chrome/browser/gtk/sad_tab_gtk.cc

Issue 466016: linux: use TabContents to launch url for link in crash page... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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
« no previous file with comments | « chrome/browser/gtk/sad_tab_gtk.h ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/sad_tab_gtk.h" 5 #include "chrome/browser/gtk/sad_tab_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/gfx/gtk_util.h" 9 #include "app/gfx/gtk_util.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 11 #include "app/resource_bundle.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "chrome/browser/browser_list.h"
14 #include "chrome/browser/gtk/gtk_chrome_link_button.h" 13 #include "chrome/browser/gtk/gtk_chrome_link_button.h"
14 #include "chrome/browser/tab_contents/tab_contents.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 #include "grit/locale_settings.h" 16 #include "grit/locale_settings.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 18
19 namespace { 19 namespace {
20 20
21 // The y offset from the center at which to paint the icon. 21 // The y offset from the center at which to paint the icon.
22 const int kSadTabOffset = -64; 22 const int kSadTabOffset = -64;
23 // The spacing between the icon and the title. 23 // The spacing between the icon and the title.
24 const int kIconTitleSpacing = 20; 24 const int kIconTitleSpacing = 20;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Set text to white. 61 // Set text to white.
62 GdkColor white = gfx::kGdkWhite; 62 GdkColor white = gfx::kGdkWhite;
63 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); 63 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
64 64
65 return label; 65 return label;
66 } 66 }
67 67
68 } // namespace 68 } // namespace
69 69
70 SadTabGtk::SadTabGtk() 70 SadTabGtk::SadTabGtk(TabContents* tab_contents)
71 : width_(0), 71 : width_(0),
72 height_(0) { 72 height_(0),
73 tab_contents_(tab_contents) {
74 DCHECK(tab_contents_);
75
73 // Use an event box to get the background painting correctly. 76 // Use an event box to get the background painting correctly.
74 event_box_.Own(gtk_event_box_new()); 77 event_box_.Own(gtk_event_box_new());
75 gtk_widget_set_app_paintable(event_box_.get(), TRUE); 78 gtk_widget_set_app_paintable(event_box_.get(), TRUE);
76 g_signal_connect(event_box_.get(), "expose-event", 79 g_signal_connect(event_box_.get(), "expose-event",
77 G_CALLBACK(OnBackgroundExposeThunk), this); 80 G_CALLBACK(OnBackgroundExposeThunk), this);
78 // Listen to signal for resizing of widget. 81 // Listen to signal for resizing of widget.
79 g_signal_connect(event_box_.get(), "size-allocate", 82 g_signal_connect(event_box_.get(), "size-allocate",
80 G_CALLBACK(OnSizeAllocateThunk), this); 83 G_CALLBACK(OnSizeAllocateThunk), this);
81 84
82 // Use an alignment to set the top and horizontal paddings. The padding will 85 // Use an alignment to set the top and horizontal paddings. The padding will
(...skipping 20 matching lines...) Expand all
103 sad_tab_constants.title); 106 sad_tab_constants.title);
104 gtk_box_pack_start(GTK_BOX(vbox), title, FALSE, FALSE, kTitleMessageSpacing); 107 gtk_box_pack_start(GTK_BOX(vbox), title, FALSE, FALSE, kTitleMessageSpacing);
105 108
106 // Add center-aligned message. 109 // Add center-aligned message.
107 message_ = MakeWhiteMarkupLabel("<span style=\"normal\">%s</span>", 110 message_ = MakeWhiteMarkupLabel("<span style=\"normal\">%s</span>",
108 sad_tab_constants.message); 111 sad_tab_constants.message);
109 gtk_label_set_line_wrap(GTK_LABEL(message_), TRUE); 112 gtk_label_set_line_wrap(GTK_LABEL(message_), TRUE);
110 gtk_box_pack_start(GTK_BOX(vbox), message_, FALSE, FALSE, 113 gtk_box_pack_start(GTK_BOX(vbox), message_, FALSE, FALSE,
111 kMessageLinkSpacing); 114 kMessageLinkSpacing);
112 115
113 // Add the learn-more link and center-align it in an alignment. 116 if (tab_contents_ != NULL) {
114 GtkWidget* link = gtk_chrome_link_button_new( 117 // Add the learn-more link and center-align it in an alignment.
115 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); 118 GtkWidget* link = gtk_chrome_link_button_new(
116 gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link), 119 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
117 &gfx::kGdkWhite); 120 gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link),
118 g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClick), 121 &gfx::kGdkWhite);
119 const_cast<char*>(sad_tab_constants.learn_more_url.c_str())); 122 g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClickThunk), this);
120 GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); 123 GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
121 gtk_container_add(GTK_CONTAINER(link_alignment), link); 124 gtk_container_add(GTK_CONTAINER(link_alignment), link);
122 gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0); 125 gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0);
126 }
123 127
124 gtk_widget_show_all(event_box_.get()); 128 gtk_widget_show_all(event_box_.get());
125 } 129 }
126 130
127 SadTabGtk::~SadTabGtk() { 131 SadTabGtk::~SadTabGtk() {
128 event_box_.Destroy(); 132 event_box_.Destroy();
129 } 133 }
130 134
131 gboolean SadTabGtk::OnBackgroundExpose( 135 gboolean SadTabGtk::OnBackgroundExpose(
132 GtkWidget* widget, GdkEventExpose* event) { 136 GtkWidget* widget, GdkEventExpose* event) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // Only readjust width for message if width of widget has changed. 174 // Only readjust width for message if width of widget has changed.
171 if (allocation->width != 0 && allocation->width != width_) { 175 if (allocation->width != 0 && allocation->width != width_) {
172 width_ = allocation->width; 176 width_ = allocation->width;
173 // If necessary, set width for wrappable message. 177 // If necessary, set width for wrappable message.
174 int message_width = width_ - (kTabHorzMargin * 2); 178 int message_width = width_ - (kTabHorzMargin * 2);
175 if (message_width > -1) 179 if (message_width > -1)
176 gtk_widget_set_size_request(message_, message_width, -1); 180 gtk_widget_set_size_request(message_, message_width, -1);
177 } 181 }
178 } 182 }
179 183
180 // static 184 void SadTabGtk::OnLinkButtonClick() {
181 void SadTabGtk::OnLinkButtonClick(GtkWidget* button, const char* url) { 185 if (tab_contents_ != NULL) {
182 BrowserList::GetLastActive()->OpenURL(GURL(url), GURL(), CURRENT_TAB, 186 const SadTabGtkConstants& sad_tab_constants = g_sad_tab_constants.Get();
183 PageTransition::LINK); 187 tab_contents_->OpenURL(GURL(sad_tab_constants.learn_more_url.c_str()),
188 GURL(), CURRENT_TAB, PageTransition::LINK);
189 }
184 } 190 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/sad_tab_gtk.h ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698