2006-05-22 Alex Roitman <shura@gramps-project.org>
* src/ArgHandler.py (need_gui): Add method. * src/ViewManager.py: Move statusbar notification from gramps_main. * src/gramps_main.py: Remove unused methods, handle ArgHandler better. svn: r6749
This commit is contained in:
parent
9056f20f16
commit
9fa0c2bd12
@ -1,3 +1,8 @@
|
|||||||
|
2006-05-22 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/ArgHandler.py (need_gui): Add method.
|
||||||
|
* src/ViewManager.py: Move statusbar notification from gramps_main.
|
||||||
|
* src/gramps_main.py: Remove unused methods, handle ArgHandler better.
|
||||||
|
|
||||||
2006-05-21 Don Allingham <don@gramps-project.org>
|
2006-05-21 Don Allingham <don@gramps-project.org>
|
||||||
* src/ViewManager.py: handle export, import, and save as if
|
* src/ViewManager.py: handle export, import, and save as if
|
||||||
database does not exist, yet UIManager still wants to call them.
|
database does not exist, yet UIManager still wants to call them.
|
||||||
|
@ -58,9 +58,7 @@ import Utils
|
|||||||
from PluginUtils import Report, Tool, cl_list, cli_tool_list
|
from PluginUtils import Report, Tool, cl_list, cli_tool_list
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
|
||||||
# ArgHandler
|
# ArgHandler
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class ArgHandler:
|
class ArgHandler:
|
||||||
"""
|
"""
|
||||||
@ -104,16 +102,15 @@ class ArgHandler:
|
|||||||
self.imports = []
|
self.imports = []
|
||||||
|
|
||||||
self.parse_args()
|
self.parse_args()
|
||||||
self.handle_args()
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
|
||||||
# Argument parser: sorts out given arguments
|
# Argument parser: sorts out given arguments
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def parse_args(self):
|
def parse_args(self):
|
||||||
"""
|
"""
|
||||||
Fill in lists with open, exports, imports, and actions options.
|
Fill in lists with open, exports, imports, and actions options.
|
||||||
|
|
||||||
|
Any parsing errors lead to abort via os._exit(1).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -122,15 +119,16 @@ class ArgHandler:
|
|||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
# return without filling anything if we could not parse the args
|
# return without filling anything if we could not parse the args
|
||||||
print "Error parsing arguments: %s " % self.args[1:]
|
print "Error parsing arguments: %s " % self.args[1:]
|
||||||
return
|
os._exit(1)
|
||||||
|
|
||||||
if leftargs:
|
if leftargs:
|
||||||
# if there were an argument without option, use it as a file to
|
# if there were an argument without option,
|
||||||
# open and return
|
# use it as a file to open and return
|
||||||
self.open_gui = leftargs[0]
|
self.open_gui = leftargs[0]
|
||||||
print "Trying to open: %s ..." % leftargs[0]
|
print "Trying to open: %s ..." % leftargs[0]
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Go over all given option and place them into appropriate lists
|
||||||
for opt_ix in range(len(options)):
|
for opt_ix in range(len(options)):
|
||||||
o,v = options[opt_ix]
|
o,v = options[opt_ix]
|
||||||
if o in ( '-O', '--open'):
|
if o in ( '-O', '--open'):
|
||||||
@ -250,10 +248,31 @@ class ArgHandler:
|
|||||||
self.actions.append((action,options_str))
|
self.actions.append((action,options_str))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
# Determine the need for GUI
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def need_gui(self):
|
||||||
|
"""
|
||||||
|
Determine whether we need a GUI session for the given tasks.
|
||||||
|
"""
|
||||||
|
if self.open_gui:
|
||||||
|
# No-option argument, definitely GUI
|
||||||
|
return True
|
||||||
|
|
||||||
|
# If we have data to work with:
|
||||||
|
if (self.open or self.imports):
|
||||||
|
if (self.exports or self.actions):
|
||||||
|
# have both data and what to do with it => no GUI
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
# data given, but no action/export => GUI
|
||||||
|
return True
|
||||||
|
|
||||||
|
# No data, can only do GUI here
|
||||||
|
return True
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
# Overall argument handler:
|
# Overall argument handler:
|
||||||
# sorts out the sequence and details of operations
|
# sorts out the sequence and details of operations
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def handle_args(self):
|
def handle_args(self):
|
||||||
"""
|
"""
|
||||||
|
@ -416,6 +416,11 @@ class ViewManager:
|
|||||||
self.build_report_menu()
|
self.build_report_menu()
|
||||||
self.fileactions.set_sensitive(True)
|
self.fileactions.set_sensitive(True)
|
||||||
self.uistate.widget.set_sensitive(True)
|
self.uistate.widget.set_sensitive(True)
|
||||||
|
Config.client.notify_add("/apps/gramps/interface/statusbar",
|
||||||
|
self.statusbar_key_update)
|
||||||
|
|
||||||
|
def statusbar_key_update(self,client,cnxn_id,entry,data):
|
||||||
|
self.uistate.modify_statusbar()
|
||||||
|
|
||||||
def post_init_interface(self):
|
def post_init_interface(self):
|
||||||
# Showing the main window is deferred so that
|
# Showing the main window is deferred so that
|
||||||
|
@ -20,16 +20,24 @@
|
|||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Python modules
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
from gettext import gettext as _
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger(".")
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GTK+/GNOME modules
|
# GTK+/GNOME modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
log = logging.getLogger(".")
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -46,13 +54,14 @@ import TipOfDay
|
|||||||
import DataViews
|
import DataViews
|
||||||
from Mime import mime_type_is_defined
|
from Mime import mime_type_is_defined
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
from gettext import gettext as _
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# helper functions
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
iconpaths = [const.image_dir,"."]
|
iconpaths = [const.image_dir,"."]
|
||||||
|
|
||||||
|
|
||||||
import platform
|
|
||||||
|
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
person_icon = "person.png"
|
person_icon = "person.png"
|
||||||
relation_icon = "relation.png"
|
relation_icon = "relation.png"
|
||||||
@ -132,7 +141,11 @@ def build_user_paths():
|
|||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Main Gramps class
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
class Gramps:
|
class Gramps:
|
||||||
"""
|
"""
|
||||||
Main class corresponding to a running gramps process.
|
Main class corresponding to a running gramps process.
|
||||||
@ -169,7 +182,6 @@ class Gramps:
|
|||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
register_stock_icons()
|
register_stock_icons()
|
||||||
|
|
||||||
state = GrampsDb.DbState()
|
state = GrampsDb.DbState()
|
||||||
@ -178,28 +190,23 @@ class Gramps:
|
|||||||
self.vm.register_view(view)
|
self.vm.register_view(view)
|
||||||
|
|
||||||
self.vm.init_interface()
|
self.vm.init_interface()
|
||||||
ArgHandler.ArgHandler(state,self.vm,args)
|
|
||||||
|
# Depending on the nature of this session,
|
||||||
|
# we may need to change the order of operation
|
||||||
|
ah = ArgHandler.ArgHandler(state,self.vm,args)
|
||||||
|
if ah.need_gui():
|
||||||
|
self.vm.post_init_interface()
|
||||||
|
ah.handle_args()
|
||||||
|
else:
|
||||||
|
ah.handle_args()
|
||||||
self.vm.post_init_interface()
|
self.vm.post_init_interface()
|
||||||
|
|
||||||
state.db.request_rebuild()
|
state.db.request_rebuild()
|
||||||
state.change_active_person(state.db.get_default_person())
|
state.change_active_person(state.db.get_default_person())
|
||||||
|
|
||||||
# Don't show main window until ArgHandler is done.
|
|
||||||
# This prevents a window from annoyingly popping up when
|
|
||||||
# the command line args are sufficient to operate without it.
|
|
||||||
Config.client.notify_add("/apps/gramps/researcher",
|
|
||||||
self.researcher_key_update)
|
|
||||||
Config.client.notify_add("/apps/gramps/interface/statusbar",
|
|
||||||
self.statusbar_key_update)
|
|
||||||
|
|
||||||
if Config.get(Config.USE_TIPS):
|
if Config.get(Config.USE_TIPS):
|
||||||
TipOfDay.TipOfDay(self.vm.uistate)
|
TipOfDay.TipOfDay(self.vm.uistate)
|
||||||
|
|
||||||
## # FIXME: THESE will have to be added (ViewManager?)
|
|
||||||
## # once bookmarks work again
|
|
||||||
## self.db.set_researcher(GrampsCfg.get_researcher())
|
|
||||||
## self.db.connect('person-delete',self.on_remove_bookmark)
|
|
||||||
## self.db.connect('person-update',self.on_update_bookmark)
|
|
||||||
|
|
||||||
def welcome(self):
|
def welcome(self):
|
||||||
if not Config.get(Config.BETAWARN):
|
if not Config.get(Config.BETAWARN):
|
||||||
@ -221,17 +228,3 @@ class Gramps:
|
|||||||
Config.set(Config.BETAWARN,True)
|
Config.set(Config.BETAWARN,True)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def researcher_key_update(self,client,cnxn_id,entry,data):
|
|
||||||
pass
|
|
||||||
# self.db.set_person_id_prefix(Config.get(Config.IPREFIX))
|
|
||||||
# self.db.set_family_id_prefix(Config.get(Config.FPREFIX))
|
|
||||||
# self.db.set_source_id_prefix(Config.get(Config.SPREFIX))
|
|
||||||
# self.db.set_object_id_prefix(Config.get(Config.OPREFIX))
|
|
||||||
# self.db.set_place_id_prefix(Config.get(Config.PPREFIX))
|
|
||||||
# self.db.set_event_id_prefix(Config.get(Config.EPREFIX))
|
|
||||||
|
|
||||||
def statusbar_key_update(self,client,cnxn_id,entry,data):
|
|
||||||
self.vm.uistate.modify_statusbar()
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user