def __populate_gui(self, event): """ Populate the GUI for a given form event. """ # Set source handle = self.citation.get_reference_handle() source = self.db.get_source_from_handle(handle) source_text = self.widgets['source_text'] source_text.set_text(source.get_title()) form_id = get_form_id(source) # Set event type event_type = EventType() event_type.set_from_xml_str(get_form_type(form_id)) self.event.set_type(event_type) # Set date form_date = get_form_date(form_id) date_text = self.widgets['date_text'] date_button = self.widgets['date_button'] if form_date is not None: date_text.set_text(displayer.display(form_date)) self.event.set_date_object(form_date) self.citation.set_date_object(form_date) date_text.set_editable(False) date_button.set_sensitive(False) else: date_text.set_text(get_date(event)) date_text.set_editable(True) date_button.set_sensitive(True) # Create tabs self.details = DetailsTab(self.dbstate, self.uistate, self.track, self.event, self.citation, form_id) self.headings = HeadingsTab(self.dbstate, self.uistate, self.track, self.event, self.citation, form_id) self.gallery_list = GalleryTab(self.dbstate, self.uistate, self.track, self.citation.get_media_list()) self._add_tab(self.notebook, self.details) self._add_tab(self.notebook, self.headings) self._add_tab(self.notebook, self.gallery_list) self.notebook.show_all() self.notebook.set_current_page(0)
def init_gui(self): # Draw dialog and make it handle everything self.glade = Glade() self.auto1 = self.glade.get_object("original") self.auto2 = self.glade.get_object("new") # Need to display localized event names etype = EventType() event_names = sorted(etype.get_standard_names(), key=glocale.sort_key) fill_combo(self.auto1,event_names) fill_combo(self.auto2,event_names) etype.set_from_xml_str(self.options.handler.options_dict['fromtype']) self.auto1.get_child().set_text(str(etype)) etype.set_from_xml_str(self.options.handler.options_dict['totype']) self.auto2.get_child().set_text(str(etype)) window = self.glade.toplevel self.set_window(window,self.glade.get_object('title'),self.title) self.glade.connect_signals({ "on_close_clicked" : self.close, "on_apply_clicked" : self.on_apply_clicked, "on_delete_event" : self.close, }) self.show()
def on_apply_clicked(self, obj): # Need to store English names for later comparison the_type = EventType() the_type.set(self.auto1.get_child().get_text()) self.options.handler.options_dict['fromtype'] = the_type.xml_str() the_type.set(self.auto2.get_child().get_text()) self.options.handler.options_dict['totype'] = the_type.xml_str() self.run_tool(self.window) # Save options self.options.handler.save_options() self.close()
def _createmap_for_one_person(self, person, color): """ Create all markers for each people's event in the database which has a lat/lon. """ self.place_list = [] dbstate = self.dbstate if person is not None: # For each event, if we have a place, set a marker. for event_ref in person.get_event_ref_list(): if not event_ref: continue event = dbstate.db.get_event_from_handle(event_ref.ref) role = event_ref.get_role() try: date = event.get_date_object().to_calendar(self.cal) except: continue eyear = str("%04d" % date.get_year()) + \ str("%02d" % date.get_month()) + \ str("%02d" % date.get_day()) place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle(place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) descr1 = _("%(eventtype)s : %(name)s") % { 'eventtype': evt, 'name': _nd.display(person)} # place.get_longitude and place.get_latitude return # one string. We have coordinates when the two values # contains non null string. if longitude and latitude: self._append_to_places_list(descr, evt, person.gramps_id, latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role ) else: self._append_to_places_without_coord( place.gramps_id, descr) family_list = person.get_family_handle_list() descr1 = " - " for family_hdl in family_list: family = self.dbstate.db.get_family_from_handle(family_hdl) if family is not None: fhandle = family_list[0] # first is primary fam = dbstate.db.get_family_from_handle(fhandle) mother = father = None handle = fam.get_father_handle() if handle: father = dbstate.db.get_person_from_handle(handle) if father: descr1 = "%s - " % _nd.display(father) handle = fam.get_mother_handle() if handle: mother = dbstate.db.get_person_from_handle(handle) if mother: descr1 = "%s%s" % (descr1, _nd.display(mother)) for event_ref in family.get_event_ref_list(): if event_ref: event = dbstate.db.get_event_from_handle( event_ref.ref) role = event_ref.get_role() if event.get_place_handle(): place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle( place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType( event.get_type()) eyear = str( "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day()) if longitude and latitude: self._append_to_places_list( descr, evt, person.gramps_id, latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role ) else: self._append_to_places_without_coord(place.gramps_id, descr) sort1 = sorted(self.place_list, key=operator.itemgetter(1, 6)) self.draw(None, sort1, color) # merge with the last results merge_list = self.sort for the_event in sort1: if the_event not in merge_list: merge_list.append(the_event) self.sort = sorted(merge_list, key=operator.itemgetter(6))
def bubble_message(self, event, lat, lon, marks): self.menu = Gtk.Menu() menu = self.menu menu.set_title("events") message = "" oldplace = "" prevmark = None for mark in marks: if message != "": add_item = Gtk.MenuItem(label=message) add_item.show() menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) modify.show() modify.connect("activate", self.edit_event, event, lat, lon, prevmark) itemoption.append(modify) center = Gtk.MenuItem(label=_("Center on this place")) center.show() center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) evt = self.dbstate.db.get_event_from_gramps_id(mark[10]) hdle = evt.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this event")) bookm.show() bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) if mark[0] != oldplace: message = "%s :" % mark[0] self.add_place_bubble_message(event, lat, lon, marks, menu, message, mark) oldplace = mark[0] evt = self.dbstate.db.get_event_from_gramps_id(mark[10]) # format the date as described in preferences. date = displayer.display(evt.get_date_object()) message = "(%s) %s : %s" % (date, EventType(mark[7]), mark[5]) prevmark = mark add_item = Gtk.MenuItem(label=message) add_item.show() menu.append(add_item) self.itemoption = Gtk.Menu() itemoption = self.itemoption itemoption.set_title(message) itemoption.show() add_item.set_submenu(itemoption) modify = Gtk.MenuItem(label=_("Edit Event")) modify.show() modify.connect("activate", self.edit_event, event, lat, lon, prevmark) itemoption.append(modify) center = Gtk.MenuItem(label=_("Center on this place")) center.show() center.connect("activate", self.center_here, event, lat, lon, prevmark) itemoption.append(center) evt = self.dbstate.db.get_event_from_gramps_id(mark[10]) hdle = evt.get_handle() bookm = Gtk.MenuItem(label=_("Bookmark this event")) bookm.show() bookm.connect("activate", self.add_bookmark_from_popup, hdle) itemoption.append(bookm) menu.popup(None, None, None, None, event.button, event.time) return 1
# Global variables (ones used in both classes here, that is) # #------------------------------------------------------------------------ # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh def _T_(value): # enable deferred translations (see Python docs 22.1.3.4) return value CUSTOM = _T_("Custom") # Construct section list and type to group map SECTION_LIST = [] TYPE2GROUP = {} for event_group, type_list in EventType().get_menu_standard_xml(): SECTION_LIST.append(event_group) for event_type in type_list: TYPE2GROUP[event_type] = event_group SECTION_LIST.append(CUSTOM) TYPE2GROUP[EventType.CUSTOM] = CUSTOM #------------------------------------------------------------------------ # # IndivCompleteReport # #------------------------------------------------------------------------ class IndivCompleteReport(Report): def __init__(self, database, options, user): """
def _createmap(self, active): """ Create all markers for each people's event in the database which has a lat/lon. @param: active is mandatory but unused in this view. Fix : 10088 """ dbstate = self.dbstate self.cal = config.get('preferences.calendar-format-report') self.place_list = [] self.place_without_coordinates = [] self.places_found = [] self.minlat = self.maxlat = self.minlon = self.maxlon = 0.0 self.minyear = 9999 self.maxyear = 0 latitude = "" longitude = "" self.nbplaces = 0 self.nbmarkers = 0 self.message_layer.clear_messages() self.message_layer.set_font_attributes(None, None, None) self.kml_layer.clear() person_handle = self.uistate.get_active('Person') person = None if person_handle: person = dbstate.db.get_person_from_handle(person_handle) if person is not None: # For each event, if we have a place, set a marker. self.load_kml_files(person) self.message_layer.add_message( _("Person places for %s") % _nd.display(person)) for event_ref in person.get_event_ref_list(): if not event_ref: continue event = dbstate.db.get_event_from_handle(event_ref.ref) self.load_kml_files(event) role = event_ref.get_role() eyear = str( "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day()) place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle(place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) descr1 = _("%(eventtype)s : %(name)s") % { 'eventtype': evt, 'name': _nd.display(person) } self.load_kml_files(place) # place.get_longitude and place.get_latitude return # one string. We have coordinates when the two values # contains non null string. if longitude and latitude: self._append_to_places_list( descr, evt, _nd.display(person), latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role) else: self._append_to_places_without_coord( place.gramps_id, descr) family_list = person.get_family_handle_list() for family_hdl in family_list: family = self.dbstate.db.get_family_from_handle(family_hdl) if family is not None: fhandle = family_list[0] # first is primary fam = dbstate.db.get_family_from_handle(fhandle) father = mother = None handle = fam.get_father_handle() if handle: father = dbstate.db.get_person_from_handle(handle) descr1 = " - " if father: descr1 = "%s - " % _nd.display(father) handle = fam.get_mother_handle() if handle: mother = dbstate.db.get_person_from_handle(handle) if mother: descr1 = "%s%s" % (descr1, _nd.display(mother)) for event_ref in family.get_event_ref_list(): if event_ref: event = dbstate.db.get_event_from_handle( event_ref.ref) self.load_kml_files(event) role = event_ref.get_role() if event.get_place_handle(): place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle( place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() (latitude, longitude) = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) eyear = str( "%04d" % event.get_date_object().to_calendar(self.cal).get_year()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_month()) + \ str("%02d" % event.get_date_object().to_calendar(self.cal).get_day()) self.load_kml_files(place) if longitude and latitude: self._append_to_places_list( descr, evt, _nd.display(person), latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role) else: self._append_to_places_without_coord( place.gramps_id, descr) self.sort = sorted(self.place_list, key=operator.itemgetter(6)) self._create_markers()
def _createpersonmarkers(self, dbstate, person, comment, fam_id): """ Create all markers for the specified person. """ self.cal = config.get('preferences.calendar-format-report') latitude = longitude = "" if person: # For each event, if we have a place, set a marker. for event_ref in person.get_event_ref_list(): if not event_ref: continue role = event_ref.get_role() event = dbstate.db.get_event_from_handle(event_ref.ref) eyear = event.get_date_object().to_calendar( self.cal).get_year() place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle(place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) descr1 = _("%(eventtype)s : %(name)s") % { 'eventtype': evt, 'name': _nd.display(person) } # place.get_longitude and place.get_latitude return # one string. We have coordinates when the two values # contains non null string. if (longitude and latitude): if not self._present_in_places_list( 2, str(descr1 + descr + str(evt))): self._append_to_places_list( descr, str(descr1 + descr + str(evt)), _nd.display(person), latitude, longitude, role, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, fam_id) else: self._append_to_places_without_coord( place.gramps_id, descr) family_list = person.get_family_handle_list() for family_hdl in family_list: family = self.dbstate.db.get_family_from_handle(family_hdl) if family is not None: for event_ref in family.get_event_ref_list(): if event_ref: event = dbstate.db.get_event_from_handle( event_ref.ref) role = event_ref.get_role() if event.get_place_handle(): place_handle = event.get_place_handle() if place_handle: place = dbstate.db.get_place_from_handle( place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) (father_name, mother_name ) = self._get_father_and_mother_name( event) descr1 = "%s : %s - " % (evt, father_name) descr1 = "%s%s" % (descr1, mother_name) eyear = event.get_date_object( ).to_calendar(self.cal).get_year() if (longitude and latitude): if not self._present_in_places_list( 2, str(descr1 + descr + str(evt))): self._append_to_places_list( descr, str(descr1 + descr + str(evt)), _nd.display(person), latitude, longitude, role, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, family.gramps_id) else: self._append_to_places_without_coord( place.gramps_id, descr)
def get_person_label(self, person): "return person label string" # see if we have an image to use for this person image_path = None if self.use_html_output: media_list = person.get_media_list() if len(media_list) > 0: media_handle = media_list[0].get_reference_handle() media = self._db.get_media_from_handle(media_handle) media_mime_type = media.get_mime_type() if media_mime_type[0:5] == "image": image_path = get_thumbnail_path( media_path_full(self._db, media.get_path()), rectangle=media_list[0].get_rectangle()) # test if thumbnail actually exists in thumbs # (import of data means media files might not be present image_path = find_file(image_path) label = "" line_delimiter = '\\n' # If we have an image, then start an HTML table; remember to close # the table afterwards! # # This isn't a free-form HTML format here...just a few keywords that # happen to be # similar to keywords commonly seen in HTML. For additional # information on what # is allowed, see: # # http://www.graphviz.org/info/shapes.html#html # if self.use_html_output and image_path: line_delimiter = '<BR/>' label += '<TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0" ' label += 'CELLBORDER="0"><TR><TD></TD><TD>' label += '<IMG SRC="%s"/></TD><TD></TD>' % image_path if self.imgpos == 0: #trick it into not stretching the image label += '</TR><TR><TD COLSPAN="3">' else: label += '<TD>' else: #no need for html label with this person self.use_html_output = False # at the very least, the label must have the person's name p_name = self._name_display.display(person) label += html.escape(p_name) p_id = person.get_gramps_id() if self.includeid == 1: # same line label += " (%s)" % p_id elif self.includeid == 2: # own line label += "%s(%s)" % (line_delimiter, p_id) if self.event_choice != 0: b_date, d_date, b_place, d_place, b_type, d_type = \ self.get_event_strings(person) if self.event_choice in [1, 2, 3, 4, 5] and (b_date or d_date): label += '%s(' % line_delimiter if b_date: label += '%s' % b_date label += ' – ' if d_date: label += '%s' % d_date label += ')' if (self.event_choice in [2, 3, 5, 6] and (b_place or d_place) and not (self.event_choice == 3 and (b_date or d_date))): label += '%s(' % line_delimiter if b_place: label += '%s' % b_place label += ' – ' if d_place: label += '%s' % d_place label += ')' if self.event_choice == 7: if b_type: label += '%s%s' % (line_delimiter, b_type.get_abbreviation()) if b_date: label += ' %s' % b_date if b_place: label += ' %s' % b_place if d_type: label += '%s%s' % (line_delimiter, d_type.get_abbreviation()) if d_date: label += ' %s' % d_date if d_place: label += ' %s' % d_place if self.increlname and self.center_person != person: # display relationship info if self.advrelinfo: (relationship, _ga, _gb) = self.rel_calc.get_one_relationship( self._db, self.center_person, person, extra_info=True, olocale=self._locale) if relationship: label += "%s(%s Ga=%d Gb=%d)" % (line_delimiter, relationship, _ga, _gb) else: relationship = self.rel_calc.get_one_relationship( self._db, self.center_person, person, olocale=self._locale) if relationship: label += "%s(%s)" % (line_delimiter, relationship) if self.occupation > 0: event_refs = person.get_primary_event_ref_list() events = [ event for event in [ self._db.get_event_from_handle(ref.ref) for ref in event_refs ] if event.get_type() == EventType(EventType.OCCUPATION) ] if len(events) > 0: events.sort(key=lambda x: x.get_date_object()) if self.occupation == 1: occupation = events[-1].get_description() if occupation: label += "%s(%s)" % (line_delimiter, occupation) elif self.occupation == 2: for evt in events: date = self.get_date_string(evt) place = self.get_place_string(evt) desc = evt.get_description() if not date and not desc and not place: continue label += '%s(' % line_delimiter if date: label += '%s' % date if desc: label += ' ' if desc: label += '%s' % desc if place: if date or desc: label += self._(', ') # Arabic OK label += '%s' % place label += ')' # see if we have a table that needs to be terminated if self.use_html_output: label += '</TD></TR></TABLE>' return label else: # non html label is enclosed by "" so escape other " return label.replace('"', '\\\"')
def show_one_person(self, person): """ Create all markers for each people's event in the database which has a lat/lon. """ dbstate = self.dbstate self.load_kml_files(person) for event_ref in person.get_event_ref_list(): if not event_ref: continue event = dbstate.db.get_event_from_handle(event_ref.ref) self.load_kml_files(event) role = event_ref.get_role() edate = event.get_date_object().to_calendar(self.cal) eyear = str("%04d" % edate.get_year()) + \ str("%02d" % edate.get_month()) + \ str("%02d" % edate.get_day()) place_handle = event.get_place_handle() if place_handle and event_ref.ref not in self.event_list: self.event_list.append(event_ref.ref) place = dbstate.db.get_place_from_handle(place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) descr1 = _("%(eventtype)s : %(name)s") % { 'eventtype': evt, 'name': _nd.display(person) } self.load_kml_files(place) # place.get_longitude and place.get_latitude return # one string. We have coordinates when the two values # contains non null string. if longitude and latitude: self.progress.step() self._append_to_places_list(descr, evt, _nd.display(person), latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role) else: self._append_to_places_without_coord( place.gramps_id, descr) family_list = person.get_family_handle_list() for family_hdl in family_list: family = self.dbstate.db.get_family_from_handle(family_hdl) if family is not None: fhandle = family_list[0] # first is primary fam = dbstate.db.get_family_from_handle(fhandle) father = mother = None handle = fam.get_father_handle() if handle: father = dbstate.db.get_person_from_handle(handle) descr1 = " - " if father: self.already_done.append(handle) descr1 = "%s - " % _nd.display(father) handle = fam.get_mother_handle() if handle: self.already_done.append(handle) mother = dbstate.db.get_person_from_handle(handle) if mother: descr1 = "%s%s" % (descr1, _nd.display(mother)) for event_ref in family.get_event_ref_list(): if event_ref: event = dbstate.db.get_event_from_handle(event_ref.ref) self.load_kml_files(event) role = event_ref.get_role() if event.get_place_handle(): place_handle = event.get_place_handle() if (place_handle and event_ref.ref not in self.event_list): self.event_list.append(event_ref.ref) place = dbstate.db.get_place_from_handle( place_handle) if place: longitude = place.get_longitude() latitude = place.get_latitude() (latitude, longitude) = conv_lat_lon( latitude, longitude, "D.D8") descr = _pd.display(dbstate.db, place) evt = EventType(event.get_type()) edate = event.get_date_object() edate = edate.to_calendar(self.cal) eyear = str("%04d" % edate.get_year()) + \ str("%02d" % edate.get_month())\ + str("%02d" % edate.get_day()) self.load_kml_files(place) if longitude and latitude: self.progress.step() self._append_to_places_list( descr, evt, _nd.display(person), latitude, longitude, descr1, eyear, event.get_type(), person.gramps_id, place.gramps_id, event.gramps_id, role) else: self._append_to_places_without_coord( place.gramps_id, descr) for pers in [ self._get_parent(person, True), self._get_parent(person, False) ]: if pers: self.show_one_person(pers)
def default_types(self): return [ EventType(EventType.BIRTH), EventType(EventType.DEATH), EventType(EventType.BURIAL), ]