Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches: [ "main" ]
types: [ "review_requested", "ready_for_review" ]
workflow_dispatch:
name: Spell Check
permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Desktop.GNOME/Helpers/ComboRowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public void SetModel(IReadOnlyList<ISelectionItem> selectionItems, bool allowEli
{
var selectedIndex = 0u;
var list = Gtk.StringList.New(null);
for(var i = 0; i < selectionItems.Count; i++)
for (var i = 0; i < selectionItems.Count; i++)
{
var item = selectionItems[i];
list.Append(item.Label);
if(item.ShouldSelect)
if (item.ShouldSelect)
{
selectedIndex = (uint)i;
}
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Desktop.GNOME/Nickvision.Desktop.GNOME.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net10.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net9.0;net9.0-windows10.0.19041.0;net10.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
21 changes: 17 additions & 4 deletions Nickvision.Desktop.Tests/PowerServiceTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nickvision.Desktop.System;
using System.Threading.Tasks;

namespace Nickvision.Desktop.Tests;

Expand All @@ -15,17 +16,29 @@
}

[TestMethod]
public void Case002_PreventSuspend()
public async Task Case002_PreventSuspend()
{
#if OS_LINUX
if (Environment.GetEnvironmentVariable("CI") == "true")

Check failure on line 22 in Nickvision.Desktop.Tests/PowerServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build on Linux (x64, ubuntu-latest)

'Environment' does not contain a definition for 'GetEnvironmentVariable'

Check failure on line 22 in Nickvision.Desktop.Tests/PowerServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build on Linux (x64, ubuntu-latest)

'Environment' does not contain a definition for 'GetEnvironmentVariable'
{
Assert.Inconclusive("org.freedesktop.ScreenSaver service not available in CI environments");
}
#endif
Assert.IsNotNull(_powerService);
Assert.IsTrue(_powerService.PreventSuspend());
Assert.IsTrue(await _powerService.PreventSuspendAsync());
}

[TestMethod]
public void Case003_AllowSuspend()
public async Task Case003_AllowSuspend()
{
#if OS_LINUX
if (Environment.GetEnvironmentVariable("CI") == "true")

Check failure on line 35 in Nickvision.Desktop.Tests/PowerServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build on Linux (x64, ubuntu-latest)

'Environment' does not contain a definition for 'GetEnvironmentVariable'

Check failure on line 35 in Nickvision.Desktop.Tests/PowerServiceTests.cs

View workflow job for this annotation

GitHub Actions / Build on Linux (x64, ubuntu-latest)

'Environment' does not contain a definition for 'GetEnvironmentVariable'
{
Assert.Inconclusive("org.freedesktop.ScreenSaver service not available in CI environments");
}
#endif
Assert.IsNotNull(_powerService);
Assert.IsTrue(_powerService.AllowSuspend());
Assert.IsTrue(await _powerService.AllowSuspendAsync());
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Desktop.WinUI/Controls/StatusPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ImageSource? Image
public string Title
{
get => (string)GetValue(TitleProperty);

set
{
SetValue(TitleProperty, value);
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Desktop.WinUI/Controls/ViewStack.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ObservableCollection<UIElement> Pages
set
{
SetValue(PagesProperty, value);
if(value.Count > 0)
if (value.Count > 0)
{
Content = Pages[SelectedIndex];
}
Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Desktop.WinUI/Helpers/ComboBoxExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Nickvision.Desktop.Application;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls;
using Nickvision.Desktop.Application;
using System.Collections.Generic;
using System.Linq;

Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Desktop.WinUI/Helpers/ListViewExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Nickvision.Desktop.Application;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls;
using Nickvision.Desktop.Application;
using System.Collections.Generic;
using System.Linq;

Expand Down
4 changes: 2 additions & 2 deletions Nickvision.Desktop.WinUI/Helpers/WindowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public WindowGeometry Geometry
});
}
else
{
{
window.AppWindow.Resize(new SizeInt32
{
Width = Math.Max(900, value.Width),
Expand All @@ -57,7 +57,7 @@ public bool IsGeometryValid(WindowGeometry windowGeometry)
{
var workArea = DisplayArea.GetFromWindowId(window.AppWindow.Id, DisplayAreaFallback.Nearest).WorkArea;
var windowRect = new RectInt32(windowGeometry.X, windowGeometry.Y, windowGeometry.Width, windowGeometry.Height);
return Math.Max(0, Math.Min(windowRect.X + windowRect.Width, workArea.X + workArea.Width) - Math.Max(windowRect.X, workArea.X)) >= 100 &&
return Math.Max(0, Math.Min(windowRect.X + windowRect.Width, workArea.X + workArea.Width) - Math.Max(windowRect.X, workArea.X)) >= 100 &&
Math.Max(0, Math.Min(windowRect.Y + windowRect.Height, workArea.Y + workArea.Height) - Math.Max(windowRect.Y, workArea.Y)) >= 100;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Nickvision.Desktop.WinUI/Nickvision.Desktop.WinUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.19041.0;net9.0-windows10.0.19041.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net9.0-windows10.0.19041.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
Expand Down
21 changes: 21 additions & 0 deletions Nickvision.Desktop/FreeDesktop/IScreenSaver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Threading.Tasks;
using Tmds.DBus;

namespace Nickvision.Desktop.FreeDesktop;

[DBusInterface("org.freedesktop.ScreenSaver")]
public interface IScreenSaver : IDBusObject
{
Task LockAsync();
Task SimulateUserActivityAsync();
Task<bool> GetActiveAsync();
Task<uint> GetActiveTimeAsync();
Task<uint> GetSessionIdleTimeAsync();
Task<bool> SetActiveAsync(bool E);
Task<uint> InhibitAsync(string ApplicationName, string ReasonForInhibit);
Task UnInhibitAsync(uint Cookie);
Task<uint> ThrottleAsync(string ApplicationName, string ReasonForInhibit);
Task UnThrottleAsync(uint Cookie);
Task<IDisposable> WatchActiveChangedAsync(Action<bool> handler, Action<Exception>? onError = null);
}
3 changes: 2 additions & 1 deletion Nickvision.Desktop/Nickvision.Desktop.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net8.0-windows10.0.19041.0;net9.0;net9.0-windows10.0.19041.0;net10.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net9.0;net9.0-windows10.0.19041.0;net10.0;net10.0-windows10.0.19041.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -43,6 +43,7 @@
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlcipher" Version="2.1.11" />
<PackageReference Include="System.Drawing.Common" Version="10.0.2" />
<PackageReference Include="Tmds.DBus" Version="0.23.0" />
<PackageReference Include="Vanara.PInvoke.Kernel32" Version="5.0.0" />
<PackageReference Include="Vanara.PInvoke.PowrProf" Version="5.0.0" />
<PackageReference Include="Vanara.PInvoke.Security" Version="5.0.0" />
Expand Down
6 changes: 1 addition & 5 deletions Nickvision.Desktop/Notifications/NotificationService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using Nickvision.Desktop.Application;
using System;
using System.Diagnostics;
#if OS_WINDOWS
using Microsoft.Toolkit.Uwp.Notifications;

#elif OS_MAC
using System.Diagnostics;

#elif OS_LINUX
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
#endif
Expand Down
32 changes: 5 additions & 27 deletions Nickvision.Desktop/System/IPowerService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Nickvision.Desktop.System;
using System.Threading.Tasks;

namespace Nickvision.Desktop.System;

/// <summary>
/// An interface for a service for managing power options.
Expand All @@ -9,35 +11,11 @@ public interface IPowerService : IService
/// Allows the system to suspend.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool AllowSuspend();

/// <summary>
/// Logs the user off the system.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool Logoff();
Task<bool> AllowSuspendAsync();

/// <summary>
/// Prevents the system from suspending.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool PreventSuspend();

/// <summary>
/// Restarts the system.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool Restart();

/// <summary>
/// Shuts down the system.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool Shutdown();

/// <summary>
/// Suspends the system.
/// </summary>
/// <returns>True if the action was applied successfully, else false</returns>
bool Suspend();
Task<bool> PreventSuspendAsync();
}
Loading
Loading