Skip to content

Commit

Permalink
Merge pull request #625 from NickvisionApps/winui
Browse files Browse the repository at this point in the history
WinUI + More
  • Loading branch information
nlogozzo committed Nov 3, 2023
2 parents 758ec4a + 5e07d41 commit a0d2d27
Show file tree
Hide file tree
Showing 130 changed files with 36,907 additions and 18,311 deletions.
9 changes: 8 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Auto detect text files and perform LF normalization
* text=auto
* text eol=lf
*.csproj eol=crlf
*.sln eol=crlf
*.png binary
*.jpg binary
*.ico binary
*.pdf binary
*.exe binary
# Exclude Docs From Stats
NickvisionTubeConverter.Shared/Docs/** linguist-documentation
48 changes: 48 additions & 0 deletions .github/workflows/winui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
types: [ "review_requested", "ready_for_review" ]
workflow_dispatch:
name: WinUI
jobs:
gnome-flatpak:
name: "WinUI on Windows"
runs-on: windows-latest
if: ${{ github.event.pull_request.user.login != 'weblate' }}
strategy:
matrix:
configuration: [Debug] #release doesn't work for some reason
platform: [x64, arm64]
env:
Project_Path: NickvisionTubeConverter.WinUI/NickvisionTubeConverter.WinUI.csproj
steps:
- uses: actions/[email protected]
with:
submodules: recursive
# Install the .NET Core workload
- name: Install .NET Core
uses: actions/[email protected]
with:
dotnet-version: 7.0.x
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/[email protected]
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: msbuild $env:Project_Path /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}
# Build the app
- name: Build the application
run: msbuild $env:Project_Path /p:Configuration=$env:Configuration /p:Platform=$env:Platform
env:
Configuration: ${{ matrix.configuration }}
Platform: ${{ matrix.platform }}
# Upload the app
- name: Upload app
uses: actions/[email protected]
with:
name: org.nickvision.tubeconverter-winui-${{ matrix.platform }}
path: ${{ github.workspace }}\NickvisionTubeConverter.WinUI\bin\${{ matrix.platform }}\Debug\net7.0-windows10.0.19041.0
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,9 @@ _nickbuild/

# Cake tools
tools/

# WinUI App Installer
*.WinUI/Installer/*.exe
*.WinUI/Dependencies/ffmpeg.exe
*.WinUI/Dependencies/ffplay.exe
*.WinUI/Dependencies/ffprobe.exe
35 changes: 33 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents
- [Manually](#manually)
- [Your First Code Contribution](#your-first-code-contribution)
- [Developing on Linux](#developing-on-linux)
- [Developing on Windows](#developing-on-windows)
- [Styleguides](#styleguides)
- [Join The Project Team](#join-the-project-team)

Expand Down Expand Up @@ -125,10 +126,11 @@ Once all changes to your translated file are made, commit these changes and crea

#### Structure

Parabolic is built using .NET 7 and C#. With these technologies, Parabolic is built for GNOME (Linux).
The solution is setup into 2 projects:
Parabolic is built using .NET 7 and C#. With these technologies, Parabolic is built for GNOME (Linux) and Windows.
The solution is setup into 3 projects:
- NickvisionTubeConverter.Shared
- NickvisionTubeConverter.GNOME
- NickvisionTubeConverter.WinUI

The whole solution utilizes the [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) pattern for separating data and UI views.

Expand All @@ -150,6 +152,15 @@ Powered by the C# bindings for GTK4/Libadwaita: [gir.core](https://github.com/gi
- Helpers => Useful objects that are specific for GNOME platform version of the app
- Blueprints => UI files written in [Blueprint markup language](https://jwestman.pages.gitlab.gnome.org/blueprint-compiler/)

##### NickvisionTubeConverter.WinUI

This project contains all of the code used for the Windows platform version of the app, including installer scripts.
Powered by the [Windows App SDK](https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/)
- Views => The views (pages, windows, dialogs) of the app that connect to the shared controllers
- Controls => Generic controls for the app
- These controls should not be connected to a controller and should be able to be ported to any other application
- Installer => Inno installer scripts

#### Developing on Linux

##### GNOME
Expand Down Expand Up @@ -183,6 +194,26 @@ Use one of the commands to build the app:
| `dotnet cake --target=Publish --prefix=PREFIX --ui=gnome` | Builds the application in `_nickbuild` directory, preparing it to be installed in a provided prefix (examples of a valid prefix: `/usr`, `/app`). If `--self-contained` is added, the application will not need dotnet-runtime to run.
| `dotnet cake --target=Install --destdir=DESTDIR` | Copies files to the `DESTDIR`. `--destdir` is optional, by default files are copied to root (`/`). This command should be used after `Publish`. |

##### WinUI

Can not be developed on non-Windows platforms.

#### Developing on Windows

##### WinUI
Recommended IDE:
- Visual Studio 2022 setup for use with Windows App SDK

You may also build the app manually without Visual Studio 2022 but the Windows App SDK runtime must be installed. It can be found here: https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads.

You will also need gettext for Windows to be installed for the app to properly utilize transactions. Get it here: https://mlocati.github.io/articles/gettext-iconv-windows.html

With all dependencies installed a simple `dotnet run` will build and start the app.

##### GNOME

Can not be developed on non-Linux platforms.

## Styleguides

Parabolic follows [Microsoft's C# Coding Conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Adw.Window _root {
activatable-widget: _subtitleSwitch;

[suffix]
Gtk.Switch _subtitleSwitch {
Gtk.Switch _subtitleSwitch {
valign: center;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Adw.Window _root {
margin-start: 12;
margin-end: 12;
margin-bottom: 12;
placeholder-text: _("Search...");
placeholder-text: _("Search history");
}

Gtk.Separator {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Adw.Window _root {
child: Adw.StatusPage _disabledPage {
icon-name: "key2-symbolic";
title: _("Keyring Disabled");
description: _("Use keyring to safely store credentials for sites that require login with username and password.");
description: _("Use keyring to safely store credentials for sites that require a user name and password to login.");
child: Gtk.Button _enableKeyringButton {
label: _("Enable");
halign: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ Adw.PreferencesWindow _root {
numeric: true;
adjustment: Gtk.Adjustment {
lower: 1;
upper: 32;
upper: 16;
step-increment: 1;
page-increment: 2;
};
Expand Down Expand Up @@ -348,7 +348,7 @@ Adw.PreferencesWindow _root {
hexpand: true;

child: Adw.ButtonContent {
label: "Chrome";
label: _("Chrome/Edge");
icon-name: "google-chrome-symbolic";
};
}
Expand All @@ -357,7 +357,7 @@ Adw.PreferencesWindow _root {
hexpand: true;

child: Adw.ButtonContent {
label: "Firefox";
label: _("Firefox");
icon-name: "firefox-symbolic";
};
}
Expand Down
4 changes: 2 additions & 2 deletions NickvisionTubeConverter.GNOME/Controls/DownloadRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using NickvisionTubeConverter.Shared.Models;
using System;
using System.IO;
using static Nickvision.Aura.Localization.Gettext;
using static Nickvision.GirExt.GtkExt;
using static NickvisionTubeConverter.Shared.Helpers.Gettext;

namespace NickvisionTubeConverter.GNOME.Controls;

Expand Down Expand Up @@ -168,7 +168,7 @@ public void SetProgressState(DownloadProgressState state)
});
}
_stateViewStack.SetVisibleChildName("processing");
_progressLabel.SetText(_("Downloading"));
_progressLabel.SetText(_("Downloading..."));
break;
case DownloadProgressStatus.Processing:
if (!_runPulsingBar)
Expand Down
25 changes: 7 additions & 18 deletions NickvisionTubeConverter.GNOME/Controls/HistoryDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static Nickvision.Aura.Localization.Gettext;
using static Nickvision.GirExt.GtkExt;
using static NickvisionTubeConverter.Shared.Helpers.Gettext;

namespace NickvisionTubeConverter.GNOME.Controls;

Expand All @@ -21,9 +21,8 @@ public partial class HistoryDialog : Adw.Window
[Gtk.Connect] private readonly Gtk.Button _clearButton;
[Gtk.Connect] private readonly Gtk.SearchEntry _searchEntry;
[Gtk.Connect] private readonly Adw.ViewStack _viewStack;
[Gtk.Connect] private readonly Gtk.ScrolledWindow _scrolledWindow;
[Gtk.Connect] private readonly Adw.PreferencesGroup _urlsGroup;

/// <summary>
/// Occurs when a download is requested to be downloaded again
/// </summary>
Expand Down Expand Up @@ -51,7 +50,7 @@ private HistoryDialog(Gtk.Builder builder, Gtk.Window parent, string iconName, D
foreach (var pair in _history.History.OrderByDescending(x => x.Value.Date))
{
var row = Adw.ActionRow.New();
if(string.IsNullOrEmpty(pair.Value.Title))
if (string.IsNullOrEmpty(pair.Value.Title))
{
row.SetTitle(pair.Key);
}
Expand All @@ -62,7 +61,7 @@ private HistoryDialog(Gtk.Builder builder, Gtk.Window parent, string iconName, D
}
row.SetTitleLines(1);
row.SetSubtitleLines(1);
if(File.Exists(pair.Value.Path))
if (File.Exists(pair.Value.Path))
{
var openButton = Gtk.Button.New();
openButton.SetIconName("media-playback-start-symbolic");
Expand Down Expand Up @@ -119,7 +118,7 @@ private void ClearHistory(Gtk.Button sender, EventArgs e)
//Update UI
_searchEntry.SetVisible(false);
_viewStack.SetVisibleChildName("no-history");
foreach(var row in _historyRows)
foreach (var row in _historyRows)
{
_urlsGroup.Remove(row);
}
Expand All @@ -134,19 +133,9 @@ private void ClearHistory(Gtk.Button sender, EventArgs e)
private void SearchChanged(Gtk.SearchEntry sender, EventArgs e)
{
var search = _searchEntry.GetText().ToLower();
if(string.IsNullOrEmpty(search))
foreach (var row in _historyRows)
{
foreach (var row in _historyRows)
{
row.SetVisible(true);
}
}
else
{
foreach(var row in _historyRows)
{
row.SetVisible(row.GetTitle().ToLower().Contains(search));
}
row.SetVisible(string.IsNullOrEmpty(search) || row.GetTitle().ToLower().Contains(search));
}
}
}
46 changes: 36 additions & 10 deletions NickvisionTubeConverter.GNOME/Controls/MediaRow.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using NickvisionTubeConverter.GNOME.Helpers;
using NickvisionTubeConverter.Shared.Models;
using System;
using static NickvisionTubeConverter.Shared.Helpers.Gettext;
using static Nickvision.Aura.Localization.Gettext;

namespace NickvisionTubeConverter.GNOME.Controls;

/// <summary>
/// A row for a media in the AddDownloadDialog
/// </summary>
public class MediaRow : Adw.EntryRow
{
private readonly MediaInfo _mediaInfo;
Expand All @@ -16,17 +19,16 @@ public class MediaRow : Adw.EntryRow
[Gtk.Connect] private readonly Gtk.Button _undoButton;

/// <summary>
/// The active status of the row's check button
/// Occurs when the check to select the download is changed
/// </summary>
public bool Active
{
get => _downloadCheck.GetActive();

set => _downloadCheck.SetActive(value);
}

public event EventHandler<EventArgs>? OnSelectionChanged;

/// <summary>
/// Constructs a MediaRow
/// </summary>
/// <param name="builder">Gtk.Builder</param>
/// <param name="mediaInfo">MediaInfo</param>
/// <param name="limitChars">Whether or not to limit characters to those only supported by Windows</param>
private MediaRow(Gtk.Builder builder, MediaInfo mediaInfo, bool limitChars) : base(builder.GetPointer("_root"), false)
{
_mediaInfo = mediaInfo;
Expand Down Expand Up @@ -59,21 +61,45 @@ private MediaRow(Gtk.Builder builder, MediaInfo mediaInfo, bool limitChars) : ba
AddController(_titleKeyController);
_undoButton.OnClicked += (sender, e) =>
{
SetText(_numberString + _mediaInfo.OriginalTitle);
SetText($"{_numberString}{_mediaInfo.OriginalTitle}");
};
}

/// <summary>
/// Constructs a MediaRow
/// </summary>
/// <param name="mediaInfo">MediaInfo</param>
/// <param name="limitChars">Whether or not to limit characters to those only supported by Windows</param>
public MediaRow(MediaInfo mediaInfo, bool limitChars) : this(Builder.FromFile("media_row.ui"), mediaInfo, limitChars)
{

}

/// <summary>
/// The active status of the row's check button
/// </summary>
public bool Active
{
get => _downloadCheck.GetActive();

set => _downloadCheck.SetActive(value);
}

/// <summary>
/// Updates the title of the row
/// </summary>
/// <param name="numbered"></param>
public void UpdateTitle(bool numbered)
{
SetText(_mediaInfo.Title);
_numberString = numbered ? $"{_mediaInfo.PlaylistPosition} - " : "";
}

/// <summary>
/// Occurs when the row's text is changed
/// </summary>
/// <param name="sender">Gtk.EventControllerKey</param>
/// <param name="e">Gtk.EventControllerKey.KeyPressedSignalArgs</param>
private bool OnKeyPressed(Gtk.EventControllerKey sender, Gtk.EventControllerKey.KeyPressedSignalArgs e)
{
var res = e.Keyval == 0x2f; // '/'
Expand Down
7 changes: 4 additions & 3 deletions NickvisionTubeConverter.GNOME/Controls/PasswordDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NickvisionTubeConverter.GNOME.Helpers;
using NickvisionTubeConverter.Shared.Helpers;
using System.Threading.Tasks;

namespace NickvisionTubeConverter.GNOME.Controls;
Expand All @@ -19,8 +20,8 @@ public partial class PasswordDialog : Adw.Window
/// <summary>
/// Whether or not the dialog was skipped
/// </summary>
public bool WasSkipped { get; private set; }
public bool WasSkipped { get; private set; }

/// <summary>
/// Constructs a PasswordDialog
/// </summary>
Expand All @@ -35,7 +36,7 @@ private PasswordDialog(Gtk.Builder builder, Gtk.Window parent, string title, Tas
builder.Connect(this);
//Dialog Settings
SetTransientFor(parent);
_migrateButton.OnClicked += (sender, e) => Gtk.Functions.ShowUri(this, Help.GetHelpURL("keyring"), 0);
_migrateButton.OnClicked += (sender, e) => Gtk.Functions.ShowUri(this, DocumentationHelpers.GetHelpURL("keyring"), 0);
_titleLabel.SetLabel(title);
_skipButton.OnClicked += (sender, e) =>
{
Expand Down
Loading

0 comments on commit a0d2d27

Please sign in to comment.