Skip to content

Commit 6a51787

Browse files
committed
feat: Update deps
1 parent 4991f0f commit 6a51787

13 files changed

Lines changed: 199 additions & 196 deletions

File tree

Nickvision.Application.GNOME/Nickvision.Application.GNOME.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="GirCore.Adw-1" Version="0.7.0" />
17-
<PackageReference Include="Nickvision.Desktop.GNOME" Version="2026.3.5" />
17+
<PackageReference Include="Nickvision.Desktop.GNOME" Version="2026.3.6" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<ProjectReference Include="..\Nickvision.Application.Shared\Nickvision.Application.Shared.csproj" />

Nickvision.Application.GNOME/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
using Nickvision.Application.GNOME.Views;
44
using Nickvision.Application.Shared.Helpers;
55
using Nickvision.Desktop.GNOME.Helpers;
6-
using System.Diagnostics.CodeAnalysis;
76
using System.Threading.Tasks;
87

98
namespace Nickvision.Application.GNOME;
109

1110
public class Program
1211
{
13-
[RequiresDynamicCode("Calls ConfigureAdw<T>() which may use dynamic code generation.")]
1412
public static async Task Main(string[] args)
1513
{
1614
var newArgs = new string[args.Length + 1];

Nickvision.Application.GNOME/Views/MainWindow.cs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
using Nickvision.Desktop.Notifications;
1212
using System;
1313
using System.Diagnostics.CodeAnalysis;
14+
using System.IO;
1415
using System.Linq;
1516

1617
namespace Nickvision.Application.GNOME.Views;
1718

1819
public class MainWindow : Adw.ApplicationWindow
1920
{
2021
private readonly IServiceProvider _serviceProvider;
22+
private readonly Adw.Application _application;
2123
private readonly MainWindowController _controller;
2224
private readonly AppInfo _appInfo;
2325
private readonly ITranslationService _translationService;
@@ -39,16 +41,16 @@ public class MainWindow : Adw.ApplicationWindow
3941
[Gtk.Connect("pageFiles")]
4042
private Adw.StatusPage? _pageFiles;
4143

42-
public MainWindow(IServiceProvider serviceProvider, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, IGtkBuilderFactory builderFactory) : this(serviceProvider, controller, appInfo, eventsService, translationService, builderFactory.Create("MainWindow"))
44+
public MainWindow(IServiceProvider serviceProvider, Adw.Application application, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, IGtkBuilderFactory builderFactory) : this(serviceProvider, application, controller, appInfo, eventsService, translationService, builderFactory.Create("MainWindow"))
4345
{
4446

4547
}
4648

4749
[DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, typeof(MainWindow))]
48-
private MainWindow(IServiceProvider serviceProvider, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, Gtk.Builder builder) : base(new Adw.Internal.ApplicationWindowHandle(builder.GetPointer("root"), false))
50+
private MainWindow(IServiceProvider serviceProvider, Adw.Application application, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, Gtk.Builder builder) : base(new Adw.Internal.ApplicationWindowHandle(builder.GetPointer("root"), false))
4951
{
50-
var application = serviceProvider.GetRequiredService<Adw.Application>();
5152
_serviceProvider = serviceProvider;
53+
_application = application;
5254
_controller = controller;
5355
_appInfo = appInfo;
5456
_translationService = translationService;
@@ -87,32 +89,36 @@ private MainWindow(IServiceProvider serviceProvider, MainWindowController contro
8789
var actQuit = Gio.SimpleAction.New("quit", null);
8890
actQuit.OnActivate += Quit;
8991
AddAction(actQuit);
90-
application.SetAccelsForAction("win.quit", ["<Ctrl>q"]);
92+
_application.SetAccelsForAction("win.quit", ["<Ctrl>q"]);
93+
// Open in files action
94+
var actOpenInFiles = Gio.SimpleAction.New("openInFiles", null);
95+
actOpenInFiles.OnActivate += OpenInFiles;
96+
AddAction(actOpenInFiles);
9197
// Open folder action
9298
var actOpenFolder = Gio.SimpleAction.New("openFolder", null);
9399
actOpenFolder.OnActivate += OpenFolder;
94100
AddAction(actOpenFolder);
95-
application.SetAccelsForAction("win.openFolder", ["<Ctrl>o"]);
101+
_application.SetAccelsForAction("win.openFolder", ["<Ctrl>o"]);
96102
// Close folder action
97103
var actCloseFolder = Gio.SimpleAction.New("closeFolder", null);
98104
actCloseFolder.OnActivate += CloseFolder;
99105
AddAction(actCloseFolder);
100-
application.SetAccelsForAction("win.closeFolder", ["<Ctrl>w"]);
106+
_application.SetAccelsForAction("win.closeFolder", ["<Ctrl>w"]);
101107
// Preferences action
102108
var actPreferences = Gio.SimpleAction.New("preferences", null);
103109
actPreferences.OnActivate += Preferences;
104110
AddAction(actPreferences);
105-
application.SetAccelsForAction("win.preferences", ["<Ctrl>period"]);
111+
_application.SetAccelsForAction("win.preferences", ["<Ctrl>period"]);
106112
// Keyboard shortcuts action
107113
var actKeyboardShortcuts = Gio.SimpleAction.New("keyboardShortcuts", null);
108114
actKeyboardShortcuts.OnActivate += KeyboardShortcuts;
109115
AddAction(actKeyboardShortcuts);
110-
application.SetAccelsForAction("win.keyboardShortcuts", ["<Ctrl>question"]);
116+
_application.SetAccelsForAction("win.keyboardShortcuts", ["<Ctrl>question"]);
111117
// About action
112118
var actAbout = Gio.SimpleAction.New("about", null);
113119
actAbout.OnActivate += About;
114120
AddAction(actAbout);
115-
application.SetAccelsForAction("win.about", ["F1"]);
121+
_application.SetAccelsForAction("win.about", ["F1"]);
116122
}
117123

118124
public new void Present()
@@ -158,6 +164,16 @@ private bool Window_OnDrop(Gtk.DropTarget sender, Gtk.DropTarget.DropSignalArgs
158164

159165
private void Controller_AppNotificationSent(object? sender, AppNotificationSentEventArgs e)
160166
{
167+
if (e.Notification is ShellNotification shellNotification)
168+
{
169+
var notification = Gio.Notification.New(shellNotification.Title);
170+
notification.SetBody(shellNotification.Message);
171+
if (shellNotification.Action == "open" && !Directory.Exists(shellNotification.ActionParam))
172+
{
173+
notification.AddButton(_translationService._("Open in Files"), "win.openInFiles");
174+
}
175+
_application.SendNotification(null, notification);
176+
}
161177
var toast = Adw.Toast.New(e.Notification.Message);
162178
if (e.Notification.Action == "close")
163179
{
@@ -187,6 +203,16 @@ private void Controller_FolderChanged(object? sender, FolderChangedEventArgs e)
187203

188204
private void Quit(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) => Window_OnCloseRequest(this, new EventArgs());
189205

206+
private async void OpenInFiles(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e)
207+
{
208+
if (!Directory.Exists(_controller.CurrentFolder))
209+
{
210+
return;
211+
}
212+
var launcher = Gtk.FileLauncher.New(Gio.FileHelper.NewForPath(_controller.CurrentFolder));
213+
await launcher.LaunchAsync(this);
214+
}
215+
190216
private async void OpenFolder(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e)
191217
{
192218
var folderDialog = Gtk.FileDialog.New();

Nickvision.Application.Shared/Controllers/MainWindowController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public MainWindowController(ILogger<MainWindowController> logger, AppInfo appInf
5050

5151
public bool CanShutdown => true;
5252

53+
public string? CurrentFolder => _folderService.Path;
54+
5355
public string Greeting => DateTime.Now.Hour switch
5456
{
5557
>= 0 and < 6 => _translationService._p("Night", "Good Morning!"),

Nickvision.Application.Shared/Nickvision.Application.Shared.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Nickvision.Desktop" Version="2026.3.8" />
15+
<PackageReference Include="Nickvision.Desktop" Version="2026.3.9" />
1616
<PackageReference Include="NReco.Logging.File" Version="1.3.1" />
1717
</ItemGroup>
1818

Nickvision.Application.Shared/Services/FolderService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public void Open(string path)
4848
{
4949
Action = "close"
5050
});
51+
_notificationService.Send(new ShellNotification(_translationService._("Folder"), _translationService._("Loaded {0} file(s)", Files.Count), NotificationSeverity.Information)
52+
{
53+
Action = "open",
54+
ActionParam = Path
55+
});
5156
Changed?.Invoke(this, new FolderChangedEventArgs(Path, Files));
5257
}
5358

Nickvision.Application.WinUI/App.xaml.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
using Microsoft.Extensions.DependencyInjection;
22
using Microsoft.UI.Xaml;
3+
using Microsoft.Windows.AppNotifications;
34
using Nickvision.Application.WinUI.Views;
45
using System;
6+
using System.Diagnostics;
7+
using System.IO;
8+
using Windows.System;
59

610
namespace Nickvision.Application.WinUI;
711

@@ -14,6 +18,13 @@ public App(IServiceProvider serviceProvider)
1418
{
1519
InitializeComponent();
1620
_serviceProvider = serviceProvider;
21+
AppNotificationManager.Default.NotificationInvoked += App_NotificationInvoked;
22+
AppNotificationManager.Default.Register();
23+
AppDomain.CurrentDomain.ProcessExit += async (_, _) =>
24+
{
25+
await AppNotificationManager.Default.RemoveAllAsync();
26+
AppNotificationManager.Default.UnregisterAll();
27+
};
1728
}
1829

1930
protected override void OnLaunched(LaunchActivatedEventArgs args)
@@ -24,4 +35,26 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
2435
}
2536
_window.Activate();
2637
}
38+
39+
private async void App_NotificationInvoked(AppNotificationManager sender, AppNotificationActivatedEventArgs args)
40+
{
41+
if (args.Arguments.ContainsKey("action") && args.Arguments["action"] == "OpenInExplorer")
42+
{
43+
if (!Directory.Exists(args.Arguments["path"]))
44+
{
45+
try
46+
{
47+
using var _ = Process.Start(new ProcessStartInfo()
48+
{
49+
FileName = args.Arguments["path"],
50+
UseShellExecute = true
51+
});
52+
}
53+
catch
54+
{
55+
await Launcher.LaunchFolderPathAsync(args.Arguments["path"]);
56+
}
57+
}
58+
}
59+
}
2760
}

Nickvision.Application.WinUI/Nickvision.Application.WinUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<PackageReference Include="CommunityToolkit.WinUI.Extensions" Version="8.2.251219" />
3636
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.7705" />
3737
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.260317003" />
38-
<PackageReference Include="Nickvision.Desktop.WinUI" Version="2026.3.6" />
38+
<PackageReference Include="Nickvision.Desktop.WinUI" Version="2026.3.7" />
3939
</ItemGroup>
4040
<ItemGroup>
4141
<ProjectReference Include="..\Nickvision.Application.Shared\Nickvision.Application.Shared.csproj" />

Nickvision.Application.WinUI/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Nickvision.Application.WinUI.Helpers;
44
using Nickvision.Desktop.WinUI.Helpers;
55
using System;
6-
using System.Diagnostics.CodeAnalysis;
76
using System.Runtime.InteropServices;
87

98
namespace Nickvision.Application.WinUI;
@@ -14,7 +13,6 @@ public static partial class Program
1413
private static partial void XamlCheckProcessRequirements();
1514

1615
[STAThread]
17-
[RequiresDynamicCode("Calls ConfigureWinUI<T>() which may use dynamic code generation.")]
1816
private static void Main(string[] args)
1917
{
2018
XamlCheckProcessRequirements();

Nickvision.Application.WinUI/Views/MainWindow.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.UI.Xaml.Controls;
66
using Microsoft.UI.Xaml.Controls.Primitives;
77
using Microsoft.UI.Xaml.Input;
8+
using Microsoft.Windows.AppNotifications;
9+
using Microsoft.Windows.AppNotifications.Builder;
810
using Microsoft.Windows.Storage.Pickers;
911
using Nickvision.Application.Shared.Controllers;
1012
using Nickvision.Application.Shared.Events;
@@ -133,6 +135,20 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
133135

134136
private void Controller_AppNotificationSent(object? sender, AppNotificationSentEventArgs args)
135137
{
138+
if (args.Notification is ShellNotification shellNotification)
139+
{
140+
var builder = new AppNotificationBuilder()
141+
.AddText(shellNotification.Title)
142+
.AddText(shellNotification.Message);
143+
if (shellNotification.Action == "open")
144+
{
145+
builder.AddButton(new AppNotificationButton(_translationService._("Open in Explorer"))
146+
.AddArgument("action", "OpenInExplorer")
147+
.AddArgument("param", shellNotification.ActionParam));
148+
}
149+
AppNotificationManager.Default.Show(builder.BuildNotification());
150+
return;
151+
}
136152
if (_notificationClickHandler is not null)
137153
{
138154
BtnInfoBar.Click -= _notificationClickHandler;

0 commit comments

Comments
 (0)