* src/Viewmanager.py: prompt before abandoning changes; enable autobackup

* src/GrampsCfg.py: enable autobackup
	* src/Config/_GrampsConfigKeys.py: enable autobackup
	* data/gramps.schemas: enable autobackup


svn: r7621
This commit is contained in:
Don Allingham 2006-11-13 04:50:38 +00:00
parent feeae34b01
commit b5ac0d52fc
5 changed files with 48 additions and 9 deletions

View File

@ -1,5 +1,8 @@
2006-11-12 Don Allingham <don@gramps-project.org> 2006-11-12 Don Allingham <don@gramps-project.org>
* src/Viewmanager.py: prompt before abandoning changes * src/Viewmanager.py: prompt before abandoning changes; enable autobackup
* src/GrampsCfg.py: enable autobackup
* src/Config/_GrampsConfigKeys.py: enable autobackup
* data/gramps.schemas: enable autobackup
* src/GrampsDb/_WriteGedcom.py: RepoRefs don't have a privacy flag * src/GrampsDb/_WriteGedcom.py: RepoRefs don't have a privacy flag
2006-11-11 Don Allingham <don@gramps-project.org> 2006-11-11 Don Allingham <don@gramps-project.org>

View File

@ -159,6 +159,18 @@
</locale> </locale>
</schema> </schema>
<schema>
<key>/schemas/apps/gramps/behavior/enable-autobackup</key>
<applyto>/apps/gramps/behavior/enable-autobackup</applyto>
<owner>gramps</owner>
<type>bool</type>
<default>1</default>
<locale name="C">
<short>Backup database on exit</short>
<long>If set to True, an XML backup of the database is created on exit.</long>
</locale>
</schema>
<schema> <schema>
<key>/schemas/apps/gramps/behavior/spellcheck</key> <key>/schemas/apps/gramps/behavior/spellcheck</key>
<applyto>/apps/gramps/behavior/spellcheck</applyto> <applyto>/apps/gramps/behavior/spellcheck</applyto>

View File

@ -32,6 +32,7 @@ HIDE_EP_MSG = ('preferences','hide-ep-msg', 0)
LAST_VIEW = ('preferences','last-view', 1) LAST_VIEW = ('preferences','last-view', 1)
USE_LAST_VIEW = ('preferences','use-last-view', 1) USE_LAST_VIEW = ('preferences','use-last-view', 1)
FAMILY_SIBLINGS = ('preferences','family-siblings', 0) FAMILY_SIBLINGS = ('preferences','family-siblings', 0)
ENABLE_AUTOBACKUP = ('behavior','enable-autobackup', 1)
AUTOLOAD = ('behavior','autoload', 0) AUTOLOAD = ('behavior','autoload', 0)
SPELLCHECK = ('behavior','spellcheck', 0) SPELLCHECK = ('behavior','spellcheck', 0)
BETAWARN = ('behavior','betawarn', 0) BETAWARN = ('behavior','betawarn', 0)
@ -96,6 +97,7 @@ default_value = {
USE_LAST_VIEW : True, USE_LAST_VIEW : True,
FAMILY_SIBLINGS : True, FAMILY_SIBLINGS : True,
AUTOLOAD : False, AUTOLOAD : False,
ENABLE_AUTOBACKUP : True,
SPELLCHECK : False, SPELLCHECK : False,
BETAWARN : False, BETAWARN : False,
WELCOME : 100, WELCOME : 100,

View File

@ -490,22 +490,24 @@ class GrampsPreferences(ManagedWindow.ManagedWindow):
table.set_col_spacings(6) table.set_col_spacings(6)
table.set_row_spacings(6) table.set_row_spacings(6)
self.add_checkbox(table, _('Automatically backup database on exit'),
0, Config.ENABLE_AUTOBACKUP)
self.add_checkbox(table, _('Automatically load last database'), self.add_checkbox(table, _('Automatically load last database'),
0, Config.AUTOLOAD) 1, Config.AUTOLOAD)
self.add_checkbox(table, _('Enable database transactions'), self.add_checkbox(table, _('Enable database transactions'),
1, Config.TRANSACTIONS) 2, Config.TRANSACTIONS)
self.add_checkbox(table, _('Add default source on import'), self.add_checkbox(table, _('Add default source on import'),
2, Config.DEFAULT_SOURCE) 3, Config.DEFAULT_SOURCE)
self.add_checkbox(table, _('Enable spelling checker'), self.add_checkbox(table, _('Enable spelling checker'),
3, Config.SPELLCHECK) 4, Config.SPELLCHECK)
self.add_checkbox(table, _('Display Tip of the Day'), self.add_checkbox(table, _('Display Tip of the Day'),
4, Config.USE_TIPS) 5, Config.USE_TIPS)
self.add_checkbox(table, _('Use shading in Relationship View'), self.add_checkbox(table, _('Use shading in Relationship View'),
5, Config.RELATION_SHADE) 6, Config.RELATION_SHADE)
self.add_checkbox(table, _('Display edit buttons on Relationship View'), self.add_checkbox(table, _('Display edit buttons on Relationship View'),
6, Config.RELEDITBTN) 7, Config.RELEDITBTN)
self.add_checkbox(table, _('Remember last view displayed'), self.add_checkbox(table, _('Remember last view displayed'),
7, Config.USE_LAST_VIEW) 8, Config.USE_LAST_VIEW)
return table return table

View File

@ -452,6 +452,7 @@ class ViewManager:
self.uistate.push_message(self.state,_('Ready')) self.uistate.push_message(self.state,_('Ready'))
def quit(self, *obj): def quit(self, *obj):
self.backup()
self.state.db.close() self.state.db.close()
(width, height) = self.window.get_size() (width, height) = self.window.get_size()
Config.set(Config.WIDTH, width) Config.set(Config.WIDTH, width)
@ -459,6 +460,25 @@ class ViewManager:
Config.sync() Config.sync()
gtk.main_quit() gtk.main_quit()
def backup(self):
import GrampsDb
if self.state.db.undoindex > 0:
bpath = self.state.db.get_save_path()
name = os.path.splitext(bpath)
backup = name[0] + ".backup.gramps"
if os.path.exists(backup):
os.rename(backup,backup + ".old")
self.uistate.set_busy_cursor(1)
self.uistate.progress.show()
self.uistate.push_message(self.state, _("Autobackup..."))
writer = GrampsDb.XmlWriter(self.state.db, self.uistate.pulse_progressbar, 0, 1)
writer.write(backup)
self.uistate.set_busy_cursor(0)
self.uistate.progress.hide()
def abort(self,obj=None): def abort(self,obj=None):
""" """
Abandon changes and quit. Abandon changes and quit.