Exemplo n.º 1
0
static gboolean
drive_is_cd_device (GDrive *gdrive)
{
        BraseroMediumMonitor *monitor;
        BraseroDrive         *drive;
        gchar                *device;

        device = g_drive_get_identifier (gdrive, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
        if (!device)
                return FALSE;

        DEBUG_PRINT ("Got device: %s\n", device);

	/* FIXME: since we call the monitor, the library should be initialized.
	 * To avoid all the initializing we'll be able to use the new GIO API
	 * (#594649 -  Have a way to detect optical drives) */
	ensure_initialized();

	monitor = brasero_medium_monitor_get_default ();
        drive = brasero_medium_monitor_get_drive (monitor, device);
        g_object_unref (monitor);
        g_free (device);

        if (drive == NULL)
                return FALSE;
        
        g_object_unref (drive);
        return TRUE;
}
Exemplo n.º 2
0
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);
    }
}
Exemplo n.º 3
0
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);
    }
}
Exemplo n.º 4
0
static void
test_disc (gconstpointer data)
{
	TotemDiscMediaType type;
	GError *error = NULL;
	char *mrl = NULL;
	const char *device = (const char*) data;

	type = totem_cd_detect_type_with_url (device, &mrl, &error);

	if (type == MEDIA_TYPE_ERROR) {
		GList *or, *list;
		GVolumeMonitor *mon;

		g_message ("Error getting media type: %s", error ? error->message : "unknown reason");
		g_message ("List of connected drives:");

		mon = g_volume_monitor_get ();
		for (or = list = g_volume_monitor_get_connected_drives (mon); list != NULL; list = list->next) {
			char *device_id;
			device_id = g_drive_get_identifier ((GDrive *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
			g_message ("\t%s", device_id);
			g_free (device_id);
			g_object_unref (list->data);
		}
		if (or == NULL)
			g_message ("\tNo connected drives!");
		else
			g_list_free (or);

		g_message ("List of volumes:");
		for (or = list = g_volume_monitor_get_volumes (mon); list != NULL; list = list->next) {
			char *device_id;

			device_id = g_volume_get_identifier ((GVolume *) list->data, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
			if (g_volume_get_mount ((GVolume *) list->data) == NULL)
				g_message ("\t%s", device_id);
			else
				g_message ("\t%s (mounted)", device_id);
			g_free (device_id);
			g_object_unref (list->data);
		}

		if (or == NULL)
			g_message ("\tNo volumes!");
		else
			g_list_free (or);

		return;
	}

	if (type != MEDIA_TYPE_DATA)
		g_message ("%s contains a %s.", device, totem_cd_get_human_readable_name (type));
	else
		g_message ("%s contains a data disc", device);
	g_assert (mrl != NULL);
	g_message ("MRL for directory is \"%s\".", mrl);

	g_free (mrl);

	return;
}