From 69d90e8fc3ffc51065cb7b101e6378ca862d04c8 Mon Sep 17 00:00:00 2001 From: Thomas Suckow Date: Fri, 19 Mar 2021 06:42:02 -0700 Subject: [PATCH] Rip out libappindicator as it isn't compatible with net5 This fixes #4529. --- .../AppIndicatorRunner.cs | 88 ------------------- .../Duplicati.GUI.TrayIcon.csproj | 25 +++--- .../GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs | 4 + .../GUI/Duplicati.GUI.TrayIcon/Program.cs | 38 +------- 4 files changed, 18 insertions(+), 137 deletions(-) delete mode 100644 Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs deleted file mode 100644 index 540382e7b..000000000 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/AppIndicatorRunner.cs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2015, The Duplicati Team -// http://www.duplicati.com, info@duplicati.com -// -// This library is free software; you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as -// published by the Free Software Foundation; either version 2.1 of the -// License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -#if __WindowsGTK__ || ENABLE_GTK -using System; -using AppIndicator; -using Gtk; -using System.Collections.Generic; - -using Duplicati.Library.Common.IO; -using Duplicati.Library.Utility; -using Duplicati.Server.Serialization; - - -namespace Duplicati.GUI.TrayIcon -{ - public class AppIndicatorRunner : GtkRunner - { - protected ApplicationIndicator m_appIndicator; - private string m_themeFolder; - - protected override void CreateTrayInstance() - { - m_themeFolder = SystemIO.IO_OS.PathCombine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"TrayResources\SVGIcons"); - m_themeFolder = SystemIO.IO_OS.PathCombine(m_themeFolder, "dark"); - - m_appIndicator = new ApplicationIndicator("duplicati", "normal", Category.ApplicationStatus, m_themeFolder); - } - - protected override void Run(string[] args) - { - m_appIndicator.Menu.ShowAll(); - m_appIndicator.Status = Status.Active; - Gtk.Application.Run(); - } - - protected override void SetMenu (IEnumerable items) - { - base.SetMenu(items); - m_appIndicator.Menu = m_popupMenu; - } - - protected override void SetIcon(TrayIcons icon) - { - m_appIndicator.IconName = GetTrayIconFilename(icon); - - switch (icon) - { - case TrayIcons.Paused: - m_appIndicator.IconDesc = "Paused"; - break; - case TrayIcons.Running: - m_appIndicator.IconDesc = "Running"; - break; - case TrayIcons.IdleWarning: - m_appIndicator.IconDesc = "Warning"; - break; - case TrayIcons.IdleError: - m_appIndicator.IconDesc = "Error"; - break; - case TrayIcons.RunningError: - m_appIndicator.IconDesc = "Running"; - break; - case TrayIcons.PausedError: - m_appIndicator.IconDesc = "Paused"; - break; - case TrayIcons.Idle: - default: - m_appIndicator.IconDesc = "Ready"; - break; - } - } - } -} -#endif diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj index 58aaed530..133a00e23 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Duplicati.GUI.TrayIcon.csproj @@ -27,23 +27,18 @@ - - ..\..\..\thirdparty\appindicator-sharp\appindicator-sharp.dll - - - ..\..\..\thirdparty\appindicator-sharp\gdk-sharp.dll - - - ..\..\..\thirdparty\appindicator-sharp\gtk-sharp.dll - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + ..\..\..\thirdparty\MonoMac\MonoMac.dll - - ..\..\..\thirdparty\notify-sharp\notify-sharp.dll - @@ -146,4 +141,4 @@ - \ No newline at end of file + diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs index 3b81a6e68..f5a5f99fa 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/GtkRunner.cs @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + #if __WindowsGTK__ || ENABLE_GTK using System; using System.Collections.Generic; @@ -343,8 +344,11 @@ namespace Duplicati.GUI.TrayIcon break; } + /* + FIXME: Someone would need to port notify-sharp to use Tmds.DBus var notification = new Notifications.Notification(title, message, icon); notification.Show(); + */ } protected void StatusUpdateEvent(object sender, EventArgs a) diff --git a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs index e2881901b..91df59727 100644 --- a/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs +++ b/Duplicati/GUI/Duplicati.GUI.TrayIcon/Program.cs @@ -19,7 +19,6 @@ namespace Duplicati.GUI.TrayIcon private const string TOOLKIT_OPTION = "toolkit"; private const string TOOLKIT_WINDOWS_FORMS = "winforms"; private const string TOOLKIT_GTK = "gtk"; - private const string TOOLKIT_GTK_APP_INDICATOR = "gtk-appindicator"; private const string TOOLKIT_COCOA = "cocoa"; private const string TOOLKIT_RUMPS = "rumps"; @@ -50,9 +49,6 @@ namespace Duplicati.GUI.TrayIcon #if __WindowsGTK__ || ENABLE_GTK if (Platform.IsClientPosix) { - if (SupportsAppIndicator) - return TOOLKIT_GTK_APP_INDICATOR; - else return TOOLKIT_GTK; } else @@ -128,8 +124,6 @@ namespace Duplicati.GUI.TrayIcon #if __WindowsGTK__ || ENABLE_GTK else if (TOOLKIT_GTK.Equals(toolkit, StringComparison.OrdinalIgnoreCase)) toolkit = TOOLKIT_GTK; - else if (TOOLKIT_GTK_APP_INDICATOR.Equals(toolkit, StringComparison.OrdinalIgnoreCase)) - toolkit = TOOLKIT_GTK_APP_INDICATOR; #endif else if (TOOLKIT_COCOA.Equals(toolkit, StringComparison.OrdinalIgnoreCase)) toolkit = TOOLKIT_COCOA; @@ -294,13 +288,14 @@ namespace Duplicati.GUI.TrayIcon private static TrayIconBase RunTrayIcon(string toolkit) { + //https://medium.com/@k.l.mueller/cross-platform-tray-bar-applications-with-xamarin-forms-bbd6c1b7f17a + //https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/other/gtk?tabs=windows + if (toolkit == TOOLKIT_WINDOWS_FORMS) return GetWinformsInstance(); #if __WindowsGTK__ || ENABLE_GTK else if (toolkit == TOOLKIT_GTK) return GetGtkInstance(); - else if (toolkit == TOOLKIT_GTK_APP_INDICATOR) - return GetAppIndicatorInstance(); #endif else if (toolkit == TOOLKIT_COCOA) return GetCocoaRunnerInstance(); @@ -322,8 +317,6 @@ namespace Duplicati.GUI.TrayIcon #if __MonoCS__ || __WindowsGTK__ || ENABLE_GTK [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static TrayIconBase GetGtkInstance() { return new GtkRunner(); } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static TrayIconBase GetAppIndicatorInstance() { return new AppIndicatorRunner(); } #endif [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static TrayIconBase GetCocoaRunnerInstance() { return new CocoaRunner(); } @@ -340,7 +333,7 @@ namespace Duplicati.GUI.TrayIcon private static bool TryGetGtk() { #if __WindowsGTK__ || ENABLE_GTK - return typeof(Gtk.StatusIcon) != null && typeof(Gdk.Image) != null; + return typeof(Gtk.StatusIcon) != null; #else return false; #endif @@ -351,16 +344,6 @@ namespace Duplicati.GUI.TrayIcon { return Platform.IsClientWindows; } - - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] - private static bool TryGetAppIndicator() - { -#if __WindowsGTK__ || ENABLE_GTK - return typeof(AppIndicator.ApplicationIndicator) != null; -#else - return false; -#endif - } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] private static bool TryGetMonoMac() @@ -382,17 +365,6 @@ namespace Duplicati.GUI.TrayIcon } } - private static bool SupportsAppIndicator - { - get - { - try { return TryGetAppIndicator(); } - catch {} - - return false; - } - } - private static bool SupportsCocoa { get @@ -436,8 +408,6 @@ namespace Duplicati.GUI.TrayIcon toolkits.Add(TOOLKIT_WINDOWS_FORMS); if (SupportsGtk) toolkits.Add(TOOLKIT_GTK); - if (SupportsAppIndicator) - toolkits.Add(TOOLKIT_GTK_APP_INDICATOR); if (SupportsCocoa) toolkits.Add(TOOLKIT_COCOA); if (SupportsRumps)