* various: undo messages

svn: r3181
This commit is contained in:
Don Allingham 2004-05-19 06:13:36 +00:00
parent 1e9b3cfc20
commit 79d9a39a9e
18 changed files with 113 additions and 72 deletions

View File

@ -1,3 +1,6 @@
2004-05-19 Don Allingham <dallingham@users.sourceforge.net>
* various: undo messages
2004-05-18 Don Allingham <dallingham@users.sourceforge.net>
* src/GrampsCfg.py: added support for tip of the day
* src/data/tips.xml: tip data

View File

@ -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):
"""

View File

@ -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,

View File

@ -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)

View File

@ -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):

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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()

View File

@ -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

View File

@ -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())

View File

@ -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)

View File

@ -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):

View File

@ -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:

View File

@ -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()

View File

@ -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):

View File

@ -56,7 +56,7 @@
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1950">
<widget class="GtkImage" id="image1987">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -78,7 +78,7 @@
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1951">
<widget class="GtkImage" id="image1988">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -112,7 +112,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1952">
<widget class="GtkImage" id="image1989">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -140,7 +140,7 @@
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1953">
<widget class="GtkImage" id="image1990">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="icon_size">1</property>
@ -167,10 +167,24 @@
<widget class="GtkMenu" id="edit1_menu">
<child>
<widget class="GtkImageMenuItem" id="undo1">
<widget class="GtkImageMenuItem" id="undolabel">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_UNDO_ITEM</property>
<signal name="activate" handler="on_undo_activate" last_modification_time="Fri, 26 Mar 2004 00:07:15 GMT"/>
<property name="label" translatable="yes">_Undo</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_undo_activate" last_modification_time="Tue, 18 May 2004 14:34:56 GMT"/>
<accelerator key="z" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1991">
<property name="visible">True</property>
<property name="stock">gtk-undo</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
@ -198,7 +212,7 @@
<accelerator key="Insert" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1954">
<widget class="GtkImage" id="image1992">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -221,7 +235,7 @@
<accelerator key="Delete" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1955">
<widget class="GtkImage" id="image1993">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
@ -259,7 +273,7 @@
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1956">
<widget class="GtkImage" id="image1994">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
@ -281,7 +295,7 @@
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1957">
<widget class="GtkImage" id="image1995">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -308,7 +322,7 @@
<signal name="activate" handler="on_preferences1_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1958">
<widget class="GtkImage" id="image1996">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -329,7 +343,7 @@
<signal name="activate" handler="on_column_order_activate" last_modification_time="Wed, 10 Mar 2004 04:36:07 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1959">
<widget class="GtkImage" id="image1997">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
@ -350,7 +364,7 @@
<signal name="activate" handler="on_default_person_activate" last_modification_time="Sat, 16 Aug 2003 01:58:26 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1960">
<widget class="GtkImage" id="image1998">
<property name="visible">True</property>
<property name="stock">gtk-home</property>
<property name="icon_size">1</property>
@ -436,7 +450,7 @@
<accelerator key="D" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1961">
<widget class="GtkImage" id="image1999">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">1</property>
@ -458,7 +472,7 @@
<accelerator key="B" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1962">
<widget class="GtkImage" id="image2000">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -531,7 +545,7 @@
<accelerator key="F1" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1963">
<widget class="GtkImage" id="image2001">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -552,7 +566,7 @@
<signal name="activate" handler="on_faq_activate" last_modification_time="Wed, 26 Nov 2003 17:59:23 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1964">
<widget class="GtkImage" id="image2002">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -579,7 +593,7 @@
<signal name="activate" handler="on_gramps_home_page_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1965">
<widget class="GtkImage" id="image2003">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -600,7 +614,7 @@
<signal name="activate" handler="on_gramps_mailing_lists_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1966">
<widget class="GtkImage" id="image2004">
<property name="visible">True</property>
<property name="stock">gnome-stock-mail</property>
<property name="icon_size">1</property>
@ -654,7 +668,7 @@
<signal name="activate" handler="on_about_activate" last_modification_time="Tue, 01 Apr 2003 03:44:24 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1967">
<widget class="GtkImage" id="image2005">
<property name="visible">True</property>
<property name="stock">gnome-stock-about</property>
<property name="icon_size">1</property>

View File

@ -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):