Image thumbnails, source bug fixes
svn: r71
This commit is contained in:
parent
23738ca234
commit
034c89dd1e
@ -27,7 +27,7 @@ import const
|
||||
import string
|
||||
|
||||
try:
|
||||
import PIL
|
||||
import Image
|
||||
no_pil = 0
|
||||
except:
|
||||
no_pil = 1
|
||||
@ -79,10 +79,10 @@ class AbiWordDoc(TextDoc):
|
||||
tag = string.replace(base,'.','_')
|
||||
|
||||
if no_pil:
|
||||
cmd = "%s -size %dx%d %s %s" % (const.convert,width,height,file,base)
|
||||
cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,width,height,file,base)
|
||||
os.system(cmd)
|
||||
else:
|
||||
im = PIL.Image.open(file)
|
||||
im = Image.open(file)
|
||||
im.thumbnail((width,height))
|
||||
im.save(base,"PNG")
|
||||
|
||||
|
@ -2569,11 +2569,6 @@
|
||||
<object>editPerson</object>
|
||||
<last_modification_time>Sun, 10 Dec 2000 03:48:37 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>text_changed</name>
|
||||
<handler>on_photolist_text_changed</handler>
|
||||
<last_modification_time>Sun, 10 Dec 2000 15:12:13 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>button_press_event</name>
|
||||
<handler>on_photolist_button_press_event</handler>
|
||||
|
@ -79,6 +79,7 @@ class EditPerson:
|
||||
self.surname_list = surname_list
|
||||
self.callback = callback
|
||||
self.path = db.getSavePath()
|
||||
self.not_loaded = 1
|
||||
|
||||
self.top_window = libglade.GladeXML(const.editPersonFile, "editPerson")
|
||||
|
||||
@ -123,7 +124,6 @@ class EditPerson:
|
||||
self.is_female = self.get_widget("genderFemale")
|
||||
|
||||
self.selectedIcon = -1
|
||||
self.currentImages = []
|
||||
|
||||
self.top_window.signal_autoconnect({
|
||||
"on_eventAddBtn_clicked" : on_event_add_clicked,
|
||||
@ -210,7 +210,10 @@ class EditPerson:
|
||||
# load photos into the photo window
|
||||
photo_list = person.getPhotoList()
|
||||
if len(photo_list) != 0:
|
||||
self.load_photo(photo_list[0].getPath())
|
||||
thumb = self.db.getSavePath() + os.sep + ".thumb" + \
|
||||
os.sep + "i%d.jpg" % self.person.getId()
|
||||
RelImage.check_thumb(photo_list[0].getPath(),thumb,const.picWidth)
|
||||
self.load_photo(thumb)
|
||||
|
||||
# set notes data
|
||||
self.notes_field.set_point(0)
|
||||
@ -386,33 +389,27 @@ class EditPerson:
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# add_thumbnail - Scale the image and add it to the IconList. Currently,
|
||||
# there seems to be a problem with either GdkImlib. A reference has to be
|
||||
# kept to the image, or it gets lost. This is supposed to be a known
|
||||
# imlib problem
|
||||
# add_thumbnail - Scale the image and add it to the IconList.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def add_thumbnail(self,photo):
|
||||
src = photo.getPath()
|
||||
thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \
|
||||
os.path.basename(src)
|
||||
|
||||
image2 = RelImage.scale_image(photo.getPath(),const.thumbScale)
|
||||
RelImage.check_thumb(src,thumb,const.thumbScale)
|
||||
|
||||
self.currentImages.append(image2)
|
||||
self.photo_list.append_imlib(image2,photo.getDescription())
|
||||
self.photo_list.append(thumb,photo.getDescription())
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# load_images - clears the currentImages list to free up any cached
|
||||
# Imlibs. Then add each photo in the person's list of photos to the
|
||||
# load_images - add each photo in the person's list of photos to the
|
||||
# photolist window.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def load_images(self):
|
||||
|
||||
if len(self.person.getPhotoList()) == 0:
|
||||
return
|
||||
|
||||
self.currentImages = []
|
||||
|
||||
self.photo_list.freeze()
|
||||
self.photo_list.clear()
|
||||
for photo in self.person.getPhotoList():
|
||||
@ -427,8 +424,7 @@ class EditPerson:
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def load_photo(self,photo):
|
||||
image2 = RelImage.scale_image(photo,const.picWidth)
|
||||
self.get_widget("personPix").load_imlib(image2)
|
||||
self.get_widget("personPix").load_file(photo)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -840,8 +836,10 @@ def on_event_select_row(obj,row,b,c):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_switch_page(obj,a,page):
|
||||
if page == 6:
|
||||
obj.get_data(EDITPERSON).load_images()
|
||||
edit_obj = obj.get_data(EDITPERSON)
|
||||
if page == 6 and edit_obj.not_loaded:
|
||||
edit_obj.not_loaded = 0
|
||||
edit_obj.load_images()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -884,7 +882,12 @@ def on_primary_photo_clicked(obj):
|
||||
photolist[selectedIcon-i] = photolist[selectedIcon-i-1]
|
||||
photolist[0] = savePhoto
|
||||
edit_person_obj.load_images()
|
||||
edit_person_obj.load_photo(savePhoto)
|
||||
|
||||
thumb = edit_person_obj.db.getSavePath() + os.sep + ".thumb" + os.sep + \
|
||||
"i%d" % edit_person_obj.person.getId()
|
||||
|
||||
mk_thumb(savePhoto,thumb,const.picWidth)
|
||||
edit_person_obj.load_photo(thumb)
|
||||
utils.modified()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -53,18 +53,29 @@ import RelImage
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
INDEX = "i"
|
||||
SOURCE = "s"
|
||||
|
||||
class EditSource:
|
||||
|
||||
def __init__(self,source,db,func):
|
||||
self.source = source
|
||||
self.db = db
|
||||
self.callback = func
|
||||
self.path = db.getSavePath()
|
||||
self.not_loaded = 1
|
||||
|
||||
self.selectedIcon = -1
|
||||
self.currentImages = []
|
||||
self.top_window = libglade.GladeXML(const.gladeFile,"sourceEditor")
|
||||
self.title = self.top_window.get_widget("source_title")
|
||||
self.author = self.top_window.get_widget("author")
|
||||
self.pubinfo = self.top_window.get_widget("pubinfo")
|
||||
self.pubinfo = self.top_window.get_widget("pubinfo")
|
||||
self.note = self.top_window.get_widget("source_note")
|
||||
|
||||
self.title.set_text(source.getTitle())
|
||||
@ -75,17 +86,63 @@ class EditSource:
|
||||
self.note.insert_defaults(source.getNote())
|
||||
self.note.set_word_wrap(1)
|
||||
|
||||
self.photo_list = self.top_window.get_widget("photolist")
|
||||
|
||||
self.top_window.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_photolist_select_icon" : on_photo_select_icon,
|
||||
"on_photolist_button_press_event" : on_photolist_button_press_event,
|
||||
"on_switch_page" : on_switch_page,
|
||||
"on_addphoto_clicked" : on_add_photo_clicked,
|
||||
"on_deletephoto_clicked" : on_delete_photo_clicked,
|
||||
"on_sourceapply_clicked" : on_source_apply_clicked
|
||||
})
|
||||
|
||||
self.top = self.top_window.get_widget("sourceEditor")
|
||||
self.top.set_data("o",self)
|
||||
self.top.set_data(SOURCE,self)
|
||||
|
||||
if self.source.getId() == -1:
|
||||
self.top_window.get_widget("add_photo").set_sensitive(0)
|
||||
self.top_window.get_widget("delete_photo").set_sensitive(0)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# add_thumbnail - Scale the image and add it to the IconList.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def add_thumbnail(self,photo):
|
||||
src = photo.getPath()
|
||||
thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \
|
||||
os.path.basename(src)
|
||||
|
||||
RelImage.check_thumb(src,thumb,const.thumbScale)
|
||||
|
||||
self.photo_list.append(thumb,photo.getDescription())
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# load_images - clears the currentImages list to free up any cached
|
||||
# Imlibs. Then add each photo in the source's list of photos to the
|
||||
# photolist window.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def load_images(self):
|
||||
if len(self.source.getPhotoList()) == 0:
|
||||
return
|
||||
self.photo_list.freeze()
|
||||
self.photo_list.clear()
|
||||
for photo in self.source.getPhotoList():
|
||||
self.add_thumbnail(photo)
|
||||
self.photo_list.thaw()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-----------------------------------------------------------------------------
|
||||
def on_source_apply_clicked(obj):
|
||||
|
||||
edit = obj.get_data("o")
|
||||
edit = obj.get_data(SOURCE)
|
||||
title = edit.title.get_text()
|
||||
author = edit.author.get_text()
|
||||
pubinfo = edit.pubinfo.get_text()
|
||||
@ -100,7 +157,7 @@ def on_source_apply_clicked(obj):
|
||||
utils.modified()
|
||||
|
||||
if pubinfo != edit.source.getPubInfo():
|
||||
edit.source.sePubInfo(pubinfo)
|
||||
edit.source.setPubInfo(pubinfo)
|
||||
utils.modified()
|
||||
|
||||
if note != edit.source.getNote():
|
||||
@ -110,4 +167,222 @@ def on_source_apply_clicked(obj):
|
||||
utils.destroy_passed_object(edit.top)
|
||||
edit.callback(edit.source)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_switch_page(obj,a,page):
|
||||
src = obj.get_data(SOURCE)
|
||||
if page == 2 and src.not_loaded:
|
||||
src.not_loaded = 0
|
||||
src.load_images()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_photo_select_icon(obj,iconNumber,event):
|
||||
obj.get_data(SOURCE).selectedIcon = iconNumber
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_delete_photo_clicked(obj):
|
||||
edit_source_obj = obj.get_data(SOURCE)
|
||||
icon = edit_source_obj.selectedIcon
|
||||
|
||||
if icon == -1:
|
||||
return
|
||||
|
||||
photolist = edit_source_obj.source.getPhotoList()
|
||||
edit_source_obj.photo_list.remove(icon)
|
||||
del photolist[edit_source_obj.selectedIcon]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_add_photo_clicked(obj):
|
||||
|
||||
edit_source = obj.get_data(SOURCE)
|
||||
|
||||
image_select = libglade.GladeXML(const.imageselFile,"imageSelect")
|
||||
|
||||
edit_source.isel = image_select
|
||||
|
||||
image_select.signal_autoconnect({
|
||||
"on_savephoto_clicked" : on_savephoto_clicked,
|
||||
"on_name_changed" : on_name_changed,
|
||||
"destroy_passed_object" : utils.destroy_passed_object
|
||||
})
|
||||
|
||||
edit_source.fname = image_select.get_widget("fname")
|
||||
edit_source.add_image = image_select.get_widget("image")
|
||||
edit_source.external = image_select.get_widget("private")
|
||||
image_select.get_widget("imageSelect").set_data(SOURCE,edit_source)
|
||||
image_select.get_widget("imageSelect").show()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_savephoto_clicked(obj):
|
||||
edit_source_obj = obj.get_data(SOURCE)
|
||||
image_select = edit_source_obj.isel
|
||||
|
||||
filename = image_select.get_widget("photosel").get_full_path(0)
|
||||
description = image_select.get_widget("photoDescription").get_text()
|
||||
|
||||
if os.path.exists(filename) == 0:
|
||||
return
|
||||
|
||||
prefix = "s" + str(edit_source_obj.source.getId())
|
||||
if edit_source_obj.external.get_active() == 1:
|
||||
if os.path.isfile(filename):
|
||||
name = filename
|
||||
else:
|
||||
return
|
||||
else:
|
||||
name = RelImage.import_photo(filename,edit_source_obj.path,prefix)
|
||||
if name == None:
|
||||
return
|
||||
|
||||
photo = Photo()
|
||||
photo.setPath(name)
|
||||
photo.setDescription(description)
|
||||
|
||||
edit_source_obj.source.addPhoto(photo)
|
||||
edit_source_obj.add_thumbnail(photo)
|
||||
|
||||
utils.modified()
|
||||
utils.destroy_passed_object(obj)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_photolist_button_press_event(obj,event):
|
||||
|
||||
myobj = obj.get_data(SOURCE)
|
||||
icon = myobj.selectedIcon
|
||||
if icon == -1:
|
||||
return
|
||||
|
||||
if event.button == 3:
|
||||
photo = myobj.source.getPhotoList()[icon]
|
||||
menu = GtkMenu()
|
||||
item = GtkTearoffMenuItem()
|
||||
item.show()
|
||||
view = GtkMenuItem(_("View Photo"))
|
||||
view.set_data("m",myobj)
|
||||
view.connect("activate",on_view_photo)
|
||||
view.show()
|
||||
edit = GtkMenuItem(_("Edit Photo"))
|
||||
edit.set_data("m",myobj)
|
||||
edit.connect("activate",on_edit_photo)
|
||||
edit.show()
|
||||
change = GtkMenuItem(_("Edit Description"))
|
||||
change.set_data("m",myobj)
|
||||
change.connect("activate",on_change_description)
|
||||
change.show()
|
||||
menu.append(item)
|
||||
menu.append(view)
|
||||
menu.append(edit)
|
||||
menu.append(change)
|
||||
if photo.getPrivate() == 0:
|
||||
private = GtkMenuItem(_("Convert to private copy"))
|
||||
private.set_data("m",myobj)
|
||||
private.connect("activate",on_convert_to_private)
|
||||
private.show()
|
||||
menu.append(private)
|
||||
menu.popup(None,None,None,0,0)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_convert_to_private(obj):
|
||||
edit_source_obj = obj.get_data("m")
|
||||
photo = edit_source_obj.source.getPhotoList()[edit_source_obj.selectedIcon]
|
||||
|
||||
prefix = "i" + str(edit_source_obj.source.getId())
|
||||
name = RelImage.import_photo(photo.getPath(),edit_source_obj.path,prefix)
|
||||
|
||||
photo.setPath(name)
|
||||
photo.setPrivate(1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_view_photo(obj):
|
||||
myobj = obj.get_data("m")
|
||||
photo = myobj.source.getPhotoList()[myobj.selectedIcon]
|
||||
type = gnome.mime.type(photo.getPath())
|
||||
|
||||
prog = string.split(gnome.mime.get_value(type,'view'))
|
||||
args = []
|
||||
for val in prog:
|
||||
if val == "%f":
|
||||
args.append(photo.getPath())
|
||||
else:
|
||||
args.append(val)
|
||||
|
||||
if os.fork() == 0:
|
||||
os.execvp(args[0],args)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_edit_photo(obj):
|
||||
myobj = obj.get_data("m")
|
||||
photo = myobj.source.getPhotoList()[myobj.selectedIcon]
|
||||
if os.fork() == 0:
|
||||
os.execvp(const.editor,[const.editor, photo.getPath()])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_change_description(obj):
|
||||
myobj = obj.get_data("m")
|
||||
photo = myobj.source.getPhotoList()[myobj.selectedIcon]
|
||||
window = libglade.GladeXML(const.imageselFile,"dialog1")
|
||||
|
||||
text = window.get_widget("text")
|
||||
text.set_text(photo.getDescription())
|
||||
|
||||
image2 = RelImage.scale_image(photo.getPath(),200.0)
|
||||
window.get_widget("photo").load_imlib(image2)
|
||||
window.get_widget("dialog1").set_data("p",photo)
|
||||
window.get_widget("dialog1").set_data("t",text)
|
||||
window.get_widget("dialog1").set_data("m",obj.get_data("m"))
|
||||
window.signal_autoconnect({
|
||||
"on_cancel_clicked" : utils.destroy_passed_object,
|
||||
"on_ok_clicked" : on_ok_clicked,
|
||||
"on_apply_clicked" : on_apply_clicked
|
||||
})
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_name_changed(obj):
|
||||
edit_person = obj.get_data(SOURCE)
|
||||
file = edit_person.fname.get_text()
|
||||
if os.path.isfile(file):
|
||||
image = RelImage.scale_image(file,const.thumbScale)
|
||||
edit_person.add_image.load_imlib(image)
|
||||
|
@ -69,6 +69,7 @@ class GrampsParser(handler.ContentHandler):
|
||||
self.scomments_list = []
|
||||
self.note_list = []
|
||||
|
||||
self.use_p = 0
|
||||
self.in_note = 0
|
||||
self.in_attribute = 0
|
||||
self.in_old_attr = 0
|
||||
@ -398,6 +399,8 @@ class GrampsParser(handler.ContentHandler):
|
||||
photo.setPrivate(0)
|
||||
if self.in_family == 1:
|
||||
self.family.addPhoto(photo)
|
||||
if self.in_source == 1:
|
||||
self.source.addPhoto(photo)
|
||||
else:
|
||||
self.person.addPhoto(photo)
|
||||
|
||||
@ -609,7 +612,12 @@ class GrampsParser(handler.ContentHandler):
|
||||
#
|
||||
#---------------------------------------------------------------------
|
||||
def stop_stext(self,tag):
|
||||
self.source_ref.setText(fix_spaces(tag))
|
||||
if self.use_p:
|
||||
self.use_p = 0
|
||||
note = fix_spaces(self.stext_list)
|
||||
else:
|
||||
note = tag
|
||||
self.source_ref.setText(note)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
#
|
||||
@ -617,7 +625,12 @@ class GrampsParser(handler.ContentHandler):
|
||||
#
|
||||
#---------------------------------------------------------------------
|
||||
def stop_scomments(self,tag):
|
||||
self.source_ref.setComments(fix_spaces(self.scomments_list))
|
||||
if self.use_p:
|
||||
self.use_p = 0
|
||||
note = fix_spaces(self.scomments_list)
|
||||
else:
|
||||
note = tag
|
||||
self.source_ref.setComments(note)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
#
|
||||
@ -658,16 +671,23 @@ class GrampsParser(handler.ContentHandler):
|
||||
#---------------------------------------------------------------------
|
||||
def stop_note(self,tag):
|
||||
self.in_note = 0
|
||||
if self.use_p:
|
||||
self.use_p = 0
|
||||
note = fix_spaces(self.note_list)
|
||||
else:
|
||||
note = tag
|
||||
if self.in_address == 1:
|
||||
self.address.setNote(fix_spaces(self.note_list))
|
||||
elif self.in_source_ref == 1:
|
||||
self.source_ref.setNote(fix_spaces(self.note_list))
|
||||
self.address.setNote(note)
|
||||
if self.in_attribute == 1:
|
||||
self.attribute.setNote(note)
|
||||
elif self.in_source == 1:
|
||||
self.source.setNote(note)
|
||||
elif self.in_event == 1:
|
||||
self.event.setNote(fix_spaces(self.note_list))
|
||||
self.event.setNote(note)
|
||||
elif self.in_people == 1:
|
||||
self.person.setNote(fix_spaces(self.note_list))
|
||||
self.person.setNote(note)
|
||||
elif self.in_family == 1:
|
||||
self.family.setNote(fix_spaces(self.note_list))
|
||||
self.family.setNote(note)
|
||||
self.note_list = []
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
@ -749,6 +769,7 @@ class GrampsParser(handler.ContentHandler):
|
||||
#
|
||||
#---------------------------------------------------------------------
|
||||
def stop_ptag(self,tag):
|
||||
self.use_p = 1
|
||||
if self.in_note:
|
||||
self.note_list.append(tag)
|
||||
elif self.in_stext:
|
||||
|
@ -70,7 +70,6 @@ class Marriage:
|
||||
self.path = db.getSavePath()
|
||||
|
||||
self.selectedIcon = 0
|
||||
self.currentImages = []
|
||||
|
||||
self.top = libglade.GladeXML(const.marriageFile,"marriageEditor")
|
||||
self.top.signal_autoconnect({
|
||||
@ -149,10 +148,13 @@ class Marriage:
|
||||
#-------------------------------------------------------------------------
|
||||
def add_thumbnail(self,photo):
|
||||
|
||||
image2 = RelImage.scale_image(photo.getPath(),const.thumbScale)
|
||||
src = photo.getPath()
|
||||
thumb = self.db.getSavePath() + os.sep + ".thumb" + os.sep + \
|
||||
os.path.basename(src)
|
||||
|
||||
self.currentImages.append(image2)
|
||||
self.photo_list.append_imlib(image2,photo.getDescription())
|
||||
RelImage.check_thumb(src,thumb,const.thumbScale)
|
||||
|
||||
self.photo_list.append(thumb,photo.getDescription())
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -165,9 +167,6 @@ class Marriage:
|
||||
|
||||
if len(self.family.getPhotoList()) == 0:
|
||||
return
|
||||
|
||||
self.currentImages = []
|
||||
|
||||
self.photo_list.freeze()
|
||||
self.photo_list.clear()
|
||||
for photo in self.family.getPhotoList():
|
||||
|
@ -27,7 +27,7 @@ from latin_utf8 import latin_to_utf8
|
||||
import const
|
||||
|
||||
try:
|
||||
import PIL
|
||||
import Image
|
||||
no_pil = 0
|
||||
except:
|
||||
no_pil = 1
|
||||
@ -425,10 +425,10 @@ class OpenOfficeDoc(TextDoc):
|
||||
base = os.path.basename(file)
|
||||
image_name = self.tempdir + os.sep + "Pictures" + os.sep + base
|
||||
if no_pil:
|
||||
cmd = "%s -size %dx%d '%s' '%s'" % (const.convert,width,height,file,image_name)
|
||||
cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,width,height,file,image_name)
|
||||
os.system(cmd)
|
||||
else:
|
||||
im = PIL.Image.open(file)
|
||||
im = Image.open(file)
|
||||
im.thumbnail((width,height))
|
||||
im.save(name,"JPEG")
|
||||
|
||||
|
@ -30,7 +30,7 @@ import reportlab.lib.styles
|
||||
from latin_utf8 import latin_to_utf8
|
||||
|
||||
try:
|
||||
import PIL.Image
|
||||
import Image
|
||||
no_pil = 0
|
||||
except:
|
||||
no_pil = 1
|
||||
@ -215,7 +215,7 @@ class PdfDoc(TextDoc):
|
||||
|
||||
def add_photo(self,name,x,y):
|
||||
if no_pil == 0:
|
||||
im = PIL.Image.open(name)
|
||||
im = Image.open(name)
|
||||
|
||||
nx,ny = im.size
|
||||
scale = float(y)/float(nx)
|
||||
|
@ -31,7 +31,7 @@ from gnome.ui import *
|
||||
_ = intl.gettext
|
||||
|
||||
try:
|
||||
import PIL.Image
|
||||
import Image
|
||||
no_pil = 0
|
||||
except:
|
||||
no_pil = 1
|
||||
@ -56,7 +56,15 @@ def import_photo(filename,path,prefix):
|
||||
if os.path.exists(name) == 0:
|
||||
break
|
||||
|
||||
thumb = path+os.sep+".thumb"
|
||||
if not os.path.exists(thumb):
|
||||
os.mkdir(thumb)
|
||||
|
||||
try:
|
||||
path = thumb + os.sep + base
|
||||
|
||||
mk_thumb(filename,path,const.thumbScale)
|
||||
|
||||
if type == "image/jpeg":
|
||||
shutil.copy(filename,name)
|
||||
else:
|
||||
@ -64,7 +72,7 @@ def import_photo(filename,path,prefix):
|
||||
cmd = "%s '%s' '%s'" % (const.convert,filename,name)
|
||||
os.system(cmd)
|
||||
else:
|
||||
PIL.Image.open(filename).save(name)
|
||||
Image.open(filename).save(name)
|
||||
except:
|
||||
return None
|
||||
|
||||
@ -91,4 +99,38 @@ def scale_image(path,size):
|
||||
image2 = image1.clone_scaled_image(int(scale*width), int(scale*height))
|
||||
return image2
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# scale_image
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def mk_thumb(source,dest,size):
|
||||
|
||||
dir = os.path.dirname(dest)
|
||||
if not os.path.exists(dir):
|
||||
os.mkdir(dir)
|
||||
|
||||
if no_pil:
|
||||
cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,size,size,source,dest)
|
||||
print cmd
|
||||
os.system(cmd)
|
||||
else:
|
||||
im = Image.open(source)
|
||||
im.thumbnail((size,size))
|
||||
im.save(dest,"JPEG")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# scale_image
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def check_thumb(source,dest,size):
|
||||
if not os.path.isfile(source):
|
||||
return
|
||||
if not os.path.isfile(dest):
|
||||
mk_thumb(source,dest,size)
|
||||
elif os.path.getmtime(source) > os.path.getmtime(dest):
|
||||
mk_thumb(source,dest,size)
|
||||
|
||||
|
||||
|
||||
|
@ -620,6 +620,8 @@ class Source:
|
||||
self.pubinfo = ""
|
||||
self.callno = ""
|
||||
self.note = Note()
|
||||
self.photoList = []
|
||||
self.id = -1
|
||||
|
||||
def setId(self,newId):
|
||||
self.id = newId
|
||||
@ -627,6 +629,12 @@ class Source:
|
||||
def getId(self):
|
||||
return self.id
|
||||
|
||||
def addPhoto(self,photo):
|
||||
self.photoList.append(photo)
|
||||
|
||||
def getPhotoList(self):
|
||||
return self.photoList
|
||||
|
||||
def setTitle(self,title):
|
||||
self.title = title
|
||||
|
||||
|
@ -106,7 +106,11 @@ class SourceEditor:
|
||||
typeMenu.append(menuitem)
|
||||
index = 1
|
||||
save = 0
|
||||
if self.source_ref:
|
||||
self.base = self.source_ref.getBase()
|
||||
else:
|
||||
self.base = None
|
||||
|
||||
for src in self.db.getSourceMap().values():
|
||||
if src == self.base:
|
||||
save = index
|
||||
@ -155,6 +159,10 @@ def on_sourceok_clicked(obj):
|
||||
src_edit = obj.get_data(SOURCEDISP)
|
||||
|
||||
current_source_ref = src_edit.active_entry.getSourceRef()
|
||||
if current_source_ref == None:
|
||||
current_source_ref = SourceRef()
|
||||
src_edit.active_entry.setSourceRef(current_source_ref)
|
||||
|
||||
if src_edit.active_source != current_source_ref.getBase():
|
||||
src_edit.active_entry.getSourceRef().setBase(src_edit.active_source)
|
||||
utils.modified()
|
||||
|
@ -62,11 +62,8 @@ def fix(line):
|
||||
def writeNote(g,val,note):
|
||||
if not note:
|
||||
return
|
||||
g.write("<" + val + ">\n")
|
||||
textlines = string.split(note[:-1],'\n')
|
||||
|
||||
for line in textlines:
|
||||
g.write("<p>" + fix(line) + "</p>\n")
|
||||
g.write("<" + val + ">")
|
||||
g.write(fix(note))
|
||||
g.write("</" + val + ">\n")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -90,7 +87,7 @@ def dump_my_event(g,name,event):
|
||||
date = event.getSaveDate()
|
||||
place = event.getPlace()
|
||||
description = event.getDescription()
|
||||
if not date and not place and not description:
|
||||
if not name and not date and not place and not description:
|
||||
return
|
||||
|
||||
g.write("<event type=\"" + fix(name) + "\">\n")
|
||||
@ -123,7 +120,7 @@ def dump_source_ref(g,source_ref):
|
||||
write_line(g,"spage",p)
|
||||
writeNote(g,"scomments",c)
|
||||
writeNote(g,"stext",t)
|
||||
write_line(g,"sdate",c)
|
||||
write_line(g,"sdate",d)
|
||||
g.write("</sourceref>\n")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -283,7 +280,7 @@ def exportData(database, filename, callback):
|
||||
g.write("<attributes>\n")
|
||||
for attr in person.getAttributeList():
|
||||
if attr.getSourceRef() or attr.getNote():
|
||||
g.write('<attribute>')
|
||||
g.write('<attribute>\n')
|
||||
write_line(g,"attr_type",attr.getType())
|
||||
write_line(g,"attr_value",attr.getValue())
|
||||
dump_source_ref(g,attr.getSourceRef())
|
||||
@ -358,6 +355,12 @@ def exportData(database, filename, callback):
|
||||
write_line(g,"scallno",source.getCallNumber())
|
||||
if source.getNote() != "":
|
||||
writeNote(g,"note",source.getNote())
|
||||
for photo in source.getPhotoList():
|
||||
path = photo.getPath()
|
||||
if os.path.dirname(path) == fileroot:
|
||||
path = os.path.basename(path)
|
||||
g.write("<img src=\"" + fix(path) + "\"")
|
||||
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"/>\n")
|
||||
g.write("</source>\n")
|
||||
g.write("</sources>\n")
|
||||
|
||||
|
@ -2373,6 +2373,11 @@
|
||||
<handler>on_source_list_select_row</handler>
|
||||
<last_modification_time>Tue, 29 May 2001 21:23:02 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>button_press_event</name>
|
||||
<handler>on_source_list_button_press_event</handler>
|
||||
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
||||
</signal>
|
||||
<columns>2</columns>
|
||||
<column_widths>300,80</column_widths>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
@ -3407,7 +3412,7 @@ Other
|
||||
<title>Gramps - Source Editor</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_CENTER</position>
|
||||
<modal>True</modal>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>False</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
@ -3519,8 +3524,14 @@ Other
|
||||
<class>GtkNotebook</class>
|
||||
<name>notebook2</name>
|
||||
<width>450</width>
|
||||
<height>250</height>
|
||||
<height>350</height>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>switch_page</name>
|
||||
<handler>on_switch_page</handler>
|
||||
<object>sourceEditor</object>
|
||||
<last_modification_time>Thu, 31 May 2001 15:04:55 GMT</last_modification_time>
|
||||
</signal>
|
||||
<show_tabs>True</show_tabs>
|
||||
<show_border>True</show_border>
|
||||
<tab_pos>GTK_POS_TOP</tab_pos>
|
||||
@ -3711,7 +3722,7 @@ Other
|
||||
<class>GtkScrolledWindow</class>
|
||||
<name>scrolledwindow23</name>
|
||||
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
|
||||
<vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy>
|
||||
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
|
||||
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
|
||||
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
|
||||
|
||||
@ -3738,7 +3749,101 @@ Other
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
<class>GtkScrolledWindow</class>
|
||||
<name>scrolledwindow25</name>
|
||||
<hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy>
|
||||
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
|
||||
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
|
||||
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
|
||||
|
||||
<widget>
|
||||
<class>GtkViewport</class>
|
||||
<name>viewport1</name>
|
||||
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox34</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
|
||||
<widget>
|
||||
<class>GnomeIconList</class>
|
||||
<name>photolist</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>select_icon</name>
|
||||
<handler>on_photolist_select_icon</handler>
|
||||
<object>sourceEditor</object>
|
||||
<last_modification_time>Thu, 31 May 2001 14:39:53 GMT</last_modification_time>
|
||||
</signal>
|
||||
<signal>
|
||||
<name>button_press_event</name>
|
||||
<handler>on_photolist_button_press_event</handler>
|
||||
<object>sourceEditor</object>
|
||||
<last_modification_time>Thu, 31 May 2001 14:40:04 GMT</last_modification_time>
|
||||
</signal>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
<icon_width>100</icon_width>
|
||||
<row_spacing>20</row_spacing>
|
||||
<column_spacing>10</column_spacing>
|
||||
<text_spacing>5</text_spacing>
|
||||
<text_editable>False</text_editable>
|
||||
<text_static>True</text_static>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox21</name>
|
||||
<layout_style>GTK_BUTTONBOX_SPREAD</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>add_photo</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_addphoto_clicked</handler>
|
||||
<object>sourceEditor</object>
|
||||
<last_modification_time>Thu, 31 May 2001 14:39:32 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Add Photo</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>delete_photo</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_deletephoto_clicked</handler>
|
||||
<object>sourceEditor</object>
|
||||
<last_modification_time>Thu, 31 May 2001 14:39:16 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Delete Photo</label>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
|
@ -65,7 +65,9 @@ import utils
|
||||
import Bookmarks
|
||||
import ListColors
|
||||
import Config
|
||||
|
||||
import EditSource
|
||||
import EditPerson
|
||||
import Marriage
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -579,8 +581,6 @@ def new_database_response(val):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def marriage_edit(family):
|
||||
import Marriage
|
||||
|
||||
Marriage.Marriage(family,database)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -669,8 +669,6 @@ def on_source_list_select_row(obj,a,b,c):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_add_source_clicked(obj):
|
||||
import EditSource
|
||||
|
||||
EditSource.EditSource(Source(),database,new_source_after_edit)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -687,8 +685,6 @@ def on_delete_source_clicked(obj):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_edit_source_clicked(obj):
|
||||
import EditSource
|
||||
|
||||
index = obj.get_data("i")
|
||||
if index == -1:
|
||||
return
|
||||
@ -1603,8 +1599,6 @@ def update_after_edit(person):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def load_person(person):
|
||||
import EditPerson
|
||||
|
||||
if person == None:
|
||||
EditPerson.EditPerson(Person(),database,surnameList,\
|
||||
new_after_edit)
|
||||
|
Loading…
Reference in New Issue
Block a user