From 945a491e180a139020890f2fe5d97bb6cda01e44 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Wed, 2 Jan 2013 23:31:07 +0000 Subject: [PATCH] Tidy up resource files svn: r20944 --- gramps/gen/const.py.in | 79 +++++++++++++++++++++++------------------- setup.py | 33 ++++++++++-------- 2 files changed, 61 insertions(+), 51 deletions(-) diff --git a/gramps/gen/const.py.in b/gramps/gen/const.py.in index 851ccf267..de2a37d6e 100644 --- a/gramps/gen/const.py.in +++ b/gramps/gen/const.py.in @@ -86,13 +86,6 @@ APP_GRAMPS_PKG = "application/x-gramps-package" APP_GENEWEB = "application/x-geneweb" APP_VCARD = ["text/x-vcard", "text/x-vcalendar"] -#------------------------------------------------------------------------- -# -# system paths -# -#------------------------------------------------------------------------- -LOCALE_DIR = "@LOCALE_DIR@" - #------------------------------------------------------------------------- # # Platforms @@ -135,24 +128,6 @@ if sys.version_info[0] < 3: else: pass -#------------------------------------------------------------------------- -# -# Paths to files - assumes that files reside in the same directory as -# this one, and that the plugins directory is in a directory below this. -# -#------------------------------------------------------------------------- -ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname( - __file__), os.pardir)) -if sys.version_info[0] < 3: - # test for sys.frozen to detect a py2exe executable on Windows - if hasattr(sys, "frozen"): - ROOT_DIR = os.path.abspath(os.path.dirname( - unicode(sys.executable, sys.getfilesystemencoding()))) - else: - ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname( - unicode(__file__, sys.getfilesystemencoding())), os.pardir)) - -IMAGE_DIR = os.path.join(ROOT_DIR, "images") VERSION_DIR = os.path.join( HOME_DIR, "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])) @@ -170,15 +145,26 @@ USER_PLUGINS = os.path.join(VERSION_DIR, "plugins") USER_DIRLIST = (HOME_DIR, VERSION_DIR, ENV_DIR, TEMP_DIR, THUMB_DIR, THUMB_NORMAL, THUMB_LARGE, USER_PLUGINS) -ICON = os.path.join(ROOT_DIR, "images", "gramps.png") -LOGO = os.path.join(ROOT_DIR, "images", "logo.png") -SPLASH = os.path.join(ROOT_DIR, "images", "splash.jpg") -LICENSE_FILE = os.path.join(ROOT_DIR, "COPYING") +#------------------------------------------------------------------------- +# +# Paths to python modules - assumes that the root directory is one level +# above this one, and that the plugins directory is below the root directory. +# +#------------------------------------------------------------------------- +ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname( + __file__), os.pardir)) +if sys.version_info[0] < 3: + # test for sys.frozen to detect a py2exe executable on Windows + if hasattr(sys, "frozen"): + ROOT_DIR = os.path.abspath(os.path.dirname( + unicode(sys.executable, sys.getfilesystemencoding()))) + else: + ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname( + unicode(__file__, sys.getfilesystemencoding())), os.pardir)) # # Glade files # - GLADE_DIR = os.path.join(ROOT_DIR, "gui", "glade") GLADE_FILE = os.path.join(GLADE_DIR, "gramps.glade") PERSON_GLADE = os.path.join(GLADE_DIR, "edit_person.glade") @@ -188,22 +174,43 @@ RULE_GLADE = os.path.join(GLADE_DIR, "rule.glade") PLUGINS_DIR = os.path.join(ROOT_DIR, "plugins") -DATA_DIR = os.path.join(ROOT_DIR, "data") WEB_DIR = os.path.join(ROOT_DIR, 'webapp') -#SYSTEM_FILTERS = os.path.join(DATA_DIR, "system_filters.xml") -TIP_DATA = os.path.join(DATA_DIR, "tips.xml") WEBSTUFF_DIR = os.path.join(PLUGINS_DIR, "webstuff") WEBSTUFF_IMAGE_DIR = os.path.join(WEBSTUFF_DIR, "images") -PAPERSIZE = os.path.join(DATA_DIR, "papersize.xml") - -USE_TIPS = False +USE_TIPS = False if os.sys.platform in WINDOWS: USE_THUMBNAILER = False else: USE_THUMBNAILER = True +#------------------------------------------------------------------------- +# +# Paths to data files. +# +#------------------------------------------------------------------------- +SHARE_DIR = "@SHARE_DIR@" +LOCALE_DIR = "@LOCALE_DIR@" + +if SHARE_DIR != '': + DATA_DIR = os.path.join(SHARE_DIR, 'gramps') + IMAGE_DIR = os.path.join(SHARE_DIR, 'gramps', 'icons', 'hicolor') + DOC_DIR = os.path.join(SHARE_DIR, 'doc', 'gramps') +else: + DATA_DIR = os.path.join('gramps', 'data') + IMAGE_DIR = os.path.join('gramps', 'images') + DOC_DIR = os.curdir + +TIP_DATA = os.path.join(DATA_DIR, "tips.xml") +PAPERSIZE = os.path.join(DATA_DIR, "papersize.xml") + +ICON = os.path.join(IMAGE_DIR, "gramps.png") +LOGO = os.path.join(IMAGE_DIR, "logo.png") +SPLASH = os.path.join(IMAGE_DIR, "splash.jpg") + +LICENSE_FILE = os.path.join(DOC_DIR, 'COPYING') + #------------------------------------------------------------------------- # # About box information diff --git a/setup.py b/setup.py index aba5e9edc..360434fdf 100644 --- a/setup.py +++ b/setup.py @@ -241,15 +241,18 @@ def write_const_py(command): const_py = os.path.join('gramps', 'gen', 'const.py') if hasattr(command, 'install_data'): #during install + share_dir = os.path.join(command.install_data, 'share') locale_dir = os.path.join(command.install_data, 'share', 'locale') else: #in build if 'install' in command.distribution.command_obj: # Prevent overwriting version created during install return + share_dir = '' locale_dir = os.path.join(command.build_base, 'mo') subst_vars = (('@VERSIONSTRING@', VERSION), + ('@SHARE_DIR@', share_dir), ('@LOCALE_DIR@', locale_dir)) substitute_variables(const_py_in, const_py, subst_vars) @@ -307,21 +310,14 @@ GEDCOM_FILES = glob.glob(os.path.join('example', 'gedcom', '*.*')) GRAMPS_FILES = glob.glob(os.path.join('example', 'gramps', '*.*')) PNG_FILES = glob.glob(os.path.join('data', '*.png')) SVG_FILES = glob.glob(os.path.join('data', '*.svg')) +DATA_FILES = glob.glob(os.path.join('gramps', 'data', '*.xml')) +IMAGE_FILES = glob.glob(os.path.join('gramps', 'images', '*.*')) +IMAGE_16 = glob.glob(os.path.join('gramps', 'images', '16x16', '*.png')) +IMAGE_22 = glob.glob(os.path.join('gramps', 'images', '22x22', '*.png')) +IMAGE_48 = glob.glob(os.path.join('gramps', 'images', '48x48', '*.png')) +IMAGE_S = glob.glob(os.path.join('gramps', 'images', 'scalable', '*.svg')) -data_list = [ - 'data/*.txt', - 'data/*.xml', - 'gui/glade/*.glade', - 'images/*.ico', - 'images/*.png', - 'images/splash.jpg', - 'images/*.svg', - 'images/16x16/*.png', - 'images/22x22/*.png', - 'images/48x48/*.png', - 'images/scalable/*.svg' - ] - +data_list = ['gui/glade/*.glade'] # add all subdirs of plugin with glade: basedir = os.path.join('gramps', 'plugins') for (dirpath, dirnames, filenames) in os.walk(basedir): @@ -433,5 +429,12 @@ setup(name = 'gramps', ('share/icons', ['gramps/images/gramps.png']), ('share/doc/gramps/example/gedcom', GEDCOM_FILES), ('share/doc/gramps/example/gramps', GRAMPS_FILES), - ('share/doc/gramps', DOC_FILES)] + ('share/doc/gramps', DOC_FILES), + ('share/gramps', DATA_FILES), + ('share/gramps/icons/hicolor', IMAGE_FILES), + ('share/gramps/icons/hicolor/16x16', IMAGE_16), + ('share/gramps/icons/hicolor/22x22', IMAGE_22), + ('share/gramps/icons/hicolor/48x48', IMAGE_48), + ('share/gramps/icons/hicolor/scalable', IMAGE_S), + ] )