Skip to content

Instantly share code, notes, and snippets.

@Therzok
Created October 21, 2019 22:30
Show Gist options
  • Save Therzok/b04521325a87d0a4c09da21a8f43d932 to your computer and use it in GitHub Desktop.
Save Therzok/b04521325a87d0a4c09da21a8f43d932 to your computer and use it in GitHub Desktop.
diff --git a/gtk/generated/Clipboard.cs b/gtk/generated/Clipboard.cs
index 4ce8495ae..a49cfa424 100644
--- a/gtk/generated/Clipboard.cs
+++ b/gtk/generated/Clipboard.cs
@@ -154,6 +154,7 @@ namespace Gtk {
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_clipboard_request_targets(IntPtr raw, GtkSharp.ClipboardTargetsReceivedFuncNative cb, IntPtr user_data);
+ [Obsolete]
public void RequestTargets(Gtk.ClipboardTargetsReceivedFunc cb) {
Gtk.Application.AssertMainThread();
IntPtr gch = IntPtr.Zero;
@@ -176,11 +177,13 @@ namespace Gtk {
}
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern void gtk_clipboard_set_can_store(IntPtr raw, ref Gtk.TargetEntry targets, int n_targets);
+ static extern void gtk_clipboard_set_can_store(IntPtr raw, Gtk.TargetEntry[] targets, int n_targets);
- public void SetCanStore(Gtk.TargetEntry targets, int n_targets) {
- Gtk.Application.AssertMainThread();
- gtk_clipboard_set_can_store(Handle, ref targets, n_targets);
+ public Gtk.TargetEntry[] CanStore {
+ set {
+ Gtk.Application.AssertMainThread();
+ gtk_clipboard_set_can_store(Handle, value, (value == null ? 0 : value.Length));
+ }
}
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
@@ -234,6 +237,7 @@ namespace Gtk {
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern bool gtk_clipboard_wait_for_targets(IntPtr raw, out IntPtr targets, out int n_targets);
+ [Obsolete]
public bool WaitForTargets(out Gdk.Atom targets, out int n_targets) {
Gtk.Application.AssertMainThread();
IntPtr native_targets;
@@ -411,6 +415,47 @@ namespace Gtk {
gtk_clipboard_request_rich_text (Handle, buffer == null ? IntPtr.Zero : buffer.Handle, rt_rcvd_marshaler, (IntPtr) GCHandle.Alloc (cb));
}
+ [Obsolete("Use CanStore setter")]
+ public void SetCanStore (Gtk.TargetEntry targets, int n_targets)
+ {
+ CanStore = new Gtk.TargetEntry[] { targets };
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll", EntryPoint="gtk_clipboard_wait_for_targets", CallingConvention = CallingConvention.Cdecl)]
+ static extern bool gtk_clipboard_wait_for_targets2(IntPtr raw, out IntPtr targets, out int n_targets);
+
+ public bool WaitForTargets(out Gdk.Atom[] targets) {
+ Gtk.Application.AssertMainThread();
+
+ IntPtr raw_targets;
+ int n_targets;
+
+ bool raw_ret = gtk_clipboard_wait_for_targets2(Handle, out raw_targets, out n_targets);
+
+ targets = new Gdk.Atom [n_targets];
+ for (int i = 0; i < n_targets; ++i) {
+ targets[i] = (Gdk.Atom) GLib.Opaque.GetOpaque (IntPtr.Add(raw_targets, IntPtr.Size * i), typeof(Gdk.Atom), true);
+ }
+ GLib.Marshaller.Free (raw_targets);
+
+ return raw_ret;
+ }
+
+ [DllImport("libgtk-win32-2.0-0.dll", EntryPoint="gtk_clipboard_request_targets", CallingConvention = CallingConvention.Cdecl)]
+ static extern void gtk_clipboard_request_targets2(IntPtr raw, GtkSharp.ClipboardTargetsReceivedFuncNative2 cb, IntPtr user_data);
+
+ public void RequestTargets(Gtk.ClipboardTargetsReceivedFunc2 cb) {
+ Gtk.Application.AssertMainThread();
+ IntPtr gch = IntPtr.Zero;
+ if (cb != null) {
+ gch = (IntPtr)GCHandle.Alloc (cb);
+ }
+ gtk_clipboard_request_targets2(Handle, (cb == null) ? null : GtkSharp.ClipboardTargetsReceivedFuncWrapper2.NativeDelegate, (IntPtr)gch);
+ }
+
+
+
+
#endregion
}
diff --git a/gtk/generated/Selection.cs b/gtk/generated/Selection.cs
index ce49ac69a..d6dd8993e 100644
--- a/gtk/generated/Selection.cs
+++ b/gtk/generated/Selection.cs
@@ -18,11 +18,11 @@ namespace Gtk {
}
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern void gtk_selection_add_targets(IntPtr widget, IntPtr selection, ref Gtk.TargetEntry targets, uint ntargets);
+ static extern void gtk_selection_add_targets(IntPtr widget, IntPtr selection, Gtk.TargetEntry[] targets, uint n_targets);
- public static void AddTargets(Gtk.Widget widget, Gdk.Atom selection, Gtk.TargetEntry targets, uint ntargets) {
+ public static void AddTargets(Gtk.Widget widget, Gdk.Atom selection, Gtk.TargetEntry[] targets) {
Gtk.Application.AssertMainThread();
- gtk_selection_add_targets(widget == null ? IntPtr.Zero : widget.Handle, selection == null ? IntPtr.Zero : selection.Handle, ref targets, ntargets);
+ gtk_selection_add_targets(widget == null ? IntPtr.Zero : widget.Handle, selection == null ? IntPtr.Zero : selection.Handle, targets, (uint) (targets == null ? 0 : targets.Length));
}
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
@@ -82,6 +82,34 @@ namespace Gtk {
gtk_selection_remove_all(widget == null ? IntPtr.Zero : widget.Handle);
}
+#endregion
+#region Customized extensions
+#line 1 "Selection.custom"
+// Selection.custom - customizations for Gtk.Selection
+//
+// Authors: Marius Ungureanu - maungu@microsoft.com
+//
+// Copyright (c) 2017 Microsoft, Inc.
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of version 2 of the Lesser GNU General
+// Public License as published by the Free Software Foundation.
+//
+// This program 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 program; if not, write to the
+// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+ [Obsolete ("Please use the AddTargets(Widget, Atom, TargetEntry[]) overload")]
+ public static void AddTargets(Gtk.Widget widget, Gdk.Atom selection, Gtk.TargetEntry targets, uint ntargets) {
+ AddTargets (widget, selection, new Gtk.TargetEntry[] { targets });
+ }
+
#endregion
}
}
diff --git a/gtk/generated/Target.cs b/gtk/generated/Target.cs
index c95ec1cef..f31a9db0c 100644
--- a/gtk/generated/Target.cs
+++ b/gtk/generated/Target.cs
@@ -10,16 +10,20 @@ namespace Gtk {
public class Target {
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
- static extern void gtk_target_table_free(ref Gtk.TargetEntry targets, int n_targets);
+ static extern void gtk_target_table_free(Gtk.TargetEntry[] targets, int n_targets);
- public static void TableFree(Gtk.TargetEntry targets, int n_targets) {
+ public static void TableFree(Gtk.TargetEntry[] targets) {
Gtk.Application.AssertMainThread();
- gtk_target_table_free(ref targets, n_targets);
+ gtk_target_table_free(targets, (targets == null ? 0 : targets.Length));
}
+#endregion
+#region Customized extensions
+#line 1 "Target.custom"
[DllImport("libgtk-win32-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_target_table_new_from_list(IntPtr list, out int n_targets);
+ [Obsolete]
public static Gtk.TargetEntry TableNewFromList(Gtk.TargetList list, out int n_targets) {
Gtk.Application.AssertMainThread();
IntPtr raw_ret = gtk_target_table_new_from_list(list == null ? IntPtr.Zero : list.Handle, out n_targets);
@@ -27,6 +31,19 @@ namespace Gtk {
return ret;
}
+ [Obsolete]
+ public static void TableFree(Gtk.TargetEntry targets, int n_targets) {
+ Gtk.Application.AssertMainThread();
+ TableFree(new Gtk.TargetEntry[] { targets });
+ }
+
+ public static Gtk.TargetEntry[] TableNewFromList(Gtk.TargetList list) {
+ Gtk.Application.AssertMainThread();
+ // there is an explicit operator
+ return (Gtk.TargetEntry[])list;
+ }
+
+
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment