5934: How to fix invalid Database Path?

svn: r20455
This commit is contained in:
Benny Malengier
2012-09-27 09:18:34 +00:00
parent af0707e74c
commit c41939e966
2 changed files with 54 additions and 19 deletions

View File

@@ -1116,9 +1116,16 @@ class GrampsPreferences(ConfigureDialog):
table.set_col_spacings(6)
table.set_row_spacings(6)
self.add_entry(table,
_('Family Tree Database path'),
0, 'behavior.database-path')
self.dbpath_entry = gtk.Entry()
self.add_path_box(table,
_('Family Tree Database path'),
0, self.dbpath_entry, config.get('behavior.database-path'),
self.set_dbpath, self.select_dbpath)
#self.add_entry(table,
# _('Family Tree Database path'),
# 0, 'behavior.database-path')
self.add_checkbox(table,
_('Automatically load last family tree'),
1, 'behavior.autoload')
@@ -1151,6 +1158,30 @@ class GrampsPreferences(ConfigureDialog):
self.path_entry.set_text(val)
f.destroy()
def set_dbpath(self, *obj):
path = self.dbpath_entry.get_text().strip()
config.set('behavior.database-path', path)
def select_dbpath(self, *obj):
f = gtk.FileChooserDialog(
_("Select database directory"),
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_CANCEL,
gtk.STOCK_APPLY,
gtk.RESPONSE_OK))
dbpath = config.get('behavior.database-path')
if not dbpath:
dbpath = os.path.join(os.environ['HOME'], '.gramps','grampsdb')
f.set_current_folder(os.path.dirname(dbpath))
status = f.run()
if status == gtk.RESPONSE_OK:
val = Utils.get_unicode_path_from_file_chooser(f.get_filename())
if val:
self.dbpath_entry.set_text(val)
f.destroy()
def update_idformat_entry(self, obj, constant):
config.set(constant, unicode(obj.get_text()))
self.dbstate.db.set_prefixes(