Skip to content

Commit

Permalink
Add source icon to editor dialogs
Browse files Browse the repository at this point in the history
Implements #11372.
  • Loading branch information
prismatisch authored and Nick-Hall committed Feb 27, 2022
1 parent 557c1c7 commit 990d4ed
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 39 deletions.
9 changes: 9 additions & 0 deletions gramps/gen/lib/citationbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ def get_citation_list(self):
"""
return self.citation_list

def has_citations(self):
"""
Return True if citations exist for this object.
:returns: Returns whether citations exist for this object.
:rtype: bool
"""
return bool(self.get_citation_list())

def get_all_citation_lists(self):
"""
Return the list of :class:`~.citation.Citation` handles associated with
Expand Down
7 changes: 4 additions & 3 deletions gramps/gui/editors/displaytabs/addrembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AddrEmbedList(EmbeddedList):
Derives from the EmbeddedList class.
"""

_HANDLE_COL = 9
_HANDLE_COL = 10
_DND_TYPE = DdTargets.ADDRESS

_MSG = {
Expand All @@ -76,7 +76,8 @@ class AddrEmbedList(EmbeddedList):
(_('Country'), 5, 75, TEXT_COL, -1, None),
(_("Postal"), 6, 75, TEXT_COL, -1, None),
(_("Phone"), 7, 150, TEXT_COL, -1, None),
(_('Private'), 8, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 8, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 9, 30, ICON_COL, -1, 'gramps-lock'),
]

def __init__(self, dbstate, uistate, track, data):
Expand All @@ -100,7 +101,7 @@ def column_order(self):
"""
Return the column order of the columns in the display tab.
"""
return ((1,8), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7))
return ((1, 8), (1, 9), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7))

def add_button_clicked(self, obj):
"""
Expand Down
4 changes: 3 additions & 1 deletion gramps/gui/editors/displaytabs/addressmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(self, obj_list, dbase):
"""
AddressModel derives from the ListStore, defining te items in the list
"""
Gtk.ListStore.__init__(self, str, str, str, str, str, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, str, str, str, str, str,
bool, bool, object)
self.db = dbase
for obj in obj_list:
self.append(row=[
Expand All @@ -62,6 +63,7 @@ def __init__(self, obj_list, dbase):
obj.country,
obj.postal,
obj.phone,
obj.has_citations(),
obj.get_privacy(),
obj,
])
7 changes: 4 additions & 3 deletions gramps/gui/editors/displaytabs/attrembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#-------------------------------------------------------------------------
class AttrEmbedList(EmbeddedList):

_HANDLE_COL = 3
_HANDLE_COL = 4
_DND_TYPE = DdTargets.ATTRIBUTE

_MSG = {
Expand All @@ -61,7 +61,8 @@ class AttrEmbedList(EmbeddedList):
_column_names = [
(_('Type'), 0, 250, TEXT_COL, -1, None),
(_('Value'), 1, 200, TEXT_COL, -1, None),
(_('Private'), 2, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 2, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 3, 30, ICON_COL, -1, 'gramps-lock'),
]

def __init__(self, dbstate, uistate, track, data):
Expand Down Expand Up @@ -89,7 +90,7 @@ def get_data(self):
return self.data

def column_order(self):
return ((1, 2), (1, 0), (1, 1))
return ((1, 2), (1, 3), (1, 0), (1, 1))

def add_button_clicked(self, obj):
pname = ''
Expand Down
4 changes: 2 additions & 2 deletions gramps/gui/editors/displaytabs/attrmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#
#-------------------------------------------------------------------------
from gi.repository import Gtk

#-------------------------------------------------------------------------
#
# Gramps classes
Expand All @@ -40,12 +39,13 @@
class AttrModel(Gtk.ListStore):

def __init__(self, attr_list, db):
Gtk.ListStore.__init__(self, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, bool, bool, object)
self.db = db
for attr in attr_list:
self.append(row=[
str(attr.get_type()),
attr.get_value(),
attr.has_citations(),
attr.get_privacy(),
attr,
])
3 changes: 2 additions & 1 deletion gramps/gui/editors/displaytabs/childmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ChildModel(Gtk.ListStore):

def __init__(self, child_ref_list, db):
Gtk.ListStore.__init__(self, int, str, str, str, str, str,
str, str, str, str, str, str, str, bool, object)
str, str, str, str, str, str, str, bool, bool, object)
self.db = db
for index, child_ref in enumerate(child_ref_list):
child = db.get_person_from_handle(child_ref.ref)
Expand All @@ -66,6 +66,7 @@ def __init__(self, child_ref_list, db):
name_displayer.sort_string(child.primary_name),
self.column_birth_sort(child),
self.column_death_sort(child),
child_ref.has_citations(),
child_ref.get_privacy(),
child_ref
])
Expand Down
4 changes: 3 additions & 1 deletion gramps/gui/editors/displaytabs/eventembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
None,
(_('Age'), EventRefModel.COL_SORTAGE[0], 60, TEXT_COL, -1, None),
None,
(_('Private'), EventRefModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock')
(_('Private'), EventRefModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock'),
(_('Source'), EventRefModel.COL_HAS_SOURCE[0], 30, ICON_COL, -1, 'gramps-source'),
]

def __init__(self, dbstate, uistate, track, obj, build_model=EventRefModel, **kwargs):
Expand Down Expand Up @@ -196,6 +197,7 @@ def column_order(self):
(1, 3), # date
(1, 4), # place
(1, 6), # main participants
(1, 13), # has source
(1, 12), # private
(1, 5), # role
(1, 2), # gramps id
Expand Down
6 changes: 4 additions & 2 deletions gramps/gui/editors/displaytabs/eventrefmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ class EventRefModel(Gtk.TreeStore):
COL_AGE = (10, str)
COL_SORTAGE = (11, str)
COL_PRIVATE = (12, bool)
COL_HAS_SOURCE = (13, bool)

COLS = (COL_DESCR, COL_TYPE, COL_GID, COL_DATE, COL_PLACE, COL_ROLE,
COL_PARTIC, COL_SORTDATE, COL_EVENTREF, COL_FONTWEIGHT, COL_AGE,
COL_SORTAGE, COL_PRIVATE)
COL_SORTAGE, COL_PRIVATE, COL_HAS_SOURCE)

def __init__(self, event_list, db, groups, **kwargs):
"""
Expand All @@ -114,7 +115,7 @@ def row_group(self, index, group):
name = self.namegroup(index, len(group))
spouse = self.groups[index][2]
return [spouse, name, '', '', '', '', '', '', (index, None),
WEIGHT_BOLD, '', '', None]
WEIGHT_BOLD, '', '', None, None]

def namegroup(self, groupindex, length):
return self._GROUPSTRING % {'groupname': self.groups[groupindex][1],
Expand All @@ -134,6 +135,7 @@ def row(self, index, eventref, event):
self.column_age(event),
self.column_sort_age(event),
eventref.get_privacy(),
event.has_citations(),
]

def colweight(self, index):
Expand Down
7 changes: 4 additions & 3 deletions gramps/gui/editors/displaytabs/familyldsembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#-------------------------------------------------------------------------
class FamilyLdsEmbedList(LdsEmbedList):

_HANDLE_COL = 6
_HANDLE_COL = 7
# _DND_TYPE = DdTargets.ADDRESS

#index = column in model. Value =
Expand All @@ -52,8 +52,9 @@ class FamilyLdsEmbedList(LdsEmbedList):
(_('Date'), 1, 150, MARKUP_COL, -1, None),
(_('Status'), 3, 75, TEXT_COL, -1, None),
(_('Temple'), 2, 200, TEXT_COL, -1, None),
(_('Place'), 3, 100, TEXT_COL, -1, None),
(_('Private'), 5, 30, ICON_COL, -1, 'gramps-lock')
(_('Place'), 4, 100, TEXT_COL, -1, None),
(_('Source'), 5, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 6, 30, ICON_COL, -1, 'gramps-lock'),
]

def __init__(self, dbstate, uistate, track, data):
Expand Down
9 changes: 5 additions & 4 deletions gramps/gui/editors/displaytabs/ldsembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#-------------------------------------------------------------------------
class LdsEmbedList(EmbeddedList):

_HANDLE_COL = 6
_HANDLE_COL = 7
# _DND_TYPE = DdTargets.ADDRESS

_MSG = {
Expand All @@ -62,8 +62,9 @@ class LdsEmbedList(EmbeddedList):
(_('Date'), 1, 150, MARKUP_COL, -1, None),
(_('Status'), 3, 75, TEXT_COL, -1, None),
(_('Temple'), 2, 200, TEXT_COL, -1, None),
(_('Place'), 3, 100, TEXT_COL, -1, None),
(_('Private'), 5, 30, ICON_COL, -1, 'gramps-lock')
(_('Place'), 4, 100, TEXT_COL, -1, None),
(_('Source'), 5, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 6, 30, ICON_COL, -1, 'gramps-lock'),
]

def __init__(self, dbstate, uistate, track, data):
Expand All @@ -82,7 +83,7 @@ def get_data(self):
return self.data

def column_order(self):
return ((1, 5), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4))
return ((1, 5), (1, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4))

def add_button_clicked(self, obj):
try:
Expand Down
5 changes: 3 additions & 2 deletions gramps/gui/editors/displaytabs/ldsmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
#-------------------------------------------------------------------------
class LdsModel(Gtk.ListStore):

_HANDLE_COL = 5
_HANDLE_COL = 6

def __init__(self, lds_list, db):
Gtk.ListStore.__init__(self, str, str, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, str, str, bool, bool, object)

for lds_ord in lds_list:
self.append(row=[
Expand All @@ -59,6 +59,7 @@ def __init__(self, lds_list, db):
lds_ord.status2str(),
TEMPLES.name(lds_ord.get_temple()),
place_displayer.display_event(db, lds_ord),
lds_ord.has_citations(),
lds_ord.get_privacy(),
lds_ord,
])
4 changes: 2 additions & 2 deletions gramps/gui/editors/displaytabs/nameembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NameEmbedList(GroupEmbeddedList):
None,
None,
(_('Group As'), NameModel.COL_GROUPAS[0],100, TEXT_COL, -1, None),
(_('Source'), NameModel.COL_HASSOURCE[0],60, TEXT_COL, -1, None),
(_('Source'), NameModel.COL_HASSOURCE[0],30, ICON_COL, -1, "gramps-source"),
(_('Notes Preview'), NameModel.COL_NOTEPREVIEW[0], 250, TEXT_COL, -1, None),
(_('Private'), NameModel.COL_PRIVATE[0], 30, ICON_COL, -1, 'gramps-lock')
]
Expand Down Expand Up @@ -114,7 +114,7 @@ def column_order(self):
The columns to show as a tuple of tuples containing
tuples (show/noshow, model column)
"""
return ((1, 0), (1, 7), (1, 1), (1, 4), (1, 5), (1, 6))
return ((1, 0), (1, 5), (1, 7), (1, 1), (1, 4), (1, 6))

def get_popup_menu_items(self):
if self._tmpgroup == self._WORKGROUP:
Expand Down
9 changes: 2 additions & 7 deletions gramps/gui/editors/displaytabs/namemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NameModel(Gtk.TreeStore):
COL_DATA = (2, object)
COL_FONTWEIGHT = (3, int)
COL_GROUPAS = (4, str)
COL_HASSOURCE = (5, str)
COL_HASSOURCE = (5, bool)
COL_NOTEPREVIEW = (6, str)
COL_PRIVATE = (7, bool)

Expand Down Expand Up @@ -109,7 +109,7 @@ def row(self, index, name):
(index, name),
self.colweight(index),
name.get_group_as(),
self.hassource(name),
name.has_citations(),
self.notepreview(name),
name.get_privacy(),
]
Expand All @@ -134,11 +134,6 @@ def update_defname(self, defname):
self.insert(self.get_iter(self.DEFINDEX), 0,
row=self.row(self.DEFINDEX, defname))

def hassource(self, name):
if len(name.get_citation_list()):
return YES
return NO

def notepreview(self, name):
nlist = name.get_note_list()
if nlist:
Expand Down
7 changes: 4 additions & 3 deletions gramps/gui/editors/displaytabs/personrefembedlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#-------------------------------------------------------------------------
class PersonRefEmbedList(DbGUIElement, EmbeddedList):

_HANDLE_COL = 4
_HANDLE_COL = 5
_DND_TYPE = DdTargets.PERSONREF
_DND_EXTRA = DdTargets.PERSON_LINK

Expand All @@ -66,7 +66,8 @@ class PersonRefEmbedList(DbGUIElement, EmbeddedList):
(_('Name'), 0, 250, TEXT_COL, -1, None),
(_('ID'), 1, 100, TEXT_COL, -1, None),
(_('Association'), 2, 100, TEXT_COL, -1, None),
(_('Private'), 3, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 3, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 4, 30, ICON_COL, -1, 'gramps-lock')
]

def __init__(self, dbstate, uistate, track, data):
Expand Down Expand Up @@ -129,7 +130,7 @@ def get_data(self):
return self.data

def column_order(self):
return ((1,3), (1, 0), (1, 1), (1, 2))
return ((1, 3), (1, 4), (1, 0), (1, 1), (1, 2))

def add_button_clicked(self, obj):
from .. import EditPersonRef
Expand Down
4 changes: 2 additions & 2 deletions gramps/gui/editors/displaytabs/personrefmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
class PersonRefModel(Gtk.ListStore):

def __init__(self, obj_list, db):
Gtk.ListStore.__init__(self, str, str, str, bool, object)
Gtk.ListStore.__init__(self, str, str, str, bool, bool, object)
self.db = db
for obj in obj_list:
p = self.db.get_person_from_handle(obj.ref)
if p:
data = [name_displayer.display(p), p.gramps_id, obj.rel,
obj.get_privacy(), obj]
obj.has_citations(), obj.get_privacy(), obj]
else:
data = ['unknown','unknown', obj.rel, obj.get_privacy(), obj]
self.append(row=data)
7 changes: 4 additions & 3 deletions gramps/gui/editors/editfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ChildEmbedList(DbGUIElement, EmbeddedList):
is contained here instead of in displaytabs.
"""

_HANDLE_COL = 14
_HANDLE_COL = 15
_DND_TYPE = DdTargets.CHILDREF
_DND_EXTRA = DdTargets.PERSON_LINK

Expand Down Expand Up @@ -133,7 +133,8 @@ class ChildEmbedList(DbGUIElement, EmbeddedList):
None,
None,
None,
(_('Private'), 13, 30, ICON_COL, -1, 'gramps-lock')
(_('Source'), 13, 30, ICON_COL, -1, 'gramps-source'),
(_('Private'), 14, 30, ICON_COL, -1, 'gramps-lock'),
]

def __init__(self, dbstate, uistate, track, family):
Expand Down Expand Up @@ -216,7 +217,7 @@ def get_data(self):
return prefs

def column_order(self):
return [(1, 13), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
return [(1, 13), (1, 14), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(0, 8), (0, 9)]

def add_button_clicked(self, obj=None):
Expand Down

0 comments on commit 990d4ed

Please sign in to comment.