From 30c8de7bc37b1d9e2154b3cf596df725dfb911b5 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sun, 5 Feb 2006 01:23:25 +0000 Subject: [PATCH] * src/TransTable.py: removed * src/AddSpouse.py: removed * src/Marriage.py: removed * src/GrampsDb/_ReadGedcom.py: remove useless comparea svn: r5884 --- gramps2/ChangeLog | 5 +- gramps2/src/AddSpouse.py | 399 ---------------- gramps2/src/EditRepository.py | 2 - gramps2/src/EditSource.py | 2 - gramps2/src/ImageSelect.py | 53 --- gramps2/src/Marriage.py | 872 ---------------------------------- gramps2/src/MediaView.py | 56 ++- gramps2/src/TransTable.py | 66 --- 8 files changed, 58 insertions(+), 1397 deletions(-) delete mode 100644 gramps2/src/AddSpouse.py delete mode 100644 gramps2/src/Marriage.py delete mode 100644 gramps2/src/TransTable.py diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5acdf88fe..3f1aac618 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,7 @@ 2006-02-04 Don Allingham + * src/TransTable.py: removed + * src/AddSpouse.py: removed + * src/Marriage.py: removed * src/AddMedia.py: relative path support * src/AddrEdit.py: add DisplayTab support * src/DdTargets.py: repository references support @@ -12,7 +15,7 @@ relative paths work * src/edit_person.glade: fix size * src/gramps.glade: add relative path indicator - * src/GrampsDb/_ReadGedcom.py: remove useless compare + * src/GrampsDb/_ReadGedcom.py: remove useless comparea 2006-02-03 Don Allingham * src/AttrEdit.py: use DisplayTabs diff --git a/gramps2/src/AddSpouse.py b/gramps2/src/AddSpouse.py deleted file mode 100644 index ee9564ca1..000000000 --- a/gramps2/src/AddSpouse.py +++ /dev/null @@ -1,399 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2000-2006 Donald N. Allingham -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -# $Id$ - -""" -The AddSpouse module provides the AddSpouse class that allows the user to -add a new spouse to the active person. -""" - -__author__ = "Donald N. Allingham" -__version__ = "$Revision$" - -#------------------------------------------------------------------------- -# -# internationalization -# -#------------------------------------------------------------------------- -from gettext import gettext as _ -import gc - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gtk.glade -import gobject - -#------------------------------------------------------------------------- -# -# gramps modules -# -#------------------------------------------------------------------------- -import GrampsDisplay -import RelLib -import const -import Utils -import PeopleModel -import Marriage -import NameDisplay -import GenericFilter -from QuestionDialog import ErrorDialog, QuestionDialog2 -import AutoComp -from WindowUtils import GladeIf - -#------------------------------------------------------------------------- -# -# AddSpouse -# -#------------------------------------------------------------------------- -class AddSpouse: - """ - Displays the AddSpouse dialog, allowing the user to create a new - family with the passed person as one spouse, and another person to - be selected. - """ - def __init__(self,parent,db,person,family=None): - """ - Displays the AddSpouse dialog box. - - db - database to which to add the new family - person - the current person, will be one of the parents - """ - self.parent = parent - self.db = db - self.person = person - self.gender = self.person.get_gender() - self.active_family = family - - self.likely = self.build_likely(self.gender) - self.all = self.build_all() - self.filter = self.likely - - # determine the gender of the people to be loaded into - # the potential spouse list. If Partners is selected, use - # the same gender as the current person. - - self.glade = gtk.glade.XML(const.gladeFile, "spouseDialog","gramps") - self.gladeif = GladeIf(self.glade) - - self.rel_combo = self.glade.get_widget("rel_combo") - self.spouse_list = self.glade.get_widget("spouse_list") - self.showall = self.glade.get_widget('showall') - - self.renderer = gtk.CellRendererText() - - self.selection = self.spouse_list.get_selection() - self.selection.connect('changed',self.select_row) - self.add_columns(self.spouse_list) - - self.ok = self.glade.get_widget('spouse_ok') - self.ok.set_sensitive(0) - - name = NameDisplay.displayer.display(person) - title = _("Choose Spouse/Partner of %s") % name - - self.window = self.glade.get_widget('spouseDialog') - Utils.set_titles(self.window, - self.glade.get_widget('title'),title, - _('Choose Spouse/Partner')) - - self.gladeif.connect('button117','clicked',self.close) - self.gladeif.connect('spouseDialog','delete_event',self.delete_event) - self.gladeif.connect('spouse_ok','clicked',self.select_spouse_clicked) - self.gladeif.connect('spouse_help','clicked',self.on_spouse_help_clicked) - self.gladeif.connect('spouseNewPerson','clicked',self.new_spouse_clicked) - self.gladeif.connect('showall','clicked',self.on_show_toggled) - - self.rel_selector = AutoComp.StandardCustomSelector( - Utils.family_relations,self.rel_combo, - RelLib.Family.CUSTOM,RelLib.Family.MARRIED) - - self.set_gender() - self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) - gobject.idle_add(self.update_data) - - def delete_event(self,obj): - self.gladeif.close() - - def close(self,obj): - self.gladeif.close() - self.window.destroy() - - def build_all(self): - return None - - def build_likely(self,gender): - birth_ref = self.person.get_birth_ref() - death_ref = self.person.get_death_ref() - - filt = GenericFilter.GenericFilter() - filt.add_rule(LikelyFilter([self.person.handle,self.person.gender])) - - if birth_ref: - birth = self.db.get_event_from_handle(birth_ref.ref) - date_obj = RelLib.Date(birth.get_date_object()) - year = date_obj.get_year() - if year: - date_obj.set_year(year-50) - date_obj.set_modifier(RelLib.Date.MOD_AFTER) - text = DateHandler.displayer.display(date_obj) - rule = GenericFilter.HasBirth([text,"",""]) - filt.add_rule(rule) - return filt - - def add_columns(self,tree): - column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0) - column.set_resizable(True) - column.set_min_width(225) - tree.append_column(column) - column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1) - column.set_resizable(True) - column.set_min_width(75) - tree.append_column(column) - column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3) - column.set_clickable(True) - tree.append_column(column) - - def on_spouse_help_clicked(self,obj): - """Display the relevant portion of GRAMPS manual""" - GrampsDisplay.help('gramps-edit-quick') - - def get_selected_ids(self): - mlist = [] - self.selection.selected_foreach(self.select_function,mlist) - return mlist - - def select_function(self,store,path,iter,id_list): - id_list.append(store.get_value(iter,PeopleModel.COLUMN_INT_ID)) - - def select_row(self,obj): - """ - Called with a row has be unselected. Used to enable the OK button - when a row has been selected. - """ - idlist = self.get_selected_ids() - if idlist and idlist[0]: - self.ok.set_sensitive(True) - else: - self.ok.set_sensitive(False) - - def new_spouse_clicked(self,obj): - """ - Called when the spouse to be added does not exist, and needs - to be created and added to the database - """ - import EditPerson - - rel_i,rel_s = self.rel_selector.get_values() - if rel_i == RelLib.Family.CIVIL_UNION: - if self.person.get_gender() == RelLib.Person.MALE: - gen = RelLib.Person.MALE - else: - gen = RelLib.Person.FEMALE - elif self.person.get_gender() == RelLib.Person.MALE: - gen = RelLib.Person.FEMALE - else: - gen = RelLib.Person.MALE - - person = RelLib.Person() - person.set_gender(gen) - EditPerson.EditPerson(self.parent,person,self.db,self.update_list) - - def update_list(self,epo,change): - """ - Updates the potential spouse list after a person has been added - to database. Called by the QuickAdd class when the dialog has - been closed. - """ - person = epo.person - self.update_data() - - self.slist = PeopleModel.PeopleModel(self.db,self.filter) - self.slist.rebuild_data() - self.spouse_list.set_model(self.slist) - - path = self.slist.on_get_path(person.get_handle()) - top_path = self.slist.on_get_path(person.get_primary_name().get_surname()) - self.spouse_list.expand_row(top_path,0) - self.selection.select_path(path) - - def select_spouse_clicked(self,obj): - """ - Called when the spouse to be added already exists and has been - selected from the list. - """ - - idlist = self.get_selected_ids() - if not idlist or not idlist[0]: - return - - spouse = self.db.get_person_from_handle(idlist[0]) - spouse_id = spouse.get_handle() - - # don't do anything if adding self - if spouse_id == self.person.get_handle(): - ErrorDialog(_("Error adding a spouse"), - _("A person cannot be linked as his/her spouse")) - return - - # display warning if adding a parent - for (family_handle,frel,mrel) in self.person.get_parent_family_handle_list(): - family = self.db.get_family_from_handle(family_handle) - if spouse_id in [family.get_mother_handle(),family.get_father_handle()]: - dialog = QuestionDialog2( - _("Spouse is a parent"), - _("The person selected as a spouse is a parent of the " - "active person. Usually, this is a mistake. You may " - "choose either to proceed with adding a spouse, or to " - "return to the Choose Spouse dialog to fix the problem."), - _("Proceed with adding"), _("Return to dialog"), - self.window) - if not dialog.run(): - return - - # don't do anything if the marriage already exists - for f in self.person.get_family_handle_list(): - fam = self.db.get_family_from_handle(f) - if fam: - if spouse_id in \ - (fam.get_mother_handle(),fam.get_father_handle()): - ErrorDialog(_("Error adding a spouse"), - _("The spouse is already present in this family")) - return - if spouse_id in fam.get_child_handle_list(): - dialog = QuestionDialog2( - _("Spouse is a child"), - _("The person selected as a spouse is a child of the " - "active person. Usually, this is a mistake. You may " - "choose either to proceed with adding a spouse, or to " - "return to the Choose Spouse dialog to fix the problem."), - _("Proceed with adding"), _("Return to dialog"), - self.window) - if not dialog.run(): - return - - trans = self.db.transaction_begin() - - if not self.active_family: - self.active_family = RelLib.Family() - gid = self.db.find_next_family_gramps_id() - self.active_family.set_gramps_id(gid) - self.active_family.set_handle(self.db.create_id()) - self.person.add_family_handle(self.active_family.get_handle()) - self.db.commit_person(self.person,trans) - - spouse.add_family_handle(self.active_family.get_handle()) - self.db.commit_person(spouse,trans) - - if self.person.get_gender() == RelLib.Person.MALE: - self.active_family.set_mother_handle(spouse.get_handle()) - self.active_family.set_father_handle(self.person.get_handle()) - else: - self.active_family.set_father_handle(spouse.get_handle()) - self.active_family.set_mother_handle(self.person.get_handle()) - - rtype = self.rel_selector.get_values() - self.active_family.set_relationship(rtype) - self.db.commit_family(self.active_family,trans) - self.db.transaction_commit(trans,_("Add Spouse")) - - Utils.destroy_passed_object(obj) - gc.collect() - m = Marriage.Marriage(self.parent, self.active_family, self.parent.db) - m.on_add_clicked() - - def relation_type_changed(self,obj): - gobject.idle_add(self.update_data) - - def set_gender(self): - rel_i,rel_s = self.rel_selector.get_values() - if rel_i == RelLib.Family.CIVIL_UNION: - if self.gender == RelLib.Person.MALE: - self.sgender = RelLib.Person.FEMALE - else: - self.sgender = RelLib.Person.MALE - else: - if self.gender == RelLib.Person.MALE: - self.sgender = RelLib.Person.MALE - else: - self.sgender = RelLib.Person.FEMALE - - def update_data(self): - """ - Called whenever the relationship type changes. Rebuilds the - the potential spouse list. - """ - self.window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) - while(gtk.events_pending()): - gtk.main_iteration() - self.slist = PeopleModel.PeopleModel(self.db,self.filter) - self.spouse_list.set_model(self.slist) - self.window.window.set_cursor(None) - - def on_show_toggled(self,obj): - if self.filter == self.likely: - self.filter = self.all - else: - self.filter = self.likely - gobject.idle_add(self.update_data) - - -#------------------------------------------------------------------------- -# -# Likely Filters -# -#------------------------------------------------------------------------- -class LikelyFilter(GenericFilter.Rule): - - labels = [ 'Person handle', 'Person gender' ] - category = _('General filters') - - def prepare(self,db): - person = db.get_person_from_handle(self.list[0]) - if person.birth_handle: - birth = db.get_event_from_handle(person.birth_handle) - dateobj = RelLib.Date(birth.date) - year = dateobj.get_year() - dateobj.set_year(year+40) - self.lower = dateobj.sortval - dateobj.set_year(year-40) - self.upper = dateobj.sortval - else: - self.upper = None - self.lower = None - - if person.gender == RelLib.Person.MALE: - self.gender = RelLib.Person.FEMALE - else: - self.gender = RelLib.Person.MALE - - def apply(self,db,person): - if person.gender != self.gender: - return False - if not person.birth_handle or (self.upper == None and - self.lower == None): - return True - event = db.get_event_from_handle(person.birth_handle) - return (event.date == None or event.date.sortval == 0 or - self.lower > event.date.sortval > self.upper) - diff --git a/gramps2/src/EditRepository.py b/gramps2/src/EditRepository.py index f519674c3..5e6c57a87 100644 --- a/gramps2/src/EditRepository.py +++ b/gramps2/src/EditRepository.py @@ -43,8 +43,6 @@ import gtk.gdk #------------------------------------------------------------------------- import const import Utils -import ImageSelect -import ListModel import RelLib import NameDisplay import AutoComp diff --git a/gramps2/src/EditSource.py b/gramps2/src/EditSource.py index a56313fbd..fb5ec84b9 100644 --- a/gramps2/src/EditSource.py +++ b/gramps2/src/EditSource.py @@ -47,8 +47,6 @@ import gtk.glade #------------------------------------------------------------------------- import const import Utils -import ImageSelect -import ListModel import RelLib import NameDisplay import RepositoryRefEdit diff --git a/gramps2/src/ImageSelect.py b/gramps2/src/ImageSelect.py index 1f1da2f33..f3654295a 100644 --- a/gramps2/src/ImageSelect.py +++ b/gramps2/src/ImageSelect.py @@ -340,59 +340,6 @@ class LocalMediaProperties: PluginMgr.get_image_attributes(), self.attr_callback) -class DeleteMediaQuery: - - def __init__(self,media_handle,db,the_lists): - self.db = db - self.media_handle = media_handle - self.the_lists = the_lists - - def query_response(self): - trans = self.db.transaction_begin() - self.db.disable_signals() - - (person_list,family_list,event_list, - place_list,source_list) = self.the_lists - - for handle in person_list: - person = self.db.get_person_from_handle(handle) - new_list = [ photo for photo in person.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] - person.set_media_list(new_list) - self.db.commit_person(person,trans) - - for handle in family_list: - family = self.db.get_family_from_handle(handle) - new_list = [ photo for photo in family.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] - family.set_media_list(new_list) - self.db.commit_family(family,trans) - - for handle in event_list: - event = self.db.get_event_from_handle(handle) - new_list = [ photo for photo in event.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] - event.set_media_list(new_list) - self.db.commit_event(event,trans) - - for handle in place_list: - place = self.db.get_place_from_handle(handle) - new_list = [ photo for photo in place.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] - place.set_media_list(new_list) - self.db.commit_place(place,trans) - - for handle in source_list: - source = self.db.get_source_from_handle(handle) - new_list = [ photo for photo in source.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] - source.set_media_list(new_list) - self.db.commit_source(source,trans) - - self.db.enable_signals() - self.db.remove_object(self.media_handle,trans) - self.db.transaction_commit(trans,_("Remove Media Object")) - def build_dropdown(entry,strings): store = gtk.ListStore(str) for value in strings: diff --git a/gramps2/src/Marriage.py b/gramps2/src/Marriage.py deleted file mode 100644 index c75c4a893..000000000 --- a/gramps2/src/Marriage.py +++ /dev/null @@ -1,872 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2000-2006 Donald N. Allingham -# -# This program is free software; you can redistribute it and/or modiy -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -# $Id$ - -#------------------------------------------------------------------------- -# -# Python modules -# -#------------------------------------------------------------------------- -import cPickle as pickle -from gettext import gettext as _ -import sets -from cgi import escape - -#------------------------------------------------------------------------- -# -# GTK/Gnome modules -# -#------------------------------------------------------------------------- -import gtk -import gtk.gdk -import gtk.glade - -#------------------------------------------------------------------------- -# -# gramps modules -# -#------------------------------------------------------------------------- - -import const -import Utils -import AutoComp -import ListModel -import ListBox -import RelLib -import ImageSelect -import DateHandler -import Sources -import GrampsKeys -import NameDisplay -import DateEdit -import DateHandler -import Spell -import GrampsDisplay - -from QuestionDialog import QuestionDialog, WarningDialog, SaveDialog -from DdTargets import DdTargets -from WindowUtils import GladeIf - -#------------------------------------------------------------------------- -# -# Globals -# -#------------------------------------------------------------------------- -_temple_names = const.lds_temple_codes.keys() -_temple_names.sort() -_temple_names = [""] + _temple_names - - -#------------------------------------------------------------------------- -# -# Marriage class -# -#------------------------------------------------------------------------- -class Marriage: - - def __init__(self,parent,family,db): - """Initializes the Marriage class, and displays the window""" - family_handle = family.get_handle() - # UGLY HACK to refresh faimly object from handle if that exists - # done to ensure that the family object is not stale, as it could - # have been changed by something external (merge, tool, etc). - if family_handle: - family = db.get_family_from_handle(family_handle) - self.family = family - self.parent = parent - if self.parent.child_windows.has_key(family_handle): - self.parent.child_windows[family_handle].present(None) - return - self.child_windows = {} - self.db = db - self.path = db.get_save_path() - self.pmap = {} - self.dp = DateHandler.parser - - if family: - self.srcreflist = family.get_source_references() - else: - self.srcreflist = [] - - for key in db.get_place_handles(): - p = db.get_place_from_handle(key).get_display_info() - self.pmap[p[0]] = key - - self.top = gtk.glade.XML(const.gladeFile,"marriageEditor","gramps") - self.gladeif = GladeIf(self.top) - - self.window = self.get_widget("marriageEditor") - - Utils.set_titles(self.window, self.top.get_widget('title'), - _('Marriage/Relationship Editor')) - - self.icon_list = self.get_widget('iconlist') - self.gallery = ImageSelect.Gallery(family, self.db.commit_family, - self.path, self.icon_list, db, self) - - self.gladeif.connect('marriageEditor','delete_event',self.on_delete_event) - self.gladeif.connect('button108','clicked',self.on_cancel_edit) - self.gladeif.connect('ok','clicked',self.on_close) - self.gladeif.connect('button119','clicked',self.on_help_clicked) - self.gladeif.connect('notebook4','switch_page',self.on_switch_page) - self.gladeif.connect('marriage_add','clicked',self.on_add_clicked) - self.gladeif.connect('button116','clicked',self.on_event_update_clicked) - self.gladeif.connect('marriage_del','clicked',self.on_delete_clicked) - self.gladeif.connect('attr_add','clicked',self.on_add_attr_clicked) - self.gladeif.connect('button118','clicked',self.on_update_attr_clicked) - self.gladeif.connect('attr_del','clicked',self.on_delete_attr_clicked) - self.gladeif.connect('media_add','clicked',self.gallery.on_add_media_clicked) - self.gladeif.connect('media_sel','clicked',self.gallery.on_select_media_clicked) - self.gladeif.connect('button117','clicked',self.gallery.on_edit_media_clicked) - self.gladeif.connect('media_del','clicked',self.gallery.on_delete_media_clicked) - self.gladeif.connect('button114','clicked',self.lds_src_clicked) - self.gladeif.connect('button115','clicked',self.lds_note_clicked) - - mode = not self.db.readonly - - fid = family.get_father_handle() - mid = family.get_mother_handle() - - father = self.db.get_person_from_handle(fid) - mother = self.db.get_person_from_handle(mid) - - self.title = _("%s and %s") % (escape(NameDisplay.displayer.display(father)), - escape(NameDisplay.displayer.display(mother))) - - Utils.set_title_label(self.top,self.title) - - self.event_ref_list = self.get_widget("marriageEventList") - - if gtk.gdk.screen_height() > 700: - self.event_ref_list.set_size_request(500,250) - else: - self.event_ref_list.set_size_request(500,-1) - - # widgets - self.complete = self.get_widget('complete') - self.complete.set_sensitive(mode) - self.type_field = self.get_widget("marriage_type") - self.type_field.set_sensitive(mode) - self.notes_field = self.get_widget("marriageNotes") - self.notes_field.set_editable(mode) - self.spell = Spell.Spell(self.notes_field) - self.gid = self.get_widget("gid") - self.gid.set_editable(mode) - self.attr_list = self.get_widget("attr_list") - event_add_btn = self.get_widget("marriage_add") - event_edit_btn = self.get_widget("marriage_edit") - event_delete_btn = self.get_widget("marriage_del") - event_sel_btn = self.get_widget("marriage_sel") - attr_add_btn = self.get_widget("attr_add") - attr_edit_btn = self.get_widget("attr_edit") - attr_del_btn = self.get_widget("attr_del") - self.lds_date = self.get_widget("lds_date") - self.lds_date.set_editable(mode) - self.lds_date_led = self.get_widget("lds_date_stat") - self.lds_date_led.set_sensitive(mode) - self.lds_temple = self.get_widget("lds_temple") - self.lds_temple.set_sensitive(mode) - self.lds_status = self.get_widget("lds_status") - self.lds_status.set_sensitive(mode) - self.lds_place = self.get_widget("lds_place") - self.lds_place.set_sensitive(mode) - self.slist = self.get_widget("slist") - self.sources_label = self.get_widget("sourcesMarriage") - self.gallery_label = self.get_widget("galleryMarriage") - self.sources_label = self.get_widget("sourcesMarriage") - self.events_label = self.get_widget("eventsMarriage") - self.attr_label = self.get_widget("attrMarriage") - self.notes_label = self.get_widget("notesMarriage") - self.lds_label = self.get_widget("ldsMarriage") - - self.flowed = self.get_widget("mar_flowed") - self.flowed.set_sensitive(mode) - self.preform = self.get_widget("mar_preform") - self.preform.set_sensitive(mode) - - self.alist = family.get_attribute_list()[:] - self.lists_changed = 0 - - self.get_widget('changed').set_text(family.get_change_display()) - - # set initial data - self.gallery.load_images() - - # event display - self.event_box = ListBox.EventListBox( - self, family, self.event_ref_list, self.events_label, - [event_add_btn,event_edit_btn,event_delete_btn,event_sel_btn]) - self.event_box.redraw() - - self.type_selector = AutoComp.StandardCustomSelector( \ - Utils.family_relations,self.type_field, - RelLib.Family.CUSTOM,RelLib.Name.MARRIED) - - frel = family.get_relationship() - self.type_selector.set_values(frel) - - # attribute display - self.attr_box = ListBox.AttrListBox( - self, family, self.attr_list, self.attr_label, - [attr_add_btn,attr_edit_btn,attr_del_btn]) - self.attr_box.redraw() - - self.gid.set_text(family.get_gramps_id()) - - - place_list = self.pmap.keys() - place_list.sort() - AutoComp.fill_combo(self.lds_place, place_list) - - lds_ord = self.family.get_lds_sealing() - self.seal_stat = 0 - - self.lds_date_object = RelLib.Date() - if GrampsKeys.get_uselds() or lds_ord: - if lds_ord: - place_handle = lds_ord.get_place_handle() - if place_handle: - place = self.db.get_place_from_handle( place_handle) - if place: - self.lds_place.child.set_text( place.get_title()) - self.lds_date.set_text(lds_ord.get_date()) - self.seal_stat = lds_ord.get_status() - self.lds_date_object = lds_ord.get_date_object() - else: - self.lds_place.child.set_text("") - self.lds_label.show() - self.get_widget('lds_page').show() - else: - self.lds_label.hide() - self.get_widget('lds_page').hide() - - self.lds_date_check = DateEdit.DateEdit( - self.lds_date_object, self.lds_date, - self.lds_date_led, self.window) - - if self.family.get_complete_flag(): - self.complete.set_active(1) - - self.lds_field(lds_ord,self.lds_temple) - - self.build_seal_menu() - - if lds_ord: - Utils.bold_label(self.lds_label) - else: - Utils.unbold_label(self.lds_label) - - self.event_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.FAMILY_EVENT.target()], - gtk.gdk.ACTION_COPY) - self.event_list.drag_source_set(gtk.gdk.BUTTON1_MASK, - [DdTargets.FAMILY_EVENT.target()], - gtk.gdk.ACTION_COPY) - self.event_list.connect('drag_data_get', - self.ev_source_drag_data_get) - if not self.db.readonly: - self.event_list.connect('drag_data_received', - self.ev_dest_drag_data_received) - self.event_list.connect('drag_begin', self.ev_drag_begin) - - self.attr_list.drag_dest_set(gtk.DEST_DEFAULT_ALL, - [DdTargets.FAMILY_ATTRIBUTE.target()], - gtk.gdk.ACTION_COPY) - self.attr_list.drag_source_set(gtk.gdk.BUTTON1_MASK, - [DdTargets.FAMILY_ATTRIBUTE.target()], - gtk.gdk.ACTION_COPY) - self.attr_list.connect('drag_data_get', - self.at_source_drag_data_get) - if not self.db.readonly: - self.attr_list.connect('drag_data_received', - self.at_dest_drag_data_received) - self.attr_list.connect('drag_begin', self.at_drag_begin) - - # set notes data - self.notes_buffer = self.notes_field.get_buffer() - if family.get_note(): - self.notes_buffer.set_text(family.get_note()) - Utils.bold_label(self.notes_label) - if family.get_note_format() == 1: - self.preform.set_active(1) - else: - self.flowed.set_active(1) - - self.sourcetab = Sources.SourceTab( - self.srcreflist, self, self.top, self.window, self.slist, - self.top.get_widget('add_src'), self.top.get_widget('edit_src'), - self.top.get_widget('del_src'), self.db.readonly) - - self.add_itself_to_winsmenu() - self.top.get_widget('ok').set_sensitive(not self.db.readonly) - - self.top.get_widget('marriage_del').set_sensitive(mode) - self.top.get_widget('marriage_add').set_sensitive(mode) - self.top.get_widget('attr_del').set_sensitive(mode) - self.top.get_widget('attr_add').set_sensitive(mode) - self.top.get_widget('media_del').set_sensitive(mode) - self.top.get_widget('media_add').set_sensitive(mode) - self.top.get_widget('media_sel').set_sensitive(mode) - self.window.show() - - def lds_field(self,lds_ord,combo): - - cell = gtk.CellRendererText() - combo.pack_start(cell,True) - combo.add_attribute(cell,'text',0) - store = gtk.ListStore(str) - for value in _temple_names: - node = store.append() - store.set(node,0,unicode(value)) - combo.set_model(store) - - if lds_ord: - temple_code = const.lds_temple_to_abrev.get(lds_ord.get_temple(),"") - index = _temple_names.index(temple_code) - else: - index = 0 - combo.set_active(index) - - def close_child_windows(self): - for child_window in self.child_windows.values(): - child_window.close(None) - self.child_windows = {} - - def close(self): - self.gladeif.close() - self.gallery.close() - self.close_child_windows() - self.remove_itself_from_winsmenu() - self.window.destroy() - - def add_itself_to_winsmenu(self): - self.parent.child_windows[self.family.get_handle()] = self - win_menu_label = self.title - if not win_menu_label.strip(): - win_menu_label = _("New Relationship") - self.win_menu_item = gtk.MenuItem(win_menu_label) - self.win_menu_item.set_submenu(gtk.Menu()) - self.win_menu_item.show() - self.parent.winsmenu.append(self.win_menu_item) - self.winsmenu = self.win_menu_item.get_submenu() - self.menu_item = gtk.MenuItem(_('Marriage/Relationship Editor')) - self.menu_item.connect("activate",self.present) - self.menu_item.show() - self.winsmenu.append(self.menu_item) - - def remove_itself_from_winsmenu(self): - del self.parent.child_windows[self.family.get_handle()] - self.menu_item.destroy() - self.winsmenu.destroy() - self.win_menu_item.destroy() - - def present(self,obj): - self.window.present() - - def on_help_clicked(self,obj): - """Display the relevant portion of GRAMPS manual""" - GrampsDisplay.help('adv-rel') - - def ev_drag_begin(self, context, a): - return - - def at_drag_begin(self, context, a): - return - - def build_seal_menu(self): - cell = gtk.CellRendererText() - self.lds_status.pack_start(cell,True) - self.lds_status.add_attribute(cell,'text',0) - - store = gtk.ListStore(str) - for val in const.lds_ssealing: - store.append(row=[val]) - self.lds_status.set_model(store) - self.lds_status.connect('changed',self.set_lds_seal) - self.lds_status.set_active(self.seal_stat) - - def set_lds_seal(self,obj): - self.seal_stat = obj.get_active() - - def lds_src_clicked(self,obj): - lds_ord = self.family.get_lds_sealing() - if lds_ord == None: - lds_ord = RelLib.LdsOrd() - self.family.set_lds_sealing(lds_ord) - Sources.SourceSelector(lds_ord.get_source_references(),self) - - def lds_note_clicked(self,obj): - import NoteEdit - lds_ord = self.family.get_lds_sealing() - if lds_ord == None: - lds_ord = RelLib.LdsOrd() - self.family.set_lds_sealing(lds_ord) - NoteEdit.NoteEditor(lds_ord,self,self.window,readonly=self.db.readonly) - - def ev_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time): - if self.db.readonly: # no DnD on readonly database - return - row = self.etree.get_row_at(x,y) - if selection_data and selection_data.data: - exec 'data = %s' % selection_data.data - exec 'mytype = "%s"' % data[0] - exec 'family = "%s"' % data[1] - - if mytype != DdTargets.FAMILY_EVENT.drag_type: - return - - foo = pickle.loads(data[2]); - - if family == self.family.get_handle() and \ - foo.get_handle() in [ref.ref for ref in self.ereflist]: - self.move_element(self.ereflist,self.etree.get_selected_row(), - row) - else: - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - place = foo.get_place_handle() - if place: - foo.set_place_handle( - self.db.get_place_from_handle(place.get_handle()).get_handle()) - eref = RelLib.EventRef() - eref.set_ref = foo.get_handle() - eref.set_role(RelLib.EventRef.PRIMARY, - Utils.event_roles(RelLib.EventRef.PRIMARY)) - - self.ereflist.insert(row,) - - self.lists_changed = 1 - self.redraw_event_list() - - def ev_source_drag_data_get(self,widget, context, selection_data, info, time): - ev = self.etree.get_selected_objects() - if not ev: - return - - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.FAMILY_EVENT.drag_type, - self.family.get_handle(),pickled)); - selection_data.set(selection_data.target, bits_per, data) - - def at_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time): - if self.db.readonly: # no DnD on readonly database - return - row = self.atree.get_row_at(x,y) - if selection_data and selection_data.data: - exec 'data = %s' % selection_data.data - exec 'mytype = "%s"' % data[0] - exec 'family = "%s"' % data[1] - - if mytype != DdTargets.FAMILY_ATTRIBUTE.drag_type: - return - - foo = pickle.loads(data[2]); - - if family == self.family.get_handle() and \ - foo in self.alist: - self.move_element(self.alist,self.atree.get_selected_row(),row) - else: - foo = pickle.loads(data[2]); - for src in foo.get_source_references(): - base_handle = src.get_base_handle() - newbase = self.db.get_source_from_handle(base_handle) - src.set_base_handle(newbase.get_handle()) - self.alist.insert(row,foo) - - self.lists_changed = 1 - self.redraw_attr_list() - - def at_source_drag_data_get(self,widget, context, selection_data, info, time): - ev = self.atree.get_selected_objects() - if not ev: - return - - bits_per = 8; # we're going to pass a string - pickled = pickle.dumps(ev[0]); - data = str((DdTargets.FAMILY_ATTRIBUTE.drag_type, - self.family.get_handle(),pickled)); - selection_data.set(selection_data.target, bits_per, data) - - def update_lists(self): - eref_list = [event_ref for (event_ref,event) in self.event_box.data] - self.family.set_event_ref_list(eref_list) - self.family.set_attribute_list(self.attr_box.data) - - def attr_edit_callback(self,attr): - self.redraw_attr_list() - self.atree.select_iter(self.amap[str(attr)]) - - def redraw_attr_list(self): - self.atree.clear() - self.amap = {} - for attr in self.alist: - d = [const.display_fattr(attr.get_type()),attr.get_value()] - node = self.atree.add(d,attr) - self.amap[str(attr)] = node - if self.alist: - self.atree.select_row(0) - Utils.bold_label(self.attr_label) - else: - Utils.unbold_label(self.attr_label) - - def redraw_event_list(self): - self.etree.clear() - self.emap = {} - for event_ref in self.ereflist: - if not event_ref: - continue - event = self.db.get_event_from_handle(event_ref.ref) - place_handle = event.get_place_handle() - - if place_handle: - place_name = self.db.get_place_from_handle(place_handle).get_title() - else: - place_name = "" - node = self.etree.add([event.get_type()[1], - event.get_quote_date(),place_name],event) - self.emap[str(event)] = node - if self.ereflist: - self.etree.select_row(0) - Utils.bold_label(self.events_label) - else: - Utils.unbold_label(self.events_label) - - def get_widget(self,name): - return self.top.get_widget(name) - - def did_data_change(self): - changed = 0 - if self.type_selector.get_values() != self.family.get_relationship(): - changed = 1 - - if self.complete.get_active() != self.family.get_complete_flag(): - changed = 1 - - text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(), - self.notes_buffer.get_end_iter(),False)) - format = self.preform.get_active() - - if text != self.family.get_note(): - changed = 1 - if format != self.family.get_note_format(): - changed = 1 - - if self.lists_changed: - changed = 1 - - idval = unicode(self.gid.get_text()) - if idval == "": - idval = None - if self.family.get_gramps_id() != idval: - changed = 1 - - date = unicode(self.lds_date.get_text()) - try: - temple = _temple_names[self.lds_temple.get_active()] - except: - temple = "" - - place = self.get_place(0) - - lds_ord = self.family.get_lds_sealing() - if not lds_ord: - if date or temple or place or self.seal_stat: - changed = 1 - else: - d = self.dp.parse(date) - if d.is_equal(lds_ord.get_date_object()) or \ - lds_ord.get_temple() != temple or \ - (place and lds_ord.get_place_handle() != place.get_handle()) or \ - lds_ord.get_status() != self.seal_stat: - changed = 1 - - return changed - - def cancel_callback(self): - self.close() - - def on_cancel_edit(self,obj): - if self.did_data_change() and not GrampsKeys.get_dont_ask(): - SaveDialog(_('Save Changes?'), - _('If you close without saving, the changes you ' - 'have made will be lost'), - self.cancel_callback, - self.save) - else: - self.close() - - def save(self): - self.on_close(None) - - def on_delete_event(self,obj,b): - if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask(): - SaveDialog(_('Save Changes?'), - _('If you close without saving, the changes you ' - 'have made will be lost'), - self.cancel_callback, - self.save) - return True - else: - self.close() - return False - - def on_close(self,*obj): - - trans = self.db.transaction_begin() - - idval = unicode(self.gid.get_text()) - family = self.family - if idval != family.get_gramps_id(): - if not self.db.get_family_from_gramps_id(idval): - family.set_gramps_id(idval) - else: - WarningDialog(_("GRAMPS ID value was not changed."), - _('The GRAMPS ID that you chose for this ' - 'relationship is already being used.')) - - relation = self.type_selector.get_values() - father = self.family.get_father_handle() - mother = self.family.get_mother_handle() - if father and mother: - if relation != self.family.get_relationship(): - self.family.set_relationship(relation) - - text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(), - self.notes_buffer.get_end_iter(),False)) - if text != self.family.get_note(): - self.family.set_note(text) - - format = self.preform.get_active() - if format != self.family.get_note_format(): - self.family.set_note_format(format) - - if self.complete.get_active() != self.family.get_complete_flag(): - self.family.set_complete_flag(self.complete.get_active()) - - date = unicode(self.lds_date.get_text()) - try: - temple = _temple_names[self.lds_temple.get_active()] - except: - temple = "" - place = self.get_place(1,trans) - - lds_ord = self.family.get_lds_sealing() - if not lds_ord: - if date or temple or place or self.seal_stat: - lds_ord = RelLib.LdsOrd() - DateHandler.set_date(lds_ord,date) - temple_code = const.lds_temple_codes.get(temple,"") - lds_ord.set_temple(temple_code) - lds_ord.set_status(self.seal_stat) - lds_ord.set_place_handle(place) - self.family.set_lds_sealing(lds_ord) - else: - d = self.dp.parse(date) - if d.is_equal(lds_ord.get_date_object()): - lds_ord.set_date_object(d) - temple_code = const.lds_temple_codes.get(temple,"") - if lds_ord.get_temple() != temple_code: - lds_ord.set_temple(temple_code) - if lds_ord.get_status() != self.seal_stat: - lds_ord.set_status(self.seal_stat) - if place and lds_ord.get_place_handle() != place.get_handle(): - lds_ord.set_place_handle(place.get_handle()) - - if self.lists_changed: - self.family.set_source_reference_list(self.srcreflist) - - self.update_lists() - - for (event_ref,event) in self.event_box.get_changed_objects(): - self.db.commit_event(event,trans) - - self.db.commit_family(self.family,trans) - self.db.transaction_commit(trans,_("Edit Marriage")) - - self.close() - - def event_edit_callback(self,data): - """Birth and death events may not be in the map""" - self.event_box.edit_callback(data) - - def on_add_clicked(self,*obj): - import EventEdit - EventEdit.EventRefEditor(None,None,self.family,self.db, - self.event_box.edit_callback,self) - - def on_event_update_clicked(self,obj): - import EventEdit - model,node = self.etree.get_selected() - if not node: - return - event = self.etree.get_object(node) - name = Utils.family_name(self.family,self.db) - EventEdit.EventRefEditor( - self, name, Utils.family_events,event, - None, 0, self.event_edit_callback, None, self.db.readonly) - - def on_delete_clicked(self,obj): - if Utils.delete_selected(obj,self.ereflist): - self.lists_changed = 1 - self.redraw_event_list() - - def on_select_row(self,obj): - - model,node = self.etree.get_selected() - if not node: - return - event = self.etree.get_object(node) - - self.date_field.set_text(DateHandler.get_date(event)) - place_handle = event.get_place_handle() - if place_handle: - place_name = self.db.get_place_from_handle(place_handle).get_title() - else: - place_name = u"" - self.place_field.set_text(place_name) - self.cause_field.set_text(event.get_cause()) - self.name_field.set_label(event.get_type()[1]) - if len(event.get_source_references()) > 0: - psrc_ref = event.get_source_references()[0] - psrc_id = psrc_ref.get_base_handle() - psrc = self.db.get_source_from_handle(psrc_id) - self.event_src_field.set_text(psrc.get_title()) - self.event_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) - else: - self.event_src_field.set_text('') - self.event_conf_field.set_text('') - self.descr_field.set_text(event.get_description()) - - def on_attr_list_select_row(self,obj): - model,node = self.atree.get_selected() - if not node: - return - attr = self.atree.get_object(node) - - self.attr_type.set_label(const.display_fattr(attr.get_type())) - self.attr_value.set_text(attr.get_value()) - if len(attr.get_source_references()) > 0: - psrc_ref = attr.get_source_references()[0] - psrc_id = psrc_ref.get_base_handle() - psrc = self.db.get_source_from_handle(psrc_id) - self.attr_src_field.set_text(psrc.get_title()) - self.attr_conf_field.set_text(const.confidence[psrc_ref.get_confidence_level()]) - else: - self.attr_src_field.set_text('') - self.attr_conf_field.set_text('') - - def on_update_attr_clicked(self,obj): - import AttrEdit - model,node = self.atree.get_selected() - if not node: - return - - attr = self.atree.get_object(node) - - father_handle = self.family.get_father_handle() - mother_handle = self.family.get_mother_handle() - father = self.db.get_person_from_handle(father_handle) - mother = self.db.get_person_from_handle(mother_handle) - if father and mother: - name = _("%s and %s") % ( - NameDisplay.displayer.display(father), - NameDisplay.displayer.display(mother)) - elif father: - name = NameDisplay.displayer.display(father) - else: - name = NameDisplay.displayer.display(mother) - attr_list = list(sets.Set(const.familyAttributes + self.db.get_family_attribute_types())) - AttrEdit.AttributeEditor( - self, attr, name, attr_list, self.attr_edit_callback, self.window) - - def on_delete_attr_clicked(self,obj): - if Utils.delete_selected(obj,self.alist): - self.lists_changed = 1 - self.redraw_attr_list() - - def on_add_attr_clicked(self,obj): - import AttrEdit - father_handle = self.family.get_father_handle() - mother_handle = self.family.get_mother_handle() - father = self.db.get_person_from_handle(father_handle) - mother = self.db.get_person_from_handle(mother_handle) - if father and mother: - name = _("%s and %s") % ( - NameDisplay.displayer.display(father), - NameDisplay.displayer.display(mother)) - elif father: - name = NameDisplay.displayer.display(father) - else: - name = NameDisplay.displayer.display(mother) - attr_list = list(sets.Set(const.familyAttributes + self.db.get_family_attribute_types())) - AttrEdit.AttributeEditor( - self, None, name, attr_list, self.attr_edit_callback, self.window) - - def move_element(self,list,src,dest): - if src == -1: - return - obj = list[src] - list.remove(obj) - list.insert(dest,obj) - - def on_switch_page(self,obj,a,page): - if page == 0: - self.event_box.redraw() - elif page == 1: - self.attr_box.redraw() - text = unicode(self.notes_buffer.get_text(self.notes_buffer.get_start_iter(), - self.notes_buffer.get_end_iter(),False)) - if text: - Utils.bold_label(self.notes_label) - else: - Utils.unbold_label(self.notes_label) - - date = unicode(self.lds_date.get_text()) - - try: - temple = _temple_names[self.lds_temple.get_active()] - except: - temple = "" - - if date or temple: - Utils.bold_label(self.lds_label) - else: - Utils.unbold_label(self.lds_label) - - def get_place(self,makenew,trans=None): - field = self.lds_place.child - text = unicode(field.get_text()).strip() - if text: - if self.pmap.has_key(text): - return self.db.get_place_from_handle(self.pmap[text]) - elif makenew: - place = RelLib.Place() - place.set_title(text) - self.db.add_place(place,trans) - self.pmap[text] = place.get_handle() - return place - else: - return None - else: - return None diff --git a/gramps2/src/MediaView.py b/gramps2/src/MediaView.py index 0eba27adc..00d9fe8e5 100644 --- a/gramps2/src/MediaView.py +++ b/gramps2/src/MediaView.py @@ -35,7 +35,6 @@ import gtk.gdk import RelLib import PageView import DisplayModels -import ImageSelect import ImgManip import const import Utils @@ -154,7 +153,7 @@ class MediaView(PageView.ListView): return the_lists = Utils.get_media_referents(handle,self.dbstate.db) - ans = ImageSelect.DeleteMediaQuery(handle,self.dbstate.db,the_lists) + ans = DeleteMediaQuery(handle,self.dbstate.db,the_lists) if filter(None,the_lists): # quick test for non-emptiness msg = _('This media object is currently being used. ' 'If you delete this object, it will be removed from ' @@ -179,3 +178,56 @@ class MediaView(PageView.ListView): import NoteEdit NoteEdit.NoteEditor(obj,self.parent,self.topWindow, self.note_callback) + +class DeleteMediaQuery: + + def __init__(self,media_handle,db,the_lists): + self.db = db + self.media_handle = media_handle + self.the_lists = the_lists + + def query_response(self): + trans = self.db.transaction_begin() + self.db.disable_signals() + + (person_list,family_list,event_list, + place_list,source_list) = self.the_lists + + for handle in person_list: + person = self.db.get_person_from_handle(handle) + new_list = [ photo for photo in person.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + person.set_media_list(new_list) + self.db.commit_person(person,trans) + + for handle in family_list: + family = self.db.get_family_from_handle(handle) + new_list = [ photo for photo in family.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + family.set_media_list(new_list) + self.db.commit_family(family,trans) + + for handle in event_list: + event = self.db.get_event_from_handle(handle) + new_list = [ photo for photo in event.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + event.set_media_list(new_list) + self.db.commit_event(event,trans) + + for handle in place_list: + place = self.db.get_place_from_handle(handle) + new_list = [ photo for photo in place.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + place.set_media_list(new_list) + self.db.commit_place(place,trans) + + for handle in source_list: + source = self.db.get_source_from_handle(handle) + new_list = [ photo for photo in source.get_media_list() \ + if photo.get_reference_handle() != self.media_handle ] + source.set_media_list(new_list) + self.db.commit_source(source,trans) + + self.db.enable_signals() + self.db.remove_object(self.media_handle,trans) + self.db.transaction_commit(trans,_("Remove Media Object")) diff --git a/gramps2/src/TransTable.py b/gramps2/src/TransTable.py deleted file mode 100644 index 85059aef4..000000000 --- a/gramps2/src/TransTable.py +++ /dev/null @@ -1,66 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2004 Donald N. Allingham -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# $Id$ - -from gettext import gettext as _ - -class TransTable: - - def __init__(self,map={}): - self.map = {} - self.rmap = {} - - if type(map) == type([]): - for key in map: - val = unicode(_(key)) - self.map[key] = val - self.rmap[val] = unicode(key) - else: - for key in map.keys(): - val = unicode(map[key]) - self.map[key] = val - self.rmap[val] = unicode(key) - - def add_pair(self,first,second): - first = unicode(first) - second = unicode(second) - self.map[first] = second - self.rmap[second] = first - - def find_value(self,key): - return unicode(self.map.setdefault(key,_(key))) - - def find_key(self,value): - value = unicode(value) - return unicode(self.rmap.setdefault(value,value)) - - def has_key(self,key): - return self.map.has_key(key) - - def has_value(self,value): - value = unicode(value) - return self.rmap.has_key(value) - - def get_values(self): - values = self.map.values() - values.sort() - return values - -