[rhythmbox] context: use gtk+ font settings rather than css (bug #605725)
- From: Jonathan Matthew <jmatthew src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rhythmbox] context: use gtk+ font settings rather than css (bug #605725)
- Date: Sun, 17 Jan 2010 08:54:52 +0000 (UTC)
commit 2855ec99b4311155ab945accd47c3128a0543dff
Author: Jonathan Matthew <jonathan d14n org>
Date: Sun Jan 17 18:46:28 2010 +1000
context: use gtk+ font settings rather than css (bug #605725)
This mostly involves translating the PangoFontDescription we get from
the GTK+ style into webkit.WebSettings properties.
plugins/context/context/ContextView.py | 24 ++++++++++++++++++++++--
plugins/context/tmpl/loading.html | 2 +-
plugins/context/tmpl/main.css | 2 +-
3 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/plugins/context/context/ContextView.py b/plugins/context/context/ContextView.py
index 6fd8fdf..a5f77d2 100644
--- a/plugins/context/context/ContextView.py
+++ b/plugins/context/context/ContextView.py
@@ -26,6 +26,7 @@
import rb, rhythmdb
import gtk, gobject
+import pango
import webkit
import os
@@ -203,7 +204,20 @@ class ContextView (gobject.GObject):
rb.show_uri(request.get_uri())
return 1 # WEBKIT_NAVIGATION_RESPONSE_IGNORE
else:
- return 0 # WEBKIT_NAVIGATION_RESPONSE_ACCEPT
+ return 0 # WEBKIT_NAVIGATION_RESPONSE_ACCEPT
+
+ def style_set_cb(self, widget, prev_style):
+ self.apply_font_settings()
+
+ def apply_font_settings(self):
+ style = self.webview.style
+
+ font_size = style.font_desc.get_size()
+ if style.font_desc.get_size_is_absolute() is False:
+ font_size /= pango.SCALE
+ self.websettings.props.default_font_size = font_size
+ self.websettings.props.default_font_family = style.font_desc.get_family()
+ print "web view font settings: %s, %d" % (style.font_desc.get_family(), font_size)
def init_gui(self):
self.vbox = gtk.VBox()
@@ -242,7 +256,13 @@ class ContextView (gobject.GObject):
self.scroll = gtk.ScrolledWindow()
self.scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.scroll.set_shadow_type(gtk.SHADOW_IN)
- self.scroll.add( self.webview )
+ self.scroll.add (self.webview)
+
+ # set up webkit settings to match gtk font settings
+ self.websettings = webkit.WebSettings()
+ self.webview.set_settings(self.websettings)
+ self.apply_font_settings()
+ self.webview.connect("style-set", self.style_set_cb)
#----- set up button group -----#
self.vbox2 = gtk.VBox()
diff --git a/plugins/context/tmpl/loading.html b/plugins/context/tmpl/loading.html
index b8e57d0..8b7b073 100644
--- a/plugins/context/tmpl/loading.html
+++ b/plugins/context/tmpl/loading.html
@@ -2,7 +2,7 @@
<head>
<meta http-equiv="content-type" content="text-html; charset=utf-8">
<style type="text/css">
-body { font-size: 8pt; padding: 6px; line-height: 1.4em }
+body { padding: 6px; line-height: 1.4em }
h1 { font-size: 130% }
img { display: block; margin-left: auto; margin-right: auto }
</style>
diff --git a/plugins/context/tmpl/main.css b/plugins/context/tmpl/main.css
index 29c5f6f..7261881 100644
--- a/plugins/context/tmpl/main.css
+++ b/plugins/context/tmpl/main.css
@@ -1,4 +1,4 @@
-body { font-size: 8pt; padding: 6px; line-height: 1.4em }
+body { padding: 6px; line-height: 1.4em }
h1 { font-size: 100% }
h2 { font-size: 90%; color: #555; line-height: 1em }
h3 {padding: 0}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]