* src/plugins/RelCalc.py: use empty string instead of None

* src/EditPerson.py: pychecker fixes
* src/EditPlace.py: pychecker fixes
* src/EditSource.py: pychecker fixes
* src/GenericFilter.py: pychecker fixes
* src/GrampsCfg.py: pychecker fixes
* src/ImageSelect.py: pychecker fixes
* src/ListModel.py: pychecker fixes
* src/MediaView.py; pychecker fixes
* src/MergeData.py: pychecker fixes
* src/PedView.py: pychecker fixes
* src/PeopleView.py: pychecker fixes
* src/PlaceView.py: pychecker fixes
* src/Plugins.py: pychecker fixes
* src/RelImage.py: pychecker fixes
* src/Relationship.py: pychecker fixes


svn: r3450
This commit is contained in:
Don Allingham 2004-08-20 12:11:56 +00:00
parent 182bf44509
commit 0175cf1bbf
17 changed files with 325 additions and 312 deletions

View File

@ -1,3 +1,21 @@
2004-08-20 Don Allingham <dallingham@users.sourceforge.net>
* src/plugins/RelCalc.py: use empty string instead of None
* src/EditPerson.py: pychecker fixes
* src/EditPlace.py: pychecker fixes
* src/EditSource.py: pychecker fixes
* src/GenericFilter.py: pychecker fixes
* src/GrampsCfg.py: pychecker fixes
* src/ImageSelect.py: pychecker fixes
* src/ListModel.py: pychecker fixes
* src/MediaView.py; pychecker fixes
* src/MergeData.py: pychecker fixes
* src/PedView.py: pychecker fixes
* src/PeopleView.py: pychecker fixes
* src/PlaceView.py: pychecker fixes
* src/Plugins.py: pychecker fixes
* src/RelImage.py: pychecker fixes
* src/Relationship.py: pychecker fixes
2004-08-20 Tim Waugh <twaugh@redhat.com> 2004-08-20 Tim Waugh <twaugh@redhat.com>
* src/plugins/RelCalc.py (__init__): Handle unknown birth dates. * src/plugins/RelCalc.py (__init__): Handle unknown birth dates.
* src/Calendar.py (calendar_names): Fixed typo. * src/Calendar.py (calendar_names): Fixed typo.

View File

@ -1719,9 +1719,9 @@ class EditPerson:
elif page == 9 and self.lds_not_loaded: elif page == 9 and self.lds_not_loaded:
self.lds_not_loaded = 0 self.lds_not_loaded = 0
self.draw_lds() self.draw_lds()
buffer = self.notes_buffer note_buf = self.notes_buffer
text = unicode(buffer.get_text(buffer.get_start_iter(), text = unicode(note_buf.get_text(note_buf.get_start_iter(),
buffer.get_end_iter(),gtk.FALSE)) note_buf.get_end_iter(),gtk.FALSE))
if text: if text:
Utils.bold_label(self.notes_label) Utils.bold_label(self.notes_label)
else: else:

View File

@ -393,9 +393,9 @@ class EditPlace:
def on_update_url_clicked(self,obj): def on_update_url_clicked(self,obj):
import UrlEdit import UrlEdit
store,iter = self.web_list.get_selection().get_selected() store,node = self.web_list.get_selection().get_selected()
if iter: if node:
row = store.get_path(iter) row = store.get_path(node)
url = self.ulist[row[0]] url = self.ulist[row[0]]
if url: if url:
name = _("Internet Address Editor for %s") % self.place.get_title() name = _("Internet Address Editor for %s") % self.place.get_title()
@ -406,9 +406,9 @@ class EditPlace:
def on_update_loc_clicked(self,obj): def on_update_loc_clicked(self,obj):
import LocEdit import LocEdit
store,iter = self.loc_sel.get_selected() store,node = self.loc_sel.get_selected()
if iter: if node:
row = store.get_path(iter) row = store.get_path(node)
loc = self.llist[row[0]] loc = self.llist[row[0]]
LocEdit.LocationEditor(self,loc,self.top) LocEdit.LocationEditor(self,loc,self.top)
@ -438,13 +438,13 @@ class EditPlace:
LocEdit.LocationEditor(self,None,self.top) LocEdit.LocationEditor(self,None,self.top)
def on_web_list_select_row(self,obj): def on_web_list_select_row(self,obj):
store,iter = obj.get_selected() store,node = obj.get_selected()
if not iter: if not node:
self.web_url.set_text("") self.web_url.set_text("")
self.web_go.set_sensitive(0) self.web_go.set_sensitive(0)
self.web_description.set_text("") self.web_description.set_text("")
else: else:
row = store.get_path(iter) row = store.get_path(node)
url = self.ulist[row[0]] url = self.ulist[row[0]]
path = url.get_path() path = url.get_path()
self.web_url.set_text(path) self.web_url.set_text(path)
@ -452,8 +452,8 @@ class EditPlace:
self.web_description.set_text(url.get_description()) self.web_description.set_text(url.get_description())
def on_loc_list_select_row(self,obj): def on_loc_list_select_row(self,obj):
store,iter = self.loc_sel.get_selected() store,node = self.loc_sel.get_selected()
if not iter: if not node:
self.loc_city.set_text('') self.loc_city.set_text('')
self.loc_county.set_text('') self.loc_county.set_text('')
self.loc_state.set_text('') self.loc_state.set_text('')
@ -462,7 +462,7 @@ class EditPlace:
self.loc_parish.set_text('') self.loc_parish.set_text('')
self.loc_country.set_text('') self.loc_country.set_text('')
else: else:
row = store.get_path(iter) row = store.get_path(node)
loc = self.llist[row[0]] loc = self.llist[row[0]]
self.loc_city.set_text(loc.get_city()) self.loc_city.set_text(loc.get_city())

View File

@ -218,9 +218,9 @@ class EditSource:
if sref.get_base_handle() == self.source.get_handle(): if sref.get_base_handle() == self.source.get_handle():
p_addr_list.append((name,v.get_street())) p_addr_list.append((name,v.get_street()))
for object_handle in self.db.get_media_object_handles(): for object_handle in self.db.get_media_object_handles():
object = self.db.get_object_from_handle(object_handle) obj = self.db.get_object_from_handle(object_handle)
name = object.get_description() name = obj.get_description()
for sref in object.get_source_references(): for sref in obj.get_source_references():
if sref.get_base_handle() == self.source.get_handle(): if sref.get_base_handle() == self.source.get_handle():
m_list.append(name) m_list.append(name)
for family_handle in self.db.get_family_handles(): for family_handle in self.db.get_family_handles():
@ -356,16 +356,16 @@ class DelSrcQuery:
self.db = db self.db = db
self.update = update self.update = update
def delete_source(self,object): def delete_source(self,obj):
m = 0 m = 0
l = [] l = []
for sref in object.get_source_references(): for sref in obj.get_source_references():
if sref.get_base_handle() != self.source.get_handle(): if sref.get_base_handle() != self.source.get_handle():
l.append(sref) l.append(sref)
else: else:
m = 1 m = 1
if m: if m:
object.set_source_reference_list(l) obj.set_source_reference_list(l)
return m return m
def query_response(self): def query_response(self):

View File

@ -392,9 +392,9 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
if not self.init: if not self.init:
self.init = 1 self.init = 1
filter = MatchesFilter(self.list) filt = MatchesFilter(self.list)
for person_handle in db.get_person_handles(sort_handles=False): for person_handle in db.get_person_handles(sort_handles=False):
if filter.apply (db, person_handle): if filt.apply (db, person_handle):
self.init_list (person_handle, first) self.init_list (person_handle, first)
return self.map.has_key(p_id) return self.map.has_key(p_id)
@ -523,9 +523,9 @@ class IsChildOfFilterMatch(Rule):
if not self.init: if not self.init:
self.init = 1 self.init = 1
filter = MatchesFilter(self.list) filt = MatchesFilter(self.list)
for person_handle in db.get_person_handles(sort_handles=False): for person_handle in db.get_person_handles(sort_handles=False):
if filter.apply (db, person_handle): if filt.apply (db, person_handle):
self.init_list (person_handle) self.init_list (person_handle)
return self.map.has_key(p_id) return self.map.has_key(p_id)
@ -681,9 +681,9 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
if not self.init: if not self.init:
self.init = 1 self.init = 1
filter = MatchesFilter(self.list[0]) filt = MatchesFilter(self.list[0])
for person_handle in db.get_person_handles(sort_handles=False): for person_handle in db.get_person_handles(sort_handles=False):
if filter.apply (db, person_handle): if filt.apply (db, person_handle):
self.init_ancestor_list (person_handle,first) self.init_ancestor_list (person_handle,first)
return self.map.has_key(p_id) return self.map.has_key(p_id)
@ -826,9 +826,9 @@ class IsParentOfFilterMatch(Rule):
if not self.init: if not self.init:
self.init = 1 self.init = 1
filter = MatchesFilter(self.list) filt = MatchesFilter(self.list)
for person_handle in db.get_person_handles(sort_handles=False): for person_handle in db.get_person_handles(sort_handles=False):
if filter.apply (db, person_handle): if filt.apply (db, person_handle):
self.init_list (person_handle) self.init_list (person_handle)
return self.map.has_key(p_id) return self.map.has_key(p_id)
@ -910,11 +910,11 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith):
HasCommonAncestorWith.__init__(self,list) HasCommonAncestorWith.__init__(self,list)
def init_ancestor_cache(self,db): def init_ancestor_cache(self,db):
filter = MatchesFilter(self.list) filt = MatchesFilter(self.list)
def init(self,pid): self.ancestor_cache[pid] = 1 def init(self,pid): self.ancestor_cache[pid] = 1
for p_id in db.get_person_handles(sort_handles=False): for p_id in db.get_person_handles(sort_handles=False):
if (not self.ancestor_cache.has_key (p_id) if (not self.ancestor_cache.has_key (p_id)
and filter.apply (db, p_id)): and filt.apply (db, p_id)):
for_each_ancestor([p_id],init,self) for_each_ancestor([p_id],init,self)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -1327,12 +1327,12 @@ class MatchesFilter(Rule):
return 'Matches the filter named' return 'Matches the filter named'
def apply(self,db,p_id): def apply(self,db,p_id):
for filter in SystemFilters.get_filters(): for filt in SystemFilters.get_filters():
if filter.get_name() == self.list[0]: if filt.get_name() == self.list[0]:
return filter.check(p_id) return filt.check(p_id)
for filter in CustomFilters.get_filters(): for filt in CustomFilters.get_filters():
if filter.get_name() == self.list[0]: if filt.get_name() == self.list[0]:
return filter.check(db,p_id) return filt.check(db,p_id)
return 0 return 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -1356,7 +1356,7 @@ class IsSpouseOfFilterMatch(Rule):
return _('Family filters') return _('Family filters')
def apply(self,db,p_id): def apply(self,db,p_id):
filter = MatchesFilter (self.list) filt = MatchesFilter (self.list)
p = db.get_person_from_handle(p_id) p = db.get_person_from_handle(p_id)
for family_handle in p.get_family_handle_list (): for family_handle in p.get_family_handle_list ():
family = db.get_family_from_handle(family_handle) family = db.get_family_from_handle(family_handle)
@ -1365,7 +1365,7 @@ class IsSpouseOfFilterMatch(Rule):
continue continue
if spouse_id == p_id: if spouse_id == p_id:
continue continue
if filter.apply (db, spouse_id): if filt.apply (db, spouse_id):
return 1 return 1
return 0 return 0
@ -1553,8 +1553,8 @@ class GenericFilterList:
def get_filters(self): def get_filters(self):
return self.filter_list return self.filter_list
def add(self,filter): def add(self,filt):
self.filter_list.append(filter) self.filter_list.append(filt)
def load(self): def load(self):
try: try:
@ -1704,30 +1704,30 @@ def build_filter_menu(local_filters = [], default=""):
active = 0 active = 0
cnt = 0 cnt = 0
for filter in local_filters: for filt in local_filters:
menuitem = gtk.MenuItem(filter.get_name()) menuitem = gtk.MenuItem(filt.get_name())
menuitem.show() menuitem.show()
menu.append(menuitem) menu.append(menuitem)
menuitem.set_data("filter", filter) menuitem.set_data("filter", filt)
if default != "" and default == filter.get_name(): if default != "" and default == filt.get_name():
active = cnt active = cnt
cnt += 1 cnt += 1
for filter in SystemFilters.get_filters(): for filt in SystemFilters.get_filters():
menuitem = gtk.MenuItem(_(filter.get_name())) menuitem = gtk.MenuItem(_(filt.get_name()))
menuitem.show() menuitem.show()
menu.append(menuitem) menu.append(menuitem)
menuitem.set_data("filter", filter) menuitem.set_data("filter", filt)
if default != "" and default == filter.get_name(): if default != "" and default == filt.get_name():
active = cnt active = cnt
cnt += 1 cnt += 1
for filter in CustomFilters.get_filters(): for filt in CustomFilters.get_filters():
menuitem = gtk.MenuItem(_(filter.get_name())) menuitem = gtk.MenuItem(_(filt.get_name()))
menuitem.show() menuitem.show()
menu.append(menuitem) menu.append(menuitem)
menuitem.set_data("filter", filter) menuitem.set_data("filter", filt)
if default != "" and default == filter.get_name(): if default != "" and default == filt.get_name():
active = cnt active = cnt
cnt += 1 cnt += 1

View File

@ -693,11 +693,11 @@ class GrampsPreferences:
def build_tree(self): def build_tree(self):
prev = None prev = None
ilist = [] ilist = []
for (name,list) in panellist: for (name,lst) in panellist:
node = self.store.insert_after(None, prev) node = self.store.insert_after(None, prev)
self.store.set(node,0,name) self.store.set(node,0,name)
next = None next = None
for (subname,tab) in list: for (subname,tab) in lst:
next = self.store.insert_after(node,next) next = self.store.insert_after(node,next)
ilist.append((next,tab)) ilist.append((next,tab))
self.store.set(next,0,subname) self.store.set(next,0,subname)
@ -971,10 +971,10 @@ class GrampsPreferences:
col = col + 1 col = col + 1
def select(self,obj): def select(self,obj):
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if iter: if node:
path = store.get_path(iter) path = store.get_path(node)
if iter and self.imap.has_key(path): if node and self.imap.has_key(path):
self.panel.set_current_page(self.imap[path]) self.panel.set_current_page(self.imap[path])
def on_propertybox_help(self,obj): def on_propertybox_help(self,obj):

View File

@ -143,12 +143,12 @@ class ImageSelect:
self.temp_name = root self.temp_name = root
if os.path.isfile(filename): if os.path.isfile(filename):
type = GrampsMime.get_type(filename) mtype = GrampsMime.get_type(filename)
if type[0:5] == "image": if mtype[0:5] == "image":
image = RelImage.scale_image(filename,const.thumbScale) image = RelImage.scale_image(filename,const.thumbScale)
self.image.set_from_pixbuf(image) self.image.set_from_pixbuf(image)
else: else:
i = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(type)) i = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(mtype))
self.image.set_from_pixbuf(i) self.image.set_from_pixbuf(i)
def on_savephoto_clicked(self): def on_savephoto_clicked(self):
@ -184,12 +184,12 @@ class ImageSelect:
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
self.add_thumbnail(oref) self.add_thumbnail(oref)
else: else:
type = GrampsMime.get_type(filename) mtype = GrampsMime.get_type(filename)
mobj = RelLib.MediaObject() mobj = RelLib.MediaObject()
if description == "": if description == "":
description = os.path.basename(filename) description = os.path.basename(filename)
mobj.set_description(description) mobj.set_description(description)
mobj.set_mime_type(type) mobj.set_mime_type(mtype)
self.savephoto(mobj) self.savephoto(mobj)
mobj.set_path(filename) mobj.set_path(filename)
self.db.commit_media_object(mobj,trans) self.db.commit_media_object(mobj,trans)
@ -268,9 +268,8 @@ class Gallery(ImageSelect):
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
if const.dnd_images: if const.dnd_images:
id = self.sel_obj.get_reference_handle() handle = self.sel_obj.get_reference_handle()
obj = self.db.get_object_from_handle(id) obj = self.db.get_object_from_handle(handle)
mtype = obj.get_mime_type()
name = Utils.thumb_path(self.db.get_save_path(),obj) name = Utils.thumb_path(self.db.get_save_path(),obj)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
context.set_icon_pixbuf(pix,0,0) context.set_icon_pixbuf(pix,0,0)
@ -363,7 +362,7 @@ class Gallery(ImageSelect):
def add_thumbnail(self, photo): def add_thumbnail(self, photo):
"""Scale the image and add it to the IconList.""" """Scale the image and add it to the IconList."""
oid = photo.get_reference_handle() oid = photo.get_reference_handle()
object = self.db.get_object_from_handle(oid) obj = self.db.get_object_from_handle(oid)
if self.canvas_list.has_key(oid): if self.canvas_list.has_key(oid):
(grp,item,text,x,y) = self.canvas_list[oid] (grp,item,text,x,y) = self.canvas_list[oid]
if x != self.cx or y != self.cy: if x != self.cx or y != self.cy:
@ -371,9 +370,9 @@ class Gallery(ImageSelect):
else: else:
import gobject import gobject
name = Utils.thumb_path(self.db.get_save_path(),object) name = Utils.thumb_path(self.db.get_save_path(),obj)
description = object.get_description() description = obj.get_description()
if len(description) > 20: if len(description) > 20:
description = "%s..." % description[0:20] description = "%s..." % description[0:20]
@ -461,9 +460,9 @@ class Gallery(ImageSelect):
if data and data.format == 8: if data and data.format == 8:
icon_index = self.get_index(w,x,y) icon_index = self.get_index(w,x,y)
d = string.strip(string.replace(data.data,'\0',' ')) d = string.strip(string.replace(data.data,'\0',' '))
protocol,site,file, j,k,l = urlparse.urlparse(d) protocol,site,mfile,j,k,l = urlparse.urlparse(d)
if protocol == "file": if protocol == "file":
name = file name = mfile
mime = GrampsMime.get_type(name) mime = GrampsMime.get_type(name)
photo = RelLib.MediaObject() photo = RelLib.MediaObject()
photo.set_path(name) photo.set_path(name)
@ -498,8 +497,8 @@ class Gallery(ImageSelect):
oref.set_reference_handle(photo.get_handle()) oref.set_reference_handle(photo.get_handle())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
try: try:
id = photo.get_handle() handle = photo.get_handle()
name = RelImage.import_media_object(tfile,self.path,id) name = RelImage.import_media_object(tfile,self.path,handle)
photo.set_path(name) photo.set_path(name)
except: except:
photo.set_path(tfile) photo.set_path(tfile)
@ -542,8 +541,8 @@ class Gallery(ImageSelect):
def on_photolist_drag_data_get(self,w, context, selection_data, info, time): def on_photolist_drag_data_get(self,w, context, selection_data, info, time):
if info == 1: if info == 1:
return return
id = self.p_map[self.drag_item] data = self.p_map[self.drag_item]
selection_data.set(selection_data.target, 8, id[4]) selection_data.set(selection_data.target, 8, data[4])
self.drag_item = None self.drag_item = None
def on_add_media_clicked(self, obj): def on_add_media_clicked(self, obj):
@ -556,11 +555,11 @@ class Gallery(ImageSelect):
Create a dialog to find out which object they want.""" Create a dialog to find out which object they want."""
s_o = SelectObject.SelectObject(self.db,_("Select an Object")) s_o = SelectObject.SelectObject(self.db,_("Select an Object"))
object = s_o.run() obj = s_o.run()
if not object: if not obj:
return return
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_handle(object.get_handle()) oref.set_reference_handle(obj.get_handle())
self.dataobj.add_media_reference(oref) self.dataobj.add_media_reference(oref)
self.add_thumbnail(oref) self.add_thumbnail(oref)
@ -598,8 +597,8 @@ class Gallery(ImageSelect):
menu = gtk.Menu() menu = gtk.Menu()
menu.set_title(_("Media Object")) menu.set_title(_("Media Object"))
object = self.db.get_object_from_handle(photo.get_reference_handle()) obj = self.db.get_object_from_handle(photo.get_reference_handle())
mtype = object.get_mime_type() mtype = obj.get_mime_type()
progname = GrampsMime.get_application(mtype) progname = GrampsMime.get_application(mtype)
if progname and len(progname) > 1: if progname and len(progname) > 1:
@ -628,10 +627,10 @@ class Gallery(ImageSelect):
"""Copy this picture into gramps private database instead of """Copy this picture into gramps private database instead of
leaving it as an external data object.""" leaving it as an external data object."""
photo = obj.get_data('o') photo = obj.get_data('o')
object = self.db.get_object_from_handle(photo.get_reference_handle()) obj = self.db.get_object_from_handle(photo.get_reference_handle())
name = RelImage.import_media_object(object.get_path(),self.path, name = RelImage.import_media_object(obj.get_path(),self.path,
object.get_handle()) obj.get_handle())
object.set_path(name) obj.set_path(name)
def popup_change_description(self, obj): def popup_change_description(self, obj):
"""Bring up a window allowing the user to edit the description """Bring up a window allowing the user to edit the description
@ -659,11 +658,11 @@ class LocalMediaProperties:
self.child_windows = {} self.child_windows = {}
self.photo = photo self.photo = photo
self.db = parent.db self.db = parent.db
self.object = self.db.get_object_from_handle(photo.get_reference_handle()) self.obj = self.db.get_object_from_handle(photo.get_reference_handle())
self.alist = photo.get_attribute_list()[:] self.alist = photo.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
fname = self.object.get_path() fname = self.obj.get_path()
self.change_dialog = gtk.glade.XML(const.imageselFile,"change_description","gramps") self.change_dialog = gtk.glade.XML(const.imageselFile,"change_description","gramps")
title = _('Media Reference Editor') title = _('Media Reference Editor')
@ -691,7 +690,7 @@ class LocalMediaProperties:
self.slist = self.change_dialog.get_widget("src_list") self.slist = self.change_dialog.get_widget("src_list")
self.sources_label = self.change_dialog.get_widget("source_label") self.sources_label = self.change_dialog.get_widget("source_label")
if self.object: if self.obj:
self.srcreflist = [RelLib.SourceRef(ref) for ref in self.photo.get_source_references()] self.srcreflist = [RelLib.SourceRef(ref) for ref in self.photo.get_source_references()]
else: else:
self.srcreflist = [] self.srcreflist = []
@ -703,16 +702,16 @@ class LocalMediaProperties:
self.change_dialog.get_widget('edit_src'), self.change_dialog.get_widget('edit_src'),
self.change_dialog.get_widget('del_src')) self.change_dialog.get_widget('del_src'))
descr_window.set_text(self.object.get_description()) descr_window.set_text(self.obj.get_description())
mtype = self.object.get_mime_type() mtype = self.obj.get_mime_type()
thumb = Utils.thumb_path(path,self.object) thumb = Utils.thumb_path(path,self.obj)
if os.path.isfile(thumb): if os.path.isfile(thumb):
self.pix = gtk.gdk.pixbuf_new_from_file(thumb) self.pix = gtk.gdk.pixbuf_new_from_file(thumb)
self.pixmap.set_from_pixbuf(self.pix) self.pixmap.set_from_pixbuf(self.pix)
self.change_dialog.get_widget("private").set_active(photo.get_privacy()) self.change_dialog.get_widget("private").set_active(photo.get_privacy())
self.change_dialog.get_widget("gid").set_text(self.object.get_handle()) self.change_dialog.get_widget("gid").set_text(self.obj.get_handle())
self.change_dialog.get_widget("path").set_text(fname) self.change_dialog.get_widget("path").set_text(fname)
@ -784,8 +783,8 @@ class LocalMediaProperties:
self.amap = {} self.amap = {}
for attr in self.alist: for attr in self.alist:
d = [attr.get_type(),attr.get_value()] d = [attr.get_type(),attr.get_value()]
iter = self.atree.add(d,attr) node = self.atree.add(d,attr)
self.amap[str(attr)] = iter self.amap[str(attr)] = node
if self.alist: if self.alist:
Utils.bold_label(self.attr_label) Utils.bold_label(self.attr_label)
else: else:
@ -820,7 +819,7 @@ class LocalMediaProperties:
self.parent.parent.lists_changed = 1 self.parent.parent.lists_changed = 1
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.commit_media_object(self.object,trans) self.db.commit_media_object(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Media Object")) self.db.transaction_commit(trans,_("Edit Media Object"))
def on_help_clicked(self, obj): def on_help_clicked(self, obj):
@ -832,9 +831,9 @@ class LocalMediaProperties:
self.close(obj) self.close(obj)
def on_attr_list_select_row(self,obj): def on_attr_list_select_row(self,obj):
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
self.attr_type.set_label(attr.get_type()) self.attr_type.set_label(attr.get_type())
self.attr_value.set_text(attr.get_value()) self.attr_value.set_text(attr.get_value())
@ -849,9 +848,9 @@ class LocalMediaProperties:
def on_update_attr_clicked(self,obj): def on_update_attr_clicked(self,obj):
import AttrEdit import AttrEdit
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
AttrEdit.AttributeEditor(self,attr,"Media Object", AttrEdit.AttributeEditor(self,attr,"Media Object",
Plugins.get_image_attributes(), Plugins.get_image_attributes(),
self.attr_callback) self.attr_callback)
@ -874,19 +873,19 @@ class LocalMediaProperties:
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class GlobalMediaProperties: class GlobalMediaProperties:
def __init__(self,db,object,update,parent,parent_window=None): def __init__(self,db,obj,update,parent,parent_window=None):
self.parent = parent self.parent = parent
if object: if obj:
if self.parent.parent.child_windows.has_key(object.get_handle()): if self.parent.parent.child_windows.has_key(obj.get_handle()):
self.parent.parent.child_windows[object.get_handle()].present(None) self.parent.parent.child_windows[obj.get_handle()].present(None)
return return
else: else:
self.win_key = object.get_handle() self.win_key = obj.get_handle()
else: else:
self.win_key = self self.win_key = self
self.child_windows = {} self.child_windows = {}
self.object = object self.obj = obj
self.alist = self.object.get_attribute_list()[:] self.alist = self.obj.get_attribute_list()[:]
self.lists_changed = 0 self.lists_changed = 0
self.db = db self.db = db
self.update = update self.update = update
@ -924,8 +923,8 @@ class GlobalMediaProperties:
self.slist = self.change_dialog.get_widget("src_list") self.slist = self.change_dialog.get_widget("src_list")
self.sources_label = self.change_dialog.get_widget("sourcesGlobal") self.sources_label = self.change_dialog.get_widget("sourcesGlobal")
if self.object: if self.obj:
self.srcreflist = [RelLib.SourceRef(ref) for ref in self.object.get_source_references()] self.srcreflist = [RelLib.SourceRef(ref) for ref in self.obj.get_source_references()]
else: else:
self.srcreflist = [] self.srcreflist = []
@ -936,21 +935,21 @@ class GlobalMediaProperties:
self.change_dialog.get_widget('gl_edit_src'), self.change_dialog.get_widget('gl_edit_src'),
self.change_dialog.get_widget('gl_del_src')) self.change_dialog.get_widget('gl_del_src'))
self.descr_window.set_text(self.object.get_description()) self.descr_window.set_text(self.obj.get_description())
mtype = self.object.get_mime_type() mtype = self.obj.get_mime_type()
pb = gtk.gdk.pixbuf_new_from_file(Utils.thumb_path(self.path,self.object)) pb = gtk.gdk.pixbuf_new_from_file(Utils.thumb_path(self.path,self.obj))
self.pixmap.set_from_pixbuf(pb) self.pixmap.set_from_pixbuf(pb)
self.change_dialog.get_widget("gid").set_text(self.object.get_handle()) self.change_dialog.get_widget("gid").set_text(self.obj.get_handle())
self.makelocal = self.change_dialog.get_widget("makelocal") self.makelocal = self.change_dialog.get_widget("makelocal")
self.update_info() self.update_info()
self.change_dialog.get_widget("type").set_text(Utils.get_mime_description(mtype)) self.change_dialog.get_widget("type").set_text(Utils.get_mime_description(mtype))
if self.object.get_note(): if self.obj.get_note():
self.notes.get_buffer().set_text(self.object.get_note()) self.notes.get_buffer().set_text(self.obj.get_note())
Utils.bold_label(self.notes_label) Utils.bold_label(self.notes_label)
if self.object.get_note_format() == 1: if self.obj.get_note_format() == 1:
self.preform.set_active(1) self.preform.set_active(1)
else: else:
self.flowed.set_active(1) self.flowed.set_active(1)
@ -1013,21 +1012,21 @@ class GlobalMediaProperties:
self.window.present() self.window.present()
def on_up_clicked(self,obj): def on_up_clicked(self,obj):
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
row = self.atree.get_row(iter) row = self.atree.get_row(node)
if row != 0: if row != 0:
self.atree.select_row(row-1) self.atree.select_row(row-1)
def on_down_clicked(self,obj): def on_down_clicked(self,obj):
model,iter = self.atree.get_selected() model,node = self.atree.get_selected()
if not iter: if not node:
return return
row = self.atree.get_row(iter) row = self.atree.get_row(node)
self.atree.select_row(row+1) self.atree.select_row(row+1)
def update_info(self): def update_info(self):
fname = self.object.get_path() fname = self.obj.get_path()
self.change_dialog.get_widget("path").set_text(fname) self.change_dialog.get_widget("path").set_text(fname)
def redraw_attr_list(self): def redraw_attr_list(self):
@ -1035,16 +1034,16 @@ class GlobalMediaProperties:
self.amap = {} self.amap = {}
for attr in self.alist: for attr in self.alist:
d = [attr.get_type(),attr.get_value()] d = [attr.get_type(),attr.get_value()]
iter = self.atree.add(d,attr) node = self.atree.add(d,attr)
self.amap[str(attr)] = iter self.amap[str(attr)] = node
if self.alist: if self.alist:
Utils.bold_label(self.attr_label) Utils.bold_label(self.attr_label)
else: else:
Utils.unbold_label(self.attr_label) Utils.unbold_label(self.attr_label)
def button_press(self,obj): def button_press(self,obj):
store,iter = self.refmodel.selection.get_selected() store,node = self.refmodel.selection.get_selected()
if not iter: if not node:
return return
def display_refs(self): def display_refs(self):
@ -1059,25 +1058,25 @@ class GlobalMediaProperties:
for key in self.db.get_person_handles(sort_handles=False): for key in self.db.get_person_handles(sort_handles=False):
p = self.db.get_person_from_handle(key) p = self.db.get_person_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == self.object.get_handle(): if o.get_reference_handle() == self.obj.get_handle():
self.refmodel.add([_("Person"),p.get_handle(),GrampsCfg.get_nameof()(p)]) self.refmodel.add([_("Person"),p.get_handle(),GrampsCfg.get_nameof()(p)])
any = 1 any = 1
for key in self.db.get_family_handles(): for key in self.db.get_family_handles():
p = self.db.get_family_from_handle(key) p = self.db.get_family_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == self.object.get_handle(): if o.get_reference_handle() == self.obj.get_handle():
self.refmodel.add([_("Family"),p.get_handle(),Utils.family_name(p,self.db)]) self.refmodel.add([_("Family"),p.get_handle(),Utils.family_name(p,self.db)])
any = 1 any = 1
for key in self.db.get_source_handles(): for key in self.db.get_source_handles():
p = self.db.get_source_from_handle(key) p = self.db.get_source_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == self.object.get_handle(): if o.get_reference_handle() == self.obj.get_handle():
self.refmodel.add([_("Source"),p.get_handle(),p.get_title()]) self.refmodel.add([_("Source"),p.get_handle(),p.get_title()])
any = 1 any = 1
for key in self.db.get_place_handles(): for key in self.db.get_place_handles():
p = self.db.get_place_from_handle(key) p = self.db.get_place_from_handle(key)
for o in p.get_media_list(): for o in p.get_media_list():
if o.get_reference_handle() == self.object.get_handle(): if o.get_reference_handle() == self.obj.get_handle():
self.refmodel.add([_("Place"),p.get_handle(),p.get_title()]) self.refmodel.add([_("Place"),p.get_handle(),p.get_title()])
any = 1 any = 1
if any: if any:
@ -1099,20 +1098,20 @@ class GlobalMediaProperties:
t = self.notes.get_buffer() t = self.notes.get_buffer()
text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),gtk.FALSE)) text = unicode(t.get_text(t.get_start_iter(),t.get_end_iter(),gtk.FALSE))
desc = unicode(self.descr_window.get_text()) desc = unicode(self.descr_window.get_text())
note = self.object.get_note() note = self.obj.get_note()
format = self.preform.get_active() format = self.preform.get_active()
if text != note or desc != self.object.get_description(): if text != note or desc != self.obj.get_description():
self.object.set_note(text) self.obj.set_note(text)
self.object.set_description(desc) self.obj.set_description(desc)
if format != self.object.get_note_format(): if format != self.obj.get_note_format():
self.object.set_note_format(format) self.obj.set_note_format(format)
if self.lists_changed: if self.lists_changed:
self.object.set_attribute_list(self.alist) self.obj.set_attribute_list(self.alist)
self.object.set_source_reference_list(self.srcreflist) self.obj.set_source_reference_list(self.srcreflist)
if self.update != None: if self.update != None:
self.update() self.update()
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
self.db.commit_media_object(self.object,trans) self.db.commit_media_object(self.obj,trans)
self.db.transaction_commit(trans,_("Edit Media Object")) self.db.transaction_commit(trans,_("Edit Media Object"))
def on_help_clicked(self, obj): def on_help_clicked(self, obj):
@ -1124,9 +1123,9 @@ class GlobalMediaProperties:
self.close(obj) self.close(obj)
def on_attr_list_select_row(self,obj): def on_attr_list_select_row(self,obj):
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
self.attr_type.set_label(attr.get_type()) self.attr_type.set_label(attr.get_type())
self.attr_value.set_text(attr.get_value()) self.attr_value.set_text(attr.get_value())
@ -1141,9 +1140,9 @@ class GlobalMediaProperties:
def on_update_attr_clicked(self,obj): def on_update_attr_clicked(self,obj):
import AttrEdit import AttrEdit
store,iter = self.atree.get_selected() store,node = self.atree.get_selected()
if iter: if node:
attr = self.atree.get_object(iter) attr = self.atree.get_object(node)
AttrEdit.AttributeEditor(self,attr,"Media Object", AttrEdit.AttributeEditor(self,attr,"Media Object",
Plugins.get_image_attributes(), Plugins.get_image_attributes(),
self.attr_callback) self.attr_callback)

View File

@ -128,9 +128,9 @@ class ListModel:
return path[0][0]-1 return path[0][0]-1
def get_selected_row(self): def get_selected_row(self):
store, iter = self.selection.get_selected() store, node = self.selection.get_selected()
if iter: if node:
rows = store.get_path(iter) rows = store.get_path(node)
return rows[0] return rows[0]
else: else:
return -1 return -1
@ -139,9 +139,9 @@ class ListModel:
if self.count == 0: if self.count == 0:
return [] return []
elif self.mode == gtk.SELECTION_SINGLE: elif self.mode == gtk.SELECTION_SINGLE:
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if iter: if node:
return [self.model.get_value(iter,self.data_index)] return [self.model.get_value(node,self.data_index)]
else: else:
return [] return []
else: else:
@ -151,98 +151,98 @@ class ListModel:
def get_icon(self): def get_icon(self):
if self.mode == gtk.SELECTION_SINGLE: if self.mode == gtk.SELECTION_SINGLE:
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
path = self.model.get_path(iter) path = self.model.get_path(node)
else: else:
mlist = [] mlist = []
self.selection.selected_foreach(self.blist,mlist) self.selection.selected_foreach(self.blist,mlist)
path = self.model.get_path(mlist[0]) path = self.model.get_path(mlist[0])
return self.tree.create_row_drag_icon(path) return self.tree.create_row_drag_icon(path)
def blist(self,store,path,iter,list): def blist(self,store,path,node,list):
list.append(self.model.get_value(iter,self.data_index)) list.append(self.model.get_value(node,self.data_index))
def clear(self): def clear(self):
self.count = 0 self.count = 0
self.model.clear() self.model.clear()
def remove(self,iter): def remove(self,node):
self.model.remove(iter) self.model.remove(node)
self.count = self.count - 1 self.count = self.count - 1
def get_row(self,iter): def get_row(self,node):
row = self.model.get_path(iter) row = self.model.get_path(node)
return row[0] return row[0]
def select_row(self,row): def select_row(self,row):
self.selection.select_path((row)) self.selection.select_path((row))
def select_iter(self,iter): def select_iter(self,node):
self.selection.select_iter(iter) self.selection.select_iter(node)
def get_object(self,iter): def get_object(self,node):
return self.model.get_value(iter,self.data_index) return self.model.get_value(node,self.data_index)
def insert(self,position,data,info=None,select=0): def insert(self,position,data,info=None,select=0):
self.count = self.count + 1 self.count = self.count + 1
iter = self.model.insert(position) node = self.model.insert(position)
col = 0 col = 0
for object in data: for obj in data:
self.model.set_value(iter,col,object) self.model.set_value(node,col,obj)
col = col + 1 col = col + 1
self.model.set_value(iter,col,info) self.model.set_value(node,col,info)
if info: if info:
self.idmap[str(info)] = iter self.idmap[str(info)] = node
if select: if select:
self.selection.select_iter(iter) self.selection.select_iter(node)
return iter return node
def get_data(self,iter,cols): def get_data(self,node,cols):
return [ self.model.get_value(iter,c) for c in cols ] return [ self.model.get_value(node,c) for c in cols ]
def add(self,data,info=None,select=0): def add(self,data,info=None,select=0):
self.count = self.count + 1 self.count = self.count + 1
iter = self.model.append() node = self.model.append()
col = 0 col = 0
for object in data: for obj in data:
self.model.set_value(iter,col,object) self.model.set_value(node,col,obj)
col = col + 1 col = col + 1
self.model.set_value(iter,col,info) self.model.set_value(node,col,info)
if info: if info:
self.idmap[str(info)] = iter self.idmap[str(info)] = node
if select: if select:
self.sel_iter = iter self.sel_iter = node
self.selection.select_iter(self.sel_iter) self.selection.select_iter(self.sel_iter)
return iter return node
def set(self,iter,data,info=None,select=0): def set(self,node,data,info=None,select=0):
col = 0 col = 0
for object in data: for obj in data:
self.model.set_value(iter,col,object) self.model.set_value(node,col,obj)
col = col + 1 col = col + 1
self.model.set_value(iter,col,info) self.model.set_value(node,col,info)
if info: if info:
self.idmap[str(info)] = iter self.idmap[str(info)] = node
if select: if select:
self.sel_iter = iter self.sel_iter = node
return iter return node
def add_and_select(self,data,info=None): def add_and_select(self,data,info=None):
self.count = self.count + 1 self.count = self.count + 1
iter = self.model.append() node = self.model.append()
col = 0 col = 0
for object in data: for obj in data:
self.model.set_value(iter,col,object) self.model.set_value(node,col,obj)
col = col + 1 col = col + 1
if info: if info:
self.idmap[str(info)] = iter self.idmap[str(info)] = node
self.model.set_value(iter,col,info) self.model.set_value(node,col,info)
self.selection.select_iter(iter) self.selection.select_iter(node)
def center_selected(self): def center_selected(self):
model,iter = self.selection.get_selected() model,node = self.selection.get_selected()
if iter: if node:
path = model.get_path(iter) path = model.get_path(node)
self.tree.scroll_to_cell(path,None,gtk.TRUE,0.5,0.5) self.tree.scroll_to_cell(path,None,gtk.TRUE,0.5,0.5)
def button_press(self,obj,event): def button_press(self,obj,event):
@ -253,8 +253,8 @@ class ListModel:
def find(self,info): def find(self,info):
if info in self.idmap.keys(): if info in self.idmap.keys():
iter = self.idmap[str(info)] node = self.idmap[str(info)]
self.selection.select_iter(iter) self.selection.select_iter(node)
def cleanup(self): def cleanup(self):
pass pass

View File

@ -33,7 +33,6 @@ import os
# GTK/Gnome modules # GTK/Gnome modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gobject
import gtk import gtk
import gtk.gdk import gtk.gdk
@ -48,7 +47,6 @@ import GrampsCfg
import const import const
import ImageSelect import ImageSelect
import RelImage import RelImage
import ColumnOrder
import DisplayModels import DisplayModels
import GrampsMime import GrampsMime
@ -160,22 +158,22 @@ class MediaView:
def on_select_row(self,obj): def on_select_row(self,obj):
fexists = 1 fexists = 1
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if not iter: if not node:
return return
id = store.get_value(iter,1) handle = store.get_value(node,1)
mobj = self.db.get_object_from_handle(id) mobj = self.db.get_object_from_handle(handle)
type = mobj.get_mime_type() mtype = mobj.get_mime_type()
type_name = Utils.get_mime_description(type) type_name = Utils.get_mime_description(mtype)
path = mobj.get_path() path = mobj.get_path()
thumb_path = Utils.thumb_path(self.db.get_save_path(),mobj) thumb_path = Utils.thumb_path(self.db.get_save_path(),mobj)
pexists = os.path.exists(path) pexists = os.path.exists(path)
if pexists and os.path.exists(thumb_path): if pexists and os.path.exists(thumb_path):
self.preview.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(thumb_path)) self.preview.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(thumb_path))
else: else:
icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(type)) icon_image = gtk.gdk.pixbuf_new_from_file(Utils.find_icon(mtype))
self.preview.set_from_pixbuf(icon_image) self.preview.set_from_pixbuf(icon_image)
if not pexists: if not pexists:
fexists = 0 fexists = 0
@ -211,12 +209,12 @@ class MediaView:
menu = gtk.Menu() menu = gtk.Menu()
menu.set_title(_("Media Object")) menu.set_title(_("Media Object"))
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if iter: if node:
id = store.get_value(iter,1) handle = store.get_value(node,1)
object = self.db.get_object_from_handle(id) obj = self.db.get_object_from_handle(handle)
self.obj = object self.obj = obj
mime_type = object.get_mime_type() mime_type = obj.get_mime_type()
Utils.add_menuitem(menu,_("View in the default viewer"),None, Utils.add_menuitem(menu,_("View in the default viewer"),None,
self.popup_view_photo) self.popup_view_photo)
@ -255,8 +253,8 @@ class MediaView:
def popup_convert_to_private(self, obj): def popup_convert_to_private(self, obj):
path = self.db.get_save_path() path = self.db.get_save_path()
id = self.obj.get_handle() handle = self.obj.get_handle()
name = RelImage.import_media_object(self.obj.get_path(),path,id) name = RelImage.import_media_object(self.obj.get_path(),path,handle)
if name: if name:
self.obj.set_path(name) self.obj.set_path(name)
self.load_media() self.load_media()
@ -277,20 +275,20 @@ class MediaView:
def on_edit_clicked(self,obj): def on_edit_clicked(self,obj):
"""Edit the properties of an existing media object in the media list""" """Edit the properties of an existing media object in the media list"""
list_store, iter = self.selection.get_selected() list_store, node = self.selection.get_selected()
if iter: if node:
id = list_store.get_value(iter,1) handle = list_store.get_value(node,1)
object = self.db.get_object_from_handle(id) obj = self.db.get_object_from_handle(handle)
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media, ImageSelect.GlobalMediaProperties(self.db,obj,self.load_media,
self,self.topWindow) self,self.topWindow)
def on_delete_clicked(self,obj): def on_delete_clicked(self,obj):
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if not iter: if not node:
return return
id = store.get_value(iter,1) handle = store.get_value(node,1)
mobj = self.db.get_object_from_handle(id) mobj = self.db.get_object_from_handle(handle)
if self.is_object_used(mobj): if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree) ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree)
QuestionDialog(_('Delete Media Object?'), QuestionDialog(_('Delete Media Object?'),
@ -330,13 +328,12 @@ class MediaView:
return 0 return 0
def on_drag_begin(self,obj,context): def on_drag_begin(self,obj,context):
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if not iter: if not node:
return return
if (const.dnd_images): if (const.dnd_images):
object = self.db.get_object_from_handle(store.get_value(iter,1)) obj = self.db.get_object_from_handle(store.get_value(node,1))
mtype = object.get_mime_type() name = Utils.thumb_path(self.db.get_save_path(),obj)
name = Utils.thumb_path(self.db.get_save_path(),object)
pix = gtk.gdk.pixbuf_new_from_file(name) pix = gtk.gdk.pixbuf_new_from_file(name)
context.set_icon_pixbuf(pix,0,0) context.set_icon_pixbuf(pix,0,0)
@ -344,20 +341,19 @@ class MediaView:
if info == 1: if info == 1:
return return
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if not iter: if not node:
return return
id = store.get_value(iter,1) handle = store.get_value(node,1)
selection_data.set(selection_data.target, 8, id) selection_data.set(selection_data.target, 8, handle)
def on_drag_data_received(self,w, context, x, y, data, info, time): def on_drag_data_received(self,w, context, x, y, data, info, time):
print "on_drag_data_received" print "on_drag_data_received"
import urlparse import urlparse
if data and data.format == 8: if data and data.format == 8:
d = string.strip(string.replace(data.data,'\0',' ')) d = string.strip(string.replace(data.data,'\0',' '))
protocol,site,file, j,k,l = urlparse.urlparse(d) protocol,site,name, j,k,l = urlparse.urlparse(d)
if protocol == "file": if protocol == "file":
name = file
mime = GrampsMime.get_type(name) mime = GrampsMime.get_type(name)
photo = RelLib.MediaObject() photo = RelLib.MediaObject()
photo.set_path(name) photo.set_path(name)
@ -398,9 +394,9 @@ class MediaView:
oref = RelLib.MediaRef() oref = RelLib.MediaRef()
oref.set_reference_handle(photo.get_handle()) oref.set_reference_handle(photo.get_handle())
try: try:
id = photo.get_handle() handle = photo.get_handle()
path = self.db.get_save_path() path = self.db.get_save_path()
name = RelImage.import_media_object(tfile,path,id) name = RelImage.import_media_object(tfile,path,handle)
if name: if name:
photo.set_path(name) photo.set_path(name)
except: except:

View File

@ -231,9 +231,9 @@ class MergePeople:
one.add_source_reference(xsrc) one.add_source_reference(xsrc)
def on_merge_clicked(self,obj): def on_merge_clicked(self,obj):
list = self.p1.get_alternate_names()[:] lst = self.p1.get_alternate_names()[:]
for xdata in self.p2.get_alternate_names(): for xdata in self.p2.get_alternate_names():
for data in list: for data in lst:
if data.are_equal(xdata): if data.are_equal(xdata):
self.copy_note(xdata,data) self.copy_note(xdata,data)
self.copy_sources(xdata,data) self.copy_sources(xdata,data)
@ -241,9 +241,9 @@ class MergePeople:
else: else:
self.p1.add_alternate_name(xdata) self.p1.add_alternate_name(xdata)
list = self.p1.get_attribute_list()[:] lst = self.p1.get_attribute_list()[:]
for xdata in self.p2.get_attribute_list(): for xdata in self.p2.get_attribute_list():
for data in list: for data in lst:
if data.get_type() == xdata.get_type() and \ if data.get_type() == xdata.get_type() and \
data.getValue() == xdata.get_value(): data.getValue() == xdata.get_value():
self.copy_note(xdata,data) self.copy_note(xdata,data)
@ -252,9 +252,9 @@ class MergePeople:
else: else:
self.p1.add_attribute(xdata) self.p1.add_attribute(xdata)
list = self.p1.get_event_list()[:] lst = self.p1.get_event_list()[:]
for xdata in self.p2.get_event_list(): for xdata in self.p2.get_event_list():
for data in list: for data in lst:
if data.are_equal(xdata): if data.are_equal(xdata):
self.copy_note(xdata,data) self.copy_note(xdata,data)
self.copy_sources(xdata,data) self.copy_sources(xdata,data)
@ -262,9 +262,9 @@ class MergePeople:
else: else:
self.p1.add_event(xdata) self.p1.add_event(xdata)
list = self.p1.get_url_list()[:] lst = self.p1.get_url_list()[:]
for xdata in self.p2.get_url_list(): for xdata in self.p2.get_url_list():
for data in list: for data in lst:
if data.are_equal(xdata): if data.are_equal(xdata):
break break
else: else:
@ -785,14 +785,14 @@ def is_initial(name):
# #
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
def ancestors_of(p1,list): def ancestors_of(p1,lst):
if p1 == None: if p1 == None:
return return
list.append(p1) lst.append(p1)
f1 = p1.get_main_parents_family_handle() f1 = p1.get_main_parents_family_handle()
if f1 != None: if f1 != None:
ancestors_of(f1.get_father_handle(),list) ancestors_of(f1.get_father_handle(),lst)
ancestors_of(f1.get_mother_handle(),list) ancestors_of(f1.get_mother_handle(),lst)
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
@ -875,14 +875,14 @@ class MergePlaces:
self.p1.set_note("%s\n\n%s" % (self.p1.get_note(),note)) self.p1.set_note("%s\n\n%s" % (self.p1.get_note(),note))
if t2active: if t2active:
list = [self.p1.get_main_location()] + self.p1.get_alternate_locations() lst = [self.p1.get_main_location()] + self.p1.get_alternate_locations()
self.p1.set_main_location(self.p2.get_main_location()) self.p1.set_main_location(self.p2.get_main_location())
for l in list: for l in lst:
if not l.is_empty(): if not l.is_empty():
self.p1.add_alternate_locations(l) self.p1.add_alternate_locations(l)
else: else:
list = [self.p2.get_main_location()] + self.p2.get_alternate_locations() lst = [self.p2.get_main_location()] + self.p2.get_alternate_locations()
for l in list: for l in lst:
if not l.is_empty(): if not l.is_empty():
self.p1.add_alternate_locations(l) self.p1.add_alternate_locations(l)

View File

@ -209,15 +209,15 @@ class PedigreeView:
style = self.canvas.get_style() style = self.canvas.get_style()
font = gtk.gdk.font_from_description(style.font_desc) font = gtk.gdk.font_from_description(style.font_desc)
list = [None]*31 lst = [None]*31
self.find_tree(self.active_person,0,1,list) self.find_tree(self.active_person,0,1,lst)
# determine the largest string width and height for calcuation # determine the largest string width and height for calcuation
# of box sizes. # of box sizes.
a = pango.Layout(self.canvas.get_pango_context()) a = pango.Layout(self.canvas.get_pango_context())
for t in list: for t in lst:
if t: if t:
birth_handle = t[0].get_birth_handle() birth_handle = t[0].get_birth_handle()
death_handle = t[0].get_death_handle() death_handle = t[0].get_death_handle()
@ -281,12 +281,12 @@ class PedigreeView:
self.canvas_items.append(arrow) self.canvas_items.append(arrow)
break break
if list[1]: if lst[1]:
p = list[1] p = lst[1]
self.add_parent_button(p[0],x2-_PAD,ypts[1],h) self.add_parent_button(p[0],x2-_PAD,ypts[1],h)
if list[2]: if lst[2]:
p = list[2] p = lst[2]
self.add_parent_button(p[0],x2-_PAD,ypts[2],h) self.add_parent_button(p[0],x2-_PAD,ypts[2],h)
gen_no = 1 gen_no = 1
@ -306,19 +306,19 @@ class PedigreeView:
gen_no = gen_no + 1 gen_no = gen_no + 1
for i in range(gen): for i in range(gen):
if list[i]: if lst[i]:
if i < int(gen/2.0): if i < int(gen/2.0):
findex = (2*i)+1 findex = (2*i)+1
mindex = findex+1 mindex = findex+1
if list[findex]: if lst[findex]:
p = list[findex] p = lst[findex]
self.draw_canvas_line(xpts[i], ypts[i], xpts[findex], self.draw_canvas_line(xpts[i], ypts[i], xpts[findex],
ypts[findex], h, w, p[0], style, p[1]) ypts[findex], h, w, p[0], style, p[1])
if list[mindex]: if lst[mindex]:
p = list[mindex] p = lst[mindex]
self.draw_canvas_line(xpts[i],ypts[i], xpts[mindex], self.draw_canvas_line(xpts[i],ypts[i], xpts[mindex],
ypts[mindex], h, w, p[0], style, p[1]) ypts[mindex], h, w, p[0], style, p[1])
p = list[i] p = lst[i]
box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],self.parent.db, box = DispBox(self.root,style,xpts[i],ypts[i],w,h,p[0],self.parent.db,
self.change_active_person, self.change_active_person,
self.load_person, self.build_full_nav_menu) self.load_person, self.build_full_nav_menu)
@ -479,7 +479,7 @@ class PedigreeView:
obj.set(fill_color_gdk=style.fg[gtk.STATE_NORMAL], width_pixels=2) obj.set(fill_color_gdk=style.fg[gtk.STATE_NORMAL], width_pixels=2)
self.update() self.update()
def find_tree(self,person,index,depth,list,val=0): def find_tree(self,person,index,depth,lst,val=0):
"""Recursively build a list of ancestors""" """Recursively build a list of ancestors"""
if depth > 5 or person == None: if depth > 5 or person == None:
@ -491,16 +491,16 @@ class PedigreeView:
frel = (f != "Birth") frel = (f != "Birth")
family = self.parent.db.get_family_from_handle(family_handle) family = self.parent.db.get_family_from_handle(family_handle)
list[index] = (person,val) lst[index] = (person,val)
if family != None: if family != None:
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
if father_handle != None: if father_handle != None:
father = self.parent.db.get_person_from_handle(father_handle) father = self.parent.db.get_person_from_handle(father_handle)
self.find_tree(father,(2*index)+1,depth+1,list,frel) self.find_tree(father,(2*index)+1,depth+1,lst,frel)
mother_handle = family.get_mother_handle() mother_handle = family.get_mother_handle()
if mother_handle != None: if mother_handle != None:
mother = self.parent.db.get_person_from_handle(mother_handle) mother = self.parent.db.get_person_from_handle(mother_handle)
self.find_tree(mother,(2*index)+2,depth+1,list,mrel) self.find_tree(mother,(2*index)+2,depth+1,lst,mrel)
def on_canvas1_event(self,obj,event): def on_canvas1_event(self,obj,event):
"""Handle resize events over the canvas, redrawing if the size changes""" """Handle resize events over the canvas, redrawing if the size changes"""
@ -518,6 +518,7 @@ class PedigreeView:
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
self.build_nav_menu(event) self.build_nav_menu(event)
return gtk.TRUE return gtk.TRUE
return gtk.FALSE
def add_nav_portion_to_menu(self,menu): def add_nav_portion_to_menu(self,menu):
""" """
@ -738,7 +739,7 @@ def get_distance(db,orig_person,other_person):
r = Relationship.RelationshipCalculator(db) r = Relationship.RelationshipCalculator(db)
r.apply_filter(orig_person,0,firstList,firstMap) r.apply_filter(orig_person,0,firstList,firstMap)
r.apply_filter(other_person,0,secondList,secondMap) r.apply_filter(other_person,0,secondList,secondMap)
except RuntimeError,msg: except RuntimeError:
return None return None
for person_handle in firstList: for person_handle in firstList:

View File

@ -181,7 +181,6 @@ class PeopleView:
self.goto_active_person() self.goto_active_person()
def add_to_person_list(self,person,change=0): def add_to_person_list(self,person,change=0):
path = self.person_model.add_person(person)
self.apply_filter_clicked() self.apply_filter_clicked()
def goto_active_person(self,first=0): def goto_active_person(self,first=0):

View File

@ -237,8 +237,8 @@ class PlaceView:
EditPlace.EditPlace(self.parent, place, self.update_display) EditPlace.EditPlace(self.parent, place, self.update_display)
def blist(self,store,path,iter,list): def blist(self,store,path,iter,list):
id = self.parent.db.get_place_from_handle(store.get_value(iter,_HANDLE_COL)) handle = self.parent.db.get_place_from_handle(store.get_value(iter,_HANDLE_COL))
list.append(id) list.append(handle)
def merge(self): def merge(self):
mlist = [] mlist = []

View File

@ -215,10 +215,10 @@ class PluginDialog:
"""Updates the informational display on the right hand side of """Updates the informational display on the right hand side of
the dialog box with the description of the selected report""" the dialog box with the description of the selected report"""
store,iter = self.selection.get_selected() store,node = self.selection.get_selected()
if iter: if node:
path = store.get_path(iter) path = store.get_path(node)
if not iter or not self.imap.has_key(path): if not node or not self.imap.has_key(path):
self.statbox.hide() self.statbox.hide()
return return
self.statbox.show() self.statbox.show()
@ -344,14 +344,14 @@ class PluginStatus:
info.write(_("The following modules could not be loaded:")) info.write(_("The following modules could not be loaded:"))
info.write("\n\n") info.write("\n\n")
for (file,msg) in _expect: for (filename,msg) in _expect:
info.write("%s: %s\n\n" % (file,msg)) info.write("%s: %s\n\n" % (filename,msg))
for (file,msgs) in _failmsg: for (filename,msgs) in _failmsg:
error = str(msgs[0]) error = str(msgs[0])
if error[0:11] == "exceptions.": if error[0:11] == "exceptions.":
error = error[11:] error = error[11:]
info.write("%s: %s\n" % (file,error) ) info.write("%s: %s\n" % (filename,error) )
traceback.print_exception(msgs[0],msgs[1],msgs[2],None,info) traceback.print_exception(msgs[0],msgs[1],msgs[2],None,info)
info.write('\n') info.write('\n')
info.seek(0) info.seek(0)
@ -394,20 +394,20 @@ def load_plugins(direct):
# add it to the _success list. If it fails, add it to the _failure # add it to the _success list. If it fails, add it to the _failure
# list # list
for file in os.listdir(direct): for filename in os.listdir(direct):
name = os.path.split(file) name = os.path.split(filename)
match = pymod.match(name[1]) match = pymod.match(name[1])
if not match: if not match:
continue continue
_attempt.append(file) _attempt.append(filename)
plugin = match.groups()[0] plugin = match.groups()[0]
try: try:
a = __import__(plugin) a = __import__(plugin)
_success.append(a) _success.append(a)
except Errors.PluginError, msg: except Errors.PluginError, msg:
_expect.append((file,str(msg))) _expect.append((filename,str(msg)))
except: except:
_failmsg.append((file,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -438,22 +438,22 @@ def reload_plugins(obj):
_failmsg.append((plugin,sys.exc_info())) _failmsg.append((plugin,sys.exc_info()))
# attempt to load any new files found # attempt to load any new files found
for dir in _loaddir: for directory in _loaddir:
for file in os.listdir(dir): for filename in os.listdir(directory):
name = os.path.split(file) name = os.path.split(filename)
match = pymod.match(name[1]) match = pymod.match(name[1])
if not match: if not match:
continue continue
if file in _attempt: if filename in _attempt:
return return
_attempt.append(file) _attempt.append(filename)
plugin = match.groups()[0] plugin = match.groups()[0]
try: try:
a = __import__(plugin) a = __import__(plugin)
if a not in _success: if a not in _success:
_success.append(a) _success.append(a)
except: except:
_failmsg.append((file,sys.exc_info())) _failmsg.append((filename,sys.exc_info()))
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -600,14 +600,14 @@ def build_menu(top_menu,list,callback):
report_menu = gtk.Menu() report_menu = gtk.Menu()
report_menu.show() report_menu.show()
hash = {} hash_data = {}
for report in list: for report in list:
if hash.has_key(report[1]): if hash_data.has_key(report[1]):
hash[report[1]].append((report[2],report[0])) hash_data[report[1]].append((report[2],report[0]))
else: else:
hash[report[1]] = [(report[2],report[0])] hash_data[report[1]] = [(report[2],report[0])]
catlist = hash.keys() catlist = hash_data.keys()
catlist.sort() catlist.sort()
for key in catlist: for key in catlist:
entry = gtk.MenuItem(key) entry = gtk.MenuItem(key)
@ -616,9 +616,9 @@ def build_menu(top_menu,list,callback):
submenu = gtk.Menu() submenu = gtk.Menu()
submenu.show() submenu.show()
entry.set_submenu(submenu) entry.set_submenu(submenu)
list = hash[key] lst = hash_data[key]
list.sort() lst.sort()
for name in list: for name in lst:
subentry = gtk.MenuItem("%s..." % name[0]) subentry = gtk.MenuItem("%s..." % name[0])
subentry.show() subentry.show()
subentry.connect("activate",callback,name[1]) subentry.connect("activate",callback,name[1])

View File

@ -61,8 +61,8 @@ def import_media_object(filename,path,base):
ext = os.path.splitext(filename)[1] ext = os.path.splitext(filename)[1]
type = GrampsMime.get_type(filename) mtype = GrampsMime.get_type(filename)
if type[0:5] == "image": if mtype[0:5] == "image":
name = "%s/%s%s" % (os.path.dirname(path),base,ext) name = "%s/%s%s" % (os.path.dirname(path),base,ext)
thumb = "%s/.thumb" % (os.path.dirname(path)) thumb = "%s/.thumb" % (os.path.dirname(path))
@ -137,26 +137,26 @@ def scale_image(path,size):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def mk_thumb(source,dest,size): def mk_thumb(source,dest,size):
dir = os.path.dirname(dest) directory = os.path.dirname(dest)
source = os.path.normpath(source) source = os.path.normpath(source)
dest = os.path.normpath(dest) dest = os.path.normpath(dest)
try: try:
if not os.path.exists(dir): if not os.path.exists(directory):
os.mkdir(dir) os.mkdir(directory)
except IOError,msg: except IOError,msg:
ErrorDialog(_("Could not create %s") % dir, str(msg)) ErrorDialog(_("Could not create %s") % directory, str(msg))
return return
except: except:
ErrorDialog(_("Could not create %s") % dir) ErrorDialog(_("Could not create %s") % directory)
return return
if os.path.exists(dest): if os.path.exists(dest):
try: try:
os.remove(dest) os.remove(dest)
except IOError,msg: except IOError,msg:
errmsg = _("Could not replace %s") % dir errmsg = _("Could not replace %s") % directory
ErrorDialog(errmsg,msg) ErrorDialog(errmsg,msg)
return return

View File

@ -273,7 +273,7 @@ class RelationshipCalculator:
try: try:
self.apply_filter(orig_person,0,firstList,firstMap) self.apply_filter(orig_person,0,firstList,firstMap)
self.apply_filter(other_person,0,secondList,secondMap) self.apply_filter(other_person,0,secondList,secondMap)
except RuntimeError,msg: except RuntimeError:
return (firstRel,secondRel,_("Relationship loop detected")) return (firstRel,secondRel,_("Relationship loop detected"))
for person_handle in firstList: for person_handle in firstList:

View File

@ -99,7 +99,7 @@ class RelCalc:
continue continue
val = self.db.get_person_from_handle(key).get_display_info() val = self.db.get_person_from_handle(key).get_display_info()
event = self.db.find_event_from_handle(val[3]) event = self.db.find_event_from_handle(val[3])
event_date = None event_date = ""
if event: if event:
event_date = event.get_date () event_date = event.get_date ()
self.clist.add([val[0],val[1],event_date,val[5],val[6]],p.get_handle()) self.clist.add([val[0],val[1],event_date,val[5],val[6]],p.get_handle())