static gboolean ignore_drive (GDrive *drive) { GIcon *icon; if (g_drive_can_eject (drive) == FALSE || g_drive_has_media (drive) == FALSE) { GRL_DEBUG ("%s: Not adding %s as cannot eject or has no media", __FUNCTION__, g_drive_get_name (drive)); return TRUE; } /* Hack to avoid USB devices showing up * https://bugzilla.gnome.org/show_bug.cgi?id=679624 */ icon = g_drive_get_icon (drive); if (icon && G_IS_THEMED_ICON (icon)) { const gchar * const * names; names = g_themed_icon_get_names (G_THEMED_ICON (icon)); if (names && names[0] && !g_str_has_prefix (names[0], "drive-optical")) { g_object_unref (icon); GRL_DEBUG ("%s: Not adding drive %s as is not optical drive", __FUNCTION__, g_drive_get_name (drive)); return TRUE; } } g_clear_object (&icon); return FALSE; }
static void brasero_gio_operation_ejected_cb (GDrive *gdrive, gpointer callback_data) { BraseroGioOperation *operation = callback_data; if (!g_drive_has_media (gdrive)) brasero_gio_operation_end (operation); }
static void rejilla_gio_operation_ejected_cb (GDrive *gdrive, gpointer callback_data) { RejillaGioOperation *operation = callback_data; if (!g_drive_has_media (gdrive)) rejilla_gio_operation_end (operation); }
static void list_drives (GList *drives, int indent) { GList *volumes, *l; int c, i; GDrive *drive; char *name; char **ids; GIcon *icon; for (c = 0, l = drives; l != NULL; l = l->next, c++) { drive = (GDrive *) l->data; name = g_drive_get_name (drive); g_print ("%*sDrive(%d): %s\n", indent, "", c, name); g_free (name); if (mount_list_info) { ids = g_drive_enumerate_identifiers (drive); if (ids && ids[0] != NULL) { g_print ("%*sids:\n", indent+2, ""); for (i = 0; ids[i] != NULL; i++) { char *id = g_drive_get_identifier (drive, ids[i]); g_print ("%*s %s: '%s'\n", indent+2, "", ids[i], id); g_free (id); } } g_strfreev (ids); icon = g_drive_get_icon (drive); if (icon) { if (G_IS_THEMED_ICON (icon)) show_themed_icon_names (G_THEMED_ICON (icon), indent + 2); g_object_unref (icon); } g_print ("%*sis_media_removable=%d\n", indent + 2, "", g_drive_is_media_removable (drive)); g_print ("%*shas_media=%d\n", indent + 2, "", g_drive_has_media (drive)); g_print ("%*sis_media_check_automatic=%d\n", indent + 2, "", g_drive_is_media_check_automatic (drive)); g_print ("%*scan_poll_for_media=%d\n", indent + 2, "", g_drive_can_poll_for_media (drive)); g_print ("%*scan_eject=%d\n", indent + 2, "", g_drive_can_eject (drive)); } volumes = g_drive_get_volumes (drive); list_volumes (volumes, indent + 2, FALSE); g_list_foreach (volumes, (GFunc)g_object_unref, NULL); g_list_free (volumes); } }
static GList * add_drive (GList *media_list, GDrive *drive, GrlOpticalMediaSource *source) { GList *volumes, *i; GIcon *icon; if (g_drive_can_eject (drive) == FALSE || g_drive_has_media (drive) == FALSE) { return media_list; } /* Hack to avoid USB devices showing up * https://bugzilla.gnome.org/show_bug.cgi?id=679624 */ icon = g_drive_get_icon (drive); if (icon && G_IS_THEMED_ICON (icon)) { const gchar * const * names; names = g_themed_icon_get_names (G_THEMED_ICON (icon)); if (names && names[0] && !g_str_has_prefix (names[0], "drive-optical")) { g_object_unref (icon); return media_list; } } g_clear_object (&icon); /* Repeat for all the drive's volumes */ volumes = g_drive_get_volumes (drive); for (i = volumes; i != NULL; i = i->next) { GVolume *volume = i->data; media_list = add_volume (media_list, volume, drive, source); g_object_unref (volume); } g_list_free (volumes); return media_list; }
static void list_drives (GList *drives, int indent) { GList *volumes, *l; int c, i; GDrive *drive; char *name; char **ids; GIcon *icon; char *type_name; const gchar *sort_key; for (c = 0, l = drives; l != NULL; l = l->next, c++) { drive = (GDrive *) l->data; name = g_drive_get_name (drive); g_print ("%*sDrive(%d): %s\n", indent, "", c, name); g_free (name); type_name = get_type_name (drive); g_print ("%*sType: %s\n", indent+2, "", type_name); g_free (type_name); if (extra_detail) { GEnumValue *enum_value; gpointer klass; ids = g_drive_enumerate_identifiers (drive); if (ids && ids[0] != NULL) { g_print ("%*sids:\n", indent+2, ""); for (i = 0; ids[i] != NULL; i++) { char *id = g_drive_get_identifier (drive, ids[i]); g_print ("%*s %s: '%s'\n", indent+2, "", ids[i], id); g_free (id); } } g_strfreev (ids); icon = g_drive_get_icon (drive); if (icon) { if (G_IS_THEMED_ICON (icon)) show_themed_icon_names (G_THEMED_ICON (icon), indent + 2); g_object_unref (icon); } g_print ("%*sis_media_removable=%d\n", indent + 2, "", g_drive_is_media_removable (drive)); g_print ("%*shas_media=%d\n", indent + 2, "", g_drive_has_media (drive)); g_print ("%*sis_media_check_automatic=%d\n", indent + 2, "", g_drive_is_media_check_automatic (drive)); g_print ("%*scan_poll_for_media=%d\n", indent + 2, "", g_drive_can_poll_for_media (drive)); g_print ("%*scan_eject=%d\n", indent + 2, "", g_drive_can_eject (drive)); g_print ("%*scan_start=%d\n", indent + 2, "", g_drive_can_start (drive)); g_print ("%*scan_stop=%d\n", indent + 2, "", g_drive_can_stop (drive)); enum_value = NULL; klass = g_type_class_ref (G_TYPE_DRIVE_START_STOP_TYPE); if (klass != NULL) { enum_value = g_enum_get_value (klass, g_drive_get_start_stop_type (drive)); g_print ("%*sstart_stop_type=%s\n", indent + 2, "", enum_value != NULL ? enum_value->value_nick : "UNKNOWN"); g_type_class_unref (klass); } sort_key = g_drive_get_sort_key (drive); if (sort_key != NULL) g_print ("%*ssort_key=%s\n", indent + 2, "", sort_key); } volumes = g_drive_get_volumes (drive); list_volumes (volumes, indent + 2, FALSE); g_list_foreach (volumes, (GFunc)g_object_unref, NULL); g_list_free (volumes); } }