More cleanup of code

svn: r465
This commit is contained in:
Don Allingham 2001-10-14 05:19:43 +00:00
parent bd7a01a910
commit 5d60f15189
12 changed files with 171 additions and 333 deletions

View File

@ -23,7 +23,6 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import os
import string
#-------------------------------------------------------------------------
@ -106,6 +105,7 @@ class AddressEditor:
})
def on_addr_source_clicked(self,obj):
import Sources
Sources.SourceSelector(self.srcreflist,self.parent,src_changed)
def on_addr_edit_ok_clicked(self,obj):

View File

@ -33,7 +33,6 @@ import string
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import GDK
import libglade
#-------------------------------------------------------------------------
@ -44,7 +43,6 @@ import libglade
import intl
import const
import utils
import Config
from RelLib import *
import Sources

View File

@ -51,20 +51,6 @@ import ImageSelect
_ = intl.gettext
#-------------------------------------------------------------------------
#
# Constants - quite frequently, data needs to be attached to a widget.
# this is done to prevent the use of globals, and to allow data to be
# passed with a widget (especially critical, since more that one window
# can be opened at a time). Data is attached to an widget using a string
# as the key. To avoid a lot of hard coded text strings floating around
# everywhere, values are defined here as constants with more meaningful
# names.
#
#-------------------------------------------------------------------------
NOTEOBJ = "n"
TEXTOBJ = "w"
#-------------------------------------------------------------------------
#
# EditPerson class

View File

@ -45,15 +45,11 @@ import intl
import const
import utils
from RelLib import *
import RelImage
import Sources
import ImageSelect
import UrlEdit
_ = intl.gettext
_DEFHTTP = "http://gramps.sourceforge.net"
#-------------------------------------------------------------------------
#
# Constants
@ -276,6 +272,7 @@ def on_switch_page(obj,a,page):
#
#-------------------------------------------------------------------------
def on_update_url_clicked(obj):
import UrlEdit
if len(obj.selection) > 0:
row = obj.selection[0]
mobj = obj.get_data(_PLACE)
@ -323,6 +320,7 @@ def on_delete_loc_clicked(obj):
#
#-------------------------------------------------------------------------
def on_add_url_clicked(obj):
import UrlEdit
mobj = obj.get_data(_PLACE)
if mobj.place:
name = _("Internet Address Editor for %s") % mobj.place.get_title()

View File

@ -44,7 +44,6 @@ import intl
import const
import utils
from RelLib import *
import RelImage
import ImageSelect
_ = intl.gettext

View File

@ -25,15 +25,9 @@
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import GDK
import libglade
import os
import intl
import Sources
import AttrEdit
_ = intl.gettext
#-------------------------------------------------------------------------
#
@ -42,11 +36,8 @@ _ = intl.gettext
#-------------------------------------------------------------------------
import const
import Config
import utils
from RelLib import *
import RelImage
import ImageSelect
#-------------------------------------------------------------------------
#

View File

@ -35,7 +35,6 @@ from gtk import *
from gnome.ui import *
import GDK
import libglade
import GdkImlib
#-------------------------------------------------------------------------
#
@ -48,8 +47,6 @@ import utils
import Config
from RelLib import *
import RelImage
import Sources
import AttrEdit
_ = intl.gettext
@ -393,8 +390,6 @@ class LocalMediaProperties:
self.lists_changed = 0
fname = self.object.getPath()
src = os.path.basename(fname)
self.change_dialog = libglade.GladeXML(const.imageselFile,"change_description")
window = self.change_dialog.get_widget("change_description")
descr_window = self.change_dialog.get_widget("description")
@ -462,6 +457,7 @@ class LocalMediaProperties:
self.attr_details.set_text(utils.get_detail_text(attr))
def on_update_attr_clicked(self,obj):
import AttrEdit
if len(obj.selection) > 0:
row = obj.selection[0]
attr = obj.get_row_data(row)
@ -473,6 +469,7 @@ class LocalMediaProperties:
self.redraw_attr_list()
def on_add_attr_clicked(self,obj):
import AttrEdit
AttrEdit.AttributeEditor(self,None,"Media Object",[])
#-------------------------------------------------------------------------

View File

@ -25,14 +25,9 @@
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import GDK
import libglade
import os
import intl
import Sources
import AttrEdit
import EventEdit
_ = intl.gettext
@ -46,7 +41,6 @@ import const
import Config
import utils
from RelLib import *
import RelImage
import ImageSelect
#-------------------------------------------------------------------------
@ -79,22 +73,22 @@ class Marriage:
plwidget = self.top.get_widget("photolist")
self.gallery = ImageSelect.Gallery(family, self.path, fid, plwidget, db)
self.top.signal_autoconnect({
"destroy_passed_object" : on_cancel_edit,
"on_add_attr_clicked" : on_add_attr_clicked,
"destroy_passed_object" : self.on_cancel_edit,
"on_add_attr_clicked" : self.on_add_attr_clicked,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_attr_list_select_row" : on_attr_list_select_row,
"on_close_marriage_editor" : on_close_marriage_editor,
"on_delete_attr_clicked" : on_delete_attr_clicked,
"on_delete_event" : on_delete_event,
"on_attr_list_select_row" : self.on_attr_list_select_row,
"on_close_marriage_editor" : self.on_close_marriage_editor,
"on_delete_attr_clicked" : self.on_delete_attr_clicked,
"on_delete_event" : self.on_delete_event,
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
"on_edit_properties_clicked": self.gallery.popup_change_description,
"on_marriageAddBtn_clicked" : on_add_clicked,
"on_marriageDeleteBtn_clicked" : on_delete_clicked,
"on_marriageEventList_select_row" : on_select_row,
"on_marriageUpdateBtn_clicked" : on_update_clicked,
"on_marriageAddBtn_clicked" : self.on_add_clicked,
"on_marriageDeleteBtn_clicked" : self.on_delete_clicked,
"on_marriageEventList_select_row" : self.on_select_row,
"on_marriageUpdateBtn_clicked" : self.on_update_clicked,
"on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event,
"on_photolist_select_icon" : self.gallery.on_photo_select_icon,
"on_update_attr_clicked" : on_update_attr_clicked,
"on_update_attr_clicked" : self.on_update_attr_clicked,
})
text_win = self.get_widget("marriageTitle")
@ -162,66 +156,38 @@ class Marriage:
self.family.setEventList(self.elist)
self.family.setAttributeList(self.alist)
#---------------------------------------------------------------------
#
# redraw_attr_list - redraws the attribute list for the person
#
#---------------------------------------------------------------------
def redraw_attr_list(self):
utils.redraw_list(self.alist,self.attr_list,disp_attr)
#-------------------------------------------------------------------------
#
# redraw_events - redraws the event list by deleting all the entries and
# reconstructing the list
#
#-------------------------------------------------------------------------
def redraw_event_list(self):
utils.redraw_list(self.elist,self.event_list,disp_event)
#-------------------------------------------------------------------------
#
# get_widget - returns the widget associated with the specified name
#
#-------------------------------------------------------------------------
def get_widget(self,name):
return self.top.get_widget(name)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def did_data_change(obj):
family_obj = obj.get_data(MARRIAGE)
def did_data_change(self):
changed = 0
relation = family_obj.type_field.entry.get_text()
if const.save_frel(relation) != family_obj.family.getRelationship():
relation = self.type_field.entry.get_text()
if const.save_frel(relation) != self.family.getRelationship():
changed = 1
text = family_obj.notes_field.get_chars(0,-1)
if text != family_obj.family.getNote():
text = self.notes_field.get_chars(0,-1)
if text != self.family.getNote():
changed = 1
if family_obj.lists_changed:
if self.lists_changed:
changed = 1
idval = family_obj.gid.get_text()
if family_obj.family.getId() != idval:
idval = self.gid.get_text()
if self.family.getId() != idval:
changed = 1
return changed
#-------------------------------------------------------------------------
#
# on_cancel_edit
#
#-------------------------------------------------------------------------
def on_cancel_edit(obj):
def on_cancel_edit(self,obj):
if did_data_change(obj):
if self.did_data_change():
global quit
q = _("Data was modified. Are you sure you want to abandon your changes?")
quit = obj
@ -229,44 +195,14 @@ def on_cancel_edit(obj):
else:
utils.destroy_passed_object(obj)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def cancel_callback(a):
if a==0:
utils.destroy_passed_object(quit)
def on_delete_event(self,obj,b):
self.on_cancel_edit(obj)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_delete_event(obj,b):
global quit
if did_data_change(obj):
q = _("Data was modified. Are you sure you want to abandon your changes?")
quit = obj
GnomeQuestionDialog(q,cancel_callback)
return 1
else:
utils.destroy_passed_object(obj)
return 0
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_close_marriage_editor(obj):
family_obj = obj.get_data(MARRIAGE)
idval = family_obj.gid.get_text()
family = family_obj.family
def on_close_marriage_editor(self,obj):
idval = self.gid.get_text()
family = self.family
if idval != family.getId():
m = family_obj.db.getFamilyMap()
m = self.db.getFamilyMap()
if not m.has_key(idval):
if m.has_key(family.getId()):
del m[family.getId()]
@ -277,45 +213,38 @@ def on_close_marriage_editor(obj):
msg1 = _("GRAMPS ID value was not changed.")
GnomeWarningDialog("%s" % msg1)
relation = family_obj.type_field.entry.get_text()
if const.save_frel(relation) != family_obj.family.getRelationship():
father = family_obj.family.getFather()
mother = family_obj.family.getMother()
relation = self.type_field.entry.get_text()
if const.save_frel(relation) != self.family.getRelationship():
father = self.family.getFather()
mother = self.family.getMother()
if father.getGender() == mother.getGender():
family_obj.family.setRelationship("Partners")
self.family.setRelationship("Partners")
else:
val = const.save_frel(relation)
if val == "Partners":
val = "Unknown"
if father.getGender() == Person.female or \
mother.getGender() == Person.male:
family_obj.family.setFather(mother)
family_obj.family.setMother(father)
family_obj.family.setRelationship(val)
self.family.setFather(mother)
self.family.setMother(father)
self.family.setRelationship(val)
utils.modified()
text = family_obj.notes_field.get_chars(0,-1)
if text != family_obj.family.getNote():
family_obj.family.setNote(text)
text = self.notes_field.get_chars(0,-1)
if text != self.family.getNote():
self.family.setNote(text)
utils.modified()
utils.destroy_passed_object(family_obj.get_widget("marriageEditor"))
utils.destroy_passed_object(self.get_widget("marriageEditor"))
family_obj.update_lists()
if family_obj.lists_changed:
self.update_lists()
if self.lists_changed:
utils.modified()
#-------------------------------------------------------------------------
#
# on_add_clicked - creates a new event from the data displayed in the
# window. Special care has to be take for the marriage and divorce
# events, since they are not stored in the event list.
#
#-------------------------------------------------------------------------
def on_add_clicked(obj):
mobj = obj.get_data(MARRIAGE)
father = mobj.family.getFather()
mother = mobj.family.getMother()
def on_add_clicked(self,obj):
import EventEdit
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
@ -323,22 +252,16 @@ def on_add_clicked(obj):
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
EventEdit.EventEditor(mobj,name,const.marriageEvents,const.save_pevent,None,0)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,None,0)
#-------------------------------------------------------------------------
#
# on_update_clicked - updates the selected event with the values in the
# current display
#
#-------------------------------------------------------------------------
def on_update_clicked(obj):
def on_update_clicked(self,obj):
import EventEdit
if len(obj.selection) <= 0:
return
mobj = obj.get_data(MARRIAGE)
event = obj.get_row_data(obj.selection[0])
father = mobj.family.getFather()
mother = mobj.family.getMother()
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
@ -346,66 +269,37 @@ def on_update_clicked(obj):
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
EventEdit.EventEditor(mobj,name,const.marriageEvents,const.save_pevent,event,0)
EventEdit.EventEditor(self,name,const.marriageEvents,const.save_pevent,event,0)
#-------------------------------------------------------------------------
#
# on_delete_clicked - deletes the currently displayed event from the
# marriage event list. Special care needs to be taken for the Marriage
# and Divorce events, since they are not stored in the event list
#
#-------------------------------------------------------------------------
def on_delete_clicked(obj):
family_obj = obj.get_data(MARRIAGE)
if utils.delete_selected(obj,family_obj.elist):
family_obj.lists_changed = 1
family_obj.redraw_event_list()
def on_delete_clicked(self,obj):
if utils.delete_selected(obj,self.elist):
self.lists_changed = 1
self.redraw_event_list()
#-------------------------------------------------------------------------
#
# on_select_row - updates the internal data attached to the passed object,
# then updates the display.
#
#-------------------------------------------------------------------------
def on_select_row(obj,row,b,c):
family_obj = obj.get_data(MARRIAGE)
def on_select_row(self,obj,row,b,c):
event = obj.get_row_data(row)
family_obj.date_field.set_text(event.getDate())
family_obj.place_field.set_text(event.getPlaceName())
family_obj.cause_field.set_text(event.getCause())
family_obj.name_field.set_label(const.display_fevent(event.getName()))
family_obj.event_details.set_text(utils.get_detail_text(event))
family_obj.descr_field.set_text(event.getDescription())
self.date_field.set_text(event.getDate())
self.place_field.set_text(event.getPlaceName())
self.cause_field.set_text(event.getCause())
self.name_field.set_label(const.display_fevent(event.getName()))
self.event_details.set_text(utils.get_detail_text(event))
self.descr_field.set_text(event.getDescription())
#-------------------------------------------------------------------------
#
# on_attr_list_select_row - sets the row object attached to the passed
# object, and then updates the display with the data corresponding to
# the row.
#
#-------------------------------------------------------------------------
def on_attr_list_select_row(obj,row,b,c):
family_obj = obj.get_data(MARRIAGE)
def on_attr_list_select_row(self,obj,row,b,c):
attr = obj.get_row_data(row)
family_obj.attr_type.set_label(const.display_fattr(attr.getType()))
family_obj.attr_value.set_text(attr.getValue())
family_obj.attr_details_field.set_text(utils.get_detail_text(attr))
self.attr_type.set_label(const.display_fattr(attr.getType()))
self.attr_value.set_text(attr.getValue())
self.attr_details_field.set_text(utils.get_detail_text(attr))
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_update_attr_clicked(obj):
def on_update_attr_clicked(self,obj):
import AttrEdit
if len(obj.selection) > 0:
row = obj.selection[0]
mobj = obj.get_data(MARRIAGE)
attr = obj.get_row_data(row)
father = mobj.family.getFather()
mother = mobj.family.getMother()
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
@ -413,28 +307,17 @@ def on_update_attr_clicked(obj):
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
AttrEdit.AttributeEditor(mobj,attr,name,const.familyAttributes)
AttrEdit.AttributeEditor(self,attr,name,const.familyAttributes)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_delete_attr_clicked(obj):
family_obj = obj.get_data(MARRIAGE)
if utils.delete_selected(obj,family_obj.alist):
family_obj.lists_changed = 1
family_obj.redraw_attr_list()
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(obj):
mobj = obj.get_data(MARRIAGE)
father = mobj.family.getFather()
mother = mobj.family.getMother()
def on_add_attr_clicked(self,obj):
import AttrEdit
father = self.family.getFather()
mother = self.family.getMother()
if father and mother:
name = _("%s and %s") % (father.getPrimaryName().getName(),
mother.getPrimaryName().getName())
@ -442,7 +325,7 @@ def on_add_attr_clicked(obj):
name = father.getPrimaryName().getName()
else:
name = mother.getPrimaryName().getName()
AttrEdit.AttributeEditor(mobj,None,name,const.familyAttributes)
AttrEdit.AttributeEditor(self,None,name,const.familyAttributes)
#-------------------------------------------------------------------------
@ -462,3 +345,13 @@ def disp_attr(attr):
def disp_event(event):
return [const.display_fevent(event.getName()), event.getQuoteDate(),
event.getPlaceName(), utils.get_detail_flags(event)]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def cancel_callback(a):
if a==0:
utils.destroy_passed_object(quit)

View File

@ -23,7 +23,6 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import os
import string
#-------------------------------------------------------------------------
@ -34,7 +33,6 @@ import string
from gtk import *
from gnome.ui import *
import libglade
import GdkImlib
#-------------------------------------------------------------------------
#
@ -44,10 +42,7 @@ import GdkImlib
import intl
import const
import utils
import Config
from RelLib import *
import RelImage
import Sources
_ = intl.gettext
@ -101,6 +96,7 @@ class NameEditor:
})
def on_name_source_clicked(self,obj):
import Sources
Sources.SourceSelector(self.srcreflist,self.parent,src_changed)
def on_name_edit_ok_clicked(self,obj):

View File

@ -23,7 +23,6 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import os
import string
#-------------------------------------------------------------------------
@ -42,7 +41,6 @@ import libglade
#-------------------------------------------------------------------------
import const
import utils
import Config
from RelLib import *
#-------------------------------------------------------------------------

View File

@ -23,7 +23,6 @@
# Standard python modules
#
#-------------------------------------------------------------------------
import os
import string
#-------------------------------------------------------------------------
@ -41,13 +40,10 @@ import libglade
# gramps modules
#
#-------------------------------------------------------------------------
import intl
import const
import utils
from RelLib import *
_ = intl.gettext
#-------------------------------------------------------------------------
#
# UrlEditor class

View File

@ -52,7 +52,7 @@ class VersionControl:
form of three strings - (version,date,comment)."""
return []
def checkin(self,name,comment,binary,tag):
def checkin(self,name,comment,binary):
"""Checks in a file into the revision control database
name - file to check in
@ -78,6 +78,7 @@ class RcsVersionControl(VersionControl):
def __init__(self,wd):
"""Initializes the RCS database if it does not already exist.
Sets the database to disable locking"""
VersionControl.__init__(self,wd)
self.wd = wd
self.vfile = "%s/version,v" % wd
self.tfile = "%s/version" % wd
@ -90,6 +91,9 @@ class RcsVersionControl(VersionControl):
rlist = []
slog = 0
sname = 0
v = None
l = None
d = None
r,w = popen2.popen2("rlog %s" % self.vfile)
for line in r.readlines():
@ -155,8 +159,8 @@ class RcsVersionControl(VersionControl):
def set_tag(self,tag):
"""Sets the tag to the symbolic string"""
if tag != "":
pproc = popen2.Popen3("rcs -N%s: %s" % (tag,self.tfile),1)
proc.tochild.write(comment)
proc = popen2.Popen3("rcs -N%s: %s" % (tag,self.tfile),1)
proc.tochild.write("")
proc.tochild.close()
status = proc.wait()
del proc
@ -185,21 +189,3 @@ def get_vc_list():
classes. The tuple is in the format of (class,description)"""
return _version_control_list
if __name__ == "__main__":
import sys
c = RcsVersionControl(os.getcwd())
if sys.argv[1] == "log":
for val in c.revision_list():
print "%s - %s : %s" % val
elif sys.argv[1] == "ci":
c.checkin(sys.argv[2],"mycomment",0)
for val in c.revision_list():
print "%s - %s : %s" % val
elif sys.argv[1] == "co":
f = c.get_version(sys.argv[2])
for l in f.readlines():
print l
f.close()