question about GIO and GVolumeMonitor
- From: Julien Martin <balteo gmail com>
- To: gtk-list gnome org
- Subject: question about GIO and GVolumeMonitor
- Date: Mon, 22 Jun 2009 13:53:31 +0200
Hello,
I am playing about with GTK and GIO and I am trying to list the first volume, mount and drive. My code is as follows:
#include <stdio.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <glib.h>
#include <gtk/gtk.h>
int main(int argc, char** argv) {
    GVolumeMonitor * monitor;
    GList * drives;
    GList * mounts;
    GList * volumes;
    char * mount_name;
    char * drive_name;
    char * volume_name;
    gtk_init(&argc, &argv);
    monitor = g_volume_monitor_get();
    drives = g_volume_monitor_get_connected_drives(G_VOLUME_MONITOR(monitor));
    mounts = g_volume_monitor_get_mounts(G_VOLUME_MONITOR(monitor));
    volumes = g_volume_monitor_get_volumes(G_VOLUME_MONITOR(monitor));
    GVolume * volume = (GVolume *) volumes->data;
    GDrive * drive = (GDrive *) drives->data;
    GMount * mount = (GMount *) mounts->data;
    volume_name = g_volume_get_name(volume);
    drive_name = g_drive_get_name(drive);
    mount_name = g_mount_get_name(mount);
    g_print("%s\n", volume_name);
    g_free(mount_name);
    g_free(drive_name);
    g_free(volume_name);
    gtk_main();
    return (EXIT_SUCCESS);
}I get a segmentation fault as if it was indicating that there were no volume nor any mount on my machine... (note that I don't get this problem with the drive.)
Can anyone help?
Thanks,
Julien.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]