Rip out libappindicator as it isn't compatible with net5

This fixes #4529.
This commit is contained in:
Thomas Suckow
2021-06-28 09:52:13 -07:00
committed by Kenneth Hsu
parent 060b4886da
commit 69d90e8fc3
4 changed files with 18 additions and 137 deletions
@@ -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<IMenuItem> 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
@@ -27,23 +27,18 @@
</ItemGroup>
<ItemGroup>
<Reference Include="appindicator-sharp">
<HintPath>..\..\..\thirdparty\appindicator-sharp\appindicator-sharp.dll</HintPath>
</Reference>
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<HintPath>..\..\..\thirdparty\appindicator-sharp\gdk-sharp.dll</HintPath>
</Reference>
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<HintPath>..\..\..\thirdparty\appindicator-sharp\gtk-sharp.dll</HintPath>
</Reference>
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<PackageReference Include="GtkSharp" Version="3.24.24.4" />
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="MonoMac">
<HintPath>..\..\..\thirdparty\MonoMac\MonoMac.dll</HintPath>
</Reference>
<Reference Include="notify-sharp">
<HintPath>..\..\..\thirdparty\notify-sharp\notify-sharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -146,4 +141,4 @@
</PackageReference>
</ItemGroup>
</Project>
</Project>
@@ -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)
@@ -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)