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

Side by Side Diff: chrome/browser/ui/libgtkui/gtk_ui.cc

Issue 2665753003: Gtk: Remove some unused members of GtkUi (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_ui.h ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/libgtkui/gtk_ui.h" 5 #include "chrome/browser/ui/libgtkui/gtk_ui.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 #include <X11/Xcursor/Xcursor.h> 9 #include <X11/Xcursor/Xcursor.h>
10 10
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } // namespace 401 } // namespace
402 402
403 GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) { 403 GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) {
404 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); 404 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess());
405 #if GTK_MAJOR_VERSION == 2 405 #if GTK_MAJOR_VERSION == 2
406 native_theme_ = NativeThemeGtk2::instance(); 406 native_theme_ = NativeThemeGtk2::instance();
407 fake_window_ = chrome_gtk_frame_new(); 407 fake_window_ = chrome_gtk_frame_new();
408 gtk_widget_realize(fake_window_); // Is this necessary? 408 gtk_widget_realize(fake_window_); // Is this necessary?
409 #elif GTK_MAJOR_VERSION == 3 409 #elif GTK_MAJOR_VERSION == 3
410 native_theme_ = NativeThemeGtk3::instance(); 410 native_theme_ = NativeThemeGtk3::instance();
411 (void)fake_window_; // Silence the unused warning.
411 #else 412 #else
412 #error "Unsupported GTK version" 413 #error "Unsupported GTK version"
413 #endif 414 #endif
414 } 415 }
415 416
416 GtkUi::~GtkUi() { 417 GtkUi::~GtkUi() {
417 #if GTK_MAJOR_VERSION == 2 418 #if GTK_MAJOR_VERSION == 2
418 gtk_widget_destroy(fake_window_); 419 gtk_widget_destroy(fake_window_);
419 #endif 420 #endif
420 } 421 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 colors_[ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE] = 857 colors_[ThemeProperties::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE] =
857 entry_inactive_border; 858 entry_inactive_border;
858 } 859 }
859 #endif 860 #endif
860 861
861 colors_[ThemeProperties::COLOR_CONTROL_BACKGROUND] = toolbar_color; 862 colors_[ThemeProperties::COLOR_CONTROL_BACKGROUND] = toolbar_color;
862 colors_[ThemeProperties::COLOR_TOOLBAR] = toolbar_color; 863 colors_[ThemeProperties::COLOR_TOOLBAR] = toolbar_color;
863 864
864 UpdateDeviceScaleFactor(); 865 UpdateDeviceScaleFactor();
865 866
866 // Build the various icon tints.
867 GetNormalButtonTintHSL(&button_tint_);
868 GetNormalEntryForegroundHSL(&entry_tint_);
869 GetSelectedEntryForegroundHSL(&selected_entry_tint_);
870
871 // We pick the text and background colors for the NTP out of the colors for a 867 // We pick the text and background colors for the NTP out of the colors for a
872 // GtkEntry. We do this because GtkEntries background color is never the same 868 // GtkEntry. We do this because GtkEntries background color is never the same
873 // as |toolbar_color|, is usually a white, and when it isn't a white, 869 // as |toolbar_color|, is usually a white, and when it isn't a white,
874 // provides sufficient contrast to |toolbar_color|. Try this out with 870 // provides sufficient contrast to |toolbar_color|. Try this out with
875 // Darklooks, HighContrastInverse or ThinIce. 871 // Darklooks, HighContrastInverse or ThinIce.
876 872
877 SkColor ntp_background = native_theme_->GetSystemColor( 873 SkColor ntp_background = native_theme_->GetSystemColor(
878 ui::NativeTheme::kColorId_TextfieldDefaultBackground); 874 ui::NativeTheme::kColorId_TextfieldDefaultBackground);
879 SkColor ntp_foreground = native_theme_->GetSystemColor( 875 SkColor ntp_foreground = native_theme_->GetSystemColor(
880 ui::NativeTheme::kColorId_TextfieldDefaultColor); 876 ui::NativeTheme::kColorId_TextfieldDefaultColor);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 GetBgColor("#headerbar.header-bar.titlebar:backdrop"); 962 GetBgColor("#headerbar.header-bar.titlebar:backdrop");
967 colors_[ThemeProperties::COLOR_FRAME] = color_frame; 963 colors_[ThemeProperties::COLOR_FRAME] = color_frame;
968 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive; 964 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive;
969 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = 965 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] =
970 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito); 966 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito);
971 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = 967 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] =
972 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito); 968 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito);
973 #endif 969 #endif
974 } 970 }
975 971
976 void GtkUi::GetNormalButtonTintHSL(color_utils::HSL* tint) const {
977 SkColor accent_color = native_theme_->GetSystemColor(
978 ui::NativeTheme::kColorId_ProminentButtonColor);
979 SkColor text_color = native_theme_->GetSystemColor(
980 ui::NativeTheme::kColorId_LabelEnabledColor);
981 SkColor base_color =
982 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
983
984 PickButtonTintFromColors(accent_color, text_color, base_color, tint);
985 }
986
987 void GtkUi::GetNormalEntryForegroundHSL(color_utils::HSL* tint) const {
988 SkColor accent_color = native_theme_->GetSystemColor(
989 ui::NativeTheme::kColorId_ProminentButtonColor);
990 SkColor text_color = native_theme_->GetSystemColor(
991 ui::NativeTheme::kColorId_TextfieldDefaultColor);
992 SkColor base_color = native_theme_->GetSystemColor(
993 ui::NativeTheme::kColorId_TextfieldDefaultBackground);
994
995 PickButtonTintFromColors(accent_color, text_color, base_color, tint);
996 }
997
998 void GtkUi::GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const {
999 // The simplest of all the tints. We just use the selected text in the entry
1000 // since the icons tinted this way will only be displayed against
1001 // base[GTK_STATE_SELECTED].
1002 SkColor color = native_theme_->GetSystemColor(
1003 ui::NativeTheme::kColorId_TextfieldSelectionColor);
1004
1005 color_utils::SkColorToHSL(color, tint);
1006 }
1007
1008 void GtkUi::UpdateDefaultFont() { 972 void GtkUi::UpdateDefaultFont() {
1009 GtkWidget* fake_label = gtk_label_new(nullptr); 973 GtkWidget* fake_label = gtk_label_new(nullptr);
1010 g_object_ref_sink(fake_label); // Remove the floating reference. 974 g_object_ref_sink(fake_label); // Remove the floating reference.
1011 PangoContext* pc = gtk_widget_get_pango_context(fake_label); 975 PangoContext* pc = gtk_widget_get_pango_context(fake_label);
1012 const PangoFontDescription* desc = pango_context_get_font_description(pc); 976 const PangoFontDescription* desc = pango_context_get_font_description(pc);
1013 977
1014 // Use gfx::FontRenderParams to select a family and determine the rendering 978 // Use gfx::FontRenderParams to select a family and determine the rendering
1015 // settings. 979 // settings.
1016 gfx::FontRenderParamsQuery query; 980 gfx::FontRenderParamsQuery query;
1017 query.families = 981 query.families =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1046
1083 float GtkUi::GetDeviceScaleFactor() const { 1047 float GtkUi::GetDeviceScaleFactor() const {
1084 return device_scale_factor_; 1048 return device_scale_factor_;
1085 } 1049 }
1086 1050
1087 } // namespace libgtkui 1051 } // namespace libgtkui
1088 1052
1089 views::LinuxUI* BuildGtkUi() { 1053 views::LinuxUI* BuildGtkUi() {
1090 return new libgtkui::GtkUi; 1054 return new libgtkui::GtkUi;
1091 } 1055 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698