| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sad_tab_gtk.h" | 5 #include "chrome/browser/ui/gtk/sad_tab_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" | 10 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #include "grit/locale_settings.h" | 15 #include "grit/locale_settings.h" |
| 15 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 16 #include "ui/base/gtk/gtk_hig_constants.h" | |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Background color of the content (a grayish blue) for a crashed tab. | 23 // Background color of the content (a grayish blue) for a crashed tab. |
| 24 const GdkColor kCrashedBackgroundColor = GDK_COLOR_RGB(35, 48, 64); | 24 const GdkColor kCrashedBackgroundColor = GDK_COLOR_RGB(35, 48, 64); |
| 25 | 25 |
| 26 // Background color of the content (a grayish purple) for a killed | 26 // Background color of the content (a grayish purple) for a killed |
| 27 // tab. TODO(gspencer): update this for the "real" color when the UI | 27 // tab. TODO(gspencer): update this for the "real" color when the UI |
| 28 // team provides one. See http://crosbug.com/10711 | 28 // team provides one. See http://crosbug.com/10711 |
| 29 const GdkColor kKilledBackgroundColor = GDK_COLOR_RGB(57, 48, 88); | 29 const GdkColor kKilledBackgroundColor = GDK_COLOR_RGB(57, 48, 88); |
| 30 | 30 |
| 31 // Construct a centered GtkLabel with a white foreground. | 31 // Construct a centered GtkLabel with a white foreground. |
| 32 // |format| is a printf-style format containing a %s; | 32 // |format| is a printf-style format containing a %s; |
| 33 // |str| is substituted into the format. | 33 // |str| is substituted into the format. |
| 34 GtkWidget* MakeWhiteMarkupLabel(const char* format, const std::string& str) { | 34 GtkWidget* MakeWhiteMarkupLabel(const char* format, const std::string& str) { |
| 35 GtkWidget* label = gtk_label_new(NULL); | 35 GtkWidget* label = gtk_label_new(NULL); |
| 36 char* markup = g_markup_printf_escaped(format, str.c_str()); | 36 char* markup = g_markup_printf_escaped(format, str.c_str()); |
| 37 gtk_label_set_markup(GTK_LABEL(label), markup); | 37 gtk_label_set_markup(GTK_LABEL(label), markup); |
| 38 g_free(markup); | 38 g_free(markup); |
| 39 | 39 |
| 40 // Center align and justify it. | 40 // Center align and justify it. |
| 41 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); | 41 gtk_misc_set_alignment(GTK_MISC(label), 0.5, 0.5); |
| 42 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); | 42 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER); |
| 43 | 43 |
| 44 // Set text to white. | 44 // Set text to white. |
| 45 GdkColor white = ui::kGdkWhite; | 45 GdkColor white = gtk_util::kGdkWhite; |
| 46 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); | 46 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white); |
| 47 | 47 |
| 48 return label; | 48 return label; |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 SadTabGtk::SadTabGtk(TabContents* tab_contents, Kind kind) | 53 SadTabGtk::SadTabGtk(TabContents* tab_contents, Kind kind) |
| 54 : tab_contents_(tab_contents), | 54 : tab_contents_(tab_contents), |
| 55 kind_(kind) { | 55 kind_(kind) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 // Add spacer between message and link. | 107 // Add spacer between message and link. |
| 108 spacer = gtk_label_new(" "); | 108 spacer = gtk_label_new(" "); |
| 109 gtk_box_pack_start(GTK_BOX(vbox), spacer, FALSE, FALSE, 0); | 109 gtk_box_pack_start(GTK_BOX(vbox), spacer, FALSE, FALSE, 0); |
| 110 | 110 |
| 111 if (tab_contents_ != NULL) { | 111 if (tab_contents_ != NULL) { |
| 112 // Add the learn-more link and center-align it in an alignment. | 112 // Add the learn-more link and center-align it in an alignment. |
| 113 GtkWidget* link = gtk_chrome_link_button_new( | 113 GtkWidget* link = gtk_chrome_link_button_new( |
| 114 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); | 114 l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str()); |
| 115 gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link), | 115 gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link), |
| 116 &ui::kGdkWhite); | 116 >k_util::kGdkWhite); |
| 117 g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClickThunk), this); | 117 g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClickThunk), this); |
| 118 GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); | 118 GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0); |
| 119 gtk_container_add(GTK_CONTAINER(link_alignment), link); | 119 gtk_container_add(GTK_CONTAINER(link_alignment), link); |
| 120 gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0); | 120 gtk_box_pack_start(GTK_BOX(vbox), link_alignment, FALSE, FALSE, 0); |
| 121 } | 121 } |
| 122 | 122 |
| 123 gtk_widget_show_all(event_box_.get()); | 123 gtk_widget_show_all(event_box_.get()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 SadTabGtk::~SadTabGtk() { | 126 SadTabGtk::~SadTabGtk() { |
| 127 event_box_.Destroy(); | 127 event_box_.Destroy(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SadTabGtk::OnLinkButtonClick(GtkWidget* sender) { | 130 void SadTabGtk::OnLinkButtonClick(GtkWidget* sender) { |
| 131 if (tab_contents_ != NULL) { | 131 if (tab_contents_ != NULL) { |
| 132 GURL help_url = | 132 GURL help_url = |
| 133 google_util::AppendGoogleLocaleParam(GURL( | 133 google_util::AppendGoogleLocaleParam(GURL( |
| 134 kind_ == CRASHED ? | 134 kind_ == CRASHED ? |
| 135 chrome::kCrashReasonURL : | 135 chrome::kCrashReasonURL : |
| 136 chrome::kKillReasonURL)); | 136 chrome::kKillReasonURL)); |
| 137 tab_contents_->OpenURL(help_url, GURL(), CURRENT_TAB, PageTransition::LINK); | 137 tab_contents_->OpenURL(help_url, GURL(), CURRENT_TAB, PageTransition::LINK); |
| 138 } | 138 } |
| 139 } | 139 } |
| OLD | NEW |