mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 17:25:37 +00:00
1a681abfac
* atk/Util.custom: unregister get_root function when the setter receives null. Partial fix for BNC#411444. svn path=/trunk/gtk-sharp/; revision=111872
274 lines
9.2 KiB
Plaintext
274 lines
9.2 KiB
Plaintext
// Util.custom - Atk Util class customizations
|
|
//
|
|
// Author: Mike Kestner <mkestner@novell.com>
|
|
//
|
|
// Copyright (c) 2008 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.
|
|
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate uint AddGlobalEventListenerNativeDelegate (GLib.Signal.EmissionHookNative hook, IntPtr event_type);
|
|
|
|
static AddGlobalEventListenerDelegate add_global_event_listener_handler;
|
|
static AddGlobalEventListenerNativeDelegate add_global_event_listener_callback;
|
|
|
|
static uint AddGlobalEventListenerCallback (GLib.Signal.EmissionHookNative hook, IntPtr event_type)
|
|
{
|
|
try {
|
|
return add_global_event_listener_handler (new GLib.Signal.EmissionHookMarshaler (hook, IntPtr.Zero).Invoker, GLib.Marshaller.Utf8PtrToString (event_type));
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public delegate uint AddGlobalEventListenerDelegate (GLib.Signal.EmissionHook hook, string event_type);
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_add_global_event_listener (AddGlobalEventListenerNativeDelegate cb);
|
|
public static AddGlobalEventListenerDelegate AddGlobalEventListenerHandler {
|
|
set {
|
|
add_global_event_listener_handler = value;
|
|
if (add_global_event_listener_callback == null)
|
|
add_global_event_listener_callback = new AddGlobalEventListenerNativeDelegate (AddGlobalEventListenerCallback);
|
|
atksharp_util_override_add_global_event_listener (add_global_event_listener_callback);
|
|
}
|
|
}
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate void RemoveListenerNativeDelegate (uint listener_id);
|
|
|
|
static RemoveListenerDelegate remove_global_event_listener_handler;
|
|
static RemoveListenerNativeDelegate remove_global_event_listener_callback;
|
|
|
|
static void RemoveGlobalEventListenerCallback (uint listener_id)
|
|
{
|
|
try {
|
|
remove_global_event_listener_handler (listener_id);
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_remove_global_event_listener (RemoveListenerNativeDelegate cb);
|
|
|
|
public delegate void RemoveListenerDelegate (uint listener_id);
|
|
|
|
public static RemoveListenerDelegate RemoveGlobalEventListenerHandler {
|
|
set {
|
|
remove_global_event_listener_handler = value;
|
|
if (remove_global_event_listener_callback == null)
|
|
remove_global_event_listener_callback = new RemoveListenerNativeDelegate (RemoveGlobalEventListenerCallback);
|
|
atksharp_util_override_remove_global_event_listener (remove_global_event_listener_callback);
|
|
}
|
|
}
|
|
|
|
class KeySnoopFuncInvoker {
|
|
|
|
AtkSharp.KeySnoopFuncNative native_cb;
|
|
IntPtr data;
|
|
|
|
internal KeySnoopFuncInvoker (AtkSharp.KeySnoopFuncNative native_cb, IntPtr data)
|
|
{
|
|
this.native_cb = native_cb;
|
|
this.data = data;
|
|
}
|
|
|
|
internal KeySnoopFunc Handler {
|
|
get {
|
|
return new KeySnoopFunc (InvokeNative);
|
|
}
|
|
}
|
|
|
|
int InvokeNative (KeyEventStruct evnt)
|
|
{
|
|
IntPtr native_evnt = GLib.Marshaller.StructureToPtrAlloc (evnt);
|
|
int result = native_cb (native_evnt, data);
|
|
evnt = KeyEventStruct.New (native_evnt);
|
|
Marshal.FreeHGlobal (native_evnt);
|
|
return result;
|
|
}
|
|
}
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate uint AddKeyEventListenerNativeDelegate (AtkSharp.KeySnoopFuncNative native_func, IntPtr data);
|
|
|
|
static AddKeyEventListenerDelegate add_key_event_listener_handler;
|
|
static AddKeyEventListenerNativeDelegate add_key_event_listener_callback;
|
|
|
|
static uint AddKeyEventListenerCallback (AtkSharp.KeySnoopFuncNative func, IntPtr data)
|
|
{
|
|
try {
|
|
return add_key_event_listener_handler (new KeySnoopFuncInvoker (func, data).Handler);
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_add_key_event_listener (AddKeyEventListenerNativeDelegate cb);
|
|
|
|
public delegate uint AddKeyEventListenerDelegate (KeySnoopFunc listener);
|
|
|
|
public static AddKeyEventListenerDelegate AddKeyEventListenerHandler {
|
|
set {
|
|
add_key_event_listener_handler = value;
|
|
if (add_key_event_listener_callback == null)
|
|
add_key_event_listener_callback = new AddKeyEventListenerNativeDelegate (AddKeyEventListenerCallback);
|
|
atksharp_util_override_add_key_event_listener (add_key_event_listener_callback);
|
|
}
|
|
}
|
|
|
|
static RemoveListenerDelegate remove_key_event_listener_handler;
|
|
static RemoveListenerNativeDelegate remove_key_event_listener_callback;
|
|
|
|
static void RemoveKeyEventListenerCallback (uint listener_id)
|
|
{
|
|
try {
|
|
remove_key_event_listener_handler (listener_id);
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_remove_key_event_listener (RemoveListenerNativeDelegate cb);
|
|
|
|
public static RemoveListenerDelegate RemoveKeyEventListenerHandler {
|
|
set {
|
|
remove_key_event_listener_handler = value;
|
|
if (remove_key_event_listener_callback == null)
|
|
remove_key_event_listener_callback = new RemoveListenerNativeDelegate (RemoveKeyEventListenerCallback);
|
|
atksharp_util_override_remove_key_event_listener (remove_key_event_listener_callback);
|
|
}
|
|
}
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate IntPtr GetRootNativeDelegate ();
|
|
|
|
static GetRootDelegate get_root_handler;
|
|
static GetRootNativeDelegate get_root_callback;
|
|
|
|
static IntPtr GetRootCallback ()
|
|
{
|
|
try {
|
|
return get_root_handler ().Handle;
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
return IntPtr.Zero;
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_get_root (GetRootNativeDelegate cb);
|
|
|
|
public delegate Atk.Object GetRootDelegate ();
|
|
|
|
public static GetRootDelegate GetRootHandler {
|
|
set {
|
|
get_root_handler = value;
|
|
if (value == null)
|
|
atksharp_util_override_get_root (null);
|
|
else {
|
|
if (get_root_callback == null)
|
|
get_root_callback = new GetRootNativeDelegate (GetRootCallback);
|
|
atksharp_util_override_get_root (get_root_callback);
|
|
}
|
|
}
|
|
}
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate IntPtr GetToolkitNameNativeDelegate ();
|
|
|
|
static GetToolkitNameDelegate get_toolkit_name_handler;
|
|
static GetToolkitNameNativeDelegate get_toolkit_name_callback;
|
|
static string toolkit_name;
|
|
static IntPtr toolkit_name_native;
|
|
|
|
static IntPtr GetToolkitNameCallback ()
|
|
{
|
|
try {
|
|
string name = get_toolkit_name_handler ();
|
|
if (name != toolkit_name) {
|
|
GLib.Marshaller.Free (toolkit_name_native);
|
|
toolkit_name_native = GLib.Marshaller.StringToPtrGStrdup (name);
|
|
toolkit_name = name;
|
|
}
|
|
return toolkit_name_native;
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
return IntPtr.Zero;
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_get_toolkit_name (GetToolkitNameNativeDelegate cb);
|
|
|
|
public delegate string GetToolkitNameDelegate ();
|
|
|
|
public static GetToolkitNameDelegate GetToolkitNameHandler {
|
|
set {
|
|
get_toolkit_name_handler = value;
|
|
if (get_toolkit_name_callback == null)
|
|
get_toolkit_name_callback = new GetToolkitNameNativeDelegate (GetToolkitNameCallback);
|
|
atksharp_util_override_get_toolkit_name (get_toolkit_name_callback);
|
|
}
|
|
}
|
|
|
|
[GLib.CDeclCallback]
|
|
delegate IntPtr GetToolkitVersionNativeDelegate ();
|
|
|
|
static GetToolkitVersionDelegate get_toolkit_version_handler;
|
|
static GetToolkitVersionNativeDelegate get_toolkit_version_callback;
|
|
static string toolkit_version;
|
|
static IntPtr toolkit_version_native;
|
|
|
|
static IntPtr GetToolkitVersionCallback ()
|
|
{
|
|
try {
|
|
string version = get_toolkit_version_handler ();
|
|
if (version != toolkit_version) {
|
|
GLib.Marshaller.Free (toolkit_version_native);
|
|
toolkit_version_native = GLib.Marshaller.StringToPtrGStrdup (version);
|
|
toolkit_version = version;
|
|
}
|
|
return toolkit_version_native;
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
return IntPtr.Zero;
|
|
}
|
|
|
|
[DllImport("atksharpglue-2")]
|
|
static extern void atksharp_util_override_get_toolkit_version (GetToolkitVersionNativeDelegate cb);
|
|
|
|
public delegate string GetToolkitVersionDelegate ();
|
|
|
|
public static GetToolkitVersionDelegate GetToolkitVersionHandler {
|
|
set {
|
|
get_toolkit_version_handler = value;
|
|
if (get_toolkit_version_callback == null)
|
|
get_toolkit_version_callback = new GetToolkitVersionNativeDelegate (GetToolkitVersionCallback);
|
|
atksharp_util_override_get_toolkit_version (get_toolkit_version_callback);
|
|
}
|
|
}
|
|
|