static GrlMedia * create_media_from_mount (GMount *mount) { char *id; GrlMedia *media; /* Is it an audio CD or a blank media */ if (ignore_mount (mount)) { GRL_DEBUG ("%s: Ignoring mount %s", __FUNCTION__, g_mount_get_name (mount)); g_object_unref (mount); return NULL; } id = create_mount_id (mount); if (id == NULL) { GRL_DEBUG ("%s: Not adding mount %s as has no device path", __FUNCTION__, g_mount_get_name (mount)); return NULL; } media = grl_media_video_new (); grl_media_set_id (media, id); g_free (id); media_set_metadata (mount, media); grl_media_set_mime (media, "x-special/device-block"); GRL_DEBUG ("%s: Adding mount %s (id: %s)", __FUNCTION__, g_mount_get_name (mount), grl_media_get_id (media)); return media; }
static GList * add_volume (GList *media_list, GVolume *volume, GDrive *drive, GrlOpticalMediaSource *source) { char *name, *icon_uri; GIcon *icon; char *device_path, *id; GrlMedia * media; GMount *mount; device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); if (device_path == NULL) return media_list; /* Is it an audio CD or a blank media */ mount = g_volume_get_mount (volume); if (mount != NULL) { GFile *root; root = g_mount_get_root (mount); g_object_unref (mount); if (g_file_has_uri_scheme (root, "burn") != FALSE || g_file_has_uri_scheme (root, "cdda") != FALSE) { /* We don't add Audio CDs, or blank media */ g_object_unref (root); g_free (device_path); return media_list; } g_object_unref (root); } media = grl_media_video_new (); id = g_filename_to_uri (device_path, NULL, NULL); g_free (device_path); grl_media_set_id (media, id); g_free (id); /* Work out an icon to display */ icon = g_volume_get_icon (volume); icon_uri = get_uri_for_gicon (icon); g_object_unref (icon); grl_media_set_thumbnail (media, icon_uri); g_free (icon_uri); /* Get the volume's pretty name for the menu label */ name = g_volume_get_name (volume); g_strstrip (name); grl_media_set_title (media, name); g_free (name); grl_media_set_mime (media, "x-special/device-block"); return g_list_prepend (media_list, media); }