Merge pull request #1050 from gaphor/simpler-help-service

Simpler services
This commit is contained in:
Dan Yeaw 2021-10-03 13:55:21 -04:00 committed by GitHub
commit 79ba7d30fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 27 deletions

View File

@ -12,17 +12,17 @@ from gaphor.i18n import translated_ui_string
class HelpService(Service, ActionProvider):
def __init__(self, session):
self.session = session
def __init__(self, main_window):
self.main_window = main_window
def shutdown(self):
pass
@property
def window(self):
return self.session.get_service("main_window").window
return self.main_window.window
@action(name="app.about")
@action(name="about")
def about(self):
builder = Gtk.Builder()
builder.add_from_string(
@ -38,7 +38,7 @@ class HelpService(Service, ActionProvider):
about.run()
about.destroy()
@action(name="app.shortcuts")
@action(name="win.shortcuts")
def shortcuts(self):
builder = Gtk.Builder()
builder.add_from_string(

View File

@ -1,18 +0,0 @@
from gaphor.abc import Service
class Session(Service):
"""Application service.
Get the active session.
"""
def __init__(self, application):
self.application = application
def shutdown(self):
pass
def get_service(self, name):
assert self.application.active_session
return self.application.active_session.get_service(name)

View File

@ -55,8 +55,8 @@ def create_hamburger_model(export_menu, tools_menu):
model.append_section(None, part)
part = Gio.Menu.new()
part.append(gettext("Keyboard Shortcuts"), "app.shortcuts")
part.append(gettext("About Gaphor"), "app.about")
part.append(gettext("Keyboard Shortcuts"), "win.shortcuts")
part.append(gettext("About Gaphor"), "win.about")
model.append_section(None, part)
return model

View File

@ -129,8 +129,6 @@ type = "virtualenv"
[tool.poetry.plugins."gaphor.appservices"]
"event_manager" = "gaphor.core.eventmanager:EventManager"
"session" = "gaphor.services.session:Session"
"help" = "gaphor.services.helpservice:HelpService"
"app_file_manager" = "gaphor.ui.appfilemanager:AppFileManager"
[tool.poetry.plugins."gaphor.services"]
@ -155,6 +153,7 @@ type = "virtualenv"
"elementeditor" = "gaphor.ui.elementeditor:ElementEditor"
"diagram_export" = "gaphor.plugins.diagramexport:DiagramExport"
"xmi_export" = "gaphor.plugins.xmiexport:XMIExport"
"help" = "gaphor.services.helpservice:HelpService"
[tool.poetry.plugins."gaphor.modelinglanguages"]
"UML" = "gaphor.UML.modelinglanguage:UMLModelingLanguage"