#include <gio/gio.h>

int main()
{
	GVolumeMonitor *mon;
	GList *mounts, *vols;
	GVolume *vol = NULL;
	GMount *mount = NULL;
	GFile *file;

	g_type_init();

	mon = g_volume_monitor_get();
	vols = g_volume_monitor_get_volumes(mon);
	
	if (!vols)
		g_print("Please insert a thumb drive!\n");
	else
		vol = (GVolume*)g_object_ref(vols->data);
	
	g_list_foreach(vols, (GFunc)g_object_unref, NULL);
	g_list_free(vols);
	
	if (!vol)
		return 1;
	
	mount = g_volume_get_mount(vol);
	g_print("Volume '%s' first gives %p\n", g_volume_get_name(vol), mount);
	if (mount)
		g_object_unref(mount);
	
	g_object_unref(mon);
	
	mount = g_volume_get_mount(vol);
	g_print("Volume '%s' then gives %p\n", g_volume_get_name(vol), mount);
	if (mount)
		g_object_unref(mount);
	
	g_object_unref(vol);
	return 0;
}
