diff options
author | Jonas Smedegaard <dr@jones.dk> | 2008-10-19 19:35:32 (GMT) |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2008-10-19 19:35:32 (GMT) |
commit | bfe29cfae14e07f3f5ffc0b715e136a28e650621 (patch) | |
tree | a751080fe5c153894fb8119449d2e70b36702d2e /python | |
parent | 0893f1cfe12995d4516ae8c9ae7cc6ecc5ac9e62 (diff) | |
parent | e50692d4e77e6ece151e6090f5c527ae6936291c (diff) |
Merge commit 'v0.4.5' into upstream
Diffstat (limited to 'python')
-rw-r--r-- | python/__init__.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py index 49ce42a..6065ebe 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -17,6 +17,7 @@ import os import sys +import ConfigParser import gtk @@ -29,6 +30,12 @@ from hulahop import _hulahop _XO_DPI = 200 +_app_version = '' + +def set_app_version(version): + global _app_version + _app_version = version + def startup(profile_path, components_dirs=[]): _hulahop.set_profile_path(profile_path) if not os.path.isdir(profile_path): @@ -37,6 +44,8 @@ def startup(profile_path, components_dirs=[]): except OSError, exc: raise RuntimeError('Could not create user directory.') + _check_compreg(profile_path) + for path in components_dirs: _hulahop.add_components_path(path) @@ -49,6 +58,36 @@ def startup(profile_path, components_dirs=[]): branch = prefService.getBranch('') branch.setIntPref('layout.css.dpi', _get_layout_dpi()) +def _check_compreg(profile_path): + comp_path = os.path.join(profile_path, 'compatibility.ini') + existant = True + valid = True + + try: + cp = ConfigParser.ConfigParser(defaults={'app_version' : ''}) + if not cp.read(comp_path): + existant = False + else: + valid = cp.get('main', 'app_version') == _app_version and \ + cp.get('main', 'libxul_dir') == config.libxul_dir + except ConfigParser.Error: + valid = False + + if not valid and existant: + compreg = os.path.join(profile_path, 'compreg.dat') + + os.unlink(comp_path) + os.unlink(compreg) + + cp = ConfigParser.ConfigParser() + cp.add_section('main') + cp.set('main', 'app_version', _app_version) + cp.set('main', 'libxul_dir', config.libxul_dir) + + f = open(comp_path, 'w') + cp.write(f) + f.close() + def _get_layout_dpi(): gtk_xft_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi') screen_dpi = gtk_xft_dpi / 1024 |