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