| OLD | NEW |
| 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 #include <wchar.h> | 8 #include <wchar.h> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 current_version += L")"; | 89 current_version += L")"; |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 // Build the dialog. | 92 // Build the dialog. |
| 93 GtkWidget* dialog = gtk_dialog_new_with_buttons( | 93 GtkWidget* dialog = gtk_dialog_new_with_buttons( |
| 94 l10n_util::GetStringUTF8(IDS_ABOUT_CHROME_TITLE).c_str(), | 94 l10n_util::GetStringUTF8(IDS_ABOUT_CHROME_TITLE).c_str(), |
| 95 parent, | 95 parent, |
| 96 GTK_DIALOG_MODAL, | 96 GTK_DIALOG_MODAL, |
| 97 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, | 97 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
| 98 NULL); | 98 NULL); |
| 99 // Pick up the style set in gtk_util.cc:InitRCStyles(). |
| 100 // The layout of this dialog is special because the logo should be flush |
| 101 // with the edges of the window. |
| 102 gtk_widget_set_name(dialog, "about-dialog"); |
| 103 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
| 99 | 104 |
| 100 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; | 105 GtkWidget* content_area = GTK_DIALOG(dialog)->vbox; |
| 101 | 106 |
| 102 // Use an event box to get the background painting correctly | 107 // Use an event box to get the background painting correctly |
| 103 GtkWidget* ebox = gtk_event_box_new(); | 108 GtkWidget* ebox = gtk_event_box_new(); |
| 104 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &gfx::kGdkWhite); | 109 gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &gfx::kGdkWhite); |
| 105 | 110 |
| 106 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); | 111 GtkWidget* hbox = gtk_hbox_new(FALSE, 0); |
| 107 | 112 |
| 108 GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); | 113 GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 128 | 133 |
| 129 GtkWidget* image_vbox = gtk_vbox_new(FALSE, 0); | 134 GtkWidget* image_vbox = gtk_vbox_new(FALSE, 0); |
| 130 gtk_box_pack_end(GTK_BOX(image_vbox), | 135 gtk_box_pack_end(GTK_BOX(image_vbox), |
| 131 gtk_image_new_from_pixbuf(background), | 136 gtk_image_new_from_pixbuf(background), |
| 132 FALSE, FALSE, 0); | 137 FALSE, FALSE, 0); |
| 133 | 138 |
| 134 gtk_box_pack_start(GTK_BOX(hbox), image_vbox, FALSE, FALSE, 0); | 139 gtk_box_pack_start(GTK_BOX(hbox), image_vbox, FALSE, FALSE, 0); |
| 135 gtk_container_add(GTK_CONTAINER(ebox), hbox); | 140 gtk_container_add(GTK_CONTAINER(ebox), hbox); |
| 136 gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0); | 141 gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0); |
| 137 | 142 |
| 143 // We use a separate box for the licensing etc. text. See the comment near |
| 144 // the top of this function about using a special layout for this dialog. |
| 145 GtkWidget* vbox = gtk_vbox_new(FALSE, 6); |
| 146 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); |
| 147 |
| 138 GtkWidget* copyright_label = MakeMarkupLabel( | 148 GtkWidget* copyright_label = MakeMarkupLabel( |
| 139 "<span size=\"smaller\">%s</span>", | 149 "<span size=\"smaller\">%s</span>", |
| 140 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); | 150 l10n_util::GetString(IDS_ABOUT_VERSION_COPYRIGHT)); |
| 141 gtk_box_pack_start(GTK_BOX(content_area), copyright_label, TRUE, TRUE, 5); | 151 gtk_box_pack_start(GTK_BOX(vbox), copyright_label, TRUE, TRUE, 5); |
| 142 | 152 |
| 143 // TODO(erg): Figure out how to really insert links. We could just depend on | 153 // TODO(erg): Figure out how to really insert links. We could just depend on |
| 144 // (or include the source of) libsexy's SexyUrlLabel gtk widget... | 154 // (or include the source of) libsexy's SexyUrlLabel gtk widget... |
| 145 std::wstring license = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE); | 155 std::wstring license = l10n_util::GetString(IDS_ABOUT_VERSION_LICENSE); |
| 146 RemoveText(&license, kBeginLinkChr); | 156 RemoveText(&license, kBeginLinkChr); |
| 147 RemoveText(&license, kBeginLinkOss); | 157 RemoveText(&license, kBeginLinkOss); |
| 148 RemoveText(&license, kBeginLink); | 158 RemoveText(&license, kBeginLink); |
| 149 RemoveText(&license, kEndLinkChr); | 159 RemoveText(&license, kEndLinkChr); |
| 150 RemoveText(&license, kEndLinkOss); | 160 RemoveText(&license, kEndLinkOss); |
| 151 RemoveText(&license, kEndLink); | 161 RemoveText(&license, kEndLink); |
| 152 | 162 |
| 153 GtkWidget* license_label = MakeMarkupLabel( | 163 GtkWidget* license_label = MakeMarkupLabel( |
| 154 "<span size=\"smaller\">%s</span>", license); | 164 "<span size=\"smaller\">%s</span>", license); |
| 155 | 165 |
| 156 gtk_label_set_line_wrap(GTK_LABEL(license_label), TRUE); | 166 gtk_label_set_line_wrap(GTK_LABEL(license_label), TRUE); |
| 157 gtk_misc_set_alignment(GTK_MISC(license_label), 0, 0); | 167 gtk_misc_set_alignment(GTK_MISC(license_label), 0, 0); |
| 158 gtk_box_pack_start(GTK_BOX(content_area), license_label, TRUE, TRUE, 0); | 168 gtk_box_pack_start(GTK_BOX(vbox), license_label, TRUE, TRUE, 0); |
| 159 | 169 |
| 160 // Hack around Gtk's not-so-good label wrapping, as described here: | 170 // Hack around Gtk's not-so-good label wrapping, as described here: |
| 161 // http://blog.16software.com/dynamic-label-wrapping-in-gtk | 171 // http://blog.16software.com/dynamic-label-wrapping-in-gtk |
| 162 g_signal_connect(G_OBJECT(license_label), "size-allocate", | 172 g_signal_connect(G_OBJECT(license_label), "size-allocate", |
| 163 G_CALLBACK(FixLabelWrappingCallback), NULL); | 173 G_CALLBACK(FixLabelWrappingCallback), NULL); |
| 164 | 174 |
| 175 gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0); |
| 176 |
| 165 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), NULL); | 177 g_signal_connect(dialog, "response", G_CALLBACK(OnDialogResponse), NULL); |
| 166 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); | 178 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
| 167 gtk_widget_show_all(dialog); | 179 gtk_widget_show_all(dialog); |
| 168 } | 180 } |
| OLD | NEW |