diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 13:20:30 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 13:20:30 +0000 |
commit | bd5cf9400e6d1c8c3147af51847454a9f60e5d2d (patch) | |
tree | 46618a9c370db2ac9682b38f890700691302717f | |
parent | fc6362922f41177571187a6921ee2e7ed5a65574 (diff) | |
download | chromium_src-bd5cf9400e6d1c8c3147af51847454a9f60e5d2d.zip chromium_src-bd5cf9400e6d1c8c3147af51847454a9f60e5d2d.tar.gz chromium_src-bd5cf9400e6d1c8c3147af51847454a9f60e5d2d.tar.bz2 |
gtk: Remove the gtk implementation of About Chrome Dialog.
BUG=132917
R=erg@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10566027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142943 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/about_chrome_dialog.cc | 299 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/about_chrome_dialog.h | 22 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/browser_window_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
4 files changed, 1 insertions, 325 deletions
diff --git a/chrome/browser/ui/gtk/about_chrome_dialog.cc b/chrome/browser/ui/gtk/about_chrome_dialog.cc deleted file mode 100644 index 2eecc0f9..0000000 --- a/chrome/browser/ui/gtk/about_chrome_dialog.cc +++ /dev/null @@ -1,299 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/gtk/about_chrome_dialog.h" - -#include <gtk/gtk.h> - -#include <string> -#include <vector> - -#include "base/utf_string_conversions.h" -#include "chrome/browser/google/google_util.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_version_info.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/page_navigator.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources.h" -#include "ui/base/gtk/gtk_hig_constants.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/image/cairo_cached_surface.h" -#include "ui/gfx/image/image.h" -#include "webkit/glue/webkit_glue.h" - -using content::OpenURLParams; - -namespace { - -// Left or right margin. -const int kPanelHorizMargin = 13; - -// Top or bottom margin. -const int kPanelVertMargin = 20; - -// Extra spacing between product name and version number. -const int kExtraLineSpacing = 5; - -// These are used as placeholder text around the links in the text in the about -// dialog. -const char* kBeginLinkChr = "BEGIN_LINK_CHR"; -const char* kBeginLinkOss = "BEGIN_LINK_OSS"; -// We don't actually use this one. -// const char* kEndLinkChr = "END_LINK_CHR"; -const char* kEndLinkOss = "END_LINK_OSS"; -const char* kBeginLink = "BEGIN_LINK"; -const char* kEndLink = "END_LINK"; - -const char* kPageNavigatorKey = "__PAGE_NAVIGATOR__"; - -void OnResponse(GtkWidget* dialog, int response_id) { - // We're done. - gtk_widget_destroy(dialog); -} - -GtkWidget* MakeMarkupLabel(const char* format, const std::string& str) { - GtkWidget* label = gtk_label_new(NULL); - char* markup = g_markup_printf_escaped(format, str.c_str()); - gtk_label_set_markup(GTK_LABEL(label), markup); - g_free(markup); - - // Left align it. - gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); - - return label; -} - -void OnLinkButtonClick(GtkWidget* button, const char* url) { - content::PageNavigator* navigator = reinterpret_cast<content::PageNavigator*>( - g_object_get_data(G_OBJECT(button), kPageNavigatorKey)); - navigator->OpenURL(OpenURLParams(GURL(url), - content::Referrer(), - NEW_WINDOW, - content::PAGE_TRANSITION_LINK, - false)); -} - -const char* GetChromiumUrl() { - CR_DEFINE_STATIC_LOCAL(GURL, url, (GURL(chrome::kChromiumProjectURL))); - return url.spec().c_str(); -} - -gboolean OnEventBoxExpose(GtkWidget* event_box, - GdkEventExpose* expose, - gboolean user_data) { - cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE( - gtk_widget_get_window(event_box))); - gdk_cairo_rectangle(cr, &expose->area); - cairo_clip(cr); - - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - gfx::CairoCachedSurface* background = - rb.GetNativeImageNamed(IDR_ABOUT_BACKGROUND_COLOR).ToCairo(); - background->SetSource(cr, event_box, 0, 0); - - cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); - gdk_cairo_rectangle(cr, &expose->area); - cairo_fill(cr); - cairo_destroy(cr); - return FALSE; -} - -} // namespace - -void ShowAboutDialogForProfile(GtkWindow* parent, - Profile* profile, - content::PageNavigator* navigator) { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - static GdkPixbuf* background = rb.GetNativeImageNamed( - IDR_ABOUT_BACKGROUND).ToGdkPixbuf(); - - // Build the dialog. - GtkWidget* dialog = gtk_dialog_new_with_buttons( - l10n_util::GetStringUTF8(IDS_ABOUT_CHROME_TITLE).c_str(), - parent, - GTK_DIALOG_MODAL, - NULL); - // Pick up the style set in gtk_util.cc:InitRCStyles(). - // The layout of this dialog is special because the logo should be flush - // with the edges of the window. - gtk_widget_set_name(dialog, "about-dialog"); -#if !GTK_CHECK_VERSION(2, 22, 0) - gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); -#endif - - GtkWidget* close_button = gtk_dialog_add_button(GTK_DIALOG(dialog), - GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); - - GtkWidget* content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - - // Use an event box to get the background painting correctly - GtkWidget* ebox = gtk_event_box_new(); - gtk_widget_set_app_paintable(ebox, TRUE); - g_signal_connect(ebox, "expose-event", G_CALLBACK(OnEventBoxExpose), NULL); - - GtkWidget* hbox = gtk_hbox_new(FALSE, 0); - - GtkWidget* text_alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); - gtk_alignment_set_padding(GTK_ALIGNMENT(text_alignment), - kPanelVertMargin, kPanelVertMargin, - kPanelHorizMargin, kPanelHorizMargin); - - GtkWidget* text_vbox = gtk_vbox_new(FALSE, kExtraLineSpacing); - - GdkColor black = ui::kGdkBlack; - GtkWidget* product_label = MakeMarkupLabel( - "<span font_desc=\"18\" style=\"normal\">%s</span>", - l10n_util::GetStringUTF8(IDS_PRODUCT_NAME)); - gtk_widget_modify_fg(product_label, GTK_STATE_NORMAL, &black); - gtk_box_pack_start(GTK_BOX(text_vbox), product_label, FALSE, FALSE, 0); - - chrome::VersionInfo version_info; - GtkWidget* version_label = gtk_label_new( - version_info.CreateVersionString().c_str()); - gtk_misc_set_alignment(GTK_MISC(version_label), 0.0, 0.5); - gtk_label_set_selectable(GTK_LABEL(version_label), TRUE); - gtk_widget_modify_fg(version_label, GTK_STATE_NORMAL, &black); - gtk_box_pack_start(GTK_BOX(text_vbox), version_label, FALSE, FALSE, 0); - - gtk_container_add(GTK_CONTAINER(text_alignment), text_vbox); - gtk_box_pack_start(GTK_BOX(hbox), text_alignment, TRUE, TRUE, 0); - - GtkWidget* image_vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_end(GTK_BOX(image_vbox), - gtk_image_new_from_pixbuf(background), - FALSE, FALSE, 0); - - gtk_box_pack_start(GTK_BOX(hbox), image_vbox, FALSE, FALSE, 0); - gtk_container_add(GTK_CONTAINER(ebox), hbox); - gtk_box_pack_start(GTK_BOX(content_area), ebox, TRUE, TRUE, 0); - - // We use a separate box for the licensing etc. text. See the comment near - // the top of this function about using a special layout for this dialog. - GtkWidget* vbox = gtk_vbox_new(FALSE, 0); - - GtkWidget* copyright_label = gtk_label_new( - l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_COPYRIGHT).c_str()); - gtk_misc_set_alignment(GTK_MISC(copyright_label), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(vbox), copyright_label, FALSE, FALSE, 5); - - std::string license = l10n_util::GetStringUTF8(IDS_ABOUT_OLD_VERSION_LICENSE); - bool chromium_url_appears_first = - license.find(kBeginLinkChr) < license.find(kBeginLinkOss); - size_t link1 = license.find(kBeginLink); - DCHECK(link1 != std::string::npos); - size_t link1_end = license.find(kEndLink, link1); - DCHECK(link1_end != std::string::npos); - size_t link2 = license.find(kBeginLink, link1_end); - DCHECK(link2 != std::string::npos); - size_t link2_end = license.find(kEndLink, link2); - DCHECK(link1_end != std::string::npos); - - GtkWidget* license_chunk1 = gtk_label_new(license.substr(0, link1).c_str()); - gtk_misc_set_alignment(GTK_MISC(license_chunk1), 0.0, 0.5); - GtkWidget* license_chunk2 = gtk_label_new( - license.substr(link1_end + strlen(kEndLinkOss), - link2 - link1_end - strlen(kEndLinkOss)).c_str()); - gtk_misc_set_alignment(GTK_MISC(license_chunk2), 0.0, 0.5); - GtkWidget* license_chunk3 = gtk_label_new( - license.substr(link2_end + strlen(kEndLinkOss)).c_str()); - gtk_misc_set_alignment(GTK_MISC(license_chunk3), 0.0, 0.5); - - std::string first_link_text = - license.substr(link1 + strlen(kBeginLinkOss), - link1_end - link1 - strlen(kBeginLinkOss)); - std::string second_link_text = - license.substr(link2 + strlen(kBeginLinkOss), - link2_end - link2 - strlen(kBeginLinkOss)); - - GtkWidget* first_link = gtk_chrome_link_button_new(first_link_text.c_str()); - GtkWidget* second_link = gtk_chrome_link_button_new(second_link_text.c_str()); - if (!chromium_url_appears_first) { - GtkWidget* swap = second_link; - second_link = first_link; - first_link = swap; - } - - g_object_set_data(G_OBJECT(first_link), kPageNavigatorKey, - reinterpret_cast<void*>(navigator)); - g_object_set_data(G_OBJECT(second_link), kPageNavigatorKey, - reinterpret_cast<void*>(navigator)); - - g_signal_connect(chromium_url_appears_first ? first_link : second_link, - "clicked", G_CALLBACK(OnLinkButtonClick), - const_cast<char*>(GetChromiumUrl())); - g_signal_connect(chromium_url_appears_first ? second_link : first_link, - "clicked", G_CALLBACK(OnLinkButtonClick), - const_cast<char*>(chrome::kChromeUICreditsURL)); - - GtkWidget* license_hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_hbox), license_chunk1, - FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_hbox), first_link, - FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_hbox), license_chunk2, - FALSE, FALSE, 0); - - // Since there's no good way to dynamically wrap the license block, force - // a line break right before the second link (which matches en-US Windows - // chromium). - GtkWidget* license_hbox2 = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_hbox2), second_link, - FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_hbox2), license_chunk3, - FALSE, FALSE, 0); - - GtkWidget* license_vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(license_vbox), license_hbox2, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), license_vbox, FALSE, FALSE, 0); - -#if defined(GOOGLE_CHROME_BUILD) - // Spacing line. - gtk_box_pack_start(GTK_BOX(vbox), gtk_label_new(""), FALSE, FALSE, 0); - - std::vector<size_t> url_offsets; - string16 text = l10n_util::GetStringFUTF16(IDS_ABOUT_OLD_TERMS_OF_SERVICE, - string16(), - string16(), - &url_offsets); - - GtkWidget* tos_chunk1 = gtk_label_new( - UTF16ToUTF8(text.substr(0, url_offsets[0])).c_str()); - gtk_misc_set_alignment(GTK_MISC(tos_chunk1), 0.0, 0.5); - GtkWidget* tos_link = gtk_chrome_link_button_new( - l10n_util::GetStringUTF8(IDS_TERMS_OF_SERVICE).c_str()); - GtkWidget* tos_chunk2 = gtk_label_new( - UTF16ToUTF8(text.substr(url_offsets[0])).c_str()); - gtk_misc_set_alignment(GTK_MISC(tos_chunk2), 0.0, 0.5); - - GtkWidget* tos_hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(tos_hbox), tos_chunk1, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(tos_hbox), tos_link, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(tos_hbox), tos_chunk2, FALSE, FALSE, 0); - - g_object_set_data(G_OBJECT(tos_link), kPageNavigatorKey, - reinterpret_cast<void*>(navigator)); - g_signal_connect(tos_link, "clicked", G_CALLBACK(OnLinkButtonClick), - const_cast<char*>(chrome::kChromeUITermsURL)); - gtk_box_pack_start(GTK_BOX(vbox), tos_hbox, TRUE, TRUE, 0); -#endif - - GtkWidget* alignment = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); - gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), - ui::kContentAreaBorder, 0, - ui::kContentAreaBorder, ui::kContentAreaBorder); - gtk_container_add(GTK_CONTAINER(alignment), vbox); - gtk_box_pack_start(GTK_BOX(content_area), alignment, FALSE, FALSE, 0); - - g_signal_connect(dialog, "response", G_CALLBACK(OnResponse), NULL); - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); - gtk_widget_show_all(dialog); - gtk_widget_grab_focus(close_button); -} diff --git a/chrome/browser/ui/gtk/about_chrome_dialog.h b/chrome/browser/ui/gtk/about_chrome_dialog.h deleted file mode 100644 index 1ab0f2e..0000000 --- a/chrome/browser/ui/gtk/about_chrome_dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_GTK_ABOUT_CHROME_DIALOG_H_ -#define CHROME_BROWSER_UI_GTK_ABOUT_CHROME_DIALOG_H_ -#pragma once - -class Profile; -typedef struct _GtkWindow GtkWindow; - -namespace content { -class PageNavigator; -} - -// Displays the about box, using data copied from |profile|. |navigator| is -// supplied to handle link clicks. -void ShowAboutDialogForProfile(GtkWindow* parent, - Profile* profile, - content::PageNavigator* navigator); - -#endif // CHROME_BROWSER_UI_GTK_ABOUT_CHROME_DIALOG_H_ diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index f5493d3..722944e 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -41,7 +41,6 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/find_bar/find_bar_controller.h" #include "chrome/browser/ui/find_bar/find_tab_helper.h" -#include "chrome/browser/ui/gtk/about_chrome_dialog.h" #include "chrome/browser/ui/gtk/accelerators_gtk.h" #include "chrome/browser/ui/gtk/avatar_menu_bubble_gtk.h" #include "chrome/browser/ui/gtk/avatar_menu_button_gtk.h" @@ -1059,7 +1058,7 @@ void BrowserWindowGtk::ToggleBookmarkBar() { } void BrowserWindowGtk::ShowAboutChromeDialog() { - ShowAboutDialogForProfile(window_, browser_->profile(), browser_.get()); + // Do nothing here, we show a WebUI page instead of a native one. } void BrowserWindowGtk::ShowUpdateChromeDialog() { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 82648fa..d49244ba 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2889,8 +2889,6 @@ 'browser/ui/global_error_service.h', 'browser/ui/global_error_service_factory.cc', 'browser/ui/global_error_service_factory.h', - 'browser/ui/gtk/about_chrome_dialog.cc', - 'browser/ui/gtk/about_chrome_dialog.h', 'browser/ui/gtk/accelerators_gtk.cc', 'browser/ui/gtk/accelerators_gtk.h', 'browser/ui/gtk/autofill/autofill_popup_view_gtk.cc', |