2006-11-06 Don Allingham <don@gramps-project.org>
* src/Editors/_EditPerson.py: Change Unknown Gender dialog to allow the user to specify without going back to the main window * src/plugins/RemoveUnused.py: cleanup svn: r7569
This commit is contained in:
parent
69fa1a3af8
commit
6225faf92d
@ -1,3 +1,8 @@
|
|||||||
|
2006-11-06 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/Editors/_EditPerson.py: Change Unknown Gender dialog to allow
|
||||||
|
the user to specify without going back to the main window
|
||||||
|
* src/plugins/RemoveUnused.py: cleanup
|
||||||
|
|
||||||
2006-11-06 Alex Roitman <shura@gramps-project.org>
|
2006-11-06 Alex Roitman <shura@gramps-project.org>
|
||||||
* NEWS: Update.
|
* NEWS: Update.
|
||||||
|
|
||||||
|
@ -467,17 +467,11 @@ class EditPerson(EditPrimary):
|
|||||||
|
|
||||||
def _check_for_unknown_gender(self):
|
def _check_for_unknown_gender(self):
|
||||||
if self.obj.get_gender() == RelLib.Person.UNKNOWN:
|
if self.obj.get_gender() == RelLib.Person.UNKNOWN:
|
||||||
dialog = QuestionDialog2(
|
d = GenderDialog(self.window)
|
||||||
_("Unknown gender specified"),
|
gender = d.run()
|
||||||
_("The gender of the person is currently unknown. "
|
d.destroy()
|
||||||
"Usually, this is a mistake. You may choose to "
|
if gender >= 0:
|
||||||
"either continue saving, or returning to the "
|
self.obj.set_gender(gender)
|
||||||
"Edit Person dialog to fix the problem."),
|
|
||||||
_("Continue saving"), _("Return to window"),
|
|
||||||
self.window)
|
|
||||||
if not dialog.run():
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _check_and_update_id(self):
|
def _check_and_update_id(self):
|
||||||
original = self.db.get_person_from_handle(self.obj.get_handle())
|
original = self.db.get_person_from_handle(self.obj.get_handle())
|
||||||
@ -567,8 +561,7 @@ class EditPerson(EditPrimary):
|
|||||||
"enter data or cancel the edit."))
|
"enter data or cancel the edit."))
|
||||||
return
|
return
|
||||||
|
|
||||||
if self._check_for_unknown_gender():
|
self._check_for_unknown_gender()
|
||||||
return
|
|
||||||
|
|
||||||
set_birth_death_index(self.db, self.obj)
|
set_birth_death_index(self.db, self.obj)
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
@ -705,3 +698,24 @@ class EditPerson(EditPrimary):
|
|||||||
child_ref_list.insert(target, ref)
|
child_ref_list.insert(target, ref)
|
||||||
return child_ref_list
|
return child_ref_list
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GenderDialog(gtk.MessageDialog):
|
||||||
|
def __init__(self,parent=None):
|
||||||
|
gtk.MessageDialog.__init__(self,
|
||||||
|
parent,
|
||||||
|
flags=gtk.DIALOG_MODAL,
|
||||||
|
type=gtk.MESSAGE_QUESTION,
|
||||||
|
)
|
||||||
|
self.set_icon(ICON)
|
||||||
|
self.set_title('')
|
||||||
|
|
||||||
|
self.set_markup('<span size="larger" weight="bold">%s</span>' %
|
||||||
|
_('Unknown gender specified'))
|
||||||
|
self.format_secondary_text(
|
||||||
|
_("The gender of the person is currently unknown. "
|
||||||
|
"Usually, this is a mistake. Please specify the gender."))
|
||||||
|
|
||||||
|
self.add_button(_('Male'), RelLib.Person.MALE)
|
||||||
|
self.add_button(_('Female'), RelLib.Person.FEMALE)
|
||||||
|
self.add_button(_('Unknown'), RelLib.Person.UNKNOWN)
|
||||||
|
@ -116,7 +116,7 @@ class RemoveUnused:
|
|||||||
self.place.get_active())
|
self.place.get_active())
|
||||||
|
|
||||||
def run_tool(self, clean_events, clean_sources, clean_places):
|
def run_tool(self, clean_events, clean_sources, clean_places):
|
||||||
trans = self.db.transaction_begin("",batch=True)
|
trans = self.db.transaction_begin("",batch=False)
|
||||||
self.db.disable_signals()
|
self.db.disable_signals()
|
||||||
checker = CheckIntegrity(self.dbstate, self.uistate, trans)
|
checker = CheckIntegrity(self.dbstate, self.uistate, trans)
|
||||||
if clean_events:
|
if clean_events:
|
||||||
@ -132,7 +132,7 @@ class RemoveUnused:
|
|||||||
|
|
||||||
errs = checker.build_report()
|
errs = checker.build_report()
|
||||||
if errs:
|
if errs:
|
||||||
Report(uistate, checker.text.getvalue())
|
Report(self.uistate, checker.text.getvalue())
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -143,7 +143,11 @@ class CheckIntegrity:
|
|||||||
|
|
||||||
def __init__(self, dbstate, uistate, trans):
|
def __init__(self, dbstate, uistate, trans):
|
||||||
self.db = dbstate.db
|
self.db = dbstate.db
|
||||||
|
self.uistate = uistate
|
||||||
self.trans = trans
|
self.trans = trans
|
||||||
|
self.place_cnt = 0
|
||||||
|
self.source_cnt = 0
|
||||||
|
self.event_cnt = 0
|
||||||
self.progress = Utils.ProgressMeter(_('Checking database'),'')
|
self.progress = Utils.ProgressMeter(_('Checking database'),'')
|
||||||
|
|
||||||
def cleanup_events(self):
|
def cleanup_events(self):
|
||||||
@ -152,9 +156,9 @@ class CheckIntegrity:
|
|||||||
|
|
||||||
self.event_cnt = 0
|
self.event_cnt = 0
|
||||||
for handle in self.db.event_map.keys():
|
for handle in self.db.event_map.keys():
|
||||||
event = self.db.get_event_from_handle(handle)
|
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
||||||
if not self.db.find_backlink_handles(handle):
|
if len(hlist) == 0:
|
||||||
self.db.remove_event(handle)
|
self.db.remove_event(handle, self.trans)
|
||||||
self.event_cnt += 1
|
self.event_cnt += 1
|
||||||
|
|
||||||
def cleanup_sources(self):
|
def cleanup_sources(self):
|
||||||
@ -163,26 +167,26 @@ class CheckIntegrity:
|
|||||||
|
|
||||||
self.source_cnt = 0
|
self.source_cnt = 0
|
||||||
for handle in self.db.event_map.keys():
|
for handle in self.db.event_map.keys():
|
||||||
event = self.db.get_event_from_handle(handle)
|
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
||||||
if not self.db.find_backlink_handles(handle):
|
if len(hlist) == 0:
|
||||||
self.db.remove_event(handle)
|
self.db.remove_source(handle, self.trans)
|
||||||
self.source_cnt += 1
|
self.source_cnt += 1
|
||||||
|
|
||||||
def cleanup_places(self):
|
def cleanup_places(self):
|
||||||
self.progress.set_pass(_('Removing unused places'),
|
self.progress.set_pass(_('Removing unused places'),
|
||||||
self.db.get_number_of_places())
|
self.db.get_number_of_places())
|
||||||
|
|
||||||
self.source_cnt = 0
|
self.place_cnt = 0
|
||||||
for handle in self.db.place_map.keys():
|
for handle in self.db.place_map.keys():
|
||||||
event = self.db.get_place_from_handle(handle)
|
hlist = [ x for x in self.db.find_backlink_handles(handle)]
|
||||||
if not self.db.find_backlink_handles(handle):
|
if len(hlist) == 0:
|
||||||
self.db.remove_place(handle)
|
self.db.remove_place(handle, self.trans)
|
||||||
self.source_cnt += 1
|
self.place_cnt += 1
|
||||||
|
|
||||||
def build_report(self,cl=0):
|
def build_report(self,cl=0):
|
||||||
self.progress.close()
|
self.progress.close()
|
||||||
|
|
||||||
errors = self.event_cnt + self.source_cnt
|
errors = self.event_cnt + self.source_cnt + self.place_cnt
|
||||||
|
|
||||||
if errors == 0:
|
if errors == 0:
|
||||||
if cl:
|
if cl:
|
||||||
@ -205,6 +209,12 @@ class CheckIntegrity:
|
|||||||
else:
|
else:
|
||||||
self.text.write(_("%d non-referenced source removed\n") % self.source_cnt)
|
self.text.write(_("%d non-referenced source removed\n") % self.source_cnt)
|
||||||
|
|
||||||
|
if self.place_cnt > 0:
|
||||||
|
if self.place_cnt == 1:
|
||||||
|
self.text.write(_("1 non-referenced place removed\n"))
|
||||||
|
else:
|
||||||
|
self.text.write(_("%d non-referenced place removed\n") % self.place_cnt)
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -252,24 +262,6 @@ class CheckOptions(Tool.ToolOptions):
|
|||||||
def __init__(self,name,person_id=None):
|
def __init__(self,name,person_id=None):
|
||||||
Tool.ToolOptions.__init__(self,name,person_id)
|
Tool.ToolOptions.__init__(self,name,person_id)
|
||||||
|
|
||||||
def set_new_options(self):
|
|
||||||
self.options_dict = {
|
|
||||||
'rm_src' : 1,
|
|
||||||
'rm_event' : 1,
|
|
||||||
'rm_place' : 1,
|
|
||||||
}
|
|
||||||
self.options_help = {
|
|
||||||
'rm_src' : ("=0/1","Whether to remove unused sources",
|
|
||||||
["Do not remove unused sources","Remove unused sources"],
|
|
||||||
True),
|
|
||||||
'rm_event' : ("=0/1","Whether to remove unused events",
|
|
||||||
["Do not remove unused events","Remove unused events"],
|
|
||||||
True),
|
|
||||||
'rm_place' : ("=0/1","Whether to remove unused places",
|
|
||||||
["Do not remove unused places","Remove unused places"],
|
|
||||||
True),
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user