OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gtk/gtk_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/autocomplete/autocomplete_match.h" | 23 #include "chrome/browser/autocomplete/autocomplete_match.h" |
24 #include "chrome/browser/event_disposition.h" | 24 #include "chrome/browser/event_disposition.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
28 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" | 28 #include "chrome/browser/ui/gtk/cairo_cached_surface.h" |
29 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 29 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
30 #include "content/browser/disposition_utils.h" | 30 #include "content/browser/disposition_utils.h" |
31 #include "content/browser/renderer_host/render_view_host.h" | 31 #include "content/browser/renderer_host/render_view_host.h" |
32 #include "content/browser/tab_contents/tab_contents.h" | 32 #include "content/browser/tab_contents/tab_contents.h" |
33 #include "content/common/renderer_preferences.h" | 33 #include "content/public/common/renderer_preferences.h" |
34 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
35 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
36 #include "grit/theme_resources_standard.h" | 36 #include "grit/theme_resources_standard.h" |
37 #include "third_party/skia/include/core/SkBitmap.h" | 37 #include "third_party/skia/include/core/SkBitmap.h" |
38 #include "third_party/skia/include/core/SkColor.h" | 38 #include "third_party/skia/include/core/SkColor.h" |
39 #include "ui/base/events.h" | 39 #include "ui/base/events.h" |
40 #include "ui/base/gtk/gtk_hig_constants.h" | 40 #include "ui/base/gtk/gtk_hig_constants.h" |
41 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
42 #include "ui/base/resource/resource_bundle.h" | 42 #include "ui/base/resource/resource_bundle.h" |
43 #include "ui/base/text/text_elider.h" | 43 #include "ui/base/text/text_elider.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 } | 629 } |
630 | 630 |
631 GtkWidget* IndentWidget(GtkWidget* content) { | 631 GtkWidget* IndentWidget(GtkWidget* content) { |
632 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); | 632 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); |
633 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, | 633 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, |
634 ui::kGroupIndent, 0); | 634 ui::kGroupIndent, 0); |
635 gtk_container_add(GTK_CONTAINER(content_alignment), content); | 635 gtk_container_add(GTK_CONTAINER(content_alignment), content); |
636 return content_alignment; | 636 return content_alignment; |
637 } | 637 } |
638 | 638 |
639 void UpdateGtkFontSettings(RendererPreferences* prefs) { | 639 void UpdateGtkFontSettings(content::RendererPreferences* prefs) { |
640 DCHECK(prefs); | 640 DCHECK(prefs); |
641 | 641 |
642 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is | 642 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is |
643 // the default value for gtk-cursor-blink-time. | 643 // the default value for gtk-cursor-blink-time. |
644 static const gint kGtkDefaultCursorBlinkTime = 1200; | 644 static const gint kGtkDefaultCursorBlinkTime = 1200; |
645 | 645 |
646 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; | 646 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; |
647 gboolean cursor_blink = TRUE; | 647 gboolean cursor_blink = TRUE; |
648 gint antialias = 0; | 648 gint antialias = 0; |
649 gint hinting = 0; | 649 gint hinting = 0; |
650 gchar* hint_style = NULL; | 650 gchar* hint_style = NULL; |
651 gchar* rgba_style = NULL; | 651 gchar* rgba_style = NULL; |
652 g_object_get(gtk_settings_get_default(), | 652 g_object_get(gtk_settings_get_default(), |
653 "gtk-cursor-blink-time", &cursor_blink_time, | 653 "gtk-cursor-blink-time", &cursor_blink_time, |
654 "gtk-cursor-blink", &cursor_blink, | 654 "gtk-cursor-blink", &cursor_blink, |
655 "gtk-xft-antialias", &antialias, | 655 "gtk-xft-antialias", &antialias, |
656 "gtk-xft-hinting", &hinting, | 656 "gtk-xft-hinting", &hinting, |
657 "gtk-xft-hintstyle", &hint_style, | 657 "gtk-xft-hintstyle", &hint_style, |
658 "gtk-xft-rgba", &rgba_style, | 658 "gtk-xft-rgba", &rgba_style, |
659 NULL); | 659 NULL); |
660 | 660 |
661 // Set some reasonable defaults. | 661 // Set some reasonable defaults. |
662 prefs->should_antialias_text = true; | 662 prefs->should_antialias_text = true; |
663 prefs->hinting = RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; | 663 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SYSTEM_DEFAULT; |
664 prefs->subpixel_rendering = | 664 prefs->subpixel_rendering = |
665 RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; | 665 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_SYSTEM_DEFAULT; |
666 | 666 |
667 if (cursor_blink) { | 667 if (cursor_blink) { |
668 // Dividing by 2*1000ms follows the WebKit GTK port and makes the blink | 668 // Dividing by 2*1000ms follows the WebKit GTK port and makes the blink |
669 // frequency appear similar to the omnibox. Without this the blink is too | 669 // frequency appear similar to the omnibox. Without this the blink is too |
670 // slow. | 670 // slow. |
671 prefs->caret_blink_interval = cursor_blink_time / 2000.; | 671 prefs->caret_blink_interval = cursor_blink_time / 2000.; |
672 } else { | 672 } else { |
673 prefs->caret_blink_interval = 0; | 673 prefs->caret_blink_interval = 0; |
674 } | 674 } |
675 | 675 |
676 // g_object_get() doesn't tell us whether the properties were present or not, | 676 // g_object_get() doesn't tell us whether the properties were present or not, |
677 // but if they aren't (because gnome-settings-daemon isn't running), we'll get | 677 // but if they aren't (because gnome-settings-daemon isn't running), we'll get |
678 // NULL values for the strings. | 678 // NULL values for the strings. |
679 if (hint_style && rgba_style) { | 679 if (hint_style && rgba_style) { |
680 prefs->should_antialias_text = antialias; | 680 prefs->should_antialias_text = antialias; |
681 | 681 |
682 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { | 682 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) { |
683 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE; | 683 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_NONE; |
684 } else if (strcmp(hint_style, "hintslight") == 0) { | 684 } else if (strcmp(hint_style, "hintslight") == 0) { |
685 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT; | 685 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_SLIGHT; |
686 } else if (strcmp(hint_style, "hintmedium") == 0) { | 686 } else if (strcmp(hint_style, "hintmedium") == 0) { |
687 prefs->hinting = RENDERER_PREFERENCES_HINTING_MEDIUM; | 687 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_MEDIUM; |
688 } else if (strcmp(hint_style, "hintfull") == 0) { | 688 } else if (strcmp(hint_style, "hintfull") == 0) { |
689 prefs->hinting = RENDERER_PREFERENCES_HINTING_FULL; | 689 prefs->hinting = content::RENDERER_PREFERENCES_HINTING_FULL; |
690 } | 690 } |
691 | 691 |
692 if (strcmp(rgba_style, "none") == 0) { | 692 if (strcmp(rgba_style, "none") == 0) { |
693 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE; | 693 prefs->subpixel_rendering = |
| 694 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE; |
694 } else if (strcmp(rgba_style, "rgb") == 0) { | 695 } else if (strcmp(rgba_style, "rgb") == 0) { |
695 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; | 696 prefs->subpixel_rendering = |
| 697 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB; |
696 } else if (strcmp(rgba_style, "bgr") == 0) { | 698 } else if (strcmp(rgba_style, "bgr") == 0) { |
697 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; | 699 prefs->subpixel_rendering = |
| 700 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR; |
698 } else if (strcmp(rgba_style, "vrgb") == 0) { | 701 } else if (strcmp(rgba_style, "vrgb") == 0) { |
699 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; | 702 prefs->subpixel_rendering = |
| 703 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB; |
700 } else if (strcmp(rgba_style, "vbgr") == 0) { | 704 } else if (strcmp(rgba_style, "vbgr") == 0) { |
701 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; | 705 prefs->subpixel_rendering = |
| 706 content::RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR; |
702 } | 707 } |
703 } | 708 } |
704 | 709 |
705 if (hint_style) | 710 if (hint_style) |
706 g_free(hint_style); | 711 g_free(hint_style); |
707 if (rgba_style) | 712 if (rgba_style) |
708 g_free(rgba_style); | 713 g_free(rgba_style); |
709 } | 714 } |
710 | 715 |
711 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { | 716 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1201 |
1197 void DoCopy(BrowserWindow* window) { | 1202 void DoCopy(BrowserWindow* window) { |
1198 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1203 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); |
1199 } | 1204 } |
1200 | 1205 |
1201 void DoPaste(BrowserWindow* window) { | 1206 void DoPaste(BrowserWindow* window) { |
1202 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1207 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); |
1203 } | 1208 } |
1204 | 1209 |
1205 } // namespace gtk_util | 1210 } // namespace gtk_util |
OLD | NEW |