Пример #1
0
 def button_press_event(self, obj,event):
     if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
         store, node = self.tree.get_selection().get_selected()
         if node:
             person_handle = store.get_value(node, 1)
             person = self.db.get_person_from_handle(person_handle)
             EditPerson(self.dbstate, self.uistate, self.track, person,
                        self.this_callback)
Пример #2
0
 def edit_person_cb(self, obj, person_handle):
     person = self.dbstate.db.get_person_from_handle(person_handle)
     if person:
         try:
             EditPerson(self.dbstate, self.uistate, [], person)
         except Errors.WindowActiveError:
             pass
         return True
     return False
Пример #3
0
 def edit(self, obj):
     """
     Edit an existing person in the database.
     """
     for handle in self.selected_handles():
         person = self.dbstate.db.get_person_from_handle(handle)
         try:
             EditPerson(self.dbstate, self.uistate, [], person)
         except Errors.WindowActiveError:
             pass
Пример #4
0
 def editnotworkgroup(self, key):
     """
     Edit non native event in own editor
     """
     person = self.dbstate.db.get_person_from_handle(key)
     try:
         from gui.editors import EditPerson
         EditPerson(self.dbstate, self.uistate, [], person)
     except Errors.WindowActiveError:
         pass
Пример #5
0
 def edit_person(self, menu, event, lat, lon, mark):
     """
     Edit the selected person at the marker position
     """
     _LOG.debug("edit_person : %s" % mark[8])
     # need to add code here to edit the person.
     person = self.dbstate.db.get_person_from_gramps_id(mark[8])
     try:
         EditPerson(self.dbstate, self.uistate, [], person)
     except Errors.WindowActiveError:
         pass
Пример #6
0
 def edit_person(self, treeview):
     """
     Edit the selected child.
     """
     model, iter_ = treeview.get_selection().get_selected()
     if iter_:
         handle = model.get_value(iter_, 0)
         try:
             person = self.dbstate.db.get_person_from_handle(handle)
             EditPerson(self.dbstate, self.uistate, [], person)
         except Errors.WindowActiveError:
             pass
Пример #7
0
 def add(self, obj):
     """
     Add a new person to the database.
     """
     person = gen.lib.Person()
     #the editor requires a surname
     person.primary_name.add_surname(gen.lib.Surname())
     person.primary_name.set_primary_surname(0)
     
     try:
         EditPerson(self.dbstate, self.uistate, [], person)
     except Errors.WindowActiveError:
         pass
Пример #8
0
 def on_button_press(self, view, event):
     buffer_location = view.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT,
                                                    int(event.x),
                                                    int(event.y))
     iter = view.get_iter_at_location(*buffer_location)
     for (tag, person_handle) in self.tags:
         if iter.has_tag(tag):
             person = self.db.get_person_from_handle(person_handle)
             if event.button == 1:
                 if event.type == gtk.gdk._2BUTTON_PRESS:
                     try:
                         EditPerson(self.dbstate, self.uistate, [], person)
                     except Errors.WindowActiveError:
                         pass
                 else:
                     self.uistate.set_active(person_handle, 'Person')
                 return True  # handled event
     return False  # did not handle event
Пример #9
0
    def rowActivated(self, treeView, path, column):
        # first we need to check that the row corresponds to a person
        iter = self.model.get_iter(path)
        personGid = self.model.get_value(iter, 1)
        familyGid = self.model.get_value(iter, 4)

        if familyGid != '':  # do we have a family?
            # get the parent family for this person
            family = self.db.get_family_from_gramps_id(familyGid)
            if family:
                try:
                    EditFamily(self.dbstate, self.uistate, [], family)
                except Errors.WindowActiveError:
                    pass

        elif personGid != '':  # do we have a person?
            # get the person that corresponds to this GID
            person = self.db.get_person_from_gramps_id(personGid)
            if person:
                try:
                    EditPerson(self.dbstate, self.uistate, [], person)
                except Errors.WindowActiveError:
                    pass
Пример #10
0
    def add(self, obj):
        person = gen.lib.Person()

        # attempt to get the current surname
        (model, pathlist) = self.selection.get_selected_rows()
        name = gen.lib.Name()
        #the editor requires a surname
        name.add_surname(gen.lib.Surname())
        name.set_primary_surname(0)
        basepers = None
        if len(pathlist) == 1:
            path = pathlist[0]
            if len(path) == 1:
                path = (path[0], 0)
            node = model.get_iter(path)
            handle = model.get_value(node, self.handle_col)
            basepers = self.dbstate.db.get_person_from_handle(handle)
        if basepers:
            preset_name(basepers, name)
        person.set_primary_name(name)
        try:
            EditPerson(self.dbstate, self.uistate, [], person)
        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
Пример #12
0
 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