#include <stdio.h>
#include <stdlib.h>

#include <gio/gio.h>

static void print_mount_list(GList* mount_list) {
	GList *tmp_mnt_list = NULL;
	printf("[");
	if (mount_list) {
		printf(g_mount_get_name(mount_list->data));
		tmp_mnt_list = mount_list->next;
	}
	while (tmp_mnt_list) {
		printf(", %s", g_mount_get_name(tmp_mnt_list->data));
		tmp_mnt_list = tmp_mnt_list->next;
	}
	printf("]\n");
}

int main(int argc, char * argv[])
{
	GVolumeMonitor *gvm;
	gvm = g_volume_monitor_get();

	GList *mount_list;
	mount_list = g_volume_monitor_get_mounts(gvm);
	print_mount_list(mount_list);

	printf("Sleeping for 20 seconds. Time to mount or unmount.\n");
	g_usleep(1000*1000*20);

	g_object_unref(gvm);
	gvm = g_volume_monitor_get();
	mount_list = g_volume_monitor_get_mounts(gvm);
	print_mount_list(mount_list);

	return 0;
}

