From 3d74064db6095dfaa23a54b542dfffb45a4b9c41 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Wed, 27 Aug 2008 09:41:15 +0000 Subject: Update the profile dependent on version changes #5428 Reflected are changes in the browse bundle version or the xulrunner one (marco) --- (limited to 'python') 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 -- cgit v0.9.1