* 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. svn: r4200
This commit is contained in:
parent
d105ef6be0
commit
3dfcf51269
@ -1,3 +1,13 @@
|
|||||||
|
2005-03-17 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
|
* 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 <shura@gramps-project.org>
|
2005-03-17 Alex Roitman <shura@gramps-project.org>
|
||||||
* acinclude.m4: Add macro for defining SHARED_MIME_DIR.
|
* acinclude.m4: Add macro for defining SHARED_MIME_DIR.
|
||||||
* configure.in: Use AM_SHARED_MIME macro.
|
* configure.in: Use AM_SHARED_MIME macro.
|
||||||
|
@ -38,10 +38,12 @@ except ImportError:
|
|||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import os
|
import os
|
||||||
|
from const import ErrorSchemaInvalid
|
||||||
|
|
||||||
client = gconf.client_get_default()
|
client = gconf.client_get_default()
|
||||||
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
|
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Functions to obtain values from gconf keys
|
# Functions to obtain values from gconf keys
|
||||||
@ -345,7 +347,10 @@ def get_bool(key):
|
|||||||
if val in (True,False):
|
if val in (True,False):
|
||||||
return val
|
return val
|
||||||
else:
|
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):
|
def set_bool(key,val):
|
||||||
if val in (True,False):
|
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:
|
if not correct_tuple or val in correct_tuple:
|
||||||
return val
|
return val
|
||||||
else:
|
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):
|
def set_int(key,val,correct_tuple=None):
|
||||||
if not correct_tuple or val in correct_tuple:
|
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):
|
if not test_func or test_func(val):
|
||||||
return val
|
return val
|
||||||
else:
|
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):
|
def set_string(key,val,test_func=None):
|
||||||
if not test_func or test_func(val):
|
if not test_func or test_func(val):
|
||||||
@ -398,4 +409,3 @@ def set_string_as_id_prefix(key,val):
|
|||||||
|
|
||||||
def sync():
|
def sync():
|
||||||
client.suggest_sync()
|
client.suggest_sync()
|
||||||
|
|
||||||
|
@ -51,3 +51,11 @@ def get_type(file):
|
|||||||
return get_mime_type(file)
|
return get_mime_type(file)
|
||||||
except:
|
except:
|
||||||
return _('unknown')
|
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
|
||||||
|
@ -154,6 +154,13 @@ documenters = [
|
|||||||
|
|
||||||
translators = _('TRANSLATORS: Translate this to your name in your native language')
|
translators = _('TRANSLATORS: Translate this to your name in your native language')
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# custom exception
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
ErrorSchemaInvalid = "GConf schema not properly installed"
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Constants
|
# Constants
|
||||||
|
@ -77,6 +77,8 @@ import RelImage
|
|||||||
import RecentFiles
|
import RecentFiles
|
||||||
import NameDisplay
|
import NameDisplay
|
||||||
|
|
||||||
|
from GrampsMime import mime_type_is_defined
|
||||||
|
|
||||||
from QuestionDialog import *
|
from QuestionDialog import *
|
||||||
|
|
||||||
from bsddb import db
|
from bsddb import db
|
||||||
@ -131,8 +133,10 @@ class Gramps:
|
|||||||
|
|
||||||
self.db = GrampsBSDDB.GrampsBSDDB()
|
self.db = GrampsBSDDB.GrampsBSDDB()
|
||||||
|
|
||||||
|
try:
|
||||||
GrampsCfg.loadConfig()
|
GrampsCfg.loadConfig()
|
||||||
|
|
||||||
|
|
||||||
if GrampsKeys.get_betawarn() == 0:
|
if GrampsKeys.get_betawarn() == 0:
|
||||||
WarningDialog(_("Use at your own risk"),
|
WarningDialog(_("Use at your own risk"),
|
||||||
_("This is an unstable development version of GRAMPS. "
|
_("This is an unstable development version of GRAMPS. "
|
||||||
@ -145,8 +149,24 @@ class Gramps:
|
|||||||
self.RelClass = PluginMgr.relationship_class
|
self.RelClass = PluginMgr.relationship_class
|
||||||
self.relationship = self.RelClass(self.db)
|
self.relationship = self.RelClass(self.db)
|
||||||
self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps")
|
self.gtop = gtk.glade.XML(const.gladeFile, "gramps", "gramps")
|
||||||
|
|
||||||
self.init_interface()
|
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)
|
ArgHandler.ArgHandler(self,args)
|
||||||
|
|
||||||
# Don't show main window until ArgHandler is done.
|
# Don't show main window until ArgHandler is done.
|
||||||
|
Loading…
Reference in New Issue
Block a user