2023-12-04 14:17:13 +01:00
using Gtk ;
2024-01-29 19:58:18 +01:00
using Ryujinx.Common ;
2021-01-08 09:14:13 +01:00
using Ryujinx.Common.Logging ;
2024-02-11 03:09:18 +01:00
using Ryujinx.UI.Common.Configuration ;
2021-01-08 09:14:13 +01:00
using System.IO ;
2024-02-11 03:09:18 +01:00
namespace Ryujinx.UI.Helper
2021-01-08 09:14:13 +01:00
{
static class ThemeHelper
{
public static void ApplyTheme ( )
{
2024-02-11 03:09:18 +01:00
if ( ! ConfigurationState . Instance . UI . EnableCustomTheme )
2021-01-08 09:14:13 +01:00
{
return ;
}
2024-02-11 03:09:18 +01:00
if ( File . Exists ( ConfigurationState . Instance . UI . CustomThemePath ) & & ( Path . GetExtension ( ConfigurationState . Instance . UI . CustomThemePath ) = = ".css" ) )
2021-01-08 09:14:13 +01:00
{
2023-07-02 00:25:07 +02:00
CssProvider cssProvider = new ( ) ;
2021-01-08 09:14:13 +01:00
2024-02-11 03:09:18 +01:00
cssProvider . LoadFromPath ( ConfigurationState . Instance . UI . CustomThemePath ) ;
2021-01-08 09:14:13 +01:00
StyleContext . AddProviderForScreen ( Gdk . Screen . Default , cssProvider , 800 ) ;
}
else
{
2024-02-11 03:09:18 +01:00
Logger . Warning ? . Print ( LogClass . Application , $"The \" custom_theme_path \ " section in \"{ReleaseInformation.ConfigName}\" contains an invalid path: \"{ConfigurationState.Instance.UI.CustomThemePath}\"." ) ;
2021-01-08 09:14:13 +01:00
2024-02-11 03:09:18 +01:00
ConfigurationState . Instance . UI . CustomThemePath . Value = "" ;
ConfigurationState . Instance . UI . EnableCustomTheme . Value = false ;
2021-01-08 09:14:13 +01:00
ConfigurationState . Instance . ToFileFormat ( ) . SaveConfig ( Program . ConfigurationPath ) ;
}
}
}
2023-07-02 00:25:07 +02:00
}