Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Pinta.Core/Classes/BaseTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Pinta.Core/Pinta.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

<Import Project="../properties/ReferenceGirCoreAdw1.props" />
<Import Project="../properties/ReferenceGirCorePangoCairo10.props" />
<Import Project="../properties/ReferenceGirCoreGObject20Integration.props" />

<ItemGroup>
<PackageReference Include="NGettext" />
Expand Down
25 changes: 17 additions & 8 deletions Pinta.Core/Widgets/ToolBarDropDownButton.cs
Original file line number Diff line number Diff line change
@@ -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<Gtk.MenuButton>]
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;

Check warning on line 14 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

Field 'ToolBarDropDownButton.show_label' is never assigned to, and will always have its default value false

Check warning on line 14 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

Field 'ToolBarDropDownButton.show_label' is never assigned to, and will always have its default value false

Check warning on line 14 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

Field 'ToolBarDropDownButton.show_label' is never assigned to, and will always have its default value false

Check warning on line 14 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

Field 'ToolBarDropDownButton.show_label' is never assigned to, and will always have its default value false
private Gio.Menu dropdown;
private Gio.SimpleActionGroup action_group;
private ToolBarItem? selected_item;

private readonly List<ToolBarItem> items;
public ReadOnlyCollection<ToolBarItem> Items { get; }
private List<ToolBarItem> items;
public ReadOnlyCollection<ToolBarItem> Items { get; private set; }

public ToolBarDropDownButton (bool showLabel = false)
public static ToolBarDropDownButton New(bool showLabel = false)
{
show_label = showLabel;
var obj = NewWithProperties([]);

Check failure on line 24 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

There is no argument given that corresponds to the required parameter 'names' of 'Object.NewWithProperties(Type, string[], Value[])'

Check failure on line 24 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

There is no argument given that corresponds to the required parameter 'names' of 'Object.NewWithProperties(Type, string[], Value[])'

Check failure on line 24 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

There is no argument given that corresponds to the required parameter 'names' of 'Object.NewWithProperties(Type, string[], Value[])'

Check failure on line 24 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

There is no argument given that corresponds to the required parameter 'names' of 'Object.NewWithProperties(Type, string[], Value[])'
obj.show_label = showLabel;

Check failure on line 25 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

'Object' does not contain a definition for 'show_label' and no accessible extension method 'show_label' accepting a first argument of type 'Object' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 25 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

'Object' does not contain a definition for 'show_label' and no accessible extension method 'show_label' accepting a first argument of type 'Object' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 25 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

'Object' does not contain a definition for 'show_label' and no accessible extension method 'show_label' accepting a first argument of type 'Object' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 25 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

'Object' does not contain a definition for 'show_label' and no accessible extension method 'show_label' accepting a first argument of type 'Object' could be found (are you missing a using directive or an assembly reference?)

return obj;

Check failure on line 27 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

Cannot implicitly convert type 'GObject.Object' to 'Pinta.Core.ToolBarDropDownButton'. An explicit conversion exists (are you missing a cast?)

Check failure on line 27 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-macos (osx-arm64)

Cannot implicitly convert type 'GObject.Object' to 'Pinta.Core.ToolBarDropDownButton'. An explicit conversion exists (are you missing a cast?)

Check failure on line 27 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

Cannot implicitly convert type 'GObject.Object' to 'Pinta.Core.ToolBarDropDownButton'. An explicit conversion exists (are you missing a cast?)

Check failure on line 27 in Pinta.Core/Widgets/ToolBarDropDownButton.cs

View workflow job for this annotation

GitHub Actions / build-windows (win-x64)

Cannot implicitly convert type 'GObject.Object' to 'Pinta.Core.ToolBarDropDownButton'. An explicit conversion exists (are you missing a cast?)
}

[MemberNotNull(nameof(items), nameof(Items), nameof(action_group), nameof(dropdown))]
partial void Initialize()
{
items = [];
Items = new ReadOnlyCollection<ToolBarItem> (items);
AlwaysShowArrow = true;
Expand Down
4 changes: 2 additions & 2 deletions Pinta.Tools/Editable/EditEngines/BaseEditEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Loading