diff --git a/gramps/src/plugins/Desbrowser.py b/gramps/src/plugins/Desbrowser.py index ff038d2ee..56645f076 100644 --- a/gramps/src/plugins/Desbrowser.py +++ b/gramps/src/plugins/Desbrowser.py @@ -21,11 +21,10 @@ "Analysis and Exploration/Interactive descendant browser" from RelLib import * -import re -import string import os import utils import intl +import Config _ = intl.gettext @@ -39,45 +38,47 @@ from libglade import * # #------------------------------------------------------------------------ def runTool(database,person,callback): - global active_person - global topDialog - global glade_file - global db - - active_person = person - db = database + DesBrowse(database,person,callback) - base = os.path.dirname(__file__) - glade_file = base + os.sep + "desbrowse.glade" +class DesBrowse: + def __init__(self,database,person,callback): + self.active = person + self.db = database + self.callback = callback - topDialog = GladeXML(glade_file,"top") - topDialog.signal_autoconnect({ - "destroy_passed_object" : utils.destroy_passed_object, - }) - top = topDialog.get_widget("top") - tree= topDialog.get_widget("tree1") + base = os.path.dirname(__file__) + glade_file = base + os.sep + "desbrowse.glade" - add_to_tree(tree,active_person) + self.glade = GladeXML(glade_file,"top") + self.glade.signal_autoconnect({ + "destroy_passed_object" : utils.destroy_passed_object, + }) + top = self.glade.get_widget("top") + tree= self.glade.get_widget("tree1") + + self.add_to_tree(tree,self.active) + top.show() - top.show() + def add_to_tree(self,tree,person): + item = GtkTreeItem(Config.nameof(person)) + item.show() + item.connect('button-press-event',self.button_press_event) + item.set_data('d',person) + tree.append(item) + subtree = None + for family in person.getFamilyList(): + for child in family.getChildList(): + if subtree == None: + subtree = GtkTree() + subtree.show() + item.set_subtree(subtree) + self.add_to_tree(subtree,child) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def add_to_tree(tree,person): - item = GtkTreeItem(person.getPrimaryName().getName()) - item.show() - tree.append(item) - subtree = None - for family in person.getFamilyList(): - for child in family.getChildList(): - if subtree == None: - subtree = GtkTree() - subtree.show() - item.set_subtree(subtree) - add_to_tree(subtree,child) + def button_press_event(self,obj,event): + import EditPerson + if event.button == 1 and event.type == GDK._2BUTTON_PRESS: + person = obj.get_data('d') + EditPerson.EditPerson(person,self.db,self.callback) #------------------------------------------------------------------------ # @@ -93,3 +94,4 @@ register_tool( description=_("Provides a browsable hierarchy based on the active person") ) + diff --git a/gramps/src/plugins/Merge.py b/gramps/src/plugins/Merge.py index 545d1fcfa..51dc4bd3a 100644 --- a/gramps/src/plugins/Merge.py +++ b/gramps/src/plugins/Merge.py @@ -74,20 +74,6 @@ def get_name_obj(p1): else: return p1.getPrimaryName() -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_merge_ok_clicked(obj): - - myobj = obj.get_data("t") - active = myobj.menu.get_menu().get_active().get_data("v") - myobj.use_soundex = myobj.soundex_obj.get_active() - utils.destroy_passed_object(obj) - myobj.find_potentials(active) - myobj.show() - #------------------------------------------------------------------------- # # @@ -118,7 +104,6 @@ class Merge: self.glade_file = base + os.sep + "merge.glade" top = GladeXML(self.glade_file,"dialog") topWin = top.get_widget("dialog") - topWin.set_data("t",self) my_menu = GtkMenu() item = GtkMenuItem(_("Low")) @@ -139,9 +124,18 @@ class Merge: self.menu.set_menu(my_menu) top.signal_autoconnect({ - "on_merge_ok_clicked" : on_merge_ok_clicked, + "on_merge_ok_clicked" : self.on_merge_ok_clicked, "destroy_passed_object" : utils.destroy_passed_object }) + + def on_merge_ok_clicked(self,obj): + + active = self.menu.get_menu().get_active().get_data("v") + self.use_soundex = self.soundex_obj.get_active() + utils.destroy_passed_object(obj) + self.find_potentials(active) + self.show() + #--------------------------------------------------------------------- # @@ -227,18 +221,26 @@ class Merge: self.altname = self.topDialog.get_widget("altname") self.topDialog.signal_autoconnect({ - "on_next_clicked" : on_next_clicked, - "on_merge_clicked" : on_merge_clicked, - "destroy_passed_object" : update_and_destroy + "on_next_clicked" : self.on_next_clicked, + "on_merge_clicked" : self.on_merge_clicked, + "destroy_passed_object" : self.update_and_destroy }) if len(self.map) > 0: top = self.topDialog.get_widget("merge") - top.set_data("MergeObject",self) top.show() - top.set_data("t",self) self.load_next() + def on_merge_clicked(self,obj): + self.merge() + + def on_next_clicked(self,obj): + self.load_next() + + def update_and_destroy(self,obj): + self.update(1) + utils.destroy_passed_object(obj) + #--------------------------------------------------------------------- # # @@ -914,33 +916,6 @@ class Merge: def runTool(database,active_person,callback): mergeObj = Merge(database,callback) -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def update_and_destroy(obj): - obj.get_data("t").update(1) - utils.destroy_passed_object(obj) - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_next_clicked(obj): - myObject = obj.get_data("MergeObject") - myObject.load_next() - -#------------------------------------------------------------------------- -# -# -# -#------------------------------------------------------------------------- -def on_merge_clicked(obj): - myObject = obj.get_data("MergeObject") - myObject.merge() - #------------------------------------------------------------------------- # # diff --git a/gramps/src/plugins/merge.glade b/gramps/src/plugins/merge.glade index 32a057ed0..0948de78b 100644 --- a/gramps/src/plugins/merge.glade +++ b/gramps/src/plugins/merge.glade @@ -129,7 +129,7 @@ 0 0 - 0 + 10 False False @@ -159,6 +159,7 @@ GtkFrame PersonFrame1 + 300 0 GTK_SHADOW_ETCHED_IN @@ -787,6 +788,7 @@ GtkFrame PersonFrame2 + 300 0 GTK_SHADOW_ETCHED_IN @@ -1420,7 +1422,7 @@ 0 10 - True + False True @@ -1478,7 +1480,7 @@ hseparator8 0 - True + False True @@ -1490,7 +1492,7 @@ 0 0 - True + False True