Fixed place editing

svn: r1146
This commit is contained in:
Don Allingham 2002-10-21 01:18:07 +00:00
parent 2b3241bc19
commit aedf532a43
13 changed files with 128 additions and 91 deletions

View File

@ -43,7 +43,7 @@ _ = gettext
# GTK/Gnome modules # GTK/Gnome modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gnome.ui import GnomeErrorDialog from QuestionDialog import ErrorDialog
import gtk.glade import gtk.glade
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -103,7 +103,7 @@ class AddMediaObject:
if os.path.exists(filename) == 0: if os.path.exists(filename) == 0:
msgstr = _("%s is not a valid file name or does not exist.") msgstr = _("%s is not a valid file name or does not exist.")
GnomeErrorDialog(msgstr % filename) ErrorDialog(msgstr % filename)
return return
type = Utils.get_mime_type(filename) type = Utils.get_mime_type(filename)

View File

@ -1248,7 +1248,7 @@ class EditPerson:
msg = _("Changing the gender caused problems " msg = _("Changing the gender caused problems "
"with marriage information.\nPlease check " "with marriage information.\nPlease check "
"the person's marriages.") "the person's marriages.")
GnomeErrorDialog(msg) ErrorDialog(msg)
text = self.notes_buffer.get_text(self.notes_buffer.get_start_iter(), text = self.notes_buffer.get_text(self.notes_buffer.get_start_iter(),
self.notes_buffer.get_end_iter(),gtk.FALSE) self.notes_buffer.get_end_iter(),gtk.FALSE)

View File

@ -404,7 +404,7 @@ class DeletePlaceQuery:
self.update = update self.update = update
def query_response(self): def query_response(self):
del self.db.getPlaceMap()[self.place.getId()] self.db.removePlace(self.place.getId())
Utils.modified() Utils.modified()
for key in self.db.getPersonKeys(): for key in self.db.getPersonKeys():
@ -416,4 +416,5 @@ class DeletePlaceQuery:
for event in f.getEventList(): for event in f.getEventList():
if event.getPlace() == self.place: if event.getPlace() == self.place:
event.setPlace(None) event.setPlace(None)
self.update(0)
self.update(None)

View File

@ -53,6 +53,7 @@ import Marriage
import EditPlace import EditPlace
import EditSource import EditSource
from QuestionDialog import ErrorDialog
from intl import gettext as _ from intl import gettext as _
_IMAGEX = 140 _IMAGEX = 140
@ -137,7 +138,7 @@ class ImageSelect:
description = self.description.get_text() description = self.description.get_text()
if os.path.exists(filename) == 0: if os.path.exists(filename) == 0:
gnome.ui.GnomeErrorDialog(_("That is not a valid file name.")); ErrorDialog(_("That is not a valid file name."));
return return
already_imported = None already_imported = None
@ -325,7 +326,7 @@ class Gallery(ImageSelect):
except IOError, msg: except IOError, msg:
t = _("Could not import %s") % d t = _("Could not import %s") % d
gnome.ui.GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1])) ErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
return return
mime = Utils.get_mime_type(tfile) mime = Utils.get_mime_type(tfile)
photo = Photo() photo = Photo()

View File

@ -42,7 +42,7 @@ import ImageSelect
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
from QuestionDialog import QuestionDialog from QuestionDialog import QuestionDialog, ErrorDialog
import Utils import Utils
import os import os
import GrampsCfg import GrampsCfg
@ -325,7 +325,7 @@ class MediaView:
except IOError, msg: except IOError, msg:
t = _("Could not import %s") % d t = _("Could not import %s") % d
gnome.ui.GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1])) ErrorDialog("%s\n%s %d" % (t,msg[0],msg[1]))
return return
mime = Utils.get_mime_type(tfile) mime = Utils.get_mime_type(tfile)
photo = Photo() photo = Photo()

View File

@ -37,7 +37,7 @@ import gtk.gdk
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
from QuestionDialog import QuestionDialog from QuestionDialog import QuestionDialog, ErrorDialog
import EditPlace import EditPlace
import Utils import Utils
@ -68,10 +68,10 @@ _column_headers = [
class PlaceView: class PlaceView:
def __init__(self,db,glade,update): def __init__(self,db,glade,update):
self.db = db self.db = db
self.glade = glade self.glade = glade
self.list = glade.get_widget("place_list") self.list = glade.get_widget("place_list")
self.update_display= update self.update = update
self.active = None self.active = None
@ -130,11 +130,11 @@ class PlaceView:
def merge(self): def merge(self):
if len(self.place_list.selection) != 2: if len(self.place_list.selection) != 2:
msg = _("Exactly two places must be selected to perform a merge") msg = _("Exactly two places must be selected to perform a merge")
gnome.ui.GnomeErrorDialog(msg) ErrorDialog(msg)
else: else:
import MergeData import MergeData
p1 = self.place_list.get_row_data(self.place_list.selection[0]) p1 = self.place_list.get_row_data(self.place_list.selection[0])
p2 = self.place_list.get_row_data(self.place_list.selection[1]) P2 = self.place_list.get_row_data(self.place_list.selection[1])
p1 = self.db.getPlace(p1) p1 = self.db.getPlace(p1)
p2 = self.db.getPlace(p2) p2 = self.db.getPlace(p2)
MergeData.MergePlaces(self.db,p1,p2,self.load_places) MergeData.MergePlaces(self.db,p1,p2,self.load_places)
@ -148,38 +148,36 @@ class PlaceView:
EditPlace.EditPlace(self,place,self.update_display) EditPlace.EditPlace(self,place,self.update_display)
return 1 return 1
def insert_place(self,place): # def insert_place(self,place):
self.place_list.append(place.getDisplayInfo()) # self.place_list.append(place.getDisplayInfo())
self.place_list.set_row_data(self.place_list.rows-1,place.getId()) # self.place_list.set_row_data(self.place_list.rows-1,place.getId())
def new_place_after_edit(self,place): def new_place_after_edit(self,place):
self.db.addPlace(place) self.db.addPlace(place)
self.update(0) self.update(0)
def update_display(self,place): def update_display(self,place):
self.db.buildPlaceDisplay(place.getId()) if place:
self.db.buildPlaceDisplay(place.getId())
self.update(0) self.update(0)
def on_add_place_clicked(self,obj): def on_add_place_clicked(self,obj):
EditPlace.EditPlace(self,Place(),self.new_place_after_edit) EditPlace.EditPlace(self,Place(),self.new_place_after_edit)
def moveto(self,row): # def moveto(self,row):
self.place_list.unselect_all() # self.place_list.unselect_all()
self.place_list.select_row(row,0) # self.place_list.select_row(row,0)
self.place_list.moveto(row) # self.place_list.moveto(row)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
if len(obj.selection) == 0: store,iter = self.selection.get_selected()
if not iter:
return return
elif len(obj.selection) > 1:
msg = _("Currently, you can only delete one place at a time") id = store.get_value(iter,1)
gnome.ui.GnomeErrorDialog(msg)
return
else:
index = obj.selection[0]
used = 0 used = 0
place = self.db.getPlace(obj.get_row_data(index)) place = self.db.getPlace(id)
for key in self.db.getPersonKeys(): for key in self.db.getPersonKeys():
p = self.db.getPerson(key) p = self.db.getPerson(key)
event_list = [p.getBirth(), p.getDeath()] + p.getEventList() event_list = [p.getBirth(), p.getDeath()] + p.getEventList()
@ -208,8 +206,8 @@ class PlaceView:
_('Delete Place'),ans.query_response, _('Delete Place'),ans.query_response,
_('Keep Place')) _('Keep Place'))
else: else:
obj.remove(index)
self.db.removePlace(place.getId()) self.db.removePlace(place.getId())
self.update(0)
Utils.modified() Utils.modified()
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):

View File

@ -18,8 +18,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
import gnome.ui
import gtk import gtk
import gnome.ui
from intl import gettext as _
class QuestionDialog: class QuestionDialog:
def __init__(self,title,msg,blabel1,task1,blabel2,task2=None): def __init__(self,title,msg,blabel1,task1,blabel2,task2=None):
@ -58,4 +59,26 @@ class QuestionDialog:
if self.task2: if self.task2:
self.task2() self.task2()
self.top.destroy() self.top.destroy()
class ErrorDialog:
def __init__(self,msg):
title = '%s - GRAMPS' % _('Error')
self.top = gtk.Dialog()
self.top.set_title(title)
label = gtk.Label(msg)
label.show()
hbox = gtk.HBox()
image = gtk.Image()
image.set_from_stock(gtk.STOCK_DIALOG_ERROR,gtk.ICON_SIZE_DIALOG)
hbox.set_spacing(10)
hbox.pack_start(image)
hbox.add(label)
self.top.vbox.pack_start(hbox)
self.top.set_default_size(300,150)
self.top.add_button(gtk.STOCK_OK,0)
self.top.set_response_sensitive(0,gtk.TRUE)
self.top.show_all()
self.top.run()
self.top.destroy()

View File

@ -31,7 +31,7 @@ import os
# Gnome/GTK # Gnome/GTK
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gnome.ui #import GnomeErrorDialog import gnome.ui
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -40,8 +40,8 @@ import gnome.ui #import GnomeErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
from GrampsParser import GrampsParser, GrampsImportParser from GrampsParser import GrampsParser, GrampsImportParser
from intl import gettext from QuestionDialog import ErrorDialog
_ = gettext from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -86,16 +86,16 @@ def importData(database, filename, callback):
else: else:
xml_file = open(filename,"r") xml_file = open(filename,"r")
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg)) ErrorDialog(_("%s could not be opened\n") % filename + str(msg))
return 0 return 0
except: except:
GnomeErrorDialog(_("%s could not be opened\n") % filename) ErrorDialog(_("%s could not be opened\n") % filename)
return 0 return 0
try: try:
parser.parse(xml_file) parser.parse(xml_file)
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("Error reading %s") % filename + "\n" + str(msg)) ErrorDialog(_("Error reading %s") % filename + "\n" + str(msg))
import traceback import traceback
traceback.print_exc() traceback.print_exc()
return 0 return 0
@ -142,22 +142,22 @@ def loadData(database, filename, callback=None):
xml_file = open(filename,"r") xml_file = open(filename,"r")
except IOError,msg: except IOError,msg:
filemsg = _("%s could not be opened\n") % filename filemsg = _("%s could not be opened\n") % filename
GnomeErrorDialog(filemsg + str(msg)) ErrorDialog(filemsg + str(msg))
return 0 return 0
except: except:
GnomeErrorDialog(_("%s could not be opened\n") % filename) ErrorDialog(_("%s could not be opened\n") % filename)
return 0 return 0
try: try:
parser.parse(xml_file) parser.parse(xml_file)
except IOError,msg: except IOError,msg:
errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg)) errmsg = "%s\n%s" % (_("Error reading %s") % filename,str(msg))
GnomeErrorDialog(errmsg) ErrorDialog(errmsg)
import traceback import traceback
traceback.print_exc() traceback.print_exc()
return 0 return 0
except: except:
GnomeErrorDialog(_("Error reading %s") % filename) ErrorDialog(_("Error reading %s") % filename)
import traceback import traceback
traceback.print_exc() traceback.print_exc()
return 0 return 0
@ -186,7 +186,7 @@ def loadRevision(database, file, filename, revision, callback=None):
parser.parse(file) parser.parse(file)
except IOError,msg: except IOError,msg:
errmsg = "%s\n%s" % (_("Error reading %s") % filename, str(msg)) errmsg = "%s\n%s" % (_("Error reading %s") % filename, str(msg))
GnomeErrorDialog(errmsg) ErrorDialog(errmsg)
import traceback import traceback
traceback.print_exc() traceback.print_exc()
return 0 return 0

View File

@ -32,7 +32,7 @@ import string
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
#from gnome.ui import GnomeErrorDialog, GnomeWarningDialog from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -42,9 +42,7 @@ import gtk
import const import const
import Utils import Utils
import ImgManip import ImgManip
from intl import gettext from intl import gettext as _
_ = gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -55,7 +53,7 @@ def import_media_object(filename,path,base):
import shutil import shutil
if not os.path.exists(filename): if not os.path.exists(filename):
GnomeErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename) ErrorDialog(_("Could not import %s\nThe file has been moved or deleted") % filename)
return "" return ""
ext = os.path.splitext(filename)[1] ext = os.path.splitext(filename)[1]
@ -71,23 +69,23 @@ def import_media_object(filename,path,base):
if not os.path.exists(thumb): if not os.path.exists(thumb):
os.mkdir(thumb) os.mkdir(thumb)
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("Could not create %s") % thumb + "\n" + str(msg)) ErrorDialog(_("Could not create %s") % thumb + "\n" + str(msg))
return "" return ""
except: except:
GnomeErrorDialog(_("Could not create %s") % thumb) ErrorDialog(_("Could not create %s") % thumb)
return "" return ""
try: try:
path = "%s/%s.jpg" % (thumb,base) path = "%s/%s.jpg" % (thumb,base)
mk_thumb(filename,path,const.thumbScale) mk_thumb(filename,path,const.thumbScale)
except: except:
GnomeErrorDialog(_("Error creating the thumbnail : %s")) ErrorDialog(_("Error creating the thumbnail : %s"))
return "" return ""
try: try:
shutil.copy(filename,name) shutil.copy(filename,name)
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("Error copying %s") % filename + "\n" + msg) ErrorDialog(_("Error copying %s") % filename + "\n" + msg)
return "" return ""
else: else:
@ -136,10 +134,10 @@ def mk_thumb(source,dest,size):
if not os.path.exists(dir): if not os.path.exists(dir):
os.mkdir(dir) os.mkdir(dir)
except IOError,msg: except IOError,msg:
GnomeErrorDialog(_("Could not create %s") % dir + "\n" + str(msg)) ErrorDialog(_("Could not create %s") % dir + "\n" + str(msg))
return return
except: except:
GnomeErrorDialog(_("Could not create %s") % dir) ErrorDialog(_("Could not create %s") % dir)
return return
if os.path.exists(dest): if os.path.exists(dest):
@ -147,11 +145,11 @@ def mk_thumb(source,dest,size):
os.remove(dest) os.remove(dest)
except IOError,msg: except IOError,msg:
errmsg = _("Could not replace %s") % dir errmsg = _("Could not replace %s") % dir
GnomeErrorDialog(errmsg + "\n" + msg) ErrorDialog(errmsg + "\n" + msg)
return return
if not os.path.exists(source): if not os.path.exists(source):
GnomeErrorDialog(_("Could not create a thumbnail for %s\nThe file has been moved or deleted") % source) ErrorDialog(_("Could not create a thumbnail for %s\nThe file has been moved or deleted") % source)
try: try:
img = ImgManip.ImgManip(source) img = ImgManip.ImgManip(source)
@ -159,7 +157,7 @@ def mk_thumb(source,dest,size):
except: except:
import sys import sys
msg = "%s\n%s %s" % (source,sys.exc_type,sys.exc_value) msg = "%s\n%s %s" % (source,sys.exc_type,sys.exc_value)
GnomeErrorDialog(_("Could not create a thumbnail for %s") % msg) ErrorDialog(_("Could not create a thumbnail for %s") % msg)
return return
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -1890,35 +1890,50 @@ class GrampsDB(Persistent):
self.placeTable[nkey] = self.placeMap[nkey].getDisplayInfo() self.placeTable[nkey] = self.placeMap[nkey].getDisplayInfo()
def set_iprefix(self,val): def set_iprefix(self,val):
if _id_reg.search(val): if val:
self.iprefix = val if _id_reg.search(val):
self.iprefix = val
else:
self.iprefix = val + "%d"
else: else:
self.iprefix = val + "%d" self.iprefix = "I%d"
def set_sprefix(self,val): def set_sprefix(self,val):
if _id_reg.search(val): if val:
self.sprefix = val if _id_reg.search(val):
self.sprefix = val
else:
self.sprefix = val + "%d"
else: else:
self.sprefix = val + "%d" self.sprefix = "S%d"
def set_oprefix(self,val): def set_oprefix(self,val):
if _id_reg.search(val): if val:
self.oprefix = val if _id_reg.search(val):
self.oprefix = val
else:
self.oprefix = val + "%d"
else: else:
self.oprefix = val + "%d" self.oprefix = "O%d"
def set_pprefix(self,val): def set_pprefix(self,val):
if _id_reg.search(val): if val:
self.pprefix = val if _id_reg.search(val):
self.pprefix = val
else:
self.pprefix = val + "%d"
else: else:
self.pprefix = val + "%d" self.pprefix = "P%d"
def set_fprefix(self,val): def set_fprefix(self,val):
if _id_reg.search(val): if val:
self.fprefix = val if _id_reg.search(val):
self.fprefix = val
else:
self.fprefix = val + "%d"
else: else:
self.fprefix = val + "%d" self.fprefix = "F%d"
def new(self): def new(self):
"""initializes the GrampsDB to empty values""" """initializes the GrampsDB to empty values"""

View File

@ -58,6 +58,8 @@ import latin_utf8
u2l = latin_utf8.utf8_to_latin u2l = latin_utf8.utf8_to_latin
_ = intl.gettext _ = intl.gettext
from QuesionDialog import ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Import XML libraries # Import XML libraries
@ -813,7 +815,7 @@ class ReportDialog:
return None return None
if not self.get_target_is_directory() and os.path.isdir(self.target_path): if not self.get_target_is_directory() and os.path.isdir(self.target_path):
gnome.ui.GnomeErrorDialog(_("The filename that you gave is a directory.\n" GnomeErrorDialog(_("The filename that you gave is a directory.\n"
"You need to provide a valid filename.")) "You need to provide a valid filename."))
return None return None
@ -942,7 +944,7 @@ class ReportDialog:
try: try:
self.make_report() self.make_report()
except (IOError,OSError),msg: except (IOError,OSError),msg:
gnome.ui.GnomeErrorDialog(str(msg)) ErrorDialog(str(msg))
# Clean up the dialog object # Clean up the dialog object
self.window.destroy() self.window.destroy()

View File

@ -41,8 +41,8 @@ import const
import GrampsCfg import GrampsCfg
from RelLib import * from RelLib import *
from Date import SingleDate from Date import SingleDate
from intl import gettext from intl import gettext as _
_ = gettext from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -71,11 +71,10 @@ def exportData(database, filename, callback):
g = XmlWriter(database,callback,0,compress) g = XmlWriter(database,callback,0,compress)
g.write(filename) g.write(filename)
except: except:
from gnome.ui import GnomeErrorDialog
import DisplayTrace import DisplayTrace
DisplayTrace.DisplayTrace() DisplayTrace.DisplayTrace()
GnomeErrorDialog(_("Failure writing %s, original file restored") % filename) ErrorDialog(_("Failure writing %s, original file restored") % filename)
shutil.copy(filename + ".bak", filename) shutil.copy(filename + ".bak", filename)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ from SourceView import SourceView
from MediaView import MediaView from MediaView import MediaView
from FamilyView import FamilyView from FamilyView import FamilyView
from QuestionDialog import QuestionDialog from QuestionDialog import QuestionDialog, ErrorDialog
import DisplayTrace import DisplayTrace
import Filter import Filter
@ -350,7 +350,7 @@ class Gramps:
elif cpage == 3: elif cpage == 3:
self.source_view.on_add_clicked(obj) self.source_view.on_add_clicked(obj)
elif cpage == 4: elif cpage == 4:
self.place_view.on_add_clicked(obj) self.place_view.on_add_place_clicked(obj)
def remove_button_clicked(self,obj): def remove_button_clicked(self,obj):
cpage = self.notebook.get_current_page() cpage = self.notebook.get_current_page()
@ -475,7 +475,7 @@ class Gramps:
if page == 0: if page == 0:
if len(self.person_list.selection) != 2: if len(self.person_list.selection) != 2:
msg = _("Exactly two people must be selected to perform a merge") msg = _("Exactly two people must be selected to perform a merge")
gnome.ui.GnomeErrorDialog(msg) ErrorDialog(msg)
else: else:
import MergeData import MergeData
p1 = self.person_list.get_row_data(self.person_list.selection[0]) p1 = self.person_list.get_row_data(self.person_list.selection[0])
@ -897,10 +897,10 @@ class Gramps:
os.mkdir(filename) os.mkdir(filename)
except (OSError,IOError), msg: except (OSError,IOError), msg:
emsg = _("Could not create %s") % filename + "\n" + str(msg) emsg = _("Could not create %s") % filename + "\n" + str(msg)
gnome.ui.GnomeErrorDialog(emsg) ErrorDialog(emsg)
return return
except: except:
gnome.ui.GnomeErrorDialog(_("Could not create %s") % filename) ErrorDialog(_("Could not create %s") % filename)
return return
old_file = filename old_file = filename
@ -909,7 +909,7 @@ class Gramps:
self.db.save(filename,self.load_progress) self.db.save(filename,self.load_progress)
except (OSError,IOError), msg: except (OSError,IOError), msg:
emsg = _("Could not create %s") % filename + "\n" + str(msg) emsg = _("Could not create %s") % filename + "\n" + str(msg)
gnome.ui.GnomeErrorDialog(emsg) ErrorDialog(emsg)
return return
self.db.setSavePath(old_file) self.db.setSavePath(old_file)
@ -1526,7 +1526,7 @@ class Gramps:
self.bookmark_callback) self.bookmark_callback)
def displayError(self,msg): def displayError(self,msg):
gnome.ui.GnomeErrorDialog(msg) ErrorDialog(msg)
self.statusbar.set_status("") self.statusbar.set_status("")
def apply_filter(self): def apply_filter(self):
@ -1555,7 +1555,7 @@ class Gramps:
self.change_active_person(temp) self.change_active_person(temp)
self.update_display(0) self.update_display(0)
else: else:
gnome.ui.GnomeErrorDialog(_("No default/home person has been set")) ErrorDialog(_("No default/home person has been set"))
def on_add_bookmark_activate(self,obj): def on_add_bookmark_activate(self,obj):
if self.active_person: if self.active_person: