kkujansuu / gramps

MIT License
1 stars 1 forks source link

FilterParam should monitor the dbstate database-changed signal #39

Open emyoulation opened 2 months ago

emyoulation commented 2 months ago

When a different database is loaded after the FilterParams dialog is spawned, then changing ID type parameters with any of the Select Object dialogs causes an "sqlite3.ProgrammingError: Cannot operate on a closed database" error. FilterParams only sees the database was closed, not that a new one was loaded.

database-changed https://www.gramps-project.org/wiki/index.php/Signals_and_Callbacks#Db_signals https://gramps-project.org/docs/gen/gen_utils.html#module-gramps.gen.utils.callback

For full error report, see: https://gramps.discourse.group/t/add-a-recent-sub-menu/5760/23

kkujansuu commented 2 months ago

Fixed by closing the FilterParam window if the database is changed. The tool uses code from gramps.gui.editors.filtereditor that can't handle a database change - so the only solution is to close the tool.

kkujansuu commented 2 months ago

The above fix seems to work except that now there is the console message:

Tried to close a ManagedWindow more than once.

emyoulation commented 2 months ago

Could you updated the FilterParams.gpr.py file?

This is the one I'm trying to use. (Not sure if the from gramps.gui import plug is needed.)

#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2021-2024      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
"""
from gramps.gui import plug
from gramps.version import major_version, VERSION_TUPLE

plug.tool.tool_categories["Isotammi"] = ("Isotammi", _("Isotammi tools"))

#------------------------------------------------------------------------
#
# FilterParams
#
# See https://github.com/kkujansuu/gramps/edit/master/addons/FilterParams/
#
#------------------------------------------------------------------------

help_url = "Addon:Isotammi_addons#FilterParams_tool"

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

register(
    TOOL,
    id="FilterParams",
    name=_("FilterParams"),
    description=_("Display custom filters and allow changing their parameters"),
    version="1.1.7",
    gramps_target_version=major_version,
    status=STABLE,
    fname="FilterParams.py",
    authors=["Kari Kujansuu"],
    category="Isotammi",
    toolclass="Tool",
    optionclass="Options",
    tool_modes=[TOOL_MODE_GUI],
    **additional_args,
)

kkujansuu commented 2 months ago

I made the change in my dev environment but it seems that the help url does not work. It tries to open the page

https://gramps-project.org/wiki/index.php?title=Addon%3AIsotammi_addons%23FilterParams_tool

which goes to the top of the page, not to the FilterParams part. Probably because the # character is encoded to %23.

pe 23. elok. 2024 klo 23.11 Emyoulation or BAMaustin ( @.***) kirjoitti:

Could you updated the FilterParams.gpr.py file?

This is the one I'm trying to use. (Not sure if the from gramps.gui import plug is needed.)

#

Gramps - a GTK+/GNOME based genealogy program

#

Copyright (C) 2021-2024 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 """ from gramps.gui import plug from gramps.version import major_version, VERSION_TUPLE

plug.tool.toolcategories["Isotammi"] = ("Isotammi", ("Isotammi tools"))

------------------------------------------------------------------------

#

FilterParams

#

See https://github.com/kkujansuu/gramps/edit/master/addons/FilterParams/

#

------------------------------------------------------------------------

help_url = "Addon:Isotammi_addons#FilterParams_tool"

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

register( TOOL, id="FilterParams", name=("FilterParams"), description=("Display custom filters and allow changing their parameters"), version="1.1.7", gramps_target_version=major_version, status=STABLE, fname="FilterParams.py", authors=["Kari Kujansuu"], category="Isotammi", toolclass="Tool", optionclass="Options", tool_modes=[TOOL_MODE_GUI], **additional_args, )

— Reply to this email directly, view it on GitHub https://github.com/kkujansuu/gramps/issues/39#issuecomment-2307746044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIYOXVRSUKPXLEK4YZS3TTZS6JQXAVCNFSM6AAAAABM3GAJ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXG42DMMBUGQ . You are receiving this because you were assigned.Message ID: @.***>

emyoulation commented 2 months ago

Non-gramplet help_url pass-through to Help buttons seems a bit flakey. It seems to work better from the addons.json than from the .gpr.py files for manually installed addons. Gramps still needs some refining there. I have been unable to communicate (or test) the problems with supporting the Help/Wiki buttons when Weblate needs to localize the help_url.

You might want to try the fully qualified URL. Maybe avoiding strings that have to be compounded will sidestep the percent-encoding for the slash, colon and hashtag.

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

emyoulation commented 2 months ago

added a 5.2 Addon Manager section to the Isotammi Installation section on the wiki.

Thought you might want to grab the screen captures for your GitHub pages:

https://blog.gramps-project.org/wiki/index.php/Addon:Isotammi_addons#Installation

kkujansuu commented 2 months ago

Yes that works. I updated the file.

la 24. elok. 2024 klo 20.53 Emyoulation or BAMaustin ( @.***) kirjoitti:

Non-gramplet help_url pass-through to Help buttons seems a bit flakey. It seems to work better from the addons.json than from the .gpr.py files for manually installed addons. Gramps still needs some refining there. I have been unable to communicate (or test) the problems with supporting the Help/Wiki buttons when Weblate needs to localize the help_url.

You might want to try the fully qualified URL. Maybe avoiding strings that have to be compounded will sidestep the percent-encoding for the slash, colon and hashtag.

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

— Reply to this email directly, view it on GitHub https://github.com/kkujansuu/gramps/issues/39#issuecomment-2308472785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIYOXSVBCTLHL45756OMOLZTDCDDAVCNFSM6AAAAABM3GAJ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGQ3TENZYGU . You are receiving this because you were assigned.Message ID: @.***>