mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-26 00:35:34 +00:00
8c0e123418
* *: s/win32-2.0-0/win32-3.0-0/ I suspect this will need to change again when I see some win32 binaries. I think the win32 goes away. Killing a few dead customs in the list as well.
109 lines
3.8 KiB
Plaintext
109 lines
3.8 KiB
Plaintext
// Gtk.TextView.custom - Gtk TextView class customizations
|
|
//
|
|
// Author: Mike Kestner <mkestner@ximian.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.
|
|
|
|
|
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
static extern IntPtr gtk_text_view_new_with_buffer (IntPtr buffer);
|
|
|
|
public TextView (TextBuffer buffer) : base (IntPtr.Zero)
|
|
{
|
|
if (GetType() != typeof (TextView)) {
|
|
CreateNativeObject (new string [0], new GLib.Value [0]);
|
|
Buffer = buffer;
|
|
return;
|
|
}
|
|
|
|
Raw = gtk_text_view_new_with_buffer (buffer.Handle);
|
|
}
|
|
|
|
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
|
delegate void MoveFocusSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
|
|
|
|
static void MoveFocusSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
|
|
{
|
|
Gtk.MoveFocusArgs args = new Gtk.MoveFocusArgs ();
|
|
try {
|
|
GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
|
|
if (sig == null)
|
|
throw new Exception("Unknown signal GC handle received " + gch);
|
|
|
|
args.Args = new object[1];
|
|
args.Args[0] = (Gtk.DirectionType) arg1;
|
|
Gtk.MoveFocusHandler handler = (Gtk.MoveFocusHandler) sig.Handler;
|
|
handler (GLib.Object.GetObject (arg0), args);
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
}
|
|
|
|
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
|
delegate void MoveFocusVMDelegate (IntPtr text_view, int direction);
|
|
|
|
static MoveFocusVMDelegate MoveFocusVMCallback;
|
|
|
|
static void movefocus_cb (IntPtr text_view, int direction)
|
|
{
|
|
try {
|
|
TextView text_view_managed = GLib.Object.GetObject (text_view, false) as TextView;
|
|
text_view_managed.OnMoveFocus ((Gtk.DirectionType) direction);
|
|
} catch (Exception e) {
|
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
}
|
|
}
|
|
|
|
private static void OverrideMoveFocus (GLib.GType gtype)
|
|
{
|
|
if (MoveFocusVMCallback == null)
|
|
MoveFocusVMCallback = new MoveFocusVMDelegate (movefocus_cb);
|
|
OverrideVirtualMethod (gtype, "move_focus", MoveFocusVMCallback);
|
|
}
|
|
|
|
[Obsolete ("Replaced by keybinding signal on Gtk.Widget")]
|
|
[GLib.DefaultSignalHandler(Type=typeof(Gtk.TextView), ConnectionMethod="OverrideMoveFocus")]
|
|
protected virtual void OnMoveFocus (Gtk.DirectionType direction)
|
|
{
|
|
GLib.Value ret = GLib.Value.Empty;
|
|
GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
|
|
GLib.Value[] vals = new GLib.Value [2];
|
|
vals [0] = new GLib.Value (this);
|
|
inst_and_params.Append (vals [0]);
|
|
vals [1] = new GLib.Value (direction);
|
|
inst_and_params.Append (vals [1]);
|
|
g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
|
|
foreach (GLib.Value v in vals)
|
|
v.Dispose ();
|
|
}
|
|
|
|
[Obsolete ("Replaced by keybinding signal on Gtk.Widget")]
|
|
[GLib.Signal("move_focus")]
|
|
public event Gtk.MoveFocusHandler MoveFocus {
|
|
add {
|
|
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
|
sig.AddDelegate (value);
|
|
}
|
|
remove {
|
|
GLib.Signal sig = GLib.Signal.Lookup (this, "move_focus", new MoveFocusSignalDelegate(MoveFocusSignalCallback));
|
|
sig.RemoveDelegate (value);
|
|
}
|
|
}
|
|
|