Skip to content

Commit

Permalink
Application is a normal class again
Browse files Browse the repository at this point in the history
no longer a special singleton thingy.
  • Loading branch information
amolenaar committed Jan 26, 2020
1 parent 2b8cd14 commit 9eb3a84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions gaphor/application.py
Expand Up @@ -44,7 +44,7 @@ class ComponentLookupError(LookupError):
pass


class _Application(Service, ActionProvider):
class Application(Service, ActionProvider):
"""
The Gaphor application is started from the gaphor.ui module.
Expand All @@ -55,21 +55,15 @@ class _Application(Service, ActionProvider):
are registered in the "component_registry" service.
"""

def __init__(self):
def __init__(self, appservices=None):
self.active_session: Optional[Session] = None
self.sessions: Set[Session] = set()
self._services_by_name: Dict[str, Service] = {}

def __call__(self, appservices=None):
"""Mimic object instantiation behavior."""
assert not self._services_by_name
uninitialized_services = load_services("gaphor.appservices", appservices)
self._services_by_name = init_services(uninitialized_services, application=self)

transaction.subscribers.add(self._transaction_proxy)

return self

def new_session(self, services=None):
"""
Initialize an application session.
Expand Down Expand Up @@ -233,7 +227,3 @@ def init(name, cls):
init(name, cls)

return ready


# Make sure there is only one!
Application = _Application()
4 changes: 2 additions & 2 deletions gaphor/ui/__init__.py
Expand Up @@ -10,7 +10,7 @@

import gi

from gaphor.application import Application, _Application
from gaphor.application import Application
from gaphor.core import event_handler
from gaphor.event import ActiveSessionChanged, SessionShutdown
from gaphor.ui.actiongroup import apply_application_actions
Expand Down Expand Up @@ -84,7 +84,7 @@ def on_session_shutdown(event):


def run(args):
application: Optional[_Application] = None
application: Optional[Application] = None

def new_session():
assert application
Expand Down

0 comments on commit 9eb3a84

Please sign in to comment.