From 6e63aea4986d38bd61e6248fb62231323db4b7ba Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 1 Jan 2002 05:25:08 +0000 Subject: [PATCH] Autosave and thumbnail improvements svn: r672 --- gramps/src/AddrEdit.py | 2 +- gramps/src/Config.py | 18 ++--- gramps/src/ImageSelect.py | 22 ++++-- gramps/src/RelImage.py | 9 +++ gramps/src/config.glade | 157 ++++++++++++++++---------------------- gramps/src/gramps_main.py | 34 ++++++++- 6 files changed, 125 insertions(+), 117 deletions(-) diff --git a/gramps/src/AddrEdit.py b/gramps/src/AddrEdit.py index 1ef115970..4e100b432 100644 --- a/gramps/src/AddrEdit.py +++ b/gramps/src/AddrEdit.py @@ -151,10 +151,10 @@ class AddressEditor: self.addr.setDate(date) self.parent.lists_changed = 1 - self.check(self.addr.getDate,self.addr.setDate,state) self.check(self.addr.getStreet,self.addr.setStreet,street) self.check(self.addr.getCountry,self.addr.setCountry,country) self.check(self.addr.getCity,self.addr.setCity,city) + self.check(self.addr.getState,self.addr.setState,state) self.check(self.addr.getPostal,self.addr.setPostal,postal) self.check(self.addr.getNote,self.addr.setNote,note) self.check(self.addr.getPrivacy,self.addr.setPrivacy,priv) diff --git a/gramps/src/Config.py b/gramps/src/Config.py index bcae1b511..503225a67 100644 --- a/gramps/src/Config.py +++ b/gramps/src/Config.py @@ -94,8 +94,7 @@ sprefix = "S" pprefix = "P" fprefix = "F" autoload = 0 -autosave = 0 -autosave_int = 5 +autosave_int = 0 usetabs = 0 uselds = 0 autocomp = 1 @@ -164,7 +163,6 @@ def make_path(path): #------------------------------------------------------------------------- def loadConfig(call): global autoload - global autosave global autosave_int global owner global usetabs @@ -225,7 +223,6 @@ def loadConfig(call): hide_altnames = get_bool("/gramps/config/DisplayAltNames") autoload = get_bool("/gramps/config/autoLoad") - autosave = get_bool("/gramps/config/autoSave") autosave_int = get_int("/gramps/config/autoSaveInterval") dateFormat = get_int("/gramps/config/dateFormat") dateEntry = get_int("/gramps/config/dateEntry") @@ -304,10 +301,8 @@ def loadConfig(call): if autoload == None: autoload = 1 - if autosave == None: - autosave = 0 if autosave_int == None: - autosave = 5 + autosave_int = 0 if mediaref == None: mediaref = 1 if globalprop == None: @@ -469,10 +464,9 @@ def on_propertybox_apply(obj,page): if page != -1: return - + show_detail = prefsTop.get_widget("showdetail").get_active() autoload = prefsTop.get_widget("autoload").get_active() - autosave = prefsTop.get_widget("save_enable").get_active() autosave_int = prefsTop.get_widget("save_interval").get_value_as_int() display_attr = prefsTop.get_widget("attr_display").get_active() attr_name = string.strip(prefsTop.get_widget("attr_name").get_text()) @@ -559,9 +553,9 @@ def on_propertybox_apply(obj,page): set_string("/gramps/config/paperPreference",paper_preference) set_string("/gramps/config/outputPreference",output_preference) set_bool("/gramps/config/autoLoad",autoload) - set_bool("/gramps/config/autoSave",autosave) set_int("/gramps/config/autoSaveInterval",autosave_int) - if autosave and autosave_int != 0: + + if autosave_int != 0: utils.enable_autosave(None,autosave_int) else: utils.disable_autosave() @@ -711,7 +705,6 @@ def display_preferences_box(db): pbox = prefsTop.get_widget("propertybox") pbox.set_data("db",db) auto = prefsTop.get_widget("autoload") - asave = prefsTop.get_widget("save_enable") asave_int = prefsTop.get_widget("save_interval") vis = prefsTop.get_widget("gid_visible") idedit = prefsTop.get_widget("gid_edit") @@ -731,7 +724,6 @@ def display_preferences_box(db): display_attr_obj = prefsTop.get_widget("attr_display") display_altnames = prefsTop.get_widget("display_altnames") auto.set_active(autoload) - asave.set_active(autosave) asave_int.set_value(autosave_int) detail.set_active(show_detail) tabs.set_active(usetabs) diff --git a/gramps/src/ImageSelect.py b/gramps/src/ImageSelect.py index 6dd00e102..91b9f2a3b 100644 --- a/gramps/src/ImageSelect.py +++ b/gramps/src/ImageSelect.py @@ -34,6 +34,7 @@ import string import GDK import GTK import gtk +import GdkImlib import gnome.ui import libglade @@ -73,11 +74,16 @@ class ImageSelect: self.path = path; self.db = db self.dataobj = None + self.icon_cache = [] def add_thumbnail(self, photo): "should be overrridden" pass - + + def load_images(self): + "should be overrridden" + pass + #------------------------------------------------------------------------- # # create_add_dialog - Create the gnome dialog for selecting a new @@ -156,7 +162,7 @@ class ImageSelect: mobj = Photo() if description == "": description = os.path.basename(filename) - mobj.setDescription(description) + mobj.setDescription(description) mobj.setMimeType(type) self.savephoto(mobj) @@ -166,14 +172,13 @@ class ImageSelect: else: if self.external.get_active() == 1: name = filename - RelImage.mk_thumb(filename,self.path,mobj.getId()) else: name = RelImage.import_media_object(filename,self.path,mobj.getId()) - mobj.setPath(name) - + utils.modified() utils.destroy_passed_object(obj) + self.load_images() #------------------------------------------------------------------------- # @@ -241,8 +246,10 @@ class Gallery(ImageSelect): #------------------------------------------------------------------------- def add_thumbnail(self, photo): object = photo.getReference() - thumb = utils.thumb_path(self.db.getSavePath(),object) - self.icon_list.append(thumb,object.getDescription()) + name = utils.thumb_path(self.db.getSavePath(),object) + thumb = GdkImlib.Image(name) + self.icon_cache.append(thumb) + self.icon_list.append_imlib(thumb,object.getDescription()) #------------------------------------------------------------------------- # @@ -254,6 +261,7 @@ class Gallery(ImageSelect): def load_images(self): self.icon_list.freeze() self.icon_list.clear() + self.icon_cache = [] for photo in self.dataobj.getPhotoList(): self.add_thumbnail(photo) self.icon_list.thaw() diff --git a/gramps/src/RelImage.py b/gramps/src/RelImage.py index 44fa77dd9..276fdcfda 100644 --- a/gramps/src/RelImage.py +++ b/gramps/src/RelImage.py @@ -82,6 +82,7 @@ def import_media_object(filename,path,base): try: path = "%s/%s" % (thumb,base) + print "Making",path,"from",filename mk_thumb(filename,path,const.thumbScale) shutil.copy(filename,name) except: @@ -122,6 +123,8 @@ def scale_image(path,size): #------------------------------------------------------------------------- def mk_thumb(source,dest,size): + print "making a thumbnail",source,dest + dir = os.path.dirname(dest) try: if not os.path.exists(dir): @@ -133,8 +136,12 @@ def mk_thumb(source,dest,size): GnomeErrorDialog(_("Could not create %s") % dir) return + if os.path.exists(dest): + os.remove(dest) + if no_pil: cmd = "%s -geometry %dx%d '%s' '%s'" % (const.convert,size,size,source,dest) + print cmd os.system(cmd) else: try: @@ -144,7 +151,9 @@ def mk_thumb(source,dest,size): im.draft('RGB',im.size) im = im.convert("RGB") im.save(dest,"JPEG") + print "saving",dest except: + print "save failed" pass #------------------------------------------------------------------------- diff --git a/gramps/src/config.glade b/gramps/src/config.glade index f5a43371c..4eb85b5ae 100644 --- a/gramps/src/config.glade +++ b/gramps/src/config.glade @@ -152,99 +152,6 @@ - - GtkLabel - label217 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - - - GtkCheckButton - save_enable - True - - toggled - on_object_toggled - propertybox - Mon, 24 Dec 2001 23:25:36 GMT - - - False - True - - 0 - 1 - 2 - 3 - 3 - 3 - False - False - False - False - True - False - - - - - GtkSpinButton - save_interval - True - - changed - on_object_changed - propertybox - Mon, 24 Dec 2001 23:25:52 GMT - - 1 - 0 - True - GTK_UPDATE_IF_VALID - True - False - 5 - 0 - 100 - 1 - 10 - 10 - - 2 - 3 - 2 - 3 - 3 - 3 - False - False - False - False - True - False - - - GtkCheckButton autoload @@ -302,6 +209,70 @@ False + + + GtkLabel + label217 + + GTK_JUSTIFY_CENTER + False + 1 + 0.5 + 0 + 0 + + 0 + 1 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + GtkSpinButton + save_interval + True + + changed + on_object_toggled + propertybox + Mon, 31 Dec 2001 16:51:59 GMT + + 1 + 0 + True + GTK_UPDATE_IF_VALID + True + False + 0 + 0 + 100 + 1 + 10 + 10 + + 1 + 2 + 2 + 3 + 3 + 3 + False + False + False + False + True + False + + diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index f24b9d769..aee1f0079 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -504,6 +504,9 @@ def on_reports_clicked(obj): # #------------------------------------------------------------------------- def on_ok_button1_clicked(obj): + global yname + global nname + dbname = obj.get_data("dbname") getoldrev = obj.get_data("getoldrev") filename = dbname.get_full_path(0) @@ -517,9 +520,32 @@ def on_ok_button1_clicked(obj): if getoldrev.get_active(): vc = VersionControl.RcsVersionControl(filename) VersionControl.RevisionSelect(database,filename,vc,load_revision) + else: + auto_save_load(filename) + +def auto_save_load(filename): + global yname, nname + + if os.path.isdir(filename): + dirname = filename + else: + dirname = os.path.dirname(filename) + autosave = "%s/autosave.gramps" % dirname + + if os.path.isfile(autosave): + q = _("An autosave file exists. Should this be loaded instead of the last saved version?") + yname = autosave + nname = filename + gnome.ui.GnomeQuestionDialog(q,autosave_query) else: read_file(filename) +def autosave_query(value): + if value == 0: + read_file(yname) + else: + read_file(nname) + #------------------------------------------------------------------------- # # @@ -529,6 +555,8 @@ def read_file(filename): base = os.path.basename(filename) if base == const.indexFile: filename = os.path.dirname(filename) + elif base == "autosave.gramps": + filename = os.path.dirname(filename) elif not os.path.isdir(filename): displayError(_("%s is not a directory") % filename) return @@ -628,7 +656,7 @@ def autosave_database(): path = database.getSavePath() filename = os.path.normpath(path) - utils.clearModified() + utils.clear_timer() filename = "%s/autosave.gramps" % (database.getSavePath()) @@ -2111,11 +2139,11 @@ def main(arg): if arg != None: read_file(arg) elif Config.lastfile != None and Config.lastfile != "" and Config.autoload: - read_file(Config.lastfile) + auto_save_load(Config.lastfile) else: DbPrompter(database,0) - if Config.autosave and Config.autosave_int != 0: + if Config.autosave_int != 0: utils.enable_autosave(autosave_database,Config.autosave_int) database.setResearcher(Config.owner)