mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-22 23:21:09 +00:00
2002-12-24 Mike Kestner <mkestner@speakeasy.net>
* generator/ObjectGen.cs : generate protected GType ctors * generator/SymbolTable.cs : map GType to uint * glib/Object.cs : add GType ctor. add RegisterGType. * glue/type.c (gtksharp_register_type): new GType registrar * */*.custom : make GType params uints * sample/Subclass.cs : a simple type registration example svn path=/trunk/gtk-sharp/; revision=9870
This commit is contained in:
parent
e0ec6df596
commit
f750d78d6a
|
@ -1,3 +1,12 @@
|
||||||
|
2002-12-24 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
|
* generator/ObjectGen.cs : generate protected GType ctors
|
||||||
|
* generator/SymbolTable.cs : map GType to uint
|
||||||
|
* glib/Object.cs : add GType ctor. add RegisterGType.
|
||||||
|
* glue/type.c (gtksharp_register_type): new GType registrar
|
||||||
|
* */*.custom : make GType params uints
|
||||||
|
* sample/Subclass.cs : a simple type registration example
|
||||||
|
|
||||||
2002-12-24 Alejandro Sánchez Acosta <raciel@gnome.org>
|
2002-12-24 Alejandro Sánchez Acosta <raciel@gnome.org>
|
||||||
|
|
||||||
* samples/tutorial/notebook: Added notebook sample.
|
* samples/tutorial/notebook: Added notebook sample.
|
||||||
|
|
|
@ -190,6 +190,7 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine("\t\t\tDispose();");
|
sw.WriteLine("\t\t\tDispose();");
|
||||||
sw.WriteLine("\t\t}");
|
sw.WriteLine("\t\t}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
sw.WriteLine("\t\tprotected " + Name + "(uint gtype) : base(gtype) {}");
|
||||||
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
||||||
sw.WriteLine();
|
sw.WriteLine();
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace GtkSharp.Generation {
|
||||||
simple_types.Add ("gunichar", "string");
|
simple_types.Add ("gunichar", "string");
|
||||||
simple_types.Add ("uint1", "bool");
|
simple_types.Add ("uint1", "bool");
|
||||||
simple_types.Add ("GPtrArray", "System.IntPtr[]");
|
simple_types.Add ("GPtrArray", "System.IntPtr[]");
|
||||||
simple_types.Add ("GType", "int");
|
simple_types.Add ("GType", "uint");
|
||||||
simple_types.Add ("GError", "IntPtr");
|
simple_types.Add ("GError", "IntPtr");
|
||||||
// gsize is a system-specific typedef in glibconfig.h,
|
// gsize is a system-specific typedef in glibconfig.h,
|
||||||
// but this should work for now
|
// but this should work for now
|
||||||
|
|
|
@ -10,8 +10,15 @@ namespace GLib {
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.All)]
|
||||||
|
public class WrapperClassAttribute : Attribute {
|
||||||
|
|
||||||
|
public WrapperClassAttribute () : base () {}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Object Class
|
/// Object Class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -131,6 +138,23 @@ namespace GLib {
|
||||||
return GtkSharp.ObjectManager.CreateObject(o);
|
return GtkSharp.ObjectManager.CreateObject(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("gtksharpglue")]
|
||||||
|
static extern uint gtksharp_register_type (string name, uint parent_type);
|
||||||
|
|
||||||
|
public static uint RegisterGType (Type t)
|
||||||
|
{
|
||||||
|
Type parent = t.BaseType;
|
||||||
|
PropertyInfo pi = parent.GetProperty ("GType", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
|
||||||
|
if (pi == null) {
|
||||||
|
Console.WriteLine ("null PropertyInfo");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
uint parent_gtype = (uint) pi.GetValue (null, null);
|
||||||
|
string name = t.Namespace + t.Name;
|
||||||
|
GtkSharp.ObjectManager.RegisterType (name, t.Namespace + t.Name, t.Assembly.GetName().Name);
|
||||||
|
return gtksharp_register_type (name, parent_gtype);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Object Constructor
|
/// Object Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -156,6 +180,14 @@ namespace GLib {
|
||||||
Raw = raw;
|
Raw = raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("gobject-2.0")]
|
||||||
|
static extern IntPtr g_object_new (uint gtype, IntPtr dummy);
|
||||||
|
|
||||||
|
public Object (uint gtype)
|
||||||
|
{
|
||||||
|
Raw = g_object_new (gtype, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raw Property
|
/// Raw Property
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -190,7 +222,7 @@ namespace GLib {
|
||||||
/// The type associated with this object class.
|
/// The type associated with this object class.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
|
|
||||||
[DllImport("libgtksharpglue.so")]
|
[DllImport("gtksharpglue")]
|
||||||
private static extern uint gtksharp_get_type_id (IntPtr obj);
|
private static extern uint gtksharp_get_type_id (IntPtr obj);
|
||||||
|
|
||||||
public static uint GType {
|
public static uint GType {
|
||||||
|
|
15
glue/type.c
15
glue/type.c
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
gtksharp_get_type_name (GObject *obj)
|
gtksharp_get_type_name (GObject *obj)
|
||||||
|
@ -36,3 +37,17 @@ gtksharp_get_type_name_for_id (GType typ)
|
||||||
{
|
{
|
||||||
return g_type_name (typ);
|
return g_type_name (typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GType
|
||||||
|
gtksharp_register_type (gchar *name, GType parent)
|
||||||
|
{
|
||||||
|
GTypeQuery query;
|
||||||
|
GTypeInfo info = {0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL };
|
||||||
|
|
||||||
|
g_type_query (parent, &query);
|
||||||
|
|
||||||
|
info.class_size = query.class_size;
|
||||||
|
info.instance_size = query.instance_size;
|
||||||
|
|
||||||
|
return g_type_register_static (parent, name, &info, 0);
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// This code is inserted after the automatically generated code.
|
// This code is inserted after the automatically generated code.
|
||||||
//
|
//
|
||||||
|
|
||||||
protected CanvasGroup (Gnome.CanvasGroup group, int type) : base (group, type)
|
protected CanvasGroup (Gnome.CanvasGroup group, uint type) : base (group, type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
|
|
||||||
[DllImport("gnomecanvas-2")]
|
[DllImport("gnomecanvas-2")]
|
||||||
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, int type, IntPtr null_terminator);
|
static extern System.IntPtr gnome_canvas_item_new (IntPtr group, uint type, IntPtr null_terminator);
|
||||||
|
|
||||||
public CanvasItem (Gnome.CanvasGroup group, int 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))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// This code is inserted after the automatically generated code.
|
// This code is inserted after the automatically generated code.
|
||||||
//
|
//
|
||||||
|
|
||||||
protected CanvasRE (Gnome.CanvasGroup group, int type) : base (group, type)
|
protected CanvasRE (Gnome.CanvasGroup group, uint type) : base (group, type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// This code is inserted after the automatically generated code.
|
// This code is inserted after the automatically generated code.
|
||||||
//
|
//
|
||||||
|
|
||||||
protected CanvasShape (Gnome.CanvasGroup group, int type) : base (group, type)
|
protected CanvasShape (Gnome.CanvasGroup group, uint type) : base (group, type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumnTypes (params int[] types)
|
public void SetColumnTypes (params uint[] types)
|
||||||
{
|
{
|
||||||
SetColumnTypes (types.Length, types);
|
SetColumnTypes (types.Length, types);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetColumnTypes (params int[] types)
|
public void SetColumnTypes (params uint[] types)
|
||||||
{
|
{
|
||||||
SetColumnTypes (types.Length, types);
|
SetColumnTypes (types.Length, types);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ windows:
|
||||||
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
|
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll /r:../gdk/gdk-sharp.dll HelloWorld.cs
|
||||||
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
|
$(CSC) /unsafe /out:button.exe /r:../glib/glib-sharp.dll /r:../gtk/gtk-sharp.dll ButtonApp.cs
|
||||||
|
|
||||||
linux: gtk-hello-world.exe button.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS)
|
linux: gtk-hello-world.exe button.exe subclass.exe menu.exe size.exe scribble.exe treeviewdemo.exe $(GNOME_TARGETS) $(GLADE_TARGETS)
|
||||||
@ENABLE_GNOME_TRUE@ $(MAKE) -C gconf
|
@ENABLE_GNOME_TRUE@ $(MAKE) -C gconf
|
||||||
|
|
||||||
gtk-hello-world.exe: HelloWorld.cs
|
gtk-hello-world.exe: HelloWorld.cs
|
||||||
|
@ -36,6 +36,9 @@ fifteen.exe: Fifteen.cs
|
||||||
button.exe: ButtonApp.cs
|
button.exe: ButtonApp.cs
|
||||||
$(MCS) --unsafe -o button.exe $(local_paths) $(all_assemblies) ButtonApp.cs
|
$(MCS) --unsafe -o button.exe $(local_paths) $(all_assemblies) ButtonApp.cs
|
||||||
|
|
||||||
|
subclass.exe: Subclass.cs
|
||||||
|
$(MCS) --unsafe -o subclass.exe $(local_paths) $(all_assemblies) Subclass.cs
|
||||||
|
|
||||||
menu.exe: Menu.cs
|
menu.exe: Menu.cs
|
||||||
$(MCS) --unsafe -o menu.exe $(local_paths) $(all_assemblies) Menu.cs
|
$(MCS) --unsafe -o menu.exe $(local_paths) $(all_assemblies) Menu.cs
|
||||||
|
|
||||||
|
|
58
sample/Subclass.cs
Executable file
58
sample/Subclass.cs
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
// Subclass.cs - Widget subclass Test implementation
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
//
|
||||||
|
// (c) 2001-2002 Mike Kestner
|
||||||
|
|
||||||
|
namespace GtkSamples {
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
using GtkSharp;
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
|
public class ButtonApp {
|
||||||
|
|
||||||
|
public static int Main (string[] args)
|
||||||
|
{
|
||||||
|
Application.Init ();
|
||||||
|
Window win = new Window ("Button Tester");
|
||||||
|
win.DefaultSize = new Size (200, 150);
|
||||||
|
win.DeleteEvent += new DeleteEventHandler (Window_Delete);
|
||||||
|
Button btn = new MyButton ();
|
||||||
|
btn.Label = "I'm a subclassed button";
|
||||||
|
btn.Clicked += new EventHandler (btn_click);
|
||||||
|
win.Add (btn);
|
||||||
|
win.ShowAll ();
|
||||||
|
Application.Run ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void btn_click (object obj, EventArgs args)
|
||||||
|
{
|
||||||
|
Console.WriteLine ("Button Clicked");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Window_Delete (object obj, DeleteEventArgs args)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
args.RetVal = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MyButton : Gtk.Button {
|
||||||
|
|
||||||
|
static uint gtype = 0;
|
||||||
|
|
||||||
|
public MyButton () : base (GType) {}
|
||||||
|
|
||||||
|
public static new uint GType {
|
||||||
|
get {
|
||||||
|
if (gtype == 0)
|
||||||
|
gtype = RegisterGType (typeof (MyButton));
|
||||||
|
return gtype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue