OLD | NEW |
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_util.h" | 5 #include "chrome/browser/ui/libgtkui/gtk_util.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkx.h> | 9 #include <gdk/gdkx.h> |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 else if (actual_minor < minor) | 271 else if (actual_minor < minor) |
272 return false; | 272 return false; |
273 | 273 |
274 static int actual_micro = gtk_get_micro_version(); | 274 static int actual_micro = gtk_get_micro_version(); |
275 if (actual_micro >= micro) | 275 if (actual_micro >= micro) |
276 return true; | 276 return true; |
277 else | 277 else |
278 return false; | 278 return false; |
279 } | 279 } |
280 | 280 |
| 281 GtkStateFlags StateToStateFlags(ui::NativeTheme::State state) { |
| 282 switch (state) { |
| 283 case ui::NativeTheme::kDisabled: |
| 284 return GTK_STATE_FLAG_INSENSITIVE; |
| 285 case ui::NativeTheme::kHovered: |
| 286 return GTK_STATE_FLAG_PRELIGHT; |
| 287 case ui::NativeTheme::kNormal: |
| 288 return GTK_STATE_FLAG_NORMAL; |
| 289 case ui::NativeTheme::kPressed: |
| 290 return static_cast<GtkStateFlags>(GTK_STATE_FLAG_PRELIGHT | |
| 291 GTK_STATE_FLAG_ACTIVE); |
| 292 default: |
| 293 NOTREACHED(); |
| 294 return GTK_STATE_FLAG_NORMAL; |
| 295 } |
| 296 } |
| 297 |
281 ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context, | 298 ScopedStyleContext AppendCssNodeToStyleContext(GtkStyleContext* context, |
282 const std::string& css_node) { | 299 const std::string& css_node) { |
283 GtkWidgetPath* path = | 300 GtkWidgetPath* path = |
284 context ? gtk_widget_path_copy(gtk_style_context_get_path(context)) | 301 context ? gtk_widget_path_copy(gtk_style_context_get_path(context)) |
285 : gtk_widget_path_new(); | 302 : gtk_widget_path_new(); |
286 | 303 |
287 enum { | 304 enum { |
288 CSS_TYPE, | 305 CSS_TYPE, |
289 CSS_NAME, | 306 CSS_NAME, |
290 CSS_CLASS, | 307 CSS_CLASS, |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 548 } |
532 | 549 |
533 CairoSurface surface(gfx::Size(w, h)); | 550 CairoSurface surface(gfx::Size(w, h)); |
534 gtk_render_background(context, surface.cairo(), 0, 0, w, h); | 551 gtk_render_background(context, surface.cairo(), 0, 0, w, h); |
535 gtk_render_frame(context, surface.cairo(), 0, 0, w, h); | 552 gtk_render_frame(context, surface.cairo(), 0, 0, w, h); |
536 return surface.GetAveragePixelValue(false); | 553 return surface.GetAveragePixelValue(false); |
537 } | 554 } |
538 #endif | 555 #endif |
539 | 556 |
540 } // namespace libgtkui | 557 } // namespace libgtkui |
OLD | NEW |