From 0a40b1623f53031023638dd5f5cf603f90b3a10f Mon Sep 17 00:00:00 2001 From: DaPigGuy Date: Tue, 14 Nov 2023 19:30:00 -0800 Subject: [PATCH] GNOME - Don't use Adw.ButtonContent outside a Gtk.Button `Adw.ButtonContent` expects its parent to be a `Gtk.Button`, resulting in error messages here on startup. --- NickvisionMoney.GNOME/Blueprints/window.blp | 11 ++++++++++- NickvisionMoney.GNOME/Views/MainWindow.cs | 15 ++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/NickvisionMoney.GNOME/Blueprints/window.blp b/NickvisionMoney.GNOME/Blueprints/window.blp index c1cf54465..e1287e82e 100644 --- a/NickvisionMoney.GNOME/Blueprints/window.blp +++ b/NickvisionMoney.GNOME/Blueprints/window.blp @@ -158,10 +158,19 @@ Adw.ApplicationWindow _root { hexpand: true; halign: fill; - Adw.ButtonContent _greeting { + Gtk.Box { halign: center; margin-top: 24; margin-bottom: 14; + + Gtk.Image _greetingIcon { + pixel-size: 48; + margin-end: 12; + } + + Gtk.Label _greetingLabel { + styles ["greeting-title"] + } } Gtk.Label _dragLabel { diff --git a/NickvisionMoney.GNOME/Views/MainWindow.cs b/NickvisionMoney.GNOME/Views/MainWindow.cs index 63619a621..90075db85 100644 --- a/NickvisionMoney.GNOME/Views/MainWindow.cs +++ b/NickvisionMoney.GNOME/Views/MainWindow.cs @@ -35,7 +35,8 @@ public partial class MainWindow : Adw.ApplicationWindow [Gtk.Connect] private readonly Adw.Bin _dashboardBin; [Gtk.Connect] private readonly Adw.ToastOverlay _toastOverlay; [Gtk.Connect] private readonly Adw.ViewStack _viewStack; - [Gtk.Connect] private readonly Adw.ButtonContent _greeting; + [Gtk.Connect] private readonly Gtk.Image _greetingIcon; + [Gtk.Connect] private readonly Gtk.Label _greetingLabel; [Gtk.Connect] private readonly Adw.PreferencesGroup _startPageRecentAccountsGroup; [Gtk.Connect] private readonly Gtk.Button _newAccountButton; [Gtk.Connect] private readonly Gtk.Button _openAccountButton; @@ -87,16 +88,8 @@ private MainWindow(Gtk.Builder builder, MainWindowController controller, Adw.App _windowTitle.SetTitle(_controller.AppInfo.ShortName); _graphToggleButton.SetActive(_controller.ShowGraphs); //Greeting - _greeting.SetIconName(_controller.ShowSun ? "sun-outline-symbolic" : "moon-outline-symbolic"); - _greeting.SetLabel(_controller.Greeting); - var image = (Gtk.Image)_greeting.GetFirstChild(); - image.SetPixelSize(48); - image.SetMarginEnd(6); - var label = (Gtk.Label)_greeting.GetLastChild(); - label.AddCssClass("greeting-title"); - _greeting.SetHalign(Gtk.Align.Center); - _greeting.SetMarginTop(24); - _greeting.SetMarginBottom(14); + _greetingIcon.SetFromIconName(_controller.ShowSun ? "sun-outline-symbolic" : "moon-outline-symbolic"); + _greetingLabel.SetLabel(_controller.Greeting); //Page Tabs _tabView.OnClosePage += OnCloseAccountPage; //New Account Action