Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed dependency on libadwaita in Linux #1380

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/dev/DevToys.Blazor/wwwroot/css/devtoys.g.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Adw;
using DevToys.Api;
using DevToys.Api;
using DevToys.Core.Settings;
using DevToys.Blazor.Components;
using DevToys.Blazor.Core.Services;
Expand All @@ -13,7 +12,6 @@ internal sealed class ThemeListener : IThemeListener
{
private readonly ISettingsProvider _settingsProvider;
private readonly Gtk.Settings _gtkSettings;
private readonly StyleManager _adwStyleManager;

private Gtk.Window? _mainWindow;
private bool _ignoreOperatingSystemSettingChanged;
Expand All @@ -25,8 +23,6 @@ public ThemeListener(ISettingsProvider settingsProvider)
_settingsProvider = settingsProvider;
_settingsProvider.SettingChanged += SettingsProvider_SettingChanged;

_adwStyleManager = StyleManager.GetDefault();

// Listen for operating system settings.
_gtkSettings = Gtk.Settings.GetDefault()!;
_gtkSettings.OnNotify += System_RequestedThemeChanged;
Expand Down Expand Up @@ -68,12 +64,10 @@ public void ApplyDesiredColorTheme()
if (theme == AvailableApplicationTheme.Dark)
{
ActualAppTheme = ApplicationTheme.Dark;
_adwStyleManager.ColorScheme = ColorScheme.ForceDark;
}
else
{
ActualAppTheme = ApplicationTheme.Light;
_adwStyleManager.ColorScheme = ColorScheme.ForceLight;
}

_ignoreOperatingSystemSettingChanged = false;
Expand Down Expand Up @@ -142,14 +136,19 @@ private bool GetBestValueForCompactMode()

private void UpdateSystemSettingsAndApplyTheme()
{
IsHighContrast = _adwStyleManager.HighContrast;
IsHighContrast
= _gtkSettings.GtkThemeName is not null
&& _gtkSettings.GtkThemeName.Contains("high", StringComparison.OrdinalIgnoreCase)
&& _gtkSettings.GtkThemeName.Contains("contrast", StringComparison.OrdinalIgnoreCase);
CurrentSystemTheme = GetCurrentSystemTheme();

ApplyDesiredColorTheme();
}

private AvailableApplicationTheme GetCurrentSystemTheme()
{
return _gtkSettings.GtkApplicationPreferDarkTheme ? AvailableApplicationTheme.Dark : AvailableApplicationTheme.Light;
return _gtkSettings.GtkApplicationPreferDarkTheme || (_gtkSettings.GtkThemeName?.Contains("Dark", StringComparison.OrdinalIgnoreCase) ?? false)
? AvailableApplicationTheme.Dark
veler marked this conversation as resolved.
Show resolved Hide resolved
: AvailableApplicationTheme.Light;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GirCore.Adw-1" />
<PackageReference Include="GirCore.Gtk-4.0" />
<PackageReference Include="GirCore.WebKit-6.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView" />
Expand Down
6 changes: 3 additions & 3 deletions src/app/dev/platforms/desktop/DevToys.Linux/LinuxProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ internal partial class LinuxProgram

internal LinuxProgram()
{
Application = Adw.Application.New(null, Gio.ApplicationFlags.NonUnique);
Application = Gtk.Application.New(null, Gio.ApplicationFlags.NonUnique);

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

internal Adw.Application Application { get; }
internal Gtk.Application Application { get; }

private void OnApplicationActivate(object sender, object e)
{
Expand Down Expand Up @@ -81,7 +81,7 @@ LanguageDefinition languageDefinition
LanguageManager.Instance.SetCurrentCulture(languageDefinition);

// Create and open main window.
_mainWindow = new MainWindow(serviceProvider, (Adw.Application)sender);
_mainWindow = new MainWindow(serviceProvider, (Gtk.Application)sender);
}

private void OnApplicationShutdown(object sender, object e)
Expand Down
2 changes: 1 addition & 1 deletion src/app/dev/platforms/desktop/DevToys.Linux/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class MainWindow
private readonly BlazorWebView _blazorGtkWebView;
private readonly Gtk.Window _window;

internal MainWindow(IServiceProvider serviceProvider, Adw.Application application)
internal MainWindow(IServiceProvider serviceProvider, Gtk.Application application)
{
serviceProvider.GetService<IMefProvider>()!.SatisfyImports(this);
Guard.IsNotNull(_themeListener);
Expand Down
Loading