Exemple #1
0
static PyObject *
_wrap_gimp_thumbnail_peek_image(PyGObject *self)
{
    gint ret;

    
    ret = gimp_thumbnail_peek_image(GIMP_THUMBNAIL(self->obj));
    
    return pyg_enum_from_gtype(GIMP_TYPE_THUMB_STATE, ret);
}
Exemple #2
0
/**
 * gimp_thumbnail_has_failed:
 * @thumbnail: a #GimpThumbnail object
 *
 * Checks if a valid failure thumbnail for the given thumbnail exists
 * in the global thumbnail repository. This may be the case even if
 * gimp_thumbnail_peek_thumb() doesn't return %GIMP_THUMB_STATE_FAILED
 * since there might be a real thumbnail and a failure thumbnail for
 * the same image file.
 *
 * The application should not attempt to create the thumbnail if a
 * valid failure thumbnail exists.
 *
 * Return value: %TRUE if a failure thumbnail exists or
 *
 * Since: 2.2
 **/
gboolean
gimp_thumbnail_has_failed (GimpThumbnail *thumbnail)
{
  GdkPixbuf   *pixbuf;
  const gchar *option;
  gchar       *filename;
  gint64       image_mtime;
  gint64       image_size;
  gboolean     failed = FALSE;

  g_return_val_if_fail (GIMP_IS_THUMBNAIL (thumbnail), FALSE);
  g_return_val_if_fail (thumbnail->image_uri != NULL, FALSE);

  GIMP_THUMB_DEBUG_CALL (thumbnail);

  filename = gimp_thumb_name_from_uri (thumbnail->image_uri,
                                       GIMP_THUMB_SIZE_FAIL);
  if (! filename)
    return FALSE;

  pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
  g_free (filename);

  if (! pixbuf)
    return FALSE;

  if (gimp_thumbnail_peek_image (thumbnail) < GIMP_THUMB_STATE_EXISTS)
    goto finish;

  /* URI and mtime from the thumbnail need to match our file */
  option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_URI);
  if (! option || strcmp (option, thumbnail->image_uri))
    goto finish;

  option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_MTIME);
  if (!option || sscanf (option, "%" G_GINT64_FORMAT, &image_mtime) != 1)
    goto finish;

  option = gdk_pixbuf_get_option (pixbuf, TAG_THUMB_FILESIZE);
  if (option && sscanf (option, "%" G_GINT64_FORMAT, &image_size) != 1)
    goto finish;

  /* TAG_THUMB_FILESIZE is optional but must match if present */
  if (image_mtime == thumbnail->image_mtime &&
      (option == NULL || image_size == thumbnail->image_filesize))
    {
      failed = TRUE;
    }

 finish:
  g_object_unref (pixbuf);

  return failed;
}
static void
documents_remove_dangling_foreach (GimpImagefile *imagefile,
                                   GimpContainer *container)
{
  GimpThumbnail *thumbnail = gimp_imagefile_get_thumbnail (imagefile);

  if (gimp_thumbnail_peek_image (thumbnail) == GIMP_THUMB_STATE_NOT_FOUND)
    {
      const gchar *uri = gimp_object_get_name (imagefile);

      gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri,
                                      NULL);

      gimp_container_remove (container, GIMP_OBJECT (imagefile));
    }
}
static void
process_thumbnail (const gchar *filename)
{
  GimpThumbnail *thumbnail;
  GError        *error = NULL;

  thumbnail = gimp_thumbnail_new ();

  if (! gimp_thumbnail_set_from_thumb (thumbnail, filename, &error))
    {
      if (option_state == STATE_ERROR)
        {
          if (option_verbose)
            g_print ("%s '%s'\n", filename, error->message);
          else
            g_print ("%s\n", filename);
        }

      g_clear_error (&error);
    }
  else
    {
      GimpThumbState state = gimp_thumbnail_peek_image (thumbnail);

      if ((option_state == STATE_NONE || state == option_state)

          &&

          (option_path == NULL ||
           strstr (thumbnail->image_uri, option_path)))
        {
          if (option_verbose)
            g_print ("%s '%s'\n", filename, thumbnail->image_uri);
          else
            g_print ("%s\n", filename);
        }

#if 0
      switch (foo)
        {
        case GIMP_THUMB_STATE_REMOTE:
          g_print ("%s Remote image '%s'\n", filename, thumbnail->image_uri);
          break;

        case GIMP_THUMB_STATE_FOLDER:
          g_print ("%s Folder '%s'\n", filename, thumbnail->image_uri);
          break;

        case GIMP_THUMB_STATE_SPECIAL:
          g_print ("%s Special file '%s'\n", filename, thumbnail->image_uri);
          break;

        case GIMP_THUMB_STATE_NOT_FOUND:
          g_print ("%s Image not found '%s'\n", filename, thumbnail->image_uri);
          break;

        case GIMP_THUMB_STATE_OLD:
          g_print ("%s Thumbnail old '%s'\n", filename, thumbnail->image_uri);
          break;

        case GIMP_THUMB_STATE_FAILED:
          g_print ("%s EEEEEEEEK '%s'\n", filename, thumbnail->image_uri);
          break;

        default:
          g_print ("%s '%s'\n", filename, thumbnail->image_uri);
          break;
        }
#endif
    }

  g_object_unref (thumbnail);
}