diff options
author | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-22 20:57:48 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <marco@localhost.localdomain> | 2007-05-22 20:57:48 (GMT) |
commit | 32a18dfc6da97801673dd0bf7424350489694ca0 (patch) | |
tree | e9a171ae8776ceb805fe0ddc407d4c859026a398 /python | |
parent | e66eb0affccb71012619b7cdef3f502e32156f78 (diff) |
Load default prefs
Diffstat (limited to 'python')
-rw-r--r-- | python/__init__.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py index aaa29a9..55758a0 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -15,9 +15,13 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. +import gtk + from hulahop._hulahop import shutdown from hulahop import _hulahop +_XO_DPI = 200.0 + def startup(profile_path, components_dirs=[]): _hulahop.set_profile_path(profile_path) @@ -25,3 +29,28 @@ def startup(profile_path, components_dirs=[]): _hulahop.add_components_path(path) _hulahop.startup() + + from xpcom import components + + cls = components.classes["@mozilla.org/preferences-service;1"] + prefService = cls.getService(components.interfaces.nsIPrefService) + branch = prefService.getBranch('') + branch.setIntPref('layout.css.dpi', _get_layout_dpi()) + +def _get_layout_dpi(): + _screen_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi') + screen_width = gtk.gdk.screen_width() + + if _screen_dpi != _XO_DPI or screen_width != 1200: + return -1 + + # Layout: + # 1024x768 -> (96 * 6) / 1024 * 201 = 113 dpi + # 800x600 -> (96 * 6) / 800 * 201 = 144 dpi + # + # Fonts: + # 7 pt -> 7 / 12 * 201 = 117 dpi + # 8 pt -> 8 / 12 * 201 = 134 dpi + # 9 pt -> 9 / 12 * 201 = 150 dpi + + return 134 |