XML improvements, photo handling better (no thumbnail for main edit personapage p

svn: r266
This commit is contained in:
Don Allingham 2001-07-29 23:27:42 +00:00
parent abd0ee6ac1
commit 15f88e1ab8
6 changed files with 121 additions and 64 deletions

View File

@ -94,6 +94,7 @@ _name_format_list = [
owner = Researcher.Researcher()
autoload = 0
usetabs = 0
uncompress = 0
show_detail = 0
hide_altnames = 0
lastfile = None
@ -147,6 +148,7 @@ def loadConfig(call):
global autoload
global owner
global usetabs
global uncompress
global id_visible
global show_detail
global hide_altnames
@ -167,6 +169,7 @@ def loadConfig(call):
_callback = call
lastfile = gnome.config.get_string("/gramps/data/LastFile")
usetabs = gnome.config.get_bool("/gramps/config/UseTabs")
uncompress = gnome.config.get_bool("/gramps/config/DontCompressXML")
id_visible = gnome.config.get_bool("/gramps/config/IdVisible")
show_detail = gnome.config.get_bool("/gramps/config/ShowDetail")
status_bar = gnome.config.get_int("/gramps/config/StatusBar")
@ -236,6 +239,8 @@ def loadConfig(call):
autoload = 1
if usetabs == None:
usetabs = 0
if uncompress == None:
uncompress = 0
if id_visible == None:
id_visible = 0
if show_detail == None:
@ -327,6 +332,7 @@ def on_propertybox_apply(obj,page):
global nameof
global owner
global usetabs
global uncompress
global id_visible
global status_bar
global display_attr
@ -347,6 +353,7 @@ def on_propertybox_apply(obj,page):
display_attr = prefsTop.get_widget("attr_display").get_active()
attr_name = string.strip(prefsTop.get_widget("attr_name").get_text())
usetabs = prefsTop.get_widget("usetabs").get_active()
uncompress = prefsTop.get_widget("uncompress").get_active()
id_visible = prefsTop.get_widget("gid_visible").get_active()
hide_altnames = prefsTop.get_widget("display_altnames").get_active()
paper_obj = prefsTop.get_widget("paper_size").get_menu().get_active()
@ -375,6 +382,7 @@ def on_propertybox_apply(obj,page):
output_preference = output_obj.get_data("d")
gnome.config.set_bool("/gramps/config/UseTabs",usetabs)
gnome.config.set_bool("/gramps/config/DontCompressXML",uncompress)
gnome.config.set_bool("/gramps/config/IdVisible",id_visible)
gnome.config.set_bool("/gramps/config/ShowDetail",show_detail)
gnome.config.set_int("/gramps/config/StatusBar",status_bar)
@ -513,12 +521,14 @@ def display_preferences_box():
auto = prefsTop.get_widget("autoload")
vis = prefsTop.get_widget("gid_visible")
tabs = prefsTop.get_widget("usetabs")
compress = prefsTop.get_widget("uncompress")
detail = prefsTop.get_widget("showdetail")
display_attr_obj = prefsTop.get_widget("attr_display")
display_altnames = prefsTop.get_widget("display_altnames")
auto.set_active(autoload)
detail.set_active(show_detail)
tabs.set_active(usetabs)
compress.set_active(uncompress)
vis.set_active(id_visible)
if status_bar == 0:

View File

@ -35,7 +35,6 @@ import utils
from gtk import *
from gnome.ui import *
import gnome.mime
import libglade
#-------------------------------------------------------------------------
@ -238,9 +237,7 @@ class EditPerson:
# load photos into the photo window
photo_list = person.getPhotoList()
if len(photo_list) != 0:
thumb = "%s%s.thumb%si%s" % ( self.path,os.sep,os.sep,self.person.getId())
RelImage.check_thumb(photo_list[0].getPath(),thumb,const.picWidth)
self.load_photo(thumb)
self.load_photo(photo_list[0].getPath())
# set notes data
self.notes_field.set_point(0)
@ -286,14 +283,7 @@ class EditPerson:
self.name_index = 0
for name in self.nlist:
attr = ""
if Config.show_detail:
if name.getNote() != "":
attr = "N"
if name.getSourceRef().getBase():
attr = attr + "S"
if name.getPrivacy():
attr = attr + "P"
attr = get_detail_flags(name)
self.name_list.append([name.getName(),attr])
self.name_list.set_row_data(self.name_index,name)
self.name_index = self.name_index + 1
@ -348,14 +338,7 @@ class EditPerson:
self.attr_index = 0
for attr in self.alist:
detail = ""
if Config.show_detail:
if attr.getNote() != "":
detail = "N"
if attr.getSourceRef().getBase():
detail = detail + "S"
if attr.getPrivacy():
attr = attr + "P"
detail = get_detail_flags(attr)
self.attr_list.append([const.display_pattr(attr.getType()),\
attr.getValue(),detail])
self.attr_list.set_row_data(self.attr_index,attr)
@ -384,14 +367,7 @@ class EditPerson:
self.address_index = 0
for address in self.plist:
detail = ""
if Config.show_detail:
if address.getNote() != "":
detail = "N"
if address.getSourceRef().getBase():
detail = detail + "S"
if address.getPrivacy():
detail = detail + "P"
detail = get_detail_flags(address)
location = address.getCity() + " " + address.getState() + " " + \
address.getCountry()
self.address_list.append([address.getDate(),location,detail])
@ -422,14 +398,7 @@ class EditPerson:
self.event_index = 0
for event in self.elist:
attr = ""
if Config.show_detail:
if event.getNote() != "":
attr = "N"
if event.getSourceRef().getBase():
attr = attr + "S"
if event.getPrivacy():
attr = attr + "P"
attr = get_detail_flags(event)
self.event_list.append([const.display_pevent(event.getName()),\
event.getQuoteDate(), event.getPlace(),attr])
self.event_list.set_row_data(self.event_index,event)
@ -484,7 +453,14 @@ class EditPerson:
#
#-------------------------------------------------------------------------
def load_photo(self,photo):
self.get_widget("personPix").load_file(photo)
import GdkImlib
i = GdkImlib.Image(photo)
scale = float(const.picWidth)/float(max(i.rgb_height,i.rgb_width))
x = int(scale*(i.rgb_width))
y = int(scale*(i.rgb_height))
i = i.clone_scaled_image(x,y)
self.get_widget("personPix").load_imlib(i)
#-------------------------------------------------------------------------
#
@ -949,12 +925,9 @@ def on_primary_photo_clicked(obj):
for i in range(0,selectedIcon):
photolist[selectedIcon-i] = photolist[selectedIcon-i-1]
photolist[0] = savePhoto
epo.load_photo(savePhoto.getPath())
epo.load_images()
thumb = "%s%s.thumb%si%s" % (epo.path,os.sep,os.sep,epo.person.getId())
RelImage.mk_thumb(savePhoto,thumb,const.picWidth)
epo.load_photo(thumb)
utils.modified()
#-------------------------------------------------------------------------
@ -2070,3 +2043,19 @@ def on_url_edit_ok_clicked(obj):
ee.parent.redraw_url_list()
utils.destroy_passed_object(obj)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def get_detail_flags(obj):
detail = ""
if Config.show_detail:
if obj.getNote() != "":
detail = "N"
if obj.getSourceRef().getBase():
detail = detail + "S"
if obj.getPrivacy():
detail = detail + "P"
return detail

View File

@ -59,8 +59,20 @@ def importData(database, filename, callback):
parser = make_parser()
parser.setContentHandler(GrampsImportParser(database,callback,basefile))
use_gzip = 1
try:
f = gzip.open(filename,"r")
f.read(1)
f.close()
except IOError,msg:
use_gzip = 0
f.close()
try:
if use_gzip:
xml_file = gzip.open(filename,"rb")
else:
xml_file = open(filename,"r")
except IOError,msg:
GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg))
return 0
@ -106,8 +118,20 @@ def loadData(database, filename, callback):
parser = make_parser()
parser.setContentHandler(GrampsParser(database,callback,basefile))
use_gzip = 1
try:
f = gzip.open(filename,"r")
f.read(1)
f.close()
except IOError,msg:
use_gzip = 0
f.close()
try:
if use_gzip:
xml_file = gzip.open(filename,"rb")
else:
xml_file = open(filename,"r")
except IOError,msg:
GnomeErrorDialog(_("%s could not be opened\n") % filename + str(msg))
return 0

View File

@ -128,6 +128,7 @@ def mk_thumb(source,dest,size):
os.system(cmd)
else:
try:
print "Creating thumbnail",dest,"from",source
im = PIL.Image.open(source)
im.thumbnail((size,size))
im.save(dest,"JPEG")

View File

@ -23,6 +23,7 @@ from Researcher import *
import const
import string
import Config
import time
import gzip
import shutil
@ -224,6 +225,9 @@ def exportData(database, filename, callback):
if os.path.isfile(filename):
shutil.copy(filename, filename + ".bak")
if Config.uncompress:
g = open(filename,"w")
else:
g = gzip.open(filename,"wb")
g.write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n")

View File

@ -77,8 +77,8 @@
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
@ -92,22 +92,22 @@
<widget>
<class>GtkCheckButton</class>
<name>usetabs</name>
<name>attr_display</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 15 Feb 2001 21:32:23 GMT</last_modification_time>
<last_modification_time>Thu, 24 May 2001 21:14:10 GMT</last_modification_time>
</signal>
<label>Use tabbed pages</label>
<label>Display attribute on Edit Person form</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
@ -134,7 +134,7 @@
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
@ -150,22 +150,51 @@
<widget>
<class>GtkCheckButton</class>
<name>attr_display</name>
<name>uncompress</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 24 May 2001 21:14:10 GMT</last_modification_time>
<last_modification_time>Sat, 09 Dec 2000 18:11:20 GMT</last_modification_time>
</signal>
<label>Display attribute on Edit Person form</label>
<label>Do not compress XML data file</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>usetabs</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_object_toggled</handler>
<object>propertybox</object>
<last_modification_time>Thu, 15 Feb 2001 21:32:23 GMT</last_modification_time>
</signal>
<label>Use tabbed pages</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>
@ -192,9 +221,9 @@
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xexpand>False</xexpand>