diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index cb6e83842..14e9373e6 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -91,6 +91,12 @@ from .aboutdialog import GrampsAboutDialog from .navigator import Navigator from .views.tags import Tags from .actiongroup import ActionGroup +from gramps.gen.lib import (Person, Surname, Family, Media, Note, Place, + Source, Repository, Citation, Event, EventType, + ChildRef) +from gramps.gui.editors import (EditPerson, EditFamily, EditMedia, EditNote, + EditPlace, EditSource, EditRepository, + EditCitation, EditEvent) from gramps.gen.db.exceptions import DbWriteFailure from .managedwindow import ManagedWindow @@ -128,6 +134,23 @@ UIDEFAULT = ''' + + + + + + + + + + + + + + + + + @@ -574,6 +597,27 @@ class ViewManager(CLIManager): self._action_action_list = [ ('Clipboard', 'edit-paste', _('Clip_board'), "b", _("Open the Clipboard dialog"), self.clipboard), + ('AddMenu', None, _('_Add')), + ('AddNewMenu', None, _('_New')), + ('PersonAdd', None, _('_Person'), "p", None, + self.add_new_person), + ('FamilyAdd', None, _('Famil_y'), "y", None, + self.add_new_family), + ('EventAdd', None, _('_Event'), "e", None, + self.add_new_event), + ('PlaceAdd', None, _('_Place'), "p", None, + self.add_new_place), + ('SourceAdd', None, _('_Source'), "s", None, + self.add_new_source), + ('CitationAdd', None, _('_Citation'), "c", None, + self.add_new_citation), + ('RepositoryAdd', None, _('Repositor_y'), "y", None, + self.add_new_repository), + ('MediaAdd', None, _('_Media'), "m", None, + self.add_new_media), + ('NoteAdd', None, _('_Note'), "n", None, + self.add_new_note), + #-------------------------------------- ('Import', 'gramps-import', _('_Import...'), "i", None, self.import_data), ('Tools', 'gramps-tools', _('_Tools'), None, @@ -1355,6 +1399,87 @@ class ViewManager(CLIManager): except WindowActiveError: return + # ---------------Add new xxx -------------------------------- + def add_new_person(self, obj): + """ + Add a new person to the database. (Global keybinding) + """ + person = Person() + #the editor requires a surname + person.primary_name.add_surname(Surname()) + person.primary_name.set_primary_surname(0) + + try: + EditPerson(self.dbstate, self.uistate, [], person) + except WindowActiveError: + pass + + def add_new_family(self, obj): + """ + Add a new family to the database. (Global keybinding) + """ + family = Family() + try: + EditFamily(self.dbstate, self.uistate, [], family) + except WindowActiveError: + pass + + def add_new_event(self, obj): + """ + Add a new custom/unknown event (Note you type first letter of event) + """ + try: + event = Event() + event.set_type(EventType.UNKNOWN) + EditEvent(self.dbstate, self.uistate, [], event) + except WindowActiveError: + pass + + def add_new_place(self, obj): + """Add a new place to the place list""" + try: + EditPlace(self.dbstate, self.uistate, [], Place()) + except WindowActiveError: + pass + + def add_new_source(self, obj): + """Add a new source to the source list""" + try: + EditSource(self.dbstate, self.uistate, [], Source()) + except WindowActiveError: + pass + + def add_new_repository(self, obj): + """Add a new repository to the repository list""" + try: + EditRepository(self.dbstate, self.uistate, [], Repository()) + except WindowActiveError: + pass + + def add_new_citation(self, obj): + """ + Add a new citation + """ + try: + EditCitation(self.dbstate, self.uistate, [], Citation()) + except WindowActiveError: + pass + + def add_new_media(self, obj): + """Add a new media object to the media list""" + try: + EditMedia(self.dbstate, self.uistate, [], Media()) + except WindowActiveError: + pass + + def add_new_note(self, obj): + """Add a new note to the note list""" + try: + EditNote(self.dbstate, self.uistate, [], Note()) + except WindowActiveError: + pass + # ------------------------------------------------------------------------ + def config_view(self, obj): """ Displays the configuration dialog for the active view