mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-25 02:25:37 +00:00
2003-07-23 Mike Kestner <mkestner@ximian.com>
[Equal credit to Ettore Perazzoli <ettore@ximian.com> for fixing all the bugs in the initial patch] * */*.custom : fix incorrect usage of new Object (IntPtr) where Glib.Object.GetObject should've been used. add ref_owned param to GetObject calls. * generator/CallbackGen.cs : setup ref_owned in bodies * generator/ClassBase.cs : add ref_owned to GetObject FromNative call * generator/Method.cs : setup ref_owned in bodies * generator/Property.cs : setup ref_owned in bodies * generator/SignalHandler.cs : pass ref_owned to GetObject * generator/StructBase.cs : setup ref_owned in bodies * glib/Object.cs : kill Ref/Unref methods. Don't want it to be easy for users to screw with ref counts, or make it look like they should need to. (GetObject): add ref_owned param and ref/unref to remain at 1 * glib/Value.cs : pass ref_owned to GetObject svn path=/trunk/gtk-sharp/; revision=16581
This commit is contained in:
parent
9d369d8cf9
commit
23464e6514
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
||||||
|
2003-07-23 Mike Kestner <mkestner@ximian.com>
|
||||||
|
|
||||||
|
[Equal credit to Ettore Perazzoli <ettore@ximian.com> for fixing
|
||||||
|
all the bugs in the initial patch]
|
||||||
|
* */*.custom : fix incorrect usage of new Object (IntPtr) where
|
||||||
|
Glib.Object.GetObject should've been used. add ref_owned param
|
||||||
|
to GetObject calls.
|
||||||
|
* generator/CallbackGen.cs : setup ref_owned in bodies
|
||||||
|
* generator/ClassBase.cs : add ref_owned to GetObject FromNative call
|
||||||
|
* generator/Method.cs : setup ref_owned in bodies
|
||||||
|
* generator/Property.cs : setup ref_owned in bodies
|
||||||
|
* generator/SignalHandler.cs : pass ref_owned to GetObject
|
||||||
|
* generator/StructBase.cs : setup ref_owned in bodies
|
||||||
|
* glib/Object.cs : kill Ref/Unref methods. Don't want it to be
|
||||||
|
easy for users to screw with ref counts, or make it look like they
|
||||||
|
should need to.
|
||||||
|
(GetObject): add ref_owned param and ref/unref to remain at 1
|
||||||
|
* glib/Value.cs : pass ref_owned to GetObject
|
||||||
|
|
||||||
2003-07-23 Martin Willemoes Hansen <mwh@sysrq.dk>
|
2003-07-23 Martin Willemoes Hansen <mwh@sysrq.dk>
|
||||||
|
|
||||||
* generator/ClassBase.cs: Fixed printouts of ctor validation.
|
* generator/ClassBase.cs: Fixed printouts of ctor validation.
|
||||||
|
|
|
@ -33,18 +33,13 @@
|
||||||
Raw = LoadFromStream (s);
|
Raw = LoadFromStream (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale_simple, composite_color_simple, and addalpha do a gdk_pixbuf_new on the
|
|
||||||
// return first, and we also ref it
|
|
||||||
// in the GetObject. So get rid of one extra reference.
|
|
||||||
|
|
||||||
|
|
||||||
[DllImport("gdk_pixbuf-2.0")]
|
[DllImport("gdk_pixbuf-2.0")]
|
||||||
static extern IntPtr gdk_pixbuf_scale_simple(IntPtr raw, int dest_width, int dest_height, int interp_type);
|
static extern IntPtr gdk_pixbuf_scale_simple(IntPtr raw, int dest_width, int dest_height, int interp_type);
|
||||||
|
|
||||||
public Gdk.Pixbuf ScaleSimple(int dest_width, int dest_height, Gdk.InterpType interp_type) {
|
public Gdk.Pixbuf ScaleSimple(int dest_width, int dest_height, Gdk.InterpType interp_type) {
|
||||||
IntPtr raw_ret = gdk_pixbuf_scale_simple(Handle, dest_width, dest_height, (int) interp_type);
|
IntPtr raw_ret = gdk_pixbuf_scale_simple(Handle, dest_width, dest_height, (int) interp_type);
|
||||||
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret, true);
|
||||||
ret.Unref ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +48,7 @@
|
||||||
|
|
||||||
public Gdk.Pixbuf CompositeColorSimple(int dest_width, int dest_height, Gdk.InterpType interp_type, int overall_alpha, int check_size, uint color1, uint color2) {
|
public Gdk.Pixbuf CompositeColorSimple(int dest_width, int dest_height, Gdk.InterpType interp_type, int overall_alpha, int check_size, uint color1, uint color2) {
|
||||||
IntPtr raw_ret = gdk_pixbuf_composite_color_simple(Handle, dest_width, dest_height, (int) interp_type, overall_alpha, check_size, color1, color2);
|
IntPtr raw_ret = gdk_pixbuf_composite_color_simple(Handle, dest_width, dest_height, (int) interp_type, overall_alpha, check_size, color1, color2);
|
||||||
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret, true);
|
||||||
ret.Unref ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +57,7 @@
|
||||||
|
|
||||||
public Gdk.Pixbuf AddAlpha(bool substitute_color, byte r, byte g, byte b) {
|
public Gdk.Pixbuf AddAlpha(bool substitute_color, byte r, byte g, byte b) {
|
||||||
IntPtr raw_ret = gdk_pixbuf_add_alpha(Handle, substitute_color, r, g, b);
|
IntPtr raw_ret = gdk_pixbuf_add_alpha(Handle, substitute_color, r, g, b);
|
||||||
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret, true);
|
||||||
ret.Unref ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t\t\tobject[] _args = new object[{0}];", count);
|
sw.WriteLine ("\t\t\tobject[] _args = new object[{0}];", count);
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
bool need_sep = false;
|
bool need_sep = false;
|
||||||
|
bool need_ref_owned = true;
|
||||||
string call_str = "";
|
string call_str = "";
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -142,6 +143,10 @@ namespace GtkSharp.Generation {
|
||||||
string cstype = parms[i].CSType;
|
string cstype = parms[i].CSType;
|
||||||
// FIXME: Too much code copy/pasted here. Refactor?
|
// FIXME: Too much code copy/pasted here. Refactor?
|
||||||
ClassBase parm_wrapper = table.GetClassGen (ctype);
|
ClassBase parm_wrapper = table.GetClassGen (ctype);
|
||||||
|
if (need_ref_owned && parm_wrapper != null && ((parm_wrapper is ObjectGen) || (parm_wrapper is InterfaceGen))) {
|
||||||
|
need_ref_owned = false;
|
||||||
|
sw.WriteLine("\t\t\tbool ref_owned = false;");
|
||||||
|
}
|
||||||
sw.WriteLine("\t\t\t_args[" + idx + "] = " + table.FromNative (ctype, parm_name) + ";");
|
sw.WriteLine("\t\t\t_args[" + idx + "] = " + table.FromNative (ctype, parm_name) + ";");
|
||||||
if ((parm_wrapper != null && ((parm_wrapper is OpaqueGen))) || table.IsManuallyWrapped (ctype)) {
|
if ((parm_wrapper != null && ((parm_wrapper is OpaqueGen))) || table.IsManuallyWrapped (ctype)) {
|
||||||
sw.WriteLine("\t\t\tif (_args[" + idx + "] == null)");
|
sw.WriteLine("\t\t\tif (_args[" + idx + "] == null)");
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public virtual String FromNative(String var)
|
public virtual String FromNative(String var)
|
||||||
{
|
{
|
||||||
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ")";
|
return "(" + QualifiedName + ") GLib.Object.GetObject(" + var + ", ref_owned)";
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual String FromNativeReturn(String var)
|
public virtual String FromNativeReturn(String var)
|
||||||
|
|
|
@ -391,9 +391,9 @@ namespace GtkSharp.Generation {
|
||||||
if (table.IsObject (rettype) || table.IsOpaque (rettype))
|
if (table.IsObject (rettype) || table.IsOpaque (rettype))
|
||||||
{
|
{
|
||||||
sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";");
|
sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";");
|
||||||
|
if (table.IsObject (rettype))
|
||||||
|
sw.WriteLine(indent + "\t\t\tbool ref_owned = false;");
|
||||||
sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + table.FromNativeReturn(rettype, "raw_ret") + ";");
|
sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + table.FromNativeReturn(rettype, "raw_ret") + ";");
|
||||||
if (needs_ref)
|
|
||||||
sw.WriteLine(indent + "\t\t\tret.Ref ();");
|
|
||||||
if (table.IsOpaque (rettype))
|
if (table.IsOpaque (rettype))
|
||||||
sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);");
|
sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);");
|
||||||
}
|
}
|
||||||
|
@ -403,6 +403,8 @@ namespace GtkSharp.Generation {
|
||||||
string raw_parms = "raw_ret";
|
string raw_parms = "raw_ret";
|
||||||
if (element_type != null)
|
if (element_type != null)
|
||||||
raw_parms += ", typeof (" + element_type + ")";
|
raw_parms += ", typeof (" + element_type + ")";
|
||||||
|
if (table.IsInterface (rettype))
|
||||||
|
sw.WriteLine(indent + "\t\t\tbool ref_owned = false;");
|
||||||
sw.WriteLine(s_ret + " ret = " + table.FromNativeReturn(rettype, raw_parms) + ";");
|
sw.WriteLine(s_ret + " ret = " + table.FromNativeReturn(rettype, raw_parms) + ";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
sw.WriteLine("\t\t\t\tGetProperty(" + cname + ", val);");
|
||||||
if (table.IsObject (c_type) || table.IsOpaque (c_type) || table.IsBoxed (c_type)) {
|
if (table.IsObject (c_type) || table.IsOpaque (c_type) || table.IsBoxed (c_type)) {
|
||||||
sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type);
|
sw.WriteLine("\t\t\t\tSystem.IntPtr raw_ret = (System.IntPtr) {0} val;", v_type);
|
||||||
|
if (table.IsObject (c_type))
|
||||||
|
sw.WriteLine ("\t\t\t\tbool ref_owned = false;");
|
||||||
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";");
|
sw.WriteLine("\t\t\t\t" + cs_type + " ret = " + table.FromNativeReturn(c_type, "raw_ret") + ";");
|
||||||
if (!table.IsBoxed (c_type))
|
if (!table.IsBoxed (c_type))
|
||||||
sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);");
|
sw.WriteLine("\t\t\t\tif (ret == null) ret = new " + cs_type + "(raw_ret);");
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\t\targs.Args[{0}] = null;", idx - 1);
|
sw.WriteLine("\t\t\t\targs.Args[{0}] = null;", idx - 1);
|
||||||
sw.WriteLine("\t\t\telse {");
|
sw.WriteLine("\t\t\telse {");
|
||||||
if (wrapper != null && wrapper is ObjectGen)
|
if (wrapper != null && wrapper is ObjectGen)
|
||||||
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = GLib.Object.GetObject(arg" + idx + ");");
|
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = GLib.Object.GetObject(arg" + idx + ", true);");
|
||||||
else
|
else
|
||||||
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = " + table.FromNative (ctype, "arg" + idx) + ";");
|
sw.WriteLine("\t\t\t\targs.Args[" + (idx-1) + "] = " + table.FromNative (ctype, "arg" + idx) + ";");
|
||||||
if ((wrapper != null && (wrapper is OpaqueGen)) || table.IsManuallyWrapped (ctype)) {
|
if ((wrapper != null && (wrapper is OpaqueGen)) || table.IsManuallyWrapped (ctype)) {
|
||||||
|
|
|
@ -163,8 +163,8 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {");
|
sw.WriteLine ("\t\tpublic " + wrapped + " " + wrapped_name + " {");
|
||||||
sw.WriteLine ("\t\t\tget { ");
|
sw.WriteLine ("\t\t\tget { ");
|
||||||
|
sw.WriteLine ("\t\t\t\tbool ref_owned = false;");
|
||||||
sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + table.FromNativeReturn(c_type, name) + ";");
|
sw.WriteLine ("\t\t\t\t" + wrapped + " ret = " + table.FromNativeReturn(c_type, name) + ";");
|
||||||
sw.WriteLine ("\t\t\t\tret.Ref ();");
|
|
||||||
sw.WriteLine ("\t\t\t\treturn ret;");
|
sw.WriteLine ("\t\t\t\treturn ret;");
|
||||||
sw.WriteLine ("\t\t\t}");
|
sw.WriteLine ("\t\t\t}");
|
||||||
sw.WriteLine ("\t\t\tset { " + name + " = " + table.CallByName (c_type, "value") + "; }");
|
sw.WriteLine ("\t\t\tset { " + name + " = " + table.CallByName (c_type, "value") + "; }");
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
static public Glade.XML GetWidgetTree (Gtk.Widget w) {
|
static public Glade.XML GetWidgetTree (Gtk.Widget w) {
|
||||||
IntPtr ret_raw = glade_get_widget_tree (w.Handle);
|
IntPtr ret_raw = glade_get_widget_tree (w.Handle);
|
||||||
Glade.XML ret = GLib.Object.GetObject (ret_raw) as Glade.XML;
|
Glade.XML ret = GLib.Object.GetObject (ret_raw, false) as Glade.XML;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,13 +165,13 @@
|
||||||
string signal_name, string signal_data,
|
string signal_name, string signal_data,
|
||||||
IntPtr connect_object_ptr, int after, IntPtr user_data) {
|
IntPtr connect_object_ptr, int after, IntPtr user_data) {
|
||||||
|
|
||||||
GLib.Object objekt = GLib.Object.GetObject (objekt_ptr);
|
GLib.Object objekt = GLib.Object.GetObject (objekt_ptr, false);
|
||||||
|
|
||||||
/* if an connect_object_ptr is provided, use that as handler */
|
/* if an connect_object_ptr is provided, use that as handler */
|
||||||
object connect_object =
|
object connect_object =
|
||||||
connect_object_ptr == IntPtr.Zero
|
connect_object_ptr == IntPtr.Zero
|
||||||
? handler_object
|
? handler_object
|
||||||
: GLib.Object.GetObject (connect_object_ptr);
|
: GLib.Object.GetObject (connect_object_ptr, false);
|
||||||
|
|
||||||
/* search for the event to connect */
|
/* search for the event to connect */
|
||||||
System.Reflection.MemberInfo[] evnts = objekt.GetType ().
|
System.Reflection.MemberInfo[] evnts = objekt.GetType ().
|
||||||
|
|
|
@ -145,7 +145,7 @@ namespace GLib {
|
||||||
ret = Activator.CreateInstance (list.element_type, new object[] {data});
|
ret = Activator.CreateInstance (list.element_type, new object[] {data});
|
||||||
}
|
}
|
||||||
else if (Object.IsObject (data))
|
else if (Object.IsObject (data))
|
||||||
ret = GLib.Object.GetObject (data);
|
ret = GLib.Object.GetObject (data, true);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
103
glib/Object.cs
103
glib/Object.cs
|
@ -1,9 +1,8 @@
|
||||||
// Object.cs - GObject class wrapper implementation
|
// Object.cs - GObject class wrapper implementation
|
||||||
//
|
//
|
||||||
// Authors: Bob Smith <bob@thestuff.net>
|
// Authors: Mike Kestner <mkestner@speakeasy.net>
|
||||||
// Mike Kestner <mkestner@speakeasy.net>
|
|
||||||
//
|
//
|
||||||
// (c) 2001 Bob Smith and Mike Kestner
|
// (c) 2001-2003 Mike Kestner
|
||||||
//
|
//
|
||||||
// TODO:
|
// TODO:
|
||||||
// Could remove `disposed' for a check if an object is on the dispose_queue_list.
|
// Could remove `disposed' for a check if an object is on the dispose_queue_list.
|
||||||
|
@ -34,7 +33,6 @@ namespace GLib {
|
||||||
|
|
||||||
// Private class and instance members
|
// Private class and instance members
|
||||||
IntPtr _obj;
|
IntPtr _obj;
|
||||||
protected bool needs_ref = true;
|
|
||||||
EventHandlerList _events;
|
EventHandlerList _events;
|
||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
Hashtable data;
|
Hashtable data;
|
||||||
|
@ -50,6 +48,9 @@ namespace GLib {
|
||||||
Dispose ();
|
Dispose ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
static extern void g_object_unref (IntPtr raw);
|
||||||
|
|
||||||
static bool PerformQueuedUnrefs ()
|
static bool PerformQueuedUnrefs ()
|
||||||
{
|
{
|
||||||
Object [] objects;
|
Object [] objects;
|
||||||
|
@ -66,7 +67,7 @@ namespace GLib {
|
||||||
if (o._obj == IntPtr.Zero)
|
if (o._obj == IntPtr.Zero)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
o.Unref ();
|
g_object_unref (o._obj);
|
||||||
o._obj = IntPtr.Zero;
|
o._obj = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -101,49 +102,9 @@ namespace GLib {
|
||||||
GC.SuppressFinalize (this);
|
GC.SuppressFinalize (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
|
||||||
static extern void g_object_unref (IntPtr raw);
|
|
||||||
|
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
static extern void g_object_ref (IntPtr raw);
|
static extern void g_object_ref (IntPtr raw);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ref Method
|
|
||||||
/// </summary>
|
|
||||||
///
|
|
||||||
/// <remarks>
|
|
||||||
/// Increases the reference count on the native object.
|
|
||||||
/// This method is used by generated classes and structs,
|
|
||||||
/// and should not be used in user code.
|
|
||||||
/// </remarks>
|
|
||||||
public virtual void Ref ()
|
|
||||||
{
|
|
||||||
if (_obj == IntPtr.Zero)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_object_ref (_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Unref Method
|
|
||||||
/// </summary>
|
|
||||||
///
|
|
||||||
/// <remarks>
|
|
||||||
/// Decreases the reference count on the native object.
|
|
||||||
/// This method is used by generated classes and structs,
|
|
||||||
/// and should not be used in user code.
|
|
||||||
///
|
|
||||||
/// This method should not be invoked by a thread.
|
|
||||||
/// </remarks>
|
|
||||||
public virtual void Unref ()
|
|
||||||
{
|
|
||||||
if (_obj == IntPtr.Zero)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_object_unref (_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GetObject Shared Method
|
/// GetObject Shared Method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -160,24 +121,40 @@ namespace GLib {
|
||||||
/// The wrapper instance.
|
/// The wrapper instance.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
|
|
||||||
public static Object GetObject(IntPtr o)
|
public static Object GetObject(IntPtr o, bool owned_ref)
|
||||||
{
|
{
|
||||||
WeakReference obj = Objects[o] as WeakReference;
|
Object obj;
|
||||||
if (obj != null) {
|
WeakReference weak_ref = Objects[o] as WeakReference;
|
||||||
// If the target object has not been collected, use it...
|
if (weak_ref != null && weak_ref.IsAlive) {
|
||||||
if (obj.IsAlive)
|
obj = weak_ref.Target as GLib.Object;
|
||||||
return obj.Target as GLib.Object;
|
if (owned_ref)
|
||||||
|
g_object_unref (obj._obj);
|
||||||
// ... otherwise we create a new wrapper around the IntPtr.
|
return obj;
|
||||||
Objects [o] = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return GtkSharp.ObjectManager.CreateObject(o);
|
obj = GtkSharp.ObjectManager.CreateObject(o);
|
||||||
|
if (obj == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!owned_ref)
|
||||||
|
g_object_ref (obj.Handle);
|
||||||
|
Objects [o] = new WeakReference (obj);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
static extern uint gtksharp_register_type (string name, uint parent_type);
|
static extern uint gtksharp_register_type (string name, uint parent_type);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RegisterGType Shared Method
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Shared method to register types with the GType system.
|
||||||
|
/// This method should be called from the class constructor
|
||||||
|
/// of subclasses.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
public static GLib.Type RegisterGType (System.Type t)
|
public static GLib.Type RegisterGType (System.Type t)
|
||||||
{
|
{
|
||||||
System.Type parent = t.BaseType;
|
System.Type parent = t.BaseType;
|
||||||
|
@ -200,9 +177,7 @@ namespace GLib {
|
||||||
/// Dummy constructor needed for derived classes.
|
/// Dummy constructor needed for derived classes.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
public Object () {
|
protected Object () {}
|
||||||
needs_ref = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Object Constructor
|
/// Object Constructor
|
||||||
|
@ -220,7 +195,15 @@ namespace GLib {
|
||||||
[DllImport("libgobject-2.0-0.dll")]
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
static extern IntPtr g_object_new (uint gtype, IntPtr dummy);
|
static extern IntPtr g_object_new (uint gtype, IntPtr dummy);
|
||||||
|
|
||||||
public Object (GLib.Type gtype)
|
/// <summary>
|
||||||
|
/// Object Constructor
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Creates an object from a specified GType.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
protected Object (GLib.Type gtype)
|
||||||
{
|
{
|
||||||
Raw = g_object_new (gtype.Value, IntPtr.Zero);
|
Raw = g_object_new (gtype.Value, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
@ -241,8 +224,6 @@ namespace GLib {
|
||||||
return _obj;
|
return _obj;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
if (needs_ref)
|
|
||||||
g_object_ref (value);
|
|
||||||
Objects [value] = new WeakReference (this);
|
Objects [value] = new WeakReference (this);
|
||||||
_obj = value;
|
_obj = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ namespace GLib {
|
||||||
{
|
{
|
||||||
// FIXME: Insert an appropriate exception here if
|
// FIXME: Insert an appropriate exception here if
|
||||||
// _val.type indicates an error.
|
// _val.type indicates an error.
|
||||||
return GLib.Object.GetObject(g_value_get_object (val._val));
|
return GLib.Object.GetObject(g_value_get_object (val._val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -12,13 +12,17 @@
|
||||||
[DllImport("gnomecanvas-2")]
|
[DllImport("gnomecanvas-2")]
|
||||||
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, uint type, IntPtr null_terminator);
|
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, uint type, IntPtr null_terminator);
|
||||||
|
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
static extern void g_object_ref (IntPtr raw);
|
||||||
|
|
||||||
public CanvasItem (Gnome.CanvasGroup group, uint type)
|
public CanvasItem (Gnome.CanvasGroup group, uint type)
|
||||||
: base (gnome_canvas_item_new (group.Handle, type, IntPtr.Zero))
|
: base (gnome_canvas_item_new (group.Handle, type, IntPtr.Zero))
|
||||||
{
|
{
|
||||||
|
g_object_ref (Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
static extern IntPtr gtksharp_gnome_canvas_item_get_canvas (IntPtr i);
|
static extern IntPtr gtksharp_gnome_canvas_item_get_canvas (IntPtr i);
|
||||||
public Canvas Canvas {
|
public Canvas Canvas {
|
||||||
get { return new Gnome.Canvas (gtksharp_gnome_canvas_item_get_canvas (this.Handle)); }
|
get { return GLib.Object.GetObject (gtksharp_gnome_canvas_item_get_canvas (this.Handle), false) as Canvas; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ static extern IntPtr gtksharp_combo_get_entry(IntPtr i);
|
||||||
|
|
||||||
public Gtk.Entry Entry {
|
public Gtk.Entry Entry {
|
||||||
get {
|
get {
|
||||||
return new Gtk.Entry (gtksharp_combo_get_entry(this.Handle));
|
return GLib.Object.GetObject (gtksharp_combo_get_entry(this.Handle), false) as Gtk.Entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,6 @@ static extern IntPtr gtksharp_combo_get_button(IntPtr i);
|
||||||
|
|
||||||
public Gtk.Button Button {
|
public Gtk.Button Button {
|
||||||
get {
|
get {
|
||||||
return new Gtk.Button (gtksharp_combo_get_button(this.Handle));
|
return GLib.Object.GetObject (gtksharp_combo_get_button(this.Handle), false) as Gtk.Button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,12 @@ public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags) : base()
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
static extern IntPtr gtksharp_dialog_get_vbox (IntPtr i);
|
static extern IntPtr gtksharp_dialog_get_vbox (IntPtr i);
|
||||||
public Gtk.VBox VBox {
|
public Gtk.VBox VBox {
|
||||||
get { return new Gtk.VBox (gtksharp_dialog_get_vbox (this.Handle)); }
|
get { return GLib.Object.GetObject (gtksharp_dialog_get_vbox (this.Handle), false) as VBox; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
static extern IntPtr gtksharp_dialog_get_action_area (IntPtr i);
|
static extern IntPtr gtksharp_dialog_get_action_area (IntPtr i);
|
||||||
public Gtk.VBox ActionArea {
|
public Gtk.VBox ActionArea {
|
||||||
get { return new Gtk.VBox (gtksharp_dialog_get_action_area (this.Handle)); }
|
get { return GLib.Object.GetObject (gtksharp_dialog_get_action_area (this.Handle), false) as VBox; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace GtkSharp {
|
||||||
{
|
{
|
||||||
if (RemoveIfNotAlive ()) return;
|
if (RemoveIfNotAlive ()) return;
|
||||||
object[] _args = new object[2];
|
object[] _args = new object[2];
|
||||||
_args[0] = (Gtk.Clipboard) GLib.Object.GetObject(clipboard);
|
_args[0] = (Gtk.Clipboard) GLib.Object.GetObject(clipboard, false);
|
||||||
if (_args[0] == null)
|
if (_args[0] == null)
|
||||||
_args[0] = new Gtk.Clipboard(clipboard);
|
_args[0] = new Gtk.Clipboard(clipboard);
|
||||||
_args[1] = Gtk.Clipboard.clipboard_objects[objid];
|
_args[1] = Gtk.Clipboard.clipboard_objects[objid];
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace GtkSharp {
|
||||||
{
|
{
|
||||||
if (RemoveIfNotAlive ()) return;
|
if (RemoveIfNotAlive ()) return;
|
||||||
object[] _args = new object[4];
|
object[] _args = new object[4];
|
||||||
_args[0] = (Gtk.Clipboard) GLib.Object.GetObject(clipboard);
|
_args[0] = (Gtk.Clipboard) GLib.Object.GetObject(clipboard, false);
|
||||||
if (_args[0] == null)
|
if (_args[0] == null)
|
||||||
_args[0] = new Gtk.Clipboard(clipboard);
|
_args[0] = new Gtk.Clipboard(clipboard);
|
||||||
_args[1] = selection_data;
|
_args[1] = selection_data;
|
||||||
|
|
|
@ -17,8 +17,7 @@ public Gdk.Window BinWindow {
|
||||||
IntPtr raw = gtksharp_gtk_layout_get_bin_window (Handle);
|
IntPtr raw = gtksharp_gtk_layout_get_bin_window (Handle);
|
||||||
|
|
||||||
if (raw != (IntPtr) 0) {
|
if (raw != (IntPtr) 0) {
|
||||||
Gdk.Window ret = (Gdk.Window) GLib.Object.GetObject (raw);
|
Gdk.Window ret = (Gdk.Window) GLib.Object.GetObject (raw, false);
|
||||||
ret.Ref ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,17 @@
|
||||||
[DllImport("gtksharpglue")]
|
[DllImport("gtksharpglue")]
|
||||||
private static extern bool gtksharp_object_is_floating (IntPtr raw);
|
private static extern bool gtksharp_object_is_floating (IntPtr raw);
|
||||||
|
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
private static extern void g_object_ref (IntPtr raw);
|
||||||
|
|
||||||
protected override IntPtr Raw {
|
protected override IntPtr Raw {
|
||||||
get {
|
get {
|
||||||
return base.Raw;
|
return base.Raw;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
base.Raw = value;
|
base.Raw = value;
|
||||||
if (!needs_ref && gtksharp_object_is_floating (value)) {
|
if (gtksharp_object_is_floating (value)) {
|
||||||
Ref ();
|
g_object_ref (value);
|
||||||
Sink ();
|
Sink ();
|
||||||
}
|
}
|
||||||
// System.Diagnostics.Debug.WriteLine ("Gtk.Object:set_Raw: object type is: " + (this as GLib.Object).GType.Name + " refcount now: " + RefCount + " needs_ref: " + needs_ref);
|
// System.Diagnostics.Debug.WriteLine ("Gtk.Object:set_Raw: object type is: " + (this as GLib.Object).GType.Name + " refcount now: " + RefCount + " needs_ref: " + needs_ref);
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
static extern IntPtr gtksharp_paned_get_child1 (IntPtr i);
|
static extern IntPtr gtksharp_paned_get_child1 (IntPtr i);
|
||||||
|
|
||||||
public Gtk.Widget Child1 {
|
public Gtk.Widget Child1 {
|
||||||
get { return new Widget (gtksharp_paned_get_child1 (this.Handle)); }
|
get { return GLib.Object.GetObject (gtksharp_paned_get_child1 (this.Handle), false) as Widget; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gtksharpglue")]
|
[DllImport ("gtksharpglue")]
|
||||||
static extern IntPtr gtksharp_paned_get_child2 (IntPtr i);
|
static extern IntPtr gtksharp_paned_get_child2 (IntPtr i);
|
||||||
|
|
||||||
public Gtk.Widget Child2 {
|
public Gtk.Widget Child2 {
|
||||||
get { return new Widget (gtksharp_paned_get_child2 (this.Handle)); }
|
get { return GLib.Object.GetObject (gtksharp_paned_get_child2 (this.Handle), false) as Widget; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
static Gdk.GC EnsureGC (IntPtr raw) {
|
static Gdk.GC EnsureGC (IntPtr raw) {
|
||||||
if (raw == IntPtr.Zero)
|
if (raw == IntPtr.Zero)
|
||||||
return null;
|
return null;
|
||||||
Gdk.GC ret = (Gdk.GC) GLib.Object.GetObject (raw);
|
Gdk.GC ret = (Gdk.GC) GLib.Object.GetObject (raw, false);
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
ret = new Gdk.GC (raw);
|
ret = new Gdk.GC (raw);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
IntPtr handle = (IntPtr) 0;
|
IntPtr handle = (IntPtr) 0;
|
||||||
bool raw_ret = gtk_tree_selection_get_selected(Handle, out handle, ref iter);
|
bool raw_ret = gtk_tree_selection_get_selected(Handle, out handle, ref iter);
|
||||||
bool ret = raw_ret;
|
bool ret = raw_ret;
|
||||||
model = (Gtk.TreeModel)GLib.Object.GetObject (handle);
|
model = (Gtk.TreeModel)GLib.Object.GetObject (handle, false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
public Gtk.TreeModel Model {
|
public Gtk.TreeModel Model {
|
||||||
get {
|
get {
|
||||||
IntPtr raw_ret = gtk_tree_view_get_model (Handle);
|
IntPtr raw_ret = gtk_tree_view_get_model (Handle);
|
||||||
Gtk.TreeModel ret = (Gtk.TreeModel) GLib.Object.GetObject (raw_ret);
|
Gtk.TreeModel ret = (Gtk.TreeModel) GLib.Object.GetObject (raw_ret, false);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,7 @@ public Gdk.Window GdkWindow {
|
||||||
IntPtr raw_ret = gtksharp_gtk_widget_get_window (Handle);
|
IntPtr raw_ret = gtksharp_gtk_widget_get_window (Handle);
|
||||||
|
|
||||||
if (raw_ret != (IntPtr) 0){
|
if (raw_ret != (IntPtr) 0){
|
||||||
Gdk.Window ret = (Gdk.Window) GLib.Object.GetObject(raw_ret);
|
Gdk.Window ret = (Gdk.Window) GLib.Object.GetObject(raw_ret, false);
|
||||||
ret.Ref ();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue