├── .gitignore ├── .pylintrc ├── CREDITS ├── KNOWN_ISSUES.md ├── LICENSE ├── MANIFEST ├── README.md ├── icons ├── gramps-citationcard.svg ├── gramps-dashboardcardview.svg ├── gramps-eventcard.svg ├── gramps-familycard.svg ├── gramps-mediacard.svg ├── gramps-notecard.svg ├── gramps-person-name.png ├── gramps-personcard.svg ├── gramps-placecard.svg ├── gramps-relation-linked.svg ├── gramps-relationshipscard.svg ├── gramps-repositorycard.svg ├── gramps-sourcecard.svg ├── gramps-tagcard.svg └── gramps-temple.png ├── images ├── LinkedViewMedia.png ├── LinkedViewMediaSidebar.png ├── LinkedViewPerson.png ├── cardview-configuration-template-editor-active-person.png ├── cardview-configuration-template-editor-colors-confidence.png ├── cardview-configuration-template-editor-global-display.png ├── cardview-configuration-template-editor-layout-person.png ├── cardview-configuration-template-editor-timelines-person.png ├── cardview-configuration-templates.png ├── cardview-indicators-child-objects.png ├── cardview-indicators-status1.png ├── cardview-indicators-status2.png ├── cardview-media-bar.png ├── cardview-menu-bookmarks.png ├── cardview-menu-citation.png ├── cardview-menu-configuration.png ├── cardview-menu-event.png ├── cardview-menu-person.png ├── cardview-status-citation-alert.png ├── cardview-view-address.png ├── cardview-view-attribute.png ├── cardview-view-child-reference.png ├── cardview-view-citation.png ├── cardview-view-event-reference.png ├── cardview-view-event.png ├── cardview-view-family.png ├── cardview-view-ldsord.png ├── cardview-view-media.png ├── cardview-view-name.png ├── cardview-view-note.png ├── cardview-view-person-minimal.png ├── cardview-view-person-reference.png ├── cardview-view-person.png ├── cardview-view-place.png ├── cardview-view-repository.png ├── cardview-view-source.png ├── cardview-view-tag.png ├── cardview-window-group-associations.png ├── cardview-window-group-names.png ├── cardview-window-group-urls.png └── cardview-window-view-pinned.png └── src ├── card_view.gpr.py ├── card_view.py ├── card_view_citation.py ├── card_view_const.py ├── card_view_event.py ├── card_view_family.py ├── card_view_media.py ├── card_view_note.py ├── card_view_person.py ├── card_view_place.py ├── card_view_repository.py ├── card_view_source.py ├── card_view_statistics.py ├── card_view_tag.py ├── field_child.gpr.py ├── field_child.py ├── field_duration.gpr.py ├── field_duration.py ├── field_marriage_age.gpr.py ├── field_marriage_age.py ├── field_occupations.gpr.py ├── field_occupations.py ├── field_progenitors.gpr.py ├── field_progenitors.py ├── field_relationship.gpr.py ├── field_relationship.py ├── global_history.py ├── global_navigation.py ├── status_person.gpr.py ├── status_person.py ├── status_todo.gpr.py ├── status_todo.py ├── tagview.gpr.py ├── tagview.py ├── template_minimal.gpr.py ├── template_minimal.py └── view ├── __init__.py ├── actions ├── __init__.py ├── action_address.py ├── action_attribute.py ├── action_base.py ├── action_bookmark.py ├── action_citation.py ├── action_const.py ├── action_event.py ├── action_factory.py ├── action_family.py ├── action_ldsord.py ├── action_media.py ├── action_name.py ├── action_note.py ├── action_person.py ├── action_place.py ├── action_privacy.py ├── action_repository.py ├── action_source.py ├── action_tag.py ├── action_url.py └── delete.py ├── bars ├── __init__.py └── bar_media.py ├── cards ├── __init__.py ├── card_address.py ├── card_attribute.py ├── card_child_ref.py ├── card_citation.py ├── card_event.py ├── card_event_ref.py ├── card_family.py ├── card_family_tree.py ├── card_generic.py ├── card_media.py ├── card_media_ref.py ├── card_name.py ├── card_note.py ├── card_note_url.py ├── card_object.py ├── card_ordinance.py ├── card_person.py ├── card_person_backref.py ├── card_person_ref.py ├── card_place.py ├── card_place_ref.py ├── card_primary.py ├── card_reference.py ├── card_repository.py ├── card_repository_ref.py ├── card_secondary.py ├── card_source.py ├── card_tag.py ├── card_text.py ├── card_url.py ├── card_utils.py ├── card_view.py └── card_widgets.py ├── common ├── __init__.py ├── common_classes.py ├── common_const.py ├── common_exceptions.py ├── common_strings.py ├── common_utils.py ├── common_vitals.py └── timeline.py ├── config ├── __init__.py ├── config_builder.py ├── config_colors.py ├── config_const.py ├── config_defaults.py ├── config_global.py ├── config_layout.py ├── config_objects.py ├── config_panel.py ├── config_profile.py ├── config_selectors.py ├── config_templates.py ├── config_timeline.py ├── config_utils.py └── configure_dialog.py ├── fields ├── __init__.py ├── field_base.py ├── field_builder.py └── field_utils.py ├── groups ├── __init__.py ├── group_addresses.py ├── group_associations.py ├── group_attributes.py ├── group_builder.py ├── group_children.py ├── group_citations.py ├── group_const.py ├── group_events.py ├── group_expander.py ├── group_generic.py ├── group_lineage.py ├── group_list.py ├── group_media.py ├── group_names.py ├── group_notes.py ├── group_ordinances.py ├── group_places.py ├── group_repositories.py ├── group_research.py ├── group_sources.py ├── group_statistics.py ├── group_timeline.py ├── group_todo.py ├── group_uncited.py ├── group_urls.py └── group_window.py ├── menus ├── __init__.py ├── menu_bookmarks.py ├── menu_config.py ├── menu_templates.py └── menu_utils.py ├── services ├── __init__.py ├── service_fields.py ├── service_images.py ├── service_statistics.py ├── service_statistics_labels.py ├── service_statistics_worker.py ├── service_status.py ├── service_templates.py └── service_windows.py ├── views ├── __init__.py ├── view_attribute.py ├── view_base.py ├── view_builder.py ├── view_citation.py ├── view_const.py ├── view_event.py ├── view_family.py ├── view_generic.py ├── view_media.py ├── view_person.py ├── view_source.py ├── view_statistics.py └── view_tag.py └── zotero ├── __init__.py ├── zotero.py └── zotero_bibtex.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *~ 3 | 4 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | The following people have helped contribute to this project in one form or another: 2 | 3 | Christopher Horn - Original author 4 | Brian McCullough - Ideas, feedback, testing, bug reports and documentation 5 | Nick Hall - Feedback and advice 6 | Barrie Phelan - Provided the new icons it uses 7 | DaveSch - New icons, testing and bug reports 8 | gburto1 - Testing and bug reports 9 | brinycoolie - Testing and bug reports 10 | 11 | Numerous others now with testing and bug reports, thank you all! -------------------------------------------------------------------------------- /KNOWN_ISSUES.md: -------------------------------------------------------------------------------- 1 | ![CardView icon](icons/gramps-relation-linked.svg) Card View Addon Known Issues 2 | =============== 3 | 4 | Below are some known common issues with this collection of Addons to be aware of. 5 | 6 | 7 | ### AttributeError: 'NoneType' object has no attribute 'post_create' 8 | 9 | In certain scenarios on startup when switching databases or trying to navigate you may see the following: 10 | 11 | ``` 12 | 186123: ERROR: grampsapp.py: line 174: Unhandled exception 13 | Traceback (most recent call last): 14 | File "Z:\PortableApps\GrampsPortable\App\Gramps\gramps\gui\navigator.py", line 274, in cb_view_clicked 15 | self.viewmanager.goto_page(int(cat_num), int(view_num)) 16 | File "Z:\PortableApps\GrampsPortable\App\Gramps\gramps\gui\viewmanager.py", line 786, in goto_page 17 | self.__create_page(page_def[0], page_def[1]) 18 | File "Z:\PortableApps\GrampsPortable\App\Gramps\gramps\gui\viewmanager.py", line 840, in __create_page 19 | self.active_page.post_create() 20 | AttributeError: 'NoneType' object has no attribute 'post_create' 21 | ``` 22 | 23 | The page is not available but it tries to run the post_create() method anyway. 24 | -------------------------------------------------------------------------------- /icons/gramps-person-name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/icons/gramps-person-name.png -------------------------------------------------------------------------------- /icons/gramps-temple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/icons/gramps-temple.png -------------------------------------------------------------------------------- /images/LinkedViewMedia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/LinkedViewMedia.png -------------------------------------------------------------------------------- /images/LinkedViewMediaSidebar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/LinkedViewMediaSidebar.png -------------------------------------------------------------------------------- /images/LinkedViewPerson.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/LinkedViewPerson.png -------------------------------------------------------------------------------- /images/cardview-configuration-template-editor-active-person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-template-editor-active-person.png -------------------------------------------------------------------------------- /images/cardview-configuration-template-editor-colors-confidence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-template-editor-colors-confidence.png -------------------------------------------------------------------------------- /images/cardview-configuration-template-editor-global-display.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-template-editor-global-display.png -------------------------------------------------------------------------------- /images/cardview-configuration-template-editor-layout-person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-template-editor-layout-person.png -------------------------------------------------------------------------------- /images/cardview-configuration-template-editor-timelines-person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-template-editor-timelines-person.png -------------------------------------------------------------------------------- /images/cardview-configuration-templates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-configuration-templates.png -------------------------------------------------------------------------------- /images/cardview-indicators-child-objects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-indicators-child-objects.png -------------------------------------------------------------------------------- /images/cardview-indicators-status1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-indicators-status1.png -------------------------------------------------------------------------------- /images/cardview-indicators-status2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-indicators-status2.png -------------------------------------------------------------------------------- /images/cardview-media-bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-media-bar.png -------------------------------------------------------------------------------- /images/cardview-menu-bookmarks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-menu-bookmarks.png -------------------------------------------------------------------------------- /images/cardview-menu-citation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-menu-citation.png -------------------------------------------------------------------------------- /images/cardview-menu-configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-menu-configuration.png -------------------------------------------------------------------------------- /images/cardview-menu-event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-menu-event.png -------------------------------------------------------------------------------- /images/cardview-menu-person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-menu-person.png -------------------------------------------------------------------------------- /images/cardview-status-citation-alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-status-citation-alert.png -------------------------------------------------------------------------------- /images/cardview-view-address.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-address.png -------------------------------------------------------------------------------- /images/cardview-view-attribute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-attribute.png -------------------------------------------------------------------------------- /images/cardview-view-child-reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-child-reference.png -------------------------------------------------------------------------------- /images/cardview-view-citation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-citation.png -------------------------------------------------------------------------------- /images/cardview-view-event-reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-event-reference.png -------------------------------------------------------------------------------- /images/cardview-view-event.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-event.png -------------------------------------------------------------------------------- /images/cardview-view-family.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-family.png -------------------------------------------------------------------------------- /images/cardview-view-ldsord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-ldsord.png -------------------------------------------------------------------------------- /images/cardview-view-media.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-media.png -------------------------------------------------------------------------------- /images/cardview-view-name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-name.png -------------------------------------------------------------------------------- /images/cardview-view-note.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-note.png -------------------------------------------------------------------------------- /images/cardview-view-person-minimal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-person-minimal.png -------------------------------------------------------------------------------- /images/cardview-view-person-reference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-person-reference.png -------------------------------------------------------------------------------- /images/cardview-view-person.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-person.png -------------------------------------------------------------------------------- /images/cardview-view-place.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-place.png -------------------------------------------------------------------------------- /images/cardview-view-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-repository.png -------------------------------------------------------------------------------- /images/cardview-view-source.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-source.png -------------------------------------------------------------------------------- /images/cardview-view-tag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-view-tag.png -------------------------------------------------------------------------------- /images/cardview-window-group-associations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-window-group-associations.png -------------------------------------------------------------------------------- /images/cardview-window-group-names.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-window-group-names.png -------------------------------------------------------------------------------- /images/cardview-window-group-urls.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-window-group-urls.png -------------------------------------------------------------------------------- /images/cardview-window-view-pinned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cdhorn/CardView/c206eb7d0a8ad6100263e41848dccebc6bfa7c4a/images/cardview-window-view-pinned.png -------------------------------------------------------------------------------- /src/card_view_citation.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | CitationCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Citation 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # CitationCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class CitationCardView(CardView): 67 | """ 68 | Card view for a Citation 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Citation"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Citation" 86 | 87 | additional_ui = [ 88 | MENU_LOCALEXPORT, 89 | MENU_ADDEDITBOOK, 90 | MENU_COMMONGO, 91 | MENU_COMMONEDIT, 92 | MENU_OTHEREDIT, 93 | TOOLBAR_COMMONNAVIGATION, 94 | TOOLBAR_BARCOMMONEDIT 95 | % ( 96 | ADD_TOOLTIPS["Citation"], 97 | EDIT_TOOLTIPS["Citation"], 98 | DELETE_TOOLTIPS["Citation"], 99 | ), 100 | TOOLBAR_MOREBUTTONS, 101 | ] 102 | 103 | def define_actions(self): 104 | """ 105 | Define page specific actions. 106 | """ 107 | CardView.define_actions(self) 108 | self.first_action_group = ActionGroup(name="RW") 109 | self.first_action_group.add_actions( 110 | [ 111 | ("Add", self._add_new_citation), 112 | ("Remove", self._delete_citation), 113 | ] 114 | ) 115 | self._add_action_group(self.first_action_group) 116 | 117 | def _add_new_citation(self, *_dummy_obj): 118 | """ 119 | Add a new citation to the database. 120 | """ 121 | action = action_handler("Citation", self.grstate, Citation()) 122 | action.edit_citation(focus=True) 123 | 124 | def _delete_citation(self, *_dummy_obj): 125 | """ 126 | Delete citation. 127 | """ 128 | if self.current_context: 129 | citation = self.current_context.primary_obj.obj 130 | action = action_handler("Citation", self.grstate, citation) 131 | action.delete_object(citation) 132 | -------------------------------------------------------------------------------- /src/card_view_note.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | NoteCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Note 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # NoteCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class NoteCardView(CardView): 67 | """ 68 | Card view for a Note 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Note"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Note" 86 | 87 | additional_ui = [ 88 | MENU_LOCALEXPORT, 89 | MENU_ADDEDITBOOK, 90 | MENU_COMMONGO, 91 | MENU_COMMONEDIT, 92 | MENU_OTHEREDIT, 93 | TOOLBAR_COMMONNAVIGATION, 94 | TOOLBAR_BARCOMMONEDIT 95 | % ( 96 | ADD_TOOLTIPS["Note"], 97 | EDIT_TOOLTIPS["Note"], 98 | DELETE_TOOLTIPS["Note"], 99 | ), 100 | TOOLBAR_MOREBUTTONS, 101 | ] 102 | 103 | def define_actions(self): 104 | """ 105 | Define page specific actions. 106 | """ 107 | CardView.define_actions(self) 108 | self.first_action_group = ActionGroup(name="RW") 109 | self.first_action_group.add_actions( 110 | [("Add", self._add_new_note), ("Remove", self._delete_note)] 111 | ) 112 | self._add_action_group(self.first_action_group) 113 | 114 | def _add_new_note(self, *_dummy_obj): 115 | """ 116 | Add a new note to the database. 117 | """ 118 | action = action_handler("Note", self.grstate, Note()) 119 | action.edit_note(focus=True) 120 | 121 | def _delete_note(self, *_dummy_obj): 122 | """ 123 | Delete note. 124 | """ 125 | if self.current_context: 126 | note = self.current_context.primary_obj.obj 127 | action = action_handler("Note", self.grstate, note) 128 | action.delete_object(note) 129 | -------------------------------------------------------------------------------- /src/card_view_place.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | PlaceCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Place 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # PlaceCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class PlaceCardView(CardView): 67 | """ 68 | Card view for a place 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Place"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Place" 86 | 87 | additional_ui = [ 88 | MENU_LOCALEXPORT, 89 | MENU_ADDEDITBOOK, 90 | MENU_COMMONGO, 91 | MENU_COMMONEDIT, 92 | MENU_OTHEREDIT, 93 | TOOLBAR_COMMONNAVIGATION, 94 | TOOLBAR_BARCOMMONEDIT 95 | % ( 96 | ADD_TOOLTIPS["Place"], 97 | EDIT_TOOLTIPS["Place"], 98 | DELETE_TOOLTIPS["Place"], 99 | ), 100 | TOOLBAR_MOREBUTTONS, 101 | ] 102 | 103 | def define_actions(self): 104 | """ 105 | Define page specific actions. 106 | """ 107 | CardView.define_actions(self) 108 | self.first_action_group = ActionGroup(name="RW") 109 | self.first_action_group.add_actions( 110 | [("Add", self._add_new_place), ("Remove", self._delete_place)] 111 | ) 112 | self._add_action_group(self.first_action_group) 113 | 114 | def _add_new_place(self, *_dummy_obj): 115 | """ 116 | Add a new place to the database. 117 | """ 118 | action = action_handler("Place", self.grstate, Place()) 119 | action.edit_place(focus=True) 120 | 121 | def _delete_place(self, *_dummy_obj): 122 | """ 123 | Delete place. 124 | """ 125 | if self.current_context: 126 | place = self.current_context.primary_obj.obj 127 | action = action_handler("Place", self.grstate, place) 128 | action.delete_object(place) 129 | -------------------------------------------------------------------------------- /src/card_view_repository.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | RepositoryCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Repository 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # RepositoryCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class RepositoryCardView(CardView): 67 | """ 68 | Card view for a Repository 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Repository"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Repository" 86 | 87 | additional_ui = [ 88 | MENU_LOCALEXPORT, 89 | MENU_ADDEDITBOOK, 90 | MENU_COMMONGO, 91 | MENU_COMMONEDIT, 92 | MENU_OTHEREDIT, 93 | TOOLBAR_COMMONNAVIGATION, 94 | TOOLBAR_BARCOMMONEDIT 95 | % ( 96 | ADD_TOOLTIPS["Repository"], 97 | EDIT_TOOLTIPS["Repository"], 98 | DELETE_TOOLTIPS["Repository"], 99 | ), 100 | TOOLBAR_MOREBUTTONS, 101 | ] 102 | 103 | def define_actions(self): 104 | """ 105 | Define page specific actions. 106 | """ 107 | CardView.define_actions(self) 108 | self.first_action_group = ActionGroup(name="RW") 109 | self.first_action_group.add_actions( 110 | [ 111 | ("Add", self._add_new_repository), 112 | ("Remove", self._delete_repository), 113 | ] 114 | ) 115 | self._add_action_group(self.first_action_group) 116 | 117 | def _add_new_repository(self, *_dummy_obj): 118 | """ 119 | Add a new repository to the database. 120 | """ 121 | action = action_handler("Repository", self.grstate, Repository()) 122 | action.edit_repository(focus=True) 123 | 124 | def _delete_repository(self, *_dummy_obj): 125 | """ 126 | Delete repository. 127 | """ 128 | if self.current_context: 129 | repository = self.current_context.primary_obj.obj 130 | action = action_handler("Repository", self.grstate, repository) 131 | action.delete_object(repository) 132 | -------------------------------------------------------------------------------- /src/card_view_source.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | SourceCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Source 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # SourceCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class SourceCardView(CardView): 67 | """ 68 | Card view for a Source 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Source"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Source" 86 | 87 | additional_ui = [ 88 | MENU_LOCALEXPORT, 89 | MENU_ADDEDITBOOK, 90 | MENU_COMMONGO, 91 | MENU_COMMONEDIT, 92 | MENU_OTHEREDIT, 93 | TOOLBAR_COMMONNAVIGATION, 94 | TOOLBAR_BARCOMMONEDIT 95 | % ( 96 | ADD_TOOLTIPS["Source"], 97 | EDIT_TOOLTIPS["Source"], 98 | DELETE_TOOLTIPS["Source"], 99 | ), 100 | TOOLBAR_MOREBUTTONS, 101 | ] 102 | 103 | def define_actions(self): 104 | """ 105 | Define page specific actions. 106 | """ 107 | CardView.define_actions(self) 108 | self.first_action_group = ActionGroup(name="RW") 109 | self.first_action_group.add_actions( 110 | [ 111 | ("Add", self._add_new_source), 112 | ("Remove", self._delete_source), 113 | ] 114 | ) 115 | self._add_action_group(self.first_action_group) 116 | 117 | def _add_new_source(self, *_dummy_obj): 118 | """ 119 | Add a new source to the database. 120 | """ 121 | action = action_handler("Source", self.grstate, Source()) 122 | action.edit_source(focus=True) 123 | 124 | def _delete_source(self, *_dummy_obj): 125 | """ 126 | Delete source. 127 | """ 128 | if self.current_context: 129 | source = self.current_context.primary_obj.obj 130 | action = action_handler("Source", self.grstate, source) 131 | action.delete_object(source) 132 | -------------------------------------------------------------------------------- /src/card_view_tag.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2015-2016 Nick Hall 7 | # Copyright (C) 2021-2022 Christopher Horn 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 | """ 25 | TagCardView 26 | """ 27 | 28 | # ------------------------------------------------------------------------- 29 | # 30 | # Gramps Modules 31 | # 32 | # ------------------------------------------------------------------------- 33 | from gramps.gen.const import GRAMPS_LOCALE as glocale 34 | from gramps.gen.lib import Tag 35 | from gramps.gui.uimanager import ActionGroup 36 | 37 | # ------------------------------------------------------------------------- 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------- 42 | from card_view import CardView 43 | from card_view_const import ( 44 | MENU_LOCALEXPORT, 45 | MENU_ADDEDITBOOK, 46 | MENU_COMMONGO, 47 | MENU_COMMONEDIT, 48 | MENU_OTHEREDIT, 49 | TOOLBAR_BARCOMMONEDIT, 50 | TOOLBAR_COMMONNAVIGATION, 51 | TOOLBAR_MOREBUTTONS, 52 | ADD_TOOLTIPS, 53 | EDIT_TOOLTIPS, 54 | DELETE_TOOLTIPS, 55 | ) 56 | from view.actions import action_handler 57 | 58 | _ = glocale.translation.sgettext 59 | 60 | 61 | # ------------------------------------------------------------------------- 62 | # 63 | # TagCardView Class 64 | # 65 | # ------------------------------------------------------------------------- 66 | class TagCardView(CardView): 67 | """ 68 | Card view for a Tag 69 | """ 70 | 71 | def __init__(self, pdata, dbstate, uistate, nav_group=1): 72 | CardView.__init__( 73 | self, 74 | _("Tag"), 75 | pdata, 76 | dbstate, 77 | uistate, 78 | nav_group, 79 | ) 80 | 81 | def navigation_type(self): 82 | """ 83 | Return active navigation type. 84 | """ 85 | return "Tag" 86 | 87 | def set_active(self): 88 | CardView.set_active(self) 89 | self.uistate.viewmanager.tags.tag_disable() 90 | self.bookmarks.undisplay() 91 | 92 | def set_inactive(self): 93 | CardView.set_inactive(self) 94 | self.uistate.viewmanager.tags.tag_enable(update_menu=False) 95 | self.bookmarks.undisplay() 96 | 97 | additional_ui = [ 98 | MENU_LOCALEXPORT, 99 | MENU_ADDEDITBOOK, 100 | MENU_COMMONGO, 101 | MENU_COMMONEDIT, 102 | MENU_OTHEREDIT, 103 | TOOLBAR_COMMONNAVIGATION, 104 | TOOLBAR_BARCOMMONEDIT 105 | % ( 106 | ADD_TOOLTIPS["Tag"], 107 | EDIT_TOOLTIPS["Tag"], 108 | DELETE_TOOLTIPS["Tag"], 109 | ), 110 | TOOLBAR_MOREBUTTONS, 111 | ] 112 | 113 | def define_actions(self): 114 | """ 115 | Define page specific actions. 116 | """ 117 | CardView.define_actions(self) 118 | self.first_action_group = ActionGroup(name="RW") 119 | self.first_action_group.add_actions( 120 | [("Add", self._add_new_tag), ("Remove", self._delete_tag)] 121 | ) 122 | self._add_action_group(self.first_action_group) 123 | 124 | def _add_new_tag(self, *_dummy_obj): 125 | """ 126 | Add a new tag to the database. 127 | """ 128 | action = action_handler("Tag", self.grstate, Tag()) 129 | action.edit_tag() 130 | 131 | def _delete_tag(self, *_dummy_obj): 132 | """ 133 | Delete note. 134 | """ 135 | if self.current_context: 136 | tag = self.current_context.primary_obj.obj 137 | action = action_handler("Tag", self.grstate, tag) 138 | action.delete_object(tag) 139 | -------------------------------------------------------------------------------- /src/field_child.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_child", 24 | name=_("Child Number Field Calculator"), 25 | description=_("A child number field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_child.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_duration.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_duration", 24 | name=_("Duration Field Calculator"), 25 | description=_("A duration related field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_duration.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_marriage_age.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_marriage_age", 24 | name=_("Marriage Age Field Calculator"), 25 | description=_("A marriage age field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_marriage_age.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_marriage_age.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Marriage age field calculator. 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gen.lib import Family 32 | 33 | # ------------------------------------------------------------------------- 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------- 38 | from view.common.common_vitals import get_marriage_ages 39 | 40 | _ = glocale.translation.sgettext 41 | 42 | AGES = "Ages" 43 | AGES_LANG = _("Ages") 44 | BRIDE_AGE = "Bride Age" 45 | BRIDE_AGE_LANG = _("Bride Age") 46 | GROOM_AGE = "Groom Age" 47 | GROOM_AGE_LANG = _("Groom Age") 48 | 49 | 50 | # ------------------------------------------------------------------------ 51 | # 52 | # Calculated field plugin API consists of a dictionary with the supported 53 | # object types and keyword values, default options, callable to build 54 | # configuration grids for the options, and callable to generate the field 55 | # labels. 56 | # 57 | # ------------------------------------------------------------------------ 58 | def load_on_reg(_dummy_dbstate, _dummy_uistate, _dummy_plugin): 59 | """ 60 | Return calculated field plugin attributes. 61 | """ 62 | return [ 63 | { 64 | "supported_types": supported_types, 65 | "default_options": [], 66 | "get_config_grids": build_marriage_age_grid, 67 | "get_field": get_marriage_age_field, 68 | } 69 | ] 70 | 71 | 72 | supported_types = { 73 | "Family": [ 74 | (AGES, AGES_LANG), 75 | (BRIDE_AGE, BRIDE_AGE_LANG), 76 | (GROOM_AGE, GROOM_AGE_LANG), 77 | ] 78 | } 79 | 80 | 81 | def build_marriage_age_grid(_dummy_configdialog, _dummy_grstate): 82 | """ 83 | Build the marriage age option grid. As we have none return None. 84 | """ 85 | return None 86 | 87 | 88 | def get_marriage_age_field(grstate, obj, field_value, args): 89 | """ 90 | Calculate ages of couple. 91 | """ 92 | if not isinstance(obj, Family): 93 | return [] 94 | get_label = args.get("get_label") 95 | 96 | groom_age, bride_age = get_marriage_ages(grstate.dbstate.db, obj) 97 | if bride_age: 98 | bride_text = bride_age 99 | else: 100 | bride_text = _("Unknown") 101 | 102 | if field_value == BRIDE_AGE: 103 | return [(get_label(BRIDE_AGE_LANG), get_label(bride_text))] 104 | 105 | if groom_age: 106 | groom_text = groom_age 107 | else: 108 | groom_text = _("Unknown") 109 | 110 | if field_value == GROOM_AGE: 111 | return [(get_label(GROOM_AGE_LANG), get_label(groom_text))] 112 | 113 | bride_text = "%s %s" % (_("Bride age"), bride_text.lower()) 114 | groom_text = "%s %s" % (_("Groom age"), groom_text.lower()) 115 | text = "%s; %s" % (bride_text, groom_text) 116 | return [(get_label(AGES_LANG), get_label(text))] 117 | -------------------------------------------------------------------------------- /src/field_occupations.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_occupations", 24 | name=_("Occupations Field Calculator"), 25 | description=_("An occupations field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_occupations.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_occupations.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Occupations field calculator. 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | 38 | _ = glocale.translation.sgettext 39 | 40 | 41 | # ------------------------------------------------------------------------ 42 | # 43 | # Calculated field plugin API consists of a dictionary with the supported 44 | # object types and keyword values, default options, callable to build 45 | # configuration grids for the options, and callable to generate the field 46 | # labels. 47 | # 48 | # ------------------------------------------------------------------------ 49 | def load_on_reg(_dummy_dbstate, _dummy_uistate, _dummy_plugin): 50 | """ 51 | Return calculated field plugin attributes. 52 | """ 53 | return [ 54 | { 55 | "supported_types": supported_types, 56 | "default_options": [], 57 | "get_config_grids": build_occupations_grid, 58 | "get_field": get_occupations_field, 59 | } 60 | ] 61 | 62 | 63 | supported_types = {"Person": [("Occupations", _("Occupations"))]} 64 | 65 | 66 | def build_occupations_grid(_dummy_configdialog, _dummy_grstate): 67 | """ 68 | Build the occupations option grid. As we have none return None. 69 | """ 70 | return None 71 | 72 | 73 | def get_occupations_field(_dummy_grstate, obj, _dummy_event_type, args): 74 | """ 75 | Calculate a list of occupations. 76 | """ 77 | args = args or {} 78 | get_label = args.get("get_label") 79 | 80 | occupations = [] 81 | event_cache = args.get("event_cache") or {} 82 | for event in event_cache: 83 | if ( 84 | event.get_type().xml_str() == "Occupation" 85 | and event.get_description() not in occupations 86 | ): 87 | occupations.append(event.get_description()) 88 | 89 | for attribute in obj.attribute_list: 90 | if ( 91 | attribute.get_type().xml_str() == "Occupation" 92 | and attribute.get_value() not in occupations 93 | ): 94 | occupations.append(attribute.get_value()) 95 | 96 | if occupations: 97 | return [ 98 | ( 99 | get_label(_("Occupations")), 100 | get_label(", ".join(tuple(occupations))), 101 | ) 102 | ] 103 | return [] 104 | -------------------------------------------------------------------------------- /src/field_progenitors.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_progenitors", 24 | name=_("Progenitors Field Calculator"), 25 | description=_("A progenitors field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_progenitors.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_relationship.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="field_relationship", 24 | name=_("Couple Relationship Field Calculator"), 25 | description=_("A couple relationship field calculator."), 26 | category="FIELD", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="field_relationship.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/field_relationship.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Couple relationship field calculator. 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gen.lib import Family 32 | 33 | # ------------------------------------------------------------------------- 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------- 38 | 39 | _ = glocale.translation.sgettext 40 | 41 | 42 | # ------------------------------------------------------------------------ 43 | # 44 | # Calculated field plugin API consists of a dictionary with the supported 45 | # object types and keyword values, default options, callable to build 46 | # configuration grids for the options, and callable to generate the field 47 | # labels. 48 | # 49 | # ------------------------------------------------------------------------ 50 | def load_on_reg(_dummy_dbstate, _dummy_uistate, _dummy_plugin): 51 | """ 52 | Return calculated field plugin attributes. 53 | """ 54 | return [ 55 | { 56 | "supported_types": supported_types, 57 | "default_options": [], 58 | "get_config_grids": build_relationship_grid, 59 | "get_field": get_relationship_field, 60 | } 61 | ] 62 | 63 | 64 | supported_types = {"Family": [("Relationship", _("Relationship"))]} 65 | 66 | 67 | def build_relationship_grid(_dummy_configdialog, _dummy_grstate): 68 | """ 69 | Build the couple relationship option grid. As we have none return None. 70 | """ 71 | return None 72 | 73 | 74 | def get_relationship_field(grstate, obj, field_value, args): 75 | """ 76 | Calculate potential ancestral relationship between a couple. 77 | """ 78 | if not isinstance(obj, Family) or not field_value == "Relationship": 79 | return [] 80 | 81 | get_label = args.get("get_label") 82 | 83 | if not obj.father_handle or not obj.mother_handle: 84 | return [] 85 | 86 | father = grstate.fetch("Person", obj.father_handle) 87 | mother = grstate.fetch("Person", obj.mother_handle) 88 | 89 | relations = grstate.uistate.relationship.get_all_relationships( 90 | grstate.dbstate.db, father, mother 91 | ) 92 | for relation in relations[0]: 93 | if _("husband") not in relation and _("wife") not in relation: 94 | text = relation 95 | if "(" in text: 96 | text = text.split("(")[0].strip() 97 | return [ 98 | ( 99 | get_label(_("Relationship")), 100 | get_label(text.capitalize()), 101 | ) 102 | ] 103 | return [] 104 | -------------------------------------------------------------------------------- /src/status_person.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="status_person", 24 | name=_("Person Status Indicators"), 25 | description=_("Status indicators for how well researched a person is."), 26 | category="STATUS", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="status_person.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/status_todo.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="status_todo", 24 | name=_("To Do Status Indicator"), 25 | description=_("A To Do note status indicator."), 26 | category="STATUS", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="status_todo.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/tagview.gpr.py: -------------------------------------------------------------------------------- 1 | # encoding:utf-8 2 | # 3 | # Gramps - a GTK+/GNOME based genealogy program 4 | # 5 | # Copyright (C) 2009 Benny Malengier 6 | # Copyright (C) 2009 Douglas S. Blank 7 | # Copyright (C) 2009 Nick Hall 8 | # Copyright (C) 2011 Tim G L Lyons 9 | # Copyright (C) 2022 Christopher Horn 10 | # 11 | # This program is free software; you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation; either version 2 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # This program is distributed in the hope that it will be useful, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with this program; if not, write to the Free Software 23 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 24 | # 25 | from gramps.gen.const import GRAMPS_LOCALE as glocale 26 | 27 | _ = glocale.translation.gettext 28 | 29 | MODULE_VERSION = "6.0" 30 | 31 | # ------------------------------------------------------------------------ 32 | # 33 | # default views of Gramps 34 | # 35 | # ------------------------------------------------------------------------ 36 | 37 | register( 38 | VIEW, 39 | id="tagview", 40 | name=_("Tags"), 41 | description=_("The view showing all the tags"), 42 | version="0.93", 43 | gramps_target_version=MODULE_VERSION, 44 | status=STABLE, 45 | fname="tagview.py", 46 | authors=["The Gramps project"], 47 | authors_email=["http://gramps-project.org"], 48 | category=("Tags", _("Tags")), 49 | stock_icon="gramps-tag", 50 | stock_category_icon="gramps-tag", 51 | viewclass="TagView", 52 | order=START, 53 | ) 54 | -------------------------------------------------------------------------------- /src/template_minimal.gpr.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | register( 22 | GENERAL, 23 | id="template_minimal", 24 | name=_("Minimal Card View Template"), 25 | description=_("A minimal option template for the card views."), 26 | category="TEMPLATE", 27 | version="0.9", 28 | gramps_target_version="6.0", 29 | status=STABLE, 30 | fname="template_minimal.py", 31 | load_on_reg=True, 32 | authors=["Christopher Horn"], 33 | authors_email=["https://gramps-project.org"], 34 | ) 35 | -------------------------------------------------------------------------------- /src/view/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing the card view objects. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/actions/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing the context menu and drag and drop action handlers. 23 | """ 24 | 25 | from .action_address import AddressAction 26 | from .action_attribute import AttributeAction 27 | from .action_bookmark import BookmarkAction 28 | from .action_citation import CitationAction 29 | from .action_event import EventAction 30 | from .action_factory import action_handler 31 | from .action_family import FamilyAction 32 | from .action_ldsord import LdsOrdAction 33 | from .action_media import MediaAction 34 | from .action_name import NameAction 35 | from .action_note import NoteAction 36 | from .action_person import PersonAction 37 | from .action_place import PlaceAction 38 | from .action_privacy import PrivacyAction 39 | from .action_repository import RepositoryAction 40 | from .action_source import SourceAction 41 | from .action_tag import TagAction 42 | from .action_url import UrlAction 43 | -------------------------------------------------------------------------------- /src/view/actions/action_address.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2011 Tim G L Lyons 7 | # Copyright (C) 2015-2016 Nick Hall 8 | # Copyright (C) 2021-2022 Christopher Horn 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | 25 | """ 26 | AddressAction 27 | """ 28 | 29 | # ------------------------------------------------------------------------ 30 | # 31 | # Gramps Modules 32 | # 33 | # ------------------------------------------------------------------------ 34 | from gramps.gen.const import GRAMPS_LOCALE as glocale 35 | from gramps.gen.errors import WindowActiveError 36 | from gramps.gui.editors import EditAddress 37 | 38 | # ------------------------------------------------------------------------ 39 | # 40 | # Plugin Modules 41 | # 42 | # ------------------------------------------------------------------------ 43 | from .action_base import GrampsAction 44 | from .action_factory import factory 45 | 46 | _ = glocale.translation.sgettext 47 | 48 | 49 | # ------------------------------------------------------------------------ 50 | # 51 | # AddressAction Class 52 | # 53 | # ------------------------------------------------------------------------ 54 | class AddressAction(GrampsAction): 55 | """ 56 | Class to support actions related to address objects. 57 | """ 58 | 59 | def __init__(self, grstate, action_object=None, target_object=None): 60 | GrampsAction.__init__(self, grstate, action_object, target_object) 61 | 62 | def edit_address(self, *_dummy_args): 63 | """ 64 | Edit an address. 65 | """ 66 | callback = lambda x: self._edited_address( 67 | x, self.action_object.obj_hash 68 | ) 69 | try: 70 | EditAddress( 71 | self.grstate.dbstate, 72 | self.grstate.uistate, 73 | [], 74 | self.action_object.obj, 75 | callback, 76 | ) 77 | except WindowActiveError: 78 | pass 79 | 80 | def _edited_address(self, address, old_hash): 81 | """ 82 | Save edited address. 83 | """ 84 | if address: 85 | self.grstate.update_history_object(old_hash, address) 86 | message = _("Edited Address for %s") % ( 87 | self.describe_object(self.target_object.obj), 88 | ) 89 | self.target_object.commit(self.grstate, message) 90 | 91 | 92 | factory.register_action("Address", AddressAction) 93 | -------------------------------------------------------------------------------- /src/view/actions/action_bookmark.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2011 Tim G L Lyons 7 | # Copyright (C) 2015-2016 Nick Hall 8 | # Copyright (C) 2021-2022 Christopher Horn 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | 25 | """ 26 | BookmarkAction 27 | """ 28 | 29 | # ------------------------------------------------------------------------ 30 | # 31 | # Plugin Modules 32 | # 33 | # ------------------------------------------------------------------------ 34 | from ..common.common_utils import get_bookmarks 35 | from .action_base import GrampsAction 36 | from .action_factory import factory 37 | 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # BookmarkAction Class 42 | # 43 | # action_object is the TableObject, a primary Gramps object other than Tag 44 | # 45 | # ------------------------------------------------------------------------ 46 | class BookmarkAction(GrampsAction): 47 | """ 48 | Class to support toggling the bookmark state for an object. 49 | """ 50 | 51 | def __init__(self, grstate, action_object, callback=None): 52 | GrampsAction.__init__(self, grstate, action_object) 53 | self.callback = callback 54 | 55 | def set_callback(self, callback): 56 | """ 57 | Set the callback. 58 | """ 59 | self.callback = callback 60 | 61 | def is_set(self, *_dummy_args): 62 | """ 63 | Return true if bookmark set. 64 | """ 65 | bookmarks = get_bookmarks(self.db, self.action_object.obj_type).get() 66 | if self.action_object.obj.handle in bookmarks: 67 | return True 68 | return False 69 | 70 | def toggle(self, *_dummy_args): 71 | """ 72 | Toggle the bookmark state. 73 | """ 74 | bookmarks = get_bookmarks(self.db, self.action_object.obj_type) 75 | if self.is_set(): 76 | bookmarks.remove(self.action_object.obj.handle) 77 | else: 78 | bookmarks.insert(0, self.action_object.obj.handle) 79 | self.grstate.set_dirty_redraw_trigger() 80 | context = self.grstate.fetch_page_context() 81 | self.grstate.load_page(context.pickled) 82 | if self.callback: 83 | self.callback(self.action_object) 84 | 85 | 86 | factory.register_action("Bookmark", BookmarkAction) 87 | -------------------------------------------------------------------------------- /src/view/actions/action_const.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2000-2007 Donald N. Allingham 5 | # Copyright (C) 2015-2016 Nick Hall 6 | # Copyright (C) 2021-2022 Christopher Horn 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | # 22 | 23 | """ 24 | Action handler related constants 25 | """ 26 | 27 | # ------------------------------------------------------------------------ 28 | # 29 | # Gramps Modules 30 | # 31 | # ------------------------------------------------------------------------ 32 | from gramps.gen.const import GRAMPS_LOCALE as glocale 33 | from gramps.gui.editors import ( 34 | EditAddress, 35 | EditAttribute, 36 | EditCitation, 37 | EditEvent, 38 | EditFamily, 39 | EditLdsOrd, 40 | EditMedia, 41 | EditName, 42 | EditNote, 43 | EditPerson, 44 | EditPlace, 45 | EditRepository, 46 | EditSource, 47 | EditUrl, 48 | ) 49 | from gramps.gui.views.tags import EditTag 50 | 51 | # ------------------------------------------------------------------------ 52 | # 53 | # Plugin Modules 54 | # 55 | # ------------------------------------------------------------------------ 56 | _ = glocale.translation.sgettext 57 | 58 | 59 | RECIPROCAL_ASSOCIATIONS = { 60 | _("Godfather"): _("Godchild"), 61 | _("Godmother"): _("Godchild"), 62 | _("Godparent"): _("Godchild"), 63 | _("Godchild"): _("Godparent"), 64 | _("Landlord"): _("Tenant"), 65 | _("Tenant"): _("Landlord"), 66 | _("DNA"): _("DNA"), 67 | _("cm"): _("cm"), 68 | _("Best Man"): _("Groom"), 69 | _("Maid of Honor"): _("Bride"), 70 | _("Friend"): _("Friend"), 71 | _("Employer"): _("Employee"), 72 | _("Employee"): _("Employer"), 73 | _("Lawyer"): _("Client"), 74 | _("Doctor"): _("Patient"), 75 | _("Patient"): _("Doctor"), 76 | _("Teacher"): _("Student"), 77 | _("Student"): _("Teacher"), 78 | } 79 | 80 | GRAMPS_EDITORS = { 81 | "Address": EditAddress, 82 | "Attribute": EditAttribute, 83 | "Citation": EditCitation, 84 | "Event": EditEvent, 85 | "Family": EditFamily, 86 | "LdsOrd": EditLdsOrd, 87 | "Media": EditMedia, 88 | "Name": EditName, 89 | "Note": EditNote, 90 | "Person": EditPerson, 91 | "Place": EditPlace, 92 | "Repository": EditRepository, 93 | "Source": EditSource, 94 | "Tag": EditTag, 95 | "Url": EditUrl, 96 | } 97 | -------------------------------------------------------------------------------- /src/view/actions/action_factory.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2011 Tim G L Lyons 7 | # Copyright (C) 2015-2016 Nick Hall 8 | # Copyright (C) 2021-2022 Christopher Horn 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | 25 | """ 26 | GrampsActionFactory 27 | """ 28 | 29 | # ------------------------------------------------------------------------ 30 | # 31 | # GrampsActionFactory class 32 | # 33 | # ------------------------------------------------------------------------ 34 | class GrampsActionFactory: 35 | """ 36 | Base class to support actions on or between Gramps objects. 37 | """ 38 | 39 | def __init__(self): 40 | self._actions = {} 41 | 42 | def register_action(self, obj_type, handler): 43 | """ 44 | Register action handler. 45 | """ 46 | self._actions[obj_type] = handler 47 | 48 | def create(self, obj_type, *args): 49 | """ 50 | Get an action handler. 51 | """ 52 | handler = self._actions.get(obj_type) 53 | return handler(*args) 54 | 55 | 56 | factory = GrampsActionFactory() 57 | 58 | 59 | def action_handler(*args): 60 | """ 61 | Return the proper action handler. 62 | """ 63 | return factory.create(*args) 64 | -------------------------------------------------------------------------------- /src/view/actions/action_privacy.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2011 Tim G L Lyons 7 | # Copyright (C) 2015-2016 Nick Hall 8 | # Copyright (C) 2021-2022 Christopher Horn 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | 25 | """ 26 | PrivacyAction 27 | """ 28 | 29 | # ------------------------------------------------------------------------ 30 | # 31 | # Gramps Modules 32 | # 33 | # ------------------------------------------------------------------------ 34 | from gramps.gen.const import GRAMPS_LOCALE as glocale 35 | from gramps.gen.lib.privacybase import PrivacyBase 36 | 37 | # ------------------------------------------------------------------------ 38 | # 39 | # Plugin Modules 40 | # 41 | # ------------------------------------------------------------------------ 42 | from .action_base import GrampsAction 43 | from .action_factory import factory 44 | 45 | _ = glocale.translation.sgettext 46 | 47 | 48 | # ------------------------------------------------------------------------ 49 | # 50 | # PrivacyAction Class 51 | # 52 | # target_object and target_child_object are PrivacyBase objects 53 | # 54 | # ------------------------------------------------------------------------ 55 | class PrivacyAction(GrampsAction): 56 | """ 57 | Class to support toggling the privacy option on an object. 58 | """ 59 | 60 | def __init__(self, grstate, target_object, target_child_object=None): 61 | GrampsAction.__init__( 62 | self, 63 | grstate, 64 | target_object=target_object, 65 | target_child_object=target_child_object, 66 | ) 67 | 68 | def is_valid(self): 69 | """ 70 | Return true if had privacy attribute. 71 | """ 72 | active_target_object = self.get_target_object() 73 | return isinstance(active_target_object.obj, PrivacyBase) 74 | 75 | def is_set(self): 76 | """ 77 | Return true if set. 78 | """ 79 | active_target_object = self.get_target_object() 80 | return active_target_object.obj.private 81 | 82 | def toggle(self, *_dummy_args): 83 | """ 84 | Toggle the privacy indicator. 85 | """ 86 | active_target_object = self.get_target_object() 87 | mode = active_target_object.obj.private 88 | if mode: 89 | text = _("Public") 90 | else: 91 | text = _("Private") 92 | if self.target_child_object: 93 | message = _("Made %s for %s %s") % ( 94 | self.target_child_object.obj_lang, 95 | self.describe_object(self.target_object.obj), 96 | text, 97 | ) 98 | else: 99 | message = _("Made %s %s") % ( 100 | self.describe_object(self.target_object.obj), 101 | text, 102 | ) 103 | active_target_object.save_hash() 104 | active_target_object.obj.set_privacy(not mode) 105 | active_target_object.sync_hash(self.grstate) 106 | self.target_object.commit(self.grstate, message) 107 | 108 | 109 | factory.register_action("Privacy", PrivacyAction) 110 | -------------------------------------------------------------------------------- /src/view/bars/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing bar style group views. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/cards/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing the cards for the card groups and page views. 23 | """ 24 | 25 | from .card_address import AddressCard 26 | from .card_attribute import AttributeCard 27 | from .card_child_ref import ChildRefCard 28 | from .card_citation import CitationCard 29 | from .card_event import EventCard 30 | from .card_event_ref import EventRefCard 31 | from .card_family import FamilyCard 32 | from .card_family_tree import FamilyTreeCard 33 | from .card_media import MediaCard 34 | from .card_media_ref import MediaRefCard 35 | from .card_name import NameCard 36 | from .card_note import NoteCard 37 | from .card_note_url import NoteUrlCard 38 | from .card_ordinance import LDSOrdinanceCard 39 | from .card_person import PersonCard 40 | from .card_person_backref import PersonBackRefCard 41 | from .card_person_ref import PersonRefCard 42 | from .card_place import PlaceCard 43 | from .card_place_ref import PlaceRefCard 44 | from .card_repository import RepositoryCard 45 | from .card_repository_ref import RepositoryRefCard 46 | from .card_source import SourceCard 47 | from .card_tag import TagCard 48 | from .card_text import TextCard 49 | from .card_url import UrlCard 50 | -------------------------------------------------------------------------------- /src/view/cards/card_address.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | AddressCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..common.common_utils import format_address 38 | from .card_secondary import SecondaryCard 39 | 40 | _ = glocale.translation.sgettext 41 | 42 | 43 | # ------------------------------------------------------------------------ 44 | # 45 | # AddressCard Class 46 | # 47 | # ------------------------------------------------------------------------ 48 | class AddressCard(SecondaryCard): 49 | """ 50 | The AddressCard exposes some of the basic facts about an Address. 51 | """ 52 | 53 | def __init__( 54 | self, 55 | grstate, 56 | groptions, 57 | obj, 58 | address, 59 | ): 60 | SecondaryCard.__init__(self, grstate, groptions, obj, address) 61 | self.__add_address_formatted(address) 62 | self.__add_address_phone(address) 63 | self.__add_address_date(address) 64 | if len(self.widgets["facts"]) == 0: 65 | self.add_fact(self.get_label("[%s]" % _("Empty"))) 66 | self.show_all() 67 | self.enable_drag() 68 | self.enable_drop( 69 | self.eventbox, self.dnd_drop_targets, self.drag_data_received 70 | ) 71 | self.set_css_style() 72 | 73 | def __add_address_formatted(self, address): 74 | """ 75 | Add formatted address. 76 | """ 77 | lines = format_address(address) 78 | for line in lines: 79 | self.add_fact(self.get_label(line)) 80 | 81 | def __add_address_phone(self, address): 82 | """ 83 | Add phone number. 84 | """ 85 | if address.phone: 86 | self.add_fact(self.get_label(address.phone)) 87 | 88 | def __add_address_date(self, address): 89 | """ 90 | Add address date. 91 | """ 92 | address_date = address.get_date_object() 93 | if address_date: 94 | self.add_fact( 95 | self.get_label(glocale.date_displayer.display(address_date)) 96 | ) 97 | if self.groptions.age_base and ( 98 | self.groptions.context in ["timeline"] 99 | or self.grstate.config.get("group.address.show-age") 100 | ): 101 | self.load_age(self.groptions.age_base, address_date) 102 | -------------------------------------------------------------------------------- /src/view/cards/card_attribute.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | AttributeCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from html import escape 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # GTK Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from gi.repository import Gtk 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # Gramps Modules 42 | # 43 | # ------------------------------------------------------------------------ 44 | from gramps.gen.const import GRAMPS_LOCALE as glocale 45 | 46 | # ------------------------------------------------------------------------ 47 | # 48 | # Plugin Modules 49 | # 50 | # ------------------------------------------------------------------------ 51 | from ..common.common_classes import GrampsContext 52 | from .card_secondary import SecondaryCard 53 | 54 | _ = glocale.translation.sgettext 55 | 56 | 57 | # ------------------------------------------------------------------------ 58 | # 59 | # AttributeCard Class 60 | # 61 | # ------------------------------------------------------------------------ 62 | class AttributeCard(SecondaryCard): 63 | """ 64 | The AttributeCard exposes facts about an Attribute. 65 | """ 66 | 67 | def __init__(self, grstate, groptions, obj, attribute): 68 | SecondaryCard.__init__(self, grstate, groptions, obj, attribute) 69 | self.__add_attribute_title(attribute) 70 | self.__add_attribute_value(attribute) 71 | self.enable_drag() 72 | self.enable_drop( 73 | self.eventbox, self.dnd_drop_targets, self.drag_data_received 74 | ) 75 | self.set_css_style() 76 | 77 | def __add_attribute_title(self, attribute): 78 | """ 79 | Add attribute title. 80 | """ 81 | name = glocale.translation.sgettext(attribute.get_type().xml_str()) 82 | if "Ref" not in self.primary.obj_type: 83 | label = self.get_link( 84 | name, 85 | self.primary.obj_type, 86 | self.primary.obj.handle, 87 | callback=self.switch_attribute_page, 88 | ) 89 | else: 90 | name = "%s" % escape(name) 91 | label = Gtk.Label( 92 | halign=Gtk.Align.START, 93 | wrap=True, 94 | xalign=0.0, 95 | justify=Gtk.Justification.LEFT, 96 | ) 97 | label.set_markup(name) 98 | self.widgets["title"].pack_start(label, False, False, 0) 99 | 100 | def __add_attribute_value(self, attribute): 101 | """ 102 | Add attribute value. 103 | """ 104 | if attribute.get_value(): 105 | self.add_fact(self.get_label(attribute.get_value())) 106 | 107 | def switch_attribute_page(self, *_dummy_obj): 108 | """ 109 | Initiate switch to attribute page. 110 | """ 111 | context = GrampsContext(self.primary.obj, None, self.secondary.obj) 112 | self.grstate.load_page(context.pickled) 113 | 114 | def route_action(self, obj, event): 115 | """ 116 | Route the action if the card was clicked on. 117 | """ 118 | if "Ref" not in self.primary.obj_type: 119 | SecondaryCard.route_action(self, obj, event) 120 | -------------------------------------------------------------------------------- /src/view/cards/card_child_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | ChildRefCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gui.ddtargets import DdTargets 32 | 33 | # ------------------------------------------------------------------------ 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------ 38 | from ..actions import action_handler 39 | from ..menus.menu_utils import menu_item 40 | from .card_person import PersonCard 41 | from ..common.common_strings import DELETE_REFERENCE, EDIT_REFERENCE 42 | 43 | _ = glocale.translation.sgettext 44 | 45 | 46 | # ------------------------------------------------------------------------ 47 | # 48 | # ChildRefCard Class 49 | # 50 | # ------------------------------------------------------------------------ 51 | class ChildRefCard(PersonCard): 52 | """ 53 | The ChildRefCard exposes some of the basic facts about a Child. 54 | """ 55 | 56 | def __init__( 57 | self, 58 | grstate, 59 | groptions, 60 | family, 61 | child_ref, 62 | ): 63 | child = grstate.fetch("Person", child_ref.ref) 64 | PersonCard.__init__( 65 | self, 66 | grstate, 67 | groptions, 68 | child, 69 | reference_tuple=(family, child_ref), 70 | ) 71 | if groptions.ref_mode: 72 | if child_ref.get_father_relation(): 73 | relation_type = str(child_ref.get_father_relation()) 74 | self.add_ref_item(_("Father"), relation_type) 75 | if child_ref.get_mother_relation(): 76 | relation_type = str(child_ref.get_mother_relation()) 77 | self.add_ref_item(_("Mother"), relation_type) 78 | self.show_ref_items() 79 | 80 | self.dnd_drop_ref_targets.append(DdTargets.PERSON_LINK.target()) 81 | self.dnd_drop_ref_targets.append(DdTargets.EVENT.target()) 82 | self.ref_enable_drop( 83 | self.ref_eventbox, 84 | self.dnd_drop_ref_targets, 85 | self.ref_drag_data_received, 86 | ) 87 | 88 | def _ref_child_drop_handler(self, dnd_type, obj_or_handle, data): 89 | """ 90 | Handle child reference specific drop processing. 91 | """ 92 | if DdTargets.EVENT.drag_type == dnd_type: 93 | action = action_handler("Person", self.grstate, self.primary) 94 | action.add_new_event(None, obj_or_handle) 95 | return True 96 | if DdTargets.PERSON_LINK.drag_type == dnd_type: 97 | action = action_handler("Person", self.grstate, self.primary) 98 | action._add_new_person_reference(obj_or_handle) 99 | return True 100 | return self._ref_base_drop_handler(dnd_type, obj_or_handle, data) 101 | 102 | def add_ref_custom_actions(self, context_menu): 103 | """ 104 | Build the action menu for a right click on a reference object. 105 | """ 106 | action = action_handler( 107 | "Family", self.grstate, self.reference_base, self.reference 108 | ) 109 | context_menu.append( 110 | menu_item("gtk-edit", EDIT_REFERENCE, action.edit_child_reference) 111 | ) 112 | if self.grstate.config.get("menu.delete"): 113 | context_menu.append( 114 | menu_item("list-remove", DELETE_REFERENCE, action.remove_child) 115 | ) 116 | -------------------------------------------------------------------------------- /src/view/cards/card_event_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | EventRefCard. 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gen.display.name import displayer as name_displayer 32 | from gramps.gen.utils.db import family_name 33 | from gramps.gui.ddtargets import DdTargets 34 | 35 | # ------------------------------------------------------------------------ 36 | # 37 | # Plugin Modules 38 | # 39 | # ------------------------------------------------------------------------ 40 | from ..actions import action_handler 41 | from ..common.common_strings import DELETE_REFERENCE, EDIT_REFERENCE 42 | from ..menus.menu_utils import menu_item 43 | from .card_event import EventCard 44 | 45 | _ = glocale.translation.sgettext 46 | 47 | 48 | # ------------------------------------------------------------------------ 49 | # 50 | # EventRefCard Class 51 | # 52 | # ------------------------------------------------------------------------ 53 | class EventRefCard(EventCard): 54 | """ 55 | The EventRefCard exposes some of the basic facts about an Event 56 | for a Person or Family 57 | """ 58 | 59 | def __init__(self, grstate, groptions, obj, event_ref): 60 | event = grstate.fetch("Event", event_ref.ref) 61 | reference_tuple = (obj, event_ref) 62 | EventCard.__init__( 63 | self, grstate, groptions, event, reference_tuple=reference_tuple 64 | ) 65 | if groptions.ref_mode: 66 | role = str(event_ref.get_role()) 67 | if ( 68 | groptions.relation 69 | and groptions.relation.handle != self.reference_base.obj.handle 70 | ): 71 | name = None 72 | if self.reference_base.obj_type == "Person": 73 | name = name_displayer.display(self.reference_base.obj) 74 | elif self.reference_base.obj_type == "Family": 75 | name = family_name( 76 | self.reference_base.obj, grstate.dbstate.db 77 | ) 78 | if name: 79 | self.add_ref_item(name, role) 80 | else: 81 | self.add_ref_item(role, None) 82 | self.show_ref_items() 83 | 84 | self.dnd_drop_ref_targets.append(DdTargets.PERSON_LINK.target()) 85 | self.ref_enable_drop( 86 | self.ref_eventbox, 87 | self.dnd_drop_ref_targets, 88 | self.ref_drag_data_received, 89 | ) 90 | 91 | def _ref_child_drop_handler(self, dnd_type, obj_or_handle, data): 92 | """ 93 | Handle child reference specific drop processing. 94 | """ 95 | if DdTargets.PERSON_LINK.drag_type == dnd_type: 96 | action = action_handler("Event", self.grstate, self.primary) 97 | action.add_existing_participant(person_handle=obj_or_handle) 98 | return True 99 | return self._ref_base_drop_handler(dnd_type, obj_or_handle, data) 100 | 101 | def add_ref_custom_actions(self, context_menu): 102 | """ 103 | Add custom action menu items for the event reference. 104 | """ 105 | action = action_handler( 106 | "Event", self.grstate, self.primary, self.reference_base 107 | ) 108 | context_menu.append( 109 | menu_item("gtk-edit", EDIT_REFERENCE, action.edit_participant) 110 | ) 111 | if self.grstate.config.get("menu.delete"): 112 | context_menu.append( 113 | menu_item( 114 | "list-remove", 115 | DELETE_REFERENCE, 116 | action.remove_participant, 117 | ) 118 | ) 119 | -------------------------------------------------------------------------------- /src/view/cards/card_media_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | MediaRefCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..actions import action_handler 38 | from ..common.common_strings import ( 39 | DELETE_REFERENCE, 40 | EDIT_REFERENCE, 41 | MAKE_MEDIA_ACTIVE, 42 | ) 43 | from ..menus.menu_utils import menu_item 44 | from .card_media import MediaCard 45 | 46 | _ = glocale.translation.sgettext 47 | 48 | 49 | # ------------------------------------------------------------------------ 50 | # 51 | # MediaRefCard Class 52 | # 53 | # ------------------------------------------------------------------------ 54 | class MediaRefCard(MediaCard): 55 | """ 56 | The MediaRefCard exposes the image and some facts about Media. 57 | """ 58 | 59 | def __init__(self, grstate, groptions, obj, media_ref): 60 | media = grstate.fetch("Media", media_ref.ref) 61 | MediaCard.__init__( 62 | self, grstate, groptions, media, reference_tuple=(obj, media_ref) 63 | ) 64 | 65 | def add_ref_custom_actions(self, context_menu): 66 | """ 67 | Add custom action menu items for the reference. 68 | """ 69 | action = action_handler( 70 | "Media", self.grstate, self.reference, self.reference_base 71 | ) 72 | context_menu.append( 73 | menu_item("gtk-edit", EDIT_REFERENCE, action.edit_media) 74 | ) 75 | if self.grstate.config.get("menu.delete"): 76 | context_menu.append( 77 | menu_item( 78 | "list-remove", 79 | DELETE_REFERENCE, 80 | action.remove_media_reference, 81 | ) 82 | ) 83 | context_menu.append( 84 | menu_item( 85 | "gramps-media", 86 | MAKE_MEDIA_ACTIVE, 87 | action.set_active_media, 88 | ) 89 | ) 90 | -------------------------------------------------------------------------------- /src/view/cards/card_note_url.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | NoteUrlCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from html import escape 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # GTK Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from gi.repository import Gtk 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # Gramps Modules 42 | # 43 | # ------------------------------------------------------------------------ 44 | from gramps.gen.const import GRAMPS_LOCALE as glocale 45 | from gramps.gui.display import display_url 46 | 47 | # ------------------------------------------------------------------------ 48 | # 49 | # Plugin Modules 50 | # 51 | # ------------------------------------------------------------------------ 52 | from ..common.common_const import BUTTON_PRIMARY 53 | from ..common.common_utils import button_released 54 | from .card_object import ObjectCard 55 | 56 | _ = glocale.translation.sgettext 57 | 58 | 59 | # ------------------------------------------------------------------------ 60 | # 61 | # NoteUrlCard Class 62 | # 63 | # ------------------------------------------------------------------------ 64 | class NoteUrlCard(ObjectCard): 65 | """ 66 | The NoteUrlCard class exposes information about a Url found 67 | in a Note record. 68 | """ 69 | 70 | def __init__(self, grstate, groptions, note, link): 71 | ObjectCard.__init__(self, grstate, groptions, note) 72 | self.link = link 73 | self.build_layout() 74 | 75 | label = Gtk.Label(use_markup=True, label="%s" % escape(link)) 76 | self.widgets["title"].pack_start(label, False, False, 0) 77 | text = "%s %s %s %s" % (_("Found"), _("in"), _("note"), note.gramps_id) 78 | note_link = self.get_link( 79 | text, 80 | "Note", 81 | note.handle, 82 | hexpand=False, 83 | title=False, 84 | ) 85 | self.widgets["facts"].attach(note_link, 0, 0, 1, 1) 86 | self.set_css_style() 87 | self.show_all() 88 | 89 | def cb_button_released(self, obj, event): 90 | """ 91 | Handle button released. 92 | """ 93 | if button_released(event, BUTTON_PRIMARY): 94 | display_url(self.link) 95 | return True 96 | return False 97 | -------------------------------------------------------------------------------- /src/view/cards/card_place_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | PlaceRefCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..actions import action_handler 38 | from ..common.common_strings import ( 39 | DELETE_REFERENCE, 40 | EDIT_REFERENCE, 41 | NONE_PROVIDED, 42 | ) 43 | from ..menus.menu_utils import menu_item 44 | from .card_place import PlaceCard 45 | 46 | _ = glocale.translation.sgettext 47 | 48 | 49 | # ------------------------------------------------------------------------ 50 | # 51 | # PlaceRefCard Class 52 | # 53 | # ------------------------------------------------------------------------ 54 | class PlaceRefCard(PlaceCard): 55 | """ 56 | The PlaceRefCard exposes some of the basic facts about an 57 | enclosed Place. 58 | """ 59 | 60 | def __init__( 61 | self, 62 | grstate, 63 | groptions, 64 | place, 65 | place_ref, 66 | ): 67 | enclosed_place = grstate.fetch("Place", place_ref.ref) 68 | PlaceCard.__init__( 69 | self, 70 | grstate, 71 | groptions, 72 | place, 73 | reference_tuple=(enclosed_place, place_ref), 74 | ) 75 | if groptions.ref_mode: 76 | date = glocale.date_displayer.display(place_ref.get_date_object()) 77 | if not date: 78 | date = NONE_PROVIDED 79 | self.add_ref_item(_("Date"), date) 80 | self.show_ref_items() 81 | 82 | def add_ref_custom_actions(self, context_menu): 83 | """ 84 | Add custom action menu items for an associate. 85 | """ 86 | action = action_handler( 87 | "Place", self.grstate, self.primary, self.reference 88 | ) 89 | context_menu.append( 90 | menu_item("gtk-edit", EDIT_REFERENCE, action.edit_place) 91 | ) 92 | context_menu.append( 93 | menu_item( 94 | "list-remove", 95 | DELETE_REFERENCE, 96 | action.remove_place_reference, 97 | ) 98 | ) 99 | -------------------------------------------------------------------------------- /src/view/cards/card_repository_ref.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | RepositoryRefCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gui.ddtargets import DdTargets 32 | 33 | # ------------------------------------------------------------------------ 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------ 38 | from ..actions import action_handler 39 | from ..common.common_strings import DELETE_REFERENCE, EDIT_REFERENCE 40 | from ..menus.menu_utils import menu_item 41 | from .card_repository import RepositoryCard 42 | 43 | _ = glocale.translation.sgettext 44 | 45 | 46 | # ------------------------------------------------------------------------ 47 | # 48 | # RepositoryRefCard Class 49 | # 50 | # ------------------------------------------------------------------------ 51 | class RepositoryRefCard(RepositoryCard): 52 | """ 53 | The RepositoryRefCard exposes some of the basic facts about a 54 | Repository and the reference to it. 55 | """ 56 | 57 | def __init__(self, grstate, groptions, source, repo_ref=None): 58 | repository = grstate.fetch("Repository", repo_ref.ref) 59 | RepositoryCard.__init__( 60 | self, 61 | grstate, 62 | groptions, 63 | repository, 64 | reference_tuple=(source, repo_ref), 65 | ) 66 | if groptions.ref_mode: 67 | if self.get_option("show-call-number") and repo_ref.call_number: 68 | self.add_ref_item(_("Call number"), repo_ref.call_number) 69 | if self.get_option("show-media-type") and repo_ref.media_type: 70 | media_type = glocale.translation.sgettext( 71 | repo_ref.media_type.xml_str() 72 | ) 73 | self.add_ref_item(_("Media type"), media_type) 74 | self.show_ref_items() 75 | 76 | self.dnd_drop_targets.append(DdTargets.SOURCE_LINK.target()) 77 | self.ref_enable_drop( 78 | self.ref_eventbox, 79 | self.dnd_drop_ref_targets, 80 | self.ref_drag_data_received, 81 | ) 82 | 83 | def _ref_child_drop_handler(self, dnd_type, obj_or_handle, data): 84 | """ 85 | Handle drop processing for a repository. 86 | """ 87 | if DdTargets.SOURCE_LINK.drag_type == dnd_type: 88 | source = self.fetch("Source", obj_or_handle) 89 | action = action_handler( 90 | "Repository", self.grstate, self.primary, source 91 | ) 92 | action.add_new_source() 93 | return True 94 | return self._ref_base_drop_handler(dnd_type, obj_or_handle, data) 95 | 96 | def add_ref_custom_actions(self, context_menu): 97 | """ 98 | Build the action menu for a right click on a reference object. 99 | """ 100 | action = action_handler( 101 | "Source", self.grstate, self.reference_base, self.reference 102 | ) 103 | context_menu.append( 104 | menu_item( 105 | "gtk-edit", EDIT_REFERENCE, action.edit_repository_reference 106 | ) 107 | ) 108 | if self.grstate.config.get("menu.delete"): 109 | context_menu.append( 110 | menu_item( 111 | "list-remove", 112 | DELETE_REFERENCE, 113 | action.remove_repository_reference, 114 | ) 115 | ) 116 | -------------------------------------------------------------------------------- /src/view/cards/card_source.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | SourceCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gui.ddtargets import DdTargets 32 | 33 | # ------------------------------------------------------------------------ 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------ 38 | from ..actions import action_handler 39 | from ..menus.menu_utils import add_repositories_menu 40 | from .card_primary import PrimaryCard 41 | 42 | _ = glocale.translation.sgettext 43 | 44 | 45 | # ------------------------------------------------------------------------ 46 | # 47 | # SourceCard Class 48 | # 49 | # ------------------------------------------------------------------------ 50 | class SourceCard(PrimaryCard): 51 | """ 52 | The SourceCard exposes some of the basic facts about a Source. 53 | """ 54 | 55 | def __init__(self, grstate, groptions, source): 56 | PrimaryCard.__init__(self, grstate, groptions, source) 57 | self.__add_source_title(source) 58 | self.__add_source_author(source) 59 | self.__add_source_publisher(source) 60 | self.__add_source_abbrev(source) 61 | self.enable_drag() 62 | self.dnd_drop_targets.append(DdTargets.REPO_LINK.target()) 63 | self.enable_drop( 64 | self.eventbox, self.dnd_drop_targets, self.drag_data_received 65 | ) 66 | self.set_css_style() 67 | 68 | def __add_source_title(self, source): 69 | """ 70 | Add source title. 71 | """ 72 | title = self.get_link( 73 | source.title, 74 | "Source", 75 | source.handle, 76 | ) 77 | self.widgets["title"].pack_start(title, True, False, 0) 78 | 79 | def __add_source_author(self, source): 80 | """ 81 | Add source author. 82 | """ 83 | if source.author: 84 | self.add_fact(self.get_label(source.author)) 85 | 86 | def __add_source_publisher(self, source): 87 | """ 88 | Add source publisher. 89 | """ 90 | if source.pubinfo: 91 | self.add_fact(self.get_label(source.pubinfo)) 92 | 93 | def __add_source_abbrev(self, source): 94 | """ 95 | Add source abbreviation. 96 | """ 97 | if source.abbrev: 98 | self.add_fact(self.get_label(source.abbrev)) 99 | 100 | def _child_drop_handler(self, dnd_type, obj_or_handle, data): 101 | """ 102 | Handle drop processing for a person. 103 | """ 104 | if DdTargets.REPO_LINK.drag_type == dnd_type: 105 | action = action_handler("Source", self.grstate, self.primary) 106 | action.add_new_repository_reference(obj_or_handle) 107 | return True 108 | return self._primary_drop_handler(dnd_type, obj_or_handle, data) 109 | 110 | def add_custom_actions(self, context_menu): 111 | """ 112 | Add action menu items for the source. 113 | """ 114 | add_repositories_menu(self.grstate, context_menu, self.primary) 115 | -------------------------------------------------------------------------------- /src/view/cards/card_url.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | UrlCard 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from html import escape 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # GTK Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from gi.repository import Gtk 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # Gramps Modules 42 | # 43 | # ------------------------------------------------------------------------ 44 | from gramps.gen.const import GRAMPS_LOCALE as glocale 45 | from gramps.gui.display import display_url 46 | from gramps.gui.utils import match_primary_mask 47 | 48 | # ------------------------------------------------------------------------ 49 | # 50 | # Plugin Modules 51 | # 52 | # ------------------------------------------------------------------------ 53 | from ..common.common_const import BUTTON_PRIMARY 54 | from ..common.common_utils import button_released 55 | from .card_secondary import SecondaryCard 56 | 57 | _ = glocale.translation.sgettext 58 | 59 | 60 | # ------------------------------------------------------------------------ 61 | # 62 | # UrlCard Class 63 | # 64 | # ------------------------------------------------------------------------ 65 | class UrlCard(SecondaryCard): 66 | """ 67 | The UrlCard exposes some of the basic facts about an Url. 68 | """ 69 | 70 | def __init__( 71 | self, 72 | grstate, 73 | groptions, 74 | obj, 75 | url, 76 | ): 77 | SecondaryCard.__init__(self, grstate, groptions, obj, url) 78 | self.link = url.get_full_path() 79 | 80 | label = Gtk.Label( 81 | use_markup=True, label="%s" % escape(self.link) 82 | ) 83 | self.widgets["title"].pack_start(label, False, False, 0) 84 | 85 | if url.get_description(): 86 | self.add_fact(self.get_label(url.get_description())) 87 | 88 | if url.get_type(): 89 | self.add_fact(self.get_label(str(url.get_type()))) 90 | 91 | self.show_all() 92 | self.enable_drag() 93 | self.set_css_style() 94 | 95 | def cb_button_released(self, obj, event): 96 | """ 97 | Handle button release. 98 | """ 99 | if button_released(event, BUTTON_PRIMARY): 100 | if match_primary_mask(event.state): 101 | self._dump_context() 102 | return True 103 | display_url(self.link) 104 | return True 105 | return False 106 | -------------------------------------------------------------------------------- /src/view/common/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing common classes and utility functions. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/common/common_exceptions.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2000-2006 Donald N. Allingham 5 | # Copyright (C) 2021-2022 Christopher Horn 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 | Common exceptions. 23 | """ 24 | 25 | 26 | class FactoryException(Exception): 27 | """ 28 | Raised when a factory has an unhandled request. 29 | """ 30 | 31 | def __init__(self, value): 32 | Exception.__init__(self) 33 | self.value = value 34 | 35 | def __str__(self): 36 | return repr(self.value) 37 | -------------------------------------------------------------------------------- /src/view/common/common_strings.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Common strings for cards 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | 33 | _ = glocale.translation.sgettext 34 | 35 | 36 | REFERENCE = _("reference") 37 | EDIT_REFERENCE = "%s %s" % (_("Edit"), REFERENCE) 38 | DELETE_REFERENCE = "%s %s" % (_("Delete"), REFERENCE) 39 | NONE_PROVIDED = "[%s]" % _("None Provided") 40 | BACK_REFERENCE = "[%s]" % _("Back Reference") 41 | RECIPROCAL = "[%s]" % _("Reciprocal") 42 | MISSING = "[%s]" % _("Missing") 43 | LATITUDE_LONGITUDE = "%s, %s" % (_("Latitude"), _("Longitude")) 44 | MAKE_MEDIA_ACTIVE = "%s %s %s" % (_("Make"), _("media"), _("active")) 45 | UNKNOWN = "[%s]" % _("Unknown") 46 | UNTITLED = "[%s]" % _("Untitled") 47 | NONE = "[%s]" % _("None") 48 | UNAVAILABLE = "[%s]" % _("Unavailable") 49 | MISSING_ORIGIN = "[%s]" % _("Missing Origin") 50 | -------------------------------------------------------------------------------- /src/view/config/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing configuration classes, options, panels and utilities. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/config/config_builder.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | GrampsPageView factory and builder functions 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from .config_global import ( 31 | build_dashboard_grid, 32 | build_display_grid, 33 | build_general_grid, 34 | build_indicator_grid, 35 | build_media_bar_grid, 36 | build_status_grid, 37 | ) 38 | from .config_objects import ( 39 | build_address_grid, 40 | build_citation_grid, 41 | build_event_grid, 42 | build_family_grid, 43 | build_ldsord_grid, 44 | build_media_grid, 45 | build_name_grid, 46 | build_note_grid, 47 | build_person_grid, 48 | build_place_grid, 49 | build_repository_grid, 50 | build_source_grid, 51 | ) 52 | from .config_panel import build_global_panel 53 | from .config_timeline import ( 54 | build_family_timeline_grid, 55 | build_person_timeline_grid, 56 | build_place_timeline_grid, 57 | ) 58 | 59 | CONFIG_GRID_MAP = { 60 | "dashboard": build_dashboard_grid, 61 | "display": build_display_grid, 62 | "general": build_general_grid, 63 | "indicator": build_indicator_grid, 64 | "status": build_status_grid, 65 | "media-bar": build_media_bar_grid, 66 | "person": build_person_grid, 67 | "parent": build_person_grid, 68 | "sibling": build_person_grid, 69 | "spouse": build_person_grid, 70 | "child": build_person_grid, 71 | "association": build_person_grid, 72 | "family": build_family_grid, 73 | "place": build_place_grid, 74 | "ldsord": build_ldsord_grid, 75 | "citation": build_citation_grid, 76 | "source": build_source_grid, 77 | "repository": build_repository_grid, 78 | "media": build_media_grid, 79 | "note": build_note_grid, 80 | "name": build_name_grid, 81 | "address": build_address_grid, 82 | "event": build_event_grid, 83 | } 84 | 85 | 86 | def config_factory(space, context): 87 | """ 88 | A factory to return a configuration object. 89 | """ 90 | if "global" in space: 91 | func = build_global_panel 92 | elif "timeline" in space: 93 | if context == "person": 94 | func = build_person_timeline_grid 95 | elif context == "family": 96 | func = build_family_timeline_grid 97 | elif context == "place": 98 | func = build_place_timeline_grid 99 | else: 100 | func = CONFIG_GRID_MAP.get(context) 101 | return func 102 | -------------------------------------------------------------------------------- /src/view/config/config_profile.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2008 Raphael Ackermann 6 | # Copyright (C) 2009-2010 Gary Burton 7 | # Copyright (C) 2010 Benny Malengier 8 | # Copyright (C) 2012 Doug Blank 9 | # Copyright (C) 2015-2016 Nick Hall 10 | # Copyright (C) 2015 Serge Noiraud 11 | # Copyright (C) 2021-2022 Christopher Horn 12 | # 13 | # This program is free software; you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation; either version 2 of the License, or 16 | # (at your option) any later version. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with this program; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26 | # 27 | 28 | """ 29 | ProfileManager 30 | """ 31 | 32 | # ------------------------------------------------------------------------- 33 | # 34 | # Gramps Modules 35 | # 36 | # ------------------------------------------------------------------------- 37 | from gramps.gen.const import GRAMPS_LOCALE as glocale 38 | 39 | # ------------------------------------------------------------------------- 40 | # 41 | # Plugin Modules 42 | # 43 | # ------------------------------------------------------------------------- 44 | from ..services.service_templates import TemplatesService 45 | 46 | _ = glocale.translation.sgettext 47 | 48 | 49 | # ------------------------------------------------------------------------- 50 | # 51 | # ProfileManager Class 52 | # 53 | # ------------------------------------------------------------------------- 54 | class ProfileManager: 55 | """ 56 | Class to manage configuration profiles. 57 | """ 58 | 59 | def __init__(self, dbstate, config): 60 | self.templates_service = TemplatesService(dbstate) 61 | self.dbstate = dbstate 62 | self.config = config 63 | self.user_options = None 64 | self.db_options = None 65 | 66 | def _load_active_template(self): 67 | """ 68 | Load active template configuration options. 69 | """ 70 | profile_name = self.config.get("templates.active") 71 | ( 72 | active_name, 73 | self.user_options, 74 | ) = self.templates_service.get_rebased_user_options(profile_name) 75 | if active_name != profile_name: 76 | self.config.set("templates.active", active_name) 77 | self.config.save() 78 | if self.dbstate.is_open(): 79 | active_options = self.get_active_user_options() 80 | self.db_options = ( 81 | self.templates_service.get_rebased_database_options( 82 | active_options 83 | ) 84 | ) 85 | 86 | def get_active_user_options(self): 87 | """ 88 | Extract active user options. 89 | """ 90 | options = [] 91 | user_options = self.user_options 92 | for section in user_options.get_sections(): 93 | for setting in user_options.get_section_settings(section): 94 | key = ".".join((section, setting)) 95 | value = user_options.get(key) 96 | options.append((key, value)) 97 | return options 98 | 99 | def get_active_options(self): 100 | """ 101 | Return configuration manager object. 102 | """ 103 | self._load_active_template() 104 | if self.db_options: 105 | return self.db_options 106 | return self.user_options 107 | -------------------------------------------------------------------------------- /src/view/fields/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing support for user customizable fields. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/fields/field_builder.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | User customizable field factory and builder functions. 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..services.service_fields import FieldCalculatorService 31 | from .field_base import ( 32 | get_attribute_field, 33 | get_event_field, 34 | get_fact_field, 35 | get_relation_field, 36 | ) 37 | 38 | 39 | def field_factory(field_type, field_value): 40 | """ 41 | A factory to return a user customizable field renderer. 42 | """ 43 | if field_type == "Attribute": 44 | render = get_attribute_field 45 | elif field_type == "Event": 46 | render = get_event_field 47 | elif field_type == "Fact": 48 | render = get_fact_field 49 | elif field_type == "Relation": 50 | render = get_relation_field 51 | elif field_type == "Calculated": 52 | render = FieldCalculatorService().get_field 53 | else: 54 | render = [] 55 | return render 56 | 57 | 58 | def field_builder(grstate, obj, field_type, field_value, args): 59 | """ 60 | A builder to generate widgets to render user customizable fields. 61 | 62 | Required args: 63 | 64 | get_label Method to generate a styled label 65 | get_link Method to generate a styled link to an object 66 | event_cache Event objects to examine when field_type is 67 | "Event" or "Fact" 68 | """ 69 | if field_value != "None": 70 | field = field_factory(field_type, field_value) 71 | if field: 72 | return field(grstate, obj, field_value, args) 73 | return [] 74 | -------------------------------------------------------------------------------- /src/view/groups/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing the card groups for the page views. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/groups/group_addresses.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | AddressesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from ..cards import AddressCard 31 | from .group_list import CardGroupList 32 | 33 | 34 | # ------------------------------------------------------------------------ 35 | # 36 | # AddressesCardGroup Class 37 | # 38 | # ------------------------------------------------------------------------ 39 | class AddressesCardGroup(CardGroupList): 40 | """ 41 | The AddressesCardGroup class provides a container for managing 42 | all of the addresses a person or repository may have. 43 | """ 44 | 45 | def __init__(self, grstate, groptions, obj): 46 | CardGroupList.__init__( 47 | self, grstate, groptions, obj, enable_drop=False 48 | ) 49 | for address in obj.address_list: 50 | card = AddressCard( 51 | grstate, 52 | groptions, 53 | obj, 54 | address, 55 | ) 56 | self.add_card(card) 57 | self.show_all() 58 | -------------------------------------------------------------------------------- /src/view/groups/group_attributes.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | AttributesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from ..cards import AttributeCard 31 | from .group_list import CardGroupList 32 | 33 | 34 | # ------------------------------------------------------------------------ 35 | # 36 | # AttributesCardGroup Class 37 | # 38 | # ------------------------------------------------------------------------ 39 | class AttributesCardGroup(CardGroupList): 40 | """ 41 | The AttributesCardGroup class provides a container for managing 42 | all of the attributes an object may have. 43 | """ 44 | 45 | def __init__(self, grstate, groptions, obj): 46 | CardGroupList.__init__( 47 | self, grstate, groptions, obj, enable_drop=False 48 | ) 49 | for attribute in obj.attribute_list: 50 | card = AttributeCard(grstate, groptions, obj, attribute) 51 | self.add_card(card) 52 | self.show_all() 53 | -------------------------------------------------------------------------------- /src/view/groups/group_expander.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2001-2007 Donald N. Allingham 5 | # Copyright (C) 2009-2010 Gary Burton 6 | # Copyright (C) 2011 Tim G L Lyons 7 | # Copyright (C) 2015-2016 Nick Hall 8 | # Copyright (C) 2021-2022 Christopher Horn 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program; if not, write to the Free Software 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23 | # 24 | 25 | """ 26 | CardGroup helper classes 27 | """ 28 | 29 | # ------------------------------------------------------------------------ 30 | # 31 | # GTK Modules 32 | # 33 | # ------------------------------------------------------------------------ 34 | from gi.repository import Gtk 35 | 36 | # ------------------------------------------------------------------------ 37 | # 38 | # Gramps Modules 39 | # 40 | # ------------------------------------------------------------------------ 41 | from gramps.gen.const import GRAMPS_LOCALE as glocale 42 | from gramps.gui.utils import match_primary_mask 43 | 44 | # ------------------------------------------------------------------------ 45 | # 46 | # Plugin Modules 47 | # 48 | # ------------------------------------------------------------------------ 49 | from ..common.common_const import BUTTON_SECONDARY 50 | from ..common.common_utils import button_pressed 51 | 52 | _ = glocale.translation.sgettext 53 | 54 | 55 | # ------------------------------------------------------------------------ 56 | # 57 | # CardGroupExpander Class 58 | # 59 | # ------------------------------------------------------------------------ 60 | class CardGroupExpander(Gtk.Expander): 61 | """ 62 | A simple class for managing collapse of a CardGroup object. 63 | """ 64 | 65 | def __init__( 66 | self, grstate, hide_title=True, expanded=True, use_markup=True 67 | ): 68 | Gtk.Expander.__init__( 69 | self, expanded=expanded, use_markup=use_markup, hexpand=True 70 | ) 71 | self.set_resize_toplevel(False) 72 | self.connect("button-press-event", self.button_press) 73 | self.connect("activate", self.toggle_state) 74 | 75 | self.grstate = grstate 76 | self.hidden = False 77 | self.nested = None 78 | self.hidden_title = hide_title 79 | 80 | def button_press(self, _dummy_obj, event): 81 | """ 82 | Handle button press. 83 | """ 84 | if button_pressed(event, BUTTON_SECONDARY) and match_primary_mask( 85 | event.state 86 | ): 87 | self.hide() 88 | self.grstate.set_dirty_redraw_trigger() 89 | return True 90 | return False 91 | 92 | def toggle_state(self, _dummy_obj): 93 | """ 94 | Expand or collapse as needed. 95 | """ 96 | if self.hidden: 97 | self.set_hexpand(True) 98 | self.show_all() 99 | self.hidden = False 100 | elif self.get_expanded(): 101 | if self.hidden_title: 102 | parent = self.get_parent() 103 | gparent = parent.get_parent() 104 | ggparent = gparent.get_parent() 105 | if not hasattr(ggparent, "nested"): 106 | self.set_hexpand(False) 107 | for child in self.get_children(): 108 | child.hide() 109 | self.hidden = True 110 | return True 111 | -------------------------------------------------------------------------------- /src/view/groups/group_generic.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | GenericCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # GTK Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gi.repository import Gtk 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..common.common_classes import GrampsOptions 38 | from ..cards import ( 39 | CitationCard, 40 | EventCard, 41 | FamilyCard, 42 | MediaCard, 43 | NoteCard, 44 | PersonCard, 45 | PlaceCard, 46 | RepositoryCard, 47 | SourceCard, 48 | ) 49 | from .group_list import CardGroupList 50 | 51 | CARD_MAP = { 52 | "Person": PersonCard, 53 | "Family": FamilyCard, 54 | "Event": EventCard, 55 | "Place": PlaceCard, 56 | "Media": MediaCard, 57 | "Note": NoteCard, 58 | "Source": SourceCard, 59 | "Citation": CitationCard, 60 | "Repository": RepositoryCard, 61 | } 62 | 63 | 64 | # ------------------------------------------------------------------------ 65 | # 66 | # GenericCardGroup Class 67 | # 68 | # ------------------------------------------------------------------------ 69 | class GenericCardGroup(CardGroupList): 70 | """ 71 | The GenericCardGroup class provides a container for managing a 72 | set of generi..cards for a list of primary Gramps objects. 73 | """ 74 | 75 | def __init__(self, grstate, groptions, card_obj_type, card_obj_handles): 76 | CardGroupList.__init__( 77 | self, grstate, groptions, None, enable_drop=False 78 | ) 79 | self.obj_type = card_obj_type 80 | self.obj_handles = card_obj_handles 81 | 82 | if card_obj_type == "Tuples": 83 | tuple_list = card_obj_handles 84 | else: 85 | tuple_list = [(card_obj_type, x) for x in card_obj_handles] 86 | 87 | groups = { 88 | "ref": Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL), 89 | "age": Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL), 90 | "data": Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL), 91 | "attributes": Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL), 92 | "image": Gtk.SizeGroup(mode=Gtk.SizeGroupMode.HORIZONTAL), 93 | } 94 | 95 | for obj_type, obj_handle in tuple_list: 96 | if obj_type not in CARD_MAP: 97 | continue 98 | group_space = "group.%s" % obj_type.lower() 99 | group_groptions = GrampsOptions(group_space, size_groups=groups) 100 | group_groptions.set_age_base(groptions.age_base) 101 | obj = self.fetch(obj_type, obj_handle) 102 | card = CARD_MAP[obj_type](grstate, group_groptions, obj) 103 | self.add_card(card) 104 | self.show_all() 105 | -------------------------------------------------------------------------------- /src/view/groups/group_names.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | NamesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from ..cards import NameCard 31 | from .group_list import CardGroupList 32 | 33 | 34 | # ------------------------------------------------------------------------ 35 | # 36 | # NamesCardGroup Class 37 | # 38 | # ------------------------------------------------------------------------ 39 | class NamesCardGroup(CardGroupList): 40 | """ 41 | The NamesCardGroup class provides a container for managing 42 | all of the addresses a person or repository may have. 43 | """ 44 | 45 | def __init__(self, grstate, groptions, obj): 46 | CardGroupList.__init__( 47 | self, grstate, groptions, obj, enable_drop=False 48 | ) 49 | card = NameCard( 50 | grstate, 51 | groptions, 52 | obj, 53 | obj.primary_name, 54 | ) 55 | self.add_card(card) 56 | 57 | for name in obj.alternate_names: 58 | card = NameCard(grstate, groptions, obj, name) 59 | self.add_card(card) 60 | self.show_all() 61 | -------------------------------------------------------------------------------- /src/view/groups/group_notes.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | NotesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..common.common_utils import get_object_type 38 | from ..cards import NoteCard 39 | from .group_list import CardGroupList 40 | 41 | _ = glocale.translation.sgettext 42 | 43 | 44 | # ------------------------------------------------------------------------ 45 | # 46 | # NotesCardGroup Class 47 | # 48 | # ------------------------------------------------------------------------ 49 | class NotesCardGroup(CardGroupList): 50 | """ 51 | The NotesCardGroup class provides a container for managing all 52 | of the notes associated with an object. 53 | """ 54 | 55 | def __init__(self, grstate, groptions, obj): 56 | CardGroupList.__init__( 57 | self, grstate, groptions, obj, enable_drop=False 58 | ) 59 | if not self.group_base.has_notes: 60 | return 61 | if self.group_base.is_primary: 62 | groptions.set_backlink( 63 | (self.group_base.obj_type, self.group_base.obj.handle) 64 | ) 65 | maximum = grstate.config.get("group.note.max-per-group") 66 | notes = [(self.group_base.obj_lang, x) for x in obj.note_list] 67 | if grstate.config.get("group.note.include-child-objects"): 68 | notes = self.get_child_object_notes(notes) 69 | 70 | notes = notes[:maximum] 71 | for (obj_lang, handle) in notes: 72 | note = self.fetch("Note", handle) 73 | card = NoteCard(grstate, groptions, note, reference=obj_lang) 74 | card.set_size_request(220, -1) 75 | self.add_card(card) 76 | self.show_all() 77 | 78 | def get_child_object_notes(self, notes): 79 | """ 80 | Get notes from child objects. 81 | """ 82 | if self.group_base.has_notes: 83 | for obj in self.group_base.obj.get_note_child_list(): 84 | obj_lang = get_object_type(obj, lang=True) 85 | for handle in obj.note_list: 86 | if handle not in notes: 87 | notes.append((obj_lang, handle)) 88 | return notes 89 | 90 | def save_new_object(self, handle, insert_row): 91 | """ 92 | Add new note to the list. 93 | """ 94 | note = self.fetch("Note", handle) 95 | message = " ".join( 96 | ( 97 | _("Added"), 98 | _("Note"), 99 | note.gramps_id, 100 | _("to"), 101 | self.group_base.obj_lang, 102 | self.group_base.obj.gramps_id, 103 | ) 104 | ) 105 | self.group_base.obj.add_note(handle) 106 | self.group_base.commit(self.grstate, message) 107 | -------------------------------------------------------------------------------- /src/view/groups/group_ordinances.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | LDSOrdinancesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from ..cards import LDSOrdinanceCard 31 | from .group_list import CardGroupList 32 | 33 | 34 | # ------------------------------------------------------------------------ 35 | # 36 | # LDSOrdinancesCardGroup Class 37 | # 38 | # ------------------------------------------------------------------------ 39 | class LDSOrdinancesCardGroup(CardGroupList): 40 | """ 41 | The LDSOrdinancesCardGroup class provides a container for managing 42 | all of the ordinances a person or family may have. 43 | """ 44 | 45 | def __init__(self, grstate, groptions, obj): 46 | CardGroupList.__init__( 47 | self, grstate, groptions, obj, enable_drop=False 48 | ) 49 | for ordinance in obj.lds_ord_list: 50 | card = LDSOrdinanceCard(grstate, groptions, obj, ordinance) 51 | self.add_card(card) 52 | self.show_all() 53 | -------------------------------------------------------------------------------- /src/view/groups/group_repositories.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | RepositoriesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..cards import RepositoryRefCard 38 | from .group_list import CardGroupList 39 | 40 | _ = glocale.translation.sgettext 41 | 42 | 43 | # ------------------------------------------------------------------------ 44 | # 45 | # RepositoriesCardGroup Class 46 | # 47 | # ------------------------------------------------------------------------ 48 | class RepositoriesCardGroup(CardGroupList): 49 | """ 50 | The RepositoriesCardGroup class provides a container for managing 51 | all of the repositories that may contain a Source. 52 | """ 53 | 54 | def __init__(self, grstate, groptions, obj): 55 | CardGroupList.__init__( 56 | self, grstate, groptions, obj, enable_drop=False 57 | ) 58 | groptions.set_ref_mode( 59 | self.grstate.config.get("group.repository.reference-mode") 60 | ) 61 | for repo_ref in obj.reporef_list: 62 | profile = RepositoryRefCard(grstate, groptions, obj, repo_ref) 63 | self.add_card(profile) 64 | self.show_all() 65 | -------------------------------------------------------------------------------- /src/view/groups/group_research.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | ResearchNotesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gen.lib import NoteType 32 | 33 | # ------------------------------------------------------------------------ 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------ 38 | from ..common.common_utils import get_object_type 39 | from ..cards import NoteCard 40 | from .group_list import CardGroupList 41 | 42 | _ = glocale.translation.sgettext 43 | 44 | 45 | # ------------------------------------------------------------------------ 46 | # 47 | # ResearchNotesCardGroup Class 48 | # 49 | # ------------------------------------------------------------------------ 50 | class ResearchNotesCardGroup(CardGroupList): 51 | """ 52 | The ResearchNotesCardGroup class provides a container for managing all 53 | of the todo notes associated with an object. 54 | """ 55 | 56 | def __init__(self, grstate, groptions, obj): 57 | CardGroupList.__init__( 58 | self, grstate, groptions, obj, enable_drop=False 59 | ) 60 | if not self.group_base.has_notes: 61 | return 62 | if self.group_base.is_primary: 63 | groptions.set_backlink( 64 | (self.group_base.obj_type, self.group_base.obj.handle) 65 | ) 66 | maximum = grstate.config.get("group.note.max-per-group") 67 | notes = [(self.group_base.obj_lang, x) for x in obj.note_list] 68 | notes = self.get_child_object_notes(notes) 69 | 70 | notes = notes[:maximum] 71 | for (obj_lang, handle) in notes: 72 | note = self.fetch("Note", handle) 73 | if note.get_type() == NoteType.RESEARCH: 74 | card = NoteCard(grstate, groptions, note, reference=obj_lang) 75 | card.set_size_request(220, -1) 76 | self.add_card(card) 77 | self.show_all() 78 | 79 | def get_child_object_notes(self, notes): 80 | """ 81 | Get notes from child objects. 82 | """ 83 | if self.group_base.has_notes: 84 | for obj in self.group_base.obj.get_note_child_list(): 85 | obj_lang = get_object_type(obj, lang=True) 86 | for handle in obj.note_list: 87 | if handle not in notes: 88 | notes.append((obj_lang, handle)) 89 | return notes 90 | -------------------------------------------------------------------------------- /src/view/groups/group_sources.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | SourcesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..cards import SourceCard 38 | from .group_list import CardGroupList 39 | 40 | _ = glocale.translation.sgettext 41 | 42 | 43 | # ------------------------------------------------------------------------ 44 | # 45 | # SourcesCardGroup Class 46 | # 47 | # ------------------------------------------------------------------------ 48 | class SourcesCardGroup(CardGroupList): 49 | """ 50 | The SourcesCardGroup class provides a container for viewing and 51 | managing all of the sources associated with a primary Gramps object. 52 | """ 53 | 54 | def __init__(self, grstate, groptions, obj): 55 | CardGroupList.__init__( 56 | self, grstate, groptions, obj, enable_drop=False 57 | ) 58 | sources_list = [] 59 | if self.group_base.obj_type == "Repository": 60 | for ( 61 | obj_type, 62 | obj_handle, 63 | ) in grstate.dbstate.db.find_backlink_handles( 64 | self.group_base.obj.handle 65 | ): 66 | if obj_type == "Source": 67 | source = self.fetch("Source", obj_handle) 68 | sources_list.append(source) 69 | 70 | maximum = grstate.config.get("group.source.max-per-group") 71 | sources_list = sources_list[:maximum] 72 | 73 | if sources_list: 74 | for source in sources_list: 75 | card = SourceCard( 76 | grstate, 77 | groptions, 78 | source, 79 | ) 80 | self.add_card(card) 81 | self.show_all() 82 | -------------------------------------------------------------------------------- /src/view/groups/group_todo.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | TodoNotesCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | from gramps.gen.lib import NoteType 32 | 33 | # ------------------------------------------------------------------------ 34 | # 35 | # Plugin Modules 36 | # 37 | # ------------------------------------------------------------------------ 38 | from ..common.common_utils import get_object_type 39 | from ..cards import NoteCard 40 | from .group_list import CardGroupList 41 | 42 | _ = glocale.translation.sgettext 43 | 44 | 45 | # ------------------------------------------------------------------------ 46 | # 47 | # TodoNotesCardGroup Class 48 | # 49 | # ------------------------------------------------------------------------ 50 | class TodoNotesCardGroup(CardGroupList): 51 | """ 52 | The TodoNotesCardGroup class provides a container for managing all 53 | of the todo notes associated with an object. 54 | """ 55 | 56 | def __init__(self, grstate, groptions, obj): 57 | CardGroupList.__init__( 58 | self, grstate, groptions, obj, enable_drop=False 59 | ) 60 | if not self.group_base.has_notes: 61 | return 62 | if self.group_base.is_primary: 63 | groptions.set_backlink( 64 | (self.group_base.obj_type, self.group_base.obj.handle) 65 | ) 66 | maximum = grstate.config.get("group.note.max-per-group") 67 | notes = [(self.group_base.obj_lang, x) for x in obj.note_list] 68 | notes = self.get_child_object_notes(notes) 69 | 70 | notes = notes[:maximum] 71 | for (obj_lang, handle) in notes: 72 | note = self.fetch("Note", handle) 73 | if note.get_type() == NoteType.TODO: 74 | card = NoteCard(grstate, groptions, note, reference=obj_lang) 75 | card.set_size_request(220, -1) 76 | self.add_card(card) 77 | self.show_all() 78 | 79 | def get_child_object_notes(self, notes): 80 | """ 81 | Get notes from child objects. 82 | """ 83 | if self.group_base.has_notes: 84 | for obj in self.group_base.obj.get_note_child_list(): 85 | obj_lang = get_object_type(obj, lang=True) 86 | for handle in obj.note_list: 87 | if handle not in notes: 88 | notes.append((obj_lang, handle)) 89 | return notes 90 | -------------------------------------------------------------------------------- /src/view/groups/group_uncited.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | UncitedEventsCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Gramps Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gramps.gen.const import GRAMPS_LOCALE as glocale 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..cards import EventRefCard 38 | from .group_list import CardGroupList 39 | 40 | _ = glocale.translation.sgettext 41 | 42 | 43 | # ------------------------------------------------------------------------ 44 | # 45 | # UncitedEventsCardGroup Class 46 | # 47 | # ------------------------------------------------------------------------ 48 | class UncitedEventsCardGroup(CardGroupList): 49 | """ 50 | The UncitedEventsCardGroup class provides a container for displaying 51 | events associated with an object that have no citations. 52 | """ 53 | 54 | def __init__(self, grstate, groptions, obj): 55 | CardGroupList.__init__(self, grstate, groptions, obj) 56 | 57 | groptions.set_ref_mode( 58 | self.grstate.config.get("group.event.reference-mode") 59 | ) 60 | groptions.set_relation(obj) 61 | 62 | self.check_events(groptions, obj) 63 | if self.group_base.obj_type == "Person": 64 | for family_handle in obj.family_list: 65 | self.check_family(groptions, family_handle) 66 | self.show_all() 67 | 68 | def check_events(self, options, obj): 69 | """ 70 | Check for uncited events and add to group if found. 71 | """ 72 | db = self.grstate.dbstate.db 73 | for event_ref in obj.event_ref_list: 74 | event = db.get_event_from_handle(event_ref.ref) 75 | if not event.citation_list: 76 | card = EventRefCard( 77 | self.grstate, 78 | options, 79 | obj, 80 | event_ref, 81 | ) 82 | self.add_card(card) 83 | 84 | def check_family(self, options, family_handle): 85 | """ 86 | Check family events with spouse. 87 | """ 88 | family = self.grstate.dbstate.db.get_family_from_handle(family_handle) 89 | self.check_events(options, family) 90 | -------------------------------------------------------------------------------- /src/view/groups/group_urls.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | UrlsCardGroup 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | import re 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Plugin Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from ..cards import NoteUrlCard, UrlCard 38 | from .group_list import CardGroupList 39 | 40 | 41 | # ------------------------------------------------------------------------ 42 | # 43 | # UrlsCardGroup Class 44 | # 45 | # ------------------------------------------------------------------------ 46 | class UrlsCardGroup(CardGroupList): 47 | """ 48 | The UrlsCardGroup class provides a container for launching all 49 | of the urls associated with an object. It gathers them from the url 50 | list but also extracts what it can from the notes as well. 51 | """ 52 | 53 | def __init__(self, grstate, groptions, obj): 54 | CardGroupList.__init__( 55 | self, grstate, groptions, obj, enable_drop=False 56 | ) 57 | self.parse_urls() 58 | if self.grstate.config.get("general.include-note-urls"): 59 | self.parse_notes() 60 | self.show_all() 61 | 62 | def parse_urls(self): 63 | """ 64 | Parse all urls associated with object. 65 | """ 66 | if self.group_base.has_urls: 67 | for url in self.group_base.obj.urls: 68 | card = UrlCard( 69 | self.grstate, self.groptions, self.group_base.obj, url 70 | ) 71 | self.add_card(card) 72 | 73 | def parse_notes(self): 74 | """ 75 | Parse all notes associated with object. 76 | """ 77 | if self.group_base.has_notes: 78 | for handle in self.group_base.obj.note_list: 79 | self.parse_note(handle) 80 | 81 | for obj in self.group_base.obj.get_note_child_list(): 82 | for handle in obj.note_list: 83 | self.parse_note(handle) 84 | 85 | def parse_note(self, handle): 86 | """ 87 | Parse a specific note extracting urls. 88 | """ 89 | note = self.fetch("Note", handle) 90 | links = re.findall(r"(?Phttps?://[^\s]+)", note.get()) 91 | if links: 92 | for link in links: 93 | self.add_note_url(note, link) 94 | 95 | def add_note_url(self, note, link): 96 | """ 97 | Add a note url. 98 | """ 99 | text = link 100 | if text[-1:] == ".": 101 | text = text[:-1] 102 | card = NoteUrlCard(self.grstate, self.groptions, note, text) 103 | self.add_card(card) 104 | -------------------------------------------------------------------------------- /src/view/menus/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing context and configuration menu support. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/menus/menu_bookmarks.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Bookmarks menu 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from functools import partial 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # GTK Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from gi.repository import Gtk 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # Gramps Modules 42 | # 43 | # ------------------------------------------------------------------------ 44 | from gramps.gen.const import GRAMPS_LOCALE as glocale 45 | from gramps.gui.views.bookmarks import ( 46 | PersonBookmarks, 47 | FamilyBookmarks, 48 | EventBookmarks, 49 | PlaceBookmarks, 50 | CitationBookmarks, 51 | SourceBookmarks, 52 | RepoBookmarks, 53 | MediaBookmarks, 54 | NoteBookmarks, 55 | ) 56 | 57 | # ------------------------------------------------------------------------ 58 | # 59 | # Plugin Modules 60 | # 61 | # ------------------------------------------------------------------------ 62 | from .menu_utils import ( 63 | menu_item, 64 | new_menu, 65 | show_menu, 66 | add_double_separator, 67 | submenu_item, 68 | ) 69 | 70 | _ = glocale.translation.sgettext 71 | 72 | BOOKMARK_TYPES = [ 73 | ("Person", _("People"), PersonBookmarks, "gramps-person"), 74 | ("Family", _("Families"), FamilyBookmarks, "gramps-family"), 75 | ("Event", _("Events"), EventBookmarks, "gramps-event"), 76 | ("Place", _("Places"), PlaceBookmarks, "gramps-place"), 77 | ("Media", _("Media"), MediaBookmarks, "gramps-media"), 78 | ("Note", _("Notes"), NoteBookmarks, "gramps-note"), 79 | ("Citations", _("Citations"), CitationBookmarks, "gramps-citation"), 80 | ("Source", _("Source"), SourceBookmarks, "gramps-source"), 81 | ("Repository", _("Repository"), RepoBookmarks, "gramps-repository"), 82 | ] 83 | 84 | 85 | def build_bookmark_menu(grstate, parent_menu, bookmark_type): 86 | """ 87 | Build bookmark submenu for specific bookmark type. 88 | """ 89 | (obj_type, obj_type_lang, bookmark_class, icon) = bookmark_type 90 | bookmark_handler = bookmark_class(grstate.dbstate, grstate.uistate, None) 91 | bookmark_handles = bookmark_handler.get_bookmarks().get() 92 | if bookmark_handles: 93 | menu = new_menu( 94 | "list-add", 95 | _("Organize Bookmarks"), 96 | edit_bookmarks, 97 | bookmark_handler, 98 | ) 99 | add_double_separator(menu) 100 | for obj_handle in bookmark_handles: 101 | title, dummy_obj = bookmark_handler.make_label(obj_handle) 102 | goto_object = partial(goto_bookmark, grstate, obj_type, obj_handle) 103 | menu.add(menu_item("go-next", title, goto_object)) 104 | parent_menu.append(submenu_item(icon, obj_type_lang, menu)) 105 | 106 | 107 | def edit_bookmarks(_dummy_arg, bookmarks): 108 | """ 109 | Organize bookmarks. 110 | """ 111 | bookmarks.edit() 112 | return True 113 | 114 | 115 | def goto_bookmark(grstate, obj_type, obj_handle, *_dummy_args): 116 | """ 117 | Go to desired bookmark. 118 | """ 119 | grstate.load_primary_page(obj_type, obj_handle) 120 | return True 121 | 122 | 123 | def build_bookmarks_menu(widget, grstate, event): 124 | """ 125 | Build the bookmarks menu. 126 | """ 127 | menu = Gtk.Menu() 128 | for bookmark_type in BOOKMARK_TYPES: 129 | build_bookmark_menu(grstate, menu, bookmark_type) 130 | add_double_separator(menu) 131 | label = Gtk.MenuItem(label=_("Bookmarks")) 132 | label.set_sensitive(False) 133 | menu.append(label) 134 | return show_menu(menu, widget, event) 135 | -------------------------------------------------------------------------------- /src/view/menus/menu_templates.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Templates menu 23 | """ 24 | 25 | # ------------------------------------------------------------------------ 26 | # 27 | # GTK Modules 28 | # 29 | # ------------------------------------------------------------------------ 30 | from gi.repository import Gtk 31 | 32 | # ------------------------------------------------------------------------ 33 | # 34 | # Gramps Modules 35 | # 36 | # ------------------------------------------------------------------------ 37 | from gramps.gen.const import GRAMPS_LOCALE as glocale 38 | 39 | # ------------------------------------------------------------------------ 40 | # 41 | # Plugin Modules 42 | # 43 | # ------------------------------------------------------------------------ 44 | from .menu_utils import add_double_separator, menu_item, show_menu 45 | from ..services.service_templates import TemplatesService 46 | 47 | _ = glocale.translation.sgettext 48 | 49 | 50 | def build_templates_menu(widget, grstate, event): 51 | """ 52 | Build the templates menu. 53 | """ 54 | menu = Gtk.Menu() 55 | templates_service = TemplatesService(grstate.dbstate) 56 | user_templates = templates_service.get_templates() 57 | for template in user_templates: 58 | menu.append( 59 | menu_item( 60 | "preferences-system", 61 | template["lang_string"], 62 | switch_active_template, 63 | grstate, 64 | template["xml_string"], 65 | ) 66 | ) 67 | add_double_separator(menu) 68 | label = Gtk.MenuItem(label=_("Templates")) 69 | label.set_sensitive(False) 70 | menu.append(label) 71 | return show_menu(menu, widget, event) 72 | 73 | 74 | def switch_active_template(_dummy_obj, grstate, new_template): 75 | """ 76 | Change the active template. 77 | """ 78 | grstate.templates.set("templates.active", new_template) 79 | grstate.templates.save() 80 | grstate.reload_config(refresh_only=False, defer_refresh=False) 81 | -------------------------------------------------------------------------------- /src/view/services/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing various service objects. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/services/service_images.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | ImagesService 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Python Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from functools import lru_cache 31 | 32 | # ------------------------------------------------------------------------- 33 | # 34 | # Gramps Modules 35 | # 36 | # ------------------------------------------------------------------------- 37 | from gramps.gen.utils.thumbnails import get_thumbnail_image 38 | 39 | 40 | # ------------------------------------------------------------------------- 41 | # 42 | # ImagesService 43 | # 44 | # ------------------------------------------------------------------------- 45 | class ImagesService: 46 | """ 47 | A singleton class that wraps image lookups with a LRU cache. 48 | """ 49 | 50 | def __new__(cls): 51 | """ 52 | Return the singleton class. 53 | """ 54 | if not hasattr(cls, "instance"): 55 | cls.instance = super(ImagesService, cls).__new__(cls) 56 | return cls.instance 57 | 58 | @lru_cache(maxsize=64) 59 | def get_thumbnail_image(self, path, rectangle, size): 60 | """ 61 | Fetch a thumbnail. 62 | """ 63 | return get_thumbnail_image(path, rectangle=rectangle, size=size) 64 | 65 | def get_cache_info(self): 66 | """ 67 | Return cache info. 68 | """ 69 | return self.get_thumbnail_image.cache_info() 70 | 71 | 72 | images_service = ImagesService() 73 | -------------------------------------------------------------------------------- /src/view/views/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing the object views. 23 | """ 24 | -------------------------------------------------------------------------------- /src/view/views/view_attribute.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | AttributeObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from .view_base import GrampsObjectView 32 | from .view_const import CARD_MAP 33 | 34 | 35 | # ------------------------------------------------------------------------- 36 | # 37 | # AttributeObjectView Class 38 | # 39 | # ------------------------------------------------------------------------- 40 | class AttributeObjectView(GrampsObjectView): 41 | """ 42 | Provides the attribute object view. 43 | """ 44 | 45 | def build_view(self): 46 | """ 47 | Build the view header and body and set the focus. 48 | """ 49 | base = self.grcontext.primary_obj 50 | attribute = self.grcontext.secondary_obj 51 | if self.grcontext.reference_obj: 52 | base = self.grcontext.reference_obj 53 | 54 | build_card = CARD_MAP[base.obj_type] 55 | option_space = "active.%s" % base.obj_type.lower() 56 | groptions = GrampsOptions(option_space) 57 | self.view_object = build_card(self.grstate, groptions, base.obj) 58 | 59 | groptions = GrampsOptions("active.attribute") 60 | self.view_focus = self.wrap_focal_widget( 61 | CARD_MAP["Attribute"]( 62 | self.grstate, groptions, base.obj, attribute.obj 63 | ) 64 | ) 65 | 66 | self.view_header.pack_start(self.view_object, False, False, 0) 67 | self.view_header.pack_start(self.view_focus, False, False, 0) 68 | 69 | self.view_body = self.build_object_groups(attribute) 70 | -------------------------------------------------------------------------------- /src/view/views/view_builder.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | GrampsObjectView factory and builder functions 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_exceptions import FactoryException 31 | from .view_attribute import AttributeObjectView 32 | from .view_citation import CitationObjectView 33 | from .view_event import EventObjectView 34 | from .view_family import FamilyObjectView 35 | from .view_generic import GenericObjectView 36 | from .view_media import MediaObjectView 37 | from .view_person import PersonObjectView 38 | from .view_source import SourceObjectView 39 | from .view_statistics import StatisticsObjectView 40 | from .view_tag import TagObjectView 41 | 42 | 43 | def view_factory(grcontext, hint=None): 44 | """ 45 | A factory to return an object viewer based on navigation context. 46 | """ 47 | page_type = grcontext.page_type 48 | 49 | if page_type in [ 50 | "Address", 51 | "Name", 52 | "Note", 53 | "LdsOrd", 54 | "Place", 55 | "Repository", 56 | "ChildRef", 57 | "EventRef", 58 | "MediaRef", 59 | "PersonRef", 60 | "RepoRef", 61 | ]: 62 | cls = GenericObjectView 63 | elif page_type == "Attribute": 64 | cls = AttributeObjectView 65 | elif page_type == "Citation": 66 | cls = CitationObjectView 67 | elif page_type == "Event": 68 | cls = EventObjectView 69 | elif page_type == "Family": 70 | cls = FamilyObjectView 71 | elif page_type == "Media": 72 | cls = MediaObjectView 73 | elif page_type == "Person": 74 | cls = PersonObjectView 75 | elif page_type == "Source": 76 | cls = SourceObjectView 77 | elif page_type == "Tag": 78 | cls = TagObjectView 79 | elif hint == "Statistics": 80 | cls = StatisticsObjectView 81 | else: 82 | raise FactoryException( 83 | "Attempt to create unknown ObjectView class: " 84 | "classname = %s | %s" % (str(page_type), str(hint)) 85 | ) 86 | return cls 87 | 88 | 89 | def view_builder(grstate, grcontext, hint=None): 90 | """ 91 | A builder to instantiate the view based on navigation context. 92 | """ 93 | view = view_factory(grcontext, hint=hint) 94 | return view(grstate, grcontext) 95 | -------------------------------------------------------------------------------- /src/view/views/view_citation.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | CitationObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from .view_base import GrampsObjectView 32 | from .view_const import CARD_MAP 33 | 34 | 35 | # ------------------------------------------------------------------------- 36 | # 37 | # CitationObjectView Class 38 | # 39 | # ------------------------------------------------------------------------- 40 | class CitationObjectView(GrampsObjectView): 41 | """ 42 | Provides the citation object view. 43 | """ 44 | 45 | def build_view(self): 46 | """ 47 | Build the view header and body and set the focus. 48 | """ 49 | citation = self.grcontext.primary_obj 50 | 51 | age_base = None 52 | if citation.obj.get_date_object(): 53 | age_base = citation.obj.get_date_object() 54 | 55 | if citation.obj.source_handle: 56 | source = self.grstate.dbstate.db.get_source_from_handle( 57 | citation.obj.source_handle 58 | ) 59 | groptions = GrampsOptions("active.source") 60 | source_card = CARD_MAP["Source"](self.grstate, groptions, source) 61 | self.view_header.pack_start(source_card, False, False, 0) 62 | 63 | groptions = GrampsOptions("active.citation") 64 | self.view_object = CARD_MAP["Citation"]( 65 | self.grstate, groptions, citation.obj 66 | ) 67 | self.view_focus = self.wrap_focal_widget(self.view_object) 68 | self.view_header.pack_start(self.view_focus, False, False, 0) 69 | 70 | self.view_body = self.build_object_groups(citation, age_base=age_base) 71 | -------------------------------------------------------------------------------- /src/view/views/view_const.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | GrampObjectView related constants 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..cards import ( 31 | AddressCard, 32 | AttributeCard, 33 | ChildRefCard, 34 | CitationCard, 35 | EventCard, 36 | EventRefCard, 37 | FamilyCard, 38 | LDSOrdinanceCard, 39 | MediaCard, 40 | MediaRefCard, 41 | NameCard, 42 | NoteCard, 43 | PersonCard, 44 | PersonRefCard, 45 | PlaceCard, 46 | RepositoryCard, 47 | RepositoryRefCard, 48 | SourceCard, 49 | TagCard, 50 | ) 51 | 52 | CARD_MAP = { 53 | "Address": AddressCard, 54 | "Attribute": AttributeCard, 55 | "ChildRef": ChildRefCard, 56 | "Citation": CitationCard, 57 | "Event": EventCard, 58 | "EventRef": EventRefCard, 59 | "Family": FamilyCard, 60 | "LdsOrd": LDSOrdinanceCard, 61 | "Media": MediaCard, 62 | "MediaRef": MediaRefCard, 63 | "Name": NameCard, 64 | "Note": NoteCard, 65 | "Person": PersonCard, 66 | "PersonRef": PersonRefCard, 67 | "Place": PlaceCard, 68 | "Repository": RepositoryCard, 69 | "RepoRef": RepositoryRefCard, 70 | "Source": SourceCard, 71 | "Tag": TagCard, 72 | } 73 | -------------------------------------------------------------------------------- /src/view/views/view_generic.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | GenericObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from .view_base import GrampsObjectView 32 | from .view_const import CARD_MAP 33 | 34 | 35 | # ------------------------------------------------------------------------- 36 | # 37 | # GenericObjectView Class 38 | # 39 | # ------------------------------------------------------------------------- 40 | class GenericObjectView(GrampsObjectView): 41 | """ 42 | Provides an object view that handles most basic objects. 43 | """ 44 | 45 | def build_view(self): 46 | """ 47 | Build the view header and body and set the focus. 48 | """ 49 | primary = self.grcontext.primary_obj 50 | reference = self.grcontext.reference_obj 51 | secondary = self.grcontext.secondary_obj 52 | 53 | build_card = CARD_MAP[primary.obj_type] 54 | option_space = "active.%s" % primary.obj_type.lower() 55 | groptions = GrampsOptions(option_space) 56 | primary_card = build_card(self.grstate, groptions, primary.obj) 57 | 58 | groups = primary 59 | if reference: 60 | groups = reference 61 | reference_card = self.build_secondary_card(primary, reference) 62 | self.view_object = reference_card 63 | self.view_focus = self.wrap_focal_widget(self.view_object) 64 | self.view_header.pack_start(primary_card, False, False, 0) 65 | self.view_header.pack_start(self.view_focus, False, False, 0) 66 | elif secondary: 67 | groups = secondary 68 | self.view_object = self.build_secondary_card(primary, secondary) 69 | self.view_focus = self.wrap_focal_widget(self.view_object) 70 | self.view_header.pack_start(primary_card, False, False, 0) 71 | self.view_header.pack_start(self.view_focus, False, False, 0) 72 | else: 73 | self.view_object = primary_card 74 | self.view_focus = self.wrap_focal_widget(self.view_object) 75 | self.view_header.pack_start(self.view_focus, False, False, 0) 76 | 77 | self.view_body = self.build_object_groups(groups) 78 | 79 | def build_secondary_card(self, primary, secondary): 80 | """ 81 | Build card for secondary objects. 82 | """ 83 | build_card = CARD_MAP[secondary.obj_type] 84 | option_space = "active.%s" % secondary.obj_type.lower() 85 | groptions = GrampsOptions(option_space) 86 | if "Ref" in secondary.obj_type: 87 | groptions.set_ref_mode(2) 88 | return build_card( 89 | self.grstate, 90 | groptions, 91 | primary.obj, 92 | secondary.obj, 93 | ) 94 | -------------------------------------------------------------------------------- /src/view/views/view_media.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | MediaObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from .view_base import GrampsObjectView 32 | from .view_const import CARD_MAP 33 | 34 | 35 | # ------------------------------------------------------------------------- 36 | # 37 | # MediaObjectView Class 38 | # 39 | # ------------------------------------------------------------------------- 40 | class MediaObjectView(GrampsObjectView): 41 | """ 42 | Provides the media object view. 43 | """ 44 | 45 | def __init__(self, grstate, grcontext): 46 | GrampsObjectView.__init__(self, grstate, grcontext) 47 | self.colors = None 48 | 49 | def build_view(self): 50 | """ 51 | Build the view header and body and set the focus. 52 | """ 53 | media = self.grcontext.primary_obj 54 | 55 | age_base = None 56 | if media.obj.get_date_object(): 57 | age_base = media.obj.get_date_object() 58 | 59 | groptions = GrampsOptions("active.media") 60 | self.view_object = CARD_MAP["Media"]( 61 | self.grstate, groptions, media.obj 62 | ) 63 | self.view_focus = self.wrap_focal_widget(self.view_object) 64 | self.view_header.pack_start(self.view_focus, False, False, 0) 65 | 66 | self.view_body = self.build_object_groups(media, age_base=age_base) 67 | -------------------------------------------------------------------------------- /src/view/views/view_person.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | PersonObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from .view_base import GrampsObjectView 32 | from .view_const import CARD_MAP 33 | 34 | 35 | # ------------------------------------------------------------------------- 36 | # 37 | # PersonObjectView Class 38 | # 39 | # ------------------------------------------------------------------------- 40 | class PersonObjectView(GrampsObjectView): 41 | """ 42 | Provides the person object view. 43 | """ 44 | 45 | def __init__(self, grstate, grcontext): 46 | GrampsObjectView.__init__(self, grstate, grcontext) 47 | self.colors = None 48 | 49 | def build_view(self): 50 | """ 51 | Build the view header and body and set the focus. 52 | """ 53 | person = self.grcontext.primary_obj.obj 54 | 55 | age_base = None 56 | birth_ref = person.get_birth_ref() 57 | if birth_ref is not None: 58 | event = self.grstate.dbstate.db.get_event_from_handle( 59 | birth_ref.ref 60 | ) 61 | if event: 62 | age_base = event.get_date_object() 63 | 64 | groptions = GrampsOptions("active.person") 65 | self.view_object = CARD_MAP["Person"](self.grstate, groptions, person) 66 | self.view_focus = self.wrap_focal_widget(self.view_object) 67 | 68 | if self.grstate.config.get("active.person.show-parents"): 69 | self._add_primary_parents(person) 70 | self.view_header.pack_start(self.view_focus, False, False, 0) 71 | 72 | self.view_body = self.build_object_groups( 73 | self.grcontext.primary_obj, age_base=age_base 74 | ) 75 | 76 | def _add_primary_parents(self, person): 77 | """ 78 | Add widget with primary parents of a person. 79 | """ 80 | primary_handle = person.get_main_parents_family_handle() 81 | if primary_handle: 82 | family = self.grstate.dbstate.db.get_family_from_handle( 83 | primary_handle 84 | ) 85 | groptions = GrampsOptions("active.parent") 86 | groptions.set_relation(person) 87 | groptions.set_vertical(False) 88 | if self.grstate.config.get("active.person.compact-mode-parents"): 89 | groptions.partners_only = True 90 | 91 | self.view_header.pack_start( 92 | CARD_MAP["Family"]( 93 | self.grstate, 94 | groptions, 95 | family, 96 | ), 97 | False, 98 | False, 99 | 0, 100 | ) 101 | -------------------------------------------------------------------------------- /src/view/views/view_statistics.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | StatisticsObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..cards import FamilyTreeCard 31 | from ..common.common_classes import GrampsOptions 32 | from ..groups.group_builder import group_builder 33 | from .view_base import GrampsObjectView 34 | 35 | 36 | # ------------------------------------------------------------------------- 37 | # 38 | # StatisticsView Class 39 | # 40 | # ------------------------------------------------------------------------- 41 | class StatisticsObjectView(GrampsObjectView): 42 | """ 43 | Provides the statistics view. 44 | """ 45 | 46 | def build_view(self): 47 | """ 48 | Build the view header and body and set the focus. 49 | """ 50 | groptions = GrampsOptions("active.tree") 51 | self.view_object = FamilyTreeCard(self.grstate, groptions) 52 | self.view_focus = self.wrap_focal_widget(self.view_object) 53 | self.view_header.pack_start(self.view_focus, False, False, 0) 54 | self.view_body = self.build_statistics_groups() 55 | 56 | def build_statistics_groups(self): 57 | """ 58 | Gather and build the statistics groups. 59 | """ 60 | groups = self.grstate.config.get("layout.statistics.groups").split(",") 61 | 62 | object_groups = {} 63 | for group in groups: 64 | if self.grstate.config.get("layout.statistics.%s.visible" % group): 65 | object_groups.update( 66 | {group: group_builder(self.grstate, group, None, None)} 67 | ) 68 | return self.render_group_view( 69 | object_groups, space_override="layout.statistics" 70 | ) 71 | -------------------------------------------------------------------------------- /src/view/views/view_tag.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | TagObjectView 23 | """ 24 | 25 | # ------------------------------------------------------------------------- 26 | # 27 | # Plugin Modules 28 | # 29 | # ------------------------------------------------------------------------- 30 | from ..common.common_classes import GrampsOptions 31 | from ..groups.group_builder import get_references_group 32 | from .view_base import GrampsObjectView 33 | from .view_const import CARD_MAP 34 | 35 | 36 | # ------------------------------------------------------------------------- 37 | # 38 | # TagObjectView Class 39 | # 40 | # ------------------------------------------------------------------------- 41 | class TagObjectView(GrampsObjectView): 42 | """ 43 | Provides the tag object view. 44 | """ 45 | 46 | def build_view(self): 47 | """ 48 | Build the view header and body and set the focus. 49 | """ 50 | tag = self.grcontext.primary_obj.obj 51 | 52 | groptions = GrampsOptions("active.tag") 53 | self.view_object = CARD_MAP["Tag"](self.grstate, groptions, tag) 54 | self.view_focus = self.wrap_focal_widget(self.view_object) 55 | self.view_header.pack_start(self.view_focus, False, False, 0) 56 | 57 | object_list = {} 58 | for ( 59 | obj_type, 60 | obj_handle, 61 | ) in self.grstate.dbstate.db.find_backlink_handles(tag.handle): 62 | if obj_type not in object_list: 63 | object_list.update({obj_type: []}) 64 | object_list[obj_type].append((obj_type, obj_handle)) 65 | 66 | object_groups = {} 67 | if object_list: 68 | for key, value in object_list.items(): 69 | groptions = GrampsOptions("group.{}".format(key.lower())) 70 | object_groups.update( 71 | { 72 | key.lower(): get_references_group( 73 | self.grstate, 74 | None, 75 | None, 76 | groptions=groptions, 77 | obj_list=value, 78 | ) 79 | } 80 | ) 81 | self.view_body = self.render_group_view(object_groups) 82 | -------------------------------------------------------------------------------- /src/view/zotero/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Gramps - a GTK+/GNOME based genealogy program 3 | # 4 | # Copyright (C) 2021-2022 Christopher Horn 5 | # 6 | # This program is free software; you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation; either version 2 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | """ 22 | Module containing rudimentary Zotero support 23 | """ 24 | --------------------------------------------------------------------------------