summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/clipboard/clipboard_linux.cc6
-rw-r--r--base/base.gypi2
-rw-r--r--base/gtk_util.cc71
-rw-r--r--base/gtk_util.h28
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc22
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk_unittest.cc2
-rw-r--r--chrome/browser/gtk/about_chrome_dialog.cc3
-rw-r--r--chrome/browser/gtk/bookmark_bubble_gtk.cc3
-rw-r--r--chrome/browser/gtk/bookmark_utils_gtk.cc4
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc4
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc3
-rw-r--r--chrome/browser/gtk/certificate_viewer.cc8
-rw-r--r--chrome/browser/gtk/constrained_html_delegate_gtk.cc6
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc8
-rw-r--r--chrome/browser/gtk/first_run_bubble.cc3
-rw-r--r--chrome/browser/gtk/first_run_dialog.cc5
-rw-r--r--chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc6
-rw-r--r--chrome/browser/gtk/gtk_theme_provider.cc1
-rw-r--r--chrome/browser/gtk/gtk_util.cc9
-rw-r--r--chrome/browser/gtk/gtk_util.h14
-rw-r--r--chrome/browser/gtk/infobar_gtk.cc8
-rw-r--r--chrome/browser/gtk/keyword_editor_view.cc5
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc4
-rw-r--r--chrome/browser/gtk/menu_gtk.cc23
-rw-r--r--chrome/browser/gtk/notifications/balloon_view_gtk.cc3
-rw-r--r--chrome/browser/gtk/options/cookies_view.cc7
-rw-r--r--chrome/browser/gtk/options/general_page_gtk.cc7
-rw-r--r--chrome/browser/gtk/page_info_bubble_gtk.cc3
-rw-r--r--chrome/browser/gtk/sad_tab_gtk.cc6
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc3
-rw-r--r--chrome/browser/gtk/theme_install_bubble_view_gtk.cc5
-rw-r--r--chrome/browser/gtk/translate/translate_infobar_base_gtk.cc3
-rw-r--r--chrome/browser/icon_loader_linux.cc4
-rw-r--r--chrome/browser/renderer_host/gtk_im_context_wrapper.cc4
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc5
-rw-r--r--chrome/browser/speech/speech_input_bubble_gtk.cc2
-rw-r--r--gfx/canvas_skia_linux.cc3
-rw-r--r--gfx/gtk_util.cc61
-rw-r--r--gfx/gtk_util.h31
-rw-r--r--views/controls/menu/native_menu_gtk.cc3
40 files changed, 175 insertions, 223 deletions
diff --git a/app/clipboard/clipboard_linux.cc b/app/clipboard/clipboard_linux.cc
index 19fbfc5..4c833fb 100644
--- a/app/clipboard/clipboard_linux.cc
+++ b/app/clipboard/clipboard_linux.cc
@@ -11,10 +11,10 @@
#include <utility>
#include "base/file_path.h"
-#include "base/gtk_util.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/utf_string_conversions.h"
+#include "gfx/gtk_util.h"
#include "gfx/size.h"
namespace {
@@ -187,8 +187,8 @@ void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) {
const gfx::Size* size = reinterpret_cast<const gfx::Size*>(size_data);
guchar* data =
- gtk_util::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data),
- size->width(), size->height(), 0);
+ gfx::BGRAToRGBA(reinterpret_cast<const uint8_t*>(pixel_data),
+ size->width(), size->height(), 0);
GdkPixbuf* pixbuf =
gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE,
diff --git a/base/base.gypi b/base/base.gypi
index 248a21e..a96e5e9 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -103,8 +103,6 @@
'global_descriptors_posix.cc',
'global_descriptors_posix.h',
'gtest_prod_util.h',
- 'gtk_util.cc',
- 'gtk_util.h',
'hash_tables.h',
'id_map.h',
'json/json_reader.cc',
diff --git a/base/gtk_util.cc b/base/gtk_util.cc
deleted file mode 100644
index b526aca..0000000
--- a/base/gtk_util.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) 2010 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 "base/gtk_util.h"
-
-#include <stdlib.h>
-
-namespace gtk_util {
-
-namespace {
-
-// Common implementation of ConvertAcceleratorsFromWindowsStyle() and
-// RemoveWindowsStyleAccelerators().
-// Replaces all ampersands (as used in our grd files to indicate mnemonics)
-// to |target|. Similarly any underscores get replaced with two underscores as
-// is needed by pango.
-std::string ConvertAmperstandsTo(const std::string& label,
- const std::string& target) {
- std::string ret;
- ret.reserve(label.length() * 2);
- for (size_t i = 0; i < label.length(); ++i) {
- if ('_' == label[i]) {
- ret.push_back('_');
- ret.push_back('_');
- } else if ('&' == label[i]) {
- if (i + 1 < label.length() && '&' == label[i + 1]) {
- ret.push_back('&');
- ++i;
- } else {
- ret.append(target);
- }
- } else {
- ret.push_back(label[i]);
- }
- }
-
- return ret;
-}
-
-} // namespace
-
-std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
- return ConvertAmperstandsTo(label, "_");
-}
-
-std::string RemoveWindowsStyleAccelerators(const std::string& label) {
- return ConvertAmperstandsTo(label, "");
-}
-
-uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
- if (stride == 0)
- stride = width * 4;
-
- uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride));
-
- // We have to copy the pixels and swap from BGRA to RGBA.
- for (int i = 0; i < height; ++i) {
- for (int j = 0; j < width; ++j) {
- int idx = i * stride + j * 4;
- new_pixels[idx] = pixels[idx + 2];
- new_pixels[idx + 1] = pixels[idx + 1];
- new_pixels[idx + 2] = pixels[idx];
- new_pixels[idx + 3] = pixels[idx + 3];
- }
- }
-
- return new_pixels;
-}
-
-} // namespace gtk_util
diff --git a/base/gtk_util.h b/base/gtk_util.h
deleted file mode 100644
index 912bfbd..0000000
--- a/base/gtk_util.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2010 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 BASE_GTK_UTIL_H_
-#define BASE_GTK_UTIL_H_
-#pragma once
-
-#include <string>
-#include <stdint.h>
-
-namespace gtk_util {
-
-// Change windows accelerator style to GTK style. (GTK uses _ for
-// accelerators. Windows uses & with && as an escape for &.)
-std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label);
-
-// Removes the "&" accelerators from a Windows label.
-std::string RemoveWindowsStyleAccelerators(const std::string& label);
-
-// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
-// The caller is responsible for free()ing the data. If |stride| is 0, it's
-// assumed to be 4 * |width|.
-uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
-
-} // namespace gtk_util
-
-#endif // BASE_GTK_UTIL_H_
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index e2d085e..6cc084f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -10,7 +10,6 @@
#include <algorithm>
#include "app/l10n_util.h"
-#include "base/gtk_util.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -44,8 +43,6 @@
#include "chrome/browser/gtk/location_bar_view_gtk.h"
#endif
-using gfx::SkColorToGdkColor;
-
namespace {
const gchar* kAutocompleteEditViewGtkKey = "__ACE_VIEW_GTK__";
@@ -685,23 +682,28 @@ void AutocompleteEditViewGtk::SetBaseColor() {
#else
background_color_ptr = &LocationBarViewGtk::kBackgroundColor;
#endif
- gtk_widget_modify_cursor(text_view_, &gfx::kGdkBlack, &gfx::kGdkGray);
+ gtk_widget_modify_cursor(
+ text_view_, &gtk_util::kGdkBlack, &gtk_util::kGdkGray);
gtk_widget_modify_base(text_view_, GTK_STATE_NORMAL, background_color_ptr);
#if !defined(TOOLKIT_VIEWS)
// Override the selected colors so we don't leak colors from the current
// gtk theme into the chrome-theme.
GdkColor c;
- c = SkColorToGdkColor(theme_provider_->get_active_selection_bg_color());
+ c = gfx::SkColorToGdkColor(
+ theme_provider_->get_active_selection_bg_color());
gtk_widget_modify_base(text_view_, GTK_STATE_SELECTED, &c);
- c = SkColorToGdkColor(theme_provider_->get_active_selection_fg_color());
+ c = gfx::SkColorToGdkColor(
+ theme_provider_->get_active_selection_fg_color());
gtk_widget_modify_text(text_view_, GTK_STATE_SELECTED, &c);
- c = SkColorToGdkColor(theme_provider_->get_inactive_selection_bg_color());
+ c = gfx::SkColorToGdkColor(
+ theme_provider_->get_inactive_selection_bg_color());
gtk_widget_modify_base(text_view_, GTK_STATE_ACTIVE, &c);
- c = SkColorToGdkColor(theme_provider_->get_inactive_selection_fg_color());
+ c = gfx::SkColorToGdkColor(
+ theme_provider_->get_inactive_selection_fg_color());
gtk_widget_modify_text(text_view_, GTK_STATE_ACTIVE, &c);
#endif
@@ -1056,7 +1058,7 @@ void AutocompleteEditViewGtk::HandlePopulatePopup(GtkWidget* sender,
// Search Engine menu item.
GtkWidget* search_engine_menuitem = gtk_menu_item_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_EDIT_SEARCH_ENGINES)).c_str());
gtk_menu_shell_append(GTK_MENU_SHELL(menu), search_engine_menuitem);
g_signal_connect(search_engine_menuitem, "activate",
@@ -1076,7 +1078,7 @@ void AutocompleteEditViewGtk::HandlePopulatePopup(GtkWidget* sender,
// Paste and Go menu item.
GtkWidget* paste_go_menuitem = gtk_menu_item_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(model_->is_paste_and_search() ?
IDS_PASTE_AND_SEARCH : IDS_PASTE_AND_GO)).c_str());
gtk_menu_shell_append(GTK_MENU_SHELL(menu), paste_go_menuitem);
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk_unittest.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk_unittest.cc
index a133b26..dd84f26 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk_unittest.cc
@@ -8,7 +8,7 @@
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
-#include "gfx/gtk_util.h"
+#include "chrome/browser/gtk/gtk_util.h"
#include "testing/platform_test.h"
namespace {
diff --git a/chrome/browser/gtk/about_chrome_dialog.cc b/chrome/browser/gtk/about_chrome_dialog.cc
index 29f9159..cf22f23 100644
--- a/chrome/browser/gtk/about_chrome_dialog.cc
+++ b/chrome/browser/gtk/about_chrome_dialog.cc
@@ -22,7 +22,6 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/url_constants.h"
-#include "gfx/gtk_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -149,7 +148,7 @@ void ShowAboutDialogForProfile(GtkWindow* parent, Profile* profile) {
GtkWidget* text_vbox = gtk_vbox_new(FALSE, kExtraLineSpacing);
- GdkColor black = gfx::kGdkBlack;
+ GdkColor black = gtk_util::kGdkBlack;
GtkWidget* product_label = MakeMarkupLabel(
"<span font_desc=\"18\" style=\"normal\">%s</span>",
l10n_util::GetStringUTF8(IDS_PRODUCT_NAME));
diff --git a/chrome/browser/gtk/bookmark_bubble_gtk.cc b/chrome/browser/gtk/bookmark_bubble_gtk.cc
index 6c57dc0..33cf4f5 100644
--- a/chrome/browser/gtk/bookmark_bubble_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bubble_gtk.cc
@@ -24,7 +24,6 @@
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
#include "chrome/common/notification_service.h"
-#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
namespace {
@@ -78,7 +77,7 @@ void BookmarkBubbleGtk::Observe(NotificationType type,
} else {
for (std::vector<GtkWidget*>::iterator it = labels_.begin();
it != labels_.end(); ++it) {
- gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
}
}
}
diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc
index b42c171..db7aa98 100644
--- a/chrome/browser/gtk/bookmark_utils_gtk.cc
+++ b/chrome/browser/gtk/bookmark_utils_gtk.cc
@@ -287,8 +287,8 @@ void SetButtonTextColors(GtkWidget* label, GtkThemeProvider* provider) {
// Because the prelight state is a white image that doesn't change by the
// theme, force the text color to black when it would be used.
- gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &gfx::kGdkBlack);
- gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &gtk_util::kGdkBlack);
+ gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, &gtk_util::kGdkBlack);
}
}
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index bb4b32b..0ab6f73 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -680,10 +680,10 @@ void BrowserTitlebar::UpdateTextColor() {
BrowserThemeProvider::COLOR_FRAME_INACTIVE);
}
GdkColor text_color = PickLuminosityContrastingColor(
- &frame_color, &gfx::kGdkWhite, &gfx::kGdkBlack);
+ &frame_color, &gtk_util::kGdkWhite, &gtk_util::kGdkBlack);
gtk_util::SetLabelColor(app_mode_title_, &text_color);
} else {
- gtk_util::SetLabelColor(app_mode_title_, &gfx::kGdkWhite);
+ gtk_util::SetLabelColor(app_mode_title_, &gtk_util::kGdkWhite);
}
}
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index c40419f..dece395 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -80,7 +80,6 @@
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
-#include "gfx/gtk_util.h"
#include "gfx/rect.h"
#include "gfx/skia_utils_gtk.h"
#include "grit/app_resources.h"
@@ -1622,7 +1621,7 @@ void BrowserWindowGtk::InitWidgets() {
// Set a white background so during startup the user sees white in the
// content area before we get a TabContents in place.
gtk_widget_modify_bg(render_area_event_box_, GTK_STATE_NORMAL,
- &gfx::kGdkWhite);
+ &gtk_util::kGdkWhite);
gtk_container_add(GTK_CONTAINER(render_area_event_box_),
render_area_floating_container_);
gtk_widget_show(render_area_event_box_);
diff --git a/chrome/browser/gtk/certificate_viewer.cc b/chrome/browser/gtk/certificate_viewer.cc
index ca58b5c..905eee3 100644
--- a/chrome/browser/gtk/certificate_viewer.cc
+++ b/chrome/browser/gtk/certificate_viewer.cc
@@ -10,7 +10,6 @@
#include <vector>
#include "app/l10n_util.h"
-#include "base/gtk_util.h"
#include "base/i18n/time_formatting.h"
#include "base/nss_util.h"
#include "base/scoped_ptr.h"
@@ -20,6 +19,7 @@
#include "chrome/browser/gtk/certificate_dialogs.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/common/net/x509_certificate_model.h"
+#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
#include "net/base/x509_certificate.h"
@@ -161,7 +161,7 @@ CertificateViewer::CertificateViewer(
GTK_NOTEBOOK(notebook_),
general_page_vbox_,
gtk_label_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(
IDS_CERT_INFO_GENERAL_TAB_LABEL)).c_str()));
@@ -169,7 +169,7 @@ CertificateViewer::CertificateViewer(
GTK_NOTEBOOK(notebook_),
details_page_vbox_,
gtk_label_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(
IDS_CERT_INFO_DETAILS_TAB_LABEL)).c_str()));
@@ -606,7 +606,7 @@ void CertificateViewer::InitDetailsPage() {
gtk_box_pack_start(GTK_BOX(details_page_vbox_), export_hbox,
FALSE, FALSE, 0);
export_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(
IDS_CERT_DETAILS_EXPORT_CERTIFICATE)).c_str());
g_signal_connect(export_button_, "clicked",
diff --git a/chrome/browser/gtk/constrained_html_delegate_gtk.cc b/chrome/browser/gtk/constrained_html_delegate_gtk.cc
index f23c82d..19ab52f 100644
--- a/chrome/browser/gtk/constrained_html_delegate_gtk.cc
+++ b/chrome/browser/gtk/constrained_html_delegate_gtk.cc
@@ -4,16 +4,16 @@
#include "chrome/browser/dom_ui/constrained_html_ui.h"
-#include "gfx/gtk_util.h"
-#include "gfx/rect.h"
#include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
#include "chrome/browser/gtk/constrained_window_gtk.h"
+#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/tab_contents_container_gtk.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_source.h"
+#include "gfx/rect.h"
#include "ipc/ipc_message.h"
class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate,
@@ -37,7 +37,7 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate,
virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate();
virtual void OnDialogClose();
virtual bool GetBackgroundColor(GdkColor* color) {
- *color = gfx::kGdkWhite;
+ *color = gtk_util::kGdkWhite;
return true;
}
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index 47f9b0c..8afba9a 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -35,7 +35,6 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/notification_service.h"
-#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -43,11 +42,11 @@ namespace {
// Used as the color of the text in the entry box and the text for the results
// label for failure searches.
-const GdkColor kEntryTextColor = gfx::kGdkBlack;
+const GdkColor kEntryTextColor = gtk_util::kGdkBlack;
// Used as the color of the background of the entry box and the background of
// the find label for successful searches.
-const GdkColor kEntryBackgroundColor = gfx::kGdkWhite;
+const GdkColor kEntryBackgroundColor = gtk_util::kGdkWhite;
const GdkColor kFindFailureBackgroundColor = GDK_COLOR_RGB(255, 102, 102);
const GdkColor kFindSuccessTextColor = GDK_COLOR_RGB(178, 178, 178);
@@ -500,7 +499,8 @@ void FindBarGtk::Observe(NotificationType type,
gtk_misc_set_alignment(GTK_MISC(match_count_label_), 0.5, 0.5);
} else {
- gtk_widget_modify_cursor(text_entry_, &gfx::kGdkBlack, &gfx::kGdkGray);
+ gtk_widget_modify_cursor(
+ text_entry_, &gtk_util::kGdkBlack, &gtk_util::kGdkGray);
gtk_widget_modify_base(text_entry_, GTK_STATE_NORMAL,
&kEntryBackgroundColor);
gtk_widget_modify_text(text_entry_, GTK_STATE_NORMAL,
diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc
index 6102180..81daf73 100644
--- a/chrome/browser/gtk/first_run_bubble.cc
+++ b/chrome/browser/gtk/first_run_bubble.cc
@@ -16,7 +16,6 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/search_engines/util.h"
#include "chrome/common/notification_service.h"
-#include "gfx/gtk_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -62,7 +61,7 @@ void FirstRunBubble::Observe(NotificationType type,
} else {
for (std::vector<GtkWidget*>::iterator it = labels_.begin();
it != labels_.end(); ++it) {
- gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
}
}
}
diff --git a/chrome/browser/gtk/first_run_dialog.cc b/chrome/browser/gtk/first_run_dialog.cc
index 45b0589..230fee3 100644
--- a/chrome/browser/gtk/first_run_dialog.cc
+++ b/chrome/browser/gtk/first_run_dialog.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/shell_integration.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/google_update_settings.h"
-#include "gfx/gtk_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -191,7 +190,7 @@ void FirstRunDialog::ShowSearchEngineWindow() {
GtkWidget* bubble_area_background = gtk_event_box_new();
gtk_widget_modify_bg(bubble_area_background,
- GTK_STATE_NORMAL, &gfx::kGdkWhite);
+ GTK_STATE_NORMAL, &gtk_util::kGdkWhite);
GtkWidget* bubble_area_box = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(bubble_area_box),
@@ -203,7 +202,7 @@ void FirstRunDialog::ShowSearchEngineWindow() {
l10n_util::GetStringFUTF8(IDS_FR_SEARCH_TEXT,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)).c_str());
gtk_misc_set_alignment(GTK_MISC(explanation), 0, 0.5);
- gtk_util::SetLabelColor(explanation, &gfx::kGdkBlack);
+ gtk_util::SetLabelColor(explanation, &gtk_util::kGdkBlack);
gtk_util::SetLabelWidth(explanation, kExplanationWidth);
gtk_box_pack_start(GTK_BOX(bubble_area_box), explanation, FALSE, FALSE, 0);
diff --git a/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc
index 848cb59..ee452b8 100644
--- a/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc
+++ b/chrome/browser/gtk/fullscreen_exit_bubble_gtk.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/gtk/gtk_floating_container.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/rounded_window.h"
-#include "gfx/gtk_util.h"
#include "grit/app_strings.h"
#include "grit/generated_resources.h"
@@ -54,9 +53,10 @@ void FullscreenExitBubbleGtk::InitWidgets() {
FALSE);
signals_.Connect(link, "clicked", G_CALLBACK(OnLinkClickedThunk), this);
- GtkWidget* container = gtk_util::CreateGtkBorderBin(link, &gfx::kGdkBlack,
+ GtkWidget* container = gtk_util::CreateGtkBorderBin(
+ link, &gtk_util::kGdkBlack,
kPaddingPixels, kPaddingPixels, kPaddingPixels, kPaddingPixels);
- gtk_util::ActAsRoundedWindow(container, gfx::kGdkGreen, kPaddingPixels,
+ gtk_util::ActAsRoundedWindow(container, gtk_util::kGdkGreen, kPaddingPixels,
gtk_util::ROUNDED_BOTTOM_LEFT | gtk_util::ROUNDED_BOTTOM_RIGHT,
gtk_util::BORDER_NONE);
diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc
index eb07a94..f33ccc2 100644
--- a/chrome/browser/gtk/gtk_theme_provider.cc
+++ b/chrome/browser/gtk/gtk_theme_provider.cc
@@ -15,6 +15,7 @@
#include "base/nix/xdg_util.h"
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
+#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/hover_controller_gtk.h"
#include "chrome/browser/gtk/meta_frames.h"
#include "chrome/browser/metrics/user_metrics.h"
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index ac45a7d..74b7423 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -15,7 +15,6 @@
#include "app/resource_bundle.h"
#include "app/x11_util.h"
#include "base/environment.h"
-#include "base/gtk_util.h"
#include "base/i18n/rtl.h"
#include "base/linux_util.h"
#include "base/logging.h"
@@ -29,6 +28,7 @@
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/common/renderer_preferences.h"
+#include "gfx/gtk_util.h"
#include "googleurl/src/gurl.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -190,6 +190,11 @@ WindowOpenDisposition DispositionFromEventFlags(guint event_flags) {
namespace gtk_util {
+const GdkColor kGdkWhite = GDK_COLOR_RGB(0xff, 0xff, 0xff);
+const GdkColor kGdkGray = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f);
+const GdkColor kGdkBlack = GDK_COLOR_RGB(0x00, 0x00, 0x00);
+const GdkColor kGdkGreen = GDK_COLOR_RGB(0x00, 0xff, 0x00);
+
GtkWidget* CreateLabeledControlsGroup(std::vector<GtkWidget*>* labels,
const char* text, ...) {
va_list ap;
@@ -620,7 +625,7 @@ GtkWidget* AddButtonToDialog(GtkWidget* dialog, const gchar* text,
GtkWidget* BuildDialogButton(GtkWidget* dialog, int ids_id,
const gchar* stock_id) {
GtkWidget* button = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(ids_id)).c_str());
gtk_button_set_image(GTK_BUTTON(button),
gtk_image_new_from_stock(stock_id,
diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h
index f7a87e1..77beb1f 100644
--- a/chrome/browser/gtk/gtk_util.h
+++ b/chrome/browser/gtk/gtk_util.h
@@ -18,6 +18,7 @@
#include "webkit/glue/window_open_disposition.h"
typedef struct _cairo cairo_t;
+typedef struct _GdkColor GdkColor;
typedef struct _GtkWidget GtkWidget;
class GtkThemeProvider;
@@ -25,6 +26,14 @@ class GURL;
class Profile;
struct RendererPreferences; // from common/renderer_preferences.h
+const int kSkiaToGDKMultiplier = 257;
+
+// Define a macro for creating GdkColors from RGB values. This is a macro to
+// allow static construction of literals, etc. Use this like:
+// GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff);
+#define GDK_COLOR_RGB(r, g, b) {0, r * kSkiaToGDKMultiplier, \
+ g * kSkiaToGDKMultiplier, b * kSkiaToGDKMultiplier}
+
namespace event_utils {
// Translates event flags into what kind of disposition they represent.
@@ -36,6 +45,11 @@ WindowOpenDisposition DispositionFromEventFlags(guint state);
namespace gtk_util {
+extern const GdkColor kGdkWhite;
+extern const GdkColor kGdkGray;
+extern const GdkColor kGdkBlack;
+extern const GdkColor kGdkGreen;
+
// Constants relating to the layout of dialog windows:
// (See http://library.gnome.org/devel/hig-book/stable/design-window.html.en)
diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc
index a512237..61992ed 100644
--- a/chrome/browser/gtk/infobar_gtk.cc
+++ b/chrome/browser/gtk/infobar_gtk.cc
@@ -185,8 +185,8 @@ void InfoBar::AddLabelWithInlineLink(const string16& display_text,
// TODO(joth): Unlike the AddLabalAndLink below, none of the label widgets
// are set as shrinkable here, meaning the text will run under the close
// button etc. when the width is restricted, rather than eliding.
- gtk_widget_modify_fg(initial_label, GTK_STATE_NORMAL, &gfx::kGdkBlack);
- gtk_widget_modify_fg(trailing_label, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(initial_label, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
+ gtk_widget_modify_fg(trailing_label, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
// We don't want any spacing between the elements, so we pack them into
// this hbox that doesn't use kElementPadding.
@@ -226,7 +226,7 @@ void InfoBar::AddLabelAndLink(const string16& display_text,
gtk_widget_set_size_request(label, 0, -1);
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
}
@@ -386,7 +386,7 @@ ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate)
GtkWidget* label = gtk_label_new(label_text.c_str());
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_util::CenterWidgetInHBox(confirm_hbox_, label, false, kEndOfLabelSpacing);
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
g_signal_connect(label, "map",
G_CALLBACK(gtk_util::InitLabelSizeRequestAndEllipsizeMode),
NULL);
diff --git a/chrome/browser/gtk/keyword_editor_view.cc b/chrome/browser/gtk/keyword_editor_view.cc
index 8967f4e..0753e28 100644
--- a/chrome/browser/gtk/keyword_editor_view.cc
+++ b/chrome/browser/gtk/keyword_editor_view.cc
@@ -7,7 +7,6 @@
#include <string>
#include "app/l10n_util.h"
-#include "base/gtk_util.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
@@ -168,7 +167,7 @@ void KeywordEditorView::Init() {
gtk_box_pack_start(GTK_BOX(hbox), button_box, FALSE, FALSE, 0);
add_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(
IDS_SEARCH_ENGINES_EDITOR_NEW_BUTTON)).c_str());
g_signal_connect(add_button_, "clicked",
@@ -182,7 +181,7 @@ void KeywordEditorView::Init() {
gtk_box_pack_start(GTK_BOX(button_box), edit_button_, FALSE, FALSE, 0);
remove_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(
IDS_SEARCH_ENGINES_EDITOR_REMOVE_BUTTON)).c_str());
g_signal_connect(remove_button_, "clicked",
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index fe22f92..c16b38c 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -811,8 +811,8 @@ void LocationBarViewGtk::Observe(NotificationType type,
gtk_util::SetRoundedWindowBorderColor(tab_to_search_box_,
kKeywordBorderColor);
- gtk_util::SetLabelColor(tab_to_search_full_label_, &gfx::kGdkBlack);
- gtk_util::SetLabelColor(tab_to_search_partial_label_, &gfx::kGdkBlack);
+ gtk_util::SetLabelColor(tab_to_search_full_label_, &gtk_util::kGdkBlack);
+ gtk_util::SetLabelColor(tab_to_search_partial_label_, &gtk_util::kGdkBlack);
gtk_util::SetLabelColor(tab_to_search_hint_leading_label_,
&kHintTextColor);
gtk_util::SetLabelColor(tab_to_search_hint_trailing_label_,
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 5d56621..ac15365 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -9,7 +9,6 @@
#include "app/menus/accelerator_gtk.h"
#include "app/menus/button_menu_item_model.h"
#include "app/menus/menu_model.h"
-#include "base/gtk_util.h"
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -22,9 +21,6 @@
#include "gfx/gtk_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
-using gtk_util::ConvertAcceleratorsFromWindowsStyle;
-using gtk_util::RemoveWindowsStyleAccelerators;
-
bool MenuGtk::block_activation_ = false;
namespace {
@@ -289,7 +285,7 @@ void MenuGtk::ConnectSignalHandlers() {
GtkWidget* MenuGtk::AppendMenuItemWithLabel(int command_id,
const std::string& label) {
- std::string converted_label = ConvertAcceleratorsFromWindowsStyle(label);
+ std::string converted_label = gfx::ConvertAcceleratorsFromWindowsStyle(label);
GtkWidget* menu_item = BuildMenuItemWithLabel(label, command_id);
return AppendMenuItem(command_id, menu_item);
}
@@ -297,14 +293,14 @@ GtkWidget* MenuGtk::AppendMenuItemWithLabel(int command_id,
GtkWidget* MenuGtk::AppendMenuItemWithIcon(int command_id,
const std::string& label,
const SkBitmap& icon) {
- std::string converted_label = ConvertAcceleratorsFromWindowsStyle(label);
+ std::string converted_label = gfx::ConvertAcceleratorsFromWindowsStyle(label);
GtkWidget* menu_item = BuildMenuItemWithImage(converted_label, icon);
return AppendMenuItem(command_id, menu_item);
}
GtkWidget* MenuGtk::AppendCheckMenuItemWithLabel(int command_id,
const std::string& label) {
- std::string converted_label = ConvertAcceleratorsFromWindowsStyle(label);
+ std::string converted_label = gfx::ConvertAcceleratorsFromWindowsStyle(label);
GtkWidget* menu_item =
gtk_check_menu_item_new_with_mnemonic(converted_label.c_str());
return AppendMenuItem(command_id, menu_item);
@@ -432,7 +428,8 @@ void MenuGtk::BuildSubmenuFromModel(menus::MenuModel* model, GtkWidget* menu) {
for (int i = 0; i < model->GetItemCount(); ++i) {
SkBitmap icon;
std::string label =
- ConvertAcceleratorsFromWindowsStyle(UTF16ToUTF8(model->GetLabelAt(i)));
+ gfx::ConvertAcceleratorsFromWindowsStyle(
+ UTF16ToUTF8(model->GetLabelAt(i)));
bool connect_to_activate = true;
switch (model->GetTypeAt(i)) {
@@ -508,7 +505,7 @@ void MenuGtk::BuildSubmenuFromModel(menus::MenuModel* model, GtkWidget* menu) {
GtkWidget* MenuGtk::BuildButtomMenuItem(menus::ButtonMenuItemModel* model,
GtkWidget* menu) {
GtkWidget* menu_item = gtk_custom_menu_item_new(
- RemoveWindowsStyleAccelerators(UTF16ToUTF8(model->label())).c_str());
+ gfx::RemoveWindowsStyleAccelerators(UTF16ToUTF8(model->label())).c_str());
// Set up the callback to the model for when it is clicked.
g_object_set_data(G_OBJECT(menu_item), "button-model", model);
@@ -537,7 +534,7 @@ GtkWidget* MenuGtk::BuildButtomMenuItem(menus::ButtonMenuItemModel* model,
} else {
gtk_button_set_label(
GTK_BUTTON(button),
- RemoveWindowsStyleAccelerators(
+ gfx::RemoveWindowsStyleAccelerators(
UTF16ToUTF8(model->GetLabelAt(i))).c_str());
}
@@ -550,7 +547,7 @@ GtkWidget* MenuGtk::BuildButtomMenuItem(menus::ButtonMenuItemModel* model,
model->GetCommandIdAt(i));
gtk_button_set_label(
GTK_BUTTON(button),
- RemoveWindowsStyleAccelerators(
+ gfx::RemoveWindowsStyleAccelerators(
UTF16ToUTF8(model->GetLabelAt(i))).c_str());
SetupButtonShowHandler(button, model, i);
break;
@@ -719,7 +716,7 @@ void MenuGtk::SetButtonItemInfo(GtkWidget* button, gpointer userdata) {
if (model->IsLabelDynamicAt(index)) {
std::string label =
- ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
UTF16ToUTF8(model->GetLabelAt(index)));
gtk_button_set_label(GTK_BUTTON(button), label.c_str());
}
@@ -778,7 +775,7 @@ void MenuGtk::SetMenuItemInfo(GtkWidget* widget, gpointer userdata) {
// Update the menu item label if it is dynamic.
if (model->IsLabelDynamicAt(id)) {
std::string label =
- ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
UTF16ToUTF8(model->GetLabelAt(id)));
#if GTK_CHECK_VERSION(2, 16, 0)
diff --git a/chrome/browser/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/gtk/notifications/balloon_view_gtk.cc
index 24a04cf..795b4ea 100644
--- a/chrome/browser/gtk/notifications/balloon_view_gtk.cc
+++ b/chrome/browser/gtk/notifications/balloon_view_gtk.cc
@@ -38,7 +38,6 @@
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "gfx/canvas.h"
-#include "gfx/gtk_util.h"
#include "gfx/insets.h"
#include "gfx/native_widget_types.h"
#include "grit/generated_resources.h"
@@ -298,7 +297,7 @@ void BalloonViewImpl::Show(Balloon* balloon) {
NotificationService::AllSources());
// We don't do InitThemesFor() because it just forces a redraw.
- gtk_util::ActAsRoundedWindow(frame_container_, gfx::kGdkBlack, 3,
+ gtk_util::ActAsRoundedWindow(frame_container_, gtk_util::kGdkBlack, 3,
gtk_util::ROUNDED_ALL,
gtk_util::BORDER_ALL);
diff --git a/chrome/browser/gtk/options/cookies_view.cc b/chrome/browser/gtk/options/cookies_view.cc
index 415dedb..557b22a 100644
--- a/chrome/browser/gtk/options/cookies_view.cc
+++ b/chrome/browser/gtk/options/cookies_view.cc
@@ -9,7 +9,6 @@
#include <string>
#include "app/l10n_util.h"
-#include "base/gtk_util.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/cookies_tree_model.h"
@@ -115,7 +114,7 @@ void CookiesView::Init(GtkWindow* parent) {
remove_button_ = gtk_util::AddButtonToDialog(
dialog_,
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_COOKIES_REMOVE_LABEL)).c_str(),
GTK_STOCK_REMOVE,
RESPONSE_REMOVE);
@@ -127,7 +126,7 @@ void CookiesView::Init(GtkWindow* parent) {
remove_all_button_ = gtk_util::AddButtonToDialog(
dialog_,
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_COOKIES_REMOVE_ALL_LABEL)).c_str(),
GTK_STOCK_CLEAR,
RESPONSE_REMOVE_ALL);
@@ -156,7 +155,7 @@ void CookiesView::Init(GtkWindow* parent) {
gtk_box_pack_start(GTK_BOX(filter_hbox), filter_entry_,
TRUE, TRUE, 0);
filter_clear_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_COOKIES_CLEAR_SEARCH_LABEL)).c_str());
g_signal_connect(filter_clear_button_, "clicked",
G_CALLBACK(OnFilterClearButtonClickedThunk), this);
diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc
index 1cc1ef9..c454ce8 100644
--- a/chrome/browser/gtk/options/general_page_gtk.cc
+++ b/chrome/browser/gtk/options/general_page_gtk.cc
@@ -9,7 +9,6 @@
#include "app/l10n_util.h"
#include "base/callback.h"
-#include "base/gtk_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/custom_home_pages_table_model.h"
#include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
@@ -277,21 +276,21 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() {
FALSE, FALSE, 0);
startup_add_custom_page_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_ADD_BUTTON)).c_str());
g_signal_connect(startup_add_custom_page_button_, "clicked",
G_CALLBACK(OnStartupAddCustomPageClickedThunk), this);
gtk_box_pack_start(GTK_BOX(url_list_buttons), startup_add_custom_page_button_,
FALSE, FALSE, 0);
startup_remove_custom_page_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_REMOVE_BUTTON)).c_str());
g_signal_connect(startup_remove_custom_page_button_, "clicked",
G_CALLBACK(OnStartupRemoveCustomPageClickedThunk), this);
gtk_box_pack_start(GTK_BOX(url_list_buttons),
startup_remove_custom_page_button_, FALSE, FALSE, 0);
startup_use_current_page_button_ = gtk_button_new_with_mnemonic(
- gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_OPTIONS_STARTUP_USE_CURRENT)).c_str());
g_signal_connect(startup_use_current_page_button_, "clicked",
G_CALLBACK(OnStartupUseCurrentPageClickedThunk), this);
diff --git a/chrome/browser/gtk/page_info_bubble_gtk.cc b/chrome/browser/gtk/page_info_bubble_gtk.cc
index fd9b7b6..cfb54de 100644
--- a/chrome/browser/gtk/page_info_bubble_gtk.cc
+++ b/chrome/browser/gtk/page_info_bubble_gtk.cc
@@ -23,7 +23,6 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
-#include "gfx/gtk_util.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -165,7 +164,7 @@ void PageInfoBubbleGtk::Observe(NotificationType type,
} else {
for (std::vector<GtkWidget*>::iterator it = labels_.begin();
it != labels_.end(); ++it) {
- gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
}
}
}
diff --git a/chrome/browser/gtk/sad_tab_gtk.cc b/chrome/browser/gtk/sad_tab_gtk.cc
index 982259b..569c53f 100644
--- a/chrome/browser/gtk/sad_tab_gtk.cc
+++ b/chrome/browser/gtk/sad_tab_gtk.cc
@@ -9,8 +9,8 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
+#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
-#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
@@ -34,7 +34,7 @@ GtkWidget* MakeWhiteMarkupLabel(const char* format, const std::string& str) {
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
// Set text to white.
- GdkColor white = gfx::kGdkWhite;
+ GdkColor white = gtk_util::kGdkWhite;
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &white);
return label;
@@ -96,7 +96,7 @@ SadTabGtk::SadTabGtk(TabContents* tab_contents)
GtkWidget* link = gtk_chrome_link_button_new(
l10n_util::GetStringUTF8(IDS_LEARN_MORE).c_str());
gtk_chrome_link_button_set_normal_color(GTK_CHROME_LINK_BUTTON(link),
- &gfx::kGdkWhite);
+ &gtk_util::kGdkWhite);
g_signal_connect(link, "clicked", G_CALLBACK(OnLinkButtonClickThunk), this);
GtkWidget* link_alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
gtk_container_add(GTK_CONTAINER(link_alignment), link);
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index e99fea0..fbb8989 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/gtk/rounded_window.h"
#include "chrome/browser/gtk/slide_animator_gtk.h"
#include "chrome/common/notification_service.h"
-#include "gfx/gtk_util.h"
namespace {
@@ -251,7 +250,7 @@ void StatusBubbleGtk::InitWidgets() {
container_.Own(gtk_event_box_new());
gtk_util::ActAsRoundedWindow(
- container_.get(), gfx::kGdkWhite, kCornerSize,
+ container_.get(), gtk_util::kGdkWhite, kCornerSize,
gtk_util::ROUNDED_TOP_RIGHT,
gtk_util::BORDER_TOP | gtk_util::BORDER_RIGHT);
gtk_widget_set_name(container_.get(), "status-bubble");
diff --git a/chrome/browser/gtk/theme_install_bubble_view_gtk.cc b/chrome/browser/gtk/theme_install_bubble_view_gtk.cc
index 651ab29..4708211 100644
--- a/chrome/browser/gtk/theme_install_bubble_view_gtk.cc
+++ b/chrome/browser/gtk/theme_install_bubble_view_gtk.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/gtk/rounded_window.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
-#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
// Roundedness of bubble.
@@ -94,7 +93,7 @@ void ThemeInstallBubbleViewGtk::InitWidgets() {
gtk_label_set_markup(GTK_LABEL(label), markup);
g_free(markup);
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gfx::kGdkWhite);
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gtk_util::kGdkWhite);
gtk_container_add(GTK_CONTAINER(widget_), label);
// We need to show the label so we'll know the widget's actual size when we
@@ -119,7 +118,7 @@ void ThemeInstallBubbleViewGtk::InitWidgets() {
G_CALLBACK(HandleExposeEventThunk), this);
gtk_widget_realize(widget_);
} else {
- gtk_widget_modify_bg(widget_, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_bg(widget_, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
GdkColor color;
gtk_util::ActAsRoundedWindow(widget_, color, kBubbleCornerRadius,
gtk_util::ROUNDED_ALL, gtk_util::BORDER_NONE);
diff --git a/chrome/browser/gtk/translate/translate_infobar_base_gtk.cc b/chrome/browser/gtk/translate/translate_infobar_base_gtk.cc
index e7a94b8..530d215 100644
--- a/chrome/browser/gtk/translate/translate_infobar_base_gtk.cc
+++ b/chrome/browser/gtk/translate/translate_infobar_base_gtk.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "gfx/canvas.h"
-#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
namespace {
@@ -127,7 +126,7 @@ void TranslateInfoBarBase::AnimationProgressed(const Animation* animation) {
GtkWidget* TranslateInfoBarBase::CreateLabel(const std::string& text) {
GtkWidget* label = gtk_label_new(text.c_str());
- gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gfx::kGdkBlack);
+ gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &gtk_util::kGdkBlack);
return label;
}
diff --git a/chrome/browser/icon_loader_linux.cc b/chrome/browser/icon_loader_linux.cc
index 1f8eff2..a4cf378 100644
--- a/chrome/browser/icon_loader_linux.cc
+++ b/chrome/browser/icon_loader_linux.cc
@@ -9,13 +9,13 @@
#include <gtk/gtk.h>
#include "base/file_util.h"
-#include "base/gtk_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/mime_util.h"
#include "base/thread.h"
#include "base/string_util.h"
#include "gfx/codec/png_codec.h"
+#include "gfx/gtk_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
static int SizeToInt(IconLoader::IconSize size) {
@@ -61,7 +61,7 @@ void IconLoader::ParseIcon() {
LOG(WARNING) << "Got an image with no alpha channel, aborting load.";
} else {
uint8_t* BGRA_pixels =
- gtk_util::BGRAToRGBA(pixels, width, height, stride);
+ gfx::BGRAToRGBA(pixels, width, height, stride);
std::vector<unsigned char> pixel_vector;
pixel_vector.resize(height * stride);
memcpy(const_cast<unsigned char*>(pixel_vector.data()), BGRA_pixels,
diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
index 1c07795..82d052e 100644
--- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
+++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc
@@ -10,7 +10,6 @@
#include <algorithm>
#include "app/l10n_util.h"
-#include "base/gtk_util.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/third_party/icu/icu_utf.h"
@@ -24,6 +23,7 @@
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/render_messages.h"
+#include "gfx/gtk_util.h"
#include "gfx/rect.h"
#include "grit/generated_resources.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -266,7 +266,7 @@ void GtkIMContextWrapper::AppendInputMethodsContextMenu(MenuGtk* menu) {
if (!show_input_method_menu)
return;
- std::string label = gtk_util::ConvertAcceleratorsFromWindowsStyle(
+ std::string label = gfx::ConvertAcceleratorsFromWindowsStyle(
l10n_util::GetStringUTF8(IDS_CONTENT_CONTEXT_INPUT_METHODS_MENU));
GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic(label.c_str());
GtkWidget* submenu = gtk_menu_new();
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
index e3647e5..49eacb3 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -39,7 +39,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "gfx/gtk_preserve_window.h"
-#include "gfx/gtk_util.h"
#include "third_party/WebKit/WebKit/chromium/public/gtk/WebInputEventFactory.h"
#include "webkit/glue/plugins/webplugin.h"
#include "webkit/glue/webaccessibility.h"
@@ -79,9 +78,9 @@ class RenderWidgetHostViewGtkWidget {
gtk_widget_set_double_buffered(widget, FALSE);
gtk_widget_set_redraw_on_allocate(widget, FALSE);
#if defined(NDEBUG)
- gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkWhite);
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gtk_util::kGdkWhite);
#else
- gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gfx::kGdkGreen);
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &gtk_util::kGdkGreen);
#endif
// Allow the browser window to be resized freely.
gtk_widget_set_size_request(widget, 0, 0);
diff --git a/chrome/browser/speech/speech_input_bubble_gtk.cc b/chrome/browser/speech/speech_input_bubble_gtk.cc
index 55edac3..923f327 100644
--- a/chrome/browser/speech/speech_input_bubble_gtk.cc
+++ b/chrome/browser/speech/speech_input_bubble_gtk.cc
@@ -25,7 +25,7 @@ const int kIconHorizontalPadding = 30;
const int kButtonBarHorizontalSpacing = 10;
// Use black for text labels since the bubble has white background.
-const GdkColor kLabelTextColor = gfx::kGdkBlack;
+const GdkColor kLabelTextColor = gtk_util::kGdkBlack;
// Implementation of SpeechInputBubble for GTK. This shows a speech input
// info bubble on screen.
diff --git a/gfx/canvas_skia_linux.cc b/gfx/canvas_skia_linux.cc
index 6d675ad..57705a6 100644
--- a/gfx/canvas_skia_linux.cc
+++ b/gfx/canvas_skia_linux.cc
@@ -10,7 +10,6 @@
#include <pango/pangocairo.h>
#include "base/logging.h"
-#include "base/gtk_util.h"
#include "base/utf_string_conversions.h"
#include "gfx/font.h"
#include "gfx/gtk_util.h"
@@ -166,7 +165,7 @@ static void SetupPangoLayout(PangoLayout* layout,
g_free(escaped_text);
} else if (flags & gfx::Canvas::HIDE_PREFIX) {
// Remove the ampersand character.
- utf8 = gtk_util::RemoveWindowsStyleAccelerators(utf8);
+ utf8 = gfx::RemoveWindowsStyleAccelerators(utf8);
pango_layout_set_text(layout, utf8.data(), utf8.size());
} else {
pango_layout_set_text(layout, utf8.data(), utf8.size());
diff --git a/gfx/gtk_util.cc b/gfx/gtk_util.cc
index bbed191..c45e133 100644
--- a/gfx/gtk_util.cc
+++ b/gfx/gtk_util.cc
@@ -20,15 +20,38 @@ void FreePixels(guchar* pixels, gpointer data) {
free(data);
}
+// Common implementation of ConvertAcceleratorsFromWindowsStyle() and
+// RemoveWindowsStyleAccelerators().
+// Replaces all ampersands (as used in our grd files to indicate mnemonics)
+// to |target|. Similarly any underscores get replaced with two underscores as
+// is needed by pango.
+std::string ConvertAmperstandsTo(const std::string& label,
+ const std::string& target) {
+ std::string ret;
+ ret.reserve(label.length() * 2);
+ for (size_t i = 0; i < label.length(); ++i) {
+ if ('_' == label[i]) {
+ ret.push_back('_');
+ ret.push_back('_');
+ } else if ('&' == label[i]) {
+ if (i + 1 < label.length() && '&' == label[i + 1]) {
+ ret.push_back('&');
+ ++i;
+ } else {
+ ret.append(target);
+ }
+ } else {
+ ret.push_back(label[i]);
+ }
+ }
+
+ return ret;
+}
+
} // namespace
namespace gfx {
-const GdkColor kGdkWhite = GDK_COLOR_RGB(0xff, 0xff, 0xff);
-const GdkColor kGdkGray = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f);
-const GdkColor kGdkBlack = GDK_COLOR_RGB(0x00, 0x00, 0x00);
-const GdkColor kGdkGreen = GDK_COLOR_RGB(0x00, 0xff, 0x00);
-
GdkPixbuf* GdkPixbufFromSkBitmap(const SkBitmap* bitmap) {
if (bitmap->isNull())
return NULL;
@@ -104,4 +127,32 @@ double GetPangoResolution() {
return resolution;
}
+std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
+ return ConvertAmperstandsTo(label, "_");
+}
+
+std::string RemoveWindowsStyleAccelerators(const std::string& label) {
+ return ConvertAmperstandsTo(label, "");
+}
+
+uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride) {
+ if (stride == 0)
+ stride = width * 4;
+
+ uint8_t* new_pixels = static_cast<uint8_t*>(malloc(height * stride));
+
+ // We have to copy the pixels and swap from BGRA to RGBA.
+ for (int i = 0; i < height; ++i) {
+ for (int j = 0; j < width; ++j) {
+ int idx = i * stride + j * 4;
+ new_pixels[idx] = pixels[idx + 2];
+ new_pixels[idx + 1] = pixels[idx + 1];
+ new_pixels[idx + 2] = pixels[idx];
+ new_pixels[idx + 3] = pixels[idx + 3];
+ }
+ }
+
+ return new_pixels;
+}
+
} // namespace gfx
diff --git a/gfx/gtk_util.h b/gfx/gtk_util.h
index 3f8fc0c..5c4ad94 100644
--- a/gfx/gtk_util.h
+++ b/gfx/gtk_util.h
@@ -6,36 +6,23 @@
#define GFX_GTK_UTIL_H_
#pragma once
+#include <glib-object.h>
#include <stdint.h>
-#include <vector>
-#include <glib-object.h>
+#include <string>
+#include <vector>
#include "base/scoped_ptr.h"
-typedef struct _GdkColor GdkColor;
typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GdkRegion GdkRegion;
class SkBitmap;
-const int kSkiaToGDKMultiplier = 257;
-
-// Define a macro for creating GdkColors from RGB values. This is a macro to
-// allow static construction of literals, etc. Use this like:
-// GdkColor white = GDK_COLOR_RGB(0xff, 0xff, 0xff);
-#define GDK_COLOR_RGB(r, g, b) {0, r * kSkiaToGDKMultiplier, \
- g * kSkiaToGDKMultiplier, b * kSkiaToGDKMultiplier}
-
namespace gfx {
class Rect;
-extern const GdkColor kGdkWhite;
-extern const GdkColor kGdkGray;
-extern const GdkColor kGdkBlack;
-extern const GdkColor kGdkGreen;
-
// Convert and copy a SkBitmap to a GdkPixbuf. NOTE: this uses BGRAToRGBA, so
// it is an expensive operation. The returned GdkPixbuf will have a refcount of
// 1, and the caller is responsible for unrefing it when done.
@@ -49,6 +36,18 @@ void SubtractRectanglesFromRegion(GdkRegion* region,
// resolution hasn't been set.
double GetPangoResolution();
+// Change windows accelerator style to GTK style. (GTK uses _ for
+// accelerators. Windows uses & with && as an escape for &.)
+std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label);
+
+// Removes the "&" accelerators from a Windows label.
+std::string RemoveWindowsStyleAccelerators(const std::string& label);
+
+// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
+// The caller is responsible for free()ing the data. If |stride| is 0, it's
+// assumed to be 4 * |width|.
+uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
+
} // namespace gfx
namespace {
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index 45c64c0..1a9c241 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -11,7 +11,6 @@
#include "app/keyboard_code_conversion_gtk.h"
#include "app/keyboard_codes.h"
#include "app/menus/menu_model.h"
-#include "base/gtk_util.h"
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
#include "base/time.h"
@@ -308,7 +307,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
GtkRadioMenuItem* radio_group,
GtkAccelGroup* accel_group) {
GtkWidget* menu_item = NULL;
- std::string label = gtk_util::ConvertAcceleratorsFromWindowsStyle(UTF16ToUTF8(
+ std::string label = gfx::ConvertAcceleratorsFromWindowsStyle(UTF16ToUTF8(
model_->GetLabelAt(index)));
menus::MenuModel::ItemType type = model_->GetTypeAt(index);