diff --git a/gramps/src/Config.py b/gramps/src/Config.py index 2eba479ca..0e3554aa3 100644 --- a/gramps/src/Config.py +++ b/gramps/src/Config.py @@ -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: diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index 26a42e8e6..b813635a7 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -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_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) + epo.load_photo(savePhoto.getPath()) + epo.load_images() 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 diff --git a/gramps/src/ReadXML.py b/gramps/src/ReadXML.py index 023916e36..8ee994d1b 100644 --- a/gramps/src/ReadXML.py +++ b/gramps/src/ReadXML.py @@ -58,9 +58,21 @@ def importData(database, filename, callback): parser = make_parser() parser.setContentHandler(GrampsImportParser(database,callback,basefile)) - + + use_gzip = 1 try: - xml_file = gzip.open(filename,"rb") + 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: - xml_file = gzip.open(filename,"rb") + 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 diff --git a/gramps/src/RelImage.py b/gramps/src/RelImage.py index f8e831d6a..3049c18c5 100644 --- a/gramps/src/RelImage.py +++ b/gramps/src/RelImage.py @@ -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") diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index 30253ddc7..fe2d08ed4 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -23,6 +23,7 @@ from Researcher import * import const import string +import Config import time import gzip import shutil @@ -223,8 +224,11 @@ def exportData(database, filename, callback): if os.path.isfile(filename): shutil.copy(filename, filename + ".bak") - - g = gzip.open(filename,"wb") + + if Config.uncompress: + g = open(filename,"w") + else: + g = gzip.open(filename,"wb") g.write("\n") g.write("\n") diff --git a/gramps/src/config.glade b/gramps/src/config.glade index f9f05b448..6131f9dc4 100644 --- a/gramps/src/config.glade +++ b/gramps/src/config.glade @@ -77,8 +77,8 @@ 1 2 - 3 - 4 + 4 + 5 0 0 True @@ -92,22 +92,22 @@ GtkCheckButton - usetabs + attr_display True toggled on_object_toggled propertybox - Thu, 15 Feb 2001 21:32:23 GMT + Thu, 24 May 2001 21:14:10 GMT - + False True 0 1 - 1 - 2 + 4 + 5 5 5 False @@ -134,7 +134,7 @@ True 0 - 1 + 2 0 1 5 @@ -150,22 +150,51 @@ GtkCheckButton - attr_display + uncompress True toggled on_object_toggled propertybox - Thu, 24 May 2001 21:14:10 GMT + Sat, 09 Dec 2000 18:11:20 GMT - + False True 0 - 1 - 3 - 4 + 2 + 1 + 2 + 5 + 5 + False + False + False + False + True + False + + + + + GtkCheckButton + usetabs + True + + toggled + on_object_toggled + propertybox + Thu, 15 Feb 2001 21:32:23 GMT + + + False + True + + 0 + 2 + 2 + 3 5 5 False @@ -192,9 +221,9 @@ True 0 - 1 - 2 - 3 + 2 + 3 + 4 5 5 False