mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2002-08-31 Rachel Hestilow <hestilow@ximian.com>
* glib/Idle.cs: Added. * gtk/Application.cs: Add EventsPending, RunIteration. * sample/TreeViewDemo.cs: Add a status dialog while populating tree. svn path=/trunk/gtk-sharp/; revision=7164
This commit is contained in:
parent
7dd24ae681
commit
a502336ccf
@ -1,3 +1,11 @@
|
|||||||
|
2002-08-31 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
|
* glib/Idle.cs: Added.
|
||||||
|
* gtk/Application.cs: Add EventsPending, RunIteration.
|
||||||
|
|
||||||
|
* sample/TreeViewDemo.cs: Add a status dialog while
|
||||||
|
populating tree.
|
||||||
|
|
||||||
2002-08-31 Rachel Hestilow <hestilow@ximian.com>
|
2002-08-31 Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
* generator/Method.cs: Re-enable "if null then new" behavior
|
* generator/Method.cs: Re-enable "if null then new" behavior
|
||||||
|
45
glib/Idle.cs
Executable file
45
glib/Idle.cs
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
// GLib.Idle.cs - Idle class implementation
|
||||||
|
//
|
||||||
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
// Rachel Hestilow <hestilow@ximian.com>
|
||||||
|
//
|
||||||
|
// (c) 2002 Mike Kestner, Rachel Hestilow
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IdleHandler Delegate
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Delegate used for idle handlerss in the GLib main loop. Return
|
||||||
|
/// true to restart the idle. Returning false clears the
|
||||||
|
/// idle.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public delegate bool IdleHandler ();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Idle Class
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Allows the installation of Idle Handlers on the GLib main
|
||||||
|
/// loop.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public class Idle {
|
||||||
|
|
||||||
|
[DllImport("glib-2.0")]
|
||||||
|
static extern uint g_idle_add (IdleHandler d, IntPtr data);
|
||||||
|
|
||||||
|
public static uint Add (IdleHandler hndlr)
|
||||||
|
{
|
||||||
|
return g_idle_add (hndlr, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -64,6 +64,38 @@ namespace Gtk {
|
|||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("gtk-x11-2.0")]
|
||||||
|
static extern bool gtk_events_pending ();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// EventsPending Method
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Returns true if Gtk+ events are pending in the queue.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public static bool EventsPending ()
|
||||||
|
{
|
||||||
|
return gtk_events_pending ();
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("gtk-x11-2.0")]
|
||||||
|
static extern void gtk_main_iteration ();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RunIteration Method
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Runs a single iteration of the event loop.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
public static void RunIteration ()
|
||||||
|
{
|
||||||
|
gtk_main_iteration ();
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport("gtk-x11-2.0")]
|
[DllImport("gtk-x11-2.0")]
|
||||||
static extern void gtk_main_quit ();
|
static extern void gtk_main_quit ();
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace GtkSamples {
|
|||||||
|
|
||||||
public class TreeViewDemo {
|
public class TreeViewDemo {
|
||||||
private static TreeStore store = null;
|
private static TreeStore store = null;
|
||||||
|
private static Dialog dialog = null;
|
||||||
|
private static Label dialog_label = null;
|
||||||
|
|
||||||
private static void ProcessType (TreeIter parent, Type t)
|
private static void ProcessType (TreeIter parent, Type t)
|
||||||
{
|
{
|
||||||
@ -36,8 +38,11 @@ namespace GtkSamples {
|
|||||||
private static void ProcessAssembly (TreeIter parent, Assembly asm)
|
private static void ProcessAssembly (TreeIter parent, Assembly asm)
|
||||||
{
|
{
|
||||||
TreeIter iter = new TreeIter ();
|
TreeIter iter = new TreeIter ();
|
||||||
|
string asm_name = asm.GetName ().Name;
|
||||||
|
|
||||||
foreach (Type t in asm.GetTypes ()) {
|
foreach (Type t in asm.GetTypes ()) {
|
||||||
|
UpdateDialog ("Loading from {0}:\n{1}", asm_name, t.ToString ());
|
||||||
|
|
||||||
GLib.Value Name = new GLib.Value (t.Name);
|
GLib.Value Name = new GLib.Value (t.Name);
|
||||||
GLib.Value Type = new GLib.Value (t.ToString ());
|
GLib.Value Type = new GLib.Value (t.ToString ());
|
||||||
|
|
||||||
@ -54,8 +59,6 @@ namespace GtkSamples {
|
|||||||
if (store != null)
|
if (store != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Console.WriteLine ("Loading data from assemblies...");
|
|
||||||
|
|
||||||
store = new TreeStore ((int)TypeFundamentals.TypeString,
|
store = new TreeStore ((int)TypeFundamentals.TypeString,
|
||||||
(int)TypeFundamentals.TypeString);
|
(int)TypeFundamentals.TypeString);
|
||||||
|
|
||||||
@ -66,6 +69,8 @@ namespace GtkSamples {
|
|||||||
// stuff in some scary class.
|
// stuff in some scary class.
|
||||||
if (asm.GetName ().Name == "mscorlib") continue;
|
if (asm.GetName ().Name == "mscorlib") continue;
|
||||||
|
|
||||||
|
UpdateDialog ("Loading {0}", asm.GetName ().Name);
|
||||||
|
|
||||||
GLib.Value Name = new GLib.Value (asm.GetName ().Name);
|
GLib.Value Name = new GLib.Value (asm.GetName ().Name);
|
||||||
GLib.Value Type = new GLib.Value ("Assembly");
|
GLib.Value Type = new GLib.Value ("Assembly");
|
||||||
|
|
||||||
@ -81,6 +86,15 @@ namespace GtkSamples {
|
|||||||
{
|
{
|
||||||
Application.Init ();
|
Application.Init ();
|
||||||
|
|
||||||
|
Idle.Add (new IdleHandler (IdleCB));
|
||||||
|
|
||||||
|
Application.Run ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IdleCB ()
|
||||||
|
{
|
||||||
|
PopulateStore ();
|
||||||
|
|
||||||
Window win = new Window ("TreeView demo");
|
Window win = new Window ("TreeView demo");
|
||||||
win.DeleteEvent += new DeleteEventHandler (DeleteCB);
|
win.DeleteEvent += new DeleteEventHandler (DeleteCB);
|
||||||
win.DefaultSize = new Size (640,480);
|
win.DefaultSize = new Size (640,480);
|
||||||
@ -88,8 +102,6 @@ namespace GtkSamples {
|
|||||||
ScrolledWindow sw = new ScrolledWindow ();
|
ScrolledWindow sw = new ScrolledWindow ();
|
||||||
win.Add (sw);
|
win.Add (sw);
|
||||||
|
|
||||||
PopulateStore ();
|
|
||||||
|
|
||||||
TreeView tv = new TreeView (store);
|
TreeView tv = new TreeView (store);
|
||||||
tv.HeadersVisible = true;
|
tv.HeadersVisible = true;
|
||||||
|
|
||||||
@ -108,10 +120,12 @@ namespace GtkSamples {
|
|||||||
tv.AppendColumn (TypeCol);
|
tv.AppendColumn (TypeCol);
|
||||||
|
|
||||||
sw.Add (tv);
|
sw.Add (tv);
|
||||||
|
|
||||||
|
dialog.Destroy ();
|
||||||
|
dialog = null;
|
||||||
|
|
||||||
win.ShowAll ();
|
win.ShowAll ();
|
||||||
|
return false;
|
||||||
Application.Run ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void DeleteCB (Object o, DeleteEventArgs args)
|
private static void DeleteCB (Object o, DeleteEventArgs args)
|
||||||
@ -119,5 +133,39 @@ namespace GtkSamples {
|
|||||||
Application.Quit ();
|
Application.Quit ();
|
||||||
args.RetVal = true;
|
args.RetVal = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void UpdateDialog (string format, params object[] args)
|
||||||
|
{
|
||||||
|
string text = String.Format (format, args);
|
||||||
|
|
||||||
|
if (dialog == null)
|
||||||
|
{
|
||||||
|
dialog = new Dialog ();
|
||||||
|
dialog.Title = "Loading data from assemblies...";
|
||||||
|
dialog.AddButton (Stock.Cancel, 1);
|
||||||
|
dialog.Response += new ResponseHandler (ResponseCB);
|
||||||
|
dialog.DefaultSize = new Size (480, 100);
|
||||||
|
|
||||||
|
VBox vbox = dialog.VBox;
|
||||||
|
HBox hbox = new HBox (false, 4);
|
||||||
|
vbox.PackStart (hbox, true, true, 0);
|
||||||
|
|
||||||
|
Gtk.Image icon = new Gtk.Image (Stock.DialogInfo, IconSize.Dialog);
|
||||||
|
hbox.PackStart (icon, false, false, 0);
|
||||||
|
dialog_label = new Label (text);
|
||||||
|
hbox.PackStart (dialog_label, false, false, 0);
|
||||||
|
dialog.ShowAll ();
|
||||||
|
} else {
|
||||||
|
dialog_label.Text = text;
|
||||||
|
while (Application.EventsPending ())
|
||||||
|
Application.RunIteration ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ResponseCB (object obj, ResponseArgs args)
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
System.Environment.Exit (0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user