def _post_load_newdb(self, filename, title=None): """Called after load of a new database.""" if not filename: return if filename[-1] == os.path.sep: filename = filename[:-1] name = os.path.basename(filename) self.dbstate.db.db_name = title if title: name = title # apply preferred researcher if loaded file has none res = self.dbstate.db.get_researcher() owner = get_researcher() # If the DB Owner Info is empty and # [default] Researcher is not empty and # database is empty, then copy default researcher to DB owner if res.is_empty() and not owner.is_empty() and self.dbstate.db.get_total() == 0: self.dbstate.db.set_researcher(owner) name_displayer.clear_custom_formats() name_displayer.set_name_format(self.dbstate.db.name_formats) fmt_default = config.get("preferences.name-format") name_displayer.set_default_format(fmt_default) self.dbstate.db.enable_signals() self.dbstate.signal_change() config.set("paths.recent-file", filename) recent_files(filename, name)
def parse_format(self): """ Parse the Gramps format string. let the date or place classes handle any sub-format strings """ from gramps.version import VERSION from gramps.gen.utils.config import get_researcher owner = get_researcher() code = "vtd" + "elcspn" + "om" info = [ VERSION, owner.get_name(), self.db.get_dbname(), owner.get_address(), owner.get_locality(), owner.get_city(), owner.get_state(), owner.get_postal_code(), owner.get_country(), owner.get_phone(), owner.get_email() ] where = code.find(self.string_in.this) if where != -1: self.string_in.step() return info[where] return "$G"
def on_menu_activate(self, menuitem): """Copies the owner information from/to the preferences""" if menuitem.props.name == 'copy_from_preferences_to_db': self.owner.set_from(get_researcher()) for entry in self.entries: entry.update() elif menuitem.props.name == 'copy_from_db_to_preferences': for i in range(len(config_keys)): config.set(config_keys[i], self.owner.get()[i])
def on_menu_activate(self, menuitem): """Copies the owner information from/to the preferences""" if menuitem.props.name == 'copy_from_preferences_to_db': self.owner.set_from(get_researcher()) for entry in self.entries: entry.update() elif menuitem.props.name == 'copy_from_db_to_preferences': for i in range(len(config_keys)): config.set(config_keys[i], self.owner.get()[i])
def _post_load_newdb_nongui(self, filename, title=None): """ Called after a new database is loaded. """ if not filename: return if filename[-1] == os.path.sep: filename = filename[:-1] name = os.path.basename(filename) self.dbstate.db.db_name = title if title: name = title # This method is for UI stuff when the database has changed. # Window title, recent files, etc related to new file. self.dbstate.db.set_save_path(filename) # apply preferred researcher if loaded file has none res = self.dbstate.db.get_researcher() owner = get_researcher() # If the DB Owner Info is empty and # [default] Researcher is not empty and # database is empty, then copy default researcher to DB owner if (res.is_empty() and not owner.is_empty() and self.dbstate.db.get_total() == 0): self.dbstate.db.set_researcher(owner) name_displayer.set_name_format(self.dbstate.db.name_formats) fmt_default = config.get('preferences.name-format') name_displayer.set_default_format(fmt_default) self.dbstate.db.enable_signals() self.dbstate.signal_change() config.set('paths.recent-file', filename) recent_files(filename, name) self.file_loaded = True
def _post_load_newdb_nongui(self, filename, title=None): """ Called after a new database is loaded. """ if not filename: return if filename[-1] == os.path.sep: filename = filename[:-1] name = os.path.basename(filename) self.dbstate.db.db_name = title if title: name = title # This method is for UI stuff when the database has changed. # Window title, recent files, etc related to new file. self.dbstate.db.set_save_path(filename) # apply preferred researcher if loaded file has none res = self.dbstate.db.get_researcher() owner = get_researcher() # If the DB Owner Info is empty and # [default] Researcher is not empty and # database is empty, then copy default researcher to DB owner if (res.is_empty() and not owner.is_empty() and self.dbstate.db.get_total() == 0): self.dbstate.db.set_researcher(owner) name_displayer.set_name_format(self.dbstate.db.name_formats) fmt_default = config.get('preferences.name-format') name_displayer.set_default_format(fmt_default) self.dbstate.db.enable_signals() self.dbstate.signal_change() config.set('paths.recent-file', filename) recent_files(filename, name) self.file_loaded = True
def __init__(self, report, title): """ @param: report -- The instance of the main report class for this report @param: title -- Is the title of the web page """ BasePage.__init__(self, report, title) output_file, sio = self.report.create_file("contact") result = self.write_header(self._('Contact')) contactpage, head, dummy_body, outerwrapper = result # begin contact division with Html("div", class_="content", id="Contact") as section: outerwrapper += section # begin summaryarea division with Html("div", id='summaryarea') as summaryarea: section += summaryarea contactimg = self.add_image('contactimg', head, 200) if contactimg is not None: summaryarea += contactimg # get researcher information res = get_researcher() with Html("div", id='researcher') as researcher: summaryarea += researcher if res.name: res.name = res.name.replace(',,,', '') researcher += Html("h3", res.name, inline=True) if res.addr: researcher += Html("span", res.addr, id='streetaddress', inline=True) if res.locality: researcher += Html("span", res.locality, id="locality", inline=True) text = "".join([res.city, res.state, res.postal]) if text: city = Html("span", res.city, id='city', inline=True) state = Html("span", res.state, id='state', inline=True) postal = Html("span", res.postal, id='postalcode', inline=True) researcher += (city, state, postal) if res.country: researcher += Html("span", res.country, id='country', inline=True) if res.email: researcher += Html("span", id='email') + ( Html("a", res.email, href='mailto:%s' % res.email, inline=True) ) # add clear line for proper styling summaryarea += FULLCLEAR note_id = report.options['contactnote'] if note_id: note = self.r_db.get_note_from_gramps_id(note_id) if note: note_text = self.get_note_format(note, False) # attach note summaryarea += note_text # add clearline for proper styling # add footer section footer = self.write_footer(None) outerwrapper += (FULLCLEAR, footer) # send page out for porcessing # and close the file self.xhtml_writer(contactpage, output_file, sio, 0)
def __init__(self, report, title): """ @param: report -- The instance of the main report class for this report @param: title -- Is the title of the web page """ BasePage.__init__(self, report, title) output_file, sio = self.report.create_file("contact") contactpage, head, body = self.write_header(self._('Contact')) # begin contact division with Html("div", class_="content", id="Contact") as section: body += section # begin summaryarea division with Html("div", id='summaryarea') as summaryarea: section += summaryarea contactimg = self.add_image('contactimg', 200) if contactimg is not None: summaryarea += contactimg # get researcher information res = get_researcher() with Html("div", id='researcher') as researcher: summaryarea += researcher if res.name: res.name = res.name.replace(',,,', '') researcher += Html("h3", res.name, inline=True) if res.addr: researcher += Html("span", res.addr, id='streetaddress', inline=True) if res.locality: researcher += Html("span", res.locality, id="locality", inline=True) text = "".join([res.city, res.state, res.postal]) if text: city = Html("span", res.city, id='city', inline=True) state = Html("span", res.state, id='state', inline=True) postal = Html("span", res.postal, id='postalcode', inline=True) researcher += (city, state, postal) if res.country: researcher += Html("span", res.country, id='country', inline=True) if res.email: researcher += Html("span", id='email') + ( Html("a", res.email, href='mailto:%s' % res.email, inline=True) ) # add clear line for proper styling summaryarea += FULLCLEAR note_id = report.options['contactnote'] if note_id: note = self.r_db.get_note_from_gramps_id(note_id) note_text = self.get_note_format(note, False) # attach note summaryarea += note_text # add clearline for proper styling # add footer section footer = self.write_footer(None) body += (FULLCLEAR, footer) # send page out for porcessing # and close the file self.xhtml_writer(contactpage, output_file, sio, 0)