* glib/Object.cs: add needs_ref boolean that controls whether
we need to ref this object once we have a pointer to it or not. By default this is set to true -- constructors and other functions where we do own the object need to set this to false before setting the "Raw" property. Also added Unref and RefCount methods. * glue/object.c, glue/type.c: some utility functions for refcounting support * gdk/Pixbuf.custom: manually wrap a few functions so that the refcount ends up being correct at the end (need an extra Unref) * api/gdk-api.xml, sources/Gdk.metadata: metadata updates for hiding manually-wrapped Pixbuf stuff svn path=/trunk/gtk-sharp/; revision=8913
This commit is contained in:
parent
9ad6d1b6a4
commit
58f6f01d45
7 changed files with 142 additions and 55 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2002-11-10 Vladimir Vukicevic <vladimir@pobox.com>
|
||||
|
||||
* glib/Object.cs: add needs_ref boolean that controls whether
|
||||
we need to ref this object once we have a pointer to it or not.
|
||||
By default this is set to true -- constructors and other functions
|
||||
where we do own the object need to set this to false before setting
|
||||
the "Raw" property. Also added Unref and RefCount methods.
|
||||
|
||||
* glue/object.c, glue/type.c: some utility functions for
|
||||
refcounting support
|
||||
|
||||
* gdk/Pixbuf.custom: manually wrap a few functions so that
|
||||
the refcount ends up being correct at the end (need an extra Unref)
|
||||
|
||||
* api/gdk-api.xml, sources/Gdk.metadata: metadata updates for
|
||||
hiding manually-wrapped Pixbuf stuff
|
||||
|
||||
2002-11-10 Vladimir Vukicevic <vladimir@pobox.com>
|
||||
|
||||
* generator/StructBase.cs: create a Zero static member for
|
||||
|
|
|
@ -2411,15 +2411,6 @@
|
|||
</parameters>
|
||||
</callback>
|
||||
<object name="Pixbuf" cname="GdkPixbuf" parent="GObject">
|
||||
<method name="AddAlpha" cname="gdk_pixbuf_add_alpha">
|
||||
<return-type type="GdkPixbuf*"/>
|
||||
<parameters>
|
||||
<parameter type="gboolean" name="substitute_color"/>
|
||||
<parameter type="guchar" name="r"/>
|
||||
<parameter type="guchar" name="g"/>
|
||||
<parameter type="guchar" name="b"/>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="AlphaModeGetType" cname="gdk_pixbuf_alpha_mode_get_type" shared="true">
|
||||
<return-type type="GType"/>
|
||||
</method>
|
||||
|
@ -2460,18 +2451,6 @@
|
|||
<parameter type="guint32" name="color2"/>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="CompositeColorSimple" cname="gdk_pixbuf_composite_color_simple">
|
||||
<return-type type="GdkPixbuf*"/>
|
||||
<parameters>
|
||||
<parameter type="int" name="dest_width"/>
|
||||
<parameter type="int" name="dest_height"/>
|
||||
<parameter type="GdkInterpType" name="interp_type"/>
|
||||
<parameter type="int" name="overall_alpha"/>
|
||||
<parameter type="int" name="check_size"/>
|
||||
<parameter type="guint32" name="color1"/>
|
||||
<parameter type="guint32" name="color2"/>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="Copy" cname="gdk_pixbuf_copy">
|
||||
<return-type type="GdkPixbuf*"/>
|
||||
</method>
|
||||
|
@ -2721,14 +2700,6 @@
|
|||
<parameter type="GdkInterpType" name="interp_type"/>
|
||||
</parameters>
|
||||
</method>
|
||||
<method name="ScaleSimple" cname="gdk_pixbuf_scale_simple">
|
||||
<return-type type="GdkPixbuf*"/>
|
||||
<parameters>
|
||||
<parameter type="int" name="dest_width"/>
|
||||
<parameter type="int" name="dest_height"/>
|
||||
<parameter type="GdkInterpType" name="interp_type"/>
|
||||
</parameters>
|
||||
</method>
|
||||
</object>
|
||||
<object name="PixbufAnimation" cname="GdkPixbufAnimation" parent="GObject">
|
||||
<method name="GetHeight" cname="gdk_pixbuf_animation_get_height">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
IntPtr LoadFromStream (System.IO.Stream input)
|
||||
{
|
||||
IntPtr LoadFromStream (System.IO.Stream input)
|
||||
{
|
||||
PixbufLoader loader = new PixbufLoader ();
|
||||
byte [] buffer = new byte [8192];
|
||||
|
||||
|
@ -10,15 +10,15 @@ IntPtr LoadFromStream (System.IO.Stream input)
|
|||
loader.Close ();
|
||||
|
||||
return loader.Pixbuf.Handle;
|
||||
}
|
||||
}
|
||||
|
||||
public Pixbuf (System.IO.Stream input)
|
||||
{
|
||||
public Pixbuf (System.IO.Stream input)
|
||||
{
|
||||
Raw = LoadFromStream (input);
|
||||
}
|
||||
}
|
||||
|
||||
public Pixbuf (System.Reflection.Assembly assembly, string resource)
|
||||
{
|
||||
public Pixbuf (System.Reflection.Assembly assembly, string resource)
|
||||
{
|
||||
if (assembly == null)
|
||||
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
||||
|
||||
|
@ -26,4 +26,39 @@ public Pixbuf (System.Reflection.Assembly assembly, string resource)
|
|||
Pixbuf p = null;
|
||||
using (s = assembly.GetManifestResourceStream (resource))
|
||||
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")]
|
||||
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) {
|
||||
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);
|
||||
ret.Unref ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gdk_pixbuf-2.0")]
|
||||
static extern IntPtr gdk_pixbuf_composite_color_simple(IntPtr raw, int dest_width, int dest_height, int 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);
|
||||
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
||||
ret.Unref ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
[DllImport("gdk_pixbuf-2.0")]
|
||||
static extern IntPtr gdk_pixbuf_add_alpha(IntPtr raw, 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);
|
||||
Gdk.Pixbuf ret = (Gdk.Pixbuf) GLib.Object.GetObject(raw_ret);
|
||||
ret.Unref ();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace GLib {
|
|||
|
||||
// Private class and instance members
|
||||
IntPtr _obj;
|
||||
protected bool needs_ref = true;
|
||||
EventHandlerList _events;
|
||||
bool disposed = false;
|
||||
Hashtable Data;
|
||||
|
@ -88,6 +89,24 @@ namespace GLib {
|
|||
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.
|
||||
/// </remarks>
|
||||
protected virtual void Unref ()
|
||||
{
|
||||
if (_obj == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
g_object_unref (_obj);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// GetObject Shared Method
|
||||
/// </summary>
|
||||
|
@ -121,6 +140,7 @@ namespace GLib {
|
|||
/// </remarks>
|
||||
|
||||
public Object () {
|
||||
needs_ref = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -147,11 +167,16 @@ namespace GLib {
|
|||
/// Handle property.
|
||||
/// </remarks>
|
||||
|
||||
protected IntPtr Raw {
|
||||
[DllImport("libgobject-2.0.so")]
|
||||
private static extern string g_type_name (uint gtype);
|
||||
|
||||
protected virtual IntPtr Raw {
|
||||
get {
|
||||
return _obj;
|
||||
}
|
||||
set {
|
||||
if (needs_ref)
|
||||
g_object_ref (value);
|
||||
Objects [value] = new WeakReference (this);
|
||||
_obj = value;
|
||||
}
|
||||
|
@ -165,6 +190,9 @@ namespace GLib {
|
|||
/// The type associated with this object class.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("libgtksharpglue.so")]
|
||||
private static extern uint gtksharp_get_type_id (IntPtr obj);
|
||||
|
||||
public static int GType {
|
||||
get {
|
||||
return 0;
|
||||
|
@ -290,5 +318,14 @@ namespace GLib {
|
|||
{
|
||||
return gtksharp_is_object (obj);
|
||||
}
|
||||
|
||||
[DllImport("gtksharpglue")]
|
||||
static extern int gtksharp_object_get_ref_count (IntPtr obj);
|
||||
|
||||
public int RefCount {
|
||||
get {
|
||||
return gtksharp_object_get_ref_count (Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,3 +15,14 @@ gtksharp_object_unref_if_floating (GObject *obj)
|
|||
g_object_unref (obj);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtksharp_object_is_floating (GObject *obj)
|
||||
{
|
||||
return GTK_OBJECT_FLOATING (obj);
|
||||
}
|
||||
|
||||
int
|
||||
gtksharp_object_get_ref_count (GObject *obj)
|
||||
{
|
||||
return obj->ref_count;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* value.c : Glue to allocate GValues on the heap.
|
||||
/* type.c : GType utilities
|
||||
*
|
||||
* Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
*
|
||||
|
|
|
@ -121,4 +121,20 @@
|
|||
</data>
|
||||
</rule>
|
||||
|
||||
<!-- hides -->
|
||||
<rule>
|
||||
<class name="GdkPixbuf">
|
||||
<method>AddAlpha</method>
|
||||
<method>ScaleSimple</method>
|
||||
<method>CompositeColorSimple</method>
|
||||
</class>
|
||||
<data>
|
||||
<attribute target="method">
|
||||
<name>hidden</name>
|
||||
<value>1</value>
|
||||
</attribute>
|
||||
</data>
|
||||
|
||||
</rule>
|
||||
|
||||
</metadata>
|
||||
|
|
Loading…
Reference in a new issue