23
23
24
24
# 9 Jun 2019
25
25
#
26
+ # v1.0.4 (30 Aug 2020): added "timespan"
27
+ #
26
28
# Gramplet to change properties of multiple places at the same time. See README.
27
29
28
30
import re
32
34
33
35
from gramps .gen .plug import Gramplet
34
36
from gramps .gen .db import DbTxn
35
- from gramps .gen .lib import Place , PlaceRef , PlaceName , PlaceType , Tag
37
+ from gramps .gen .lib import Place , PlaceRef , PlaceName , PlaceType , Tag , Date
36
38
37
39
from gramps .gui .selectors import SelectorFactory
40
+ from gramps .gui .widgets import MonitoredDate , ValidatableMaskedEntry
38
41
39
42
from gramps .gen .const import GRAMPS_LOCALE as glocale
40
43
try :
@@ -70,7 +73,8 @@ def __tagnames(self):
70
73
def cb_clear (self , obj ):
71
74
self .selected_handle = None
72
75
self .selected_name = ""
73
- self .enclosing_place .set_text (_ ("None" ))
76
+ #self.enclosing_place.set_text(_("None"))
77
+ self .but_set_enclosing .set_label (_ ("Select" ))
74
78
self .tagcombo .get_child ().set_text ("" )
75
79
self .typecombo .get_child ().set_text ("" )
76
80
self .clear_enclosing .set_active (False )
@@ -82,6 +86,8 @@ def cb_clear(self, obj):
82
86
self .use_regex .set_active (False )
83
87
self .old_text .set_text ("" )
84
88
self .new_text .set_text ("" )
89
+ self .date_object .set ()
90
+ self .date_entry .set_text ("" )
85
91
86
92
def __create_gui (self ):
87
93
vbox = Gtk .VBox (orientation = Gtk .Orientation .VERTICAL )
@@ -110,20 +116,45 @@ def __create_gui(self):
110
116
self .enclosing_place = Gtk .Label (_ ("None" ))
111
117
self .enclosing_place .set_halign (Gtk .Align .START )
112
118
119
+ date_label = Gtk .Label (_ ('Timespan:' ))
120
+ date_label .set_halign (Gtk .Align .START )
121
+ self .date_entry = ValidatableMaskedEntry ()
122
+ date_button = Gtk .Button .new_from_icon_name ("gramps-date" , - 1 )
123
+ timespan_tooltip = _ ("Set timespan for enclosing places" )
124
+ date_label .set_tooltip_text (timespan_tooltip )
125
+ date_button .set_tooltip_text (timespan_tooltip )
126
+ self .date_entry .set_tooltip_text (timespan_tooltip )
127
+ self .date_object = Date ()
128
+ self .track = []
129
+ self .date_field = MonitoredDate (self .date_entry ,
130
+ date_button ,
131
+ self .date_object ,
132
+ self .uistate , self .track )
133
+
113
134
pt_grid = Gtk .Grid (column_spacing = 10 )
114
135
pt_grid .attach (pt_label , 0 , 0 , 1 , 1 )
115
136
pt_grid .attach (self .typecombo , 1 , 0 , 1 , 1 )
116
137
117
138
pt_grid .attach (tag_label , 0 , 1 , 1 , 1 )
118
139
pt_grid .attach (self .tagcombo , 1 , 1 , 1 , 1 )
140
+
119
141
pt_grid .attach (label1 , 0 , 2 , 1 , 1 )
120
- pt_grid .attach (self .enclosing_place , 1 , 2 , 1 , 1 )
142
+
143
+ pl_grid = Gtk .Grid (column_spacing = 10 )
144
+ pl_grid .set_margin_left (20 )
145
+ #pt_grid.attach(self.enclosing_place, 1, 2, 1, 1)
146
+
147
+ pl_grid .attach (date_label , 1 , 4 , 1 , 1 )
148
+ pl_grid .attach (self .date_entry , 2 , 4 , 1 , 1 )
149
+ pl_grid .attach (date_button , 3 , 4 , 1 , 1 )
121
150
122
151
vbox .pack_start (pt_grid , False , True , 0 )
152
+ vbox .pack_start (pl_grid , False , True , 0 )
123
153
124
- but_set_enclosing = Gtk .Button (label = _ ('Select enclosing place' ))
125
- but_set_enclosing .connect ("clicked" , self .cb_select )
126
- vbox .pack_start (but_set_enclosing , False , True , 10 )
154
+ self .but_set_enclosing = Gtk .Button (label = _ ('Select' ))
155
+ self .but_set_enclosing .connect ("clicked" , self .cb_select )
156
+ #vbox.pack_start(self.but_set_enclosing, False, True, 10)
157
+ pt_grid .attach (self .but_set_enclosing , 1 , 2 , 1 , 1 )
127
158
128
159
self .clear_enclosing = Gtk .CheckButton (_ ("Clear original enclosing places" ))
129
160
vbox .pack_start (self .clear_enclosing , False , True , 0 )
@@ -207,7 +238,18 @@ def cb_select(self, obj):
207
238
title = selected_parent .get_title ()
208
239
if title :
209
240
self .selected_name += " (title={})" .format (title )
210
- self .enclosing_place .set_text (self .selected_name )
241
+ #self.enclosing_place.set_text(self.selected_name)
242
+ self .but_set_enclosing .set_label (self .selected_name )
243
+
244
+ def cb_set_enclosing_dates (self , obj ):
245
+ #SelectDate = SelectorFactory('Date')
246
+ sel = EditDate (None , self .gui .uistate , None )
247
+ date = sel .run ()
248
+ print ("date=" , date )
249
+ if not date :
250
+ return
251
+ pass
252
+
211
253
212
254
def cb_select_generate_hierarchy (self , obj ):
213
255
checked = self .generate_hierarchy .get_active ()
@@ -302,6 +344,7 @@ def __set_enclosing_place(self, place):
302
344
print (pname , "<" , self .selected_name )
303
345
placeref = PlaceRef ()
304
346
placeref .ref = self .selected_handle
347
+ placeref .set_date_object (self .date_object )
305
348
place .add_placeref (placeref )
306
349
307
350
@@ -353,6 +396,7 @@ def __generate_hierarchy(self, place, original_enclosing_places):
353
396
if parent_handle is not None :
354
397
placeref = PlaceRef ()
355
398
placeref .ref = parent_handle
399
+ placeref .set_date_object (self .date_object )
356
400
new_place .add_placeref (placeref )
357
401
parent_handle = self .dbstate .db .add_place (new_place , self .trans )
358
402
else :
@@ -363,6 +407,7 @@ def __generate_hierarchy(self, place, original_enclosing_places):
363
407
if parent_handle is not None :
364
408
placeref = PlaceRef ()
365
409
placeref .ref = parent_handle
410
+ placeref .set_date_object (self .date_object )
366
411
place .set_placeref_list ([placeref ]) # this removes any previous parent
367
412
return top_place
368
413
0 commit comments