Ryujinx-GtkSharp/sample/PropertyRegistration.cs
Mike Kestner 9864a0960d 2008-06-06 Mike Kestner <mkestner@novell.com>
Initial Patch submitted by Christian Hoff with some small
	style alterations and a round trip sample by me.  Supports the 
	registration of managed properties with the GType system, so 
	that things like custom cell renderers can be accessed via the
	native property system from treeview.

	* glib/glue/object.c : property registration related glue.
	* glib/Object.cs: implement managed property registration.
	* glib/PropertyAttribute.cs: add new props and ctor for managed
	property registration.
	* sample/PropertyRegistration.cs: little test app to test round-
	tripping of registered properties.
	* sample/Makefile.am: add new sample.

svn path=/trunk/gtk-sharp/; revision=105177
2008-06-06 16:55:00 +00:00

45 lines
974 B
C#

// PropertyRegistration.cs - GObject property registration sample
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2008 Novell, Inc.
namespace GtkSamples {
using System;
public class TestObject : GLib.Object {
public static int Main (string[] args)
{
GLib.GType.Init ();
TestObject obj = new TestObject ();
GLib.Value val = new GLib.Value (42);
obj.SetProperty ("my_prop", val);
val.Dispose ();
if (obj.MyProp != 42) {
Console.Error.WriteLine ("Property setter did not run.");
return 1;
}
GLib.Value val2 = obj.GetProperty ("my_prop");
if ((int)val2.Val != 42) {
Console.Error.WriteLine ("Property set/get roundtrip failed.");
return 1;
}
Console.WriteLine ("Round trip succeeded.");
return 0;
}
int my_prop;
[GLib.Property ("my_prop")]
public int MyProp {
get { return my_prop; }
set {
my_prop = value;
Console.WriteLine ("Property setter invoked.");
}
}
}
}