diff --git a/Pinta.Core/Classes/BaseTool.cs b/Pinta.Core/Classes/BaseTool.cs
index 965d310683..41805469c5 100644
--- a/Pinta.Core/Classes/BaseTool.cs
+++ b/Pinta.Core/Classes/BaseTool.cs
@@ -340,7 +340,7 @@ public void SetCursor (Cursor? cursor)
private ToolBarDropDownButton AlphaBlendingDropDown {
get {
if (alphablending_button is null) {
- alphablending_button = new ToolBarDropDownButton ();
+ alphablending_button = ToolBarDropDownButton.New ();
alphablending_button.AddItem (Translations.GetString ("Normal Blending"), Pinta.Resources.Icons.BlendingNormal, true);
alphablending_button.AddItem (Translations.GetString ("Overwrite"), Pinta.Resources.Icons.BlendingOverwrite, false);
@@ -357,7 +357,7 @@ private ToolBarDropDownButton AlphaBlendingDropDown {
private ToolBarDropDownButton AntialiasingDropDown {
get {
if (antialiasing_button is null) {
- antialiasing_button = new ToolBarDropDownButton ();
+ antialiasing_button = ToolBarDropDownButton.New ();
antialiasing_button.AddItem (Translations.GetString ("Antialiasing On"), Pinta.Resources.Icons.AntiAliasingEnabled, true);
antialiasing_button.AddItem (Translations.GetString ("Antialiasing Off"), Pinta.Resources.Icons.AntiAliasingDisabled, false);
diff --git a/Pinta.Core/Pinta.Core.csproj b/Pinta.Core/Pinta.Core.csproj
index 1952e07559..d7e9fccca6 100644
--- a/Pinta.Core/Pinta.Core.csproj
+++ b/Pinta.Core/Pinta.Core.csproj
@@ -5,6 +5,7 @@
+
diff --git a/Pinta.Core/Widgets/ToolBarDropDownButton.cs b/Pinta.Core/Widgets/ToolBarDropDownButton.cs
index 7ac6211c05..cc48af818c 100644
--- a/Pinta.Core/Widgets/ToolBarDropDownButton.cs
+++ b/Pinta.Core/Widgets/ToolBarDropDownButton.cs
@@ -1,26 +1,35 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Pinta.Core;
-public sealed class ToolBarDropDownButton : Gtk.MenuButton
+[GObject.Subclass]
+public sealed partial class ToolBarDropDownButton
{
private const string ACTION_PREFIX = "tool";
- private readonly bool show_label;
- private readonly Gio.Menu dropdown;
- private readonly Gio.SimpleActionGroup action_group;
+ private bool show_label;
+ private Gio.Menu dropdown;
+ private Gio.SimpleActionGroup action_group;
private ToolBarItem? selected_item;
- private readonly List items;
- public ReadOnlyCollection Items { get; }
+ private List items;
+ public ReadOnlyCollection Items { get; private set; }
- public ToolBarDropDownButton (bool showLabel = false)
+ public static ToolBarDropDownButton New(bool showLabel = false)
{
- show_label = showLabel;
+ var obj = NewWithProperties([]);
+ obj.show_label = showLabel;
+ return obj;
+ }
+
+ [MemberNotNull(nameof(items), nameof(Items), nameof(action_group), nameof(dropdown))]
+ partial void Initialize()
+ {
items = [];
Items = new ReadOnlyCollection (items);
AlwaysShowArrow = true;
diff --git a/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs b/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
index a307273ea2..14f17e8d05 100644
--- a/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
+++ b/Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
@@ -302,7 +302,7 @@ public virtual void HandleBuildToolBar (Gtk.Box tb, ISettingsService settings, s
tb.Append (fill_label);
if (fill_button == null) {
- fill_button = new ToolBarDropDownButton ();
+ fill_button = ToolBarDropDownButton.New ();
fill_button.AddItem (Translations.GetString ("Outline Shape"), Resources.Icons.FillStyleOutline, 0);
fill_button.AddItem (Translations.GetString ("Fill Shape"), Resources.Icons.FillStyleFill, 1);
@@ -328,7 +328,7 @@ public virtual void HandleBuildToolBar (Gtk.Box tb, ISettingsService settings, s
tb.Append (shape_type_label);
if (shape_type_button == null) {
- shape_type_button = new ToolBarDropDownButton ();
+ shape_type_button = ToolBarDropDownButton.New ();
shape_type_button.AddItem (Translations.GetString ("Open Line/Curve Series"), Resources.Icons.ToolLine, 0);
shape_type_button.AddItem (Translations.GetString ("Closed Line/Curve Series"), Resources.Icons.ToolRectangle, 1);