Skip to content

Commit b49ee8b

Browse files
Add Unknown and Other gender avatars (#597)
* Add Unknown and Other gender avatars * Lined avatars * Update Custom avatar choosers
1 parent a027e35 commit b49ee8b

File tree

6 files changed

+53
-1
lines changed

6 files changed

+53
-1
lines changed

GraphView/avatars.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, config):
6060
1: (_('Dark (default)'), 'dark'),
6161
2: (_('Light'), 'light'),
6262
3: (_('Cartoon'), 'cartoon'),
63+
4: (_('Modern'), 'modern'),
6364
}
6465

6566
self.style = 1
@@ -87,6 +88,10 @@ def get_avatar(self, gender):
8788
avatar = self.config.get('interface.graphview-avatars-male')
8889
elif gender == Person.FEMALE:
8990
avatar = self.config.get('interface.graphview-avatars-female')
91+
elif gender == Person.UNKNOWN:
92+
avatar = self.config.get('interface.graphview-avatars-unknown')
93+
elif gender == Person.OTHER:
94+
avatar = self.config.get('interface.graphview-avatars-other')
9095
if avatar:
9196
return avatar
9297
else:
@@ -98,6 +103,10 @@ def get_avatar(self, gender):
98103
return os.path.join(self.path, style, 'person_male.png')
99104
if gender == Person.FEMALE:
100105
return os.path.join(self.path, style, 'person_female.png')
106+
if gender == Person.UNKNOWN:
107+
return os.path.join(self.path, style, 'person_unknown.png')
108+
if gender == Person.OTHER:
109+
return os.path.join(self.path, style, 'person_other.png')
101110

102111
def get_styles_list(self):
103112
"""
@@ -108,4 +117,3 @@ def get_styles_list(self):
108117
for key, item in self.styles.items():
109118
styles_list.append((key, item[0]))
110119
return styles_list
111-
2.45 KB
Loading
2.35 KB
Loading
3.03 KB
Loading
2.36 KB
Loading

GraphView/graphview.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ class GraphView(NavigationView):
157157
('interface.graphview-avatars-style', 1),
158158
('interface.graphview-avatars-male', ''), # custom avatar
159159
('interface.graphview-avatars-female', ''), # custom avatar
160+
('interface.graphview-avatars-unknown', ''), # custom avatar
161+
('interface.graphview-avatars-other', ''), # custom avatar
160162
('interface.graphview-show-full-dates', False),
161163
('interface.graphview-show-places', False),
162164
('interface.graphview-place-format', 0),
@@ -469,6 +471,22 @@ def cb_female_avatar_set(self, file_chooser_button):
469471
file_chooser_button.get_filename())
470472
self.graph_widget.populate(self.get_active())
471473

474+
def cb_unknown_avatar_set(self, file_chooser_button):
475+
"""
476+
Called when the configuration menu changes the unknown sex avatar.
477+
"""
478+
self._config.set('interface.graphview-avatars-unknown',
479+
file_chooser_button.get_filename())
480+
self.graph_widget.populate(self.get_active())
481+
482+
def cb_other_avatar_set(self, file_chooser_button):
483+
"""
484+
Called when the configuration menu changes the other sex avatar.
485+
"""
486+
self._config.set('interface.graphview-avatars-other',
487+
file_chooser_button.get_filename())
488+
self.graph_widget.populate(self.get_active())
489+
472490
def cb_update_show_full_dates(self, _client, _cnxn_id, entry, _data):
473491
"""
474492
Called when the configuration menu changes the date setting.
@@ -836,6 +854,32 @@ def theme_config_panel(self, configdialog):
836854
grid.attach(FCB_female, 2, row, 1, 1)
837855
self.avatar_widgets.append(lbl)
838856
self.avatar_widgets.append(FCB_female)
857+
858+
row += 1
859+
lbl = Gtk.Label(label=_('Unknown avatar:'), halign=Gtk.Align.END)
860+
FCB_unknown = Gtk.FileChooserButton.new(_('Choose Unknown avatar'),
861+
Gtk.FileChooserAction.OPEN)
862+
FCB_unknown.add_filter(file_filter)
863+
FCB_unknown.set_filename(
864+
self._config.get('interface.graphview-avatars-unknown'))
865+
FCB_unknown.connect('file-set', self.cb_unknown_avatar_set)
866+
grid.attach(lbl, 1, row, 1, 1)
867+
grid.attach(FCB_unknown, 2, row, 1, 1)
868+
self.avatar_widgets.append(lbl)
869+
self.avatar_widgets.append(FCB_unknown)
870+
871+
row += 1
872+
lbl = Gtk.Label(label=_('Other avatar:'), halign=Gtk.Align.END)
873+
FCB_other = Gtk.FileChooserButton.new(_('Choose Other avatar'),
874+
Gtk.FileChooserAction.OPEN)
875+
FCB_other.add_filter(file_filter)
876+
FCB_other.set_filename(
877+
self._config.get('interface.graphview-avatars-other'))
878+
FCB_other.connect('file-set', self.cb_other_avatar_set)
879+
grid.attach(lbl, 1, row, 1, 1)
880+
grid.attach(FCB_other, 2, row, 1, 1)
881+
self.avatar_widgets.append(lbl)
882+
self.avatar_widgets.append(FCB_other)
839883
# ===================================================================
840884

841885
row += 1

0 commit comments

Comments
 (0)