Cleaning up Data Entry Gramplet; not editing data yet
svn: r11498
This commit is contained in:
parent
bd44b133ab
commit
48dc331f3e
@ -32,6 +32,7 @@ from Utils import media_path_full
|
|||||||
import Config
|
import Config
|
||||||
import DateHandler
|
import DateHandler
|
||||||
import gen.lib
|
import gen.lib
|
||||||
|
import Errors
|
||||||
|
|
||||||
from ReportBase import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
|
from ReportBase import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
|
||||||
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||||
@ -1207,33 +1208,38 @@ class DataEntryGramplet(Gramplet):
|
|||||||
self.dirty = False
|
self.dirty = False
|
||||||
self.dirty_person = None
|
self.dirty_person = None
|
||||||
self.de_widgets = {}
|
self.de_widgets = {}
|
||||||
for items in [(0, _("Active person"), "", True, self.edit_person),
|
for items in [(0, _("Active person"), None, True, self.edit_person, False),
|
||||||
(1, _("Surname, Given"), "", False, None),
|
(1, _("Surname, Given"), None, False, None, True),
|
||||||
(2, _("Birth"), "", False, None),
|
(2, _("Birth"), None, False, None, True),
|
||||||
(3, _("Death"), "", False, None)
|
(3, _("Death"), None, False, None, True)
|
||||||
]:
|
]:
|
||||||
pos, text, default, readonly, callback = items
|
pos, text, choices, readonly, callback, dirty = items
|
||||||
row = self.make_row(pos, text, default, readonly, callback)
|
row = self.make_row(pos, text, choices, readonly, callback, dirty)
|
||||||
rows.pack_start(row, False)
|
rows.pack_start(row, False)
|
||||||
|
|
||||||
for items in [(4, _("Data Entry"), "", True),
|
for items in [(4, _("Data Entry"), None, True),
|
||||||
(5, _("Surname, Given"), "", False),
|
(8, _("Add relation"),
|
||||||
(6, _("Birth"), "", False),
|
["Don't add"],
|
||||||
(7, _("Death"), "", False)
|
False),
|
||||||
|
(5, _("Surname, Given"), None, False),
|
||||||
|
(6, _("Birth"), None, False),
|
||||||
|
(7, _("Death"), None, False)
|
||||||
]:
|
]:
|
||||||
pos, text, default, readonly = items
|
pos, text, choices, readonly = items
|
||||||
row = self.make_row(pos, text, default, readonly)
|
row = self.make_row(pos, text, choices, readonly)
|
||||||
rows.pack_start(row, False)
|
rows.pack_start(row, False)
|
||||||
|
|
||||||
# Mother, Father, Spouse (if sex known), Child of ... (if spouse)
|
# Save, Abandon, Clear
|
||||||
|
|
||||||
row = gtk.HBox()
|
row = gtk.HBox()
|
||||||
button = gtk.Button(_("Save edits"))
|
button = gtk.Button(_("Save"))
|
||||||
button.connect("clicked", self.save_data_entry)
|
button.connect("clicked", self.save_data_entry)
|
||||||
row.pack_start(button, True)
|
row.pack_start(button, True)
|
||||||
button = gtk.Button(_("Abanadon edits"))
|
button = gtk.Button(_("Abandon"))
|
||||||
button.connect("clicked", self.abandon_data_entry)
|
button.connect("clicked", self.abandon_data_entry)
|
||||||
row.pack_start(button, True)
|
row.pack_start(button, True)
|
||||||
|
button = gtk.Button(_("Clear"))
|
||||||
|
button.connect("clicked", self.clear_data_entry)
|
||||||
|
row.pack_start(button, True)
|
||||||
rows.pack_start(row, False)
|
rows.pack_start(row, False)
|
||||||
|
|
||||||
self.gui.get_container_widget().remove(self.gui.textview)
|
self.gui.get_container_widget().remove(self.gui.textview)
|
||||||
@ -1243,24 +1249,12 @@ class DataEntryGramplet(Gramplet):
|
|||||||
def main(self): # return false finishes
|
def main(self): # return false finishes
|
||||||
if self.dirty:
|
if self.dirty:
|
||||||
return
|
return
|
||||||
# Clear out abandoned entry data:
|
|
||||||
self.de_widgets[4].set_text("")
|
|
||||||
self.de_widgets[5].set_text("")
|
|
||||||
self.de_widgets[6].set_text("")
|
|
||||||
active_person = self.dbstate.get_active_person()
|
active_person = self.dbstate.get_active_person()
|
||||||
self.dirty_person = active_person
|
self.dirty_person = active_person
|
||||||
if not active_person:
|
if active_person:
|
||||||
# Clear out current person edits:
|
|
||||||
name = _("None")
|
|
||||||
self.de_widgets[0].set_text("<i>%s</i>" % name)
|
|
||||||
self.de_widgets[0].set_use_markup(True)
|
|
||||||
self.de_widgets[1].set_text("")
|
|
||||||
self.de_widgets[2].set_text("")
|
|
||||||
self.de_widgets[3].set_text("")
|
|
||||||
else:
|
|
||||||
# Fill in current pseron edits:
|
# Fill in current pseron edits:
|
||||||
name = name_displayer.display(active_person)
|
name = name_displayer.display(active_person)
|
||||||
self.de_widgets[0].set_text("<i>%s</i>" % name)
|
self.de_widgets[0].set_text("<i>%s</i> " % name)
|
||||||
self.de_widgets[0].set_use_markup(True)
|
self.de_widgets[0].set_use_markup(True)
|
||||||
# Name:
|
# Name:
|
||||||
name_obj = active_person.get_primary_name()
|
name_obj = active_person.get_primary_name()
|
||||||
@ -1268,8 +1262,7 @@ class DataEntryGramplet(Gramplet):
|
|||||||
self.de_widgets[1].set_text("%s, %s" %
|
self.de_widgets[1].set_text("%s, %s" %
|
||||||
(name_obj.get_surname(), name_obj.get_first_name()))
|
(name_obj.get_surname(), name_obj.get_first_name()))
|
||||||
# Birth:
|
# Birth:
|
||||||
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db,
|
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, active_person)
|
||||||
active_person)
|
|
||||||
birth_text = ""
|
birth_text = ""
|
||||||
if birth:
|
if birth:
|
||||||
sdate = DateHandler.get_date(birth)
|
sdate = DateHandler.get_date(birth)
|
||||||
@ -1283,8 +1276,7 @@ class DataEntryGramplet(Gramplet):
|
|||||||
|
|
||||||
self.de_widgets[2].set_text(birth_text)
|
self.de_widgets[2].set_text(birth_text)
|
||||||
# Death:
|
# Death:
|
||||||
death = ReportUtils.get_death_or_fallback(self.dbstate.db,
|
death = ReportUtils.get_death_or_fallback(self.dbstate.db, active_person)
|
||||||
active_person)
|
|
||||||
death_text = ""
|
death_text = ""
|
||||||
if death:
|
if death:
|
||||||
sdate = DateHandler.get_date(death)
|
sdate = DateHandler.get_date(death)
|
||||||
@ -1295,10 +1287,28 @@ class DataEntryGramplet(Gramplet):
|
|||||||
place_text = place.get_title()
|
place_text = place.get_title()
|
||||||
if place_text:
|
if place_text:
|
||||||
death_text += _("in") + " " + place_text
|
death_text += _("in") + " " + place_text
|
||||||
|
|
||||||
self.de_widgets[3].set_text(death_text)
|
self.de_widgets[3].set_text(death_text)
|
||||||
|
|
||||||
|
# Add options for adding:
|
||||||
|
|
||||||
|
for i in range(10):
|
||||||
|
try:
|
||||||
|
self.de_widgets[8].remove_text(0)
|
||||||
|
except:
|
||||||
|
break
|
||||||
|
|
||||||
|
for add_type in ["Don't add",
|
||||||
|
"Add as Mother",
|
||||||
|
"Add as Father",
|
||||||
|
"Add as Sibling",
|
||||||
|
"Add as Child"]:
|
||||||
|
self.de_widgets[8].append_text(add_type)
|
||||||
|
self.de_widgets[8].set_active(0)
|
||||||
|
|
||||||
|
self.dirty = False
|
||||||
|
|
||||||
def make_row(self, pos, text,default="",readonly=False,callback=None):
|
def make_row(self, pos, text, choices=None, readonly=False, callback=None,
|
||||||
|
mark_dirty=False):
|
||||||
import gtk
|
import gtk
|
||||||
# Data Entry: Active Person
|
# Data Entry: Active Person
|
||||||
row = gtk.HBox()
|
row = gtk.HBox()
|
||||||
@ -1311,14 +1321,27 @@ class DataEntryGramplet(Gramplet):
|
|||||||
self.de_widgets[text].set_alignment(0.0, 0.5)
|
self.de_widgets[text].set_alignment(0.0, 0.5)
|
||||||
self.de_widgets[text].set_use_markup(True)
|
self.de_widgets[text].set_use_markup(True)
|
||||||
label.set_alignment(0.0, 0.5)
|
label.set_alignment(0.0, 0.5)
|
||||||
|
row.pack_start(label, False)
|
||||||
|
row.pack_start(self.de_widgets[text], False)
|
||||||
else:
|
else:
|
||||||
label.set_text("%s: " % text)
|
label.set_text("%s: " % text)
|
||||||
label.set_width_chars(15)
|
label.set_width_chars(15)
|
||||||
self.de_widgets[text] = gtk.Entry()
|
if choices == None:
|
||||||
label.set_alignment(1.0, 0.5)
|
self.de_widgets[text] = gtk.Entry()
|
||||||
if default != "":
|
label.set_alignment(1.0, 0.5)
|
||||||
self.de_widgets[text].set_text(default)
|
if mark_dirty:
|
||||||
row.pack_start(label, False)
|
self.de_widgets[text].connect("changed", self.mark_dirty)
|
||||||
|
row.pack_start(label, False)
|
||||||
|
row.pack_start(self.de_widgets[text], True)
|
||||||
|
else:
|
||||||
|
eventBox = gtk.EventBox()
|
||||||
|
self.de_widgets[text] = gtk.combo_box_new_text()
|
||||||
|
eventBox.add(self.de_widgets[text])
|
||||||
|
for add_type in choices:
|
||||||
|
self.de_widgets[text].append_text(add_type)
|
||||||
|
self.de_widgets[text].set_active(0)
|
||||||
|
row.pack_start(label, False)
|
||||||
|
row.pack_start(eventBox, True, True)
|
||||||
if callback:
|
if callback:
|
||||||
icon = gtk.STOCK_EDIT
|
icon = gtk.STOCK_EDIT
|
||||||
size = gtk.ICON_SIZE_MENU
|
size = gtk.ICON_SIZE_MENU
|
||||||
@ -1327,22 +1350,38 @@ class DataEntryGramplet(Gramplet):
|
|||||||
image.set_from_stock(icon, size)
|
image.set_from_stock(icon, size)
|
||||||
button.add(image)
|
button.add(image)
|
||||||
button.set_relief(gtk.RELIEF_NONE)
|
button.set_relief(gtk.RELIEF_NONE)
|
||||||
|
button.connect("clicked", callback)
|
||||||
button.show_all()
|
button.show_all()
|
||||||
row.pack_start(button, False)
|
row.pack_start(button, False)
|
||||||
button.connect("clicked", callback)
|
|
||||||
row.pack_start(self.de_widgets[text], True)
|
|
||||||
# make accessible by name or position:
|
# make accessible by name or position:
|
||||||
self.de_widgets[pos] = self.de_widgets[text]
|
self.de_widgets[pos] = self.de_widgets[text]
|
||||||
return row
|
return row
|
||||||
|
|
||||||
|
def mark_dirty(self, obj):
|
||||||
|
self.dirty = True
|
||||||
|
|
||||||
|
def edit_callback(self, person):
|
||||||
|
self.dirty = False
|
||||||
|
self.update()
|
||||||
|
|
||||||
def edit_person(self, obj):
|
def edit_person(self, obj):
|
||||||
from Editors import EditPerson
|
from Editors import EditPerson
|
||||||
EditPerson(self.gui.dbstate,
|
try:
|
||||||
self.gui.uistate, [],
|
EditPerson(self.gui.dbstate,
|
||||||
self.gui.dbstate.get_active_person())
|
self.gui.uistate, [],
|
||||||
|
self.gui.dbstate.get_active_person(),
|
||||||
|
callback=self.edit_callback)
|
||||||
|
except Errors.WindowActiveError:
|
||||||
|
pass
|
||||||
|
|
||||||
def save_data_entry(self, obj):
|
def save_data_entry(self, obj):
|
||||||
pass
|
self.dirty = False
|
||||||
|
# FIXME: save entries to db
|
||||||
|
|
||||||
|
def clear_data_entry(self, obj):
|
||||||
|
self.de_widgets[5].set_text("")
|
||||||
|
self.de_widgets[6].set_text("")
|
||||||
|
self.de_widgets[7].set_text("")
|
||||||
|
|
||||||
def abandon_data_entry(self, obj):
|
def abandon_data_entry(self, obj):
|
||||||
self.dirty = False
|
self.dirty = False
|
||||||
|
Loading…
Reference in New Issue
Block a user