mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 13:15:38 +00:00
2007-03-08 Mike Kestner <mkestner@novell.com>
* glib/Signal.cs : guard against NULL gchandles. * gdk/Input.custom : add try/catch blocks to native callbacks. * gtk/*.custom : ditto * gtk/NodeStore.cs : ditto svn path=/trunk/gtk-sharp/; revision=74004
This commit is contained in:
parent
57810954a3
commit
fd01afc12b
|
@ -1,3 +1,10 @@
|
||||||
|
2007-03-08 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/Signal.cs : guard against NULL gchandles.
|
||||||
|
* gdk/Input.custom : add try/catch blocks to native callbacks.
|
||||||
|
* gtk/*.custom : ditto
|
||||||
|
* gtk/NodeStore.cs : ditto
|
||||||
|
|
||||||
2007-03-08 Mike Kestner <mkestner@novell.com>
|
2007-03-08 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* glib/*.cs : add try/catch blocks to native callback
|
* glib/*.cs : add try/catch blocks to native callback
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// Author: Mike Kestner <mkestner@ximian.com>
|
// Author: Mike Kestner <mkestner@ximian.com>
|
||||||
//
|
//
|
||||||
// Copyright (C) 2005 Novell, Inc.
|
// Copyright (C) 2005, 2007 Novell, Inc.
|
||||||
//
|
//
|
||||||
// This code is inserted after the automatically generated code.
|
// This code is inserted after the automatically generated code.
|
||||||
//
|
//
|
||||||
|
@ -25,11 +25,15 @@
|
||||||
|
|
||||||
static void ReleaseGCHandle (IntPtr data)
|
static void ReleaseGCHandle (IntPtr data)
|
||||||
{
|
{
|
||||||
if (data == IntPtr.Zero)
|
try {
|
||||||
return;
|
if (data == IntPtr.Zero)
|
||||||
|
return;
|
||||||
|
|
||||||
GCHandle gch = (GCHandle) data;
|
GCHandle gch = (GCHandle) data;
|
||||||
gch.Free ();
|
gch.Free ();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static InputDestroyNotify release_gchandle;
|
static InputDestroyNotify release_gchandle;
|
||||||
|
|
|
@ -178,6 +178,8 @@ namespace GLib {
|
||||||
static void voidObjectCallback (IntPtr handle, IntPtr gch)
|
static void voidObjectCallback (IntPtr handle, IntPtr gch)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
if (gch == IntPtr.Zero)
|
||||||
|
return;
|
||||||
Signal sig = ((GCHandle) gch).Target as Signal;
|
Signal sig = ((GCHandle) gch).Target as Signal;
|
||||||
if (sig == null) {
|
if (sig == null) {
|
||||||
ExceptionManager.RaiseUnhandledException (new Exception ("Unknown signal class GC handle received."), false);
|
ExceptionManager.RaiseUnhandledException (new Exception ("Unknown signal class GC handle received."), false);
|
||||||
|
|
|
@ -38,20 +38,24 @@
|
||||||
|
|
||||||
static void GetSize_cb (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
|
static void GetSize_cb (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
|
||||||
{
|
{
|
||||||
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
try {
|
||||||
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
||||||
Gdk.Rectangle cell_area = Gdk.Rectangle.New (cell_area_ptr);
|
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
||||||
int a, b, c, d;
|
Gdk.Rectangle cell_area = Gdk.Rectangle.New (cell_area_ptr);
|
||||||
|
int a, b, c, d;
|
||||||
|
|
||||||
obj.GetSize (widg, ref cell_area, out a, out b, out c, out d);
|
obj.GetSize (widg, ref cell_area, out a, out b, out c, out d);
|
||||||
if (x_offset != IntPtr.Zero)
|
if (x_offset != IntPtr.Zero)
|
||||||
Marshal.WriteInt32 (x_offset, a);
|
Marshal.WriteInt32 (x_offset, a);
|
||||||
if (y_offset != IntPtr.Zero)
|
if (y_offset != IntPtr.Zero)
|
||||||
Marshal.WriteInt32 (y_offset, b);
|
Marshal.WriteInt32 (y_offset, b);
|
||||||
if (width != IntPtr.Zero)
|
if (width != IntPtr.Zero)
|
||||||
Marshal.WriteInt32 (width, c);
|
Marshal.WriteInt32 (width, c);
|
||||||
if (height != IntPtr.Zero)
|
if (height != IntPtr.Zero)
|
||||||
Marshal.WriteInt32 (height, d);
|
Marshal.WriteInt32 (height, d);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideGetSize (GLib.GType gtype)
|
static void OverrideGetSize (GLib.GType gtype)
|
||||||
|
@ -88,10 +92,14 @@
|
||||||
|
|
||||||
static void Render_cb (IntPtr item, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
|
static void Render_cb (IntPtr item, IntPtr window, IntPtr widget, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, ref Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
|
||||||
{
|
{
|
||||||
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
try {
|
||||||
Gdk.Drawable wind = GLib.Object.GetObject (window, false) as Gdk.Drawable;
|
CellRenderer obj = GLib.Object.GetObject (item, false) as CellRenderer;
|
||||||
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
Gdk.Drawable wind = GLib.Object.GetObject (window, false) as Gdk.Drawable;
|
||||||
obj.Render (wind, widg, background_area, cell_area, expose_area, flags);
|
Gtk.Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
||||||
|
obj.Render (wind, widg, background_area, cell_area, expose_area, flags);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideRender (GLib.GType gtype)
|
static void OverrideRender (GLib.GType gtype)
|
||||||
|
@ -125,13 +133,19 @@
|
||||||
|
|
||||||
static IntPtr StartEditing_cb (IntPtr raw, IntPtr evnt, IntPtr widget, IntPtr path, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, Gtk.CellRendererState flags)
|
static IntPtr StartEditing_cb (IntPtr raw, IntPtr evnt, IntPtr widget, IntPtr path, ref Gdk.Rectangle background_area, ref Gdk.Rectangle cell_area, Gtk.CellRendererState flags)
|
||||||
{
|
{
|
||||||
CellRenderer obj = GLib.Object.GetObject (raw, false) as CellRenderer;
|
try {
|
||||||
Gdk.Event _event = new Gdk.Event (evnt);
|
CellRenderer obj = GLib.Object.GetObject (raw, false) as CellRenderer;
|
||||||
Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
Gdk.Event _event = new Gdk.Event (evnt);
|
||||||
CellEditable retval = obj.StartEditing (_event, widg, GLib.Marshaller.Utf8PtrToString (path), background_area, cell_area, flags);
|
Widget widg = GLib.Object.GetObject (widget, false) as Gtk.Widget;
|
||||||
if (retval == null)
|
CellEditable retval = obj.StartEditing (_event, widg, GLib.Marshaller.Utf8PtrToString (path), background_area, cell_area, flags);
|
||||||
return IntPtr.Zero;
|
if (retval == null)
|
||||||
return retval.Handle;
|
return IntPtr.Zero;
|
||||||
|
return retval.Handle;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideStartEditing (GLib.GType gtype)
|
static void OverrideStartEditing (GLib.GType gtype)
|
||||||
|
|
|
@ -94,15 +94,19 @@
|
||||||
|
|
||||||
void RichTextReceivedCallback (IntPtr clipboard_ptr, IntPtr format_ptr, IntPtr text_ptr, UIntPtr length, IntPtr data)
|
void RichTextReceivedCallback (IntPtr clipboard_ptr, IntPtr format_ptr, IntPtr text_ptr, UIntPtr length, IntPtr data)
|
||||||
{
|
{
|
||||||
Gtk.Clipboard clipboard = GLib.Object.GetObject(clipboard_ptr) as Gtk.Clipboard;
|
try {
|
||||||
Gdk.Atom format = format_ptr == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format_ptr, typeof (Gdk.Atom), false);
|
Gtk.Clipboard clipboard = GLib.Object.GetObject(clipboard_ptr) as Gtk.Clipboard;
|
||||||
int sz = (int) (uint) length;
|
Gdk.Atom format = format_ptr == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format_ptr, typeof (Gdk.Atom), false);
|
||||||
byte[] text = new byte [sz];
|
int sz = (int) (uint) length;
|
||||||
Marshal.Copy (text, 0, text_ptr, sz);
|
byte[] text = new byte [sz];
|
||||||
GCHandle gch = (GCHandle) data;
|
Marshal.Copy (text, 0, text_ptr, sz);
|
||||||
RichTextReceivedFunc cb = gch.Target as RichTextReceivedFunc;
|
GCHandle gch = (GCHandle) data;
|
||||||
cb (clipboard, format, text);
|
RichTextReceivedFunc cb = gch.Target as RichTextReceivedFunc;
|
||||||
gch.Free ();
|
cb (clipboard, format, text);
|
||||||
|
gch.Free ();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||||
|
|
|
@ -145,9 +145,13 @@ public struct CallbackInvoker {
|
||||||
|
|
||||||
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
||||||
{
|
{
|
||||||
Container obj = GLib.Object.GetObject (container, false) as Container;
|
try {
|
||||||
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
Container obj = GLib.Object.GetObject (container, false) as Container;
|
||||||
obj.ForAll (include_internals, invoker);
|
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
||||||
|
obj.ForAll (include_internals, invoker);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideForallOld (GLib.GType gtype)
|
static void OverrideForallOld (GLib.GType gtype)
|
||||||
|
@ -166,9 +170,13 @@ protected virtual void ForAll (bool include_internals, CallbackInvoker invoker)
|
||||||
|
|
||||||
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
||||||
{
|
{
|
||||||
Container obj = GLib.Object.GetObject (container, false) as Container;
|
try {
|
||||||
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
Container obj = GLib.Object.GetObject (container, false) as Container;
|
||||||
obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
|
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
||||||
|
obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideForall (GLib.GType gtype)
|
static void OverrideForall (GLib.GType gtype)
|
||||||
|
@ -203,9 +211,15 @@ static ChildTypeDelegate ChildTypeCallback;
|
||||||
|
|
||||||
static IntPtr ChildType_cb (IntPtr raw)
|
static IntPtr ChildType_cb (IntPtr raw)
|
||||||
{
|
{
|
||||||
Container obj = GLib.Object.GetObject (raw, false) as Container;
|
try {
|
||||||
GLib.GType gtype = obj.ChildType ();
|
Container obj = GLib.Object.GetObject (raw, false) as Container;
|
||||||
return gtype.Val;
|
GLib.GType gtype = obj.ChildType ();
|
||||||
|
return gtype.Val;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLib.GType.Invalid.Val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OverrideChildType (GLib.GType gtype)
|
static void OverrideChildType (GLib.GType gtype)
|
||||||
|
|
|
@ -29,10 +29,14 @@
|
||||||
|
|
||||||
public void NativeCallback (IntPtr data, int source, int condition)
|
public void NativeCallback (IntPtr data, int source, int condition)
|
||||||
{
|
{
|
||||||
IntPtr _arg0 = data;
|
try {
|
||||||
int _arg1 = source;
|
IntPtr _arg0 = data;
|
||||||
Gdk.InputCondition _arg2 = (Gdk.InputCondition) condition;
|
int _arg1 = source;
|
||||||
managed ( _arg0, _arg1, _arg2);
|
Gdk.InputCondition _arg2 = (Gdk.InputCondition) condition;
|
||||||
|
managed ( _arg0, _arg1, _arg2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal InputFunctionNative NativeDelegate;
|
internal InputFunctionNative NativeDelegate;
|
||||||
|
|
240
gtk/NodeStore.cs
240
gtk/NodeStore.cs
|
@ -113,32 +113,49 @@ namespace Gtk {
|
||||||
|
|
||||||
IntPtr get_column_type_cb (int col)
|
IntPtr get_column_type_cb (int col)
|
||||||
{
|
{
|
||||||
return ctypes [col].Val;
|
try {
|
||||||
|
return ctypes [col].Val;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_node_cb (out int node_idx, IntPtr path)
|
bool get_node_cb (out int node_idx, IntPtr path)
|
||||||
{
|
{
|
||||||
if (path == IntPtr.Zero)
|
try {
|
||||||
throw new ArgumentNullException ("path");
|
if (path == IntPtr.Zero)
|
||||||
|
throw new ArgumentNullException ("path");
|
||||||
|
|
||||||
TreePath treepath = new TreePath (path);
|
TreePath treepath = new TreePath (path);
|
||||||
|
node_idx = -1;
|
||||||
|
|
||||||
|
ITreeNode node = GetNodeAtPath (treepath);
|
||||||
|
if (node == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
node_idx = node.ID;
|
||||||
|
node_hash [node.ID] = node;
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
node_idx = -1;
|
node_idx = -1;
|
||||||
|
return false;
|
||||||
ITreeNode node = GetNodeAtPath (treepath);
|
|
||||||
if (node == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
node_idx = node.ID;
|
|
||||||
node_hash [node.ID] = node;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr get_path_cb (int node_idx)
|
IntPtr get_path_cb (int node_idx)
|
||||||
{
|
{
|
||||||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
try {
|
||||||
if (node == null) throw new Exception ("Invalid Node ID");
|
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||||
|
if (node == null) throw new Exception ("Invalid Node ID");
|
||||||
|
|
||||||
return GetPath (node).Handle;
|
return GetPath (node).Handle;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
return IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
@ -146,125 +163,160 @@ namespace Gtk {
|
||||||
|
|
||||||
void get_value_cb (int node_idx, int col, ref GLib.Value val)
|
void get_value_cb (int node_idx, int col, ref GLib.Value val)
|
||||||
{
|
{
|
||||||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
try {
|
||||||
if (node == null)
|
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||||
return;
|
if (node == null)
|
||||||
g_value_init (ref val, ctypes [col].Val);
|
return;
|
||||||
object col_val;
|
g_value_init (ref val, ctypes [col].Val);
|
||||||
if (getters [col] is PropertyInfo)
|
object col_val;
|
||||||
col_val = ((PropertyInfo) getters [col]).GetValue (node, null);
|
if (getters [col] is PropertyInfo)
|
||||||
else
|
col_val = ((PropertyInfo) getters [col]).GetValue (node, null);
|
||||||
col_val = ((FieldInfo) getters [col]).GetValue (node);
|
else
|
||||||
val.Val = col_val;
|
col_val = ((FieldInfo) getters [col]).GetValue (node);
|
||||||
|
val.Val = col_val;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool next_cb (ref int node_idx)
|
bool next_cb (ref int node_idx)
|
||||||
{
|
{
|
||||||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
try {
|
||||||
if (node == null)
|
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||||
return false;
|
if (node == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
int idx;
|
int idx;
|
||||||
if (node.Parent == null)
|
if (node.Parent == null)
|
||||||
idx = Nodes.IndexOf (node);
|
idx = Nodes.IndexOf (node);
|
||||||
else
|
else
|
||||||
idx = node.Parent.IndexOf (node);
|
idx = node.Parent.IndexOf (node);
|
||||||
|
|
||||||
if (idx < 0) throw new Exception ("Node not found in Nodes list");
|
if (idx < 0) throw new Exception ("Node not found in Nodes list");
|
||||||
|
|
||||||
if (node.Parent == null) {
|
if (node.Parent == null) {
|
||||||
if (++idx >= Nodes.Count)
|
if (++idx >= Nodes.Count)
|
||||||
return false;
|
return false;
|
||||||
node = Nodes [idx] as ITreeNode;
|
node = Nodes [idx] as ITreeNode;
|
||||||
} else {
|
} else {
|
||||||
if (++idx >= node.Parent.ChildCount)
|
if (++idx >= node.Parent.ChildCount)
|
||||||
return false;
|
return false;
|
||||||
node = node.Parent [idx];
|
node = node.Parent [idx];
|
||||||
|
}
|
||||||
|
node_hash [node.ID] = node;
|
||||||
|
node_idx = node.ID;
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
}
|
}
|
||||||
node_hash [node.ID] = node;
|
return false;
|
||||||
node_idx = node.ID;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool children_cb (out int child_idx, int parent)
|
bool children_cb (out int child_idx, int parent)
|
||||||
{
|
{
|
||||||
child_idx = -1;
|
try {
|
||||||
ITreeNode node;
|
child_idx = -1;
|
||||||
|
ITreeNode node;
|
||||||
|
|
||||||
if (parent == -1) {
|
if (parent == -1) {
|
||||||
if (Nodes.Count <= 0)
|
if (Nodes.Count <= 0)
|
||||||
return false;
|
return false;
|
||||||
node = Nodes [0] as ITreeNode;
|
node = Nodes [0] as ITreeNode;
|
||||||
child_idx = node.ID;
|
child_idx = node.ID;
|
||||||
node_hash [node.ID] = node;
|
node_hash [node.ID] = node;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node_hash [parent] as ITreeNode;
|
node = node_hash [parent] as ITreeNode;
|
||||||
if (node == null || node.ChildCount <= 0)
|
if (node == null || node.ChildCount <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ITreeNode child = node [0];
|
ITreeNode child = node [0];
|
||||||
node_hash [child.ID] = child;
|
node_hash [child.ID] = child;
|
||||||
child_idx = child.ID;
|
child_idx = child.ID;
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
child_idx = -1;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has_child_cb (int node_idx)
|
bool has_child_cb (int node_idx)
|
||||||
{
|
{
|
||||||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
try {
|
||||||
if (node == null || node.ChildCount <= 0)
|
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||||
return false;
|
if (node == null || node.ChildCount <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int n_children_cb (int node_idx)
|
int n_children_cb (int node_idx)
|
||||||
{
|
{
|
||||||
if (node_idx == -1)
|
try {
|
||||||
return Nodes.Count;
|
if (node_idx == -1)
|
||||||
|
return Nodes.Count;
|
||||||
|
|
||||||
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
ITreeNode node = node_hash [node_idx] as ITreeNode;
|
||||||
if (node == null || node.ChildCount <= 0)
|
if (node == null || node.ChildCount <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return node.ChildCount;
|
return node.ChildCount;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nth_child_cb (out int child_idx, int parent, int n)
|
bool nth_child_cb (out int child_idx, int parent, int n)
|
||||||
{
|
{
|
||||||
child_idx = -1;
|
child_idx = -1;
|
||||||
ITreeNode node;
|
try {
|
||||||
|
ITreeNode node;
|
||||||
|
|
||||||
if (parent == -1) {
|
if (parent == -1) {
|
||||||
if (Nodes.Count <= n)
|
if (Nodes.Count <= n)
|
||||||
return false;
|
return false;
|
||||||
node = Nodes [n] as ITreeNode;
|
node = Nodes [n] as ITreeNode;
|
||||||
child_idx = node.ID;
|
child_idx = node.ID;
|
||||||
node_hash [node.ID] = node;
|
node_hash [node.ID] = node;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node_hash [parent] as ITreeNode;
|
node = node_hash [parent] as ITreeNode;
|
||||||
if (node == null || node.ChildCount <= n)
|
if (node == null || node.ChildCount <= n)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ITreeNode child = node [n];
|
ITreeNode child = node [n];
|
||||||
node_hash [child.ID] = child;
|
node_hash [child.ID] = child;
|
||||||
child_idx = child.ID;
|
child_idx = child.ID;
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parent_cb (out int parent_idx, int child)
|
bool parent_cb (out int parent_idx, int child)
|
||||||
{
|
{
|
||||||
parent_idx = -1;
|
parent_idx = -1;
|
||||||
ITreeNode node = node_hash [child] as ITreeNode;
|
try {
|
||||||
if (node == null || node.Parent == null)
|
ITreeNode node = node_hash [child] as ITreeNode;
|
||||||
return false;
|
if (node == null || node.Parent == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
node_hash [node.Parent.ID] = node.Parent;
|
node_hash [node.Parent.ID] = node.Parent;
|
||||||
parent_idx = node.Parent.ID;
|
parent_idx = node.Parent.ID;
|
||||||
return true;
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-2")]
|
[DllImport("gtksharpglue-2")]
|
||||||
|
|
|
@ -198,10 +198,14 @@ static SetScrollAdjustmentsDelegate SetScrollAdjustmentsCallback;
|
||||||
|
|
||||||
static void SetScrollAdjustments_cb (IntPtr widget, IntPtr hadj, IntPtr vadj)
|
static void SetScrollAdjustments_cb (IntPtr widget, IntPtr hadj, IntPtr vadj)
|
||||||
{
|
{
|
||||||
Widget obj = GLib.Object.GetObject (widget, false) as Widget;
|
try {
|
||||||
Gtk.Adjustment h = GLib.Object.GetObject (hadj, false) as Gtk.Adjustment;
|
Widget obj = GLib.Object.GetObject (widget, false) as Widget;
|
||||||
Gtk.Adjustment v = GLib.Object.GetObject (vadj, false) as Gtk.Adjustment;
|
Gtk.Adjustment h = GLib.Object.GetObject (hadj, false) as Gtk.Adjustment;
|
||||||
obj.OnSetScrollAdjustments (h, v);
|
Gtk.Adjustment v = GLib.Object.GetObject (vadj, false) as Gtk.Adjustment;
|
||||||
|
obj.OnSetScrollAdjustments (h, v);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ConnectSetScrollAdjustments (GLib.GType gtype)
|
static void ConnectSetScrollAdjustments (GLib.GType gtype)
|
||||||
|
@ -237,9 +241,13 @@ private delegate void BindingHandler (IntPtr handle, IntPtr user_data);
|
||||||
|
|
||||||
private static void BindingCallback (IntPtr handle, IntPtr user_data)
|
private static void BindingCallback (IntPtr handle, IntPtr user_data)
|
||||||
{
|
{
|
||||||
Widget w = GLib.Object.GetObject (handle, false) as Widget;
|
try {
|
||||||
BindingInvoker invoker = ((GCHandle) user_data).Target as BindingInvoker;
|
Widget w = GLib.Object.GetObject (handle, false) as Widget;
|
||||||
invoker.Invoke (w);
|
BindingInvoker invoker = ((GCHandle) user_data).Target as BindingInvoker;
|
||||||
|
invoker.Invoke (w);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static BindingHandler binding_delegate;
|
static BindingHandler binding_delegate;
|
||||||
|
|
Loading…
Reference in a new issue