Skip to content

Commit

Permalink
Merge pull request PintaProject#474 from Lehonti/improvement3
Browse files Browse the repository at this point in the history
In `ComboBoxWidget`, moved body of `Build()` to constructor
  • Loading branch information
cameronwhite authored Sep 15, 2023
2 parents d525cca + e935068 commit 5a5a1e3
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions Pinta.Gui.Widgets/Widgets/ComboBoxWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,37 @@
// THE SOFTWARE.

using System;
using System.Diagnostics.CodeAnalysis;
using Gtk;
using Pinta.Core;

namespace Pinta.Gui.Widgets;

public sealed class ComboBoxWidget : Box
{
private Label label;
private ComboBoxText combobox;
private readonly Label label;
private readonly ComboBoxText combobox;

public ComboBoxWidget (string[] entries)
{
Build ();
const int spacing = 6;

// Section label + line
var hbox1 = new Box { Spacing = spacing };
hbox1.SetOrientation (Orientation.Horizontal);

label = new Label ();
label.AddCssClass (AdwaitaStyles.Title4);
hbox1.Append (label);

// Combobox
combobox = new ComboBoxText ();

// Main layout
// Main layout
SetOrientation (Orientation.Vertical);
Spacing = spacing;
Append (hbox1);
Append (combobox);

foreach (var s in entries)
combobox.AppendText (s);
Expand All @@ -61,28 +78,4 @@ public int Active {
public string ActiveText => combobox.GetActiveText ()!;

public event EventHandler? Changed;

[MemberNotNull (nameof (label), nameof (combobox))]
private void Build ()
{
const int spacing = 6;

// Section label + line
var hbox1 = new Box () { Spacing = spacing };
hbox1.SetOrientation (Orientation.Horizontal);

label = new Label ();
label.AddCssClass (AdwaitaStyles.Title4);
hbox1.Append (label);

// Combobox
combobox = new ComboBoxText ();

// Main layout
// Main layout
SetOrientation (Orientation.Vertical);
Spacing = spacing;
Append (hbox1);
Append (combobox);
}
}

0 comments on commit 5a5a1e3

Please sign in to comment.