Пример #1
0
static void
eject (GFile *file)
{
  GMount *mount;
  GError *error = NULL;
  GMountOperation *mount_op;
  GMountUnmountFlags flags;

  if (file == NULL)
    return;

  mount = g_file_find_enclosing_mount (file, NULL, &error);
  if (mount == NULL)
    {
      print_file_error (file, error->message);
      success = FALSE;
      g_error_free (error);
      return;
    }

  mount_op = new_mount_op ();
  flags = force ? G_MOUNT_UNMOUNT_FORCE : G_MOUNT_UNMOUNT_NONE;
  g_mount_eject_with_operation (mount, flags, mount_op, NULL, eject_done_cb, g_object_ref (file));
  g_object_unref (mount_op);

  outstanding_mounts++;
}
Пример #2
0
static void
unmount (GFile *file)
{
  GMount *mount;
  GError *error = NULL;
  GMountOperation *mount_op;
  GMountUnmountFlags flags;

  if (file == NULL)
    return;

  mount = g_file_find_enclosing_mount (file, NULL, &error);
  if (mount == NULL)
    {
      g_printerr (_("Error finding enclosing mount: %s\n"), error->message);
      success = FALSE;
      return;
    }

  mount_op = new_mount_op ();
  flags = force ? G_MOUNT_UNMOUNT_FORCE : G_MOUNT_UNMOUNT_NONE;
  g_mount_unmount_with_operation (mount, flags, mount_op, NULL, unmount_done_cb, NULL);
  g_object_unref (mount_op);

  outstanding_mounts++;
}
Пример #3
0
static void
mount (GFile *file)
{
  GMountOperation *op;

  if (file == NULL)
    return;

  op = new_mount_op ();

  if (mount_mountable)
    g_file_mount_mountable (file, 0, op, NULL, mount_mountable_done_cb, op);
  else
    g_file_mount_enclosing_volume (file, 0, op, NULL, mount_done_cb, op);

  outstanding_mounts++;
}
Пример #4
0
static void
mount_with_device_file (const char *device_file)
{
  GVolumeMonitor *volume_monitor;
  GList *volumes;
  GList *l;

  volume_monitor = g_volume_monitor_get();

  volumes = g_volume_monitor_get_volumes (volume_monitor);
  for (l = volumes; l != NULL; l = l->next)
    {
      GVolume *volume = G_VOLUME (l->data);
      gchar *id;

      id = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
      if (g_strcmp0 (id, device_file) == 0)
        {
          GMountOperation *op;

          op = new_mount_op ();

          g_volume_mount (volume,
                          G_MOUNT_MOUNT_NONE,
                          op,
                          NULL,
                          mount_with_device_file_cb,
                          id);

          outstanding_mounts++;
        }
      else
        g_free (id);
    }
  g_list_free_full (volumes, g_object_unref);

  if (outstanding_mounts == 0)
    {
      print_error ("%s: %s", device_file, _("No volume for device file"));
      success = FALSE;
    }

  g_object_unref (volume_monitor);
}
Пример #5
0
static void
mount_with_device_file (const char *device_file)
{
  GVolumeMonitor *volume_monitor;
  GList *volumes;
  GList *l;

  volume_monitor = g_volume_monitor_get();

  volumes = g_volume_monitor_get_volumes (volume_monitor);
  for (l = volumes; l != NULL; l = l->next)
    {
      GVolume *volume = G_VOLUME (l->data);

      if (g_strcmp0 (g_volume_get_identifier (volume,
                                              G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE), device_file) == 0)
        {
          GMountOperation *op;

          op = new_mount_op ();

          g_volume_mount (volume,
                          G_MOUNT_MOUNT_NONE,
                          op,
                          NULL,
                          mount_with_device_file_cb,
                          op);

          outstanding_mounts++;
        }
    }
  g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
  g_list_free (volumes);

  if (outstanding_mounts == 0)
    {
      g_print (_("No volume for device file %s\n"), device_file);
      return;
    }

  g_object_unref (volume_monitor);
}
Пример #6
0
static void
eject (GFile *file)
{
  GMount *mount;
  GError *error = NULL;
  GMountOperation *mount_op;

  if (file == NULL)
    return;

  mount = g_file_find_enclosing_mount (file, NULL, &error);
  if (mount == NULL)
    {
      g_printerr (_("Error finding enclosing mount: %s\n"), error->message);
      return;
    }

  mount_op = new_mount_op ();
  g_mount_eject_with_operation (mount, 0, mount_op, NULL, eject_done_cb, NULL);
  g_object_unref (mount_op);

  outstanding_mounts++;
}