From 79d9a39a9eac348e3607925d0d948e7c8073593f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 19 May 2004 06:13:36 +0000 Subject: [PATCH] * various: undo messages svn: r3181 --- ChangeLog | 3 +++ src/AddMedia.py | 2 +- src/AddSpouse.py | 2 +- src/ChooseParents.py | 17 +++++++------- src/EditPerson.py | 3 ++- src/EditPlace.py | 4 ++-- src/EditSource.py | 4 ++-- src/EventEdit.py | 2 +- src/FamilyView.py | 21 +++++++++++------ src/GenericFilter.py | 2 +- src/LocEdit.py | 3 --- src/Marriage.py | 5 +--- src/PlaceView.py | 2 +- src/RelLib.py | 31 +++++++++++++++++++----- src/SelectChild.py | 13 ++++++---- src/SourceView.py | 3 ++- src/gramps.glade | 56 +++++++++++++++++++++++++++----------------- src/gramps_main.py | 12 +++++----- 18 files changed, 113 insertions(+), 72 deletions(-) diff --git a/ChangeLog b/ChangeLog index 809d82774..d6782b601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2004-05-19 Don Allingham + * various: undo messages + 2004-05-18 Don Allingham * src/GrampsCfg.py: added support for tip of the day * src/data/tips.xml: tip data diff --git a/src/AddMedia.py b/src/AddMedia.py index ea58f4b34..38c6e6a7d 100644 --- a/src/AddMedia.py +++ b/src/AddMedia.py @@ -131,7 +131,7 @@ class AddMediaObject: self.object = mobj trans = self.db.start_transaction() self.db.commit_media_object(mobj,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Add Media Object")) def on_name_changed(self,*obj): """ diff --git a/src/AddSpouse.py b/src/AddSpouse.py index 37568a24f..ea0a7fa10 100644 --- a/src/AddSpouse.py +++ b/src/AddSpouse.py @@ -260,7 +260,7 @@ class AddSpouse: rtype = const.save_frel(unicode(self.relation_type.get_text())) self.active_family.set_relationship(rtype) self.db.commit_family(self.active_family,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Add Spouse")) Utils.destroy_passed_object(obj) self.update(self.active_family) m = Marriage.Marriage(self.parent, self.active_family, diff --git a/src/ChooseParents.py b/src/ChooseParents.py index 0e923617c..e527ea726 100644 --- a/src/ChooseParents.py +++ b/src/ChooseParents.py @@ -345,7 +345,7 @@ class ChooseParents: self.mother_filter = self.likely_mother_filter self.redrawm() - def find_family(self,father_id,mother_id): + def find_family(self,father_id,mother_id,trans): """ Finds the family associated with the father and mother. If one does not exist, it is created. @@ -356,19 +356,14 @@ class ChooseParents: for family_id in self.db.get_family_keys(): family = self.db.find_family_from_id(family_id) if family.get_father_id() == father_id and family.get_mother_id() == mother_id: - trans = self.db.start_transaction() family.add_child_id(self.person.get_id()) self.db.commit_family(family,trans) - self.db.add_transaction(trans) return family elif family.get_father_id() == mother_id and family.get_mother_id() == father_id: - trans = self.db.start_transaction() family.add_child_id(self.person.get_id()) self.db.commit_family(family,trans) - self.db.add_transaction(trans) return family - trans = self.db.start_transaction() family = self.db.new_family(trans) family.set_father_id(father_id) family.set_mother_id(mother_id) @@ -384,7 +379,6 @@ class ChooseParents: self.db.commit_person(self.mother,trans) self.db.commit_family(family,trans) - self.db.add_transaction(trans) return family def mother_list_select_row(self,obj): @@ -485,6 +479,7 @@ class ChooseParents: except KeyError: father_rel = const.child_relations.find_value("Birth") + trans = self.db.start_transaction() if self.father or self.mother: if self.mother and not self.father: if self.mother.get_gender() == RelLib.Person.male: @@ -515,7 +510,7 @@ class ChooseParents: self.type = "Partners" father_id = self.father.get_id() mother_id = self.mother.get_id() - self.family = self.find_family(father_id,mother_id) + self.family = self.find_family(father_id,mother_id,trans) else: self.family = None @@ -528,8 +523,9 @@ class ChooseParents: self.family.add_child_id(self.person.get_id()) self.family.set_relationship(self.type) self.change_family_type(self.family,mother_rel,father_rel) - self.db.commit_family(self.family) + self.db.commit_family(self.family,trans) self.family_update(None) + self.db.add_transaction(trans,_("Choose Parents")) self.close(obj) def add_new_parent(self,epo): @@ -718,4 +714,7 @@ class ModifyParents: mod = 1 if mod: + trans = self.db.start_transaction() + self.db.commit_person(self.person,trans) + self.db.add_transaction(trans,_("Modify Parents")) self.family_update(None) diff --git a/src/EditPerson.py b/src/EditPerson.py index e80b280d0..63e0617e0 100644 --- a/src/EditPerson.py +++ b/src/EditPerson.py @@ -1585,7 +1585,8 @@ class EditPerson: self.callback(self,trans) self.db.commit_person(self.person, trans) - self.db.add_transaction(trans) + n = self.person.get_primary_name().get_regular_name() + self.db.add_transaction(trans,_("Edit Person (%s)") % n) self.close(1) def get_place(self,field,makenew=0): diff --git a/src/EditPlace.py b/src/EditPlace.py index 7740ede5c..d4d69d429 100644 --- a/src/EditPlace.py +++ b/src/EditPlace.py @@ -372,7 +372,7 @@ class EditPlace: trans = self.db.start_transaction() self.db.commit_place(self.place,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Edit Place (%s)") % self.place.get_title()) if self.callback: self.callback(self.place) @@ -577,5 +577,5 @@ class DeletePlaceQuery: event.set_place_id(None) self.db.commit_event(event,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Delete Place (%s)") % self.place.get_title()) self.update(None) diff --git a/src/EditSource.py b/src/EditSource.py index 8ac780572..375c9529a 100644 --- a/src/EditSource.py +++ b/src/EditSource.py @@ -329,7 +329,7 @@ class EditSource: trans = self.db.start_transaction() self.db.commit_source(self.source,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Edit Source (%s)") % title) if self.callback: self.callback(self.source) @@ -414,5 +414,5 @@ class DelSrcQuery: self.db.commit_place(p,trans) self.db.remove_source_id(self.source.get_id(),trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Delete Source (%s)") % self.source.get_title()) self.update() diff --git a/src/EventEdit.py b/src/EventEdit.py index ac06b2d35..ae9bd06b4 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -315,7 +315,7 @@ class EventEditor: self.update_event(ename,self.date,eplace_obj,edesc,enote,eformat, epriv,ecause,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Edit Event")) self.parent.redraw_event_list() self.callback(self.event) self.close(obj) diff --git a/src/FamilyView.py b/src/FamilyView.py index 52f148abf..4204d64ae 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -552,7 +552,8 @@ class FamilyView: self.person.set_preferred_family_id(self.family) trans = self.parent.db.start_transaction() self.parent.db.commit_person(self.person,trans) - self.parent.db.add_transaction(trans) + n = self.person.get_primary_name().get_regular_name() + self.parent.db.add_transaction(trans,_("Set Preferred Spouse (%s)") % n) self.load_family() def edit_spouse_callback(self,obj): @@ -621,7 +622,8 @@ class FamilyView: if epo: trans = self.parent.db.start_transaction() self.parent.db.commit_person(epo.person,trans) - self.parent.db.add_transaction(trans) + n = epo.person.get_primary_name().get_regular_name() + self.parent.db.add_transaction(trans,_("Add Person (%s)") % n) self.parent.people_view.remove_from_person_list(epo.person,epo.original_id) self.parent.people_view.redisplay_person_list(epo.person) @@ -753,7 +755,8 @@ class FamilyView: self.parent.db.commit_person(child,trans) self.parent.db.commit_family(self.family,trans) - self.parent.db.add_transaction(trans) + n = child.get_primary_name().get_regular_name() + self.parent.db.add_transaction(trans,_("Remove Child (%s)") % n) self.load_family() @@ -799,7 +802,8 @@ class FamilyView: self.load_family(self.family) else: self.load_family(self.family) - self.parent.db.add_transaction(trans) + n = self.person.get_primary_name().get_regular_name() + self.parent.db.add_transaction(trans,_("Remove Spouse (%s)") % n) if len(self.person.get_family_id_list()) <= 1: self.spouse_selection.set_mode(gtk.SELECTION_NONE) @@ -837,9 +841,10 @@ class FamilyView: person = self.parent.db.find_person_from_id(person_id) self.parent.change_active_person(person) + n = person.get_primary_name().get_name() trans = self.parent.db.start_transaction() self.parent.db.commit_family(family,trans) - self.parent.db.add_transaction(trans) + self.parent.db.add_transaction(trans,_("Select Parents (%s)") % n) self.load_family(family) def clear(self): @@ -983,7 +988,8 @@ class FamilyView: self.family = flist[0] else: self.family = None - self.parent.db.add_transaction(trans) + n = person.get_primary_name().get_name() + self.parent.db.add_transaction(trans,_("Remove from family (%s)") % n) def display_marriage(self,family): self.child_model.clear() @@ -1273,7 +1279,8 @@ class FamilyView: trans = self.parent.db.start_transaction() self.parent.db.commit_person(person,trans) - self.parent.db.add_transaction(trans) + n = person.get_primary_name().get_regular_name() + self.parent.db.add_transaction(trans,_("Remove Parents (%s)") % n) self.load_family() diff --git a/src/GenericFilter.py b/src/GenericFilter.py index ec265601b..2349ca873 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -820,7 +820,7 @@ class IsParentOfFilterMatch(Rule): def category(self): return _('Family filters') - def apply(self,db,p): + def apply(self,db,p_id): self.orig_id = p_id self.db = db diff --git a/src/LocEdit.py b/src/LocEdit.py index 747aba92c..21ce0a6f3 100644 --- a/src/LocEdit.py +++ b/src/LocEdit.py @@ -94,7 +94,6 @@ class LocationEditor: self.window.show() def on_delete_event(self,obj,b): - self.close_child_windows() self.remove_itself_from_menu() def close(self,obj): @@ -120,8 +119,6 @@ class LocationEditor: gnome.help_display('gramps-manual','gramps-edit-complete') def on_location_edit_ok_clicked(self,obj): - self.location = self.location - city = unicode(self.city.get_text()) county = unicode(self.county.get_text()) country = unicode(self.country.get_text()) diff --git a/src/Marriage.py b/src/Marriage.py index 201ecc587..e98b66d64 100644 --- a/src/Marriage.py +++ b/src/Marriage.py @@ -634,7 +634,7 @@ class Marriage: self.update_lists() self.update_fv(self.family) self.db.commit_family(self.family,trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Edit Marriage")) self.close(1) @@ -777,9 +777,6 @@ class Marriage: temple = const.lds_temple_codes[temple] else: temple = "" - trans = self.db.start_transaction() - place = self.get_place(1,trans) - self.db.add_transaction(trans) if date or temple or place: Utils.bold_label(self.lds_label) diff --git a/src/PlaceView.py b/src/PlaceView.py index 29fcaad23..59dd73d96 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -241,7 +241,7 @@ class PlaceView: else: trans = self.db.start_transaction() self.db.remove_place(place.get_id(),trans) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Delete Place (%s)") % place.title()) self.build_tree() def on_edit_clicked(self,obj): diff --git a/src/RelLib.py b/src/RelLib.py index c346c5922..de8a405c4 100644 --- a/src/RelLib.py +++ b/src/RelLib.py @@ -34,6 +34,7 @@ from re import compile import os import os.path import types +from gettext import gettext as _ #------------------------------------------------------------------------- # @@ -2402,6 +2403,11 @@ class GrampsDB: self.surnames = None self.eventnames = None self.metadata = None + self.undolabel = None + + def set_undo_label(self,label): + self.undolabel = label + self.undolabel.set_sensitive(0) def load(self,name,callback): if self.person_map: @@ -2667,14 +2673,19 @@ class GrampsDB: def start_transaction(self,msg=""): return Transaction(msg) - def add_transaction(self,transaction): + def add_transaction(self,transaction,msg): + transaction.set_description(msg) self.translist.append(transaction) + if self.undolabel: + self.undolabel.set_sensitive(1) + label = self.undolabel.get_children()[0] + label.set_text(_("_Undo %s") % transaction.get_description()) + label.set_use_underline(1) def undo(self): if len(self.translist) == 0: return transaction = self.translist.pop() - transaction.display() subitems = transaction.get_data() subitems.reverse() @@ -2710,6 +2721,17 @@ class GrampsDB: else: self.media_map.put(gid,data) + if self.undolabel: + label = self.undolabel.get_children()[0] + if len(self.translist) == 0: + label.set_text(_("_Undo")) + self.undolabel.set_sensitive(0) + else: + transaction = self.translist[-1] + label.set_text(_("_Undo %s") % transaction.get_description()) + self.undolabel.set_sensitive(1) + label.set_use_underline(1) + def get_surnames(self): names = self.surnames.keys() a = {} @@ -3340,10 +3362,9 @@ class GrampsDB: If no such Family exists, a new Family is added to the database.""" family = Family() - gid = str(gid) family.set_id(gid) if trans != None: - trans.add(FAMILY_KEY, index, None) + trans.add(FAMILY_KEY, gid, None) self.family_map.put(str(gid),family.serialize()) self.fmap_index = self.fmap_index + 1 return family @@ -3522,7 +3543,6 @@ class GrampsDB: class Transaction: def __init__(self,msg): - self.msg = msg self.data = [] def get_description(self): @@ -3541,7 +3561,6 @@ class Transaction: return len(self.data) def display(self): - print self for (key,gid,val) in self.data: if key == PERSON_KEY: if val: diff --git a/src/SelectChild.py b/src/SelectChild.py index 5f968b125..ae16a904a 100644 --- a/src/SelectChild.py +++ b/src/SelectChild.py @@ -190,7 +190,7 @@ class SelectChild: if family.get_father_id(): slist[family.get_father_id()] = 1 elif family.get_mother_id(): - slist[ffamily.get_mother_id()] = 1 + slist[family.get_mother_id()] = 1 for c in family.get_child_id_list(): slist[c] = 1 @@ -315,8 +315,10 @@ class SelectChild: trans = self.db.start_transaction() self.db.commit_person(select_child,trans) - self.db.add_transaction(trans) - + self.db.commit_family(self.family,trans) + n = select_child.get_primary_name().get_regular_name() + self.db.add_transaction(trans,_("Add Child to Family (%s)") % n) + self.redraw(self.family) self.close(obj) @@ -446,9 +448,10 @@ class EditRel: frel = "Unknown" self.child.change_parent_family_id(self.family.get_id(),mrel,frel) - trans = self.start_transaction() + trans = self.db.start_transaction() self.db.commit_person(self.child,trans) - self.db.add_transaction(trans) + n = self.child.get_primary_name().get_regular_name() + self.db.add_transaction(trans,_("Parent Relationships (%s)") % n) self.update() self.top.destroy() diff --git a/src/SourceView.py b/src/SourceView.py index 6a11ac2e4..f0f18baf8 100644 --- a/src/SourceView.py +++ b/src/SourceView.py @@ -198,7 +198,8 @@ class SourceView: else: trans = self.db.start_transaction() self.db.remove_source_id(source.get_id(),trans) - self.db.add_transaction(trans) + n = source.get_title() + self.db.add_transaction(trans,_("Delete Source (%s)") % n) self.build_tree() def is_used(self,source): diff --git a/src/gramps.glade b/src/gramps.glade index ca07f3157..7c9bb61bd 100644 --- a/src/gramps.glade +++ b/src/gramps.glade @@ -56,7 +56,7 @@ - + True gtk-new 1 @@ -78,7 +78,7 @@ - + True gtk-open 1 @@ -112,7 +112,7 @@ True - + True gtk-convert 1 @@ -140,7 +140,7 @@ - + True gtk-quit 1 @@ -167,10 +167,24 @@ - + True - GNOMEUIINFO_MENU_UNDO_ITEM - + _Undo + True + + + + + + True + gtk-undo + 1 + 0.5 + 0.5 + 0 + 0 + + @@ -198,7 +212,7 @@ - + True gtk-add 1 @@ -221,7 +235,7 @@ - + True gtk-remove 1 @@ -259,7 +273,7 @@ - + True gtk-find 1 @@ -281,7 +295,7 @@ - + True gtk-convert 1 @@ -308,7 +322,7 @@ - + True gtk-preferences 1 @@ -329,7 +343,7 @@ - + True gtk-properties 1 @@ -350,7 +364,7 @@ - + True gtk-home 1 @@ -436,7 +450,7 @@ - + True gtk-index 1 @@ -458,7 +472,7 @@ - + True gnome-stock-book-open 1 @@ -531,7 +545,7 @@ - + True gtk-help 1 @@ -552,7 +566,7 @@ - + True gnome-stock-book-open 1 @@ -579,7 +593,7 @@ - + True gtk-jump-to 1 @@ -600,7 +614,7 @@ - + True gnome-stock-mail 1 @@ -654,7 +668,7 @@ - + True gnome-stock-about 1 diff --git a/src/gramps_main.py b/src/gramps_main.py index 77f58dd5c..dfd6ee31a 100755 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -213,7 +213,9 @@ class Gramps: self.spouse_del = self.gtop.get_widget("delete_sp") self.spouse_combo= self.gtop.get_widget("spouse_combo") self.spouse_tab = self.gtop.get_widget("spouse_tab") + self.undolabel = self.gtop.get_widget('undolabel') + self.db.set_undo_label(self.undolabel) self.use_sidebar = GrampsCfg.get_view() self.sidebar_btn.set_active(self.use_sidebar) @@ -923,7 +925,6 @@ class Gramps: self.topWindow.set_title("GRAMPS") self.active_person = None - Utils.clear_timer() self.change_active_person(None) self.people_view.clear() self.family_view.clear() @@ -1104,7 +1105,7 @@ class Gramps: trans = self.db.start_transaction() self.db.remove_object(ObjectId) - self.db.add_transaction(trans) + self.db.add_transaction(trans,_("Save Media Object")) def leave_clicked(): # File is lost => do nothing, leave as is @@ -1130,7 +1131,7 @@ class Gramps: if os.path.isfile(name): RelImage.import_media_object(name,filename,base) object = self.db.find_object_from_id(ObjectId) - object.set_path(newfile) + object.set_path(name) choose.destroy() #------------------------------------------------------------------------- @@ -1171,8 +1172,6 @@ class Gramps: filename = os.path.normpath(os.path.abspath(filename)) self.status_text(_("Saving %s ...") % filename) - Utils.clear_timer() - if os.path.exists(filename): if not os.path.isdir(filename): DbPrompter.DbPrompter(self,0,self.topWindow) @@ -1302,7 +1301,8 @@ class Gramps: self.active_person = self.db.find_person_from_id(self.history[self.hindex]) else: self.change_active_person(None) - self.db.add_transaction(trans) + n = self.active_person.get_primary_name().get_regular_name() + self.db.add_transaction(trans,_("Delete Person (%s)") % n) self.redraw_histmenu() def merge_update(self,p1,p2,old_id):