From 5c72b03343322971fd3916c9d02d7e7c53dd9757 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Wed, 19 Dec 2018 21:09:59 -0800 Subject: [PATCH 1/2] Add back properties required by RUMPS (Mac status bar). This addresses issue #3550. --- Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs index 30f745aae..dde786709 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs @@ -37,6 +37,11 @@ namespace Duplicati.GUI.TrayIcon private bool m_enabled; private bool m_default; + public bool Default => this.m_default; + public bool Enabled => this.m_enabled; + public MenuIcons Icon => this.m_icon; + public string Text => this.m_text; + public MenuItemWrapper(RumpsRunner parent, string text, Action callback, IList subitems) { m_parent = parent; From da9b46e37ec8cc1f15c49ab098885922de6d5026 Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Wed, 19 Dec 2018 21:12:50 -0800 Subject: [PATCH 2/2] Use auto-properties to avoid explicit backing fields. --- .../GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs index dde786709..de7365d67 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/RumpsRunner.cs @@ -32,24 +32,19 @@ namespace Duplicati.GUI.TrayIcon private readonly RumpsRunner m_parent; - private string m_text; - private MenuIcons m_icon; - private bool m_enabled; - private bool m_default; - - public bool Default => this.m_default; - public bool Enabled => this.m_enabled; - public MenuIcons Icon => this.m_icon; - public string Text => this.m_text; + public bool Default { get; private set; } + public bool Enabled { get; private set; } + public MenuIcons Icon { get; private set; } + public string Text { get; private set; } public MenuItemWrapper(RumpsRunner parent, string text, Action callback, IList subitems) { m_parent = parent; Key = Guid.NewGuid().ToString("N"); - m_text = text ?? ""; + this.Text = text ?? ""; Callback = callback; - m_enabled = true; - m_default = false; + this.Enabled = true; + this.Default = false; if (subitems != null) Subitems = subitems.Cast().ToList(); } @@ -64,36 +59,36 @@ namespace Duplicati.GUI.TrayIcon #region IMenuItem implementation public void SetText(string text) { - if (m_text != text) + if (this.Text != text) { - m_text = text; + this.Text = text; m_parent.UpdateMenu(this); } } public void SetIcon(MenuIcons icon) { - if (m_icon != icon) + if (this.Icon != icon) { - m_icon = icon; + this.Icon = icon; m_parent.UpdateMenu(this); } } public void SetEnabled(bool isEnabled) { - if (m_enabled != isEnabled) + if (this.Enabled != isEnabled) { - m_enabled = isEnabled; + this.Enabled = isEnabled; m_parent.UpdateMenu(this); } } public void SetDefault(bool isDefault) { - if (m_default != isDefault) + if (this.Default != isDefault) { - m_default = isDefault; + this.Default = isDefault; m_parent.UpdateMenu(this); } }