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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); | 386 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); |
387 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, | 387 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, |
388 gtk_util::kGroupIndent, 0); | 388 gtk_util::kGroupIndent, 0); |
389 gtk_container_add(GTK_CONTAINER(content_alignment), content); | 389 gtk_container_add(GTK_CONTAINER(content_alignment), content); |
390 return content_alignment; | 390 return content_alignment; |
391 } | 391 } |
392 | 392 |
393 void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) { | 393 void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) { |
394 DCHECK(prefs); | 394 DCHECK(prefs); |
395 | 395 |
| 396 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is |
| 397 // the default value for gtk-cursor-blink-time. |
| 398 static const gint kGtkDefaultCursorBlinkTime = 1200; |
| 399 |
| 400 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; |
| 401 gboolean cursor_blink = TRUE; |
396 gint antialias = 0; | 402 gint antialias = 0; |
397 gint hinting = 0; | 403 gint hinting = 0; |
398 gchar* hint_style = NULL; | 404 gchar* hint_style = NULL; |
399 gchar* rgba_style = NULL; | 405 gchar* rgba_style = NULL; |
400 g_object_get(gtk_settings_get_default(), | 406 g_object_get(gtk_settings_get_default(), |
| 407 "gtk-cursor-blink-time", &cursor_blink_time, |
| 408 "gtk-cursor-blink", &cursor_blink, |
401 "gtk-xft-antialias", &antialias, | 409 "gtk-xft-antialias", &antialias, |
402 "gtk-xft-hinting", &hinting, | 410 "gtk-xft-hinting", &hinting, |
403 "gtk-xft-hintstyle", &hint_style, | 411 "gtk-xft-hintstyle", &hint_style, |
404 "gtk-xft-rgba", &rgba_style, | 412 "gtk-xft-rgba", &rgba_style, |
405 NULL); | 413 NULL); |
406 | 414 |
407 // Set some reasonable defaults. | 415 // Set some reasonable defaults. |
408 prefs->should_antialias_text = true; | 416 prefs->should_antialias_text = true; |
409 prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; | 417 prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; |
410 prefs->subpixel_rendering = | 418 prefs->subpixel_rendering = |
411 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; | 419 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; |
412 | 420 |
| 421 if (cursor_blink) { |
| 422 // Dividing by 2*1000ms follows the WebKit GTK port and makes the blink |
| 423 // frequency appear similar to the omnibox. Without this the blink is too |
| 424 // slow. |
| 425 prefs->caret_blink_interval = cursor_blink_time / 2000.; |
| 426 } else { |
| 427 prefs->caret_blink_interval = 0; |
| 428 } |
| 429 |
413 // g_object_get() doesn't tell us whether the properties were present or not, | 430 // g_object_get() doesn't tell us whether the properties were present or not, |
414 // but if they aren't (because gnome-settings-daemon isn't running), we'll get | 431 // but if they aren't (because gnome-settings-daemon isn't running), we'll get |
415 // NULL values for the strings. | 432 // NULL values for the strings. |
416 if (hint_style && rgba_style) { | 433 if (hint_style && rgba_style) { |
417 prefs->should_antialias_text = antialias; | 434 prefs->should_antialias_text = antialias; |
418 | 435 |
419 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { | 436 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { |
420 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; | 437 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; |
421 } else if (strcmp(hint_style, "hintslight") == 0) { | 438 } else if (strcmp(hint_style, "hintslight") == 0) { |
422 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; | 439 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 } | 549 } |
533 #endif | 550 #endif |
534 } | 551 } |
535 | 552 |
536 GdkCursor* GetCursor(GdkCursorType type) { | 553 GdkCursor* GetCursor(GdkCursorType type) { |
537 static GdkCursorCache impl; | 554 static GdkCursorCache impl; |
538 return impl.GetCursorImpl(type); | 555 return impl.GetCursorImpl(type); |
539 } | 556 } |
540 | 557 |
541 } // namespace gtk_util | 558 } // namespace gtk_util |
OLD | NEW |