OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/native_theme_gtk.h" | 5 #include "chrome/browser/ui/libgtkui/native_theme_gtk3.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" | 9 #include "chrome/browser/ui/libgtkui/chrome_gtk_frame.h" |
10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" | 10 #include "chrome/browser/ui/libgtkui/chrome_gtk_menu_subclasses.h" |
11 #include "chrome/browser/ui/libgtkui/gtk_ui.h" | |
12 #include "chrome/browser/ui/libgtkui/gtk_util.h" | 11 #include "chrome/browser/ui/libgtkui/gtk_util.h" |
13 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" | 12 #include "chrome/browser/ui/libgtkui/skia_utils_gtk.h" |
14 #include "third_party/skia/include/core/SkColor.h" | |
15 #include "ui/gfx/color_palette.h" | |
16 #include "ui/gfx/color_utils.h" | 13 #include "ui/gfx/color_utils.h" |
17 #include "ui/gfx/geometry/rect.h" | |
18 #include "ui/gfx/geometry/size.h" | |
19 #include "ui/gfx/path.h" | |
20 #include "ui/gfx/skia_util.h" | |
21 #include "ui/native_theme/common_theme.h" | |
22 #include "ui/native_theme/native_theme_aura.h" | |
23 #include "ui/native_theme/native_theme_dark_aura.h" | 14 #include "ui/native_theme/native_theme_dark_aura.h" |
24 | 15 |
25 namespace libgtkui { | 16 namespace libgtkui { |
26 | 17 |
27 namespace { | 18 namespace { |
28 | 19 |
29 // Theme colors returned by GetSystemColor(). | |
30 const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128); | |
31 const SkColor kURLTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); | |
32 | |
33 // Generates the normal URL color, a green color used in unhighlighted URL | |
34 // text. It is a mix of |kURLTextColor| and the current text color. Unlike the | |
35 // selected text color, it is more important to match the qualities of the | |
36 // foreground typeface color instead of taking the background into account. | |
37 SkColor NormalURLColor(SkColor foreground) { | |
38 color_utils::HSL fg_hsl, hue_hsl; | |
39 color_utils::SkColorToHSL(foreground, &fg_hsl); | |
40 color_utils::SkColorToHSL(kURLTextColor, &hue_hsl); | |
41 | |
42 // Only allow colors that have a fair amount of saturation in them (color vs | |
43 // white). This means that our output color will always be fairly green. | |
44 double s = std::max(0.5, fg_hsl.s); | |
45 | |
46 // Make sure the luminance is at least as bright as the |kURLTextColor| green | |
47 // would be if we were to use that. | |
48 double l; | |
49 if (fg_hsl.l < hue_hsl.l) | |
50 l = hue_hsl.l; | |
51 else | |
52 l = (fg_hsl.l + hue_hsl.l) / 2; | |
53 | |
54 color_utils::HSL output = {hue_hsl.h, s, l}; | |
55 return color_utils::HSLToSkColor(output, 255); | |
56 } | |
57 | |
58 // Generates the selected URL color, a green color used on URL text in the | |
59 // currently highlighted entry in the autocomplete popup. It's a mix of | |
60 // |kURLTextColor|, the current text color, and the background color (the | |
61 // select highlight). It is more important to contrast with the background | |
62 // saturation than to look exactly like the foreground color. | |
63 SkColor SelectedURLColor(SkColor foreground, SkColor background) { | |
64 color_utils::HSL fg_hsl, bg_hsl, hue_hsl; | |
65 color_utils::SkColorToHSL(foreground, &fg_hsl); | |
66 color_utils::SkColorToHSL(background, &bg_hsl); | |
67 color_utils::SkColorToHSL(kURLTextColor, &hue_hsl); | |
68 | |
69 // The saturation of the text should be opposite of the background, clamped | |
70 // to 0.2-0.8. We make sure it's greater than 0.2 so there's some color, but | |
71 // less than 0.8 so it's not the oversaturated neon-color. | |
72 double opposite_s = 1 - bg_hsl.s; | |
73 double s = std::max(0.2, std::min(0.8, opposite_s)); | |
74 | |
75 // The luminance should match the luminance of the foreground text. Again, | |
76 // we clamp so as to have at some amount of color (green) in the text. | |
77 double opposite_l = fg_hsl.l; | |
78 double l = std::max(0.1, std::min(0.9, opposite_l)); | |
79 | |
80 color_utils::HSL output = {hue_hsl.h, s, l}; | |
81 return color_utils::HSLToSkColor(output, 255); | |
82 } | |
83 | |
84 enum WidgetState { | 20 enum WidgetState { |
85 NORMAL = 0, | 21 NORMAL = 0, |
86 ACTIVE = 1, | 22 ACTIVE = 1, |
87 PRELIGHT = 2, | 23 PRELIGHT = 2, |
88 SELECTED = 3, | 24 SELECTED = 3, |
89 INSENSITIVE = 4, | 25 INSENSITIVE = 4, |
90 }; | 26 }; |
91 | 27 |
92 #if GTK_MAJOR_VERSION == 2 | |
93 // Same order as enum WidgetState above | |
94 const GtkStateType stateMap[] = { | |
95 GTK_STATE_NORMAL, | |
96 GTK_STATE_ACTIVE, | |
97 GTK_STATE_PRELIGHT, | |
98 GTK_STATE_SELECTED, | |
99 GTK_STATE_INSENSITIVE, | |
100 }; | |
101 | |
102 SkColor GetFGColor(GtkWidget* widget, WidgetState state) { | |
103 return GdkColorToSkColor(gtk_rc_get_style(widget)->fg[stateMap[state]]); | |
104 } | |
105 SkColor GetBGColor(GtkWidget* widget, WidgetState state) { | |
106 return GdkColorToSkColor(gtk_rc_get_style(widget)->bg[stateMap[state]]); | |
107 } | |
108 | |
109 SkColor GetTextColor(GtkWidget* widget, WidgetState state) { | |
110 return GdkColorToSkColor(gtk_rc_get_style(widget)->text[stateMap[state]]); | |
111 } | |
112 SkColor GetTextAAColor(GtkWidget* widget, WidgetState state) { | |
113 return GdkColorToSkColor(gtk_rc_get_style(widget)->text_aa[stateMap[state]]); | |
114 } | |
115 SkColor GetBaseColor(GtkWidget* widget, WidgetState state) { | |
116 return GdkColorToSkColor(gtk_rc_get_style(widget)->base[stateMap[state]]); | |
117 } | |
118 | |
119 #else | |
120 // Same order as enum WidgetState above | 28 // Same order as enum WidgetState above |
121 const GtkStateFlags stateMap[] = { | 29 const GtkStateFlags stateMap[] = { |
122 GTK_STATE_FLAG_NORMAL, GTK_STATE_FLAG_ACTIVE, | 30 GTK_STATE_FLAG_NORMAL, GTK_STATE_FLAG_ACTIVE, |
123 GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_SELECTED, | 31 GTK_STATE_FLAG_PRELIGHT, GTK_STATE_FLAG_SELECTED, |
124 GTK_STATE_FLAG_INSENSITIVE, | 32 GTK_STATE_FLAG_INSENSITIVE, |
125 }; | 33 }; |
126 | 34 |
127 SkColor GetFGColor(GtkWidget* widget, WidgetState state) { | 35 SkColor GetFGColor(GtkWidget* widget, WidgetState state) { |
128 GdkRGBA color; | 36 GdkRGBA color; |
129 gtk_style_context_get_color(gtk_widget_get_style_context(widget), | 37 gtk_style_context_get_color(gtk_widget_get_style_context(widget), |
(...skipping 18 matching lines...) Expand all Loading... |
148 SkColor GetTextColor(GtkWidget* widget, WidgetState state) { | 56 SkColor GetTextColor(GtkWidget* widget, WidgetState state) { |
149 return GetFGColor(widget, state); | 57 return GetFGColor(widget, state); |
150 } | 58 } |
151 SkColor GetTextAAColor(GtkWidget* widget, WidgetState state) { | 59 SkColor GetTextAAColor(GtkWidget* widget, WidgetState state) { |
152 return GetFGColor(widget, state); | 60 return GetFGColor(widget, state); |
153 } | 61 } |
154 SkColor GetBaseColor(GtkWidget* widget, WidgetState state) { | 62 SkColor GetBaseColor(GtkWidget* widget, WidgetState state) { |
155 return GetBGColor(widget, state); | 63 return GetBGColor(widget, state); |
156 } | 64 } |
157 | 65 |
158 #endif | |
159 | |
160 } // namespace | 66 } // namespace |
161 | 67 |
162 // static | 68 // static |
163 NativeThemeGtk2* NativeThemeGtk2::instance() { | 69 NativeThemeGtk3* NativeThemeGtk3::instance() { |
164 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk2, s_native_theme, ()); | 70 CR_DEFINE_STATIC_LOCAL(NativeThemeGtk3, s_native_theme, ()); |
165 return &s_native_theme; | 71 return &s_native_theme; |
166 } | 72 } |
167 | 73 |
168 // Constructors automatically called | 74 // Constructors automatically called |
169 NativeThemeGtk2::NativeThemeGtk2() {} | 75 NativeThemeGtk3::NativeThemeGtk3() {} |
170 // This doesn't actually get called | 76 // This doesn't actually get called |
171 NativeThemeGtk2::~NativeThemeGtk2() {} | 77 NativeThemeGtk3::~NativeThemeGtk3() {} |
172 | 78 |
173 void NativeThemeGtk2::PaintMenuPopupBackground( | 79 SkColor NativeThemeGtk3::GetSystemColor(ColorId color_id) const { |
174 SkCanvas* canvas, | |
175 const gfx::Size& size, | |
176 const MenuBackgroundExtraParams& menu_background) const { | |
177 if (menu_background.corner_radius > 0) { | |
178 SkPaint paint; | |
179 paint.setStyle(SkPaint::kFill_Style); | |
180 paint.setFlags(SkPaint::kAntiAlias_Flag); | |
181 paint.setColor(GetSystemColor(kColorId_MenuBackgroundColor)); | |
182 | |
183 gfx::Path path; | |
184 SkRect rect = SkRect::MakeWH(SkIntToScalar(size.width()), | |
185 SkIntToScalar(size.height())); | |
186 SkScalar radius = SkIntToScalar(menu_background.corner_radius); | |
187 SkScalar radii[8] = {radius, radius, radius, radius, | |
188 radius, radius, radius, radius}; | |
189 path.addRoundRect(rect, radii); | |
190 | |
191 canvas->drawPath(path, paint); | |
192 } else { | |
193 canvas->drawColor(GetSystemColor(kColorId_MenuBackgroundColor), | |
194 SkBlendMode::kSrc); | |
195 } | |
196 } | |
197 | |
198 void NativeThemeGtk2::PaintMenuItemBackground( | |
199 SkCanvas* canvas, | |
200 State state, | |
201 const gfx::Rect& rect, | |
202 const MenuItemExtraParams& menu_item) const { | |
203 SkColor color; | |
204 SkPaint paint; | |
205 switch (state) { | |
206 case NativeTheme::kNormal: | |
207 case NativeTheme::kDisabled: | |
208 color = GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor); | |
209 paint.setColor(color); | |
210 break; | |
211 case NativeTheme::kHovered: | |
212 color = | |
213 GetSystemColor(NativeTheme::kColorId_FocusedMenuItemBackgroundColor); | |
214 paint.setColor(color); | |
215 break; | |
216 default: | |
217 NOTREACHED() << "Invalid state " << state; | |
218 break; | |
219 } | |
220 if (menu_item.corner_radius > 0) { | |
221 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); | |
222 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); | |
223 return; | |
224 } | |
225 canvas->drawRect(gfx::RectToSkRect(rect), paint); | |
226 } | |
227 | |
228 SkColor NativeThemeGtk2::GetSystemColor(ColorId color_id) const { | |
229 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); | 80 const SkColor kPositiveTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); |
230 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29); | 81 const SkColor kNegativeTextColor = SkColorSetRGB(0xc5, 0x39, 0x29); |
231 | 82 |
232 switch (color_id) { | 83 switch (color_id) { |
233 // Windows | 84 // Windows |
234 case kColorId_WindowBackground: | 85 case kColorId_WindowBackground: |
235 return GetBGColor(GetWindow(), SELECTED); | 86 return GetBGColor(GetWindow(), SELECTED); |
236 | 87 |
237 // Dialogs | 88 // Dialogs |
238 case kColorId_DialogBackground: | 89 case kColorId_DialogBackground: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 case kColorId_LabelTextSelectionColor: | 126 case kColorId_LabelTextSelectionColor: |
276 return GetTextColor(GetLabel(), SELECTED); | 127 return GetTextColor(GetLabel(), SELECTED); |
277 case kColorId_LabelTextSelectionBackgroundFocused: | 128 case kColorId_LabelTextSelectionBackgroundFocused: |
278 return GetBaseColor(GetLabel(), SELECTED); | 129 return GetBaseColor(GetLabel(), SELECTED); |
279 | 130 |
280 // Link | 131 // Link |
281 case kColorId_LinkDisabled: | 132 case kColorId_LinkDisabled: |
282 return SkColorSetA(GetSystemColor(kColorId_LinkEnabled), 0xBB); | 133 return SkColorSetA(GetSystemColor(kColorId_LinkEnabled), 0xBB); |
283 case kColorId_LinkEnabled: { | 134 case kColorId_LinkEnabled: { |
284 SkColor link_color = SK_ColorTRANSPARENT; | 135 SkColor link_color = SK_ColorTRANSPARENT; |
285 GetChromeStyleColor("link-color", &link_color); | 136 GdkColor* style_color = nullptr; |
| 137 gtk_widget_style_get(GetWindow(), "link-color", &style_color, nullptr); |
| 138 if (style_color) { |
| 139 link_color = GdkColorToSkColor(*style_color); |
| 140 gdk_color_free(style_color); |
| 141 } |
286 if (link_color != SK_ColorTRANSPARENT) | 142 if (link_color != SK_ColorTRANSPARENT) |
287 return link_color; | 143 return link_color; |
288 // Default color comes from gtklinkbutton.c. | 144 // Default color comes from gtklinkbutton.c. |
289 return SkColorSetRGB(0x00, 0x00, 0xEE); | 145 return SkColorSetRGB(0x00, 0x00, 0xEE); |
290 } | 146 } |
291 case kColorId_LinkPressed: | 147 case kColorId_LinkPressed: |
292 return SK_ColorRED; | 148 return SK_ColorRED; |
293 | 149 |
294 // Button | 150 // Button |
295 case kColorId_ButtonEnabledColor: | 151 case kColorId_ButtonEnabledColor: |
(...skipping 18 matching lines...) Expand all Loading... |
314 return GetTextColor(GetLabel(), SELECTED); | 170 return GetTextColor(GetLabel(), SELECTED); |
315 case kColorId_ButtonPressedShade: | 171 case kColorId_ButtonPressedShade: |
316 return SK_ColorTRANSPARENT; | 172 return SK_ColorTRANSPARENT; |
317 | 173 |
318 // Textfield | 174 // Textfield |
319 case kColorId_TextfieldDefaultColor: | 175 case kColorId_TextfieldDefaultColor: |
320 return GetTextColor(GetEntry(), NORMAL); | 176 return GetTextColor(GetEntry(), NORMAL); |
321 case kColorId_TextfieldDefaultBackground: | 177 case kColorId_TextfieldDefaultBackground: |
322 return GetBaseColor(GetEntry(), NORMAL); | 178 return GetBaseColor(GetEntry(), NORMAL); |
323 | 179 |
324 #if GTK_MAJOR_VERSION == 2 | |
325 case kColorId_TextfieldReadOnlyColor: | |
326 return GetTextColor(GetEntry(), ACTIVE); | |
327 case kColorId_TextfieldReadOnlyBackground: | |
328 return GetBaseColor(GetEntry(), ACTIVE); | |
329 case kColorId_TextfieldSelectionColor: | |
330 return GetTextColor(GetEntry(), SELECTED); | |
331 case kColorId_TextfieldSelectionBackgroundFocused: | |
332 return GetBaseColor(GetEntry(), SELECTED); | |
333 #else | |
334 case kColorId_TextfieldReadOnlyColor: | 180 case kColorId_TextfieldReadOnlyColor: |
335 return GetTextColor(GetEntry(), SELECTED); | 181 return GetTextColor(GetEntry(), SELECTED); |
336 case kColorId_TextfieldReadOnlyBackground: | 182 case kColorId_TextfieldReadOnlyBackground: |
337 return GetBaseColor(GetEntry(), SELECTED); | 183 return GetBaseColor(GetEntry(), SELECTED); |
338 case kColorId_TextfieldSelectionColor: | 184 case kColorId_TextfieldSelectionColor: |
339 return GetTextColor(GetLabel(), SELECTED); | 185 return GetTextColor(GetLabel(), SELECTED); |
340 case kColorId_TextfieldSelectionBackgroundFocused: | 186 case kColorId_TextfieldSelectionBackgroundFocused: |
341 return GetBaseColor(GetLabel(), SELECTED); | 187 return GetBaseColor(GetLabel(), SELECTED); |
342 #endif | |
343 | 188 |
344 // Tooltips | 189 // Tooltips |
345 case kColorId_TooltipBackground: | 190 case kColorId_TooltipBackground: |
346 return GetBGColor(GetTooltip(), NORMAL); | 191 return GetBGColor(GetTooltip(), NORMAL); |
347 case kColorId_TooltipText: | 192 case kColorId_TooltipText: |
348 return GetFGColor(GetTooltip(), NORMAL); | 193 return GetFGColor(GetTooltip(), NORMAL); |
349 | 194 |
350 // Trees and Tables (implemented on GTK using the same class) | 195 // Trees and Tables (implemented on GTK using the same class) |
351 case kColorId_TableBackground: | 196 case kColorId_TableBackground: |
352 case kColorId_TreeBackground: | 197 case kColorId_TreeBackground: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 294 } |
450 | 295 |
451 case kColorId_NumColors: | 296 case kColorId_NumColors: |
452 NOTREACHED(); | 297 NOTREACHED(); |
453 break; | 298 break; |
454 } | 299 } |
455 | 300 |
456 return kInvalidColorIdColor; | 301 return kInvalidColorIdColor; |
457 } | 302 } |
458 | 303 |
459 // Get ChromeGtkFrame theme colors. No-op in GTK3. | 304 GtkWidget* NativeThemeGtk3::GetWindow() const { |
460 bool NativeThemeGtk2::GetChromeStyleColor(const char* style_property, | |
461 SkColor* ret_color) const { | |
462 #if GTK_MAJOR_VERSION == 2 | |
463 GdkColor* style_color = nullptr; | |
464 gtk_widget_style_get(GetWindow(), style_property, &style_color, nullptr); | |
465 if (style_color) { | |
466 *ret_color = GdkColorToSkColor(*style_color); | |
467 gdk_color_free(style_color); | |
468 return true; | |
469 } | |
470 #endif | |
471 | |
472 return false; | |
473 } | |
474 | |
475 GtkWidget* NativeThemeGtk2::GetWindow() const { | |
476 static GtkWidget* fake_window = NULL; | 305 static GtkWidget* fake_window = NULL; |
477 | 306 |
478 if (!fake_window) { | 307 if (!fake_window) { |
479 fake_window = chrome_gtk_frame_new(); | 308 fake_window = chrome_gtk_frame_new(); |
480 gtk_widget_realize(fake_window); | 309 gtk_widget_realize(fake_window); |
481 } | 310 } |
482 | 311 |
483 return fake_window; | 312 return fake_window; |
484 } | 313 } |
485 | 314 |
486 GtkWidget* NativeThemeGtk2::GetEntry() const { | 315 GtkWidget* NativeThemeGtk3::GetEntry() const { |
487 static GtkWidget* fake_entry = NULL; | 316 static GtkWidget* fake_entry = NULL; |
488 | 317 |
489 if (!fake_entry) { | 318 if (!fake_entry) { |
490 fake_entry = gtk_entry_new(); | 319 fake_entry = gtk_entry_new(); |
491 | 320 |
492 // The fake entry needs to be in the window so it can be realized so we can | 321 // The fake entry needs to be in the window so it can be realized so we can |
493 // use the computed parts of the style. | 322 // use the computed parts of the style. |
494 gtk_container_add(GTK_CONTAINER(GetWindow()), fake_entry); | 323 gtk_container_add(GTK_CONTAINER(GetWindow()), fake_entry); |
495 gtk_widget_realize(fake_entry); | 324 gtk_widget_realize(fake_entry); |
496 } | 325 } |
497 | 326 |
498 return fake_entry; | 327 return fake_entry; |
499 } | 328 } |
500 | 329 |
501 GtkWidget* NativeThemeGtk2::GetLabel() const { | 330 GtkWidget* NativeThemeGtk3::GetLabel() const { |
502 static GtkWidget* fake_label = NULL; | 331 static GtkWidget* fake_label = NULL; |
503 | 332 |
504 if (!fake_label) | 333 if (!fake_label) |
505 fake_label = gtk_label_new(""); | 334 fake_label = gtk_label_new(""); |
506 | 335 |
507 return fake_label; | 336 return fake_label; |
508 } | 337 } |
509 | 338 |
510 GtkWidget* NativeThemeGtk2::GetButton() const { | 339 GtkWidget* NativeThemeGtk3::GetButton() const { |
511 static GtkWidget* fake_button = NULL; | 340 static GtkWidget* fake_button = NULL; |
512 | 341 |
513 if (!fake_button) | 342 if (!fake_button) |
514 fake_button = gtk_button_new(); | 343 fake_button = gtk_button_new(); |
515 | 344 |
516 return fake_button; | 345 return fake_button; |
517 } | 346 } |
518 | 347 |
519 GtkWidget* NativeThemeGtk2::GetBlueButton() const { | 348 GtkWidget* NativeThemeGtk3::GetBlueButton() const { |
520 static GtkWidget* fake_bluebutton = NULL; | 349 static GtkWidget* fake_bluebutton = NULL; |
521 | 350 |
522 if (!fake_bluebutton) { | 351 if (!fake_bluebutton) { |
523 fake_bluebutton = gtk_button_new(); | 352 fake_bluebutton = gtk_button_new(); |
524 TurnButtonBlue(fake_bluebutton); | 353 TurnButtonBlue(fake_bluebutton); |
525 } | 354 } |
526 | 355 |
527 return fake_bluebutton; | 356 return fake_bluebutton; |
528 } | 357 } |
529 | 358 |
530 GtkWidget* NativeThemeGtk2::GetTree() const { | 359 GtkWidget* NativeThemeGtk3::GetTree() const { |
531 static GtkWidget* fake_tree = NULL; | 360 static GtkWidget* fake_tree = NULL; |
532 | 361 |
533 if (!fake_tree) | 362 if (!fake_tree) |
534 fake_tree = gtk_tree_view_new(); | 363 fake_tree = gtk_tree_view_new(); |
535 | 364 |
536 return fake_tree; | 365 return fake_tree; |
537 } | 366 } |
538 | 367 |
539 GtkWidget* NativeThemeGtk2::GetTooltip() const { | 368 GtkWidget* NativeThemeGtk3::GetTooltip() const { |
540 static GtkWidget* fake_tooltip = NULL; | 369 static GtkWidget* fake_tooltip = NULL; |
541 | 370 |
542 if (!fake_tooltip) { | 371 if (!fake_tooltip) { |
543 fake_tooltip = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 372 fake_tooltip = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
544 gtk_widget_set_name(fake_tooltip, "gtk-tooltip"); | 373 gtk_widget_set_name(fake_tooltip, "gtk-tooltip"); |
545 gtk_widget_realize(fake_tooltip); | 374 gtk_widget_realize(fake_tooltip); |
546 } | 375 } |
547 | 376 |
548 return fake_tooltip; | 377 return fake_tooltip; |
549 } | 378 } |
550 | 379 |
551 GtkWidget* NativeThemeGtk2::GetMenu() const { | 380 GtkWidget* NativeThemeGtk3::GetMenu() const { |
552 static GtkWidget* fake_menu = NULL; | 381 static GtkWidget* fake_menu = NULL; |
553 | 382 |
554 if (!fake_menu) | 383 if (!fake_menu) |
555 fake_menu = gtk_custom_menu_new(); | 384 fake_menu = gtk_custom_menu_new(); |
556 | 385 |
557 return fake_menu; | 386 return fake_menu; |
558 } | 387 } |
559 | 388 |
560 GtkWidget* NativeThemeGtk2::GetMenuItem() const { | 389 GtkWidget* NativeThemeGtk3::GetMenuItem() const { |
561 static GtkWidget* fake_menu_item = NULL; | 390 static GtkWidget* fake_menu_item = NULL; |
562 | 391 |
563 if (!fake_menu_item) { | 392 if (!fake_menu_item) { |
564 fake_menu_item = gtk_custom_menu_item_new(); | 393 fake_menu_item = gtk_custom_menu_item_new(); |
565 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item); | 394 gtk_menu_shell_append(GTK_MENU_SHELL(GetMenu()), fake_menu_item); |
566 } | 395 } |
567 | 396 |
568 return fake_menu_item; | 397 return fake_menu_item; |
569 } | 398 } |
570 | 399 |
571 } // namespace libgtkui | 400 } // namespace libgtkui |
OLD | NEW |