def init(self): from gramps.gen.lib.date import Today self.set_wrap(False) self.deceasedList = [] self.set_text(self.__INIT) self.tDay = Today().get_day() self.tMonth = Today().get_month() # Would prefer a regional/calendar/translation sensitive # version of month string or date string. self.tDateStr = ['', _('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')][self.tMonth] +\ ' ' + str(self.tDay) # These variables must be updated if reordering or adding new # options in build_options() # # Their order also is used in save_update_options() for the # persistent gui data list. self.__OPT_MAX = 4 self.__OPT_SORT_DEFAULT = 4 self.__OPT_LIVING_ONLY = 0 self.__OPT_SORT_BY = 1 self.__OPT_SORT_ASC = 2 self.__OPT_EVENTS = 3
def __calculate(self, database, person): """Calculate the age and days until birthday""" today = Today() birth_ref = person.get_birth_ref() death_ref = person.get_death_ref() if (birth_ref and not death_ref): birth = database.get_event_from_handle(birth_ref.ref) birth_date = birth.get_date_object() if birth_date.is_regular(): birthday_this_year = Date(today.get_year(), birth_date.get_month(), birth_date.get_day()) next_age = birthday_this_year - birth_date # (0 year, months, days) between now and birthday of this # year (positive if passed): diff = today - birthday_this_year # about number of days the diff is: diff_days = diff[1] * 30 + diff[2] if next_age[0] < self.max_age: if diff_days <= 0: # not yet passed self.result.append((diff_days, next_age, birth_date, person)) else: # passed; add it for next year's birthday self.result.append((diff_days - 365, next_age[0] + 1, birth_date, person))
def run(database, document, person): """ Display a person's timeline. """ sa = SimpleAccess(database) sd = SimpleDoc(document) sd.title(_("Timeline for %s") % sa.name(person)) sd.paragraph("") stab = QuickTable(sa) stab.columns(_("Date"), _("Event"), _("Age"), _("Place"), _("People involved")) stab.set_link_col(4) handled = {} birth_ref = gramps.gen.lib.Person.get_birth_ref(person) birth_date = get_event_date_from_ref(database, birth_ref) event_list = [] process(database, sa, event_list, handled, person, False, person) for (event, obj, desc) in sorted(event_list, key=by_date): edate = sa.event_date_obj(event) span_str, span_int = format_date(birth_date, edate, obj == person) if desc == None: desc = event stab.row(edate, desc, span_str, sa.event_place(event), obj) stab.row_sort_val(2, span_int) today = Today() span_str, span_int = format_date(birth_date, today, False) stab.row(today, _("Today"), span_str, "", person) stab.row_sort_val(2, span_int) stab.write(sd) sd.paragraph("")
def get_person_age(person, dbstate_db, age_precision): """ Function to get person age. Returns string for age column. """ birth = get_birth_or_fallback(dbstate_db, person) death = get_death_or_fallback(dbstate_db, person) is_dead = False if birth: birth_date = birth.get_date_object() if (birth_date and birth_date.get_valid()): if death: death_date = death.get_date_object() if (death_date and death_date.get_valid()): age = (death_date - birth_date) is_dead = True if not is_dead: # if person is alive age = (Today() - birth_date) # formating age string age_str = age.format(precision=age_precision) if is_dead: gender = person.get_gender() # we get localized "Dead at %s age" if gender == person.MALE: age_str = _("Male person|Dead at %s") % (age_str) elif gender == person.FEMALE: age_str = _("Female person|Dead at %s") % (age_str) else: age_str = _("Unknown gender person|Dead at %s") % (age_str) return age_str return None
def __init__(self, text, fname): """""" self.text = ImportEntry(text) self.fname = ImportEntry(fname) self.date = Today() self.date.text = '{:04d}-{:02d}-{:02d}'.format \ (self.date.dateval[2], self.date.dateval[1], self.date.dateval[0])
def _get_event_data(self, event): ret = "" place_name = "" source_txt = "" date = self.format_date(event.get_date_object()) place_handle = event.get_place_handle() if place_handle: displayer = PlaceDisplayGeneanet() dateobj2 = Today() place = self.db.get_place_from_handle(place_handle) place_name = displayer.display(self.db, place, dateobj2) log.debug(" place_name %s" % place) source = self.get_primary_source(event.get_citation_list()) if source: source_txt = self.get_source_txt(source) if date != "": ret = ret + date if place_name != "" and source_txt != "": ret = ret + " #p %s #s %s" % (self.rem_spaces(place_name), self.rem_spaces(source_txt)) if place_name != "" and source_txt == "": ret = ret + " #p %s" % self.rem_spaces(place_name) if source_txt != "" and place_name == "": ret = ret + " #s %s" % self.rem_spaces(source_txt) return ret
def main(self): self.set_text(_("Processing...")) database = self.dbstate.db personList = database.iter_people() result = [] text = '' today = Today() for cnt, person in enumerate(personList): birth_ref = person.get_birth_ref() death_ref = person.get_death_ref() if (birth_ref and not death_ref): birth = database.get_event_from_handle(birth_ref.ref) birth_date = birth.get_date_object() if birth_date.is_regular(): birthday_this_year = Date(today.get_year(), birth_date.get_month(), birth_date.get_day()) next_age = birthday_this_year - birth_date # (0 year, months, days) between now and birthday of this year (positive if passed): diff = today - birthday_this_year # about number of days the diff is: diff_days = diff[1] * 30 + diff[2] if next_age[0] < self.max_age: if diff_days <= 0: #not yet passed result.append((diff_days, next_age, birth_date, person)) else: #passed; add it for next year's birthday result.append((diff_days - 365, next_age[0] + 1, birth_date, person)) # Reverse sort on number of days from now: result.sort(key=lambda item: -item[0]) self.clear_text() for diff, age, date, person in result: name = person.get_primary_name() self.append_text("%s: " % gramps.gen.datehandler.displayer.display(date)) self.link(name_displayer.display_name(name), "Person", person.handle) self.append_text(" (%s)\n" % age) self.append_text("", scroll_to="begin")
def lock_function(self, opt): """Lock objects depending on user selection and timeframe.""" date = Today() - opt[0] lock_no_date = opt[4] if opt[1]: self.lock_persons(date, lock_no_date) if opt[2]: self.lock_events(date, lock_no_date) if opt[3]: self.lock_media(date, lock_no_date) txt = "" for entry in self.cnt: txt += _("Set private: %d %s\n") % (entry[1], entry[0]) for entry in self.cnt: txt += _("Not private: %d %s\n") % (entry[2], entry[0]) OkDialog(_("Set Privacy Tool"), txt, parent=self.window)
def parse_format(self): """Parse the $ variables. """ if not self.is_a(): return attrib_parse = AttributeParse(self._in) next_char = self._in.next self._in.step2() if PRIVACY: # only parse Events as the other standard parsers do NOT check privacy if next_char == "e": #person event return self.__parse_an_event(self.friend.person, attrib_parse) elif next_char == "t": #family event return self.__parse_an_event(self.friend.family, attrib_parse) else: if next_char == "n": #Person's name return self.__parse_name(self.friend.person) elif next_char == "s": #Souses name return self.__parse_name(self.friend.spouse) elif next_char == "i": #Person's Id return self.__parse_id(self.friend.person) elif next_char == "j": #Marriage Id return self.__parse_id(self.friend.family) elif next_char == "b": #Person's Birth date if self.empty_item(self.friend.person): return return self.__parse_date( get_birth_or_fallback(self.friend.database, self.friend.person)) elif next_char == "d": #Person's Death date if self.empty_item(self.friend.person): return return self.__parse_date( get_death_or_fallback(self.friend.database, self.friend.person)) elif next_char == "m": #Marriage date if self.empty_item(self.friend.family): return return self.__parse_date( self.get_event_by_type(self.friend.family, EventType.MARRIAGE)) elif next_char == "v": #Divorce date if self.empty_item(self.friend.family): return return self.__parse_date( self.get_event_by_type(self.friend.family, EventType.DIVORCE)) elif next_char == "T": #Todays date date_f = DateFormat(self._in) from gramps.gen.lib.date import Today date = Today() if self.empty_item(date): return return date_f.parse_format(date) elif next_char == "B": #Person's birth place if self.empty_item(self.friend.person): return return self.__parse_place( get_birth_or_fallback(self.friend.database, self.friend.person)) elif next_char == "D": #Person's death place if self.empty_item(self.friend.person): return return self.__parse_place( get_death_or_fallback(self.friend.database, self.friend.person)) elif next_char == "M": #Marriage place if self.empty_item(self.friend.family): return return self.__parse_place( self.get_event_by_type(self.friend.family, EventType.MARRIAGE)) elif next_char == "V": #Divorce place if self.empty_item(self.friend.family): return return self.__parse_place( self.get_event_by_type(self.friend.family, EventType.DIVORCE)) elif next_char == "a": #Person's Atribute if self.empty_attribute(self.friend.person): return return attrib_parse.parse_format( self.friend.person.get_attribute_list()) elif next_char == "u": #Marriage Atribute if self.empty_attribute(self.friend.family): return return attrib_parse.parse_format( self.friend.family.get_attribute_list()) elif next_char == "e": #person event return self.__parse_an_event(self.friend.person, attrib_parse) elif next_char == "t": #family event return self.__parse_an_event(self.friend.family, attrib_parse) elif next_char == 'p': #photo for the person return self.__parse_photo(self.friend.person) elif next_char == 'P': #photo for the marriage return self.__parse_photo(self.friend.family) elif next_char == "G": gramps_format = GrampsFormat(self._in, self.database) return gramps_format.parse_format()
def today(): return DateProxy(Today())
def build_report_set(): reports = [] ################################################################## # Load plugins ################################################################## dbstate = DbState() climanager = CLIManager(dbstate, setloader=True, user=None) climanager.do_reg_plugins(dbstate, uistate=None) gpr = PluginRegister.get_instance() PLUGMAN = BasePluginManager.get_instance() CSS = PLUGMAN.process_plugin_data('WEBSTUFF') ################################################################## # GRAMPS native plugins ################################################################## # GRPH_FMT = ['odt', 'ps', 'pdf', 'svg'] GRPH_FMT = ['pdf', 'svg'] # GRPH_FMT = ['svg'] GRPH_REP = [ { 'report': 'ancestor_chart', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0006', }, }, { 'report': 'descend_chart', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0104', }, }, { 'report': 'family_descend_chart', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0104', }, }, { 'report': 'fan_chart', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0006', }, }, { 'report': 'statistics_chart', 'options': { 'scale_tree': 2, 'maxgen': 6, }, }, { 'report': 'timeline', 'options': { 'scale_tree': 2, 'maxgen': 6, }, }, { 'report': 'calendar', 'options': { 'scale_tree': 2, 'maxgen': 6, }, }, { 'report': 'familylines_graph', 'options': { 'scale_tree': 2, 'maxgen': 6, 'gidlist': 'I0104 I0045', 'limitchildren': True, 'maxchildren': 20, }, }, { 'report': 'hourglass_graph', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0044', 'maxascend': 2, 'maxdescend': 2, }, }, { 'report': 'rel_graph', 'options': { 'scale_tree': 2, 'maxgen': 6, 'pid': 'I0044', 'filter': 3, 'event_choice': 2, }, }, ] # TEXT_FMT = ['ps', 'pdf', 'html', 'odt', 'tex', 'rtf', 'txt'] TEXT_FMT = ['html', 'pdf', 'txt'] # TEXT_FMT = ['html', 'txt'] TEXT_REP = [ { 'report': 'ancestor_report', 'options': { 'maxgen': 6, 'pid': 'I0006', }, }, { 'report': 'descend_report', 'options': { 'pid': 'I0104', }, }, { 'report': 'det_ancestor_report', 'options': { 'pid': 'I0006', }, }, { 'report': 'det_descendant_report', 'options': { 'pid': 'I0104', }, }, { 'report': 'family_group', 'options': { 'family_id': 'F0017', }, }, { 'report': 'birthday_report', 'options': {}, }, { 'report': 'endofline_report', 'options': { 'pid': 'I0006', }, }, { 'report': 'indiv_complete', 'options': {}, }, { 'report': 'kinship_report', 'options': { 'pid': 'I0044', }, }, { 'report': 'tag_report', 'options': { 'tag': 'ToDo', }, }, { 'report': 'number_of_ancestors', 'options': { 'pid': 'I0006', }, }, { 'report': 'place_report', 'options': { 'places': 'P1678 P1679 P1680', }, }, { 'report': 'summary', 'options': {}, }, { 'report': 'records', 'options': {}, }, { 'report': 'notelinkreport', 'options': {}, }, ] # Single run with all native reports (except web) in all formats for (rep_list, formats) in [ (TEXT_REP, TEXT_FMT), (GRPH_REP, GRPH_FMT), ]: for rep_info in TEXT_REP: report = rep_info['report'] options = rep_info['options'] plugin = gpr.get_plugin(report) if not plugin: print('Unknown plugin: %s' % report) continue for fmt in TEXT_FMT: of = os.path.join(GRAMPS_REP_DIR, report + '.' + fmt) new_options = { 'name': report, 'off': fmt, 'of': of, # 'show': 'all', } new_options.update(options) reports.append({ 'title': '"%s" in format "%s"' % (plugin.name, fmt), 'name': plugin.name, 'result': of, 'type': 'Native', 'category': plugin.category, 'version': plugin.version, 'options': new_options, }) ################################################################## # GRAMPS native web reports ################################################################## full_options = { 'linkhome': True, 'showdeath': True, 'showpartner': True, 'showparents': True, 'showhalfsiblings': True, 'inc_families': True, 'inc_repository': True, 'inc_gendex': True, 'inc_addressbook': True, 'placemappages': True, 'familymappages': True, } for (i, (css, full)) in enumerate([ ['default', False], ['Mainz', True], ]): report = 'navwebpage' plugin = gpr.get_plugin(report) opts = { 'name': report, 'target': os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i), 'css': CSS[css]['id'], 'living': _INCLUDE_LIVING_VALUE, } if (full): opts.update(full_options) reports.append({ 'title': '"%s" report example %i' % (plugin.name, i), 'name': report, 'result': os.path.join(GRAMPS_REP_DIR, 'example_NAVWEB%i' % i, 'index.html'), 'type': 'Native', 'category': plugin.category, 'version': VERSION, 'options': opts, }) full_options = { 'alive': False, 'fullyear': True, 'makeoneday': True, 'link_to_narweb': True, } for (i, (css, full)) in enumerate([ ['default', False], ['Mainz', True], ]): report = 'WebCal' plugin = gpr.get_plugin(report) opts = { 'name': report, 'target': os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i), 'css': CSS[css]['id'], 'home_link': '../../example_NAVWEB%i/index.html' % i, 'prefix': '../../example_NAVWEB%i/' % i, } page = 'January.html' if (full): opts.update(full_options) page = 'fullyearlinked.html' reports.append({ 'title': '"%s" report example %i' % (plugin.name, i), 'name': report, 'result': os.path.join(GRAMPS_REP_DIR, 'example_WebCal%i' % i, str(Today().get_year()), page), 'type': 'Native', 'category': plugin.category, 'version': VERSION, 'options': opts, }) ################################################################## # GRAMPS addons reports ################################################################## addons = [] ########## AncestorFill for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'AncestorFill.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'AncestorFill', 'options': { 'off': fmt, 'of': of, }, }) ########## d3-ancestralcollapsibletree addons.append({ 'title': '"%s" report example', 'result': os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree', 'index.html'), 'i': 'd3-ancestralcollapsibletree', 'options': { 'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-ancestralcollapsibletree'), 'dest_file': 'index.html', 'pid': 'I0006', 'maxgen': 6, }, }) ########## d3-ancestralfanchart addons.append({ 'title': '"%s" report example', 'result': os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart', 'index.html'), 'i': 'd3-ancestralfanchart', 'options': { 'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-ancestralfanchart'), 'dest_file': 'index.html', 'pid': 'I0006', 'maxgen': 6, }, }) ########## d3-descendantindentedtree addons.append({ 'title': '"%s" report example', 'result': os.path.join(ADDONS_REP_DIR, 'd3-descendantindentedtree', 'index.html'), 'i': 'd3-descendantindentedtree', 'options': { 'dest_path': os.path.join(ADDONS_REP_DIR, 'd3-descendantindentedtree'), 'dest_file': 'index.html', 'pid': 'I0104', 'max_gen': 6, 'inc_private': True, 'inc_living': _INCLUDE_LIVING_VALUE, }, }) ########## denominoviso for (i, (mode, type, dir, pid, full)) in enumerate([ [0, 0, 0, 'I0001', True], [0, 3, 2, 'I0001', False], [0, 4, 2, 'I0001', False], [1, 0, 0, 'I0044', True], [1, 1, 0, 'I0044', False], ]): addons.append({ 'title': '"%%s" report example %i' % i, 'result': os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i), 'i': 'denominoviso', 'options': { 'DNMfilename': os.path.join(ADDONS_REP_DIR, 'DenominoViso%i.xhtml' % i), 'DNMchart_mode': mode, 'DNMpid': pid, 'DNMchart_type': type, 'DNMinc_attributes_m': '"True, "', 'DNMinc_addresses': full, 'DNMinc_notes': full, 'DNMinc_url': full, 'DNMinc_url_desc': full, 'DNMinc_sources': full, 'DNMinc_img': full, 'DNMcopy_img_m': '"%s, %s%i"' % (str(full), os.path.join(ADDONS_REP_DIR, 'DenominoViso'), i), }, }) ########## DescendantBook for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'DescendantBook.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'DescendantBook', 'options': { 'off': fmt, 'of': of, }, }) for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'DetailedDescendantBook.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'DetailedDescendantBook', 'options': { 'off': fmt, 'of': of, }, }) ########## Descendants Lines for fmt in GRPH_FMT: of = os.path.join(ADDONS_REP_DIR, 'DescendantsLines.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'Descendants Lines', 'options': { 'off': fmt, 'of': of, 'pid': 'I0006', }, }) ########## database-differences-report for fmt in ['html']: of = os.path.join(ADDONS_REP_DIR, 'database-differences-report.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'database-differences-report', 'options': { 'off': fmt, 'of': of, 'filename': os.path.join(os.environ['GRAMPS_RESOURCES'], 'example', 'gramps', 'example.gramps'), }, }) ########## DynamicWeb addons.extend(report_set_DynamicWeb.addon_set()) ########## FamilyTree for fmt in GRPH_FMT: of = os.path.join(ADDONS_REP_DIR, 'FamilyTree.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'FamilyTree', 'options': { 'off': fmt, 'of': of, 'pid': 'I0006', 'max_ancestor_generations': 3, 'max_descendant_generations': 3, 'papero': 1, 'protect_private': False, 'color': 1, }, }) ########## LastChangeReport for fmt in ['html']: of = os.path.join(ADDONS_REP_DIR, 'LastChangeReport.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'LastChangeReport', 'options': { 'off': fmt, 'of': of, 'what_types': '"True,True,True,True,True,True"' }, }) ########## LinesOfDescendency for fmt in ['html']: of = os.path.join(ADDONS_REP_DIR, 'LinesOfDescendency.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'LinesOfDescendency', 'options': { 'off': fmt, 'of': of, 'pid': 'I0006', 'ancestor': 'I0104', }, }) ########## ListeEclair for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'ListeEclair.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'ListeEclair', 'options': { 'off': fmt, 'of': of, }, }) ########## PedigreeChart for fmt in GRPH_FMT: of = os.path.join(ADDONS_REP_DIR, 'PedigreeChart.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'PedigreeChart', 'options': { 'off': fmt, 'of': of, 'maxgen': 6, 'pid': 'I0006', }, }) ########## PersonEverythingReport for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'PersonEverythingReport.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'PersonEverythingReport', 'options': { 'off': fmt, 'of': of, }, }) ########## Repositories Report for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReportOptions.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'Repositories Report Options', 'options': { 'off': fmt, 'of': of, }, }) for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'RepositoriesReport.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'Repositories Report', 'options': { 'off': fmt, 'of': of, }, }) ########## TodoReport reports = [] addons = [] for fmt in TEXT_FMT: of = os.path.join(ADDONS_REP_DIR, 'TodoReport.' + fmt) addons.append({ 'title': '"%%s" in format "%s"' % fmt, 'result': of, 'i': 'TodoReport', 'options': { 'off': fmt, 'of': of, 'tag': 'ToDo', }, }) ########## Check if addon exists in the addons listings for addon in addons: plugin = gpr.get_plugin(addon['i']) if not plugin: print('Unknown plugin: %s' % addon['i']) continue addon['options'].update({ 'name': addon['i'], }) addon.update({ 'title': addon['title'] % plugin.name, 'name': plugin.name, 'type': 'Addon', 'category': plugin.category, 'version': plugin.version, }) del addon['i'] reports.append(addon) return reports
def _display(self): """ organize Glade 'Import Pro-Gen' window """ # get the main window from glade self.glade = Glade('importprogen.glade') self.set_window(self.glade.toplevel, self.glade.get_object('title'), _('Import Pro-Gen')) # calculate all entries and update Glade window # Text for Source / Citation objects for obj in ('source_btn', 'citation_btn'): widget = self.glade.get_object('imp_%s' % obj) set_import = eval('self.imp_values.%s.set_value' % obj) get_import = eval('self.imp_values.%s.get_value' % obj) self.import_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) for obj in ('source_title', 'source_attr', 'citation_page', 'citation_attr'): widget = self.glade.get_object('imp_%s' % obj) set_import = eval('self.imp_values.%s.set_entry' % obj) get_import = eval('self.imp_values.%s.get_entry' % obj) self.import_methods[obj] = MonitoredEntry(\ widget, set_import, get_import, self.dbase.readonly) widget = self.glade.get_object('imp_citation_conf') self.import_methods['conf'] = MonitoredMenu( widget, self.imp_values.citation_conf.set_value, self.imp_values.citation_conf.get_value, [(_('Very Low'), Citation.CONF_VERY_LOW), (_('Low'), Citation.CONF_LOW), (_('Normal'), Citation.CONF_NORMAL), (_('High'), Citation.CONF_HIGH), (_('Very High'), Citation.CONF_VERY_HIGH)], self.dbase.readonly) widget = self.glade.get_object('imp_source_priv') get_import = eval('self.imp_values.source_priv') self.import_methods['source_priv'] = PrivacyButton(\ widget, get_import, self.dbase.readonly) widget = self.glade.get_object('imp_citation_priv') get_import = eval('self.imp_values.citation_priv') self.import_methods['citation_priv'] = PrivacyButton(\ widget, get_import, self.dbase.readonly) # Text (w. Defaults) for Tags for obj in ('text', 'fname'): widget = self.glade.get_object('tag_default_%s' % obj) set_import = eval('self.default_values.%s.set_entry' % obj) get_import = eval('self.default_values.%s.get_entry' % obj) self.default_methods[obj] = MonitoredEntry(\ widget, set_import, get_import, self.dbase.readonly) date = Today() datebase = DateBase() datebase.set_date_object(date) self.default_methods['date'] = MonitoredDate(\ self.glade.get_object('tag_default_date'), self.glade.get_object('tag_default_date_btn'), datebase.get_date_object(), self.uistate, [], self.dbase.readonly) for obj in libprogen.TAGOBJECTS: # populate object fields with values widget = self.glade.get_object('tag_%s_obj' % obj) self.tagobj_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_obj.set_value, self.tagobj_values[obj].tag_obj.get_value) widget = self.glade.get_object('tag_%s_text' % obj) self.tagtext_methods[obj] = MonitoredEntry( widget, self.tagobj_values[obj].tag_text.set_entry, self.tagobj_values[obj].tag_text.get_entry) widget = self.glade.get_object('tag_%s_fname' % obj) self.tagfname_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_fname.set_value, self.tagobj_values[obj].tag_fname.get_value) widget = self.glade.get_object('tag_%s_date' % obj) self.tagdate_methods[obj] = MonitoredCheckbox( widget, widget, self.tagobj_values[obj].tag_date.set_value, self.tagobj_values[obj].tag_date.get_value) # button's for primary objects for obj in libprogen.PRIMOBJECTS: # populate pirm. Object buttons with values widget = self.glade.get_object('prim_%s_btn' % obj) set_import = eval("self.primobj_values['%s'].set_value" % obj) get_import = eval("self.primobj_values['%s'].get_value" % obj) self.primobj_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) # button's for miscallaneous option's for obj in libprogen.OPTOBJECTS: # populate option buttons with values widget = self.glade.get_object('opt_%s_btn' % obj) set_import = eval("self.option_values['%s'].set_value" % obj) get_import = eval("self.option_values['%s'].get_value" % obj) self.option_methods[obj] = MonitoredCheckbox(\ widget, widget, set_import, get_import, self.dbase.readonly) # connect signals self.glade.connect_signals({ "on_source_button_toggled": self.__on_source_button_toggled, "on_citation_button_toggled": self.__on_citation_button_toggled, "on_import_entry_keyrelease": self.__on_import_entry_keyrelease, "on_tagtext_entry_keyrelease": self.__on_tagtext_entry_keyrelease, "on_object_button_clicked": self.__on_object_button_clicked, "on_object_button_toggled": self.__on_object_button_toggled, "on_text_button_clicked": self.__on_text_button_clicked, "on_fname_button_clicked": self.__on_fname_button_clicked, "on_fname_button_toggled": self.__on_fname_button_toggled, "on_date_button_clicked": self.__on_date_button_clicked, "on_date_button_toggled": self.__on_date_button_toggled, "on_primobj_button_toggled": self.__on_primobj_button_toggled, "on_surname_button_toggled": self.__on_surname_button_toggled, "on_x_button_clicked": self.__on_x_button_clicked, "on_help_button_clicked": self.__on_help_button_clicked, "on_cancel_button_clicked": self.__on_cancel_button_clicked, "on_ok_button_clicked": self.__on_ok_button_clicked }) # state of two objects trigged form configuration widget = self.glade.get_object('imp_source_btn') self.__on_source_button_toggled(widget) widget = self.glade.get_object('imp_citation_btn') self.__on_citation_button_toggled(widget) widget = self.glade.get_object('import_ok') widget.grab_focus() # creates a modal window and display immediatly! self.show() self.glade.toplevel.run()
def write_title(self, person): self.handle = person.handle grid = Gtk.Grid() grid.set_column_spacing(12) grid.set_row_spacing(0) # name and edit button name = name_displayer.display(person) fmt = '<span size="larger" weight="bold">%s</span>' text = fmt % escape(name) label = widgets.DualMarkupLabel(text, _GenderCode[person.gender], halign=Gtk.Align.END) if self._config.get('preferences.releditbtn'): button = widgets.IconButton(self.edit_person_button, person.handle) button.set_tooltip_text(_('Edit %s') % name) else: button = None hbox = widgets.LinkBox(label, button) if self.show_tags: tag_list = TagList(self.get_tag_list(person)) hbox.pack_start(tag_list, False, False, 0) eventbox = self.make_dragbox(hbox, 'Person', person.get_handle()) grid.attach(eventbox, 0, 0, 2, 1) subgrid = Gtk.Grid() subgrid.set_column_spacing(12) subgrid.set_row_spacing(0) eventbox = self.make_dragbox(subgrid, 'Person', person.get_handle()) grid.attach(eventbox, 1, 1, 1, 1) # GRAMPS ID subgrid.attach(widgets.BasicLabel("%s:" % _('ID')), 1, 0, 1, 1) label = widgets.BasicLabel(person.gramps_id) label.set_hexpand(True) subgrid.attach(label, 2, 0, 1, 1) # Birth event. birth = get_birth_or_fallback(self.dbstate.db, person) if birth: birth_title = birth.get_type() else: birth_title = _("Birth") subgrid.attach(widgets.BasicLabel("%s:" % birth_title), 1, 1, 1, 1) subgrid.attach(widgets.BasicLabel(self.format_event(birth)), 2, 1, 1, 1) death = get_death_or_fallback(self.dbstate.db, person) if death: death_title = death.get_type() else: death_title = _("Death") showed_death = False if birth: birth_date = birth.get_date_object() if (birth_date and birth_date.get_valid()): if death: death_date = death.get_date_object() if (death_date and death_date.get_valid()): age = death_date - birth_date subgrid.attach(widgets.BasicLabel("%s:" % death_title), 1, 2, 1, 1) subgrid.attach(widgets.BasicLabel("%s (%s)" % (self.format_event(death), age), Pango.EllipsizeMode.END), 2, 2, 1, 1) showed_death = True if not showed_death: age = Today() - birth_date if probably_alive(person, self.dbstate.db): subgrid.attach(widgets.BasicLabel("%s:" % _("Alive")), 1, 2, 1, 1) subgrid.attach(widgets.BasicLabel("(%s)" % age, Pango.EllipsizeMode.END), 2, 2, 1, 1) else: subgrid.attach(widgets.BasicLabel("%s:" % _("Death")), 1, 2, 1, 1) subgrid.attach(widgets.BasicLabel("%s (%s)" % (_("unknown"), age), Pango.EllipsizeMode.END), 2, 2, 1, 1) showed_death = True if not showed_death: subgrid.attach(widgets.BasicLabel("%s:" % death_title), 1, 2, 1, 1) subgrid.attach(widgets.BasicLabel(self.format_event(death)), 2, 2, 1, 1) mbox = Gtk.Box() mbox.add(grid) # image image_list = person.get_media_list() if image_list: button = self.get_thumbnail(image_list[0], size=SIZE_NORMAL) if button: mbox.pack_end(button, False, True, 0) mbox.show_all() return mbox