diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 7a642178f..087407e2f 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,13 @@ +2005-03-17 Martin Hawlisch + * src/GrampsGconfKeys.py (get_bool,get_int,get_string): Raise + exception when default value could not be get from gconf schema + * src/const.py.in: Add custom exception "ErrorSchemaInvalid" + * src/GrampsMime.py (mime_type_is_defined): New method that returns + True/False + * src/gramps_main.py (__init__) Catch "ErrorSchemaInvalid" exception + and check for installed MIME-type. Show error because installation is + incomplete. + 2005-03-17 Alex Roitman * acinclude.m4: Add macro for defining SHARED_MIME_DIR. * configure.in: Use AM_SHARED_MIME macro. diff --git a/gramps2/src/GrampsGconfKeys.py b/gramps2/src/GrampsGconfKeys.py index 50445cd9a..a3c460dc7 100644 --- a/gramps2/src/GrampsGconfKeys.py +++ b/gramps2/src/GrampsGconfKeys.py @@ -38,10 +38,12 @@ except ImportError: import gobject import os +from const import ErrorSchemaInvalid client = gconf.client_get_default() client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE) + #------------------------------------------------------------------------- # # Functions to obtain values from gconf keys @@ -345,7 +347,10 @@ def get_bool(key): if val in (True,False): return val else: - return client.get_default_from_schema(key).get_bool() + val = client.get_default_from_schema(key) + if val == None: + raise ErrorSchemaInvalid, "No default value for key "+key + return val.get_bool() def set_bool(key,val): if val in (True,False): @@ -359,7 +364,10 @@ def get_int(key,correct_tuple=None): if not correct_tuple or val in correct_tuple: return val else: - return client.get_default_from_schema(key).get_int() + val = client.get_default_from_schema(key) + if val == None: + raise ErrorSchemaInvalid, "No default value for key "+key + return val.get_int() def set_int(key,val,correct_tuple=None): if not correct_tuple or val in correct_tuple: @@ -373,7 +381,10 @@ def get_string(key,test_func=None): if not test_func or test_func(val): return val else: - return client.get_default_from_schema(key).get_string() + val = client.get_default_from_schema(key) + if val == None: + raise ErrorSchemaInvalid, "No default value for key "+key + return val.get_string() def set_string(key,val,test_func=None): if not test_func or test_func(val): @@ -398,4 +409,3 @@ def set_string_as_id_prefix(key,val): def sync(): client.suggest_sync() - diff --git a/gramps2/src/GrampsMime.py b/gramps2/src/GrampsMime.py index 89c18ede9..d5619ac6f 100644 --- a/gramps2/src/GrampsMime.py +++ b/gramps2/src/GrampsMime.py @@ -51,3 +51,11 @@ def get_type(file): return get_mime_type(file) except: return _('unknown') + +def mime_type_is_defined(type): + """"Return True if a description for a mime type exists""" + try: + type = get_mime_type(file) + return True + except: + return False diff --git a/gramps2/src/const.py.in b/gramps2/src/const.py.in index b8bb55f94..c63ee28c2 100644 --- a/gramps2/src/const.py.in +++ b/gramps2/src/const.py.in @@ -154,6 +154,13 @@ documenters = [ translators = _('TRANSLATORS: Translate this to your name in your native language') +#------------------------------------------------------------------------- +# +# custom exception +# +#------------------------------------------------------------------------- +ErrorSchemaInvalid = "GConf schema not properly installed" + #------------------------------------------------------------------------- # # Constants diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 6f4d3ad44..6b0fa80b0 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -77,6 +77,8 @@ import RelImage import RecentFiles import NameDisplay +from GrampsMime import mime_type_is_defined + from QuestionDialog import * from bsddb import db @@ -131,21 +133,39 @@ class Gramps: self.db = GrampsBSDDB.GrampsBSDDB() - GrampsCfg.loadConfig() - - if GrampsKeys.get_betawarn() == 0: - WarningDialog(_("Use at your own risk"), - _("This is an unstable development version of GRAMPS. " - "It is intended as a technology preview. Do not trust your " - "family database to this development version. This version may " - "contain bugs which could corrupt your database.")) - GrampsKeys.save_betawarn(1) - GrampsKeys.sync() - - self.RelClass = PluginMgr.relationship_class - self.relationship = self.RelClass(self.db) - self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps") - self.init_interface() + try: + GrampsCfg.loadConfig() + + + if GrampsKeys.get_betawarn() == 0: + WarningDialog(_("Use at your own risk"), + _("This is an unstable development version of GRAMPS. " + "It is intended as a technology preview. Do not trust your " + "family database to this development version. This version may " + "contain bugs which could corrupt your database.")) + GrampsKeys.save_betawarn(1) + GrampsKeys.sync() + + self.RelClass = PluginMgr.relationship_class + self.relationship = self.RelClass(self.db) + self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps") + + self.init_interface() + + except const.ErrorSchemaInvalid, val: + ErrorDialog(_("Configuration error"), + val + _("\n\nPossibly the installation of GRAMPS was incomplete." + " Make sure the GConf schema of GRAMPS is properly installed.")) + gtk.main_quit() + return + + if not mime_type_is_defined(const.app_gramps): + ErrorDialog(_("Configuration error"), + _("A definition for the MIME-type %s could not be found" + "\n\nPossibly the installation of GRAMPS was incomplete." + " Make sure the MIME-types of GRAMPS are properly installed.") % const.app_gramps) + gtk.main_quit() + return ArgHandler.ArgHandler(self,args)