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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); | 454 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); |
455 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, | 455 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, |
456 gtk_util::kGroupIndent, 0); | 456 gtk_util::kGroupIndent, 0); |
457 gtk_container_add(GTK_CONTAINER(content_alignment), content); | 457 gtk_container_add(GTK_CONTAINER(content_alignment), content); |
458 return content_alignment; | 458 return content_alignment; |
459 } | 459 } |
460 | 460 |
461 void UpdateGtkFontSettings(RendererPreferences* prefs) { | 461 void UpdateGtkFontSettings(RendererPreferences* prefs) { |
462 DCHECK(prefs); | 462 DCHECK(prefs); |
463 | 463 |
| 464 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is |
| 465 // the default value for gtk-cursor-blink-time. |
| 466 static const gint kGtkDefaultCursorBlinkTime = 1200; |
| 467 |
| 468 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; |
| 469 gboolean cursor_blink = TRUE; |
464 gint antialias = 0; | 470 gint antialias = 0; |
465 gint hinting = 0; | 471 gint hinting = 0; |
466 gchar* hint_style = NULL; | 472 gchar* hint_style = NULL; |
467 gchar* rgba_style = NULL; | 473 gchar* rgba_style = NULL; |
468 g_object_get(gtk_settings_get_default(), | 474 g_object_get(gtk_settings_get_default(), |
| 475 "gtk-cursor-blink-time", &cursor_blink_time, |
| 476 "gtk-cursor-blink", &cursor_blink, |
469 "gtk-xft-antialias", &antialias, | 477 "gtk-xft-antialias", &antialias, |
470 "gtk-xft-hinting", &hinting, | 478 "gtk-xft-hinting", &hinting, |
471 "gtk-xft-hintstyle", &hint_style, | 479 "gtk-xft-hintstyle", &hint_style, |
472 "gtk-xft-rgba", &rgba_style, | 480 "gtk-xft-rgba", &rgba_style, |
473 NULL); | 481 NULL); |
474 | 482 |
475 // Set some reasonable defaults. | 483 // Set some reasonable defaults. |
476 prefs->should_antialias_text = true; | 484 prefs->should_antialias_text = true; |
477 prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; | 485 prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; |
478 prefs->subpixel_rendering = | 486 prefs->subpixel_rendering = |
479 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; | 487 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; |
480 | 488 |
| 489 if (cursor_blink) { |
| 490 // Dividing by 2*1000ms follows the WebKit GTK port and makes the blink |
| 491 // frequency appear similar to the omnibox. Without this the blink is too |
| 492 // slow. |
| 493 prefs->caret_blink_interval = cursor_blink_time / 2000.; |
| 494 } else { |
| 495 prefs->caret_blink_interval = 0; |
| 496 } |
| 497 |
481 // g_object_get() doesn't tell us whether the properties were present or not, | 498 // g_object_get() doesn't tell us whether the properties were present or not, |
482 // but if they aren't (because gnome-settings-daemon isn't running), we'll get | 499 // but if they aren't (because gnome-settings-daemon isn't running), we'll get |
483 // NULL values for the strings. | 500 // NULL values for the strings. |
484 if (hint_style && rgba_style) { | 501 if (hint_style && rgba_style) { |
485 prefs->should_antialias_text = antialias; | 502 prefs->should_antialias_text = antialias; |
486 | 503 |
487 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { | 504 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { |
488 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; | 505 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; |
489 } else if (strcmp(hint_style, "hintslight") == 0) { | 506 } else if (strcmp(hint_style, "hintslight") == 0) { |
490 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; | 507 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 g_signal_connect(container, "expose-event", | 703 g_signal_connect(container, "expose-event", |
687 G_CALLBACK(PaintNoBackground), NULL); | 704 G_CALLBACK(PaintNoBackground), NULL); |
688 } | 705 } |
689 | 706 |
690 void WrapLabelAtAllocationHack(GtkWidget* label) { | 707 void WrapLabelAtAllocationHack(GtkWidget* label) { |
691 g_signal_connect(label, "size-allocate", | 708 g_signal_connect(label, "size-allocate", |
692 G_CALLBACK(OnLabelAllocate), NULL); | 709 G_CALLBACK(OnLabelAllocate), NULL); |
693 } | 710 } |
694 | 711 |
695 } // namespace gtk_util | 712 } // namespace gtk_util |
OLD | NEW |