Skip to content

Commit 41599a5

Browse files
committed
chore: Cleanup
1 parent 5d0803d commit 41599a5

10 files changed

Lines changed: 50 additions & 15 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Nickvision.Application.GNOME.Views;
3+
4+
namespace Nickvision.Application.GNOME.Helpers;
5+
6+
public static class IServiceCollectionExtensions
7+
{
8+
extension(IServiceCollection collection)
9+
{
10+
public IServiceCollection AddControls()
11+
{
12+
collection.AddTransient<PreferencesDialog>();
13+
return collection;
14+
}
15+
}
16+
}

Nickvision.Application.GNOME/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.Hosting;
2+
using Nickvision.Application.GNOME.Helpers;
23
using Nickvision.Application.GNOME.Views;
34
using Nickvision.Application.Shared.Helpers;
45
using Nickvision.Desktop.GNOME.Helpers;
@@ -13,9 +14,10 @@ public static async Task Main(string[] args)
1314
var newArgs = new string[args.Length + 1];
1415
newArgs[0] = "org.nickvision.application";
1516
args.CopyTo(newArgs, 1);
16-
var builder = Host.CreateApplicationBuilder();
17+
var builder = Host.CreateApplicationBuilder(args);
1718
builder.ConfigureApplication(newArgs);
1819
builder.ConfigureAdw<MainWindow>();
20+
builder.Services.AddControls();
1921
var app = builder.Build();
2022
await app.RunAsync();
2123
}

Nickvision.Application.GNOME/Views/MainWindow.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ private async void OpenFolder(Gio.SimpleAction sender, Gio.SimpleAction.Activate
179179

180180
private void CloseFolder(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs args) => _controller.CloseFolder();
181181

182-
private void Preferences(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs args)
183-
{
184-
var preferencesDialog = ActivatorUtilities.CreateInstance<PreferencesDialog>(_serviceProvider);
185-
preferencesDialog.Present(this);
186-
}
182+
private void Preferences(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs args) => _serviceProvider.GetRequiredService<PreferencesDialog>().Present(this);
187183

188184
private void KeyboardShortcuts(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs args) => _serviceProvider.GetRequiredService<ShortcutsDialog>().Present(this);
189185

Nickvision.Application.Shared/Helpers/HostApplicationBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public IHostApplicationBuilder ConfigureApplication(string[] args)
2828
builder.ConfigureNickvision(args);
2929
builder.Services.AddSingleton<IFolderService, FolderService>();
3030
builder.Services.AddSingleton<MainWindowController>();
31-
builder.Services.AddSingleton<PreferencesViewController>();
31+
builder.Services.AddTransient<PreferencesViewController>();
3232
return builder;
3333
}
3434
}

Nickvision.Application.WinUI/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
2020
{
2121
if (_window is null)
2222
{
23-
_window = ActivatorUtilities.CreateInstance<MainWindow>(_serviceProvider);
23+
_window = _serviceProvider.GetRequiredService<MainWindow>();
2424
}
2525
_window.Activate();
2626
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Nickvision.Application.WinUI.Controls;
3+
using Nickvision.Application.WinUI.Views;
4+
5+
namespace Nickvision.Application.WinUI.Helpers;
6+
7+
public static class IServiceCollectionExtensions
8+
{
9+
extension(IServiceCollection collection)
10+
{
11+
public IServiceCollection AddControls()
12+
{
13+
collection.AddSingleton<MainWindow>();
14+
collection.AddTransient<SettingsPage>();
15+
collection.AddTransient<AboutDialog>();
16+
return collection;
17+
}
18+
}
19+
}

Nickvision.Application.WinUI/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.Extensions.Hosting;
22
using Nickvision.Application.Shared.Helpers;
3+
using Nickvision.Application.WinUI.Helpers;
34
using Nickvision.Desktop.WinUI.Helpers;
45
using System;
56
using System.Runtime.InteropServices;
@@ -15,9 +16,10 @@ public static partial class Program
1516
private static void Main(string[] args)
1617
{
1718
XamlCheckProcessRequirements();
18-
var builder = Host.CreateApplicationBuilder();
19+
var builder = Host.CreateApplicationBuilder(args);
1920
builder.ConfigureApplication(args);
2021
builder.ConfigureWinUI<App>();
22+
builder.Services.AddControls();
2123
var app = builder.Build();
2224
app.Run();
2325
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private void NavView_SelectionChanged(NavigationView sender, NavigationViewSelec
116116
var tag = item.Tag as string;
117117
FrameCustom.Content = tag switch
118118
{
119-
"Settings" => ActivatorUtilities.CreateInstance<SettingsPage>(_serviceProvider),
119+
"Settings" => _serviceProvider.GetRequiredService<SettingsPage>(),
120120
_ => null
121121
};
122122
ViewStack.SelectedIndex = tag switch
@@ -247,7 +247,7 @@ private async void CheckForUpdates(object sender, RoutedEventArgs e)
247247

248248
private async void About(object sender, RoutedEventArgs e)
249249
{
250-
var aboutDialog = ActivatorUtilities.CreateInstance<AboutDialog>(_serviceProvider);
250+
var aboutDialog = _serviceProvider.GetRequiredService<AboutDialog>();
251251
aboutDialog.DebugInformation = _controller.GetDebugInformation();
252252
aboutDialog.RequestedTheme = MainGrid.ActualTheme;
253253
aboutDialog.XamlRoot = MainGrid.XamlRoot;

resources/po/application.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2026-02-22 23:49-0500\n"
11+
"POT-Creation-Date: 2026-02-23 11:06-0500\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -114,7 +114,7 @@ msgid_plural "There are {0} files in the folder"
114114
msgstr[0] ""
115115
msgstr[1] ""
116116

117-
#: Nickvision.Application.GNOME/Views/MainWindow.cs:208
117+
#: Nickvision.Application.GNOME/Views/MainWindow.cs:204
118118
#: Nickvision.Application.WinUI/Views/MainWindow.xaml.cs:77
119119
msgid "GitHub Repo"
120120
msgstr ""

resources/po/ru.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: PACKAGE VERSION\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2026-02-22 23:49-0500\n"
10+
"POT-Creation-Date: 2026-02-23 11:04-0500\n"
1111
"PO-Revision-Date: 2023-05-23 06:33+0300\n"
1212
"Last-Translator: Fyodor Sobolev\n"
1313
"Language-Team: Russian\n"
@@ -117,7 +117,7 @@ msgstr[0] "В папке {0} файл."
117117
msgstr[1] "В папке {0} файла."
118118
msgstr[2] "В папке {0} файлов."
119119

120-
#: Nickvision.Application.GNOME/Views/MainWindow.cs:208
120+
#: Nickvision.Application.GNOME/Views/MainWindow.cs:204
121121
#: Nickvision.Application.WinUI/Views/MainWindow.xaml.cs:77
122122
msgid "GitHub Repo"
123123
msgstr "Репозиторий GitHub"

0 commit comments

Comments
 (0)