From 0aba9e8e2b069c5cb879e6a731a5cf29c39ba6ff Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 11 Dec 2007 02:49:58 +0000 Subject: [PATCH] * src/ViewManager.py: exposed a private method via a new method, post_load_newdb() * src/ArgHandler.py: made ArgHandler.handle_args() return filename, and filetype, if commandline or recentfile * src/gramps_main.py: handles return values from AH.handle_args() 2007-12-10 Douglas S. Blank svn: r9486 --- ChangeLog | 7 +++++++ src/ArgHandler.py | 35 ++++++++++++++++++----------------- src/ViewManager.py | 11 +++++++++++ src/gramps_main.py | 5 ++++- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4cfc94ab..e93e1be32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-12-10 Douglas S. Blank + * src/ViewManager.py: exposed a private method via a new method, + post_load_newdb() + * src/ArgHandler.py: made ArgHandler.handle_args() return filename, + and filetype, if commandline or recentfile + * src/gramps_main.py: handles return values from AH.handle_args() + 2007-12-10 Douglas S. Blank * src/DbManager.py: fixed issue in breaking lock on lock which has already been removed diff --git a/src/ArgHandler.py b/src/ArgHandler.py index 1f43b8b13..c5ea2635a 100644 --- a/src/ArgHandler.py +++ b/src/ArgHandler.py @@ -312,13 +312,13 @@ class ArgHandler: print "Type: GEDCOM file" elif filetype == const.APP_GRAMPS_XML: print "Type: GRAMPS XML database" - + try: - self.vm.read_recent_file(filename, filetype) + self.vm.db_loader.read_file(filename, filetype) print "Opened successfully!" success = True except: - print "Cannot open %s. Exiting..." + print "Cannot open '%s'. Exiting..." % filename elif filetype in (const.APP_GRAMPS_PKG,): QuestionDialog.OkDialog( _("Opening non-native format"), @@ -350,11 +350,10 @@ class ArgHandler: sys.exit(1) if success: # Add the file to the recent items - #RecentFiles.recent_files(filename,filetype) - pass + RecentFiles.recent_files(filename,const.APP_GRAMPS) else: sys.exit(1) - return + return (filename, filetype) if self.open: # Filename to open was given. Open it natively (grdb or any of @@ -430,17 +429,19 @@ class ArgHandler: print "Exiting." sys.exit(0) - ## read recent file is broken in GRAMPS 30 ! DISABLE - ##elif Config.get(Config.RECENT_FILE) and Config.get(Config.AUTOLOAD): - ## rf = Config.get(Config.RECENT_FILE) - ## - ## if os.path.isfile(rf): - ## filetype = Mime.get_type(rf) - ## self.vm.read_recent_file(rf, filetype) - ## elif os.path.isdir(rf): - ## if os.path.isfile(os.path.join(rf, "name.txt")) and \ - ## not os.path.isfile(os.path.join(rf,"need_recover")): - ## self.vm.read_recent_file(rf, 'x-directory/normal') + ## read recent file is broken in GRAMPS 30 ! DISABLE + elif Config.get(Config.RECENT_FILE) and Config.get(Config.AUTOLOAD): + filename = Config.get(Config.RECENT_FILE) + self.vm.db_loader.read_file(filename, const.APP_GRAMPS) + return (filename, const.APP_GRAMPS) + + #if os.path.isfile(rf): + # filetype = Mime.get_type(rf) + # self.vm.read_recent_file(rf, filetype) + #elif os.path.isdir(rf): + # if os.path.isfile(os.path.join(rf, "name.txt")) and \ + # not os.path.isfile(os.path.join(rf,"need_recover")): + # self.vm.read_recent_file(rf, 'x-directory/normal') #------------------------------------------------------------------------- # diff --git a/src/ViewManager.py b/src/ViewManager.py index e65a49065..6c9f5d149 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -575,6 +575,17 @@ class ViewManager: if not self.state.db.is_open(): self.__open_activate(None) + def post_load_newdb(self, filename, filetype): + # Attempt to figure out the database title + path = os.path.join(filename, "name.txt") + try: + ifile = open(path) + title = ifile.readline().strip() + ifile.close() + except: + title = filename + self.__post_load_newdb(filename, filetype, title) + def __do_load_plugins(self): """ Loads the plugins at initialization time. We load the document diff --git a/src/gramps_main.py b/src/gramps_main.py index 831e71411..273c028d7 100644 --- a/src/gramps_main.py +++ b/src/gramps_main.py @@ -248,8 +248,11 @@ class Gramps: # we may need to change the order of operation ah = ArgHandler.ArgHandler(state, self.vm, args) if ah.need_gui(): - ah.handle_args() + retval = ah.handle_args() self.vm.post_init_interface() + if retval: + filename, filetype = retval + self.vm.post_load_newdb(filename, filetype) else: ah.handle_args() self.vm.post_init_interface()