gdk: Use a Dictionary to hold the filter functions in Window class
This commit is contained in:
parent
eddc5fa796
commit
6ecd2d01f9
1 changed files with 21 additions and 19 deletions
|
@ -25,7 +25,7 @@
|
||||||
namespace Gdk {
|
namespace Gdk {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class Window {
|
public partial class Window {
|
||||||
|
@ -119,11 +119,12 @@ namespace Gdk {
|
||||||
[DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgdk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
|
static extern void gdk_window_remove_filter (IntPtr handle, GdkSharp.FilterFuncNative wrapper, IntPtr data);
|
||||||
|
|
||||||
static Hashtable filter_all_hash;
|
static IDictionary<FilterFunc, GdkSharp.FilterFuncWrapper> filter_all_hash;
|
||||||
static Hashtable FilterAllHash {
|
static IDictionary<FilterFunc, GdkSharp.FilterFuncWrapper> FilterAllHash {
|
||||||
get {
|
get {
|
||||||
if (filter_all_hash == null)
|
if (filter_all_hash == null) {
|
||||||
filter_all_hash = new Hashtable ();
|
filter_all_hash = new Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper> ();
|
||||||
|
}
|
||||||
return filter_all_hash;
|
return filter_all_hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,18 +138,19 @@ namespace Gdk {
|
||||||
|
|
||||||
public static void RemoveFilterForAll (FilterFunc func)
|
public static void RemoveFilterForAll (FilterFunc func)
|
||||||
{
|
{
|
||||||
GdkSharp.FilterFuncWrapper wrapper = FilterAllHash [func] as GdkSharp.FilterFuncWrapper;
|
GdkSharp.FilterFuncWrapper wrapper = null;
|
||||||
if (wrapper == null)
|
if (FilterAllHash.TryGetValue (func, out wrapper)) {
|
||||||
return;
|
|
||||||
FilterAllHash.Remove (func);
|
FilterAllHash.Remove (func);
|
||||||
gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero);
|
gdk_window_remove_filter (IntPtr.Zero, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AddFilter (FilterFunc function)
|
public void AddFilter (FilterFunc function)
|
||||||
{
|
{
|
||||||
if (!Data.Contains ("filter_func_hash"))
|
if (!Data.ContainsKey ("filter_func_hash")) {
|
||||||
Data ["filter_func_hash"] = new Hashtable ();
|
Data ["filter_func_hash"] = new Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper> ();
|
||||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
}
|
||||||
|
var hash = Data ["filter_func_hash"] as Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper>;
|
||||||
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
|
GdkSharp.FilterFuncWrapper wrapper = new GdkSharp.FilterFuncWrapper (function);
|
||||||
hash [function] = wrapper;
|
hash [function] = wrapper;
|
||||||
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
gdk_window_add_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
|
@ -156,13 +158,13 @@ namespace Gdk {
|
||||||
|
|
||||||
public void RemoveFilter (FilterFunc function)
|
public void RemoveFilter (FilterFunc function)
|
||||||
{
|
{
|
||||||
Hashtable hash = Data ["filter_func_hash"] as Hashtable;
|
var hash = Data ["filter_func_hash"] as Dictionary<FilterFunc, GdkSharp.FilterFuncWrapper>;
|
||||||
GdkSharp.FilterFuncWrapper wrapper = hash [function] as GdkSharp.FilterFuncWrapper;
|
GdkSharp.FilterFuncWrapper wrapper = null;
|
||||||
if (wrapper == null)
|
if (hash.TryGetValue (function, out wrapper)) {
|
||||||
return;
|
|
||||||
hash.Remove (function);
|
hash.Remove (function);
|
||||||
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
gdk_window_remove_filter (Handle, wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if MANLY_ENOUGH_TO_INCLUDE
|
#if MANLY_ENOUGH_TO_INCLUDE
|
||||||
public Cairo.Graphics CairoGraphics (out int offset_x, out int offset_y)
|
public Cairo.Graphics CairoGraphics (out int offset_x, out int offset_y)
|
||||||
|
|
Loading…
Add table
Reference in a new issue