How can I make a `.gpr.py` registration that is compatible with 4.x and 5.2?

How can an add-on plug-in be made to be compatible with both 4.x and the new registration features of 5.2?

Kari’s use of the gramps.version is a start:

from gramps.version import major_version, VERSION_TUPLE

         gramps_target_version = major_version,

But what about the incompatible Registration tags like:

     icons = [('____', _('____'))],
     stock_icon='____',
     requires_mod=['____', '____'],
     help_url = "Addon:____",

For the Fitler+ multiple Category gramplets, @kku wrote the appended registration.
It seems to address the adaptations. It this the recommended method for backward compatibility?

#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2023 Gramps developers, Kari Kujansuu
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


"""
Gramps registration file
"""

# See https://github.com/Taapeli/isotammi-addons/tree/master/source/Filter+
# or https://gramps-project.org/wiki/index.php/Addon:Isotammi_addons#Filter.2B

from gramps.version import major_version, VERSION_TUPLE

objs = """
Person
Family
Event
Place
Citation
Source
Repository
Media
Note
"""

help_url = "https://gramps-project.org/wiki/index.php/Addon:Isotammi_addons#Filter.2B"

if VERSION_TUPLE < (5, 2, 0):
    additional_args = {}
else:
    additional_args = {
        "audience": EXPERT,
        "help_url": help_url,
    }


for obj in objs.splitlines():
    obj = obj.strip()
    if obj == "": continue

    register(GRAMPLET,
             id=obj + "-Filter+",
             name=_(obj + " Filter+"),
             description = _("Gramplet providing a filter (enhanced)"),
             version="1.0.8",
             gramps_target_version=major_version,
             status = STABLE,
             fname="filter+.py",
             height=200,
             gramplet = obj + 'FilterPlus',
             gramplet_title=_("Filter+"),
             navtypes=[obj],
             **additional_args,
     )


register(RULE,
  id    = 'HasEventBase+',
  name  = _("HasEventBase+"),
  description = _("HasEventBase+ - used by Filter+"),
  version = '1.0.8',
  authors = ["Kari Kujansuu"],
  authors_email = ["kari.kujansuu@gmail.com"],
  gramps_target_version = major_version,
  status = STABLE,
  fname = "filter+.py",
  ruleclass = 'HasEventBasePlus',  # rule class name
  namespace = 'Event',  # one of the primary object classes
  **additional_args,
)

register(RULE,
  id    = 'HasSourceBase+',
  name  = _("HasSourceBase+"),
  description = _("HasSourceBase+ - used by Filter+"),
  version = '1.0.8',
  authors = ["Kari Kujansuu"],
  authors_email = ["kari.kujansuu@gmail.com"],
  gramps_target_version = major_version,
  status = STABLE,
  fname = "filter+.py",
  ruleclass = 'HasSourceBasePlus',  # rule class name
  namespace = 'Source',  # one of the primary object classes
  **additional_args,
)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.