Exemplo n.º 1
0
class RunTerminalPlugin(gedit.Plugin):
    WINDOW_DATA_KEY = "RunTerminalPluginWindowData"

    def __init__(self):
        gedit.Plugin.__init__(self)
        self._manager = None
        self._manager_default_size = None
        ToolLibrary().set_locations(os.path.join(self.get_data_dir(), "tools"))

    def activate(self, window):
        helper = TerminalWindowHelper(self, window)
        window.set_data(self.WINDOW_DATA_KEY, helper)
        window.set_data("RunExternalToolsPluginWindowData", helper.dialog)

    def deactivate(self, window):
        window.get_data(self.WINDOW_DATA_KEY).deactivate()
        window.set_data(self.WINDOW_DATA_KEY, None)

    # def update_ui(self, window):
    #  window.get_data(self.WINDOW_DATA_KEY).update_ui()

    def create_configure_dialog(self):
        return self.open_dialog()

    def open_dialog(self):
        if not self._manager:
            self._manager = Manager(self.get_data_dir())

            if self._manager_default_size:
                self._manager.dialog.set_default_size(*self._manager_default_size)

            self._manager.dialog.connect("destroy", self.on_manager_destroy)

        window = gedit.app_get_default().get_active_window()
        self._manager.run(window)

        return self._manager.dialog

    def update_manager(self, tool):
        if not self._manager:
            return

        self._manager.tool_changed(tool, True)

    def on_manager_destroy(self, dialog):
        self._manager_default_size = [dialog.allocation.width, dialog.allocation.height]
        self._manager = None
Exemplo n.º 2
0
    def open_dialog(self):
        if not self._manager:
            self._manager = Manager(self.get_data_dir())

            if self._manager_default_size:
                self._manager.dialog.set_default_size(*self._manager_default_size)

            self._manager.dialog.connect("destroy", self.on_manager_destroy)

        window = gedit.app_get_default().get_active_window()
        self._manager.run(window)

        return self._manager.dialog