import omni.ext

from .main_window import MainWindow

global g_main_window
g_main_window = None


def get_main_window() -> MainWindow:
    global g_main_window
    return g_main_window


class MainWindowExtension(omni.ext.IExt):
    # ext_id is current extension id. It can be used with extension manager to query additional information, like where
    # this extension is located on filesystem.
    def on_startup(self, ext_id):
        global g_main_window
        self._main_window = MainWindow()
        g_main_window = self._main_window

    def on_shutdown(self):
        global g_main_window

        if (g_main_window):
            g_main_window.destroy()

        self._main_window = None
        g_main_window = None
