2008-02-28 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/DefaultGramplets.py: new Pedigree Gramplet * src/DataViews/GrampletView.py: added help button on undocked windows svn: r10134
This commit is contained in:
parent
896ecd2949
commit
5f7c6c1c8a
@ -1,3 +1,7 @@
|
|||||||
|
2008-02-28 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/plugins/DefaultGramplets.py: new Pedigree Gramplet
|
||||||
|
* src/DataViews/GrampletView.py: added help button on undocked windows
|
||||||
|
|
||||||
2008-02-27 Raphael Ackermann <raphael.ackermann@gmail.com>
|
2008-02-27 Raphael Ackermann <raphael.ackermann@gmail.com>
|
||||||
* src/Editors/_EditNote.py: empty_object() add extratype to object
|
* src/Editors/_EditNote.py: empty_object() add extratype to object
|
||||||
0001476: Opening the new note dialog/editor and cancelling shouldn't ask
|
0001476: Opening the new note dialog/editor and cancelling shouldn't ask
|
||||||
|
@ -47,7 +47,20 @@ import ManagedWindow
|
|||||||
import ConfigParser
|
import ConfigParser
|
||||||
import Utils
|
import Utils
|
||||||
from QuickReports import run_quick_report_by_name
|
from QuickReports import run_quick_report_by_name
|
||||||
|
import GrampsDisplay
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Constants
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
WIKI_HELP_PAGE = 'Gramps_3.0_Wiki_Manual_-_Gramplets'
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Globals
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
AVAILABLE_GRAMPLETS = {}
|
AVAILABLE_GRAMPLETS = {}
|
||||||
GRAMPLET_FILENAME = os.path.join(const.HOME_DIR,"gramplets.ini")
|
GRAMPLET_FILENAME = os.path.join(const.HOME_DIR,"gramplets.ini")
|
||||||
NL = "\n"
|
NL = "\n"
|
||||||
@ -136,12 +149,21 @@ class GrampletWindow(ManagedWindow.ManagedWindow):
|
|||||||
gtk.DIALOG_DESTROY_WITH_PARENT,
|
gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
|
(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)),
|
||||||
None, self.title)
|
None, self.title)
|
||||||
|
self.window.add_button(gtk.STOCK_HELP, gtk.RESPONSE_HELP)
|
||||||
self.window.set_size_request(gramplet.detached_width,
|
self.window.set_size_request(gramplet.detached_width,
|
||||||
gramplet.detached_height)
|
gramplet.detached_height)
|
||||||
self.window.connect('response', self.close)
|
self.window.connect('response', self.handle_response)
|
||||||
self.gramplet.mainframe.reparent(self.window.vbox)
|
self.gramplet.mainframe.reparent(self.window.vbox)
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
|
def handle_response(self, object, response):
|
||||||
|
if response == gtk.RESPONSE_CLOSE:
|
||||||
|
self.close()
|
||||||
|
else:
|
||||||
|
# translated name:
|
||||||
|
GrampsDisplay.help('gramplet', WIKI_HELP_PAGE,
|
||||||
|
self.gramplet.tname.replace(" ", "_"))
|
||||||
|
|
||||||
def build_menu_names(self, obj):
|
def build_menu_names(self, obj):
|
||||||
return (self.title, 'Gramplet')
|
return (self.title, 'Gramplet')
|
||||||
|
|
||||||
@ -406,6 +428,7 @@ class GuiGramplet:
|
|||||||
self.title = title
|
self.title = title
|
||||||
########## Set defaults
|
########## Set defaults
|
||||||
self.name = kwargs.get("name", "Unnamed Gramplet")
|
self.name = kwargs.get("name", "Unnamed Gramplet")
|
||||||
|
self.tname = kwargs.get("tname", "Unnamed Gramplet")
|
||||||
self.expand = logical_true(kwargs.get("expand", False))
|
self.expand = logical_true(kwargs.get("expand", False))
|
||||||
self.height = int(kwargs.get("height", 200))
|
self.height = int(kwargs.get("height", 200))
|
||||||
self.column = int(kwargs.get("column", -1))
|
self.column = int(kwargs.get("column", -1))
|
||||||
@ -516,7 +539,7 @@ class GuiGramplet:
|
|||||||
self.textview.scroll_to_mark(end, 0.0, True, 0, 0)
|
self.textview.scroll_to_mark(end, 0.0, True, 0, 0)
|
||||||
elif scroll_to == "start": # beginning of this append
|
elif scroll_to == "start": # beginning of this append
|
||||||
self.textview.scroll_to_mark(start, 0.0, True, 0, 0)
|
self.textview.scroll_to_mark(start, 0.0, True, 0, 0)
|
||||||
elif scroll_to == "begin": # beginning of this append
|
elif scroll_to == "begin": # beginning of the buffer
|
||||||
begin_iter = self.buffer.get_start_iter()
|
begin_iter = self.buffer.get_start_iter()
|
||||||
begin = self.buffer.create_mark(None, begin_iter, True)
|
begin = self.buffer.create_mark(None, begin_iter, True)
|
||||||
self.textview.scroll_to_mark(begin, 0.0, True, 0, 0)
|
self.textview.scroll_to_mark(begin, 0.0, True, 0, 0)
|
||||||
|
@ -442,6 +442,78 @@ class RelativesGramplet(Gramplet):
|
|||||||
self.append_text(_("Unknown"))
|
self.append_text(_("Unknown"))
|
||||||
self.append_text("\n")
|
self.append_text("\n")
|
||||||
|
|
||||||
|
class PedigreeGramplet(Gramplet):
|
||||||
|
def init(self):
|
||||||
|
self.set_text(_("No Family Tree loaded."))
|
||||||
|
self.tooltip = _("Click name to make person active\n") + \
|
||||||
|
_("Right-click name to edit person")
|
||||||
|
self.max_generations = 100
|
||||||
|
|
||||||
|
def db_changed(self):
|
||||||
|
"""
|
||||||
|
If person or family changes, the relatives of active person might have
|
||||||
|
changed
|
||||||
|
"""
|
||||||
|
self.dbstate.db.connect('person-add', self.update)
|
||||||
|
self.dbstate.db.connect('person-delete', self.update)
|
||||||
|
self.dbstate.db.connect('family-add', self.update)
|
||||||
|
self.dbstate.db.connect('family-delete', self.update)
|
||||||
|
|
||||||
|
def active_changed(self, handle):
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def get_boxes(self, generation):
|
||||||
|
retval = ""
|
||||||
|
for i in range(generation+1):
|
||||||
|
if self._boxes[i]:
|
||||||
|
retval += " |"
|
||||||
|
else:
|
||||||
|
retval += " "
|
||||||
|
return retval + "--"
|
||||||
|
|
||||||
|
def process_person(self, handle, generation, what):
|
||||||
|
if generation > self.max_generations:
|
||||||
|
return
|
||||||
|
person = self.dbstate.db.get_person_from_handle(handle)
|
||||||
|
family_list = person.get_parent_family_handle_list()
|
||||||
|
if what == "f":
|
||||||
|
if len(family_list) > 0:
|
||||||
|
family = self.dbstate.db.get_family_from_handle(family_list[0])
|
||||||
|
father = family.get_father_handle()
|
||||||
|
if father:
|
||||||
|
self.process_person(father, generation + 1, "f")
|
||||||
|
self._boxes[generation] = 1
|
||||||
|
self.process_person(father, generation + 1, "s")
|
||||||
|
self.process_person(father, generation + 1, "m")
|
||||||
|
if what == "s":
|
||||||
|
self.append_text(self.get_boxes(generation))
|
||||||
|
self.link(name_displayer.display_name(person.get_primary_name()),
|
||||||
|
'Person', person.handle)
|
||||||
|
self.append_text("\n")
|
||||||
|
if what == "m":
|
||||||
|
if len(family_list) > 0:
|
||||||
|
family = self.dbstate.db.get_family_from_handle(family_list[0])
|
||||||
|
mother = family.get_mother_handle()
|
||||||
|
if mother:
|
||||||
|
self.process_person(mother, generation + 1, "f")
|
||||||
|
self.process_person(mother, generation + 1, "s")
|
||||||
|
self._boxes[generation] = 0
|
||||||
|
self.process_person(mother, generation + 1, "m")
|
||||||
|
|
||||||
|
def main(self): # return false finishes
|
||||||
|
"""
|
||||||
|
Generator which will be run in the background.
|
||||||
|
"""
|
||||||
|
self._boxes = [0] * self.max_generations
|
||||||
|
self.set_text("")
|
||||||
|
active_person = self.dbstate.get_active_person()
|
||||||
|
if not active_person:
|
||||||
|
return False
|
||||||
|
self.process_person(active_person.handle, 1, "f")
|
||||||
|
self.process_person(active_person.handle, 1, "s")
|
||||||
|
self.process_person(active_person.handle, 1, "m")
|
||||||
|
self.append_text("", scroll_to="begin")
|
||||||
|
|
||||||
class StatsGramplet(Gramplet):
|
class StatsGramplet(Gramplet):
|
||||||
def init(self):
|
def init(self):
|
||||||
self.set_text(_("No Family Tree loaded."))
|
self.set_text(_("No Family Tree loaded."))
|
||||||
@ -903,3 +975,11 @@ register(type="gramplet",
|
|||||||
detached_width = 250,
|
detached_width = 250,
|
||||||
detached_height = 300,
|
detached_height = 300,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
register(type="gramplet",
|
||||||
|
name="Pedigree Gramplet",
|
||||||
|
tname=_("Pedigree Gramplet"),
|
||||||
|
height=300,
|
||||||
|
content = PedigreeGramplet,
|
||||||
|
title=_("Pedigree"),
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user