OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/gtk_util.h" | 5 #include "chrome/common/gtk_util.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 | 9 |
10 #include <cstdarg> | 10 #include <cstdarg> |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 433 } |
434 | 434 |
435 GtkWidget* IndentWidget(GtkWidget* content) { | 435 GtkWidget* IndentWidget(GtkWidget* content) { |
436 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); | 436 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); |
437 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, | 437 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, |
438 gtk_util::kGroupIndent, 0); | 438 gtk_util::kGroupIndent, 0); |
439 gtk_container_add(GTK_CONTAINER(content_alignment), content); | 439 gtk_container_add(GTK_CONTAINER(content_alignment), content); |
440 return content_alignment; | 440 return content_alignment; |
441 } | 441 } |
442 | 442 |
443 void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs, | 443 void UpdateGtkFontSettings(RendererPreferences* prefs) { |
444 bool use_gtk_theme) { | |
445 DCHECK(prefs); | 444 DCHECK(prefs); |
446 | 445 |
447 gint antialias = 0; | 446 gint antialias = 0; |
448 gint hinting = 0; | 447 gint hinting = 0; |
449 gchar* hint_style = NULL; | 448 gchar* hint_style = NULL; |
450 gchar* rgba_style = NULL; | 449 gchar* rgba_style = NULL; |
451 g_object_get(gtk_settings_get_default(), | 450 g_object_get(gtk_settings_get_default(), |
452 "gtk-xft-antialias", &antialias, | 451 "gtk-xft-antialias", &antialias, |
453 "gtk-xft-hinting", &hinting, | 452 "gtk-xft-hinting", &hinting, |
454 "gtk-xft-hintstyle", &hint_style, | 453 "gtk-xft-hintstyle", &hint_style, |
(...skipping 28 matching lines...) Expand all Loading... |
483 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; | 482 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; |
484 } else if (strcmp(rgba_style, "bgr") == 0) { | 483 } else if (strcmp(rgba_style, "bgr") == 0) { |
485 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; | 484 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; |
486 } else if (strcmp(rgba_style, "vrgb") == 0) { | 485 } else if (strcmp(rgba_style, "vrgb") == 0) { |
487 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; | 486 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; |
488 } else if (strcmp(rgba_style, "vbgr") == 0) { | 487 } else if (strcmp(rgba_style, "vbgr") == 0) { |
489 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; | 488 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; |
490 } | 489 } |
491 } | 490 } |
492 | 491 |
493 static GtkWidget* fixed = gtk_fixed_new(); | |
494 GtkStyle* style = gtk_rc_get_style(fixed); | |
495 // base[SELECTED] seems more appropriate but in practice it is often too light | |
496 // to be easily visible. | |
497 GdkColor color = style->bg[GTK_STATE_SELECTED]; | |
498 prefs->focus_ring_color = | |
499 SkColorSetRGB(color.red / 257, color.green / 257, color.blue / 257); | |
500 | |
501 GdkColor thumb_active_color, thumb_inactive_color, track_color; | |
502 GtkThemeProvider::GetScrollbarColors(&thumb_active_color, | |
503 &thumb_inactive_color, | |
504 &track_color, | |
505 use_gtk_theme); | |
506 prefs->thumb_active_color = | |
507 SkColorSetRGB(thumb_active_color.red / 257, | |
508 thumb_active_color.green / 257, | |
509 thumb_active_color.blue / 257); | |
510 prefs->thumb_inactive_color = | |
511 SkColorSetRGB(thumb_inactive_color.red / 257, | |
512 thumb_inactive_color.green / 257, | |
513 thumb_inactive_color.blue / 257); | |
514 prefs->track_color = | |
515 SkColorSetRGB(track_color.red / 257, | |
516 track_color.green / 257, | |
517 track_color.blue / 257); | |
518 | |
519 if (hint_style) | 492 if (hint_style) |
520 g_free(hint_style); | 493 g_free(hint_style); |
521 if (rgba_style) | 494 if (rgba_style) |
522 g_free(rgba_style); | 495 g_free(rgba_style); |
523 } | 496 } |
524 | 497 |
525 gfx::Point ScreenPoint(GtkWidget* widget) { | 498 gfx::Point ScreenPoint(GtkWidget* widget) { |
526 int x, y; | 499 int x, y; |
527 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y, | 500 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y, |
528 NULL); | 501 NULL); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 g_signal_connect(container, "expose-event", | 637 g_signal_connect(container, "expose-event", |
665 G_CALLBACK(PaintNoBackground), NULL); | 638 G_CALLBACK(PaintNoBackground), NULL); |
666 } | 639 } |
667 | 640 |
668 void WrapLabelAtAllocationHack(GtkWidget* label) { | 641 void WrapLabelAtAllocationHack(GtkWidget* label) { |
669 g_signal_connect(label, "size-allocate", | 642 g_signal_connect(label, "size-allocate", |
670 G_CALLBACK(OnLabelAllocate), NULL); | 643 G_CALLBACK(OnLabelAllocate), NULL); |
671 } | 644 } |
672 | 645 |
673 } // namespace gtk_util | 646 } // namespace gtk_util |
OLD | NEW |