Autosave and thumbnail improvements
svn: r672
This commit is contained in:
parent
83d69a31e7
commit
6e63aea498
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -152,99 +152,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label217</name>
|
||||
<label>Autosave interval (minutes)</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</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>save_enable</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>toggled</name>
|
||||
<handler>on_object_toggled</handler>
|
||||
<object>propertybox</object>
|
||||
<last_modification_time>Mon, 24 Dec 2001 23:25:36 GMT</last_modification_time>
|
||||
</signal>
|
||||
<label>Enable Autosaving</label>
|
||||
<active>False</active>
|
||||
<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>
|
||||
<xpad>3</xpad>
|
||||
<ypad>3</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkSpinButton</class>
|
||||
<name>save_interval</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>on_object_changed</handler>
|
||||
<object>propertybox</object>
|
||||
<last_modification_time>Mon, 24 Dec 2001 23:25:52 GMT</last_modification_time>
|
||||
</signal>
|
||||
<climb_rate>1</climb_rate>
|
||||
<digits>0</digits>
|
||||
<numeric>True</numeric>
|
||||
<update_policy>GTK_UPDATE_IF_VALID</update_policy>
|
||||
<snap>True</snap>
|
||||
<wrap>False</wrap>
|
||||
<value>5</value>
|
||||
<lower>0</lower>
|
||||
<upper>100</upper>
|
||||
<step>1</step>
|
||||
<page>10</page>
|
||||
<page_size>10</page_size>
|
||||
<child>
|
||||
<left_attach>2</left_attach>
|
||||
<right_attach>3</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>3</xpad>
|
||||
<ypad>3</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>autoload</name>
|
||||
@ -302,6 +209,70 @@
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label217</name>
|
||||
<label>Autosave interval (minutes)</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<left_attach>0</left_attach>
|
||||
<right_attach>1</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkSpinButton</class>
|
||||
<name>save_interval</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>changed</name>
|
||||
<handler>on_object_toggled</handler>
|
||||
<object>propertybox</object>
|
||||
<last_modification_time>Mon, 31 Dec 2001 16:51:59 GMT</last_modification_time>
|
||||
</signal>
|
||||
<climb_rate>1</climb_rate>
|
||||
<digits>0</digits>
|
||||
<numeric>True</numeric>
|
||||
<update_policy>GTK_UPDATE_IF_VALID</update_policy>
|
||||
<snap>True</snap>
|
||||
<wrap>False</wrap>
|
||||
<value>0</value>
|
||||
<lower>0</lower>
|
||||
<upper>100</upper>
|
||||
<step>1</step>
|
||||
<page>10</page>
|
||||
<page_size>10</page_size>
|
||||
<child>
|
||||
<left_attach>1</left_attach>
|
||||
<right_attach>2</right_attach>
|
||||
<top_attach>2</top_attach>
|
||||
<bottom_attach>3</bottom_attach>
|
||||
<xpad>3</xpad>
|
||||
<ypad>3</ypad>
|
||||
<xexpand>False</xexpand>
|
||||
<yexpand>False</yexpand>
|
||||
<xshrink>False</xshrink>
|
||||
<yshrink>False</yshrink>
|
||||
<xfill>True</xfill>
|
||||
<yfill>False</yfill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user