GEP18: add hint for indicators, add tooltips, again remove some fields

svn: r22519
This commit is contained in:
Benny Malengier 2013-06-19 06:56:52 +00:00
parent 3a42651fb1
commit 2b6ee1aa60
6 changed files with 9990 additions and 6469 deletions

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,8 @@ SHORTERCOL = 12
STYLECOL = 13 STYLECOL = 13
PRIVACYCOL = 14 PRIVACYCOL = 14
OPTCOL = 15 OPTCOL = 15
HINTCOL = 16
TOOLTIPCOL = 17
CITE_TYPES = {'F': 'REF_TYPE_F', 'L': 'REF_TYPE_L', 'S': 'REF_TYPE_S'} CITE_TYPES = {'F': 'REF_TYPE_F', 'L': 'REF_TYPE_L', 'S': 'REF_TYPE_S'}
GEDCOMFIELDS = {'A': 'GED_AUTHOR', 'T': 'GED_TITLE', GEDCOMFIELDS = {'A': 'GED_AUTHOR', 'T': 'GED_TITLE',
@ -64,6 +66,202 @@ SHORTERALG = {'LOC': 'SHORTERALG_LOC', 'YEAR': 'SHORTERALG_YEAR',
STYLES = {'Quoted': 'STYLE_QUOTE', 'Italics': 'STYLE_EMPH', STYLES = {'Quoted': 'STYLE_QUOTE', 'Italics': 'STYLE_EMPH',
'QuotedCont': 'STYLE_QUOTECONT', 'Bold': 'STYLE_BOLD'} 'QuotedCont': 'STYLE_QUOTECONT', 'Bold': 'STYLE_BOLD'}
DEFAULT_HINTS = {
"ACT": "Public Law 12-98",
"ADDRESS": "Broadway Avenue, New York",
"AFFILIATION": "Agent of Gramps Software",
"AUTHOR": "Doe, D.P. & Cameron, E.",
"AUTHOR_LOCATION": "Chicago",
"BOOK": "The big example Gramps manual",
"CASE": "B. Malengier versus N. Hall",
"CEMETERY": "Greenwich Cemetery Office",
"CHAPTER": "The first office of T. Rooseveld",
"CHAPTER_PAGES": "24-55",
"COLLECTION": "Bruges Lace Collection",
"COLUMN": "col. 3",
"COMPILER": "T. Da Silva",
"CREATION_DATE": "13 Aug 1965",
"CREATOR": "P. Picasso",
"CREDIT_LINE": "Based on unnamed document lost in fire",
"DATE": "17 Sep 1745",
"DATE_ACCESSED": "18 Jun 2013",
"DATE_RANGE": "2003-6",
"DESCRIPTION": "The lace has inscriptions with names of nobility",
"DISTRICT": "Enumeration district (ED) 14",
"DIVISION": "Peterburg Post Office, or Portland, ward 4",
"EDITION": "Second Edition",
"EDITOR": "Hoover, J.E.",
"FILE": "Membership application J. Rapinat",
"FILE_DATE": "15 Jan 1870",
"FILE_LOCATION": "Accession 7, Box 3",
"FILE_NO": "1243-EB-98",
"FILE_UNIT": "Letters to George Washington",
"FILM_ID": "T345",
"FILM_PUBLICATION_PLACE": "Kansas City",
"FILM_PUBLISHER": "NY Genealogy Association",
"FILM_TYPE": "FHL microfilm",
"FORMAT": "Digital Images, or Database, or Cards, ...",
"FRAME": "frames 387-432",
"GROUP": "Miami Patent Office",
"HOUSEHOLD": "dwelling 345, family 654",
"ID": "I50-68, or 1910 U.S. census, or ...",
"INSTITUTION": "Sorbonne University",
"INTERVIEWER": "Materley, B.",
"ISSUE_DATE": "Jun 2004",
"ISSUE_RANGE": "145-394, scattered issues",
"ITEM_OF_INTEREST": "entry for G. Galileo, or Doe Household, or A. Einstein Grave ...",
"JURISDICTION": "Jackson County, Alabama",
"LOCATION": "Istanbul",
"NUMBER": "2, or Record Group 34, or ...",
"NUMBER_6TOTAL9": "5",
"ORIGINAL_REPOSITORY": "National Archives",
"ORIGINAL_REPOSITORY_LOCATION": "Washington, D.C.",
"ORIGINAL_YEAR": "1966",
"PAGE": "5; or 4,6-8, ...",
"PAGE_RANGE": "1-13",
"PART": "Part 3",
"PLACE_CREATED": "London",
"POSITION": "written in the left margin, or second row, 3th line",
"POSTING_DATE": "5 Jul 1799",
"PROFESSIONAL_CREDENTIALS": "Prof.; or Dr. ...",
"PROVENANCE": "add provenance of the material",
"PUBLICATION_FORMAT": "CD-ROM or eprint or ...",
"PUBLICATION_PLACE": "Berlin",
"PUBLICATION_TITLE": "Title of Blog, Newsletter, DVD, ...",
"PUBLICATION_YEAR": "2014",
"PUBLISHER": "Springer",
"PUB_INFO": "Springer, Berlin, 2014",
"RECIPIENT": "J. Ralls",
"RELATIONSHIP": "Paul's uncle and brother of Erik",
"REPORT_DATE": "3 May 1999",
"RESEARCH_COMMENT": "Descriptive detail or provenance or research analysis conclusion, ...",
"RESEARCH_PROJECT": "Tahiti Natives",
"ROLL": "176, or rolls 145-160",
"SCHEDULE": "population schedule or slave schedule or ...",
"SECTION": "1890 section or ER patients or ...",
"SERIES": "Carnival County Records",
"SERIES_NO": "series 34-38",
"SESSION": "2nd session",
"SHEET_NO": "sheet 13-C",
"SUBGROUP": "Diplomatic correspondance, 1798-1810",
"SUBJECT": "D. Copernicus and close family",
"SUBSERIES": "",
"SUBTITLE": "Subtitle of article or magazine ...",
"TERM": "June Term 1934 or 13th Congress or Reagan Office or ...",
"TIMESTAMP": "min. 34-36",
"TITLE": "Diary Title, Message Title, Bible Name, Article Title, ...",
"TRANSLATION": "A translated version, typically of the title",
"TYPE": "Letter",
"URL_6DIGITAL_LOCATION9": "http://gramps-project.org/blog",
"VOLUME": "4",
"VOLUME_INFO": "5 volumes",
"WEBSITE": "gramps-project.org",
"WEBSITE_CREATOR_OR_OWNER": "Family Historians Inc",
"YEAR": "1888",
"YEAR_ACCESSED": "2013",
}
DEFAULT_TOOLTIPS = {
"ACT": "A statute or law name passed by a legislature",
"ADDRESS": "Store address information. Set Private if needed! Give"
" information from lowest to highest level separated by comma's",
"AFFILIATION": "A relevant affiliation that might influence data in the source",
"AUTHOR": "Give names in following form: 'FirstAuthorSurname, Given Names & SecondAuthorSurname, Given Names'."
" Like this Gramps can parse the name and shorten as needed.",
"AUTHOR_LOCATION": "City where author resides or wrote.",
"BOOK": "Title of the Book",
"CASE": "Dispute between opposing parties in a court of law.",
"CEMETERY": "Name of cemetery or cemetery office with sources.",
"CHAPTER": "",
"CHAPTER_PAGES": "The pages in the chapter.",
"COLLECTION": "",
"COLUMN": "",
"COMPILER": "The name of the person who compiled the source.",
"CREATION_DATE": "",
"CREATOR": "The name of the creator of the artifact.",
"CREDIT_LINE": "Acknowledgement of writers and contributors",
"DATE": "",
"DATE_ACCESSED": "",
"DATE_RANGE": "The range of years which are present in the source.",
"DESCRIPTION": "Some important detail of the source.",
"DISTRICT": "District as handled by Census",
"DIVISION": "The subdivision of a larger group that is handled in the source.",
"EDITION": "",
"EDITOR": "The Editor of a multi-author book.",
"FILE": "The title of a specific file in a source.",
"FILE_DATE": "Date of submitting the document to a clerk or court.",
"FILE_LOCATION": "Accession method to the file",
"FILE_NO": "Number to indicate a file",
"FILE_UNIT": "A grouping unit for a number of files in a source.",
"FILM_ID": "ID of a Microfilm.",
"FILM_PUBLICATION_PLACE": "",
"FILM_PUBLISHER": "",
"FILM_TYPE": "The type of the microfilm.",
"FORMAT": "The format of the source.",
"FRAME": "What frames in the source are relevant.",
"GROUP": "A larger grouping to which the source belongs.",
"HOUSEHOLD": "Household of interest on a census.",
"ID": "ID to identify the source or citation part",
"INSTITUTION": "Institution that issued the source.",
"INTERVIEWER": "",
"ISSUE_DATE": "Date the source was issued.",
"ISSUE_RANGE": "A range of magazine, journal, ... issues covered in the source",
"ITEM_OF_INTEREST": "Specific part, item, or person of interest in the source",
"JURISDICTION": "Area with a set of laws under the control of a system of courts or government entity."
" Enter this from lowest to highest relevant jurisdiction, separated by comma's.",
"LOCATION": "City that is relevant.",
"NUMBER": "A number.",
"NUMBER_6TOTAL9": "The maximum of entities available.",
"ORIGINAL_REPOSITORY": "Name of the repository where the original is stored.",
"ORIGINAL_REPOSITORY_LOCATION": "Address or only city of the repository where the original is stored.",
"ORIGINAL_YEAR": "Year the original source was published/created",
"PAGE": "The page or page(s) relevant for the citation",
"PAGE_RANGE": "The range of the pages in the source. The page given for"
" a citation must be in this range.",
"PART": "",
"PLACE_CREATED": "",
"POSITION": "Where in or on the source the citation piece can be found.",
"POSTING_DATE": "",
"PROFESSIONAL_CREDENTIALS": "",
"PROVENANCE": "Where the material originated from.",
"PUBLICATION_FORMAT": "",
"PUBLICATION_PLACE": "",
"PUBLICATION_TITLE": "",
"PUBLICATION_YEAR": "",
"PUBLISHER": "",
"PUB_INFO": "Publication Information, such as city and year of publication, name of publisher, ...",
"RECIPIENT": "The person to who the letter is addressed.",
"RELATIONSHIP": "The relationship of the author to the person of interest that is the subject.",
"REPORT_DATE": "Date the report was written/submitted.",
"RESEARCH_COMMENT": "Descriptive detail or provenance or research analysis conclusion, ...",
"RESEARCH_PROJECT": "The genealogical or scientific research project.",
"ROLL": "The Microfilm role.",
"SCHEDULE": "The census schedule (the type of census table) used, eg population schedule or slave schedule. or ...",
"SECTION": "",
"SERIES": "",
"SERIES_NO": "",
"SESSION": "The number of the meeting or series of connected meetings devoted "
"by a legislature to a single order of business, program, agenda, or announced purpose.",
"SHEET_NO": "Number of a census sheet.",
"SUBGROUP": "",
"SUBJECT": "",
"SUBSERIES": "",
"SUBTITLE": "",
"TERM": "Reference to the time a person/group/parliament is in office or session.",
"TIMESTAMP": "Indication of the time in audio or video where the relevant fragment can be found.",
"TITLE": "",
"TRANSLATION": "A translated version, typically of the title",
"TYPE": "",
"URL_6DIGITAL_LOCATION9": "Detailed internet address of the content",
"VOLUME": "",
"VOLUME_INFO": "Information about the volumes, eg the amount of volumes.",
"WEBSITE": "The main internet address.",
"WEBSITE_CREATOR_OR_OWNER": "Organization or person behind a website.",
"YEAR": "",
"YEAR_ACCESSED": "",
}
nr = -1 nr = -1
cat = '' cat = ''
cattype = '' cattype = ''
@ -166,10 +364,12 @@ with open(csvfilename, 'rb') as csvfile:
shorteralg = SHORTERALG.get(row[SHORTERCOL].strip()) or 'EMPTY' shorteralg = SHORTERALG.get(row[SHORTERCOL].strip()) or 'EMPTY'
gedcommap = GEDCOMFIELDS.get(row[GEDCOMCOL].strip()) or 'EMPTY' gedcommap = GEDCOMFIELDS.get(row[GEDCOMCOL].strip()) or 'EMPTY'
style = STYLES.get(row[STYLECOL].strip()) or 'EMPTY' style = STYLES.get(row[STYLECOL].strip()) or 'EMPTY'
hint = row[HINTCOL]
tooltip = row[TOOLTIPCOL]
TYPE2CITEMAP[source_type][cite_type] += [(row[LDELCOL], field_type, TYPE2CITEMAP[source_type][cite_type] += [(row[LDELCOL], field_type,
row[RDELCOL], field_label, style, private, optional, row[RDELCOL], field_label, style, private, optional,
shorteralg, gedcommap)] shorteralg, gedcommap, hint, tooltip)]
#if shorttype, we store a type for the short version so user can store #if shorttype, we store a type for the short version so user can store
#this #this
if shortcite and shorteralg == 'EMPTY': if shortcite and shorteralg == 'EMPTY':
@ -195,6 +395,19 @@ for field in FIELDS_SHORT:
code += " " + field + ',\n' code += " " + field + ',\n'
code += ' ]\n\n' + datamap + ' ]\n' code += ' ]\n\n' + datamap + ' ]\n'
#now add default hints
code += "\n _DEFAULT_HINTS = {\n"
for key in sorted(DEFAULT_HINTS.keys()):
if DEFAULT_HINTS[key]:
code += " " + key +': _("' + DEFAULT_HINTS[key] + '"),\n'
code += " }\n"
#now add default tooltips
code += "\n _DEFAULT_TOOLTIPS = {\n"
for key in sorted(DEFAULT_TOOLTIPS.keys()):
if DEFAULT_TOOLTIPS[key]:
code += " " + key + ': _("' + DEFAULT_TOOLTIPS[key] + '"),\n'
code += " }\n"
with open('srcattrtype_extra.py', 'wb') as srcattrfile: with open('srcattrtype_extra.py', 'wb') as srcattrfile:
srcattrfile.write(code) srcattrfile.write(code)
@ -229,10 +442,19 @@ for source_type in allkeys:
for field in TYPE2CITEMAP[source_type][val]: for field in TYPE2CITEMAP[source_type][val]:
# field is tuple (row[LDELCOL], field_type, row[RDELCOL], # field is tuple (row[LDELCOL], field_type, row[RDELCOL],
# field_label, row[STYLECOL] # field_label, row[STYLECOL]
# , private, optional, shorteralg, gedcommap) # , private, optional, shorteralg, gedcommap, hint, tooltip)
if field[9]:
hint = '_("' + field[9] + '")'
else:
hint = 'None'
if field[10]:
tooltip = '_("' + field[10] + '")'
else:
tooltip = 'None'
code += " ('"+ field[0] + "', " + field[1] + ", _('"\ code += " ('"+ field[0] + "', " + field[1] + ", _('"\
+field[3] + "'), '"+ field[2] + "', " + field[4] + ", " + field[5] + ", "\ +field[3] + "'), '"+ field[2] + "', " + field[4] + ", " + field[5] + ", "\
+ field[6] + ", " + field[7] + ", " + field[8] + "),\n" + field[6] + ", " + field[7] + ", " + field[8] + ",\n" \
+ " " +hint + ", " + tooltip + "),\n"
code += " ],\n" code += " ],\n"
code += " },\n" code += " },\n"
code += " }\n" code += " }\n"

File diff suppressed because it is too large Load Diff

View File

@ -250,11 +250,11 @@ class SrcTemplate(object):
""" """
reflist = self.tempstruct[reftype] reflist = self.tempstruct[reftype]
# reflist is typically a list like # reflist is typically a list like
# [ ('', AUTHOR, '', ',', EMPTY, False, False, EMPTY, EMPTY), # [ ('', AUTHOR, '', ',', EMPTY, False, False, EMPTY, EMPTY, None, None),
# ('', TITLE, '', ',', STYLE_QUOTE, False, False, EMPTY, EMPTY), # ('', TITLE, '', ',', STYLE_QUOTE, False, False, EMPTY, EMPTY, None, None),
# ('', PUB_INFO, '', '.', EMPTY, False, False, EMPTY, EMPTY), # ('', PUB_INFO, '', '.', EMPTY, False, False, EMPTY, EMPTY, None, None),
# ('', DATE, '', ' -', EMPTY, False, False, EMPTY, EMPTY), # ('', DATE, '', ' -', EMPTY, False, False, EMPTY, EMPTY, None, None),
# ('', PAGE, 'Page(s)', '.', EMPTY, False, False, EMPTY, EMPTY), # ('', PAGE, 'Page(s)', '.', EMPTY, False, False, EMPTY, EMPTY, None, None),
# ] # ]
#set col of attrmap to use: #set col of attrmap to use:
@ -266,7 +266,8 @@ class SrcTemplate(object):
COL_SHORT = 2 COL_SHORT = 2
ref = [''] ref = ['']
fieldadded = [False] fieldadded = [False]
for (ldel, field, label, rdel, style, priv, opt, short, gedcom) in reflist: for (ldel, field, label, rdel, style, priv, opt, short, gedcom,
hint, tooltip) in reflist:
if not gedcomfield is None and gedcom != gedcomfield: if not gedcomfield is None and gedcom != gedcomfield:
continue continue
customshort = False customshort = False

View File

@ -46,7 +46,7 @@ from gramps.gen.lib.srcattrtype import (SrcAttributeType, REF_TYPE_F,
from gramps.gen.lib import SrcAttribute, SrcTemplate from gramps.gen.lib import SrcAttribute, SrcTemplate
from ...autocomp import StandardCustomSelector from ...autocomp import StandardCustomSelector
from ...widgets.srctemplatetreeview import SrcTemplateTreeView from ...widgets.srctemplatetreeview import SrcTemplateTreeView
from ...widgets import UndoableEntry, MonitoredEntry from ...widgets import UndoableEntry, MonitoredEntryIndicator
from .grampstab import GrampsTab from .grampstab import GrampsTab
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -220,10 +220,14 @@ class TemplateFields(object):
# now add new fields # now add new fields
fieldsL = [] fieldsL = []
for fielddef in template[REF_TYPE_L]: for fielddef in template[REF_TYPE_L]:
hint = fielddef[9] or SrcAttributeType.get_default_hint(fielddef[1])
fieldsL.append(fielddef[1]) fieldsL.append(fielddef[1])
if self.cite is None: if self.cite is None:
#these are source fields #these are source fields
self._add_entry(row, fielddef[1], fielddef[2]) self._add_entry(row, fielddef[1], fielddef[2],
fielddef[9] or SrcAttributeType.get_default_hint(fielddef[1]),
fielddef[10] or SrcAttributeType.get_default_tooltip(fielddef[1]))
row += 1 row += 1
tempsattrt = SrcAttributeType() tempsattrt = SrcAttributeType()
@ -259,7 +263,9 @@ class TemplateFields(object):
self.lbls.append(lbl) self.lbls.append(lbl)
row += 1 row += 1
for fielddef in fieldsF: for fielddef in fieldsF:
self._add_entry(row, fielddef[1], fielddef[2]) self._add_entry(row, fielddef[1], fielddef[2],
fielddef[9] or SrcAttributeType.get_default_hint(fielddef[1]),
fielddef[10] or SrcAttributeType.get_default_tooltip(fielddef[1]))
row += 1 row += 1
fieldsS = [fielddef for fielddef in template[REF_TYPE_S] fieldsS = [fielddef for fielddef in template[REF_TYPE_S]
if fielddef[1] not in fieldsL and fielddef[7]==EMPTY] if fielddef[1] not in fieldsL and fielddef[7]==EMPTY]
@ -283,7 +289,7 @@ class TemplateFields(object):
self.gridfields.show_all() self.gridfields.show_all()
def _add_entry(self, row, srcattrtype, alt_label): def _add_entry(self, row, srcattrtype, alt_label, hint=None, tooltip=None):
""" """
Add an entryfield to the grid of fields at row row, to edit the given Add an entryfield to the grid of fields at row row, to edit the given
srcattrtype value. Use alt_label if given to indicate the field srcattrtype value. Use alt_label if given to indicate the field
@ -306,14 +312,18 @@ class TemplateFields(object):
inpt = UndoableEntry() inpt = UndoableEntry()
inpt.set_halign(Gtk.Align.FILL) inpt.set_halign(Gtk.Align.FILL)
inpt.set_hexpand(True) inpt.set_hexpand(True)
if tooltip:
inpt.set_tooltip_text(tooltip)
self.gridfields.attach(inpt, 1, row-1, 1, 1) self.gridfields.attach(inpt, 1, row-1, 1, 1)
self.inpts.append(inpt) self.inpts.append(inpt)
if self.cite: if self.cite:
MonitoredEntry(inpt, self.set_cite_field, self.get_cite_field, MonitoredEntryIndicator(inpt, self.set_cite_field, self.get_cite_field,
hint or "",
read_only=self.db.readonly, read_only=self.db.readonly,
parameter=srcattrtype) parameter=srcattrtype)
else: else:
MonitoredEntry(inpt, self.set_src_field, self.get_src_field, MonitoredEntryIndicator(inpt, self.set_src_field, self.get_src_field,
hint or "",
read_only=self.db.readonly, read_only=self.db.readonly,
parameter=srcattrtype) parameter=srcattrtype)

View File

@ -192,18 +192,20 @@ class MonitoredEntryIndicator(MonitoredEntry):
entry becomes active entry becomes active
""" """
def __init__(self, obj, set_val, get_val, indicator, read_only=False, def __init__(self, obj, set_val, get_val, indicator, read_only=False,
autolist=None, changed=None): autolist=None, changed=None, parameter=None):
MonitoredEntry.__init__(self, obj, set_val, get_val, read_only, MonitoredEntry.__init__(self, obj, set_val, get_val, read_only,
autolist, changed) autolist, changed, parameter)
self.origcolor = obj.get_style_context().get_color(Gtk.StateType.NORMAL)
if self.get_val(None): if self.get_val(None):
self.indicatorshown = False self.indicatorshown = False
else: else:
self.indicatorshown = True self.indicatorshown = True
self.indicator = indicator self.indicator = indicator
self.obj.set_text(indicator) self.obj.set_text(indicator)
self.obj.modify_text(Gtk.StateType.NORMAL, rgba = Gdk.RGBA()
Gdk.color_parse('grey')) Gdk.RGBA.parse(rgba, 'grey')
self.obj.modify_font(Pango.FontDescription('sans italic')) self.obj.override_color(Gtk.StateType.NORMAL, rgba)
self.obj.override_font(Pango.FontDescription('sans italic'))
self.fockey = self.obj.connect('focus-in-event', self.fockey = self.obj.connect('focus-in-event',
self._obj_focus) self._obj_focus)
@ -218,8 +220,8 @@ class MonitoredEntryIndicator(MonitoredEntry):
callback for when prefix obtains focus callback for when prefix obtains focus
""" """
self.set_text('') self.set_text('')
self.obj.modify_text(Gtk.StateType.NORMAL, Gdk.color_parse('black')) self.obj.override_color(Gtk.StateType.NORMAL, self.origcolor)
self.obj.modify_font(Pango.FontDescription('normal')) self.obj.override_font(Pango.FontDescription('normal'))
self.obj.disconnect(self.fockey) self.obj.disconnect(self.fockey)
self.indicatorshown = False self.indicatorshown = False
return False return False