diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2017-01-22 20:34:28 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2017-01-22 20:34:28 +0100 |
| commit | 35a788582f7128581f409086e69a93acc43eeff8 (patch) | |
| tree | f03f64438e66761f571bcf73ab2be8397d98c40a /src | |
| parent | bf810209745cc2f90bb5f60164efaa1b6259a31f (diff) | |
remove GLib refs from rsvg-sharp, keep mostly only func used by crow
Diffstat (limited to 'src')
| -rw-r--r-- | src/rsvg/DimensionData.cs | 9 | ||||
| -rw-r--r-- | src/rsvg/Handle.cs | 187 | ||||
| -rw-r--r-- | src/rsvg/Pixbuf.cs | 133 | ||||
| -rw-r--r-- | src/rsvg/RsvgSharp.SizeFuncNative.cs | 94 | ||||
| -rw-r--r-- | src/rsvg/SizeFunc.cs | 10 |
5 files changed, 23 insertions, 410 deletions
diff --git a/src/rsvg/DimensionData.cs b/src/rsvg/DimensionData.cs index 20da1aab..83e5c6ef 100644 --- a/src/rsvg/DimensionData.cs +++ b/src/rsvg/DimensionData.cs @@ -1,13 +1,9 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - namespace Rsvg { using System; using System.Collections; using System.Runtime.InteropServices; -#region Autogenerated code [StructLayout(LayoutKind.Sequential)] public struct DimensionData { @@ -23,10 +19,5 @@ namespace Rsvg { return Rsvg.DimensionData.Zero; return (Rsvg.DimensionData) Marshal.PtrToStructure (raw, typeof (Rsvg.DimensionData)); } - - private static GLib.GType GType { - get { return GLib.GType.Pointer; } - } -#endregion } } diff --git a/src/rsvg/Handle.cs b/src/rsvg/Handle.cs index 51eec1fb..97196269 100644 --- a/src/rsvg/Handle.cs +++ b/src/rsvg/Handle.cs @@ -1,131 +1,62 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - namespace Rsvg { using System; using System.Collections; using System.Runtime.InteropServices; -#region Autogenerated code - public class Handle : GLib.Object { + public class Handle { - public Handle(IntPtr raw) : base(raw) {} + public IntPtr Raw; [DllImport("rsvg-2")] static extern IntPtr rsvg_handle_new(); - public Handle () : base (IntPtr.Zero) + public Handle () { - if (GetType () != typeof (Handle)) { - CreateNativeObject (new string [0], new GLib.Value[0]); - return; - } Raw = rsvg_handle_new(); } [DllImport("rsvg-2")] static extern unsafe IntPtr rsvg_handle_new_from_data(byte[] data, UIntPtr n_data, out IntPtr error); - public unsafe Handle (byte[] data) : base (IntPtr.Zero) + public unsafe Handle (byte[] data) { if (GetType () != typeof (Handle)) { throw new InvalidOperationException ("Can't override this constructor."); } IntPtr error = IntPtr.Zero; Raw = rsvg_handle_new_from_data(data, new UIntPtr ((ulong) (data == null ? 0 : data.Length)), out error); - if (error != IntPtr.Zero) throw new GLib.GException (error); + if (error != IntPtr.Zero) throw new Exception (error.ToString()); } [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_handle_new_from_file(IntPtr file_name, out IntPtr error); + static extern unsafe IntPtr rsvg_handle_new_from_file(string file_name, out IntPtr error); - public unsafe Handle (string file_name) : base (IntPtr.Zero) + public unsafe Handle (string file_name) { - if (GetType () != typeof (Handle)) { - throw new InvalidOperationException ("Can't override this constructor."); - } - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); IntPtr error = IntPtr.Zero; - Raw = rsvg_handle_new_from_file(native_file_name, out error); - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - } - - [DllImport("rsvg-2")] - static extern IntPtr rsvg_handle_get_pixbuf(IntPtr raw); - - public Gdk.Pixbuf Pixbuf { - get { - IntPtr raw_ret = rsvg_handle_get_pixbuf(Handle); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - return ret; - } + Raw = rsvg_handle_new_from_file(file_name, out error); + if (error != IntPtr.Zero) throw new Exception (error.ToString()); } [DllImport("rsvg-2")] static extern IntPtr rsvg_handle_get_base_uri(IntPtr raw); [DllImport("rsvg-2")] - static extern void rsvg_handle_set_base_uri(IntPtr raw, IntPtr base_uri); - - public string BaseUri { - get { - IntPtr raw_ret = rsvg_handle_get_base_uri(Handle); - string ret = GLib.Marshaller.Utf8PtrToString (raw_ret); - return ret; - } - set { - IntPtr native_value = GLib.Marshaller.StringToPtrGStrdup (value); - rsvg_handle_set_base_uri(Handle, native_value); - GLib.Marshaller.Free (native_value); - } - } - - [DllImport("rsvg-2")] static extern void rsvg_handle_set_dpi(IntPtr raw, double dpi); public double Dpi { set { - rsvg_handle_set_dpi(Handle, value); + rsvg_handle_set_dpi(Raw, value); } } [DllImport("rsvg-2")] - static extern unsafe bool rsvg_handle_write(IntPtr raw, byte[] buf, UIntPtr n_buf, out IntPtr error); - - public unsafe bool Write(byte[] buf) { - IntPtr error = IntPtr.Zero; - bool raw_ret = rsvg_handle_write(Handle, buf, new UIntPtr ((ulong) (buf == null ? 0 : buf.Length)), out error); - bool ret = raw_ret; - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr); public void RenderCairo(Cairo.Context cr) { - rsvg_handle_render_cairo(Handle, cr == null ? IntPtr.Zero : cr.Handle); - } - - [DllImport("rsvg-2")] - static extern void rsvg_handle_set_size_callback(IntPtr raw, RsvgSharp.SizeFuncNative size_func, IntPtr user_data, GLib.DestroyNotify user_data_destroy); - - [Obsolete] - public Rsvg.SizeFunc SizeCallback { - set { - RsvgSharp.SizeFuncWrapper value_wrapper = new RsvgSharp.SizeFuncWrapper (value); - IntPtr user_data; - GLib.DestroyNotify user_data_destroy; - if (value == null) { - user_data = IntPtr.Zero; - user_data_destroy = null; - } else { - user_data = (IntPtr) GCHandle.Alloc (value_wrapper); - user_data_destroy = GLib.DestroyHelper.NotifyHandler; - } - rsvg_handle_set_size_callback(Handle, value_wrapper.NativeDelegate, user_data, user_data_destroy); + unsafe{ + rsvg_handle_render_cairo (Raw, cr == null ? IntPtr.Zero : cr.Handle); } } @@ -133,7 +64,7 @@ namespace Rsvg { static extern void rsvg_handle_set_dpi_x_y(IntPtr raw, double dpi_x, double dpi_y); public void SetDpiXY(double dpi_x, double dpi_y) { - rsvg_handle_set_dpi_x_y(Handle, dpi_x, dpi_y); + rsvg_handle_set_dpi_x_y(Raw, dpi_x, dpi_y); } [DllImport("rsvg-2")] @@ -143,7 +74,7 @@ namespace Rsvg { get { Rsvg.DimensionData dimension_data; IntPtr native_dimension_data = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Rsvg.DimensionData))); - rsvg_handle_get_dimensions(Handle, native_dimension_data); + rsvg_handle_get_dimensions(Raw, native_dimension_data); dimension_data = Rsvg.DimensionData.New (native_dimension_data); Marshal.FreeHGlobal (native_dimension_data); return dimension_data; @@ -155,43 +86,9 @@ namespace Rsvg { public unsafe bool Close() { IntPtr error = IntPtr.Zero; - bool raw_ret = rsvg_handle_close(Handle, out error); - bool ret = raw_ret; - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] - static extern IntPtr rsvg_handle_get_pixbuf_sub(IntPtr raw, IntPtr id); - - public Gdk.Pixbuf GetPixbufSub(string id) { - IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id); - IntPtr raw_ret = rsvg_handle_get_pixbuf_sub(Handle, native_id); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_id); - return ret; - } - - [DllImport("rsvg-2")] - static extern IntPtr rsvg_handle_get_desc(IntPtr raw); - - public string Desc { - get { - IntPtr raw_ret = rsvg_handle_get_desc(Handle); - string ret = GLib.Marshaller.Utf8PtrToString (raw_ret); - return ret; - } - } - - [DllImport("rsvg-2")] - static extern IntPtr rsvg_handle_get_type(); - - public static new GLib.GType GType { - get { - IntPtr raw_ret = rsvg_handle_get_type(); - GLib.GType ret = new GLib.GType(raw_ret); - return ret; - } + bool raw_ret = rsvg_handle_close(Raw, out error); + if (error != IntPtr.Zero) throw new Exception (error.ToString()); + return raw_ret; } [DllImport("rsvg-2")] @@ -199,19 +96,16 @@ namespace Rsvg { public string Title { get { - IntPtr raw_ret = rsvg_handle_get_title(Handle); - string ret = GLib.Marshaller.Utf8PtrToString (raw_ret); - return ret; + IntPtr raw_ret = rsvg_handle_get_title(Raw); + return "not supported"; } } [DllImport("rsvg-2")] - static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, IntPtr id); + static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, string id); public void RenderCairoSub(Cairo.Context cr, string id) { - IntPtr native_id = GLib.Marshaller.StringToPtrGStrdup (id); - rsvg_handle_render_cairo_sub(Handle, cr == null ? IntPtr.Zero : cr.Handle, native_id); - GLib.Marshaller.Free (native_id); + rsvg_handle_render_cairo_sub(Raw, cr == null ? IntPtr.Zero : cr.Handle, id); } [DllImport("rsvg-2")] @@ -219,44 +113,9 @@ namespace Rsvg { public string Metadata { get { - IntPtr raw_ret = rsvg_handle_get_metadata(Handle); - string ret = GLib.Marshaller.Utf8PtrToString (raw_ret); - return ret; + IntPtr raw_ret = rsvg_handle_get_metadata(Raw); + return "not supported"; } } - -#endregion -#region Customized extensions -#line 1 "Handle.custom" -// Rsvg.Handle.custom - Rsvg Handle class customizations -// -// Copyright (C) 2007 Novell, Inc. -// -// This code is inserted after the automatically generated code. -// -// 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. - - public unsafe bool Write (byte[] buf, ulong count) - { - IntPtr error; - bool result = rsvg_handle_write (Handle, buf, new UIntPtr (count), out error); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return result; - } - - -#endregion } } diff --git a/src/rsvg/Pixbuf.cs b/src/rsvg/Pixbuf.cs deleted file mode 100644 index 690d454a..00000000 --- a/src/rsvg/Pixbuf.cs +++ /dev/null @@ -1,133 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Rsvg { - - using System; - using System.Runtime.InteropServices; - -#region Autogenerated code - public class Pixbuf { - - [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_pixbuf_from_file(IntPtr file_name, out IntPtr error); - - [Obsolete] - public static unsafe Gdk.Pixbuf FromFile(string file_name) { - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); - IntPtr error = IntPtr.Zero; - IntPtr raw_ret = rsvg_pixbuf_from_file(native_file_name, out error); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_pixbuf_from_file_at_size(IntPtr file_name, int width, int height, out IntPtr error); - - [Obsolete] - public static unsafe Gdk.Pixbuf FromFileAtSize(string file_name, int width, int height) { - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); - IntPtr error = IntPtr.Zero; - IntPtr raw_ret = rsvg_pixbuf_from_file_at_size(native_file_name, width, height, out error); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_pixbuf_from_file_at_zoom(IntPtr file_name, double x_zoom, double y_zoom, out IntPtr error); - - [Obsolete] - public static unsafe Gdk.Pixbuf FromFileAtZoom(string file_name, double x_zoom, double y_zoom) { - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); - IntPtr error = IntPtr.Zero; - IntPtr raw_ret = rsvg_pixbuf_from_file_at_zoom(native_file_name, x_zoom, y_zoom, out error); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_pixbuf_from_file_at_zoom_with_max(IntPtr file_name, double x_zoom, double y_zoom, int max_width, int max_height, out IntPtr error); - - [Obsolete] - public static unsafe Gdk.Pixbuf FromFileAtZoomWithMax(string file_name, double x_zoom, double y_zoom, int max_width, int max_height) { - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); - IntPtr error = IntPtr.Zero; - IntPtr raw_ret = rsvg_pixbuf_from_file_at_zoom_with_max(native_file_name, x_zoom, y_zoom, max_width, max_height, out error); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - - [DllImport("rsvg-2")] - static extern unsafe IntPtr rsvg_pixbuf_from_file_at_max_size(IntPtr file_name, int max_width, int max_height, out IntPtr error); - - [Obsolete] - public static unsafe Gdk.Pixbuf FromFileAtMaxSize(string file_name, int max_width, int max_height) { - IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup (file_name); - IntPtr error = IntPtr.Zero; - IntPtr raw_ret = rsvg_pixbuf_from_file_at_max_size(native_file_name, max_width, max_height, out error); - Gdk.Pixbuf ret = GLib.Object.GetObject(raw_ret) as Gdk.Pixbuf; - GLib.Marshaller.Free (native_file_name); - if (error != IntPtr.Zero) throw new GLib.GException (error); - return ret; - } - -#endregion -#region Customized extensions -#line 1 "Pixbuf.custom" -// Rsvg.Pixbuf.custom - Rsvg Pixbuf class customizations -// -// Author: John Luke <jluke@cfl.rr.com> -// -// Copyright (C) 2004 Novell, Inc. -// -// This code is inserted after the automatically generated code. -// -// 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. - - public static Gdk.Pixbuf LoadFromResource (string resource) - { - if (resource == null) - throw new ArgumentNullException ("resource"); - - System.IO.Stream s = System.Reflection.Assembly.GetCallingAssembly ().GetManifestResourceStream (resource); - if (s == null) - throw new ArgumentException ("resource must be a valid resource name of 'assembly'."); - - return LoadFromStream (s); - } - - public static Gdk.Pixbuf LoadFromStream (System.IO.Stream input) - { - Handle loader = new Handle (); - byte [] buffer = new byte [8192]; - int n; - while ((n = input.Read (buffer, 0, 8192)) != 0) - loader.Write (buffer, (uint) n); - - loader.Close (); - return loader.Pixbuf; - } - -#endregion - } -} diff --git a/src/rsvg/RsvgSharp.SizeFuncNative.cs b/src/rsvg/RsvgSharp.SizeFuncNative.cs deleted file mode 100644 index 43bf5b4e..00000000 --- a/src/rsvg/RsvgSharp.SizeFuncNative.cs +++ /dev/null @@ -1,94 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace RsvgSharp { - - using System; - using System.Runtime.InteropServices; - -#region Autogenerated code - - internal delegate void SizeFuncNative(out int width, out int height, IntPtr user_data); - - internal class SizeFuncInvoker { - - SizeFuncNative native_cb; - IntPtr __data; - GLib.DestroyNotify __notify; - - ~SizeFuncInvoker () - { - if (__notify == null) - return; - __notify (__data); - } - - internal SizeFuncInvoker (SizeFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {} - - internal SizeFuncInvoker (SizeFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {} - - internal SizeFuncInvoker (SizeFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify) - { - this.native_cb = native_cb; - __data = data; - __notify = notify; - } - - internal Rsvg.SizeFunc Handler { - get { - return new Rsvg.SizeFunc(InvokeNative); - } - } - - void InvokeNative (out int width, out int height) - { - native_cb (out width, out height, __data); - } - } - - internal class SizeFuncWrapper { - - public void NativeCallback (out int width, out int height, IntPtr user_data) - { - try { - managed (out width, out height); - if (release_on_call) - gch.Free (); - } catch (Exception e) { - GLib.ExceptionManager.RaiseUnhandledException (e, true); - // NOTREACHED: Above call does not return. - throw e; - } - } - - bool release_on_call = false; - GCHandle gch; - - public void PersistUntilCalled () - { - release_on_call = true; - gch = GCHandle.Alloc (this); - } - - internal SizeFuncNative NativeDelegate; - Rsvg.SizeFunc managed; - - public SizeFuncWrapper (Rsvg.SizeFunc managed) - { - this.managed = managed; - if (managed != null) - NativeDelegate = new SizeFuncNative (NativeCallback); - } - - public static Rsvg.SizeFunc GetManagedDelegate (SizeFuncNative native) - { - if (native == null) - return null; - SizeFuncWrapper wrapper = (SizeFuncWrapper) native.Target; - if (wrapper == null) - return null; - return wrapper.managed; - } - } -#endregion -} diff --git a/src/rsvg/SizeFunc.cs b/src/rsvg/SizeFunc.cs deleted file mode 100644 index 4c84738b..00000000 --- a/src/rsvg/SizeFunc.cs +++ /dev/null @@ -1,10 +0,0 @@ -// This file was generated by the Gtk# code generator. -// Any changes made will be lost if regenerated. - -namespace Rsvg { - - using System; - - public delegate void SizeFunc(out int width, out int height); - -} |