Skip to content

Commit 20136a6

Browse files
authored
Removed dependency on libadwaita in Linux (#1380)
* Removed dependency on libadwaita in Linux * Removed unnecessary code
1 parent 65c0a76 commit 20136a6

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/app/dev/DevToys.Blazor/wwwroot/css/devtoys.g.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/platforms/desktop/DevToys.Linux/Core/ThemeListener.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Adw;
2-
using DevToys.Api;
1+
using DevToys.Api;
32
using DevToys.Core.Settings;
43
using DevToys.Blazor.Components;
54
using DevToys.Blazor.Core.Services;
@@ -13,7 +12,6 @@ internal sealed class ThemeListener : IThemeListener
1312
{
1413
private readonly ISettingsProvider _settingsProvider;
1514
private readonly Gtk.Settings _gtkSettings;
16-
private readonly StyleManager _adwStyleManager;
1715

1816
private Gtk.Window? _mainWindow;
1917
private bool _ignoreOperatingSystemSettingChanged;
@@ -25,8 +23,6 @@ public ThemeListener(ISettingsProvider settingsProvider)
2523
_settingsProvider = settingsProvider;
2624
_settingsProvider.SettingChanged += SettingsProvider_SettingChanged;
2725

28-
_adwStyleManager = StyleManager.GetDefault();
29-
3026
// Listen for operating system settings.
3127
_gtkSettings = Gtk.Settings.GetDefault()!;
3228
_gtkSettings.OnNotify += System_RequestedThemeChanged;
@@ -68,12 +64,10 @@ public void ApplyDesiredColorTheme()
6864
if (theme == AvailableApplicationTheme.Dark)
6965
{
7066
ActualAppTheme = ApplicationTheme.Dark;
71-
_adwStyleManager.ColorScheme = ColorScheme.ForceDark;
7267
}
7368
else
7469
{
7570
ActualAppTheme = ApplicationTheme.Light;
76-
_adwStyleManager.ColorScheme = ColorScheme.ForceLight;
7771
}
7872

7973
_ignoreOperatingSystemSettingChanged = false;
@@ -142,14 +136,19 @@ private bool GetBestValueForCompactMode()
142136

143137
private void UpdateSystemSettingsAndApplyTheme()
144138
{
145-
IsHighContrast = _adwStyleManager.HighContrast;
139+
IsHighContrast
140+
= _gtkSettings.GtkThemeName is not null
141+
&& _gtkSettings.GtkThemeName.Contains("high", StringComparison.OrdinalIgnoreCase)
142+
&& _gtkSettings.GtkThemeName.Contains("contrast", StringComparison.OrdinalIgnoreCase);
146143
CurrentSystemTheme = GetCurrentSystemTheme();
147144

148145
ApplyDesiredColorTheme();
149146
}
150147

151148
private AvailableApplicationTheme GetCurrentSystemTheme()
152149
{
153-
return _gtkSettings.GtkApplicationPreferDarkTheme ? AvailableApplicationTheme.Dark : AvailableApplicationTheme.Light;
150+
return _gtkSettings.GtkApplicationPreferDarkTheme || (_gtkSettings.GtkThemeName?.Contains("Dark", StringComparison.OrdinalIgnoreCase) ?? false)
151+
? AvailableApplicationTheme.Dark
152+
: AvailableApplicationTheme.Light;
154153
}
155154
}

src/app/dev/platforms/desktop/DevToys.Linux/DevToys.Linux.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="GirCore.Adw-1" />
1413
<PackageReference Include="GirCore.Gtk-4.0" />
1514
<PackageReference Include="GirCore.WebKit-6.0" />
1615
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" />

src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal partial class LinuxProgram
3131

3232
internal LinuxProgram()
3333
{
34-
Application = Adw.Application.New(null, Gio.ApplicationFlags.NonUnique);
34+
Application = Gtk.Application.New(null, Gio.ApplicationFlags.NonUnique);
3535

3636
GLib.Functions.SetPrgname("DevToys");
3737
// Set the human-readable application name for app bar and task list.
@@ -41,7 +41,7 @@ internal LinuxProgram()
4141
Application.OnShutdown += OnApplicationShutdown;
4242
}
4343

44-
internal Adw.Application Application { get; }
44+
internal Gtk.Application Application { get; }
4545

4646
private void OnApplicationActivate(object sender, object e)
4747
{
@@ -81,7 +81,7 @@ LanguageDefinition languageDefinition
8181
LanguageManager.Instance.SetCurrentCulture(languageDefinition);
8282

8383
// Create and open main window.
84-
_mainWindow = new MainWindow(serviceProvider, (Adw.Application)sender);
84+
_mainWindow = new MainWindow(serviceProvider, (Gtk.Application)sender);
8585
}
8686

8787
private void OnApplicationShutdown(object sender, object e)

src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal class MainWindow
4040
private readonly BlazorWebView _blazorGtkWebView;
4141
private readonly Gtk.Window _window;
4242

43-
internal MainWindow(IServiceProvider serviceProvider, Adw.Application application)
43+
internal MainWindow(IServiceProvider serviceProvider, Gtk.Application application)
4444
{
4545
serviceProvider.GetService<IMefProvider>()!.SatisfyImports(this);
4646
Guard.IsNotNull(_themeListener);

0 commit comments

Comments
 (0)