From 31c4ebcb7b2f989d459bcc02146165d393ae49d1 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 16 Apr 2003 06:25:38 +0000 Subject: [PATCH] Allow the user to select the entries to be modified. svn: r1452 --- gramps2/src/gramps_main.py | 2 +- gramps2/src/plugins/Check.py | 34 +++---- gramps2/src/plugins/PatchNames.py | 123 +++++++++++++++++-------- gramps2/src/plugins/patchnames.glade | 129 +++++++++++++++++++++++++++ 4 files changed, 234 insertions(+), 54 deletions(-) diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index 3eef08a15..86824b23c 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -1380,7 +1380,7 @@ class Gramps: def complete_rebuild(self): self.id2col = {} self.model_used = {} - self.alpha_page = {} + #self.alpha_page = {} self.tab_list = [] self.apply_filter() self.goto_active_person() diff --git a/gramps2/src/plugins/Check.py b/gramps2/src/plugins/Check.py index 05fb77b22..7ea20737b 100644 --- a/gramps2/src/plugins/Check.py +++ b/gramps2/src/plugins/Check.py @@ -25,7 +25,7 @@ import Utils from intl import gettext as _ import os - +import cStringIO import gtk import gtk.glade from QuestionDialog import OkDialog @@ -148,12 +148,12 @@ class CheckIntegrity: _('The database has passed internal checks')) return - text = "" + text = cStringIO.StringIO; if blink > 0: if blink == 1: - text = text + _("1 broken child/family link was fixed\n") + text.write(_("1 broken child/family link was fixed\n")) else: - text = text + _("%d broken child/family links were found\n") % blink + text.write(_("%d broken child/family links were found\n") % blink) for c in self.broken_links: cn = c[0].getPrimaryName().getName() f = c[1].getFather() @@ -165,14 +165,14 @@ class CheckIntegrity: pn = f.getPrimaryName().getName() else: pn = m.getPrimaryName().getName() - text = text + '\t' + \ - _("%s was removed from the family of %s\n") % (cn,pn) + text.write('\t') + text.write('_("%s was removed from the family of %s\n") % (cn,pn)') if plink > 0: if plink == 1: - text = text + _("1 broken spouse/family link was fixed\n") + text.write(_("1 broken spouse/family link was fixed\n")) else: - text = text + _("%d broken spouse/family links were found\n") % plink + text.write(_("%d broken spouse/family links were found\n") % plink) for c in self.broken_parent_links: cn = c[0].getPrimaryName().getName() f = c[1].getFather() @@ -184,21 +184,21 @@ class CheckIntegrity: pn = f.getPrimaryName().getName() else: pn = m.getPrimaryName().getName() - text = text + '\t' + \ - _("%s was restored to the family of %s\n") % (cn,pn) + text.write('\t') + text.write(_("%s was restored to the family of %s\n") % (cn,pn)) if efam == 1: - text = text + _("1 empty family was found\n") + text.write(_("1 empty family was found\n")) elif efam > 1: - text = text + _("%d empty families were found\n") % efam + text.write(_("%d empty families were found\n") % efam) if rel == 1: - text = text + _("1 corrupted family relationship fixed\n") + text.write(_("1 corrupted family relationship fixed\n")) elif rel > 1: - text = text + _("%d corrupted family relationship fixed\n") % rel + text.write(_("%d corrupted family relationship fixed\n") % rel) if photos == 1: - text = text + _("1 media object was referenced, but not found\n") + text.write(_("1 media object was referenced, but not found\n")) elif photos > 1: - text = text + _("%d media objects were referenced, but not found\n") % photos + text.write(_("%d media objects were referenced, but not found\n") % photos) base = os.path.dirname(__file__) glade_file = base + os.sep + "summary.glade" @@ -211,7 +211,7 @@ class CheckIntegrity: textwindow = topDialog.get_widget("textwindow") Utils.set_titles(top,topDialog.get_widget("title"),title) - textwindow.get_buffer().set_text(text) + textwindow.get_buffer().set_text(text.get_value()) top.show() #------------------------------------------------------------------------ diff --git a/gramps2/src/plugins/PatchNames.py b/gramps2/src/plugins/PatchNames.py index e91e0f810..b421bc411 100644 --- a/gramps2/src/plugins/PatchNames.py +++ b/gramps2/src/plugins/PatchNames.py @@ -33,6 +33,7 @@ import re # gnome/gtk # #------------------------------------------------------------------------- +import gobject import gtk import gtk.glade @@ -95,52 +96,102 @@ class PatchNames: msg = "" + if len(self.nick_list) > 0 or len(self.title_list) > 0: - for (id,name,nick) in self.nick_list: - p = self.db.getPerson(id) - msg = msg + _("%s will be extracted as a nickname from %s\n") % \ - (nick,p.getPrimaryName().getName()) - - for (id,title,nick) in self.title_list: - p = self.db.getPerson(id) - msg = msg + _("%s will be extracted as a title from %s\n") % \ - (title,p.getPrimaryName().getName()) - - base = os.path.dirname(__file__) - glade_file = base + os.sep + "patchnames.glade" - - self.top = gtk.glade.XML(glade_file,"summary") - self.top.signal_autoconnect({ - "destroy_passed_object" : Utils.destroy_passed_object, - "on_ok_clicked" : self.on_ok_clicked - }) - - Utils.set_titles(self.top.get_widget('summary'), - self.top.get_widget('title'), - _('Name and title extraction tool')) - - self.top.get_widget("textwindow").get_buffer().set_text(msg) + self.display() else: OkDialog(_('No modifications made'), _("No titles or nicknames were found")) self.cb(0) + def toggled(self,cell,path_string): + path = tuple([int (i) for i in path_string.split(':')]) + row = self.model[path] + row[0] = not row[0] + self.model.row_changed(path,row.iter) + + def display(self): + base = os.path.dirname(__file__) + glade_file = base + os.sep + "patchnames.glade" + + self.top = gtk.glade.XML(glade_file,"top") + self.top.signal_autoconnect({ + "destroy_passed_object" : Utils.destroy_passed_object, + "on_ok_clicked" : self.on_ok_clicked + }) + self.list = self.top.get_widget("list") + Utils.set_titles(self.top.get_widget('top'), + self.top.get_widget('title'), + _('Name and title extraction tool')) + + self.model = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, + gobject.TYPE_STRING, gobject.TYPE_STRING, + gobject.TYPE_STRING) + + r = gtk.CellRendererToggle() + r.connect('toggled',self.toggled) + c = gtk.TreeViewColumn(_('Select'),r,active=0) + self.list.append_column(c) + + c = gtk.TreeViewColumn(_('ID'),gtk.CellRendererText(),text=1) + self.list.append_column(c) + + c = gtk.TreeViewColumn(_('Type'),gtk.CellRendererText(),text=2) + self.list.append_column(c) + + c = gtk.TreeViewColumn(_('Value'),gtk.CellRendererText(),text=3) + self.list.append_column(c) + + c = gtk.TreeViewColumn(_('Name'),gtk.CellRendererText(),text=4) + self.list.append_column(c) + + self.list.set_model(self.model) + + self.nick_hash = {} + self.title_hash = {} + + for (id,name,nick) in self.nick_list: + p = self.db.getPerson(id) + iter = self.model.append() + self.model.set_value(iter,0,1) + self.model.set_value(iter,1,id) + self.model.set_value(iter,2,_('Nickname')) + self.model.set_value(iter,3,nick) + self.model.set_value(iter,4,p.getPrimaryName().getName()) + self.nick_hash[id] = iter + + for (id,title,nick) in self.title_list: + p = self.db.getPerson(id) + iter = self.model.append() + self.model.set_value(iter,0,1) + self.model.set_value(iter,1,id) + self.model.set_value(iter,2,_('Title')) + self.model.set_value(iter,3,nick) + self.model.set_value(iter,4,p.getPrimaryName().getName()) + self.title_hash[id] = iter + def on_ok_clicked(self,obj): for grp in self.nick_list: - p = self.db.getPerson(grp[0]) - name = p.getPrimaryName() - name.setFirstName(grp[1]) - p.setNickName(grp[2]) - self.db.buildPersonDisplay(grp[0]) - Utils.modified() + iter = self.nick_hash[grp[0]] + val = self.model.get_value(iter,0) + if val: + p = self.db.getPerson(grp[0]) + name = p.getPrimaryName() + name.setFirstName(grp[1]) + p.setNickName(grp[2]) + self.db.buildPersonDisplay(grp[0]) + Utils.modified() for grp in self.title_list: - p = self.db.getPerson(grp[0]) - name = p.getPrimaryName() - name.setFirstName(grp[2]) - name.setTitle(grp[1]) - self.db.buildPersonDisplay(grp[0]) - Utils.modified() + iter = self.title_hash[grp[0]] + val = self.model.get_value(iter,0) + if val: + p = self.db.getPerson(grp[0]) + name = p.getPrimaryName() + name.setFirstName(grp[2]) + name.setTitle(grp[1]) + self.db.buildPersonDisplay(grp[0]) + Utils.modified() Utils.destroy_passed_object(obj) self.cb(1) diff --git a/gramps2/src/plugins/patchnames.glade b/gramps2/src/plugins/patchnames.glade index d15cef659..b9715cfde 100644 --- a/gramps2/src/plugins/patchnames.glade +++ b/gramps2/src/plugins/patchnames.glade @@ -164,4 +164,133 @@ Should the following changes be made? + + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 500 + 450 + True + False + + + + 6 + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 6 + False + False + + + + + + True + Below is a list of the nicknames and titles that GRAMPS can extract from the +current database. If you accept the changes, GRAMPS will modify the entries +that have been selected. + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 10 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 6 + + + + True + True + True + _Accept changes and close + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + + + + + + 6 + False + True + + + + + +