ThemeHelper.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Gtk;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.Configuration;
  4. using System.IO;
  5. namespace Ryujinx.Ui.Helper
  6. {
  7. static class ThemeHelper
  8. {
  9. public static void ApplyTheme()
  10. {
  11. if (!ConfigurationState.Instance.Ui.EnableCustomTheme)
  12. {
  13. return;
  14. }
  15. if (File.Exists(ConfigurationState.Instance.Ui.CustomThemePath) && (Path.GetExtension(ConfigurationState.Instance.Ui.CustomThemePath) == ".css"))
  16. {
  17. CssProvider cssProvider = new CssProvider();
  18. cssProvider.LoadFromPath(ConfigurationState.Instance.Ui.CustomThemePath);
  19. StyleContext.AddProviderForScreen(Gdk.Screen.Default, cssProvider, 800);
  20. }
  21. else
  22. {
  23. Logger.Warning?.Print(LogClass.Application, $"The \"custom_theme_path\" section in \"Config.json\" contains an invalid path: \"{ConfigurationState.Instance.Ui.CustomThemePath}\".");
  24. ConfigurationState.Instance.Ui.CustomThemePath.Value = "";
  25. ConfigurationState.Instance.Ui.EnableCustomTheme.Value = false;
  26. ConfigurationState.Instance.ToFileFormat().SaveConfig(Program.ConfigurationPath);
  27. }
  28. }
  29. }
  30. }