102 lines
2.3 KiB
Python
102 lines
2.3 KiB
Python
|
|
import sys
|
|
import os.path
|
|
import paths
|
|
|
|
# Site specific directories set by configure script.
|
|
PREFIX = paths.PREFIX
|
|
BINDIR = paths.BINDIR
|
|
DATADIR = paths.DATADIR
|
|
DOCDIR = paths.DOCDIR
|
|
PYDIR = paths.PYDIR
|
|
|
|
ICONDIR = os.path.join(DATADIR, 'icons')
|
|
|
|
#: Dictionary of observers
|
|
_observers = {}
|
|
|
|
#: The current Navigator object.
|
|
navigator = None
|
|
|
|
#: The current application
|
|
application = None
|
|
|
|
#: The current project
|
|
project = None
|
|
|
|
#: The current workflow
|
|
workflow = None
|
|
|
|
#: A cfgparse/optparse options object.
|
|
options = None
|
|
|
|
def notify_observers(name):
|
|
call = "%s_changed" % name
|
|
for s in _observers.get(name, []):
|
|
getattr(s, call)(getattr(sys.modules[__name__], name))
|
|
|
|
def _add_observer(name, observer):
|
|
"""Adds observer as an observer of the named object."""
|
|
if not _observers.has_key(name):
|
|
_observers[name] = []
|
|
_observers[name].append(observer)
|
|
|
|
def _remove_observer(name, observer):
|
|
"""Removes observer as an observer of the named object."""
|
|
if not _observers.has_key(name):
|
|
return
|
|
_observers.remove(observer)
|
|
|
|
def add_navigator_observer(observer):
|
|
_add_observer('navigator', observer)
|
|
|
|
def add_project_observer(observer):
|
|
_add_observer('project', observer)
|
|
|
|
def add_workflow_observer(observer):
|
|
_add_observer('workflow', observer)
|
|
|
|
def add_application_observer(observer):
|
|
_add_observer('application', observer)
|
|
|
|
def remove_navigator_observer(observer):
|
|
_remove_observer('navigator', observer)
|
|
|
|
def remove_project_observer(observer):
|
|
_remove_observer('project', observer)
|
|
|
|
def remove_workflow_observer(observer):
|
|
_remove_observer('workflow', observer)
|
|
|
|
def remove_application_observer(observer):
|
|
_remove_observer('application', observer)
|
|
|
|
def remove_options_observer(observer):
|
|
_remove_observer('options', observer)
|
|
|
|
def set_navigator(nav):
|
|
global navigator
|
|
navigator = nav
|
|
notify_observers('navigator')
|
|
|
|
def set_application(app):
|
|
global application
|
|
application = app
|
|
notify_observers('application')
|
|
|
|
def set_project(p):
|
|
global project
|
|
project = p
|
|
notify_observers('project')
|
|
|
|
def set_workflow(wf):
|
|
global workflow
|
|
workflow = wf
|
|
notify_observers('workflow')
|
|
|
|
def set_options(opt):
|
|
global options
|
|
options = opt
|
|
notify_observers('options')
|
|
|