mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 19:25:42 +00:00
Initial revision
svn path=/trunk/gtk-sharp/; revision=834
This commit is contained in:
commit
7d69671d49
3
.cvsignore
Executable file
3
.cvsignore
Executable file
|
@ -0,0 +1,3 @@
|
|||
*.dll
|
||||
*.exe
|
||||
|
11
README
Normal file
11
README
Normal file
|
@ -0,0 +1,11 @@
|
|||
Gtk# is a C# binding for the Gtk toolkit (www.gtk.org). The target is the
|
||||
2.0 platform, and no plans are currently in place to backport to 1.2.
|
||||
|
||||
The effort essentially boils down to an exercise in PInvoke against the C
|
||||
dynamic libraries. It may end up being slow as hell, but we'll see when we get
|
||||
there and adjust accordingly.
|
||||
|
||||
The "Hello World" application in the sample directory has been executed
|
||||
on Win32 using the Gtk and associated binaries provided by the Gimp Win32
|
||||
porting project. Links to these binaries can be found on the Gtk Homepage.
|
||||
|
BIN
gtk/.Widget.cs.swp
Executable file
BIN
gtk/.Widget.cs.swp
Executable file
Binary file not shown.
3
gtk/.cvsignore
Executable file
3
gtk/.cvsignore
Executable file
|
@ -0,0 +1,3 @@
|
|||
*.dll
|
||||
*.exe
|
||||
|
77
gtk/Application.cs
Executable file
77
gtk/Application.cs
Executable file
|
@ -0,0 +1,77 @@
|
|||
// GTK.Application.cs - GTK Main Event Loop class implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GTK {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
/// <summary>
|
||||
/// Application Class
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Provides the initialization and event loop iteration related
|
||||
/// methods for the GTK widget library. Since GTK is an event
|
||||
/// driven toolkit, Applications register callbacks against various
|
||||
/// events to handle user input. These callbacks are invoked from
|
||||
/// the main event loop when events are detected.
|
||||
/// </remarks>
|
||||
|
||||
public class Application {
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_init (ref int argc, ref String[] argv);
|
||||
|
||||
/// <summary>
|
||||
/// Init Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Initializes GTK resources.
|
||||
/// </remarks>
|
||||
|
||||
public static void Init (ref string[] args)
|
||||
{
|
||||
int argc = args.Length;
|
||||
gtk_init (ref argc, ref args);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Begins the event loop iteration.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_main ();
|
||||
|
||||
public static void Run ()
|
||||
{
|
||||
gtk_main ();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Quit Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Terminates the event loop iteration.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_main_quit ();
|
||||
|
||||
public static void Quit ()
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
36
gtk/Object.cs
Executable file
36
gtk/Object.cs
Executable file
|
@ -0,0 +1,36 @@
|
|||
// Object.cs - GtkObject class wrapper implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GTK {
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public abstract class Object {
|
||||
|
||||
protected IntPtr obj;
|
||||
|
||||
protected delegate void SimpleCallback (IntPtr obj);
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_signal_connect_full (
|
||||
IntPtr obj, string evname,
|
||||
SimpleCallback cb, IntPtr unsupported,
|
||||
IntPtr data, IntPtr destroycb,
|
||||
int objsig, int after );
|
||||
|
||||
|
||||
protected void ConnectSignal (string name, SimpleCallback cb)
|
||||
{
|
||||
gtk_signal_connect_full (obj, name, cb,
|
||||
new IntPtr (0), new IntPtr (0),
|
||||
new IntPtr (0), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
68
gtk/Widget.cs
Executable file
68
gtk/Widget.cs
Executable file
|
@ -0,0 +1,68 @@
|
|||
// GTK.Widget.cs - GTK Widget class implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GTK {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public abstract class Widget : Object {
|
||||
|
||||
/// <summary>
|
||||
/// ConnectEvents method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Connects event handlers to the wrapped GTK widget.
|
||||
/// It is not possible to perform this connection in a
|
||||
/// constructor, since the leaf class constructor in which
|
||||
/// the wrapped object is created is not executed until
|
||||
/// after the base class' constructor.
|
||||
/// </remarks>
|
||||
|
||||
protected void PrepareEvents ()
|
||||
{
|
||||
ConnectSignal ("delete-event",
|
||||
new SimpleCallback (EmitDeleteEvent));
|
||||
}
|
||||
|
||||
private void EmitDeleteEvent (IntPtr obj)
|
||||
{
|
||||
if (Delete != null) {
|
||||
EventArgs args = new EventArgs ();
|
||||
Delete (this, args);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete Event
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Occurs when the Widget is deleted by the window
|
||||
/// manager.
|
||||
/// </remarks>
|
||||
|
||||
public event EventHandler Delete;
|
||||
|
||||
/// <summary>
|
||||
/// Show Method
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Makes the Widget visible on the display.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_widget_show (IntPtr obj);
|
||||
|
||||
public void Show ()
|
||||
{
|
||||
gtk_widget_show (obj);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
162
gtk/Window.cs
Executable file
162
gtk/Window.cs
Executable file
|
@ -0,0 +1,162 @@
|
|||
// GTK.Window.cs - GTK Window class implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GTK {
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public enum WindowType {
|
||||
TopLevel,
|
||||
Popup,
|
||||
}
|
||||
|
||||
public class Window : Widget {
|
||||
|
||||
/// <summary>
|
||||
/// Window Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Constructs a new Window of type TopLevel.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern IntPtr gtk_window_new (GTK.WindowType type);
|
||||
|
||||
public Window ()
|
||||
{
|
||||
obj = gtk_window_new (WindowType.TopLevel);
|
||||
base.PrepareEvents ();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Window Constructor
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Constructs a new Window of type TopLevel with the
|
||||
/// specified Title.
|
||||
/// </remarks>
|
||||
|
||||
public Window (String title) : this ()
|
||||
{
|
||||
this.Title = title;
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// AllowGrow Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the Window can be resized to larger than
|
||||
/// the default size.
|
||||
/// </remarks>
|
||||
|
||||
public bool AllowGrow {
|
||||
get {;}
|
||||
set {;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AllowShrink Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the Window can be resized to smaller than
|
||||
/// the default size.
|
||||
/// </remarks>
|
||||
|
||||
public bool AllowShrink {
|
||||
get {;}
|
||||
set {;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DefaultSize Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The default Size of the Window in Screen Coordinates.
|
||||
/// </remarks>
|
||||
|
||||
public Size DefaultSize {
|
||||
get {;}
|
||||
set {;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DestroyWithParent Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the Window should be destroyed when any
|
||||
/// associated parent Windows are destroyed.
|
||||
/// </remarks>
|
||||
|
||||
public bool DestroyWithParent {
|
||||
get {;}
|
||||
set {;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IsModal Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Indicates if the Window is Modal. If true, the input
|
||||
/// focus is grabbed by the Window and other Windows in
|
||||
/// the application will not accept input until the Window
|
||||
/// is closed.
|
||||
/// </remarks>
|
||||
|
||||
public bool IsModal {
|
||||
get {;}
|
||||
set {;}
|
||||
}
|
||||
*/
|
||||
/// <summary>
|
||||
/// Position Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Position of the Window in Screen Coordinates.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_window_set_position (IntPtr hnd,
|
||||
int x, int y);
|
||||
|
||||
public Point Position {
|
||||
set
|
||||
{
|
||||
gtk_window_set_position (
|
||||
obj, value.X, value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Title Property
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// The Title displayed in the Window's Title Bar.
|
||||
/// </remarks>
|
||||
|
||||
[DllImport("gtk-1.3")]
|
||||
static extern void gtk_window_set_title (IntPtr hnd,
|
||||
String title);
|
||||
|
||||
public String Title {
|
||||
set
|
||||
{
|
||||
gtk_window_set_title (obj, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
gtk/makefile
Executable file
11
gtk/makefile
Executable file
|
@ -0,0 +1,11 @@
|
|||
CSC=/cygdrive/c/windows/microsoft.net/framework/v1.0.2914/csc.exe
|
||||
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows:
|
||||
$(CSC) /unsafe /target:library /out:gtk-sharp.dll /recurse:*.cs
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
3
sample/.cvsignore
Executable file
3
sample/.cvsignore
Executable file
|
@ -0,0 +1,3 @@
|
|||
*.dll
|
||||
*.exe
|
||||
|
30
sample/HelloWorld.cs
Executable file
30
sample/HelloWorld.cs
Executable file
|
@ -0,0 +1,30 @@
|
|||
// TestWindow.cs - GTK Window class Test implementation
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GtkSamples {
|
||||
|
||||
using GTK;
|
||||
using System;
|
||||
|
||||
public class HelloWorld {
|
||||
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
Application.Init (ref args);
|
||||
Window win = new Window ("Gtk# Hello World");
|
||||
win.Delete += new EventHandler (delete_cb);
|
||||
win.Show ();
|
||||
Application.Run ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void delete_cb (object obj, EventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
sample/makefile
Executable file
11
sample/makefile
Executable file
|
@ -0,0 +1,11 @@
|
|||
CSC=/cygdrive/c/windows/microsoft.net/framework/v1.0.2914/csc.exe
|
||||
|
||||
all:
|
||||
@echo "You must use 'make windows' or 'make unix'."
|
||||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows:
|
||||
$(CSC) /unsafe /out:gtk-hello-world.exe /r:../gtk/gtk-sharp.dll /recurse:*.cs
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
Loading…
Reference in a new issue