How to use the gaphor.core.gettext function in gaphor

To help you get started, we’ve selected a few gaphor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gaphor / gaphor / gaphor / ui / filemanager.py View on Github external
def load(self, filename):
        """Load the Gaphor model from the supplied file name.  A status window
        displays the loading progress.  The load generator updates the progress
        queue.  The loader is passed to a GIdleThread which executes the load
        generator.  If loading is successful, the filename is set."""

        queue = Queue()
        status_window: Optional[StatusWindow]
        main_window = self.main_window
        status_window = StatusWindow(
            gettext("Loading..."),
            gettext("Loading model from {filename}").format(filename=filename),
            parent=main_window.window,
            queue=queue,
        )

        try:
            loader = storage.load_generator(
                filename.encode("utf-8"), self.element_factory
            )
            worker = GIdleThread(loader, queue)

            worker.start()
            worker.wait()

            if worker.error:
                worker.reraise()
github gaphor / gaphor / gaphor / ui / filemanager.py View on Github external
"""Save the current UML model to the specified file name.  Before
        writing the model file, this will verify that there are no orphan
        references.  It will also verify that the filename has the correct
        extension.  A status window is displayed while the GIdleThread
        is executed.  This thread actually saves the model."""

        if not filename or not len(filename):
            return

        self.verify_orphans()
        filename = self.verify_filename(filename)

        main_window = self.main_window
        queue = Queue()
        status_window = StatusWindow(
            gettext("Saving..."),
            gettext("Saving model to {filename}").format(filename=filename),
            parent=main_window.window,
            queue=queue,
        )
        try:
            with open(filename.encode("utf-8"), "w") as out:
                saver = storage.save_generator(XMLWriter(out), self.element_factory)
                worker = GIdleThread(saver, queue)
                worker.start()
                worker.wait()

            if worker.error:
                worker.reraise()

            self.filename = filename
            self.event_manager.handle(FileSaved(self, filename))
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
ToolDef(
                "toolbox-interaction",
                gettext("Interaction"),
                "gaphor-interaction-symbolic",
                "N",
                item_factory=PlacementTool.new_item_factory(
                    diagram.interactions.InteractionItem,
                    UML.Interaction,
                    config_func=namespace_config,
                ),
                handle_index=SE,
            ),
        ),
    ),
    (
        gettext("States"),
        (
            ToolDef(
                "toolbox-state",
                gettext("State"),
                "gaphor-state-symbolic",
                "s",
                item_factory=PlacementTool.new_item_factory(
                    diagram.states.StateItem, UML.State, config_func=namespace_config
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-initial-pseudostate",
                gettext("Initial Pseudostate"),
                "gaphor-initial-pseudostate-symbolic",
                "S",
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
),
            ToolDef(
                "toolbox-implementation",
                gettext("Implementation"),
                "gaphor-implementation-symbolic",
                "I",
                PlacementTool.new_item_factory(diagram.classes.ImplementationItem),
            ),
        ),
    ),
    (
        gettext("Components"),
        (
            ToolDef(
                "toolbox-component",
                gettext("Component"),
                "gaphor-component-symbolic",
                "o",
                PlacementTool.new_item_factory(
                    diagram.components.ComponentItem,
                    UML.Component,
                    config_func=namespace_config,
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-artifact",
                gettext("Artifact"),
                "gaphor-artifact-symbolic",
                "h",
                PlacementTool.new_item_factory(
                    diagram.components.ArtifactItem,
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
),
            ToolDef(
                "toolbox-comment-line",
                gettext("Comment line"),
                "gaphor-comment-line-symbolic",
                "K",
                PlacementTool.new_item_factory(diagram.general.CommentLineItem),
            ),
        ),
    ),
    (
        gettext("Classes"),
        (
            ToolDef(
                "toolbox-class",
                gettext("Class"),
                "gaphor-class-symbolic",
                "c",
                item_factory=PlacementTool.new_item_factory(
                    diagram.classes.ClassItem, UML.Class, config_func=namespace_config
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-interface",
                gettext("Interface"),
                "gaphor-interface-symbolic",
                "i",
                item_factory=PlacementTool.new_item_factory(
                    diagram.classes.InterfaceItem,
                    UML.Interface,
                    config_func=namespace_config,
github gaphor / gaphor / gaphor / services / undomanager.py View on Github external
        label=gettext("_Undo"),
        icon_name="edit-undo",
        shortcut="z",
    )
    def undo_transaction(self):
        if not self._undo_stack:
            return

        if self._current_transaction:
            logger.warning("Trying to undo a transaction, while in a transaction")
            self.commit_transaction()
        transaction = self._undo_stack.pop()

        # Store stacks
        undo_stack = list(self._undo_stack)
        redo_stack = list(self._redo_stack)
        self._undo_stack = []
github gaphor / gaphor / gaphor / ui / mainwindow.py View on Github external
def create_hamburger_model(export_menu, tools_menu):
    model = Gio.Menu.new()

    part = Gio.Menu.new()
    part.append(gettext("New"), "win.file-new")
    part.append(gettext("New from Template"), "win.file-new-template")
    model.append_section(None, part)

    part = Gio.Menu.new()
    part.append(gettext("Save As..."), "win.file-save-as")
    part.append_submenu(gettext("Export"), export_menu)
    model.append_section(None, part)

    part = Gio.Menu.new()
    part.append_submenu(gettext("Tools"), tools_menu)
    model.append_section(None, part)

    part = Gio.Menu.new()
    part.append(gettext("Preferences"), "app.preferences")
    part.append(gettext("Keyboard Shortcuts"), "app.shortcuts")
    part.append(gettext("About Gaphor"), "app.about")
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-activity-final-node",
                gettext("Activity final node"),
                "gaphor-activity-final-node-symbolic",
                "f",
                item_factory=PlacementTool.new_item_factory(
                    diagram.actions.ActivityFinalNodeItem, UML.ActivityFinalNode
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-flow-final-node",
                gettext("Flow final node"),
                "gaphor-flow-final-node-symbolic",
                "w",
                item_factory=PlacementTool.new_item_factory(
                    diagram.actions.FlowFinalNodeItem, UML.FlowFinalNode
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-decision-node",
                gettext("Decision/merge node"),
                "gaphor-decision-node-symbolic",
                "g",
                item_factory=PlacementTool.new_item_factory(
                    diagram.actions.DecisionNodeItem, UML.DecisionNode
                ),
                handle_index=SE,
github gaphor / gaphor / gaphor / diagram / diagramtoolbox.py View on Github external
(
            ToolDef(
                "toolbox-lifeline",
                gettext("Lifeline"),
                "gaphor-lifeline-symbolic",
                "v",
                item_factory=PlacementTool.new_item_factory(
                    diagram.interactions.LifelineItem,
                    UML.Lifeline,
                    config_func=namespace_config,
                ),
                handle_index=SE,
            ),
            ToolDef(
                "toolbox-message",
                gettext("Message"),
                "gaphor-message-symbolic",
                "M",
                item_factory=PlacementTool.new_item_factory(
                    diagram.interactions.MessageItem
                ),
            ),
            ToolDef(
                "toolbox-interaction",
                gettext("Interaction"),
                "gaphor-interaction-symbolic",
                "N",
                item_factory=PlacementTool.new_item_factory(
                    diagram.interactions.InteractionItem,
                    UML.Interaction,
                    config_func=namespace_config,
                ),
github gaphor / gaphor / gaphor / ui / filemanager.py View on Github external
def action_new_from_template(self):
        """This menu action opens the new model from template dialog."""

        filters = [
            {"name": gettext("Gaphor Models"), "pattern": "*.gaphor"},
            {"name": gettext("All Files"), "pattern": "*"},
        ]

        file_dialog = FileDialog(
            gettext("New Gaphor Model From Template"), filters=filters
        )

        filename = file_dialog.selection

        file_dialog.destroy()

        log.debug(filename)

        if filename:
            self.load(filename)
            self.filename = None