From 1e639caa4090a14efa68b5d1e83ddefa6d4b61cd Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Tue, 11 Sep 2012 21:08:20 +0000 Subject: [PATCH] Feature Fanchart: an add button to add parents in the fanchart view svn: r20372 --- src/gui/widgets/fanchart.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gui/widgets/fanchart.py b/src/gui/widgets/fanchart.py index b76f7de0a..c1f0eb856 100644 --- a/src/gui/widgets/fanchart.py +++ b/src/gui/widgets/fanchart.py @@ -55,7 +55,7 @@ from cgi import escape #------------------------------------------------------------------------- from gen.display.name import displayer as name_displayer from gen.errors import WindowActiveError -from gui.editors import EditPerson +from gui.editors import EditPerson, EditFamily import gen.lib import gui.utils from gui.ddtargets import DdTargets @@ -1493,6 +1493,8 @@ class FanChartGrampsGUI(object): # Go over parents and build their menu item = Gtk.MenuItem(label=_("Parents")) + item.set_submenu(Gtk.Menu()) + par_menu = item.get_submenu() no_parents = 1 par_list = find_parents(self.dbstate.db,person) for par_id in par_list: @@ -1502,8 +1504,6 @@ class FanChartGrampsGUI(object): if no_parents: no_parents = 0 - item.set_submenu(Gtk.Menu()) - par_menu = item.get_submenu() if find_parents(self.dbstate.db,par): label = Gtk.Label(label='%s' % escape(name_displayer.display(par))) @@ -1519,12 +1519,17 @@ class FanChartGrampsGUI(object): label.set_alignment(0,0) par_item.add(label) linked_persons.append(par_id) - par_item.connect("activate",self.on_childmenu_changed, par_id) + par_item.connect("activate", self.on_childmenu_changed, par_id) par_item.show() par_menu.append(par_item) if no_parents: - item.set_sensitive(0) + #show an add button + add_item = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_ADD, None) + add_item.connect("activate", self.on_add_parents, person_handle) + add_item.show() + par_menu.append(add_item) + item.show() menu.append(item) @@ -1565,7 +1570,7 @@ class FanChartGrampsGUI(object): menu.popup(None, None, None, None, event.button, event.time) return 1 - def edit_person_cb(self, obj,person_handle): + def edit_person_cb(self, obj, person_handle): person = self.dbstate.db.get_person_from_handle(person_handle) if person: try: @@ -1575,6 +1580,16 @@ class FanChartGrampsGUI(object): return True return False + def on_add_parents(self, obj, person_handle): + family = gen.lib.Family() + childref = gen.lib.ChildRef() + childref.set_reference_handle(person_handle) + family.add_child_ref(childref) + try: + EditFamily(self.dbstate, self.uistate, [], family) + except WindowActiveError: + return + def copy_person_to_clipboard_cb(self, obj,person_handle): """Renders the person data into some lines of text and puts that into the clipboard""" person = self.dbstate.db.get_person_from_handle(person_handle)