Working on display of Data Entry Gramplet; next will come the actual database changes

svn: r11500
This commit is contained in:
Doug Blank 2008-12-20 16:41:31 +00:00
parent e10cf8deb1
commit 3b8ad54a0d

View File

@ -1210,6 +1210,9 @@ class DataEntryGramplet(Gramplet):
self.de_widgets = {} self.de_widgets = {}
for items in [(0, _("Active person"), None, True, self.edit_person, False), for items in [(0, _("Active person"), None, True, self.edit_person, False),
(1, _("Surname, Given"), None, False, None, True), (1, _("Surname, Given"), None, False, None, True),
(9, _("Gender"),
[_("female"), _("male"), _("unknown")],
False, None, True),
(2, _("Birth"), None, False, None, True), (2, _("Birth"), None, False, None, True),
(3, _("Death"), None, False, None, True) (3, _("Death"), None, False, None, True)
]: ]:
@ -1222,6 +1225,9 @@ class DataEntryGramplet(Gramplet):
["Don't add"], ["Don't add"],
False), False),
(5, _("Surname, Given"), None, False), (5, _("Surname, Given"), None, False),
(10, _("Gender"),
[_("female"), _("male"), _("unknown")],
False),
(6, _("Birth"), None, False), (6, _("Birth"), None, False),
(7, _("Death"), None, False) (7, _("Death"), None, False)
]: ]:
@ -1252,7 +1258,7 @@ class DataEntryGramplet(Gramplet):
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 active_person: if active_person:
# Fill in current pseron edits: # Fill in current person 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)
@ -1261,6 +1267,7 @@ class DataEntryGramplet(Gramplet):
if name_obj: if name_obj:
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()))
self.de_widgets[9].set_active(active_person.get_gender()) # gender
# Birth: # Birth:
birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, active_person) birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, active_person)
birth_text = "" birth_text = ""
@ -1290,22 +1297,24 @@ class DataEntryGramplet(Gramplet):
self.de_widgets[3].set_text(death_text) self.de_widgets[3].set_text(death_text)
# Add options for adding: # Add options for adding:
self.reset_add_type()
self.dirty = False
def reset_add_type(self):
for i in range(10): for i in range(10):
try: try:
self.de_widgets[8].remove_text(0) self.de_widgets[8].remove_text(0)
except: except:
break break
for add_type in [_("Don't add"),
for add_type in ["Don't add", _("Add as Parent"),
"Add as Mother", _("Add as Spouse"),
"Add as Father", _("Add as Sibling"),
"Add as Sibling", _("Add as Child"),
"Add as Child"]: _("No Relation")]:
# FIXME: keep track of options so as to save
self.de_widgets[8].append_text(add_type) self.de_widgets[8].append_text(add_type)
self.de_widgets[8].set_active(0) self.de_widgets[8].set_active(0) # Don't add
self.dirty = False
def make_row(self, pos, text, choices=None, readonly=False, callback=None, def make_row(self, pos, text, choices=None, readonly=False, callback=None,
mark_dirty=False): mark_dirty=False):
@ -1326,9 +1335,9 @@ class DataEntryGramplet(Gramplet):
else: else:
label.set_text("%s: " % text) label.set_text("%s: " % text)
label.set_width_chars(15) label.set_width_chars(15)
label.set_alignment(1.0, 0.5)
if choices == None: if choices == None:
self.de_widgets[text] = gtk.Entry() self.de_widgets[text] = gtk.Entry()
label.set_alignment(1.0, 0.5)
if mark_dirty: if mark_dirty:
self.de_widgets[text].connect("changed", self.mark_dirty) self.de_widgets[text].connect("changed", self.mark_dirty)
row.pack_start(label, False) row.pack_start(label, False)
@ -1340,6 +1349,8 @@ class DataEntryGramplet(Gramplet):
for add_type in choices: for add_type in choices:
self.de_widgets[text].append_text(add_type) self.de_widgets[text].append_text(add_type)
self.de_widgets[text].set_active(0) self.de_widgets[text].set_active(0)
if mark_dirty:
self.de_widgets[text].connect("changed", self.mark_dirty)
row.pack_start(label, False) row.pack_start(label, False)
row.pack_start(eventBox, True, True) row.pack_start(eventBox, True, True)
if callback: if callback:
@ -1351,10 +1362,11 @@ class DataEntryGramplet(Gramplet):
button.add(image) button.add(image)
button.set_relief(gtk.RELIEF_NONE) button.set_relief(gtk.RELIEF_NONE)
button.connect("clicked", callback) button.connect("clicked", callback)
button.show_all() #button.show_all()
row.pack_start(button, False) row.pack_start(button, False)
# 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]
row.show_all()
return row return row
def mark_dirty(self, obj): def mark_dirty(self, obj):
@ -1369,7 +1381,7 @@ class DataEntryGramplet(Gramplet):
try: try:
EditPerson(self.gui.dbstate, EditPerson(self.gui.dbstate,
self.gui.uistate, [], self.gui.uistate, [],
self.gui.dbstate.get_active_person(), self.dirty_person,
callback=self.edit_callback) callback=self.edit_callback)
except Errors.WindowActiveError: except Errors.WindowActiveError:
pass pass
@ -1382,6 +1394,8 @@ class DataEntryGramplet(Gramplet):
self.de_widgets[5].set_text("") self.de_widgets[5].set_text("")
self.de_widgets[6].set_text("") self.de_widgets[6].set_text("")
self.de_widgets[7].set_text("") self.de_widgets[7].set_text("")
self.reset_add_type()
self.de_widgets[10].set_active(2) # unknown gender
def abandon_data_entry(self, obj): def abandon_data_entry(self, obj):
self.dirty = False self.dirty = False
@ -1546,6 +1560,6 @@ register(type="gramplet",
content = DataEntryGramplet, content = DataEntryGramplet,
title=_("Data Entry"), title=_("Data Entry"),
detached_width = 600, detached_width = 600,
detached_height = 400, detached_height = 450,
) )