diff options
author | Simon Schampijer <simon@schampijer.de> | 2008-08-27 09:41:15 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2008-08-27 09:42:36 (GMT) |
commit | 3d74064db6095dfaa23a54b542dfffb45a4b9c41 (patch) | |
tree | 89addf2c592293d9d5bb35c29f438435739abee7 | |
parent | 48a764911abd2f6d4906774e5ce197de8e6ee8ff (diff) |
Update the profile dependent on version changes #5428
Reflected are changes in the browse bundle version or
the xulrunner one (marco)
-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..3d4741c 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -17,6 +17,7 @@ import os import sys +import ConfigParser import gtk @@ -29,7 +30,15 @@ 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=[]): + _check_compreg(profile_path) + _hulahop.set_profile_path(profile_path) if not os.path.isdir(profile_path): try: @@ -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 |