Feature:New global [Add]>[New] menu with Keybindings (#281)
Usability improvement, allows using the Menu [Add]>[New] or global keyboard shortcut(keybinding) to add [New] entries Supports: Adding [New] records for: * Person * Family * Event (default=Custom/Unknown)(Leave blank for unknown / enter letters for custom) * Place * Source * Citation * Repository * Media * Note
This commit is contained in:
parent
bef4b309b6
commit
59cced2bc6
@ -91,6 +91,12 @@ from .aboutdialog import GrampsAboutDialog
|
|||||||
from .navigator import Navigator
|
from .navigator import Navigator
|
||||||
from .views.tags import Tags
|
from .views.tags import Tags
|
||||||
from .actiongroup import ActionGroup
|
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 gramps.gen.db.exceptions import DbWriteFailure
|
||||||
from .managedwindow import ManagedWindow
|
from .managedwindow import ManagedWindow
|
||||||
|
|
||||||
@ -128,6 +134,23 @@ UIDEFAULT = '''<ui>
|
|||||||
<menuitem action="Abandon"/>
|
<menuitem action="Abandon"/>
|
||||||
<menuitem action="Quit"/>
|
<menuitem action="Quit"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
<menu action="AddMenu">
|
||||||
|
<menu action="AddNewMenu">
|
||||||
|
<separator/>
|
||||||
|
<menuitem action="PersonAdd"/>
|
||||||
|
<separator/>
|
||||||
|
<menuitem action="FamilyAdd"/>
|
||||||
|
<separator/>
|
||||||
|
<menuitem action="EventAdd"/>
|
||||||
|
<separator/>
|
||||||
|
<menuitem action="PlaceAdd"/>
|
||||||
|
<menuitem action="SourceAdd"/>
|
||||||
|
<menuitem action="CitationAdd"/>
|
||||||
|
<menuitem action="RepositoryAdd"/>
|
||||||
|
<menuitem action="MediaAdd"/>
|
||||||
|
<menuitem action="NoteAdd"/>
|
||||||
|
</menu>
|
||||||
|
</menu>
|
||||||
<menu action="EditMenu">
|
<menu action="EditMenu">
|
||||||
<menuitem action="Undo"/>
|
<menuitem action="Undo"/>
|
||||||
<menuitem action="Redo"/>
|
<menuitem action="Redo"/>
|
||||||
@ -574,6 +597,27 @@ class ViewManager(CLIManager):
|
|||||||
self._action_action_list = [
|
self._action_action_list = [
|
||||||
('Clipboard', 'edit-paste', _('Clip_board'), "<PRIMARY>b",
|
('Clipboard', 'edit-paste', _('Clip_board'), "<PRIMARY>b",
|
||||||
_("Open the Clipboard dialog"), self.clipboard),
|
_("Open the Clipboard dialog"), self.clipboard),
|
||||||
|
('AddMenu', None, _('_Add')),
|
||||||
|
('AddNewMenu', None, _('_New')),
|
||||||
|
('PersonAdd', None, _('_Person'), "<Alt>p", None,
|
||||||
|
self.add_new_person),
|
||||||
|
('FamilyAdd', None, _('Famil_y'), "<Alt>y", None,
|
||||||
|
self.add_new_family),
|
||||||
|
('EventAdd', None, _('_Event'), "<shift>e", None,
|
||||||
|
self.add_new_event),
|
||||||
|
('PlaceAdd', None, _('_Place'), "<shift><Alt>p", None,
|
||||||
|
self.add_new_place),
|
||||||
|
('SourceAdd', None, _('_Source'), "<shift><Alt>s", None,
|
||||||
|
self.add_new_source),
|
||||||
|
('CitationAdd', None, _('_Citation'), "<shift><Alt>c", None,
|
||||||
|
self.add_new_citation),
|
||||||
|
('RepositoryAdd', None, _('Repositor_y'), "<shift><Alt>y", None,
|
||||||
|
self.add_new_repository),
|
||||||
|
('MediaAdd', None, _('_Media'), "<shift><Alt>m", None,
|
||||||
|
self.add_new_media),
|
||||||
|
('NoteAdd', None, _('_Note'), "<shift><Alt>n", None,
|
||||||
|
self.add_new_note),
|
||||||
|
#--------------------------------------
|
||||||
('Import', 'gramps-import', _('_Import...'), "<PRIMARY>i", None,
|
('Import', 'gramps-import', _('_Import...'), "<PRIMARY>i", None,
|
||||||
self.import_data),
|
self.import_data),
|
||||||
('Tools', 'gramps-tools', _('_Tools'), None,
|
('Tools', 'gramps-tools', _('_Tools'), None,
|
||||||
@ -1355,6 +1399,87 @@ class ViewManager(CLIManager):
|
|||||||
except WindowActiveError:
|
except WindowActiveError:
|
||||||
return
|
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):
|
def config_view(self, obj):
|
||||||
"""
|
"""
|
||||||
Displays the configuration dialog for the active view
|
Displays the configuration dialog for the active view
|
||||||
|
Loading…
Reference in New Issue
Block a user