svn path=/trunk/hal-sharp/; revision=47369
This commit is contained in:
Aaron Bockover 2005-07-17 21:25:03 +00:00
Родитель ec914f0c0c
Коммит fcf32b6dca
1 изменённых файлов: 36 добавлений и 1 удалений

Просмотреть файл

@ -29,13 +29,15 @@
using System; using System;
using Hal; using Hal;
using Gtk; using Gtk;
using System.Collections;
public class Entry public class Entry
{ {
public static void Main() public static void Main()
{ {
Application.Init(); Application.Init();
new GtkTest(); new CdromTest();
//new GtkTest();
Application.Run(); Application.Run();
/* Context ctx = new Context(); */ /* Context ctx = new Context(); */
@ -56,6 +58,39 @@ public class Entry
} }
} }
public class CdromTest
{
private Context ctx;
private ArrayList disks = new ArrayList();
public CdromTest()
{
ctx = new Context();
ctx.DeviceAdded += OnDeviceAdded;
ctx.DeviceRemoved += OnDeviceRemoved;
}
private void OnDeviceAdded(object o, DeviceAddedArgs args)
{
Device parentDevice = new Device(ctx, args.Device["info.parent"]);
if(parentDevice["storage.drive_type"].Equals("cdrom")) {
Console.WriteLine("Found drive with disk: {0} ({1})",
parentDevice,
parentDevice["storage.model"]);
}
}
private void OnDeviceRemoved(object o, DeviceRemovedArgs args)
{
if(disks.IndexOf(args.Device.Udi) >= 0) {
Console.WriteLine("Disk removed: {0}", args.Device);
disks.Remove(args.Device.Udi);
}
}
}
public class GtkTest public class GtkTest
{ {
private Window win; private Window win;