Skip to content
Permalink
Browse files

Clipboard: add GTK support

  • Loading branch information
lukethenuke authored and knocte committed Jan 30, 2020
1 parent f20c1ec commit a5bb9b4902b5aeee0d43f0e121694774179cc11b
BIN +243 KB Libs/gdk-sharp.dll
Binary file not shown.
BIN +100 KB Libs/glib-sharp.dll
Binary file not shown.
BIN +1.43 MB Libs/gtk-sharp.dll
Binary file not shown.
@@ -4,6 +4,31 @@ namespace Xamarin.Essentials
{
public static partial class Clipboard
{
#if GTK
private static readonly Gdk.Atom clipboardAtom = Gdk.Atom.Intern("CLIPBOARD", false);

static Task PlatformSetTextAsync(string text)
{
var clipboard = Gtk.Clipboard.Get(clipboardAtom);
clipboard.Text = text;
return Task.FromResult(0);
}

static bool PlatformHasText
{
get
{
var clipboard = Gtk.Clipboard.Get(clipboardAtom);
return clipboard.WaitIsTextAvailable();
}
}

static Task<string> PlatformGetTextAsync()
{
var clipboard = Gtk.Clipboard.Get(clipboardAtom);
return Task.FromResult(clipboard.WaitForText());
}
#else
static Task PlatformSetTextAsync(string text)
=> throw ExceptionUtils.NotSupportedOrImplementedException;

@@ -12,5 +37,6 @@ static bool PlatformHasText

static Task<string> PlatformGetTextAsync()
=> throw ExceptionUtils.NotSupportedOrImplementedException;
#endif
}
}
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || GTK
using System.Net.NetworkInformation;
#endif

namespace Xamarin.Essentials
{
public static partial class Connectivity
{
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || GTK
static void StartListeners()
{
NetworkChange.NetworkAddressChanged += NetworkStatusChanged;
@@ -1,13 +1,40 @@
using System;
#if GTK
using System.Threading;
#endif

namespace Xamarin.Essentials
{
public static partial class MainThread
{
#if GTK
#pragma warning disable SA1130
static void PlatformBeginInvokeOnMainThread(Action action) => Gtk.Application.Invoke(delegate { action(); });

static int? uiThreadId = null;

static bool PlatformIsMainThread
{
get
{
if (uiThreadId == null)
{
Gtk.Application.Invoke(delegate { uiThreadId = Thread.CurrentThread.ManagedThreadId; });
return false;
}
else
{
return System.Threading.Thread.CurrentThread.ManagedThreadId == uiThreadId;
}
}
}
#pragma warning restore SA1130
#else
static void PlatformBeginInvokeOnMainThread(Action action) =>
throw ExceptionUtils.NotSupportedOrImplementedException;

static bool PlatformIsMainThread =>
throw ExceptionUtils.NotSupportedOrImplementedException;
#endif
}
}
@@ -1,7 +1,7 @@
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard1.0;netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;Xamarin.WatchOS10;MonoAndroid60;MonoAndroid70;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;uap10.0.16299;tizen40;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.0;netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;Xamarin.WatchOS10;MonoAndroid60;MonoAndroid70;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;tizen40;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard1.0;netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;Xamarin.WatchOS10;MonoAndroid60;MonoAndroid70;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;uap10.0.16299;tizen40;net461;</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.0;netstandard2.0;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;Xamarin.WatchOS10;MonoAndroid60;MonoAndroid70;MonoAndroid71;MonoAndroid80;MonoAndroid81;MonoAndroid90;tizen40;net461;</TargetFrameworks>
<AssemblyName>Xamarin.Essentials</AssemblyName>
<RootNamespace>Xamarin.Essentials</RootNamespace>
<PackageId>DotNetEssentials</PackageId>
@@ -111,6 +111,26 @@
<Compile Include="**\*.tizen.cs" />
<Compile Include="**\*.tizen.*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('net461')) ">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<Reference Include="gtk-sharp, Version=2.12.0.0">
<HintPath>../Libs/gtk-sharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="glib-sharp, Version=2.12.0.0">
<HintPath>../Libs/glib-sharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="gdk-sharp, Version=2.12.0.0">
<HintPath>../Libs/gdk-sharp.dll</HintPath>
<Private>false</Private>
</Reference>
<Compile Include="**\*.netstandard.cs" />
<Compile Include="**\*.netstandard.*.cs" />
</ItemGroup>
<PropertyGroup Condition=" $(TargetFramework.StartsWith('net461')) ">
<DefineConstants>$(DefineConstants);GTK</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)mdoc.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\CodeStyles.targets" />
</Project>

0 comments on commit a5bb9b4

Please sign in to comment.
You can’t perform that action at this time.