2007-03-27 08:48:49 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-20 12:07:09 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2009-02-09 10:40:58 +05:30
|
|
|
# Copyright (C) 2009 Brian G. Matherly
|
2009-02-22 02:34:09 +05:30
|
|
|
# Copyright (C) 2009 Gary Burton
|
2007-03-27 08:48:49 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2008-04-06 04:05:22 +05:30
|
|
|
# $Id$
|
|
|
|
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Provide the management of databases. This includes opening, renaming,
|
2007-04-02 09:26:30 +05:30
|
|
|
creating, and deleting of databases.
|
|
|
|
"""
|
2007-03-27 08:48:49 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
import time
|
2007-12-20 15:33:05 +05:30
|
|
|
import copy
|
2007-06-19 09:29:10 +05:30
|
|
|
import subprocess
|
2007-03-27 08:48:49 +05:30
|
|
|
from gettext import gettext as _
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# set up logging
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import logging
|
2007-04-02 09:26:30 +05:30
|
|
|
LOG = logging.getLogger(".DbManager")
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-19 01:03:52 +05:30
|
|
|
if os.sys.platform == "win32":
|
2008-06-02 02:27:11 +05:30
|
|
|
_RCS_FOUND = os.system("rcs -V >nul 2>nul") == 0
|
2008-07-17 23:40:32 +05:30
|
|
|
if _RCS_FOUND and "TZ" not in os.environ:
|
2008-06-02 02:07:56 +05:30
|
|
|
# RCS requires the "TZ" variable be set.
|
|
|
|
os.environ["TZ"] = str(time.timezone)
|
2007-06-19 01:03:52 +05:30
|
|
|
else:
|
2008-06-02 02:27:11 +05:30
|
|
|
_RCS_FOUND = os.system("rcs -V >/dev/null 2>/dev/null") == 0
|
2007-06-19 01:03:52 +05:30
|
|
|
|
2007-03-27 08:48:49 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
2007-07-09 03:50:10 +05:30
|
|
|
from gtk.gdk import ACTION_COPY
|
2007-06-23 10:01:05 +05:30
|
|
|
import pango
|
2007-03-27 08:48:49 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-06-20 12:07:09 +05:30
|
|
|
import const
|
2008-02-18 15:39:50 +05:30
|
|
|
from QuestionDialog import ErrorDialog, QuestionDialog
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
import gen.db
|
2008-11-04 09:42:51 +05:30
|
|
|
from gen.plug import PluginManager
|
2007-06-12 09:59:15 +05:30
|
|
|
import GrampsDbUtils
|
|
|
|
import Config
|
2007-07-09 06:48:04 +05:30
|
|
|
import Mime
|
2007-07-12 09:54:44 +05:30
|
|
|
from DdTargets import DdTargets
|
2007-12-19 22:09:36 +05:30
|
|
|
import RecentFiles
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2008-02-20 03:24:34 +05:30
|
|
|
_RETURN = gtk.gdk.keyval_from_name("Return")
|
|
|
|
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
|
2007-04-02 04:07:10 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2007-03-29 07:12:21 +05:30
|
|
|
DEFAULT_TITLE = _("Family Tree")
|
2007-03-27 08:48:49 +05:30
|
|
|
NAME_FILE = "name.txt"
|
|
|
|
META_NAME = "meta_data.db"
|
2007-06-21 05:06:09 +05:30
|
|
|
ARCHIVE = "rev.gramps"
|
|
|
|
ARCHIVE_V = "rev.gramps,v"
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2008-04-10 07:11:47 +05:30
|
|
|
NAME_COL = 0
|
|
|
|
PATH_COL = 1
|
|
|
|
FILE_COL = 2
|
|
|
|
DATE_COL = 3
|
|
|
|
DSORT_COL = 4
|
|
|
|
OPEN_COL = 5
|
|
|
|
STOCK_COL = 6
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2008-08-13 02:35:11 +05:30
|
|
|
RCS_BUTTON = { True : _('_Extract'), False : _('_Archive') }
|
2007-06-23 10:01:05 +05:30
|
|
|
|
2009-05-21 22:49:50 +05:30
|
|
|
class CLIDbManager(object):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
"""
|
|
|
|
Database manager without GTK functionality, allows users to create and
|
|
|
|
open databases
|
|
|
|
"""
|
|
|
|
def __init__(self, dbstate):
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.msg = None
|
|
|
|
|
|
|
|
if dbstate:
|
|
|
|
self.active = dbstate.db.get_save_path()
|
|
|
|
else:
|
|
|
|
self.active = None
|
|
|
|
|
|
|
|
self.current_names = []
|
|
|
|
self._populate_cli()
|
|
|
|
|
|
|
|
def empty(self, val):
|
2008-02-18 21:22:40 +05:30
|
|
|
"""Callback that does nothing
|
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
pass
|
|
|
|
|
2008-04-20 11:18:49 +05:30
|
|
|
def get_dbdir_summary(self, file_name):
|
|
|
|
"""
|
|
|
|
Returns (people_count, version_number) of current DB.
|
|
|
|
Returns ("Unknown", "Unknown") if invalid DB or other error.
|
|
|
|
"""
|
|
|
|
from bsddb import dbshelve, db
|
|
|
|
from gen.db import META, PERSON_TBL
|
|
|
|
env = db.DBEnv()
|
|
|
|
flags = db.DB_CREATE | db.DB_PRIVATE |\
|
|
|
|
db.DB_INIT_MPOOL | db.DB_INIT_LOCK |\
|
|
|
|
db.DB_INIT_LOG | db.DB_INIT_TXN | db.DB_THREAD
|
|
|
|
try:
|
|
|
|
env.open(file_name, flags)
|
|
|
|
except:
|
|
|
|
return "Unknown", "Unknown"
|
|
|
|
dbmap1 = dbshelve.DBShelf(env)
|
|
|
|
fname = os.path.join(file_name, META + ".db")
|
2009-01-14 08:39:03 +05:30
|
|
|
try:
|
|
|
|
dbmap1.open(fname, META, db.DB_HASH, db.DB_RDONLY)
|
|
|
|
except:
|
|
|
|
return "Unknown", "Unknown"
|
2008-04-20 11:18:49 +05:30
|
|
|
version = dbmap1.get('version', default=None)
|
|
|
|
dbmap1.close()
|
|
|
|
dbmap2 = dbshelve.DBShelf(env)
|
|
|
|
fname = os.path.join(file_name, PERSON_TBL + ".db")
|
|
|
|
try:
|
|
|
|
dbmap2.open(fname, PERSON_TBL, db.DB_HASH, db.DB_RDONLY)
|
|
|
|
except:
|
|
|
|
env.close()
|
|
|
|
return "Unknown", "Unknown"
|
|
|
|
count = len(dbmap2)
|
|
|
|
dbmap2.close()
|
|
|
|
env.close()
|
|
|
|
return (count, version)
|
|
|
|
|
|
|
|
def family_tree_summary(self):
|
|
|
|
"""
|
|
|
|
Return a list of dictionaries of the known family trees.
|
|
|
|
"""
|
|
|
|
# make the default directory if it does not exist
|
|
|
|
list = []
|
|
|
|
for item in self.current_names:
|
|
|
|
(name, dirpath, path_name, last,
|
|
|
|
tval, enable, stock_id) = item
|
|
|
|
count, version = self.get_dbdir_summary(dirpath)
|
|
|
|
retval = {}
|
|
|
|
retval["Number of people"] = count
|
|
|
|
if enable:
|
|
|
|
retval["Locked?"] = "yes"
|
|
|
|
else:
|
|
|
|
retval["Locked?"] = "no"
|
|
|
|
retval["DB version"] = version
|
|
|
|
retval["Family tree"] = name
|
|
|
|
retval["Path"] = dirpath
|
|
|
|
retval["Last accessed"] = time.strftime('%x %X',
|
|
|
|
time.localtime(tval))
|
|
|
|
list.append( retval )
|
|
|
|
return list
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
def _populate_cli(self):
|
2008-02-18 21:22:40 +05:30
|
|
|
""" Get the list of current names in the database dir
|
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
# make the default directory if it does not exist
|
|
|
|
dbdir = os.path.expanduser(Config.get(Config.DATABASE_PATH))
|
|
|
|
make_dbdir(dbdir)
|
|
|
|
|
|
|
|
self.current_names = []
|
|
|
|
|
|
|
|
for dpath in os.listdir(dbdir):
|
|
|
|
dirpath = os.path.join(dbdir, dpath)
|
|
|
|
path_name = os.path.join(dirpath, NAME_FILE)
|
|
|
|
if os.path.isfile(path_name):
|
|
|
|
name = file(path_name).readline().strip()
|
|
|
|
|
|
|
|
(tval, last) = time_val(dirpath)
|
|
|
|
(enable, stock_id) = icon_values(dirpath, self.active,
|
|
|
|
self.dbstate.db.is_open())
|
|
|
|
|
|
|
|
if (stock_id == 'gramps-lock'):
|
|
|
|
last = find_locker_name(dirpath)
|
|
|
|
|
|
|
|
self.current_names.append(
|
|
|
|
(name, os.path.join(dbdir, dpath), path_name,
|
2008-04-10 07:11:47 +05:30
|
|
|
last, tval, enable, stock_id))
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
|
|
|
self.current_names.sort()
|
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
def get_family_tree_path(self, name):
|
|
|
|
"""
|
|
|
|
Given a name, return None if name not existing or the path to the
|
|
|
|
database if it is a known database name.
|
2008-02-18 21:22:40 +05:30
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
for data in self.current_names:
|
2008-04-10 07:11:47 +05:30
|
|
|
if data[0] == name:
|
2008-11-04 09:42:51 +05:30
|
|
|
return data[1]
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
return None
|
|
|
|
|
|
|
|
def family_tree_list(self):
|
2008-02-18 21:22:40 +05:30
|
|
|
"""Return a list of name, dirname of the known family trees
|
|
|
|
"""
|
2008-04-10 07:11:47 +05:30
|
|
|
lst = [(x[0], x[1]) for x in self.current_names]
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
return lst
|
|
|
|
|
|
|
|
def __start_cursor(self, msg):
|
|
|
|
"""
|
|
|
|
Do needed things to start import visually, eg busy cursor
|
|
|
|
"""
|
|
|
|
print _('Starting Import, %s') % msg
|
|
|
|
|
|
|
|
def __end_cursor(self):
|
|
|
|
"""
|
|
|
|
Set end of a busy cursor
|
|
|
|
"""
|
|
|
|
print _('Import finished...')
|
|
|
|
|
2007-12-29 20:17:38 +05:30
|
|
|
def _create_new_db_cli(self, title=None):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
"""
|
|
|
|
Create a new database.
|
|
|
|
"""
|
|
|
|
new_path = find_next_db_dir()
|
|
|
|
|
|
|
|
os.mkdir(new_path)
|
|
|
|
path_name = os.path.join(new_path, NAME_FILE)
|
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
if title is None:
|
2008-04-10 07:11:47 +05:30
|
|
|
name_list = [ name[0] for name in self.current_names ]
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
title = find_next_db_name(name_list)
|
|
|
|
|
|
|
|
name_file = open(path_name, "w")
|
|
|
|
name_file.write(title)
|
|
|
|
name_file.close()
|
|
|
|
|
2008-04-06 03:17:49 +05:30
|
|
|
# write the version number into metadata
|
2008-04-06 02:37:21 +05:30
|
|
|
newdb = gen.db.GrampsDBDir()
|
2008-04-06 03:17:49 +05:30
|
|
|
newdb.write_version(new_path)
|
2008-04-06 02:37:21 +05:30
|
|
|
|
2008-04-06 04:00:17 +05:30
|
|
|
(tval, last) = time_val(new_path)
|
|
|
|
|
|
|
|
self.current_names.append((title, new_path, path_name,
|
2008-04-10 07:11:47 +05:30
|
|
|
last, tval, False, ""))
|
2008-01-08 03:33:57 +05:30
|
|
|
return new_path, title
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
2008-01-08 03:33:57 +05:30
|
|
|
def _create_new_db(self, title=None):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
"""
|
|
|
|
Create a new database, do extra stuff needed
|
|
|
|
"""
|
2007-12-29 20:17:38 +05:30
|
|
|
return self._create_new_db_cli(title)
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
def import_new_db(self, filename, callback):
|
|
|
|
"""
|
|
|
|
Attempt to import the provided file into a new database.
|
|
|
|
A new database will only be created if an appropriate importer was
|
|
|
|
found.
|
|
|
|
|
|
|
|
@return: A tuple of (new_path, name) for the new database
|
|
|
|
or (None, None) if no import was performed.
|
|
|
|
"""
|
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
(name, ext) = os.path.splitext(os.path.basename(filename))
|
|
|
|
format = ext[1:].lower()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
for plugin in pmgr.get_import_plugins():
|
|
|
|
if format == plugin.get_extension():
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
new_path, name = self._create_new_db(name)
|
|
|
|
|
|
|
|
# Create a new database
|
|
|
|
self.__start_cursor(_("Importing data..."))
|
|
|
|
dbclass = gen.db.GrampsDBDir
|
|
|
|
dbase = dbclass()
|
|
|
|
dbase.load(new_path, callback)
|
|
|
|
|
|
|
|
import_function = plugin.get_import_function()
|
|
|
|
import_function(dbase, filename, callback)
|
|
|
|
|
|
|
|
# finish up
|
|
|
|
self.__end_cursor()
|
|
|
|
dbase.close()
|
|
|
|
|
|
|
|
return new_path, name
|
|
|
|
return None, None
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
|
2008-01-28 16:46:54 +05:30
|
|
|
def is_locked(self, dbpath):
|
|
|
|
"""
|
|
|
|
returns True if there is a lock file in the dirpath
|
|
|
|
"""
|
|
|
|
if os.path.isfile(os.path.join(dbpath,"lock")):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def needs_recovery(self, dbpath):
|
|
|
|
"""
|
|
|
|
returns True if the database in dirpath needs recovery
|
|
|
|
"""
|
|
|
|
if os.path.isfile(os.path.join(dbpath,"need_recover")):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def break_lock(self, dbpath):
|
|
|
|
"""
|
|
|
|
Breaks the lock on a database
|
|
|
|
"""
|
|
|
|
if os.path.exists(os.path.join(dbpath, "lock")):
|
|
|
|
os.unlink(os.path.join(dbpath, "lock"))
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
class DbManager(CLIDbManager):
|
2007-04-02 04:07:10 +05:30
|
|
|
"""
|
|
|
|
Database Manager. Opens a database manager window that allows users to
|
|
|
|
create, rename, delete and open databases.
|
|
|
|
"""
|
|
|
|
|
2007-03-29 07:12:21 +05:30
|
|
|
def __init__(self, dbstate, parent=None):
|
2007-04-02 04:07:10 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the top level window from the glade description, and extracts
|
2007-04-02 04:07:10 +05:30
|
|
|
the GTK widgets that are needed.
|
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
CLIDbManager.__init__(self, dbstate)
|
2009-05-15 01:45:59 +05:30
|
|
|
self.glade = Glade()
|
|
|
|
self.top = self.glade.toplevel
|
|
|
|
|
2007-03-29 07:12:21 +05:30
|
|
|
if parent:
|
|
|
|
self.top.set_transient_for(parent)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2009-05-06 20:14:22 +05:30
|
|
|
for attr in ['connect', 'cancel', 'new', 'remove',
|
|
|
|
'dblist', 'rename', 'repair', 'rcs', 'msg']:
|
|
|
|
setattr(self, attr, self.glade.get_object(attr))
|
|
|
|
|
|
|
|
self.model = None
|
2007-04-02 09:26:30 +05:30
|
|
|
self.column = None
|
2007-06-23 10:01:05 +05:30
|
|
|
self.lock_file = None
|
2007-04-02 09:26:30 +05:30
|
|
|
self.data_to_delete = None
|
|
|
|
|
2007-03-28 09:03:11 +05:30
|
|
|
self.selection = self.dblist.get_selection()
|
2007-07-18 09:47:30 +05:30
|
|
|
self.dblist.set_rules_hint(True)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
self.__connect_signals()
|
|
|
|
self.__build_interface()
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
self._populate_model()
|
2008-04-11 18:42:11 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __connect_signals(self):
|
2007-04-02 04:07:10 +05:30
|
|
|
"""
|
|
|
|
Connects the signals to the buttons on the interface.
|
|
|
|
"""
|
2007-07-12 09:54:44 +05:30
|
|
|
ddtargets = [ DdTargets.URI_LIST.target() ]
|
|
|
|
self.top.drag_dest_set(gtk.DEST_DEFAULT_ALL, ddtargets, ACTION_COPY)
|
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
self.remove.connect('clicked', self.__remove_db)
|
|
|
|
self.new.connect('clicked', self.__new_db)
|
|
|
|
self.rename.connect('clicked', self.__rename_db)
|
|
|
|
self.repair.connect('clicked', self.__repair_db)
|
|
|
|
self.selection.connect('changed', self.__selection_changed)
|
|
|
|
self.dblist.connect('button-press-event', self.__button_press)
|
2008-02-20 03:24:34 +05:30
|
|
|
self.dblist.connect('key-press-event', self.__key_press)
|
2007-07-09 06:48:04 +05:30
|
|
|
self.top.connect('drag_data_received', self.__drag_data_received)
|
2007-09-11 03:44:33 +05:30
|
|
|
self.top.connect('drag_motion', drag_motion)
|
|
|
|
self.top.connect('drag_drop', drop_cb)
|
2007-07-09 03:50:10 +05:30
|
|
|
|
2008-06-02 02:27:11 +05:30
|
|
|
if _RCS_FOUND:
|
2007-07-12 09:54:44 +05:30
|
|
|
self.rcs.connect('clicked', self.__rcs)
|
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __button_press(self, obj, event):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Checks for a double click event. In the tree view, we want to
|
|
|
|
treat a double click as if it was OK button press. However, we have
|
|
|
|
to make sure that an item was selected first.
|
|
|
|
"""
|
2007-03-29 07:12:21 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
2008-02-20 13:43:35 +05:30
|
|
|
if self.connect.get_property('sensitive'):
|
2008-04-01 02:22:58 +05:30
|
|
|
self.top.response(gtk.RESPONSE_OK)
|
|
|
|
return True
|
2008-02-20 03:24:34 +05:30
|
|
|
return False
|
|
|
|
|
|
|
|
def __key_press(self, obj, event):
|
|
|
|
"""
|
|
|
|
Grab ENTER so it does not start editing the cell, but behaves
|
|
|
|
like double click instead
|
|
|
|
"""
|
|
|
|
if not event.state or event.state in (gtk.gdk.MOD2_MASK,):
|
|
|
|
if event.keyval in (_RETURN, _KP_ENTER):
|
2008-02-20 13:43:35 +05:30
|
|
|
if self.connect.get_property('sensitive'):
|
2008-04-01 02:22:58 +05:30
|
|
|
self.top.response(gtk.RESPONSE_OK)
|
|
|
|
return True
|
2007-03-29 07:12:21 +05:30
|
|
|
return False
|
2007-03-28 09:03:11 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __selection_changed(self, selection):
|
2008-04-11 18:42:11 +05:30
|
|
|
"""
|
|
|
|
Called when the selection is changed in the TreeView.
|
|
|
|
"""
|
2008-01-10 02:49:36 +05:30
|
|
|
self.__update_buttons(selection)
|
|
|
|
|
|
|
|
def __update_buttons(self, selection):
|
|
|
|
"""
|
|
|
|
What we are trying to detect is the selection or unselection of a row.
|
2007-04-02 09:26:30 +05:30
|
|
|
When a row is unselected, the Open, Rename, and Remove buttons
|
|
|
|
are set insensitive. If a row is selected, the rename and remove
|
|
|
|
buttons are disabled, and the Open button is disabled if the
|
|
|
|
row represents a open database.
|
|
|
|
"""
|
2008-04-12 02:30:36 +05:30
|
|
|
|
2007-04-02 09:26:30 +05:30
|
|
|
# Get the current selection
|
|
|
|
store, node = selection.get_selected()
|
2008-04-12 02:30:36 +05:30
|
|
|
|
|
|
|
# if nothing is selected
|
2007-04-02 09:26:30 +05:30
|
|
|
if not node:
|
2007-03-28 09:03:11 +05:30
|
|
|
self.connect.set_sensitive(False)
|
2007-03-29 08:51:54 +05:30
|
|
|
self.rename.set_sensitive(False)
|
2008-04-12 02:30:36 +05:30
|
|
|
self.rcs.set_sensitive(False)
|
|
|
|
self.repair.set_sensitive(False)
|
2007-04-02 09:26:30 +05:30
|
|
|
self.remove.set_sensitive(False)
|
2008-04-12 02:30:36 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
path = self.model.get_path(node)
|
|
|
|
if path is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
is_rev = len(path) > 1
|
2008-08-13 02:35:11 +05:30
|
|
|
self.rcs.set_label(RCS_BUTTON[is_rev])
|
2008-04-12 02:30:36 +05:30
|
|
|
|
2008-06-02 02:27:11 +05:30
|
|
|
if store.get_value(node, STOCK_COL) == gtk.STOCK_OPEN:
|
|
|
|
self.connect.set_sensitive(False)
|
|
|
|
if _RCS_FOUND:
|
2008-08-13 02:35:11 +05:30
|
|
|
self.rcs.set_sensitive(True)
|
2008-06-02 02:27:11 +05:30
|
|
|
else:
|
|
|
|
self.connect.set_sensitive(not is_rev)
|
|
|
|
if _RCS_FOUND and is_rev:
|
2008-08-13 02:35:11 +05:30
|
|
|
self.rcs.set_sensitive(True)
|
2008-06-02 02:27:11 +05:30
|
|
|
else:
|
2008-08-13 02:35:11 +05:30
|
|
|
self.rcs.set_sensitive(False)
|
2007-06-21 10:25:26 +05:30
|
|
|
|
2008-04-12 02:30:36 +05:30
|
|
|
if store.get_value(node, STOCK_COL) == gtk.STOCK_DIALOG_ERROR:
|
|
|
|
path = store.get_value(node, PATH_COL)
|
|
|
|
backup = os.path.join(path, "person.gbkp")
|
|
|
|
self.repair.set_sensitive(os.path.isfile(backup))
|
|
|
|
else:
|
|
|
|
self.repair.set_sensitive(False)
|
|
|
|
|
2008-07-10 02:38:36 +05:30
|
|
|
self.rename.set_sensitive(True)
|
2008-04-12 02:30:36 +05:30
|
|
|
self.remove.set_sensitive(True)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __build_interface(self):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Builds the columns for the TreeView. The columns are:
|
|
|
|
|
|
|
|
Icon, Database Name, Last Modified
|
|
|
|
|
|
|
|
The Icon column gets its data from column 6 of the database model.
|
|
|
|
It is expecting either None, or a GTK stock icon name
|
|
|
|
|
|
|
|
The Database Name column is an editable column. We connect to the
|
|
|
|
'edited' signal, so that we can change the name when the user changes
|
|
|
|
the column.
|
|
|
|
|
|
|
|
The last modified column simply displays the last modification time.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# build the database name column
|
2007-03-27 08:48:49 +05:30
|
|
|
render = gtk.CellRendererText()
|
2007-06-23 10:01:05 +05:30
|
|
|
render.set_property('ellipsize', pango.ELLIPSIZE_END)
|
2007-06-17 04:47:29 +05:30
|
|
|
render.connect('edited', self.__change_name)
|
2008-01-10 02:49:36 +05:30
|
|
|
render.connect('editing-canceled', self.__stop_edit)
|
|
|
|
render.connect('editing-started', self.__start_edit)
|
2007-03-29 07:12:21 +05:30
|
|
|
self.column = gtk.TreeViewColumn(_('Family tree name'), render,
|
2007-03-28 09:03:11 +05:30
|
|
|
text=NAME_COL)
|
2007-06-17 08:39:26 +05:30
|
|
|
self.column.set_sort_column_id(NAME_COL)
|
2007-06-23 10:01:05 +05:30
|
|
|
self.column.set_resizable(True)
|
|
|
|
self.column.set_min_width(275)
|
2007-03-28 09:03:11 +05:30
|
|
|
self.dblist.append_column(self.column)
|
2008-04-12 00:58:00 +05:30
|
|
|
self.name_renderer = render
|
2008-04-11 18:42:11 +05:30
|
|
|
|
2007-06-19 09:29:10 +05:30
|
|
|
# build the icon column
|
|
|
|
render = gtk.CellRendererPixbuf()
|
|
|
|
icon_column = gtk.TreeViewColumn(_('Status'), render,
|
|
|
|
stock_id=STOCK_COL)
|
|
|
|
self.dblist.append_column(icon_column)
|
|
|
|
|
2008-04-10 07:11:47 +05:30
|
|
|
# build the last modified cocolumn
|
2007-03-27 08:48:49 +05:30
|
|
|
render = gtk.CellRendererText()
|
|
|
|
column = gtk.TreeViewColumn(_('Last modified'), render, text=DATE_COL)
|
2007-06-17 08:39:26 +05:30
|
|
|
column.set_sort_column_id(DSORT_COL)
|
2007-03-27 08:48:49 +05:30
|
|
|
self.dblist.append_column(column)
|
2007-04-02 09:26:30 +05:30
|
|
|
|
|
|
|
# set the rules hit
|
2007-03-27 08:48:49 +05:30
|
|
|
self.dblist.set_rules_hint(True)
|
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __populate(self):
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
"""
|
|
|
|
Builds the data and the display model.
|
|
|
|
"""
|
|
|
|
self._populate_cli()
|
|
|
|
self._populate_model()
|
|
|
|
|
|
|
|
def _populate_model(self):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Builds the display model.
|
|
|
|
"""
|
2008-04-10 07:11:47 +05:30
|
|
|
self.model = gtk.TreeStore(str, str, str, str, int, bool, str)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
#use current names to set up the model
|
2007-03-28 09:35:16 +05:30
|
|
|
for items in self.current_names:
|
2009-05-06 20:14:22 +05:30
|
|
|
data = list(items[:7])
|
2008-04-10 07:11:47 +05:30
|
|
|
node = self.model.append(None, data)
|
|
|
|
for rdata in find_revisions(os.path.join(items[1], ARCHIVE_V)):
|
|
|
|
data = [ rdata[2], rdata[0], items[1], rdata[1], 0, False, "" ]
|
2007-06-21 05:06:09 +05:30
|
|
|
self.model.append(node, data)
|
2007-03-27 08:48:49 +05:30
|
|
|
self.dblist.set_model(self.model)
|
|
|
|
|
2008-01-10 02:49:36 +05:30
|
|
|
def existing_name(self, name, skippath=None):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Return true if a name is present in the model already.
|
2008-01-10 02:49:36 +05:30
|
|
|
If skippath given, the name of skippath is not considered
|
|
|
|
"""
|
|
|
|
iter = self.model.get_iter_first()
|
|
|
|
while (iter):
|
|
|
|
path = self.model.get_path(iter)
|
|
|
|
if path == skippath:
|
|
|
|
continue
|
|
|
|
itername = self.model.get_value(iter, NAME_COL)
|
|
|
|
if itername.strip() == name.strip():
|
|
|
|
return True
|
|
|
|
iter = self.model.iter_next(iter)
|
|
|
|
return False
|
|
|
|
|
2007-03-27 08:48:49 +05:30
|
|
|
def run(self):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Runs the dialog, returning None if nothing has been chosen,
|
|
|
|
or the path and name if something has been selected
|
|
|
|
"""
|
2008-04-01 02:22:58 +05:30
|
|
|
while True:
|
|
|
|
value = self.top.run()
|
|
|
|
if value == gtk.RESPONSE_OK:
|
|
|
|
store, node = self.selection.get_selected()
|
|
|
|
# don't open a locked file
|
|
|
|
if store.get_value(node, STOCK_COL) == 'gramps-lock':
|
|
|
|
self.__ask_to_break_lock(store, node)
|
|
|
|
continue
|
|
|
|
# don't open a version
|
|
|
|
if len(store.get_path(node)) > 1:
|
|
|
|
continue
|
|
|
|
if node:
|
|
|
|
self.top.destroy()
|
2009-02-22 02:34:09 +05:30
|
|
|
del self.selection
|
|
|
|
del self.name_renderer
|
2008-04-01 02:22:58 +05:30
|
|
|
return (store.get_value(node, PATH_COL),
|
|
|
|
store.get_value(node, NAME_COL))
|
|
|
|
else:
|
2007-03-27 08:48:49 +05:30
|
|
|
self.top.destroy()
|
2009-02-22 02:34:09 +05:30
|
|
|
del self.selection
|
|
|
|
del self.name_renderer
|
2008-04-01 02:22:58 +05:30
|
|
|
return None
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
def __ask_to_break_lock(self, store, node):
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
Prompts the user for permission to break the lock file that another
|
|
|
|
process has set on the file.
|
|
|
|
"""
|
2007-06-21 05:06:09 +05:30
|
|
|
path = store.get_path(node)
|
|
|
|
self.lock_file = store[path][PATH_COL]
|
|
|
|
|
2008-02-18 15:39:50 +05:30
|
|
|
QuestionDialog(
|
2007-06-21 05:06:09 +05:30
|
|
|
_("Break the lock on the '%s' database?") % store[path][0],
|
|
|
|
_("GRAMPS believes that someone else is actively editing "
|
|
|
|
"this database. You cannot edit this database while it "
|
|
|
|
"is locked. If no one is editing the database you may "
|
|
|
|
"safely break the lock. However, if someone else is editing "
|
|
|
|
"the database and you break the lock, you may corrupt the "
|
|
|
|
"database."),
|
|
|
|
_("Break lock"),
|
|
|
|
self.__really_break_lock)
|
|
|
|
|
|
|
|
def __really_break_lock(self):
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
Deletes the lock file associated with the selected database, then updates
|
|
|
|
the display appropriately.
|
|
|
|
"""
|
2007-06-21 05:06:09 +05:30
|
|
|
try:
|
2008-01-28 16:46:54 +05:30
|
|
|
self.break_lock(self.lock_file)
|
2007-06-21 05:06:09 +05:30
|
|
|
store, node = self.selection.get_selected()
|
|
|
|
dbpath = store.get_value(node, PATH_COL)
|
|
|
|
(tval, last) = time_val(dbpath)
|
|
|
|
store.set_value(node, OPEN_COL, 0)
|
|
|
|
store.set_value(node, STOCK_COL, "")
|
|
|
|
store.set_value(node, DATE_COL, last)
|
|
|
|
store.set_value(node, DSORT_COL, tval)
|
2007-09-11 03:44:33 +05:30
|
|
|
except IOError:
|
2007-06-23 10:01:05 +05:30
|
|
|
return
|
2007-06-21 05:06:09 +05:30
|
|
|
|
2008-01-10 02:49:36 +05:30
|
|
|
def __stop_edit(self, *args):
|
2008-04-12 00:58:00 +05:30
|
|
|
self.name_renderer.set_property('editable', False)
|
2008-01-10 02:49:36 +05:30
|
|
|
self.__update_buttons(self.selection)
|
|
|
|
|
|
|
|
def __start_edit(self, *args):
|
|
|
|
"""
|
|
|
|
Do no allow to click Load while changing name, to force users to finish
|
|
|
|
the action of renaming. Hack around the fact that clicking button
|
|
|
|
sends a 'editing-canceled' signal loosing the new name
|
|
|
|
"""
|
|
|
|
self.connect.set_sensitive(False)
|
2008-04-12 02:30:36 +05:30
|
|
|
self.rename.set_sensitive(False)
|
2008-01-10 02:49:36 +05:30
|
|
|
|
|
|
|
def __change_name(self, renderer_sel, path, new_text):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Change the name of the database. This is a callback from the
|
2007-04-02 09:26:30 +05:30
|
|
|
column, which has been marked as editable.
|
|
|
|
|
2007-12-19 22:09:36 +05:30
|
|
|
If the new string is empty, do nothing. Otherwise, renaming the
|
2007-04-02 09:26:30 +05:30
|
|
|
database is simply changing the contents of the name file.
|
|
|
|
"""
|
2008-01-10 02:49:36 +05:30
|
|
|
if len(new_text) > 0:
|
|
|
|
node = self.model.get_iter(path)
|
|
|
|
old_text = self.model.get_value(node, NAME_COL)
|
|
|
|
if not old_text.strip() == new_text.strip():
|
2008-10-29 20:46:43 +05:30
|
|
|
#If there is a ":" in path, then it as revision
|
|
|
|
if ":" in path :
|
2008-01-10 02:49:36 +05:30
|
|
|
self.__rename_revision(path, new_text)
|
2007-12-19 22:09:36 +05:30
|
|
|
else:
|
|
|
|
self.__rename_database(path, new_text)
|
2008-04-12 00:58:00 +05:30
|
|
|
|
|
|
|
self.name_renderer.set_property('editable', False)
|
2008-01-10 02:49:36 +05:30
|
|
|
self.__update_buttons(self.selection)
|
2007-06-21 05:06:09 +05:30
|
|
|
|
|
|
|
def __rename_revision(self, path, new_text):
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
Renames the RCS revision using the rcs command. The rcs command
|
|
|
|
is in the format of:
|
|
|
|
|
|
|
|
rcs -mREV:NEW_NAME archive
|
|
|
|
|
|
|
|
"""
|
2007-06-21 05:06:09 +05:30
|
|
|
node = self.model.get_iter(path)
|
|
|
|
db_dir = self.model.get_value(node, FILE_COL)
|
|
|
|
rev = self.model.get_value(node, PATH_COL)
|
|
|
|
archive = os.path.join(db_dir, ARCHIVE_V)
|
|
|
|
|
2008-06-02 02:07:56 +05:30
|
|
|
cmd = [ "rcs", "-x,v", "-m%s:%s" % (rev, new_text), archive ]
|
2007-06-21 05:06:09 +05:30
|
|
|
|
|
|
|
proc = subprocess.Popen(cmd, stderr = subprocess.PIPE)
|
|
|
|
status = proc.wait()
|
|
|
|
message = "\n".join(proc.stderr.readlines())
|
|
|
|
proc.stderr.close()
|
|
|
|
del proc
|
|
|
|
|
|
|
|
if status != 0:
|
|
|
|
ErrorDialog(
|
|
|
|
_("Rename failed"),
|
|
|
|
_("An attempt to rename a version failed "
|
|
|
|
"with the following message:\n\n%s") % message
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
self.model.set_value(node, NAME_COL, new_text)
|
|
|
|
|
|
|
|
def __rename_database(self, path, new_text):
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
Renames the database by writing the new value to the name.txt file
|
|
|
|
"""
|
2008-01-10 02:49:36 +05:30
|
|
|
new_text = new_text.strip()
|
2007-06-21 05:06:09 +05:30
|
|
|
node = self.model.get_iter(path)
|
|
|
|
filename = self.model.get_value(node, FILE_COL)
|
2008-01-10 02:49:36 +05:30
|
|
|
if self.existing_name(new_text, skippath=path):
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(
|
2008-01-10 02:49:36 +05:30
|
|
|
_("Could not rename the Family Tree."),
|
|
|
|
_("Family Tree already exists, choose a unique name."))
|
|
|
|
return
|
2007-06-21 05:06:09 +05:30
|
|
|
try:
|
2007-12-19 22:09:36 +05:30
|
|
|
name_file = open(filename, "r")
|
|
|
|
old_text=name_file.read()
|
|
|
|
name_file.close()
|
2007-06-21 05:06:09 +05:30
|
|
|
name_file = open(filename, "w")
|
|
|
|
name_file.write(new_text)
|
|
|
|
name_file.close()
|
2007-12-19 22:09:36 +05:30
|
|
|
RecentFiles.rename_filename(old_text, new_text)
|
2007-06-21 05:06:09 +05:30
|
|
|
self.model.set_value(node, NAME_COL, new_text)
|
|
|
|
except (OSError, IOError), msg:
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(
|
2007-06-21 05:06:09 +05:30
|
|
|
_("Could not rename family tree"),
|
|
|
|
str(msg))
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-19 09:29:10 +05:30
|
|
|
def __rcs(self, obj):
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
Callback for the RCS button. If the tree path is > 1, then we are
|
|
|
|
on an RCS revision, in which case we can check out. If not, then
|
|
|
|
we can only check in.
|
|
|
|
"""
|
2007-06-19 09:29:10 +05:30
|
|
|
store, node = self.selection.get_selected()
|
2007-06-21 05:06:09 +05:30
|
|
|
tree_path = store.get_path(node)
|
|
|
|
if len(tree_path) > 1:
|
|
|
|
parent_node = store.get_iter((tree_path[0],))
|
|
|
|
parent_name = store.get_value(parent_node, NAME_COL)
|
|
|
|
name = store.get_value(node, NAME_COL)
|
|
|
|
revision = store.get_value(node, PATH_COL)
|
|
|
|
db_path = store.get_value(node, FILE_COL)
|
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
self.__checkout_copy(parent_name, name, revision, db_path)
|
2007-06-21 05:06:09 +05:30
|
|
|
else:
|
|
|
|
base_path = self.dbstate.db.get_save_path()
|
|
|
|
archive = os.path.join(base_path, ARCHIVE)
|
2007-06-21 07:48:22 +05:30
|
|
|
check_in(self.dbstate.db, archive, None, self.__start_cursor)
|
2007-06-21 05:06:09 +05:30
|
|
|
self.__end_cursor()
|
2007-06-23 10:01:05 +05:30
|
|
|
|
|
|
|
self.__populate()
|
|
|
|
|
|
|
|
def __checkout_copy(self, parent_name, name, revision, db_path):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create a new database, then extracts a revision from RCS and
|
2007-06-23 10:01:05 +05:30
|
|
|
imports it into the db
|
|
|
|
"""
|
2008-01-08 03:33:57 +05:30
|
|
|
new_path, newname = self._create_new_db("%s : %s" % (parent_name, name))
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
self.__start_cursor(_("Extracting archive..."))
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
dbclass = gen.db.GrampsDBDir
|
2008-03-03 03:04:51 +05:30
|
|
|
dbase = dbclass()
|
2007-06-23 10:01:05 +05:30
|
|
|
dbase.load(new_path, None)
|
|
|
|
|
|
|
|
self.__start_cursor(_("Importing archive..."))
|
|
|
|
check_out(dbase, revision, db_path, None)
|
|
|
|
self.__end_cursor()
|
|
|
|
dbase.close()
|
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __remove_db(self, obj):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Callback associated with the Remove button. Get the selected
|
|
|
|
row and data, then call the verification dialog.
|
|
|
|
"""
|
|
|
|
store, node = self.selection.get_selected()
|
2007-06-21 05:06:09 +05:30
|
|
|
path = store.get_path(node)
|
|
|
|
self.data_to_delete = store[path]
|
|
|
|
|
|
|
|
if len(path) == 1:
|
2008-02-18 15:39:50 +05:30
|
|
|
QuestionDialog(
|
2008-02-29 04:02:40 +05:30
|
|
|
_("Remove the '%s' family tree?") % self.data_to_delete[0],
|
|
|
|
_("Removing this family tree will permanently destroy the data."),
|
|
|
|
_("Remove family tree"),
|
2007-06-21 05:06:09 +05:30
|
|
|
self.__really_delete_db)
|
|
|
|
else:
|
|
|
|
rev = self.data_to_delete[0]
|
|
|
|
parent = store[(path[0],)][0]
|
2008-02-18 15:39:50 +05:30
|
|
|
QuestionDialog(
|
2007-12-20 15:33:05 +05:30
|
|
|
_("Remove the '%(revision)s' version of '%(database)s'") % {
|
2007-06-25 10:27:53 +05:30
|
|
|
'revision' : rev,
|
|
|
|
'database' : parent
|
|
|
|
},
|
2007-06-21 05:06:09 +05:30
|
|
|
_("Removing this version will prevent you from "
|
2007-06-21 11:29:19 +05:30
|
|
|
"extracting it in the future."),
|
2007-06-21 05:06:09 +05:30
|
|
|
_("Remove version"),
|
|
|
|
self.__really_delete_version)
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __really_delete_db(self):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Delete the selected database. If the databse is open, close it first.
|
|
|
|
Then scan the database directory, deleting the files, and finally
|
|
|
|
removing the directory.
|
|
|
|
"""
|
2007-03-27 08:48:49 +05:30
|
|
|
|
2007-04-02 09:26:30 +05:30
|
|
|
# close the database if the user has requested to delete the
|
|
|
|
# active database
|
|
|
|
if self.data_to_delete[OPEN_COL]:
|
|
|
|
self.dbstate.no_database()
|
|
|
|
|
2007-12-19 22:09:36 +05:30
|
|
|
store, node = self.selection.get_selected()
|
|
|
|
path = store.get_path(node)
|
|
|
|
node = self.model.get_iter(path)
|
|
|
|
filename = self.model.get_value(node, FILE_COL)
|
2007-04-02 09:26:30 +05:30
|
|
|
try:
|
2007-12-19 22:09:36 +05:30
|
|
|
name_file = open(filename, "r")
|
|
|
|
file_name_to_delete=name_file.read()
|
|
|
|
name_file.close()
|
|
|
|
RecentFiles.remove_filename(file_name_to_delete)
|
2007-04-02 09:26:30 +05:30
|
|
|
for (top, dirs, files) in os.walk(self.data_to_delete[1]):
|
|
|
|
for filename in files:
|
|
|
|
os.unlink(os.path.join(top, filename))
|
|
|
|
os.rmdir(self.data_to_delete[1])
|
|
|
|
except (IOError, OSError), msg:
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(_("Could not delete family tree"),
|
2007-04-02 09:26:30 +05:30
|
|
|
str(msg))
|
2007-06-21 05:06:09 +05:30
|
|
|
# rebuild the display
|
|
|
|
self.__populate()
|
|
|
|
|
|
|
|
def __really_delete_version(self):
|
|
|
|
"""
|
|
|
|
Delete the selected database. If the databse is open, close it first.
|
|
|
|
Then scan the database directory, deleting the files, and finally
|
|
|
|
removing the directory.
|
|
|
|
"""
|
|
|
|
db_dir = self.data_to_delete[FILE_COL]
|
|
|
|
rev = self.data_to_delete[PATH_COL]
|
|
|
|
archive = os.path.join(db_dir, ARCHIVE_V)
|
|
|
|
|
2008-06-02 02:07:56 +05:30
|
|
|
cmd = [ "rcs", "-x,v", "-o%s" % rev, "-q", archive ]
|
2007-06-21 05:06:09 +05:30
|
|
|
|
|
|
|
proc = subprocess.Popen(cmd, stderr = subprocess.PIPE)
|
|
|
|
status = proc.wait()
|
|
|
|
message = "\n".join(proc.stderr.readlines())
|
|
|
|
proc.stderr.close()
|
|
|
|
del proc
|
|
|
|
|
|
|
|
if status != 0:
|
|
|
|
ErrorDialog(
|
|
|
|
_("Deletion failed"),
|
|
|
|
_("An attempt to delete a version failed "
|
|
|
|
"with the following message:\n\n%s") % message
|
|
|
|
)
|
|
|
|
|
|
|
|
# rebuild the display
|
|
|
|
self.__populate()
|
2007-04-02 09:26:30 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __rename_db(self, obj):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Start the rename process by calling the start_editing option on
|
|
|
|
the line with the cursor.
|
|
|
|
"""
|
2007-03-29 08:51:54 +05:30
|
|
|
store, node = self.selection.get_selected()
|
|
|
|
path = self.model.get_path(node)
|
2008-04-12 00:58:00 +05:30
|
|
|
self.name_renderer.set_property('editable', True)
|
2007-04-02 09:26:30 +05:30
|
|
|
self.dblist.set_cursor(path, focus_column=self.column,
|
|
|
|
start_editing=True)
|
2007-03-29 08:51:54 +05:30
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __repair_db(self, obj):
|
2007-06-12 09:59:15 +05:30
|
|
|
"""
|
2007-12-19 22:09:36 +05:30
|
|
|
Start the repair process by calling the start_editing option on
|
2007-06-12 09:59:15 +05:30
|
|
|
the line with the cursor.
|
|
|
|
"""
|
|
|
|
store, node = self.selection.get_selected()
|
|
|
|
dirname = store[node][1]
|
|
|
|
opened = store[node][5]
|
|
|
|
if opened:
|
|
|
|
self.dbstate.no_database()
|
|
|
|
|
|
|
|
# delete files that are not backup files or the .txt file
|
|
|
|
for filename in os.listdir(dirname):
|
|
|
|
if os.path.splitext(filename)[1] not in (".gbkp", ".txt"):
|
2007-06-23 10:01:05 +05:30
|
|
|
fname = os.path.join(dirname, filename)
|
2007-06-14 09:56:46 +05:30
|
|
|
os.unlink(fname)
|
2007-06-12 09:59:15 +05:30
|
|
|
|
2008-04-21 02:29:29 +05:30
|
|
|
newdb = gen.db.GrampsDBDir()
|
|
|
|
newdb.write_version(dirname)
|
|
|
|
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
dbclass = gen.db.GrampsDBDir
|
2008-03-03 03:04:51 +05:30
|
|
|
dbase = dbclass()
|
2007-06-23 10:01:05 +05:30
|
|
|
dbase.set_save_path(dirname)
|
|
|
|
dbase.load(dirname, None)
|
2007-06-21 05:06:09 +05:30
|
|
|
|
|
|
|
self.__start_cursor(_("Rebuilding database from backup files"))
|
2007-06-23 10:01:05 +05:30
|
|
|
GrampsDbUtils.Backup.restore(dbase)
|
2007-06-21 05:06:09 +05:30
|
|
|
self.__end_cursor()
|
2007-06-14 09:50:44 +05:30
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
dbase.close()
|
2007-06-13 05:01:40 +05:30
|
|
|
self.dbstate.no_database()
|
2007-06-17 04:47:29 +05:30
|
|
|
self.__populate()
|
2007-06-12 09:59:15 +05:30
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
def __start_cursor(self, msg):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Set the cursor to the busy state, and displays the associated
|
2007-06-21 05:06:09 +05:30
|
|
|
message
|
|
|
|
"""
|
|
|
|
self.msg.set_label(msg)
|
|
|
|
self.top.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
|
|
|
while (gtk.events_pending()):
|
|
|
|
gtk.main_iteration()
|
|
|
|
|
|
|
|
def __end_cursor(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Set the cursor back to normal and clears the message
|
2007-06-21 05:06:09 +05:30
|
|
|
"""
|
|
|
|
self.top.window.set_cursor(None)
|
|
|
|
self.msg.set_label("")
|
|
|
|
|
2007-06-17 04:47:29 +05:30
|
|
|
def __new_db(self, obj):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
Callback wrapper around the actual routine that creates the
|
|
|
|
new database. Catch OSError and IOError and display a warning
|
|
|
|
message.
|
|
|
|
"""
|
2008-01-10 02:49:36 +05:30
|
|
|
self.new.set_sensitive(False)
|
2007-04-02 09:26:30 +05:30
|
|
|
try:
|
2008-01-08 03:33:57 +05:30
|
|
|
self._create_new_db()
|
2007-04-02 09:26:30 +05:30
|
|
|
except (OSError, IOError), msg:
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(_("Could not create family tree"),
|
2007-04-02 09:26:30 +05:30
|
|
|
str(msg))
|
2008-01-10 02:49:36 +05:30
|
|
|
self.new.set_sensitive(True)
|
2007-04-02 09:26:30 +05:30
|
|
|
|
2008-01-08 03:33:57 +05:30
|
|
|
def _create_new_db(self, title=None):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
Create a new database, append to model
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
2008-01-08 03:33:57 +05:30
|
|
|
new_path, title = self._create_new_db_cli(title)
|
2007-03-27 08:48:49 +05:30
|
|
|
path_name = os.path.join(new_path, NAME_FILE)
|
2008-04-06 04:00:17 +05:30
|
|
|
(tval, last) = time_val(new_path)
|
2007-06-19 09:29:10 +05:30
|
|
|
node = self.model.append(None, [title, new_path, path_name,
|
2008-04-10 07:11:47 +05:30
|
|
|
last, tval, False, ''])
|
2007-03-28 09:03:11 +05:30
|
|
|
self.selection.select_iter(node)
|
|
|
|
path = self.model.get_path(node)
|
2008-04-12 02:30:36 +05:30
|
|
|
self.name_renderer.set_property('editable', True)
|
2007-04-02 09:26:30 +05:30
|
|
|
self.dblist.set_cursor(path, focus_column=self.column,
|
|
|
|
start_editing=True)
|
2008-01-08 03:33:57 +05:30
|
|
|
return new_path, title
|
2007-04-02 09:26:30 +05:30
|
|
|
|
2007-07-09 06:48:04 +05:30
|
|
|
def __drag_data_received(self, widget, context, xpos, ypos, selection,
|
|
|
|
info, rtime):
|
|
|
|
"""
|
|
|
|
Handle the reception of drag data
|
|
|
|
"""
|
2007-07-18 09:47:30 +05:30
|
|
|
drag_value = selection.data
|
2007-12-28 Benny Malengier <benny.malengier@gramps-project.org>
* src/ViewManager.py: remove unused functions, add alt actions left/right
* src/GrampsDb: deleted with _GrampsDbWriteXML.py,
_GrampsDbFactories.py, _GrampsGEDDB.py, _GrampsXMLDB.py,
__init__.py, Makefile.am, _GrampsInMemDB.py, _GrampsBSDDB.py.
No more inmemory databases
* src/GrampsDbUtils: moved here _GrampsDbWriteXML.py and _GrampsBSDDB.py
* src/plugins/ReadGrdb.py:
* src/plugins/Checkpoint.py:
* src/ObjectSelector/_ObjectSelectorWindow.py:
* src/DbManager.py:
* src/GrampsDbUtils/_WriteGrdb.py:
* src/GrampsDbUtils/__init__.py:
* src/GrampsDbUtils/_GrampsDbWRFactories.py:
* src/GrampsDbUtils/_WriteXML.py:
* src/GrampsDbUtils/Makefile.am:
* src/gramps_main.py:
* src/RecentFiles.py: recent-files-gramps.xml, don't overwrite 2.2.x data
* src/ArgHandler.py:
* src/DbLoader.py: remove unused functions
* src/Makefile.am:
* po/POTFILES.in:
* src/GrampsDbUtils/importdbdir.py: allow import of new database via cli
Remove inMem Editing, move remaining to DbUtils, fix ArgHandler
svn: r9613
2007-12-28 20:39:01 +05:30
|
|
|
fname = None
|
|
|
|
type = None
|
|
|
|
title = None
|
2007-07-09 06:48:04 +05:30
|
|
|
# we are only interested in this if it is a file:// URL.
|
2007-07-18 09:47:30 +05:30
|
|
|
if drag_value and drag_value[0:7] == "file://":
|
|
|
|
|
|
|
|
drag_value = drag_value.strip()
|
2007-07-09 06:48:04 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
fname, title = self.import_new_db(drag_value[7:], None)
|
2007-07-09 03:50:10 +05:30
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
return fname, title
|
2007-07-09 03:50:10 +05:30
|
|
|
|
2007-09-11 03:44:33 +05:30
|
|
|
def drag_motion(wid, context, xpos, ypos, time_stamp):
|
|
|
|
"""
|
|
|
|
DND callback that is called on a DND drag motion begin
|
|
|
|
"""
|
|
|
|
context.drag_status(gtk.gdk.ACTION_COPY, time_stamp)
|
|
|
|
return True
|
|
|
|
|
|
|
|
def drop_cb(wid, context, xpos, ypos, time_stamp):
|
|
|
|
"""
|
|
|
|
DND callback that finishes the DND operation
|
|
|
|
"""
|
|
|
|
context.finish(True, False, time_stamp)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2007-04-02 09:26:30 +05:30
|
|
|
def find_next_db_name(name_list):
|
|
|
|
"""
|
|
|
|
Scan the name list, looking for names that do not yet exist.
|
|
|
|
Use the DEFAULT_TITLE as the basis for the database name.
|
|
|
|
"""
|
|
|
|
i = 1
|
|
|
|
while True:
|
|
|
|
title = "%s %d" % (DEFAULT_TITLE, i)
|
|
|
|
if title not in name_list:
|
|
|
|
return title
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
def find_next_db_dir():
|
|
|
|
"""
|
|
|
|
Searches the default directory for the first available default
|
|
|
|
database name. Base the name off the current time. In all actuality,
|
|
|
|
the first should be valid.
|
|
|
|
"""
|
|
|
|
while True:
|
|
|
|
base = "%x" % int(time.time())
|
2007-06-19 09:57:32 +05:30
|
|
|
dbdir = os.path.expanduser(Config.get(Config.DATABASE_PATH))
|
|
|
|
new_path = os.path.join(dbdir, base)
|
2007-04-02 09:26:30 +05:30
|
|
|
if not os.path.isdir(new_path):
|
|
|
|
break
|
|
|
|
return new_path
|
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
def make_dbdir(dbdir):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the default database directory, as defined by dbdir
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
try:
|
|
|
|
if not os.path.isdir(dbdir):
|
|
|
|
os.makedirs(dbdir)
|
|
|
|
except (IOError, OSError), msg:
|
|
|
|
LOG.error(_("Could not make database directory: ") + str(msg))
|
|
|
|
|
2007-04-02 09:26:30 +05:30
|
|
|
def time_val(dirpath):
|
|
|
|
"""
|
|
|
|
Return the last modified time of the database. We do this by looking
|
|
|
|
at the modification time of the meta db file. If this file does not
|
|
|
|
exist, we indicate that database as never modified.
|
|
|
|
"""
|
|
|
|
meta = os.path.join(dirpath, META_NAME)
|
|
|
|
if os.path.isfile(meta):
|
|
|
|
tval = os.stat(meta)[9]
|
2007-10-29 15:11:12 +05:30
|
|
|
last = time.strftime('%x %X', time.localtime(tval))
|
2007-04-02 09:26:30 +05:30
|
|
|
else:
|
|
|
|
tval = 0
|
|
|
|
last = _("Never")
|
|
|
|
return (tval, last)
|
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
def icon_values(dirpath, active, is_open):
|
2007-04-02 09:26:30 +05:30
|
|
|
"""
|
|
|
|
If the directory path is the active path, then return values
|
|
|
|
that indicate to use the icon, and which icon to use.
|
|
|
|
"""
|
2007-06-13 05:01:40 +05:30
|
|
|
if os.path.isfile(os.path.join(dirpath,"need_recover")):
|
|
|
|
return (True, gtk.STOCK_DIALOG_ERROR)
|
2007-06-23 10:01:05 +05:30
|
|
|
elif dirpath == active and is_open:
|
2007-06-14 04:18:28 +05:30
|
|
|
return (True, gtk.STOCK_OPEN)
|
2007-06-19 01:03:52 +05:30
|
|
|
elif os.path.isfile(os.path.join(dirpath,"lock")):
|
|
|
|
return (True, 'gramps-lock')
|
2007-04-02 09:26:30 +05:30
|
|
|
else:
|
|
|
|
return (False, "")
|
|
|
|
|
2007-06-19 04:34:05 +05:30
|
|
|
def find_revisions(name):
|
2007-06-21 05:06:09 +05:30
|
|
|
"""
|
|
|
|
Finds all the revisions of the specfied RCS archive.
|
|
|
|
"""
|
2007-06-19 04:34:05 +05:30
|
|
|
import re
|
|
|
|
|
|
|
|
rev = re.compile("\s*revision\s+([\d\.]+)")
|
2008-01-20 05:15:09 +05:30
|
|
|
date = re.compile("date:\s+(\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)[-+]\d\d;")
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2008-06-02 02:27:11 +05:30
|
|
|
if not os.path.isfile(name) or not _RCS_FOUND:
|
2007-06-19 09:29:10 +05:30
|
|
|
return []
|
|
|
|
|
2008-06-02 02:07:56 +05:30
|
|
|
rlog = [ "rlog", "-x,v", "-zLT" , name ]
|
2007-06-19 04:34:05 +05:30
|
|
|
|
|
|
|
proc = subprocess.Popen(rlog, stdout = subprocess.PIPE)
|
|
|
|
proc.wait()
|
|
|
|
|
|
|
|
revlist = []
|
|
|
|
date_str = ""
|
|
|
|
rev_str = ""
|
2007-06-20 12:07:09 +05:30
|
|
|
com_str = ""
|
2007-06-19 04:34:05 +05:30
|
|
|
|
2007-06-20 12:07:09 +05:30
|
|
|
get_next = False
|
2007-06-19 04:34:05 +05:30
|
|
|
if os.path.isfile(name):
|
2007-06-20 12:07:09 +05:30
|
|
|
for line in proc.stdout:
|
|
|
|
match = rev.match(line)
|
2007-06-19 04:34:05 +05:30
|
|
|
if match:
|
2007-12-20 15:33:05 +05:30
|
|
|
rev_str = copy.copy(match.groups()[0])
|
2007-06-20 12:07:09 +05:30
|
|
|
continue
|
|
|
|
match = date.match(line)
|
|
|
|
if match:
|
2008-01-22 03:09:23 +05:30
|
|
|
date_str = time.strftime('%x %X',
|
|
|
|
time.strptime(match.groups()[0], '%Y-%m-%d %H:%M:%S'))
|
2007-06-20 12:07:09 +05:30
|
|
|
|
|
|
|
get_next = True
|
|
|
|
continue
|
|
|
|
if get_next:
|
|
|
|
get_next = False
|
|
|
|
com_str = line.strip()
|
|
|
|
revlist.append((rev_str, date_str, com_str))
|
2007-12-20 15:33:05 +05:30
|
|
|
proc.stdout.close()
|
|
|
|
del proc
|
2007-06-19 04:34:05 +05:30
|
|
|
return revlist
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
def find_locker_name(dirpath):
|
|
|
|
"""
|
2009-06-04 00:09:24 +05:30
|
|
|
Opens the lock file if it exists, reads the contexts which is "USERNAME"
|
|
|
|
and returns the contents, with correct string before "USERNAME",
|
|
|
|
so the message can be printed with correct locale.
|
2008-01-28 16:46:54 +05:30
|
|
|
If a file is encountered with errors, we return 'Unknown'
|
|
|
|
This data is displayed in the time column of the manager
|
2007-06-23 10:01:05 +05:30
|
|
|
"""
|
|
|
|
try:
|
|
|
|
fname = os.path.join(dirpath, "lock")
|
|
|
|
ifile = open(fname)
|
2009-06-04 00:09:24 +05:30
|
|
|
username = ifile.read().strip()
|
|
|
|
last = _("Locked by %s") % username
|
2007-06-23 10:01:05 +05:30
|
|
|
ifile.close()
|
|
|
|
except (OSError, IOError):
|
|
|
|
last = _("Unknown")
|
|
|
|
return last
|
|
|
|
|
|
|
|
def check_out(dbase, rev, path, callback):
|
|
|
|
"""
|
|
|
|
Checks out the revision from rcs, and loads the resulting XML file
|
|
|
|
into the database.
|
|
|
|
"""
|
2008-06-02 02:07:56 +05:30
|
|
|
co_cmd = [ "co", "-x,v", "-q%s" % rev] + [ os.path.join(path, ARCHIVE),
|
|
|
|
os.path.join(path, ARCHIVE_V)]
|
2007-06-21 05:06:09 +05:30
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
proc = subprocess.Popen(co_cmd, stderr = subprocess.PIPE)
|
2007-06-21 05:06:09 +05:30
|
|
|
status = proc.wait()
|
|
|
|
message = "\n".join(proc.stderr.readlines())
|
|
|
|
proc.stderr.close()
|
|
|
|
del proc
|
|
|
|
|
|
|
|
if status != 0:
|
|
|
|
ErrorDialog(
|
|
|
|
_("Retrieve failed"),
|
|
|
|
_("An attempt to retrieve the data failed "
|
|
|
|
"with the following message:\n\n%s") % message
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
2008-11-04 09:42:51 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
for plugin in pmgr.get_import_plugins():
|
|
|
|
if plugin.get_extension() == "gramps":
|
|
|
|
rdr = plugin.get_import_function()
|
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
xml_file = os.path.join(path, ARCHIVE)
|
2007-06-23 10:01:05 +05:30
|
|
|
rdr(dbase, xml_file, callback)
|
2007-06-21 05:06:09 +05:30
|
|
|
os.unlink(xml_file)
|
|
|
|
|
2007-06-23 10:01:05 +05:30
|
|
|
def check_in(dbase, filename, callback, cursor_func = None):
|
|
|
|
"""
|
|
|
|
Checks in the specified file into RCS
|
|
|
|
"""
|
2008-06-02 02:07:56 +05:30
|
|
|
init = [ "rcs", '-x,v', '-i', '-U', '-q', '-t-"GRAMPS database"' ]
|
|
|
|
ci_cmd = [ "ci", '-x,v', "-q", "-f" ]
|
|
|
|
archive_name = filename + ",v"
|
2009-05-06 20:14:22 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.glade = Glade(toplevel='comment')
|
|
|
|
self.top = self.glade.toplevel
|
2009-05-06 20:14:22 +05:30
|
|
|
text = self.glade.get_object('description')
|
2007-06-20 09:26:39 +05:30
|
|
|
top.run()
|
|
|
|
comment = text.get_text()
|
|
|
|
top.destroy()
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2008-06-02 02:07:56 +05:30
|
|
|
if not os.path.isfile(archive_name):
|
|
|
|
cmd = init + [archive_name]
|
|
|
|
proc = subprocess.Popen(cmd,
|
2007-06-20 10:23:30 +05:30
|
|
|
stderr = subprocess.PIPE)
|
2007-06-20 10:14:32 +05:30
|
|
|
status = proc.wait()
|
|
|
|
message = "\n".join(proc.stderr.readlines())
|
|
|
|
proc.stderr.close()
|
|
|
|
del proc
|
2008-06-02 02:07:56 +05:30
|
|
|
|
|
|
|
if status != 0:
|
|
|
|
ErrorDialog(
|
|
|
|
_("Archiving failed"),
|
|
|
|
_("An attempt to create the archive failed "
|
|
|
|
"with the following message:\n\n%s") % message
|
|
|
|
)
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
if cursor_func:
|
|
|
|
cursor_func(_("Creating data to be archived..."))
|
2009-02-09 10:40:58 +05:30
|
|
|
|
|
|
|
plugin_manager = PluginManager.get_instance()
|
|
|
|
for plugin in plugin_manager.get_export_plugins():
|
|
|
|
if plugin.get_extension() == "gramps":
|
|
|
|
export_function = plugin.get_export_function()
|
|
|
|
export_function(dbase, filename, None, callback)
|
2007-06-19 09:29:10 +05:30
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
if cursor_func:
|
|
|
|
cursor_func(_("Saving archive..."))
|
2008-06-02 02:07:56 +05:30
|
|
|
|
|
|
|
cmd = ci_cmd + ['-m%s' % comment, filename, archive_name ]
|
|
|
|
proc = subprocess.Popen(cmd,
|
|
|
|
stderr = subprocess.PIPE)
|
2007-06-23 10:01:05 +05:30
|
|
|
|
2007-12-19 22:09:36 +05:30
|
|
|
status = proc.wait()
|
2008-06-02 02:07:56 +05:30
|
|
|
message = "\n".join(proc.stderr.readlines())
|
2007-12-20 15:33:05 +05:30
|
|
|
proc.stderr.close()
|
2007-06-19 09:29:10 +05:30
|
|
|
del proc
|
2007-06-20 09:26:39 +05:30
|
|
|
|
2007-06-21 05:06:09 +05:30
|
|
|
if status != 0:
|
|
|
|
ErrorDialog(
|
|
|
|
_("Archiving failed"),
|
|
|
|
_("An attempt to archive the data failed "
|
|
|
|
"with the following message:\n\n%s") % message
|
|
|
|
)
|