1# -*- coding: utf-8 -*-
2#
3# Gramps - a GTK+/GNOME based genealogy program
4#
5# Copyright (C) 2000-2006  Donald N. Allingham
6# Copyright (C) 2012       Doug Blank
7# Copyright (C) 2013       John Ralls <jralls@ceridwen.us>
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22#
23
24"""
25Provides constants for other modules
26"""
27
28#-------------------------------------------------------------------------
29#
30# Standard python modules
31#
32#-------------------------------------------------------------------------
33import os
34import sys
35import uuid
36
37#-------------------------------------------------------------------------
38#
39# Gramps modules
40#
41#-------------------------------------------------------------------------
42from .git_revision import get_git_revision
43from .constfunc import get_env_var
44from ..version import VERSION, VERSION_TUPLE, major_version
45from .utils.resourcepath import ResourcePath
46from .utils.grampslocale import GrampsLocale
47
48#-------------------------------------------------------------------------
49#
50# Gramps program name
51#
52#-------------------------------------------------------------------------
53PROGRAM_NAME = "Gramps"
54
55#-------------------------------------------------------------------------
56#
57# Standard Gramps Websites
58#
59#-------------------------------------------------------------------------
60URL_HOMEPAGE = "http://gramps-project.org/"
61URL_MAILINGLIST = "http://sourceforge.net/mail/?group_id=25770"
62URL_BUGHOME = "http://gramps-project.org/bugs"
63URL_BUGTRACKER = "http://gramps-project.org/bugs/bug_report_page.php"
64URL_WIKISTRING = "http://gramps-project.org/wiki/index.php?title="
65URL_MANUAL_PAGE = "Gramps_%s_Wiki_Manual" % major_version
66URL_MANUAL_DATA = '%s_-_Entering_and_editing_data:_detailed' % URL_MANUAL_PAGE
67URL_MANUAL_SECT1 = '%s_-_part_1' % URL_MANUAL_DATA
68URL_MANUAL_SECT2 = '%s_-_part_2' % URL_MANUAL_DATA
69URL_MANUAL_SECT3 = '%s_-_part_3' % URL_MANUAL_DATA
70WIKI_FAQ = "FAQ"
71WIKI_KEYBINDINGS = "Gramps_%s_Wiki_Manual_-_Keybindings" % major_version
72WIKI_EXTRAPLUGINS = "%s_Addons" % major_version
73WIKI_EXTRAPLUGINS_RAWDATA = "Plugins%s&action=raw" % major_version
74
75#-------------------------------------------------------------------------
76#
77# Mime Types
78#
79#-------------------------------------------------------------------------
80APP_FAMTREE = 'x-directory/normal'
81APP_GRAMPS = "application/x-gramps"
82APP_GRAMPS_XML = "application/x-gramps-xml"
83APP_GEDCOM = "application/x-gedcom"
84APP_GRAMPS_PKG = "application/x-gramps-package"
85APP_GENEWEB = "application/x-geneweb"
86APP_VCARD = ["text/x-vcard", "text/x-vcalendar"]
87
88#-------------------------------------------------------------------------
89#
90# Determine the home directory. According to Wikipedia, most UNIX like
91# systems use HOME. I'm assuming that this would apply to OS X as well.
92# Windows apparently uses USERPROFILE
93#
94#-------------------------------------------------------------------------
95if 'GRAMPSHOME' in os.environ:
96    USER_HOME = get_env_var('GRAMPSHOME')
97    HOME_DIR = os.path.join(USER_HOME, 'gramps')
98elif 'USERPROFILE' in os.environ:
99    USER_HOME = get_env_var('USERPROFILE')
100    if 'APPDATA' in os.environ:
101        HOME_DIR = os.path.join(get_env_var('APPDATA'), 'gramps')
102    else:
103        HOME_DIR = os.path.join(USER_HOME, 'gramps')
104else:
105    USER_HOME = get_env_var('HOME')
106    HOME_DIR = os.path.join(USER_HOME, '.gramps')
107ORIG_HOME_DIR = HOME_DIR
108if 'SAFEMODE' in os.environ:
109    if 'USERPROFILE' in os.environ:
110        USER_HOME = get_env_var('USERPROFILE')
111    else:
112        USER_HOME = get_env_var('HOME')
113    HOME_DIR = get_env_var('SAFEMODE')
114
115
116VERSION_DIR = os.path.join(
117    HOME_DIR, "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1]))
118
119CUSTOM_FILTERS = os.path.join(VERSION_DIR, "custom_filters.xml")
120REPORT_OPTIONS = os.path.join(HOME_DIR, "report_options.xml")
121TOOL_OPTIONS = os.path.join(HOME_DIR, "tool_options.xml")
122PLACE_FORMATS = os.path.join(HOME_DIR, "place_formats.xml")
123
124ENV_DIR = os.path.join(HOME_DIR, "env")
125TEMP_DIR = os.path.join(HOME_DIR, "temp")
126THUMB_DIR = os.path.join(HOME_DIR, "thumb")
127THUMB_NORMAL = os.path.join(THUMB_DIR, "normal")
128THUMB_LARGE = os.path.join(THUMB_DIR, "large")
129USER_PLUGINS = os.path.join(VERSION_DIR, "plugins")
130USER_CSS = os.path.join(HOME_DIR, "css")
131# dirs checked/made for each Gramps session
132USER_DIRLIST = (USER_HOME, HOME_DIR, VERSION_DIR, ENV_DIR, TEMP_DIR, THUMB_DIR,
133                THUMB_NORMAL, THUMB_LARGE, USER_PLUGINS, USER_CSS)
134
135
136#-------------------------------------------------------------------------
137#
138# Paths to python modules - assumes that the root directory is one level
139# above this one, and that the plugins directory is below the root directory.
140#
141#-------------------------------------------------------------------------
142ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
143
144sys.path.insert(0, ROOT_DIR)
145git_revision = get_git_revision(ROOT_DIR).replace('\n', '')
146if sys.platform == 'win32' and git_revision == "":
147    git_revision = get_git_revision(os.path.split(ROOT_DIR)[1])
148#VERSION += git_revision
149#VERSION += "-1"
150
151#
152# Glade files
153#
154GLADE_DIR = os.path.join(ROOT_DIR, "gui", "glade")
155GLADE_FILE = os.path.join(GLADE_DIR, "gramps.glade")
156PERSON_GLADE = os.path.join(GLADE_DIR, "edit_person.glade")
157PLUGINS_GLADE = os.path.join(GLADE_DIR, "plugins.glade")
158MERGE_GLADE = os.path.join(GLADE_DIR, "mergedata.glade")
159RULE_GLADE = os.path.join(GLADE_DIR, "rule.glade")
160
161
162PLUGINS_DIR = os.path.join(ROOT_DIR, "plugins")
163
164USE_TIPS = False
165
166if sys.platform == 'win32':
167    USE_THUMBNAILER = False
168else:
169    USE_THUMBNAILER = True
170
171#-------------------------------------------------------------------------
172#
173# Paths to data files.
174#
175#-------------------------------------------------------------------------
176_resources = ResourcePath()
177DATA_DIR = _resources.data_dir
178IMAGE_DIR = _resources.image_dir
179
180TIP_DATA = os.path.join(DATA_DIR, "tips.xml")
181PAPERSIZE = os.path.join(DATA_DIR, "papersize.xml")
182
183ICON = os.path.join(IMAGE_DIR, "gramps.png")
184LOGO = os.path.join(IMAGE_DIR, "logo.png")
185SPLASH = os.path.join(IMAGE_DIR, "splash.jpg")
186
187LICENSE_FILE = os.path.join(_resources.doc_dir, 'COPYING')
188
189#-------------------------------------------------------------------------
190#
191# Gramps environment variables dictionary
192#
193#-------------------------------------------------------------------------
194ENV = {
195    "USER_HOME": USER_HOME,
196    "HOME_DIR": HOME_DIR,
197    "VERSION": VERSION,
198    "major_version": major_version,
199    "VERSION_DIR": VERSION_DIR,
200    "ENV_DIR": ENV_DIR,
201    "TEMP_DIR": TEMP_DIR,
202    "THUMB_DIR": THUMB_DIR,
203    "THUMB_NORMAL": THUMB_NORMAL,
204    "THUMB_LARGE": THUMB_LARGE,
205    "USER_PLUGINS": USER_PLUGINS,
206    "ROOT_DIR": ROOT_DIR,
207    "GLADE_DIR": GLADE_DIR,
208    "PLUGINS_DIR": PLUGINS_DIR,
209    "DATA_DIR": DATA_DIR,
210    "IMAGE_DIR": IMAGE_DIR,
211}
212
213#-------------------------------------------------------------------------
214#
215# Init Localization
216#
217#-------------------------------------------------------------------------
218GRAMPS_LOCALE = GrampsLocale(localedir=_resources.locale_dir)
219_ = GRAMPS_LOCALE.translation.sgettext
220GTK_GETTEXT_DOMAIN = 'gtk30'
221
222#-------------------------------------------------------------------------
223#
224# About box information
225#
226#-------------------------------------------------------------------------
227COPYRIGHT_MSG = "© 2001-2006 Donald N. Allingham\n" \
228                "© 2007-2021 The Gramps Developers"
229COMMENTS = _("Gramps\n (Genealogical Research and Analysis "
230             "Management Programming System)\n"
231             "is a personal genealogy program.")
232AUTHORS = [
233    "Alexander Roitman",
234    "Benny Malengier",
235    "Brian Matherly",
236    "Donald A. Peterson",
237    "Donald N. Allingham",
238    "David Hampton",
239    "Martin Hawlisch",
240    "Richard Taylor",
241    "Tim Waugh",
242    "John Ralls"
243    ]
244
245AUTHORS_FILE = os.path.join(DATA_DIR, "authors.xml")
246
247DOCUMENTERS = [
248    'Alexander Roitman',
249    ]
250
251#-------------------------------------------------------------------------
252#
253# Constants
254#
255#-------------------------------------------------------------------------
256THUMBSCALE = 96.0
257THUMBSCALE_LARGE = 180.0
258XMLFILE = "data.gramps"
259NO_SURNAME = "(%s)" % _("surname|none")
260NO_GIVEN = "(%s)" % _("given-name|none")
261ARABIC_COMMA = "،"
262ARABIC_SEMICOLON = "؛"
263DOCGEN_OPTIONS = 'Docgen Options'
264COLON = _(':') # translators: needed for French, ignore otherwise
265
266#-------------------------------------------------------------------------
267#
268# Options Constants
269#
270#-------------------------------------------------------------------------
271
272LONGOPTS = [
273    "action=",
274    "class=",
275    "config=",
276    "debug=",
277    "default=",
278    "display=",
279    "disable-sound",
280    "disable-crash-dialog",
281    "enable-sound",
282    "espeaker=",
283    "export=",
284    "force-unlock",
285    "format=",
286    "gdk-debug=",
287    "gdk-no-debug=",
288    "gtk-debug=",
289    "gtk-no-debug=",
290    "gtk-module=",
291    "g-fatal-warnings",
292    "help",
293    "import=",
294    "load-modules=",
295    "list"
296    "name=",
297    "oaf-activate-iid=",
298    "oaf-ior-fd=",
299    "oaf-private",
300    "open=",
301    "username=",
302    "password=",
303    "create=",
304    "options=",
305    "safe",
306    "screen=",
307    "show",
308    "sm-client-id=",
309    "sm-config-prefix=",
310    "sm-disable",
311    "sync",
312    "remove=",
313    "usage",
314    "version",
315    "yes",
316    "quiet",
317]
318
319SHORTOPTS = "O:U:P:C:i:e:f:a:p:d:c:r:lLthuv?syqSD:"
320
321GRAMPS_UUID = uuid.UUID('516cd010-5a41-470f-99f8-eb22f1098ad6')
322
323#-------------------------------------------------------------------------
324#
325# Fanchart Constants
326#
327#-------------------------------------------------------------------------
328
329PIXELS_PER_GENERATION = 50 # size of radius for generation
330BORDER_EDGE_WIDTH = 10     # empty white box size at edge to indicate parents
331CHILDRING_WIDTH = 12       # width of the children ring inside the person
332TRANSLATE_PX = 10          # size of the central circle, used to move the chart
333PAD_PX = 4                 # padding with edges
334PAD_TEXT = 2               # padding for text in boxes
335
336BACKGROUND_SCHEME1 = 0
337BACKGROUND_SCHEME2 = 1
338BACKGROUND_GENDER = 2
339BACKGROUND_WHITE = 3
340BACKGROUND_GRAD_GEN = 4
341BACKGROUND_GRAD_AGE = 5
342BACKGROUND_SINGLE_COLOR = 6
343BACKGROUND_GRAD_PERIOD = 7
344GENCOLOR = {
345    BACKGROUND_SCHEME1: ((255, 63, 0),
346                         (255, 175, 15),
347                         (255, 223, 87),
348                         (255, 255, 111),
349                         (159, 255, 159),
350                         (111, 215, 255),
351                         (79, 151, 255),
352                         (231, 23, 255),
353                         (231, 23, 121),
354                         (210, 170, 124),
355                         (189, 153, 112)),
356    BACKGROUND_SCHEME2: ((229, 191, 252),
357                         (191, 191, 252),
358                         (191, 222, 252),
359                         (183, 219, 197),
360                         (206, 246, 209)),
361    BACKGROUND_WHITE: ((255, 255, 255),
362                       (255, 255, 255),),
363    }
364
365MAX_AGE = 100
366GRADIENTSCALE = 5
367
368FORM_CIRCLE = 0
369FORM_HALFCIRCLE = 1
370FORM_QUADRANT = 2
371
372COLLAPSED = 0
373NORMAL = 1
374EXPANDED = 2
375
376TYPE_BOX_NORMAL = 0
377TYPE_BOX_FAMILY = 1
378