78
78
from gramps .gen .utils .libformatting import FormattingHelper
79
79
from gramps .gen .db import DbTxn
80
80
from gramps .gui .display import display_url
81
+ from gramps .gen .utils .symbols import Symbols
82
+ from gramps .gen .utils .alive import probably_alive
81
83
82
84
BORDER = 10
83
85
HEIGHT = 18
@@ -110,15 +112,18 @@ def draw(self, canvas, cr):
110
112
pass
111
113
112
114
class PersonNode (Node ):
113
- def __init__ (self , handle , layer , name , sex , ident , fg_color , bg_color ):
115
+ def __init__ (self , handle , layer , name , sex , ident ,
116
+ fg_color , bg_color , dead ):
114
117
Node .__init__ (self , handle , layer )
115
118
self .name = name
116
119
self .sex = sex
117
120
self .ident = ident
118
121
self .fg_color = fg_color
119
122
self .bg_color = bg_color
123
+ self .dead = dead
120
124
self .parents = []
121
125
self .children = []
126
+ self .symbols = Symbols ()
122
127
123
128
def add_main_family (self , family ):
124
129
self .parents .append (family )
@@ -127,12 +132,16 @@ def add_family(self, family):
127
132
self .children .append (family )
128
133
129
134
def draw (self , canvas , cr ):
130
- if self .sex == Person .MALE :
131
- label = '\u2642 ' + self .name
132
- elif self .sex == Person .FEMALE :
133
- label = '\u2640 ' + self .name
135
+ if self .sex is not None :
136
+ sex_char = self .symbols .get_symbol_for_string (self .sex )
134
137
else :
135
- label = '\u2650 ' + self .name
138
+ sex_char = ''
139
+ if config .get ('utf8.in-use' ):
140
+ if self .sex is not None :
141
+ sex_char = self .symbols .get_symbol_for_string (self .sex )
142
+ else :
143
+ sex_char = ''
144
+ label = sex_char + ' ' + self .dead + ' ' + self .name
136
145
137
146
layout = canvas .create_pango_layout (label )
138
147
if is_quartz ():
@@ -219,6 +228,8 @@ def __init__(self, pdata, dbstate, uistate, nav_group=0):
219
228
self .dbstate = dbstate
220
229
self .uistate = uistate
221
230
self .dbstate .connect ('database-changed' , self .change_db )
231
+ self .uistate .connect ('font-changed' , self .rebuild )
232
+ self .uistate .connect ('nameformat-changed' , self .rebuild )
222
233
223
234
self .additional_uis .append (self .additional_ui )
224
235
@@ -230,7 +241,7 @@ def __init__(self, pdata, dbstate, uistate, nav_group=0):
230
241
self .layers = None
231
242
self .people = []
232
243
self .paths = []
233
- self .format_helper = FormattingHelper (self .dbstate )
244
+ self .format_helper = FormattingHelper (self .dbstate , self . uistate )
234
245
scheme = config .get ('colors.scheme' )
235
246
self .home_person_color = config .get ('colors.home-person' )[scheme ]
236
247
self .timeout = None
@@ -239,6 +250,7 @@ def __init__(self, pdata, dbstate, uistate, nav_group=0):
239
250
self .total = 0
240
251
self .progress = None
241
252
self .load = 0 # avoid to load the database twice
253
+ self .symbols = Symbols ()
242
254
243
255
def get_stock (self ):
244
256
"""
@@ -275,6 +287,7 @@ def build_widget(self):
275
287
Gdk .EventMask .POINTER_MOTION_MASK |
276
288
Gdk .EventMask .SCROLL_MASK |
277
289
Gdk .EventMask .KEY_PRESS_MASK )
290
+ self .on_draw_ok = - 1
278
291
279
292
self .scrolledwindow .add (self .canvas )
280
293
@@ -549,11 +562,14 @@ def _entry_key_event(self, combobox):
549
562
count += 1
550
563
found = name [0 ]
551
564
self .name_store .append (name )
565
+ self .show_message (count )
566
+
567
+ def show_message (self , count = 0 ):
552
568
self .message .set_label (
553
569
_ ("You have %(filter)d filtered people, "
554
570
"%(count)d people shown on the tree "
555
571
"and %(total)d people in your database."
556
- % {'filter' : count if search != "" else 0 ,
572
+ % {'filter' : count ,
557
573
'count' : len (self .plist ),
558
574
'total' : self .total }))
559
575
@@ -568,6 +584,7 @@ def _erase_name_selection(self, arg=None):
568
584
"""
569
585
We erase the name in the entrybox
570
586
"""
587
+ self .name_combo .get_child ().set_text (" " ) # force entry change
571
588
self .name_combo .get_child ().set_text ("" )
572
589
573
590
def add_bookmark (self , handle ):
@@ -608,7 +625,6 @@ def center_on_node(self, obj, handle):
608
625
self .set_path_lines (self .people [handle ])
609
626
610
627
def goto_handle (self , handle = None ):
611
- self ._erase_name_selection ()
612
628
self ._clear_list_store ()
613
629
if self .load < 3 : # avoid to load the database twice
614
630
self .load = 3
@@ -647,6 +663,11 @@ def read_data(self, handle):
647
663
self .progress .set_pass (message , self .total )
648
664
todo = [(handle , 0 )]
649
665
count = 0
666
+ death_idx = self .uistate .death_symbol
667
+ if self .uistate .symbols :
668
+ death_char = self .symbols .get_death_symbol_for_char (death_idx )
669
+ else :
670
+ death_char = self .symbols .get_death_symbol_fallback (death_idx )
650
671
while todo :
651
672
handle , layer = todo .pop ()
652
673
count += 1 # persons + families
@@ -672,8 +693,10 @@ def read_data(self, handle):
672
693
death_event = get_death_or_fallback (self .dbstate .db , person )
673
694
if death_event :
674
695
fill , color = color_graph_box (False , sex )
696
+ dead = death_char
675
697
else :
676
698
fill , color = color_graph_box (True , sex )
699
+ dead = ' '
677
700
color = Gdk .color_parse (color )
678
701
fg_color = (float (color .red / 65535.0 ),
679
702
float (color .green / 65535.0 ),
@@ -689,8 +712,8 @@ def read_data(self, handle):
689
712
float (color .green / 65535.0 ),
690
713
float (color .blue / 65535.0 ))
691
714
692
- people [handle ] = PersonNode (handle , layer , name ,
693
- sex , ident , fg_color , bg_color )
715
+ people [handle ] = PersonNode (handle , layer , name , sex , ident ,
716
+ fg_color , bg_color , dead )
694
717
695
718
for fhandle in person .get_family_handle_list ():
696
719
people [handle ].add_main_family (fhandle )
@@ -746,15 +769,31 @@ def rebuild(self):
746
769
if self .load < 3 : # avoid to load the database twice
747
770
return
748
771
self .total = self .dbstate .db .get_number_of_people ()
772
+ self ._erase_name_selection ()
749
773
active = self .get_active ()
750
774
if active != "" :
775
+ self .on_draw_ok = - 1
751
776
self .people , self .families , self .layers = self .read_data (active )
752
- self .name_combo .get_child ().set_text (" " ) # force entry change
753
- self .name_combo .get_child ().set_text ("" )
754
777
self .canvas .queue_draw ()
755
778
self .canvas .grab_focus ()
756
- self .center_on_node (None , active )
757
- self .set_path_lines (active )
779
+ # We need to wait on_draw is called to draw path lines.
780
+ self .on_draw_ok = 0
781
+ GLib .timeout_add (int (200 ), self .after_on_draw_on_rebuild )
782
+
783
+ def after_on_draw_on_rebuild (self ):
784
+ """
785
+ Loop to see if we can draw the path lines
786
+ """
787
+ if self .on_draw_ok == 0 :
788
+ return True # continue to wait
789
+ #We can now set path lines. Nodes are totaly initialized.
790
+ active = self .get_active ()
791
+ if active != "" :
792
+ node = self .people [active ]
793
+ self .center_on_node (None , node )
794
+ self .set_path_lines (node )
795
+ self .show_message ()
796
+ return False
758
797
759
798
def on_draw (self , canvas , cr ):
760
799
"""
@@ -887,6 +926,8 @@ def on_draw(self, canvas, cr):
887
926
(y + BORDER ) * self .scale )
888
927
889
928
#print ('draw time', clock()- c)
929
+ if self .on_draw_ok == 0 :
930
+ self .on_draw_ok = 1 # We can now draw path lines
890
931
891
932
def home (self , * obj ):
892
933
defperson = self .dbstate .db .get_default_person ()
@@ -1716,6 +1757,8 @@ def set_path_lines(self, obj):
1716
1757
"""
1717
1758
obj : either a person or a family
1718
1759
"""
1760
+ if obj .x is None :
1761
+ return
1719
1762
self .paths = []
1720
1763
_col = self ._config .get
1721
1764
color_path = _col ('interface.quiltview-color-path' )
@@ -1753,6 +1796,8 @@ def calculate_segment_length(self, obj):
1753
1796
These coordinates include the name,
1754
1797
the segment for the parents and the segment for the children
1755
1798
"""
1799
+ if obj .x is None :
1800
+ return
1756
1801
if isinstance (obj , PersonNode ):
1757
1802
x1 = obj .x
1758
1803
x2 = obj .x + obj .width
0 commit comments