Exemplo n.º 1
1
static void
brasero_medium_selection_update_no_disc_entry (BraseroMediumSelection *self,
        GtkTreeModel *model,
        GtkTreeIter *iter)
{
    BraseroMediumMonitor *monitor;
    GIcon *icon;

    monitor = brasero_medium_monitor_get_default ();
    if (brasero_medium_monitor_is_probing (monitor)) {
        icon = g_themed_icon_new_with_default_fallbacks ("image-loading");
        gtk_list_store_set (GTK_LIST_STORE (model), iter,
                            NAME_COL, _("Searching for available discs"),
                            ICON_COL, icon,
                            VISIBLE_TEXT_COL, TRUE,
                            VISIBLE_PROGRESS_COL, FALSE,
                            -1);
    }
    else {
        icon = g_themed_icon_new_with_default_fallbacks ("drive-optical");
        gtk_list_store_set (GTK_LIST_STORE (model), iter,
                            NAME_COL, _("No disc available"),
                            ICON_COL, icon,
                            VISIBLE_TEXT_COL, TRUE,
                            VISIBLE_PROGRESS_COL, FALSE,
                            -1);
    }

    g_object_unref (icon);
    g_object_unref (monitor);

    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), iter);
    brasero_medium_selection_set_current_medium (self, iter);
}
Exemplo n.º 2
0
gboolean
sj_metadata_helper_check_media (const char *cdrom, GError **error)
{
#ifndef USE_TOTEM_PL_PARSER
  BraseroMediumMonitor *monitor;
  BraseroMedium *medium;
  BraseroDrive *drive;


  /* This initialize the library if it isn't done yet */
  monitor = brasero_medium_monitor_get_default ();
  if (brasero_medium_monitor_is_probing (monitor)) {
      /* FIXME: would be nicer to only check if "cdrom" is being probed,
       * but libbrasero doesn't seem to have an API for that
       */
      g_set_error (error, SJ_ERROR, SJ_ERROR_CD_BUSY, _("Cannot read CD: %s"),
                   _("Devices haven't been all probed yet"));
      return FALSE;
  }
  drive = brasero_medium_monitor_get_drive (monitor, cdrom);
  if (drive == NULL) {
    return FALSE;
  }

  medium = brasero_drive_get_medium (drive);
  g_object_unref (drive);

  if (!medium || !BRASERO_MEDIUM_VALID (brasero_medium_get_status (medium))) {
    char *msg;
    SjError err;

    if (access (cdrom, W_OK) == 0) {
      msg = g_strdup_printf (_("Device '%s' does not contain any media"), cdrom);
      err = SJ_ERROR_CD_NO_MEDIA;
    } else {
      msg = g_strdup_printf (_("Device '%s' could not be opened. Check the access permissions on the device."), cdrom);
      err = SJ_ERROR_CD_PERMISSION_ERROR;
    }
    g_set_error (error, SJ_ERROR, err, _("Cannot read CD: %s"), msg);
    g_free (msg);

    return FALSE;
  }
#else
  GError *totem_error = NULL;

  totem_cd_detect_type (cdrom, &totem_error);

  if (totem_error != NULL) {
    g_set_error (error, SJ_ERROR, SJ_ERROR_CD_NO_MEDIA, _("Cannot read CD: %s"), totem_error->message);
    g_error_free (totem_error);

    return FALSE;
  }
#endif /* !USE_TOTEM_PL_PARSER */

  return TRUE;
}