Skip to content

Commit

Permalink
Add filter editor menu item to Edit menu
Browse files Browse the repository at this point in the history
Also add SVG export menu item to Family Trees menu
  • Loading branch information
ztlxltl committed Feb 21, 2025
1 parent 7021d3f commit 70486a5
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions src/family_tree_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
from gi.repository import GdkPixbuf, GLib, Gtk

from gramps.gen.config import config
from gramps.gen.const import GRAMPS_LOCALE
from gramps.gen.const import CUSTOM_FILTERS, GRAMPS_LOCALE
from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.errors import HandleError
from gramps.gen.errors import HandleError, WindowActiveError
from gramps.gen.lib import EventType
from gramps.gen.utils.callback import Callback
from gramps.gen.utils.file import find_file, media_path_full
from gramps.gen.utils.symbols import Symbols
from gramps.gen.utils.thumbnails import get_thumbnail_path
from gramps.gui.editors import EditFamily, EditPerson
from gramps.gui.editors import EditFamily, EditPerson, FilterEditor
from gramps.gui.pluginmanager import GuiPluginManager
from gramps.gui.views.bookmarks import PersonBookmarks
from gramps.gui.views.navigationview import NavigationView
Expand All @@ -53,6 +53,17 @@

class FamilyTreeView(NavigationView, Callback):
ADDITIONAL_UI = [
# "Family Trees" menu:
# Export as SVG is also added here since list views have their
# export here.
"""
<placeholder id="LocalExport">
<item>
<attribute name="action">win.ExportSvgView</attribute>
<attribute name="label" translatable="yes">Export view as SVG...</attribute>
</item>
</placeholder>
""",
# "Edit" menu:
"""
<section id="CommonEdit" groups="RW">
Expand All @@ -66,6 +77,14 @@ class FamilyTreeView(NavigationView, Callback):
</item>
</section>
""",
"""
<placeholder id="otheredit">
<item>
<attribute name="action">win.FilterEdit</attribute>
<attribute name="label" translatable="yes">Person Filter Editor</attribute>
</item>
</placeholder>
""",
# "Go" menu:
"""
<placeholder id="CommonGo">
Expand Down Expand Up @@ -248,7 +267,8 @@ def let_addons_register_badges(self):
def define_actions(self):
super().define_actions()
self._add_action("PrintView", self.print_view, "<PRIMARY><SHIFT>P")
self._add_action("ExportSvgView", self.export_svg_view,)
self._add_action("ExportSvgView", self.export_svg_view)
self._add_action("FilterEdit", self.open_filter_editor)

def config_connect(self):
self.config_provider.config_connect(self._config, self.cb_update_config)
Expand Down Expand Up @@ -606,6 +626,12 @@ def edit_family(self, family_handle):
if family is not None:
EditFamily(self.dbstate, self.uistate, [], family)

def open_filter_editor(self, *args):
try:
FilterEditor("Person", CUSTOM_FILTERS, self.dbstate, self.uistate)
except WindowActiveError:
pass

# printing

def print_view(self, *args):
Expand Down

0 comments on commit 70486a5

Please sign in to comment.