Skip to content

Commit 8508052

Browse files
authored
Added input field "Timespan" in PlaceUpdate gramplet (#448)
* Added timespan * Removed trailing whitespace * PlaceUpdate: add help URL and resize detached dialog Co-authored-by: Kari Kujansuu <[email protected]>
1 parent 226dacb commit 8508052

File tree

7 files changed

+64
-10
lines changed

7 files changed

+64
-10
lines changed

PlaceUpdate/PlaceUpdate UI.png

-3.55 KB
Loading
-13.7 KB
Loading
-14.2 KB
Loading

PlaceUpdate/PlaceUpdate.gpr.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
name = _("PlaceUpdate"),
44
description = _("Gramplet to manipulate multiple places"),
55
status = STABLE,
6-
version = '1.0.3',
6+
version = '1.0.4',
77
gramps_target_version = '5.1',
88
fname = "PlaceUpdate.py",
99
gramplet = 'PlaceUpdate',
1010
height = 375,
1111
detached_width = 510,
12-
detached_height = 480,
12+
detached_height = 520,
1313
expand = True,
1414
gramplet_title = _("PlaceUpdate"),
1515
include_in_listing = True,
16+
help_url = "http://gramps-project.org/wiki/index.php/PlaceUpdate_Gramplet",
1617
navtypes=["Place"],
1718
)

PlaceUpdate/PlaceUpdate.py

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
2424
# 9 Jun 2019
2525
#
26+
# v1.0.4 (30 Aug 2020): added "timespan"
27+
#
2628
# Gramplet to change properties of multiple places at the same time. See README.
2729

2830
import re
@@ -32,9 +34,10 @@
3234

3335
from gramps.gen.plug import Gramplet
3436
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
3638

3739
from gramps.gui.selectors import SelectorFactory
40+
from gramps.gui.widgets import MonitoredDate, ValidatableMaskedEntry
3841

3942
from gramps.gen.const import GRAMPS_LOCALE as glocale
4043
try:
@@ -70,7 +73,8 @@ def __tagnames(self):
7073
def cb_clear(self, obj):
7174
self.selected_handle = None
7275
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"))
7478
self.tagcombo.get_child().set_text("")
7579
self.typecombo.get_child().set_text("")
7680
self.clear_enclosing.set_active(False)
@@ -82,6 +86,8 @@ def cb_clear(self, obj):
8286
self.use_regex.set_active(False)
8387
self.old_text.set_text("")
8488
self.new_text.set_text("")
89+
self.date_object.set()
90+
self.date_entry.set_text("")
8591

8692
def __create_gui(self):
8793
vbox = Gtk.VBox(orientation=Gtk.Orientation.VERTICAL)
@@ -110,20 +116,45 @@ def __create_gui(self):
110116
self.enclosing_place = Gtk.Label(_("None"))
111117
self.enclosing_place.set_halign(Gtk.Align.START)
112118

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+
113134
pt_grid = Gtk.Grid(column_spacing=10)
114135
pt_grid.attach(pt_label, 0, 0, 1, 1)
115136
pt_grid.attach(self.typecombo, 1, 0, 1, 1)
116137

117138
pt_grid.attach(tag_label, 0, 1, 1, 1)
118139
pt_grid.attach(self.tagcombo, 1, 1, 1, 1)
140+
119141
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)
121150

122151
vbox.pack_start(pt_grid, False, True, 0)
152+
vbox.pack_start(pl_grid, False, True, 0)
123153

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 )
127158

128159
self.clear_enclosing = Gtk.CheckButton(_("Clear original enclosing places"))
129160
vbox.pack_start(self.clear_enclosing, False, True, 0)
@@ -207,7 +238,18 @@ def cb_select(self, obj):
207238
title = selected_parent.get_title()
208239
if title:
209240
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+
211253

212254
def cb_select_generate_hierarchy(self, obj):
213255
checked = self.generate_hierarchy.get_active()
@@ -302,6 +344,7 @@ def __set_enclosing_place(self, place):
302344
print(pname, "<", self.selected_name)
303345
placeref = PlaceRef()
304346
placeref.ref = self.selected_handle
347+
placeref.set_date_object(self.date_object)
305348
place.add_placeref(placeref)
306349

307350

@@ -353,6 +396,7 @@ def __generate_hierarchy(self, place, original_enclosing_places):
353396
if parent_handle is not None:
354397
placeref = PlaceRef()
355398
placeref.ref = parent_handle
399+
placeref.set_date_object(self.date_object)
356400
new_place.add_placeref(placeref)
357401
parent_handle = self.dbstate.db.add_place(new_place, self.trans)
358402
else:
@@ -363,6 +407,7 @@ def __generate_hierarchy(self, place, original_enclosing_places):
363407
if parent_handle is not None:
364408
placeref = PlaceRef()
365409
placeref.ref = parent_handle
410+
placeref.set_date_object(self.date_object)
366411
place.set_placeref_list([placeref]) # this removes any previous parent
367412
return top_place
368413

PlaceUpdate/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The user interface looks like:
2323
**Setting enclosing place**
2424

2525
For the enclosing place first select the place that should enclose the other places
26-
and click the "Set enclosing place" button. The selected place will be displayed.
26+
and click the "Select" button next to the "New enclosing place" label. The selected place will be displayed as the label of the button.
2727
Then select any number of places that should be enclosed by the first one
2828
and click the "Apply to selected places" button.
2929

@@ -35,6 +35,8 @@ This can e.g. be used to "move" the places under another place.
3535
Attempts to set a duplicate enclosing place or a loop (so that a place contains itself)
3636
are quietly bypassed.
3737

38+
In the "Timespan" field you can specify relevant the date range if needed. This also affects the generated hierarchy (see below).
39+
3840

3941
**Setting place type or tag**
4042

@@ -66,6 +68,8 @@ The place type and tag setting affects only the original place.
6668

6769
If the original place is under another place or a new enclosing place is specified then the new hierarchy is placed under the enclosing place.
6870

71+
If a timespan is specified then it applies to all levels in the generated hierarchy.
72+
6973
**Editing place names**
7074

7175
The "Replace text" function allows substituting a specified text string in the place names with another. Regular expressions can also be used.

PlaceUpdate/po/fi-local.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ msgstr "Paikkojen ominaisuuksien asettaminen"
105105
#: PlaceTool/PlaceTool.py:272
106106
msgid "Regex operation failed: {}"
107107
msgstr ""
108+
109+
msgid "Timespan:"
110+
msgstr "Aikaväli:"
111+

0 commit comments

Comments
 (0)