mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-08 07:53:17 +02:00
glib: Re-organize code in Source for better readability
Move stuff around to have them in a reasonable order: fields, then constructors, then destructor, then static methods, then instance stuff. Also remove a commented out method, which would not be correct anyway. No real code change here, just cosmetic changes.
This commit is contained in:
parent
83b602320a
commit
11920f2add
114
glib/Source.cs
114
glib/Source.cs
@ -46,10 +46,46 @@ namespace GLib {
|
||||
|
||||
public partial class Source : GLib.Opaque {
|
||||
|
||||
internal static Hashtable source_handlers = new Hashtable ();
|
||||
|
||||
private Source () {}
|
||||
|
||||
internal static Hashtable source_handlers = new Hashtable ();
|
||||
|
||||
public Source(IntPtr raw) : base(raw) {}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_new(IntPtr source_funcs, uint struct_size);
|
||||
|
||||
public Source (GLib.SourceFuncs source_funcs, uint struct_size)
|
||||
{
|
||||
IntPtr native_source_funcs = GLib.Marshaller.StructureToPtrAlloc (source_funcs);
|
||||
Raw = g_source_new(native_source_funcs, struct_size);
|
||||
source_funcs = GLib.SourceFuncs.New (native_source_funcs);
|
||||
Marshal.FreeHGlobal (native_source_funcs);
|
||||
}
|
||||
|
||||
class FinalizerInfo {
|
||||
IntPtr handle;
|
||||
|
||||
public FinalizerInfo (IntPtr handle)
|
||||
{
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public bool Handler ()
|
||||
{
|
||||
g_source_destroy (handle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
~Source ()
|
||||
{
|
||||
if (!Owned)
|
||||
return;
|
||||
FinalizerInfo info = new FinalizerInfo (Handle);
|
||||
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove (uint tag);
|
||||
|
||||
@ -60,6 +96,17 @@ namespace GLib {
|
||||
return g_source_remove (tag);
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_get_type();
|
||||
|
||||
public static GLib.GType GType {
|
||||
get {
|
||||
IntPtr raw_ret = g_source_get_type();
|
||||
GLib.GType ret = new GLib.GType(raw_ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_get_context(IntPtr raw);
|
||||
|
||||
@ -107,17 +154,6 @@ namespace GLib {
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_get_type();
|
||||
|
||||
public static GLib.GType GType {
|
||||
get {
|
||||
IntPtr raw_ret = g_source_get_type();
|
||||
GLib.GType ret = new GLib.GType(raw_ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void g_source_add_child_source(IntPtr raw, IntPtr child_source);
|
||||
|
||||
@ -288,19 +324,6 @@ namespace GLib {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* commented out because there is already a custom implementation for Remove
|
||||
*
|
||||
[DllImport (Global.GLibNativeLib, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove(uint tag);
|
||||
|
||||
public static bool Remove(uint tag) {
|
||||
bool raw_ret = g_source_remove(tag);
|
||||
bool ret = raw_ret;
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool g_source_remove_by_funcs_user_data(IntPtr funcs, IntPtr user_data);
|
||||
|
||||
@ -331,19 +354,6 @@ namespace GLib {
|
||||
GLib.Marshaller.Free (native_name);
|
||||
}
|
||||
|
||||
public Source(IntPtr raw) : base(raw) {}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_new(IntPtr source_funcs, uint struct_size);
|
||||
|
||||
public Source (GLib.SourceFuncs source_funcs, uint struct_size)
|
||||
{
|
||||
IntPtr native_source_funcs = GLib.Marshaller.StructureToPtrAlloc (source_funcs);
|
||||
Raw = g_source_new(native_source_funcs, struct_size);
|
||||
source_funcs = GLib.SourceFuncs.New (native_source_funcs);
|
||||
Marshal.FreeHGlobal (native_source_funcs);
|
||||
}
|
||||
|
||||
[DllImport (Global.GLibNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr g_source_ref(IntPtr raw);
|
||||
|
||||
@ -373,29 +383,5 @@ namespace GLib {
|
||||
{
|
||||
g_source_destroy (raw);
|
||||
}
|
||||
|
||||
class FinalizerInfo {
|
||||
IntPtr handle;
|
||||
|
||||
public FinalizerInfo (IntPtr handle)
|
||||
{
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public bool Handler ()
|
||||
{
|
||||
g_source_destroy (handle);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
~Source ()
|
||||
{
|
||||
if (!Owned)
|
||||
return;
|
||||
FinalizerInfo info = new FinalizerInfo (Handle);
|
||||
GLib.Timeout.Add (50, new GLib.TimeoutHandler (info.Handler));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user