mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
Make ToggleRef.Signals a Dictionary
* glib/Object.cs: don't bother with IsAlive check on tref * glib/Signal.cs: remove unnecessary as usage * glib/ToggleRef.cs: make Signals a generic dictionary
This commit is contained in:
parent
a56feb01e3
commit
db738c401b
@ -105,7 +105,7 @@ namespace GLib {
|
|||||||
|
|
||||||
if (Objects.Contains (o)) {
|
if (Objects.Contains (o)) {
|
||||||
ToggleRef toggle_ref = Objects [o] as ToggleRef;
|
ToggleRef toggle_ref = Objects [o] as ToggleRef;
|
||||||
if (toggle_ref != null && toggle_ref.IsAlive)
|
if (toggle_ref != null)
|
||||||
obj = toggle_ref.Target;
|
obj = toggle_ref.Target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ namespace GLib {
|
|||||||
|
|
||||||
public static Signal Lookup (GLib.Object obj, string name, Delegate marshaler)
|
public static Signal Lookup (GLib.Object obj, string name, Delegate marshaler)
|
||||||
{
|
{
|
||||||
Signal result = obj.ToggleRef.Signals [name] as Signal;
|
Signal result = obj.ToggleRef.Signals [name];
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result = new Signal (obj, name, marshaler);
|
result = new Signal (obj, name, marshaler);
|
||||||
return result;
|
return result;
|
||||||
@ -230,7 +230,7 @@ namespace GLib {
|
|||||||
|
|
||||||
public static Signal Lookup (GLib.Object obj, string name, Type args_type)
|
public static Signal Lookup (GLib.Object obj, string name, Type args_type)
|
||||||
{
|
{
|
||||||
Signal result = obj.ToggleRef.Signals [name] as Signal;
|
Signal result = obj.ToggleRef.Signals [name];
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result = new Signal (obj, name, args_type);
|
result = new Signal (obj, name, args_type);
|
||||||
return result;
|
return result;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@novell.com>
|
// Author: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright <c> 2007 Novell, Inc.
|
// Copyright <c> 2007, 2011 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the Lesser GNU General
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
@ -19,11 +19,11 @@
|
|||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
namespace GLib {
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using System;
|
namespace GLib {
|
||||||
using System.Collections;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
internal class ToggleRef {
|
internal class ToggleRef {
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ namespace GLib {
|
|||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
object reference;
|
object reference;
|
||||||
GCHandle gch;
|
GCHandle gch;
|
||||||
Hashtable signals;
|
Dictionary<string, Signal> signals;
|
||||||
|
|
||||||
public ToggleRef (GLib.Object target)
|
public ToggleRef (GLib.Object target)
|
||||||
{
|
{
|
||||||
@ -42,27 +42,14 @@ namespace GLib {
|
|||||||
g_object_unref (target.Handle);
|
g_object_unref (target.Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsAlive {
|
|
||||||
get {
|
|
||||||
if (reference is WeakReference) {
|
|
||||||
WeakReference weak = reference as WeakReference;
|
|
||||||
return weak.IsAlive;
|
|
||||||
} else if (reference == null)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Handle {
|
public IntPtr Handle {
|
||||||
get {
|
get { return handle; }
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hashtable Signals {
|
public Dictionary<string, Signal> Signals {
|
||||||
get {
|
get {
|
||||||
if (signals == null)
|
if (signals == null)
|
||||||
signals = new Hashtable ();
|
signals = new Dictionary<string, Signal> ();
|
||||||
return signals;
|
return signals;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,8 +102,7 @@ namespace GLib {
|
|||||||
reference = new WeakReference (reference);
|
reference = new WeakReference (reference);
|
||||||
else if (!is_last_ref && reference is WeakReference) {
|
else if (!is_last_ref && reference is WeakReference) {
|
||||||
WeakReference weak = reference as WeakReference;
|
WeakReference weak = reference as WeakReference;
|
||||||
if (weak.IsAlive)
|
reference = weak.Target;
|
||||||
reference = weak.Target;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user