def main(): try: if sys.platform.startswith('win'): # Load theming under Windows _windows_load_theme() itheme: Gtk.IconTheme = Gtk.IconTheme.get_default() itheme.append_search_path(os.path.abspath(icons())) itheme.append_search_path( os.path.abspath(os.path.join(get_debugger_data_dir(), "icons"))) itheme.rescan_if_needed() # Load Builder and Window builder = get_debugger_builder() main_window: Window = builder.get_object("main_window") main_window.set_role("SkyTemple Script Engine Debugger") GLib.set_application_name("SkyTemple Script Engine Debugger") GLib.set_prgname("skytemple_ssb_debugger") # TODO: Deprecated but the only way to set the app title on GNOME...? main_window.set_wmclass("SkyTemple Script Engine Debugger", "SkyTemple Script Engine Debugger") # Load main window + controller MainController(builder, main_window, StandaloneDebuggerControlContext(main_window)) Gtk.main() finally: if EmulatorThread.instance(): EmulatorThread.instance().stop()
def main(): path = os.path.abspath(os.path.dirname(__file__)) if sys.platform.startswith('win'): # Load theming under Windows _load_theme() # Solve issue #12 try: from skytemple_files.common.platform_utils.win import win_set_error_mode win_set_error_mode() except BaseException: # This really shouldn't fail, but it's not important enough to crash over pass if sys.platform.startswith('darwin'): # Load theming under macOS _load_theme() # The search path is wrong if SkyTemple is executed as an .app bundle if getattr(sys, 'frozen', False): path = os.path.dirname(sys.executable) itheme: Gtk.IconTheme = Gtk.IconTheme.get_default() itheme.append_search_path(os.path.abspath(icons())) itheme.append_search_path(os.path.abspath(os.path.join(data_dir(), "icons"))) itheme.rescan_if_needed() # Load CSS style_provider = Gtk.CssProvider() with open(os.path.join(path, "skytemple_randomizer.css"), 'rb') as f: css = f.read() style_provider.load_from_data(css) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # Load Builder and Window builder = Gtk.Builder() builder.add_from_file(os.path.join(path, "skytemple_randomizer.glade")) main_window: Window = builder.get_object("main_window") main_window.set_role("SkyTemple Randomizer") GLib.set_application_name("SkyTemple Randomizer") GLib.set_prgname("skytemple_randomizer") # TODO: Deprecated but the only way to set the app title on GNOME...? main_window.set_wmclass("SkyTemple Randomizer", "SkyTemple Randomizer") # Load main window + controller MainController(builder, main_window) main_window.present() main_window.set_icon_name('skytemple_randomizer') Gtk.main()
def main(): # TODO: Gtk.Application: https://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html path = os.path.abspath(os.path.dirname(__file__)) # Load settings settings = SkyTempleSettingsStore() if sys.platform.startswith('win'): # Load theming under Windows _load_theme(settings) # Solve issue #12 try: from skytemple_files.common.platform_utils.win import win_set_error_mode win_set_error_mode() except BaseException: # This really shouldn't fail, but it's not important enough to crash over pass if sys.platform.startswith('darwin'): # Load theming under macOS _load_theme(settings) # The search path is wrong if SkyTemple is executed as an .app bundle if getattr(sys, 'frozen', False): path = os.path.dirname(sys.executable) if sys.platform.startswith('linux') and gdk_backend() == GDK_BACKEND_BROADWAY: gtk_settings = Gtk.Settings.get_default() gtk_settings.set_property("gtk-theme-name", 'Arc-Dark') gtk_settings.set_property("gtk-application-prefer-dark-theme", True) itheme: Gtk.IconTheme = Gtk.IconTheme.get_default() itheme.append_search_path(os.path.abspath(icons())) itheme.append_search_path(os.path.abspath(os.path.join(data_dir(), "icons"))) itheme.append_search_path(os.path.abspath(os.path.join(get_debugger_data_dir(), "icons"))) itheme.rescan_if_needed() # Load Builder and Window builder = make_builder(os.path.join(path, "skytemple.glade")) main_window: Window = builder.get_object("main_window") main_window.set_role("SkyTemple") GLib.set_application_name("SkyTemple") GLib.set_prgname("skytemple") # TODO: Deprecated but the only way to set the app title on GNOME...? main_window.set_wmclass("SkyTemple", "SkyTemple") # Load CSS style_provider = Gtk.CssProvider() with open(os.path.join(path, "skytemple.css"), 'rb') as f: css = f.read() style_provider.load_from_data(css) Gtk.StyleContext.add_provider_for_screen( Gdk.Screen.get_default(), style_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION ) # Load async task runner thread AsyncTaskRunner.instance() # Init. core events event_manager = EventManager.instance() if settings.get_integration_discord_enabled(): try: from skytemple.core.events.impl.discord import DiscordPresence discord_listener = DiscordPresence() event_manager.register_listener(discord_listener) except BaseException: pass # Load modules Modules.load() # Load main window + controller MainController(builder, main_window, settings) main_window.present() main_window.set_icon_name('skytemple') try: Gtk.main() except (KeyboardInterrupt, SystemExit): AsyncTaskRunner.end()