Skip to content

Commit

Permalink
Merge branch 'feature/gtk4'
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronwhite committed Mar 26, 2023
2 parents 5428fa0 + a02786f commit 97626fe
Show file tree
Hide file tree
Showing 328 changed files with 8,787 additions and 7,634 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
build-ubuntu:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

# Test building with .NET 6 and .NET 7
strategy:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Install Apt Dependencies
run: |
sudo apt update
sudo apt install autotools-dev autoconf-archive gettext intltool libgtk-3-dev
sudo apt install autotools-dev autoconf-archive gettext intltool libadwaita-1-dev
- name: Generate Tarball
run: |
./autogen.sh
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
with:
dotnet-version: ${{env.DOTNET_VERSION}}
- name: Install Dependencies
run: brew install gtk+3 adwaita-icon-theme gettext
run: brew install libadwaita adwaita-icon-theme gettext
- name: Build
run: dotnet build Pinta.sln -c Release
- name: Test
Expand Down Expand Up @@ -94,6 +94,9 @@ jobs:

build-windows:
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}

steps:
- uses: actions/checkout@v3
Expand All @@ -102,20 +105,28 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{env.DOTNET_VERSION}}
- name: Install dependencies
uses: msys2/setup-msys2@v2
with:
path-type: inherit # Inherit the path so that dotnet can be found
update: true
install: mingw-w64-x86_64-libadwaita
- name: Build
run: dotnet build Pinta.sln -c Release
- name: Test
run: dotnet test Pinta.sln -c Release

# Note that msgfmt is already available from the Git for Windows installation!
- name: Build Installer
if: ${{ false }} # Disable until the installer supports GTK4
run: |
choco install innosetup -y -v
dotnet publish Pinta.sln -p:BuildTranslations=true -c Release -r win-x64 --self-contained true
iscc installer/windows/installer.iss
- name: Upload Installer
uses: actions/upload-artifact@v3
if: ${{ false }} # Disable until the installer supports GTK4
with:
name: "Pinta.exe"
path: installer/windows/Pinta.exe
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ po/stamp-it
xdg/pinta.desktop
xdg/pinta.appdata.xml
.vs
.vscode
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Thanks to the following contributors who worked on this release:
- @cameronwhite

### Added
- Ported to GTK4 and libadwaita
- Due to API changes in GTK4, the File -> New Screenshot option now invokes platform-specific tools (the XDG screenshot portal on Linux, and the screenshot tool on maCOS). This is currently unsupported on Windows

### Changed

Expand Down
10 changes: 5 additions & 5 deletions Pinta.Core/Actions/AddinActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Pinta.Core
{
public class AddinActions
{
private GLib.Menu addins_menu = null!; // NRT - Set by RegisterActions
private Gio.Menu addins_menu = null!; // NRT - Set by RegisterActions

public Command AddinManager { get; private set; }

Expand All @@ -43,15 +43,15 @@ public AddinActions ()
/// <summary>
/// Adds a new item to the Add-ins menu.
/// </summary>
public void AddMenuItem (GLib.MenuItem item)
public void AddMenuItem (Gio.MenuItem item)
{
addins_menu.AppendItem (item);
}

/// <summary>
/// Removes an item from the Add-ins menu.
/// </summary>
public void RemoveMenuItem (GLib.MenuItem item)
public void RemoveMenuItem (Gio.MenuItem item)
{
// TODO-GTK3 (addins)
throw new NotImplementedException ();
Expand All @@ -61,12 +61,12 @@ public void RemoveMenuItem (GLib.MenuItem item)
}

#region Initialization
public void RegisterActions (Gtk.Application app, GLib.Menu menu)
public void RegisterActions (Gtk.Application app, Gio.Menu menu)
{
app.AddAction (AddinManager);
menu.AppendItem (AddinManager.CreateMenuItem ());

addins_menu = new GLib.Menu ();
addins_menu = Gio.Menu.New ();
menu.AppendSection (null, addins_menu);
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion Pinta.Core/Actions/AppActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AppActions ()
}

#region Initialization
public void RegisterActions (Gtk.Application app, GLib.Menu menu)
public void RegisterActions (Gtk.Application app, Gio.Menu menu)
{
app.AddAction (About);
menu.AppendItem (About.CreateMenuItem ());
Expand Down
36 changes: 22 additions & 14 deletions Pinta.Core/Actions/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
// THE SOFTWARE.

using System;
using GLib;
using Gio;
using GObject;

namespace Pinta.Core
{
Expand All @@ -34,11 +35,11 @@ namespace Pinta.Core
/// </summary>
public class Command
{
public GLib.SimpleAction Action { get; private set; }
public Gio.SimpleAction Action { get; private set; }
public string Name {
get { return Action.Name; }
get { return Action.Name!; }
}
public ActivatedHandler? Activated;
public SignalHandler<SimpleAction, SimpleAction.ActivateSignalArgs>? Activated;
public void Activate ()
{
Action.Activate (null);
Expand All @@ -50,13 +51,16 @@ public void Activate ()
public string? IconName { get; private set; }
public string FullName { get { return string.Format ("app.{0}", Name); } }
public bool IsImportant { get; set; } = false;

public bool Sensitive { get { return Action.Enabled; } set { Action.Enabled = value; } }

public Command (string name, string label, string? tooltip, string? icon_name, GLib.Variant? state = null)
{
Action = new SimpleAction (name, null, state);
Action.Activated += (o, args) => {
if (state is not null)
Action = Gio.SimpleAction.NewStateful (name, null, state);
else
Action = Gio.SimpleAction.New (name, null);

Action.OnActivate += (o, args) => {
Activated?.Invoke (o, args);
};

Expand All @@ -65,35 +69,39 @@ public Command (string name, string label, string? tooltip, string? icon_name, G
IconName = icon_name;
}

public GLib.MenuItem CreateMenuItem ()
public Gio.MenuItem CreateMenuItem ()
{
return new GLib.MenuItem (Label, FullName);
return Gio.MenuItem.New (Label, FullName);
}
}

public class ToggleCommand : Command
{
public ToggleCommand (string name, string label, string? tooltip, string? stock_id)
: base (name, label, tooltip, stock_id, new GLib.Variant (false))
: base (name, label, tooltip, stock_id, CreateBoolVariant (false))
{
Activated += (o, args) => {
var active = !(bool) Action.State;
var active = !GetBoolValue (Action.GetState ());
Toggled?.Invoke (active);
Action.ChangeState (new GLib.Variant (active));
Action.ChangeState (CreateBoolVariant (active));
};
}

public bool Value {
get { return (bool) Action.State; }
get { return GetBoolValue (Action.GetState ()); }
set {
if (value != Value) {
Toggled?.Invoke (value);
Action.ChangeState (new Variant (value));
Action.ChangeState (CreateBoolVariant (value));
}
}
}

public delegate void ToggledHandler (bool value);
public ToggledHandler? Toggled;

// TODO-GTK4 - these should be in gir.core
private static GLib.Variant CreateBoolVariant (bool v) => new GLib.Variant (GLib.Internal.Variant.NewBoolean (v));
private static bool GetBoolValue (GLib.Variant val) => GLib.Internal.Variant.GetBoolean (val.Handle);
}
}

0 comments on commit 97626fe

Please sign in to comment.