def edit(self, obj): """ Edit the selected objects in the EditMedia dialog """ for handle in self.selected_handles(): object = self.dbstate.db.get_object_from_handle(handle) try: EditMedia(self.dbstate, self.uistate, [], object) except Errors.WindowActiveError: pass
def edit_object(dbstate, uistate, reftype, ref): """ Invokes the appropriate editor for an object type and given handle. """ from gui.editors import (EditEvent, EditPerson, EditFamily, EditSource, EditPlace, EditMedia, EditRepository, EditCitation) if reftype == 'Person': try: person = dbstate.db.get_person_from_handle(ref) EditPerson(dbstate, uistate, [], person) except Errors.WindowActiveError: pass elif reftype == 'Family': try: family = dbstate.db.get_family_from_handle(ref) EditFamily(dbstate, uistate, [], family) except Errors.WindowActiveError: pass elif reftype == 'Source': try: source = dbstate.db.get_source_from_handle(ref) EditSource(dbstate, uistate, [], source) except Errors.WindowActiveError: pass elif reftype == 'Citation': try: citation = dbstate.db.get_citation_from_handle(ref) EditCitation(dbstate, uistate, [], citation) except Errors.WindowActiveError: """ Return the text used when citation cannot be edited """ blocked_text = _("Cannot open new citation editor at this time. " "Either the citation is already being edited, " "or the associated source is already being " "edited, and opening a citation editor " "(which also allows the source " "to be edited), would create ambiguity " "by opening two editors on the same source. " "\n\n" "To edit the citation, close the source " "editor and open an editor for the citation " "alone") from QuestionDialog import WarningDialog WarningDialog(_("Cannot open new citation editor"), blocked_text) elif reftype == 'Place': try: place = dbstate.db.get_place_from_handle(ref) EditPlace(dbstate, uistate, [], place) except Errors.WindowActiveError: pass elif reftype == 'Media': try: obj = dbstate.db.get_media_from_handle(ref) EditMedia(dbstate, uistate, [], obj) except Errors.WindowActiveError: pass elif reftype == 'Event': try: event = dbstate.db.get_event_from_handle(ref) EditEvent(dbstate, uistate, [], event) except Errors.WindowActiveError: pass elif reftype == 'Repository': try: repo = dbstate.db.get_repository_from_handle(ref) EditRepository(dbstate, uistate, [], repo) except Errors.WindowActiveError: pass
def add(self, obj): """Add a new media object to the media list""" try: EditMedia(self.dbstate, self.uistate, [], gen.lib.MediaObject()) except Errors.WindowActiveError: pass
def on_table_doubleclick(self, obj): """ Handle events on tables. obj is a treeview """ from gui.editors import (EditPerson, EditEvent, EditFamily, EditCitation, EditSource, EditPlace, EditRepository, EditNote, EditMedia) selection = obj.get_selection() store, paths = selection.get_selected_rows() tpath = paths[0] if len(paths) > 0 else None node = store.get_iter(tpath) if tpath else None if not node: return index = store.get_value(node, 0) # index if self._callback_leftdouble: self._callback_leftdouble(store.get_value(node, 1)) return True elif self.__link[index]: objclass, handle = self.__link[index] if objclass == 'Person': person = self.access.dbase.get_person_from_handle(handle) if person: try: EditPerson(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], person) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Event': event = self.access.dbase.get_event_from_handle(handle) if event: try: EditEvent(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], event) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Family': ref = self.access.dbase.get_family_from_handle(handle) if ref: try: EditFamily(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Citation': ref = self.access.dbase.get_citation_from_handle(handle) if ref: try: EditCitation(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Source': ref = self.access.dbase.get_source_from_handle(handle) if ref: try: EditSource(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Place': ref = self.access.dbase.get_place_from_handle(handle) if ref: try: EditPlace(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Repository': ref = self.access.dbase.get_repository_from_handle(handle) if ref: try: EditRepository(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'Note': ref = self.access.dbase.get_note_from_handle(handle) if ref: try: EditNote(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass in ['Media', 'MediaObject']: ref = self.access.dbase.get_object_from_handle(handle) if ref: try: EditMedia(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, [], ref) return True # handled event except Errors.WindowActiveError: pass elif objclass == 'PersonList': from QuickReports import run_quick_report_by_name run_quick_report_by_name(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, 'filterbyname', 'list of people', handles=handle) elif objclass == 'Filter': from QuickReports import run_quick_report_by_name run_quick_report_by_name(self.simpledoc.doc.dbstate, self.simpledoc.doc.uistate, 'filterbyname', handle[0]) return False # didn't handle event