1# encoding:utf-8
2#
3# Gramps - a GTK+/GNOME based genealogy program
4#
5# Copyright (C) 2011-2016 Serge Noiraud
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21
22#------------------------------------------------------------------------
23#
24# Geography view
25#
26#------------------------------------------------------------------------
27
28# pylint: disable=bad-whitespace
29# pylint: disable=bad-whitespace
30
31MODULE_VERSION = "5.1"
32
33from gi import Repository
34from gramps.gen.const import GRAMPS_LOCALE as glocale
35from gramps.gen.plug._pluginreg import register, VIEW, STABLE #, END, START
36_ = glocale.translation.gettext
37
38#-------------------------------------------------------------------------
39#
40# set up logging
41#
42#-------------------------------------------------------------------------
43import logging
44_LOG = logging.getLogger("Geography")
45
46# Attempting to import OsmGpsMap gives an error dialog if OsmGpsMap is not
47# available so test first and log just a warning to the console instead.
48OSMGPSMAP = False
49REPOSITORY = Repository.get_default()
50if REPOSITORY.enumerate_versions("OsmGpsMap"):
51    try:
52        # current osmgpsmap support GTK3
53        import gi
54        gi.require_version('OsmGpsMap', '1.0')
55        from gi.repository import OsmGpsMap as osmgpsmap
56        OSMGPSMAP = True
57    except:
58        pass
59
60if not OSMGPSMAP:
61    from gramps.gen.config import config
62    if not config.get('interface.ignore-osmgpsmap'):
63        from gramps.gen.constfunc import has_display
64        if has_display():
65            from gramps.gui.dialog import MessageHideDialog
66            from gramps.gen.const import URL_WIKISTRING
67            TITLE = _("OsmGpsMap module not loaded.")
68            MESSAGE = _("Geography functionality will not be available.\n"
69                       "Try to install:\n"
70                       " gir1.2-osmgpsmap-1.0 (debian, ubuntu, ...)\n"
71                       " osm-gps-map-gobject-1.0.1 for fedora, ...\n"
72                       " typelib-1_0-OsmGpsMap-1_0 for openSuse\n"
73                       " ...\n"
74                       "To build it for Gramps see the Wiki (<F1>)\n"
75                       " and search for 'build from source'")
76            if uistate:
77                MessageHideDialog(TITLE, MESSAGE,
78                                  'interface.ignore-osmgpsmap',
79                                  parent=uistate.window)
80            else:
81                MessageHideDialog(TITLE, MESSAGE,
82                                  'interface.ignore-osmgpsmap')
83else:
84    # Load the view only if osmgpsmap library is present.
85    register(VIEW,
86             id = 'geo1',
87             name = _("All known places for one Person"),
88             description = _("A view showing the places visited by "
89                             "one person during his life."),
90             version = '1.0',
91             gramps_target_version = MODULE_VERSION,
92             status = STABLE,
93             fname = 'geoperson.py',
94             authors = ["Serge Noiraud"],
95             authors_email = [""],
96             category = ("Geography", _("Geography")),
97             viewclass = 'GeoPerson',
98             #order = START,
99             stock_icon = 'geo-show-person',
100      )
101
102    register(VIEW,
103             id = 'geo2',
104             name = _("All known places for one Family"),
105             description = _("A view showing the places visited by "
106                             "one family during all their life."),
107             version = '1.0',
108             gramps_target_version = MODULE_VERSION,
109             status = STABLE,
110             fname = 'geofamily.py',
111             authors = ["Serge Noiraud"],
112             authors_email = [""],
113             category = ("Geography", _("Geography")),
114             viewclass = 'GeoFamily',
115             #order = START,
116             stock_icon = 'geo-show-family',
117      )
118
119    register(VIEW,
120             id = 'geo3',
121             name = _("Every residence or move for a person "
122                      "and any descendants"),
123             description = _("A view showing all the places visited by "
124                             "all persons during their life."
125                             "\nThis is for a person and any descendant."
126                             "\nYou can see the dates corresponding to "
127                             "the period."),
128             version = '1.0',
129             gramps_target_version = MODULE_VERSION,
130             status = STABLE,
131             fname = 'geomoves.py',
132             authors = ["Serge Noiraud"],
133             authors_email = [""],
134             category = ("Geography", _("Geography")),
135             viewclass = 'GeoMoves',
136             #order = START,
137             stock_icon = 'geo-show-family',
138      )
139
140    register(VIEW,
141             id = 'geo4',
142             name = _("Have these two families been able to meet?"),
143             description = _("A view showing the places visited by "
144                             "all family's members during their life: "
145                             "have these two people been able to meet?"),
146             version = '1.0.1',
147             gramps_target_version = MODULE_VERSION,
148             status = STABLE,
149             fname = 'geofamclose.py',
150             authors = ["Serge Noiraud"],
151             authors_email = [""],
152             category = ("Geography", _("Geography")),
153             viewclass = 'GeoFamClose',
154             #order = START,
155             stock_icon = 'geo-show-family',
156      )
157
158    register(VIEW,
159             id = 'geo5',
160             name = _("Have they been able to meet?"),
161             description = _("A view showing the places visited by "
162                             "two persons during their life: "
163                             "have these two people been able to meet?"),
164             version = '1.0.1',
165             gramps_target_version = MODULE_VERSION,
166             status = STABLE,
167             fname = 'geoclose.py',
168             authors = ["Serge Noiraud"],
169             authors_email = [""],
170             category = ("Geography", _("Geography")),
171             viewclass = 'GeoClose',
172             #order = START,
173             stock_icon = 'gramps-relation',
174      )
175
176    register(VIEW,
177             id = 'geo6',
178             name = _("All known Places"),
179             description = _("A view showing all places of the database."),
180             version = '1.0',
181             gramps_target_version = MODULE_VERSION,
182             status = STABLE,
183             fname = 'geoplaces.py',
184             authors = ["Serge Noiraud"],
185             authors_email = [""],
186             category = ("Geography", _("Geography")),
187             viewclass = 'GeoPlaces',
188             #order = START,
189             stock_icon = 'geo-show-place',
190      )
191
192    register(VIEW,
193             id = 'geo7',
194             name = _("All places related to Events"),
195             description = _("A view showing all the event "
196                             "places of the database."),
197             version = '1.0',
198             gramps_target_version = MODULE_VERSION,
199             status = STABLE,
200             fname = 'geoevents.py',
201             authors = ["Serge Noiraud"],
202             authors_email = [""],
203             category = ("Geography", _("Geography")),
204             viewclass = 'GeoEvents',
205             #order = START,
206             stock_icon = 'geo-show-event',
207      )
208
209