Remove all use of action_manager

This commit is contained in:
Arjan Molenaar 2019-10-04 17:08:51 +02:00
parent c385e84414
commit fdb71fc53b
12 changed files with 4 additions and 48 deletions

View File

@ -26,15 +26,6 @@ The Application will look for services defined as :doc:`gaphor.services
The most notable services are:
gui_manager
The GUI manager is one of the major services that have to be loaded. The
GUI manager is responsible for loading the main window and displaying it
on the screen.
This by itself doesn't do a thing though. The Action manager
(`action_manager`) is required to maintain all actions users can perform.
Actions will be shown as menu entries for example.
file_manager
Loading and saving a model is done through this service.

View File

@ -9,7 +9,6 @@ class DiagramLayoutTestCase(TestCase):
services = TestCase.services + [
"main_window",
"properties",
"action_manager",
"diagram_layout",
"import_menu",
"export_menu",

View File

@ -11,7 +11,6 @@ class CopyServiceTestCase(TestCase):
services = TestCase.services + [
"main_window",
"action_manager",
"properties",
"undo_manager",
"import_menu",

View File

@ -132,7 +132,6 @@ class MainWindow(Service, ActionProvider):
event_manager,
component_registry,
element_factory,
action_manager,
properties,
import_menu,
export_menu,
@ -141,7 +140,6 @@ class MainWindow(Service, ActionProvider):
self.event_manager = event_manager
self.component_registry = component_registry
self.element_factory = element_factory
self.action_manager = action_manager
self.properties = properties
self.import_menu = import_menu
self.export_menu = export_menu
@ -154,7 +152,6 @@ class MainWindow(Service, ActionProvider):
self.layout = None
self.init_styling()
self.init_action_group()
def init_styling(self):
with importlib.resources.path("gaphor.ui", "layout.css") as css_file:
@ -177,23 +174,6 @@ class MainWindow(Service, ActionProvider):
em.unsubscribe(self._on_undo_manager_state_changed)
em.unsubscribe(self._new_model_content)
def init_action_group(self):
self.action_group = build_action_group(self)
for name, label in (
("file", "_File"),
("file-export", "_Export"),
("file-import", "_Import"),
("edit", "_Edit"),
("diagram", "_Diagram"),
("tools", "_Tools"),
("help", "_Help"),
):
a = Gtk.Action.new(name, label, None, None)
a.set_property("hide-if-empty", False)
self.action_group.add_action(a)
self.action_manager.register_action_provider(self)
def get_ui_component(self, name):
return self.component_registry.get(UIComponent, name)
@ -276,7 +256,7 @@ class MainWindow(Service, ActionProvider):
action_group = window_action_group(self.component_registry)
self.window.insert_action_group("win", action_group)
# self.window.add_accel_group(self.action_manager.get_accel_group())
# TODO: self.window.add_accel_group(self.action_manager.get_accel_group())
self.window.present()
@ -368,10 +348,9 @@ class Diagrams(UIComponent, ActionProvider):
title = _("Diagrams")
def __init__(self, event_manager, element_factory, action_manager, properties):
def __init__(self, event_manager, element_factory, properties):
self.event_manager = event_manager
self.element_factory = element_factory
self.action_manager = action_manager
self.properties = properties
self._notebook = None
self._page_ui_settings = None
@ -501,16 +480,13 @@ class Diagrams(UIComponent, ActionProvider):
self.event_manager.handle(DiagramPageChange(page))
def _add_ui_settings(self, page_num):
action_manager = self.action_manager
child_widget = self._notebook.get_nth_page(page_num)
self.action_manager.register_action_provider(child_widget.diagram_page)
# TODO: self.window.insert_action_group("tree-view", child_widget.diagram_page.action_group)
# TODO: self.window.insert_action_group("diagram", child_widget.diagram_page.action_group)
self._page_ui_settings = child_widget.diagram_page
def _clear_ui_settings(self):
# TODO: notebook.get_current_page()?
if self._page_ui_settings:
self.action_manager.unregister_action_provider(self._page_ui_settings)
# TODO: self.action_manager.unregister_action_provider(self._page_ui_settings)
self._page_ui_settings = None
@event_handler(DiagramShow)

View File

@ -16,7 +16,6 @@ class DiagramPageTestCase(unittest.TestCase):
"component_registry",
"element_factory",
"main_window",
"action_manager",
"properties",
"namespace",
"diagrams",

View File

@ -22,7 +22,6 @@ class DiagramToolboxTestCase(TestCase):
"component_registry",
"element_factory",
"properties",
"action_manager",
"main_window",
"import_menu",
"export_menu",

View File

@ -14,7 +14,6 @@ logging.basicConfig(level=logging.DEBUG)
class DiagramItemConnectorTestCase(TestCase):
services = TestCase.services + [
"main_window",
"action_manager",
"properties",
"namespace",
"diagrams",

View File

@ -26,7 +26,6 @@ def main_window(event_manager, element_factory):
return Diagrams(
event_manager=event_manager,
element_factory=element_factory,
action_manager=None,
properties=lambda a, b: 0,
)

View File

@ -28,7 +28,6 @@ def application():
"element_factory",
"main_window",
"properties_manager",
"action_manager",
"properties",
"namespace",
"diagrams",
@ -110,7 +109,6 @@ class HandleToolTestCase(unittest.TestCase):
"element_factory",
"main_window",
"properties_manager",
"action_manager",
"properties",
"namespace",
"diagrams",

View File

@ -15,7 +15,6 @@ def application():
"element_factory",
"properties",
"main_window",
"action_manager",
"namespace",
"diagrams",
"toolbox",

View File

@ -61,7 +61,6 @@ gaphorconvert = 'gaphor.tools.gaphorconvert:main'
"file_manager" = "gaphor.ui.filemanager:FileManager"
"recent_files" = "gaphor.ui.recentfiles:RecentFiles"
"diagram_export_manager" = "gaphor.services.diagramexportmanager:DiagramExportManager"
"action_manager" = "gaphor.services.actionmanager:ActionManager"
"main_window" = "gaphor.ui.mainwindow:MainWindow"
"preferences" = "gaphor.ui.preferences:Preferences"
"export_menu" = "gaphor.ui.menufragment:MenuFragment"

View File

@ -109,7 +109,6 @@ setup(
"element_factory = gaphor.UML.elementfactory:ElementFactory",
"file_manager = gaphor.ui.filemanager:FileManager",
"recent_files = gaphor.ui.recentfiles:RecentFiles",
"action_manager = gaphor.services.actionmanager:ActionManager",
"main_window = gaphor.ui.mainwindow:MainWindow",
"preferences = gaphor.ui.preferences:Preferences",
"export_menu = gaphor.ui.menufragment:MenuFragment",