Re: [Vala] Question on Documentation and tutorials.



Hi,

you may use dbus to get the plug message from Hal. And then you may
tell Hal to mount the volume.

The best way to understand is to look at source :
http://svn.gnome.org/viewvc/gnome-volume-manager/trunk/src/manager.c?rview=markup
    * gvm_dbus_init (void)
    * gvm_hal_init (void)

The second fonction register callback from an Hal event :
        libhal_ctx_set_device_added (ctx, hal_device_added);
        libhal_ctx_set_device_removed (ctx, hal_device_removed);
        libhal_ctx_set_device_new_capability (ctx, hal_device_new_capability);
        libhal_ctx_set_device_lost_capability (ctx, hal_device_lost_capability);
        libhal_ctx_set_device_property_modified (ctx, hal_property_modified);

Quit big to read but very interressant.

2008/9/10 Alessandro Pellizzari <alex amiran it>:
Il giorno ven, 22/08/2008 alle 14.42 +0200, Clément DAVID ha scritto:

Example: you want to eject a specific volume

    2. Then look at the corresponding vapi file to find the Vala
classes and fonctions names (Usually C class name without the first
'G' and C function name without class prefix).
               // in Vala
               VolumeMonitor myVolumeMonitor = VolumeMonitor.get ();
               List myDrives = myVolumeMonitor.get_connected_drives ();
               ...
               foreach ( Drive drv in myDrives )
                      stdout.printf (drv.get_name ());

Woahhh!! I had been looking for those 4 lines of code for weeks! :)

I was looking for dbus, udev, hal, etc, and didn't think to check the
"usual" GLib... :/

But now I have a problem.
I tried a little script (including just a little bit more than those 4
lines) but it doesn't show all my drives. :(

I have 2 DVDs, a 4-slot card reader, and plugged in a USB stick to try,
but the list returned by get_connected_drives() is empty.

I also tried get_volumes() and it only recognized the 2 DVDs and the
floppy because they were in /etc/fstab. Once removed, they disappeared
from get_volumes() list.

How can I get a list of all "hot-pluggable" devices (DVD, flash cards,
etc)?

I found get_mounts() to have a list of mounted devices.

Just to be clear: I would like to code something like
gnome-volume-manager, that gets signaled when a new device gets
hot-plugged and can mount/umount it.

A link to proper documentation7example/tutorial would be more than
enough.

Thank you very much.

Bye.

--
Alessandro Pellizzari


_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]