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

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

Issue 155454: Make chrome version legible in about:chrome dialog for dark themes.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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/about_chrome_dialog.h" 5 #include "chrome/browser/gtk/about_chrome_dialog.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 28 matching lines...) Expand all
39 // These are used as placeholder text around the links in the text in the about 39 // These are used as placeholder text around the links in the text in the about
40 // dialog. 40 // dialog.
41 const char* kBeginLinkChr = "BEGIN_LINK_CHR"; 41 const char* kBeginLinkChr = "BEGIN_LINK_CHR";
42 const char* kBeginLinkOss = "BEGIN_LINK_OSS"; 42 const char* kBeginLinkOss = "BEGIN_LINK_OSS";
43 // We don't actually use this one. 43 // We don't actually use this one.
44 // const char* kEndLinkChr = "END_LINK_CHR"; 44 // const char* kEndLinkChr = "END_LINK_CHR";
45 const char* kEndLinkOss = "END_LINK_OSS"; 45 const char* kEndLinkOss = "END_LINK_OSS";
46 const char* kBeginLink = "BEGIN_LINK"; 46 const char* kBeginLink = "BEGIN_LINK";
47 const char* kEndLink = "END_LINK"; 47 const char* kEndLink = "END_LINK";
48 48
49 const char* kSmaller = "<span size=\"smaller\">%s</span>";
50
49 void OnDialogResponse(GtkDialog* dialog, int response_id) { 51 void OnDialogResponse(GtkDialog* dialog, int response_id) {
50 // We're done. 52 // We're done.
51 gtk_widget_destroy(GTK_WIDGET(dialog)); 53 gtk_widget_destroy(GTK_WIDGET(dialog));
52 } 54 }
53 55
54 void FixLabelWrappingCallback(GtkWidget *label, 56 void FixLabelWrappingCallback(GtkWidget *label,
55 GtkAllocation *allocation, 57 GtkAllocation *allocation,
56 gpointer data) { 58 gpointer data) {
57 gtk_widget_set_size_request(label, allocation->width, -1); 59 gtk_widget_set_size_request(label, allocation->width, -1);
58 } 60 }
(...skipping 13 matching lines...) Expand all
72 void OnLinkButtonClick(GtkWidget* button, const char* url) { 74 void OnLinkButtonClick(GtkWidget* button, const char* url) {
73 BrowserList::GetLastActive()-> 75 BrowserList::GetLastActive()->
74 OpenURL(GURL(url), GURL(), NEW_WINDOW, PageTransition::LINK); 76 OpenURL(GURL(url), GURL(), NEW_WINDOW, PageTransition::LINK);
75 } 77 }
76 78
77 const char* GetChromiumUrl() { 79 const char* GetChromiumUrl() {
78 static std::string url(l10n_util::GetStringUTF8(IDS_CHROMIUM_PROJECT_URL)); 80 static std::string url(l10n_util::GetStringUTF8(IDS_CHROMIUM_PROJECT_URL));
79 return url.c_str(); 81 return url.c_str();
80 } 82 }
81 83
84 std::string Smaller(const std::string& text) {
85 return std::string("<span size=\"smaller\">") + text + std::string("</span>");
86 }
87
82 } // namespace 88 } // namespace
83 89
84 void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) { 90 void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) {
85 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 91 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
86 static GdkPixbuf* background = rb.GetPixbufNamed(IDR_ABOUT_BACKGROUND); 92 static GdkPixbuf* background = rb.GetPixbufNamed(IDR_ABOUT_BACKGROUND);
87 scoped_ptr<FileVersionInfo> version_info( 93 scoped_ptr<FileVersionInfo> version_info(
88 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); 94 FileVersionInfo::CreateFileVersionInfoForCurrentModule());
89 std::wstring current_version = version_info->file_version(); 95 std::wstring current_version = version_info->file_version();
90 #if !defined(GOOGLE_CHROME_BUILD) 96 #if !defined(GOOGLE_CHROME_BUILD)
91 current_version += L" ("; 97 current_version += L" (";
(...skipping 22 matching lines...) Expand all
114 120
115 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); 121 GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
116 122
117 GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); 123 GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
118 gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment), 124 gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment),
119 kPanelVertMargin, kPanelVertMargin, 125 kPanelVertMargin, kPanelVertMargin,
120 kPanelHorizMargin, kPanelHorizMargin); 126 kPanelHorizMargin, kPanelHorizMargin);
121 127
122 GtkWidget* text_vbox = gtk_vbox_new(FALSE, kExtraLineSpacing); 128 GtkWidget* text_vbox = gtk_vbox_new(FALSE, kExtraLineSpacing);
123 129
130 GdkColor black = gfx::kGdkBlack;
124 GtkWidget* product_label = MakeMarkupLabel( 131 GtkWidget* product_label = MakeMarkupLabel(
125 "<span font_desc=\"18\" weight=\"bold\" style=\"normal\">%s</span>", 132 "<span font_desc=\"18\" weight=\"bold\" style=\"normal\">%s</span>",
126 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); 133 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME));
134 gtk_widget_modify_fg(product_label, GTK_STATE_NORMAL, &black);
127 gtk_box_pack_start(GTK_BOX(text_vbox), product_label, FALSE, FALSE, 0); 135 gtk_box_pack_start(GTK_BOX(text_vbox), product_label, FALSE, FALSE, 0);
128 136
129 GtkWidget* version_label = gtk_label_new(WideToUTF8(current_version).c_str()); 137 GtkWidget* version_label = gtk_label_new(WideToUTF8(current_version).c_str());
130 gtk_misc_set_alignment(GTK_MISC(version_label), 0.0, 0.5); 138 gtk_misc_set_alignment(GTK_MISC(version_label), 0.0, 0.5);
131 gtk_label_set_selectable(GTK_LABEL(version_label), TRUE); 139 gtk_label_set_selectable(GTK_LABEL(version_label), TRUE);
140 gtk_widget_modify_fg(version_label, GTK_STATE_NORMAL, &black);
132 gtk_box_pack_start(GTK_BOX(text_vbox), version_label, FALSE, FALSE, 0); 141 gtk_box_pack_start(GTK_BOX(text_vbox), version_label, FALSE, FALSE, 0);
133 142
134 gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox); 143 gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox);
135 gtk_box_pack_start(GTK_BOX(hbox), text_alignment, TRUE, TRUE, 0); 144 gtk_box_pack_start(GTK_BOX(hbox), text_alignment, TRUE, TRUE, 0);
136 145
137 GtkWidget* image_vbox = gtk_vbox_new(FALSE, 0); 146 GtkWidget* image_vbox = gtk_vbox_new(FALSE, 0);
138 gtk_box_pack_end(GTK_BOX(image_vbox), 147 gtk_box_pack_end(GTK_BOX(image_vbox),
139 gtk_image_new_from_pixbuf(background), 148 gtk_image_new_from_pixbuf(background),
140 FALSE, FALSE, 0); 149 FALSE, FALSE, 0);
141 150
142 gtk_box_pack_start(GTK_BOX(hbox), image_vbox, FALSE, FALSE, 0); 151 gtk_box_pack_start(GTK_BOX(hbox), image_vbox, FALSE, FALSE, 0);
143 gtk_container_add(GTK_CONTAINER(ebox), hbox); 152 gtk_container_add(GTK_CONTAINER(ebox), hbox);
144 gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0); 153 gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0);
145 154
146 // We use a separate box for the licensing etc. text. See the comment near 155 // We use a separate box for the licensing etc. text. See the comment near
147 // the top of this function about using a special layout for this dialog. 156 // the top of this function about using a special layout for this dialog.
148 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 157 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
149 gtk_container_set_border_width(GTK_CONTAINER(vbox), 158 gtk_container_set_border_width(GTK_CONTAINER(vbox),
150 gtk_util::kContentAreaBorder); 159 gtk_util::kContentAreaBorder);
151 160
152 GtkWidget* copyright_label = MakeMarkupLabel( 161 GtkWidget* copyright_label = MakeMarkupLabel(
153 "<span size=\"smaller\">%s</span>", 162 kSmaller, l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_COPYRIGHT));
154 l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_COPYRIGHT));
155 gtk_box_pack_start(GTK_BOX(vbox), copyright_label, TRUE, TRUE, 5); 163 gtk_box_pack_start(GTK_BOX(vbox), copyright_label, TRUE, TRUE, 5);
156 164
157 std::string license = l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_LICENSE); 165 std::string license = l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_LICENSE);
158 bool chromium_url_appears_first = 166 bool chromium_url_appears_first =
159 license.find(kBeginLinkChr) < license.find(kBeginLinkOss); 167 license.find(kBeginLinkChr) < license.find(kBeginLinkOss);
160 size_t link1 = license.find(kBeginLink); 168 size_t link1 = license.find(kBeginLink);
161 DCHECK(link1 != std::string::npos); 169 DCHECK(link1 != std::string::npos);
162 size_t link1_end = license.find(kEndLink, link1); 170 size_t link1_end = license.find(kEndLink, link1);
163 DCHECK(link1_end != std::string::npos); 171 DCHECK(link1_end != std::string::npos);
164 size_t link2 = license.find(kBeginLink, link1_end); 172 size_t link2 = license.find(kBeginLink, link1_end);
165 DCHECK(link2 != std::string::npos); 173 DCHECK(link2 != std::string::npos);
166 size_t link2_end = license.find(kEndLink, link2); 174 size_t link2_end = license.find(kEndLink, link2);
167 DCHECK(link1_end != std::string::npos); 175 DCHECK(link1_end != std::string::npos);
168 176
169 GtkWidget* license_chunk1 = MakeMarkupLabel( 177 GtkWidget* license_chunk1 = MakeMarkupLabel(
170 "<span size=\"smaller\">%s</span>", 178 kSmaller, license.substr(0, link1));
171 license.substr(0, link1));
172 GtkWidget* license_chunk2 = MakeMarkupLabel( 179 GtkWidget* license_chunk2 = MakeMarkupLabel(
173 "<span size=\"smaller\">%s</span>", 180 kSmaller,
174 license.substr(link1_end + strlen(kEndLinkOss), 181 license.substr(link1_end + strlen(kEndLinkOss),
175 link2 - link1_end - strlen(kEndLinkOss))); 182 link2 - link1_end - strlen(kEndLinkOss)));
176 GtkWidget* license_chunk3 = MakeMarkupLabel( 183 GtkWidget* license_chunk3 = MakeMarkupLabel(
177 "<span size=\"smaller\">%s</span>", 184 kSmaller, license.substr(link2_end + strlen(kEndLinkOss)));
178 license.substr(link2_end + strlen(kEndLinkOss)));
179 185
180 std::string first_link_text = 186 std::string first_link_text = Smaller(
181 std::string("<span size=\"smaller\">") +
182 license.substr(link1 + strlen(kBeginLinkOss), 187 license.substr(link1 + strlen(kBeginLinkOss),
183 link1_end - link1 - strlen(kBeginLinkOss)) + 188 link1_end - link1 - strlen(kBeginLinkOss)));
184 std::string("</span>"); 189 std::string second_link_text = Smaller(
185 std::string second_link_text =
186 std::string("<span size=\"smaller\">") +
187 license.substr(link2 + strlen(kBeginLinkOss), 190 license.substr(link2 + strlen(kBeginLinkOss),
188 link2_end - link2 - strlen(kBeginLinkOss)) + 191 link2_end - link2 - strlen(kBeginLinkOss)));
189 std::string("</span>");
190 192
191 GtkWidget* first_link = 193 GtkWidget* first_link =
192 gtk_chrome_link_button_new_with_markup(first_link_text.c_str()); 194 gtk_chrome_link_button_new_with_markup(first_link_text.c_str());
193 GtkWidget* second_link = 195 GtkWidget* second_link =
194 gtk_chrome_link_button_new_with_markup(second_link_text.c_str()); 196 gtk_chrome_link_button_new_with_markup(second_link_text.c_str());
195 if (!chromium_url_appears_first) { 197 if (!chromium_url_appears_first) {
196 GtkWidget* swap = second_link; 198 GtkWidget* swap = second_link;
197 second_link = first_link; 199 second_link = first_link;
198 first_link = swap; 200 first_link = swap;
199 } 201 }
(...skipping 19 matching lines...) Expand all
219 GtkWidget* license_hbox2 = gtk_hbox_new(FALSE, 0); 221 GtkWidget* license_hbox2 = gtk_hbox_new(FALSE, 0);
220 gtk_box_pack_start(GTK_BOX(license_hbox2), second_link, 222 gtk_box_pack_start(GTK_BOX(license_hbox2), second_link,
221 FALSE, FALSE, 0); 223 FALSE, FALSE, 0);
222 gtk_box_pack_start(GTK_BOX(license_hbox2), license_chunk3, 224 gtk_box_pack_start(GTK_BOX(license_hbox2), license_chunk3,
223 FALSE, FALSE, 0); 225 FALSE, FALSE, 0);
224 226
225 GtkWidget* license_vbox = gtk_vbox_new(FALSE, 0); 227 GtkWidget* license_vbox = gtk_vbox_new(FALSE, 0);
226 gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox, FALSE, FALSE, 0); 228 gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox, FALSE, FALSE, 0);
227 gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox2, FALSE, FALSE, 0); 229 gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox2, FALSE, FALSE, 0);
228 230
231 #if defined(GOOGLE_CHROME_BUILD)
232 std::vector<size_t> url_offsets;
233 std::wstring text = l10n_util::GetStringF(IDS_ABOUT_TERMS_OF_SERVICE,
234 std::wstring(),
235 std::wstring(),
236 &url_offsets);
237
238 std::string tos_link_text = Smaller(
239 l10n_util::GetStringUTF8(IDS_TERMS_OF_SERVICE));
240 GtkWidget* tos_chunk1 = MakeMarkupLabel(
241 kSmaller, WideToUTF8(text.substr(0, url_offsets[0])).c_str());
242 GtkWidget* tos_link =
243 gtk_chrome_link_button_new_with_markup(tos_link_text.c_str());
244 GtkWidget* tos_chunk2 = MakeMarkupLabel(
245 kSmaller, WideToUTF8(text.substr(url_offsets[0])).c_str());
246
247 GtkWidget* tos_hbox = gtk_hbox_new(FALSE, 0);
248 gtk_box_pack_start(GTK_BOX(tos_hbox), tos_chunk1, FALSE, FALSE, 0);
249 gtk_box_pack_start(GTK_BOX(tos_hbox), tos_link, FALSE, FALSE, 0);
250 gtk_box_pack_start(GTK_BOX(tos_hbox), tos_chunk2, FALSE, FALSE, 0);
251
252 g_signal_connect(tos_link, "clicked", G_CALLBACK(OnLinkButtonClick),
253 const_cast<char*>(kTOS));
254 #endif
255
229 gtk_box_pack_start(GTK_BOX(vbox), license_vbox, TRUE, TRUE, 0); 256 gtk_box_pack_start(GTK_BOX(vbox), license_vbox, TRUE, TRUE, 0);
257 gtk_box_pack_start(GTK_BOX(vbox), tos_hbox, TRUE, TRUE, 0);
230 gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0); 258 gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0);
231 259
232 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), NULL); 260 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), NULL);
233 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); 261 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
234 gtk_widget_show_all(dialog); 262 gtk_widget_show_all(dialog);
235 } 263 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698