2007-12-06 Douglas S.Blank <dblank@cs.brynmawr.edu>
* src/plugins/CalculateEstimatedDates.py: experimental click in text * src/PluginUtils/_PluginWindows.py: experimental write_results_link() svn: r9448
This commit is contained in:
parent
69fff5654a
commit
8be73592d6
@ -1,3 +1,7 @@
|
|||||||
|
2007-12-06 Douglas S.Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/plugins/CalculateEstimatedDates.py: experimental click in text
|
||||||
|
* src/PluginUtils/_PluginWindows.py: experimental write_results_link()
|
||||||
|
|
||||||
2007-12-05 Douglas S.Blank <dblank@cs.brynmawr.edu>
|
2007-12-05 Douglas S.Blank <dblank@cs.brynmawr.edu>
|
||||||
* src/plugins/CalculateEstimatedDates.py: set quality CALCULATED on
|
* src/plugins/CalculateEstimatedDates.py: set quality CALCULATED on
|
||||||
added dates
|
added dates
|
||||||
|
@ -241,6 +241,19 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
|
|||||||
def initial_frame(self):
|
def initial_frame(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def link_callback(self, button, person):
|
||||||
|
self.dbstate.change_active_person(person)
|
||||||
|
|
||||||
|
def results_write_link(self, text, person):
|
||||||
|
buffer = self.results_text.get_buffer()
|
||||||
|
iter = buffer.get_end_iter()
|
||||||
|
anchor = buffer.create_child_anchor(iter)
|
||||||
|
child = gtk.Button(text)
|
||||||
|
child.connect("clicked",
|
||||||
|
lambda button: self.link_callback(button, person))
|
||||||
|
self.results_text.add_child_at_anchor(child, anchor)
|
||||||
|
self.results_text.show_all()
|
||||||
|
|
||||||
def results_write(self, text):
|
def results_write(self, text):
|
||||||
buffer = self.results_text.get_buffer()
|
buffer = self.results_text.get_buffer()
|
||||||
mark = buffer.create_mark("end", buffer.get_end_iter())
|
mark = buffer.create_mark("end", buffer.get_end_iter())
|
||||||
@ -365,12 +378,16 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
|
|||||||
|
|
||||||
def add_results_frame(self,frame_name="Results"):
|
def add_results_frame(self,frame_name="Results"):
|
||||||
if frame_name not in self.frames:
|
if frame_name not in self.frames:
|
||||||
widget = (frame_name, self.results_text)
|
window = gtk.ScrolledWindow()
|
||||||
self.frames[frame_name] = [widget]
|
window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
||||||
|
window.add(self.results_text)
|
||||||
|
window.set_shadow_type(gtk.SHADOW_IN)
|
||||||
|
window.show_all()
|
||||||
|
self.frames[frame_name] = [[frame_name, window]]
|
||||||
self.frame_names.append(frame_name)
|
self.frame_names.append(frame_name)
|
||||||
l = gtk.Label("<b>%s</b>" % _(frame_name))
|
l = gtk.Label("<b>%s</b>" % _(frame_name))
|
||||||
l.set_use_markup(True)
|
l.set_use_markup(True)
|
||||||
self.notebook.append_page(widget[1], l)
|
self.notebook.append_page(window, l)
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
else:
|
else:
|
||||||
self.results_clear()
|
self.results_clear()
|
||||||
|
@ -40,7 +40,13 @@ from PluginUtils import Tool, register_tool, PluginWindows, \
|
|||||||
NumberOption
|
NumberOption
|
||||||
import gen.lib
|
import gen.lib
|
||||||
import Config
|
import Config
|
||||||
|
from BasicUtils import name_displayer
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Tool Classes
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
class CalcEstDateOptions(MenuToolOptions):
|
class CalcEstDateOptions(MenuToolOptions):
|
||||||
""" Calculate Estimated Date options """
|
""" Calculate Estimated Date options """
|
||||||
|
|
||||||
@ -70,6 +76,10 @@ class CalcEstDateOptions(MenuToolOptions):
|
|||||||
death.set_help(_("Add estimated death dates"))
|
death.set_help(_("Add estimated death dates"))
|
||||||
menu.add_option(category_name, "add_death", death)
|
menu.add_option(category_name, "add_death", death)
|
||||||
|
|
||||||
|
display_details = BooleanOption(_("Display detailed results"), False)
|
||||||
|
display_details.set_help(_("Show details for every date entered"))
|
||||||
|
menu.add_option(category_name, "display_details", display_details)
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
category_name = _("Config")
|
category_name = _("Config")
|
||||||
num = NumberOption(_("Maximum age"),
|
num = NumberOption(_("Maximum age"),
|
||||||
@ -114,6 +124,7 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
|
|||||||
add_birth = self.options.handler.options_dict['add_birth']
|
add_birth = self.options.handler.options_dict['add_birth']
|
||||||
add_death = self.options.handler.options_dict['add_death']
|
add_death = self.options.handler.options_dict['add_death']
|
||||||
remove_old = self.options.handler.options_dict['remove']
|
remove_old = self.options.handler.options_dict['remove']
|
||||||
|
display_details = self.options.handler.options_dict['display_details']
|
||||||
|
|
||||||
self.MIN_GENERATION_YEARS = self.options.handler.options_dict['MIN_GENERATION_YEARS']
|
self.MIN_GENERATION_YEARS = self.options.handler.options_dict['MIN_GENERATION_YEARS']
|
||||||
self.MAX_SIB_AGE_DIFF = self.options.handler.options_dict['MAX_SIB_AGE_DIFF']
|
self.MAX_SIB_AGE_DIFF = self.options.handler.options_dict['MAX_SIB_AGE_DIFF']
|
||||||
@ -168,6 +179,7 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
|
|||||||
source = self.get_or_create_source(source_text)
|
source = self.get_or_create_source(source_text)
|
||||||
for person_handle in people:
|
for person_handle in people:
|
||||||
self.progress.step()
|
self.progress.step()
|
||||||
|
added_birth, added_death = 0, 0
|
||||||
person = self.db.get_person_from_handle(person_handle)
|
person = self.db.get_person_from_handle(person_handle)
|
||||||
birth_ref = person.get_birth_ref()
|
birth_ref = person.get_birth_ref()
|
||||||
death_ref = person.get_death_ref()
|
death_ref = person.get_death_ref()
|
||||||
@ -183,12 +195,13 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
|
|||||||
event_ref.set_reference_handle(birth.get_handle())
|
event_ref.set_reference_handle(birth.get_handle())
|
||||||
person.set_birth_ref(event_ref)
|
person.set_birth_ref(event_ref)
|
||||||
self.db.commit_person(person, self.trans)
|
self.db.commit_person(person, self.trans)
|
||||||
|
added_birth = 1
|
||||||
if not death_ref and add_death and date2:
|
if not death_ref and add_death and date2:
|
||||||
current_date = gen.lib.Date()
|
current_date = gen.lib.Date()
|
||||||
current_date.set_yr_mon_day(*time.localtime(time.time())[0:3])
|
current_date.set_yr_mon_day(*time.localtime(time.time())[0:3])
|
||||||
if current_date.match( date2, "<<"):
|
if current_date.match( date2, "<<"):
|
||||||
# don't add events in the future!
|
# don't add events in the future!
|
||||||
pass
|
pass # FIXME: sometimes adds one in future?
|
||||||
else:
|
else:
|
||||||
#print "added death"
|
#print "added death"
|
||||||
death = self.create_event("Estimated death date",
|
death = self.create_event("Estimated death date",
|
||||||
@ -198,6 +211,15 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
|
|||||||
event_ref.set_reference_handle(death.get_handle())
|
event_ref.set_reference_handle(death.get_handle())
|
||||||
person.set_death_ref(event_ref)
|
person.set_death_ref(event_ref)
|
||||||
self.db.commit_person(person, self.trans)
|
self.db.commit_person(person, self.trans)
|
||||||
|
added_death = 1
|
||||||
|
if (added_birth or added_death) and display_details:
|
||||||
|
self.results_write_link(name_displayer.display(person),
|
||||||
|
person)
|
||||||
|
if added_birth:
|
||||||
|
self.results_write(" added birth on %s" % date1)
|
||||||
|
if added_death:
|
||||||
|
self.results_write(" added death on %s" % date2)
|
||||||
|
self.results_write("\n")
|
||||||
self.db.transaction_commit(self.trans, _("Calculate date estimates"))
|
self.db.transaction_commit(self.trans, _("Calculate date estimates"))
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.request_rebuild()
|
self.db.request_rebuild()
|
||||||
|
Loading…
Reference in New Issue
Block a user