mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
Write docs.
2002-09-19 Alexander Larsson <alexl@redhat.com> * libnautilus-private/gnome-icon-lookup.c: * libnautilus-private/gnome-thumbnail-pixbuf-utils.c: * libnautilus-private/gnome-thumbnail.c: Write docs.
This commit is contained in:
parent
20124f6d1e
commit
8972c4bde2
4 changed files with 199 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
2002-09-19 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/gnome-icon-lookup.c:
|
||||
* libnautilus-private/gnome-thumbnail-pixbuf-utils.c:
|
||||
* libnautilus-private/gnome-thumbnail.c:
|
||||
Write docs.
|
||||
|
||||
2002-09-19 Alexander Larsson <alexl@redhat.com>
|
||||
|
||||
* libnautilus-private/nautilus-icon-factory.c (ICON_NAME_THUMBNAIL_LOADING):
|
||||
|
|
|
@ -187,7 +187,40 @@ mimetype_supported_by_gdk_pixbuf (const char *mime_type)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gnome_icon_lookup:
|
||||
* @icon_loader: a #GnomeIconLoader
|
||||
* @thumbnail_factory: an optional #GnomeThumbnailFactory used to look up thumbnails
|
||||
* @file_uri: the uri of the file
|
||||
* @custom_icon: optionally the name of a custom icon to try
|
||||
* @file_info: information about the file from gnome_vfs_get_file_info()
|
||||
* @mime_type: the mime type of the icon
|
||||
* @flags: flags that affect the result of the lookup
|
||||
* @result: optionally result flags of the lookups are stored here
|
||||
*
|
||||
* This function tries to locate an icon in @icon_loader that can be used
|
||||
* to represent the file passed. It can optionally also look for existing
|
||||
* thumbnails. It does no I/O, so the lookup should be relatively fast.
|
||||
*
|
||||
* If you don't know any information about the file already you can use
|
||||
* gnome_icon_lookup_sync() which gets this information using gnome-vfs.
|
||||
*
|
||||
* The following @flags are valid:
|
||||
*
|
||||
* GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT - Return the text icon for scripts.
|
||||
* This is useful if you do text embedding in the icons.
|
||||
*
|
||||
* GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES - Return the
|
||||
* filename of the filename itself for small images. Only availible if you
|
||||
* pass a thumbnail_factory.
|
||||
*
|
||||
* Possible @result flags:
|
||||
*
|
||||
* GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL - The returned file is a thumbnail.
|
||||
*
|
||||
* Return value: the name of an icon or an absolute filename of an image to
|
||||
* use for the file.
|
||||
**/
|
||||
char *
|
||||
gnome_icon_lookup (GnomeIconLoader *icon_loader,
|
||||
GnomeThumbnailFactory *thumbnail_factory,
|
||||
|
@ -266,6 +299,21 @@ gnome_icon_lookup (GnomeIconLoader *icon_loader,
|
|||
return g_strdup (ICON_NAME_REGULAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_icon_lookup:
|
||||
* @icon_loader: a #GnomeIconLoader
|
||||
* @thumbnail_factory: an optional #GnomeThumbnailFactory used to look up thumbnails
|
||||
* @file_uri: the uri of the file
|
||||
* @custom_icon: optionally the name of a custom icon to try
|
||||
* @flags: flags that affect the result of the lookup
|
||||
* @result: optionally result flags of the lookups are stored here
|
||||
*
|
||||
* This function tries to locate an icon in @icon_loader that can be used
|
||||
* to represent the file passed. See gnome_icon_lookup() for more information.
|
||||
*
|
||||
* Return value: the name of an icon or an absolute filename of an image to
|
||||
* use for the file.
|
||||
*/
|
||||
char *
|
||||
gnome_icon_lookup_sync (GnomeIconLoader *icon_loader,
|
||||
GnomeThumbnailFactory *thumbnail_factory,
|
||||
|
|
|
@ -38,6 +38,14 @@ GdkPixbuf * _gnome_thumbnail_load_scaled_jpeg (const char *uri,
|
|||
int target_height);
|
||||
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_load_pixbuf:
|
||||
* @uri: a uri
|
||||
*
|
||||
* Loads a pixbuf using gnome-vfs
|
||||
*
|
||||
* Return value: The loaded pixbuf or %NULL on failure
|
||||
**/
|
||||
GdkPixbuf *
|
||||
gnome_thumbnail_load_pixbuf (const char *uri)
|
||||
{
|
||||
|
@ -97,6 +105,18 @@ gnome_thumbnail_load_pixbuf (const char *uri)
|
|||
return pixbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_scale_down_pixbuf:
|
||||
* @pixbuf: a #GdkPixbuf
|
||||
* @dest_width: the desired new width
|
||||
* @dest_height: the desired new height
|
||||
*
|
||||
* Scales the pixbuf to the desired size. This function
|
||||
* is a lot faster than gdk-pixbuf when scaling down by
|
||||
* large amounts.
|
||||
*
|
||||
* Return value: a scaled pixbuf
|
||||
**/
|
||||
GdkPixbuf *
|
||||
gnome_thumbnail_scale_down_pixbuf (GdkPixbuf *pixbuf,
|
||||
int dest_width,
|
||||
|
|
|
@ -252,6 +252,14 @@ gnome_thumbnail_factory_class_init (GnomeThumbnailFactoryClass *class)
|
|||
gobject_class->finalize = gnome_thumbnail_factory_finalize;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_new:
|
||||
* @size: The thumbnail size to use
|
||||
*
|
||||
* Creates a new #GnomeThumbnailFactory.
|
||||
*
|
||||
* Return value: a new #GnomeThumbnailFactory
|
||||
**/
|
||||
GnomeThumbnailFactory *
|
||||
gnome_thumbnail_factory_new (GnomeThumbnailSize size)
|
||||
{
|
||||
|
@ -441,6 +449,18 @@ gnome_thumbnail_factory_ensure_failed_uptodate (GnomeThumbnailFactory *factory)
|
|||
g_free (path);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_lookup:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @uri: the uri of a file
|
||||
* @mtime: the mtime of the file
|
||||
*
|
||||
* Tries to locate an existing thumbnail for the file specified.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
*
|
||||
* Return value: The absolute path of the thumbnail, or %NULL if none exist
|
||||
**/
|
||||
char *
|
||||
gnome_thumbnail_factory_lookup (GnomeThumbnailFactory *factory,
|
||||
const char *uri,
|
||||
|
@ -502,6 +522,20 @@ gnome_thumbnail_factory_lookup (GnomeThumbnailFactory *factory,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_has_valid_failed_thumbnail:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @uri: the uri of a file
|
||||
* @mtime: the mtime of the file
|
||||
*
|
||||
* Tries to locate an failed thumbnail for the file specified. Writing
|
||||
* and looking for failed thumbnails is important to avoid to try to
|
||||
* thumbnail e.g. broken images several times.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
*
|
||||
* Return value: TRUE if there is a failed thumbnail for the file
|
||||
**/
|
||||
gboolean
|
||||
gnome_thumbnail_factory_has_valid_failed_thumbnail (GnomeThumbnailFactory *factory,
|
||||
const char *uri,
|
||||
|
@ -578,6 +612,20 @@ mimetype_supported_by_gdk_pixbuf (const char *mime_type)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_can_thumbnail:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @uri: the uri of a file
|
||||
* @mime_type: the mime type of the file
|
||||
* @mtime: the mtime of the file
|
||||
*
|
||||
* Returns TRUE if this GnomeIconFactory can (at least try) to thumbnail
|
||||
* this file. Thumbnails or files with failed thumbnails won't be thumbnailed.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
*
|
||||
* Return value: TRUE if the file can be thumbnailed
|
||||
**/
|
||||
gboolean
|
||||
gnome_thumbnail_factory_can_thumbnail (GnomeThumbnailFactory *factory,
|
||||
const char *uri,
|
||||
|
@ -590,7 +638,6 @@ gnome_thumbnail_factory_can_thumbnail (GnomeThumbnailFactory *factory,
|
|||
strstr (uri, "/.thumbnails/") != NULL)
|
||||
return FALSE;
|
||||
|
||||
/* TODO: Replace with generic system */
|
||||
if (mime_type != NULL &&
|
||||
(mimetype_supported_by_gdk_pixbuf (mime_type) ||
|
||||
g_hash_table_lookup (factory->priv->scripts_hash, mime_type)))
|
||||
|
@ -672,6 +719,19 @@ expand_thumbnailing_script (const char *script,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_generate_thumbnail:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @uri: the uri of a file
|
||||
* @mime_type: the mime type of the file
|
||||
*
|
||||
* Tries to generate a thumbnail for the specified file. If it succeeds
|
||||
* it returns a pixbuf that can be used as a thumbnail.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
*
|
||||
* Return value: thumbnail pixbuf if thumbnailing succeeded, %NULL otherwise
|
||||
**/
|
||||
GdkPixbuf *
|
||||
gnome_thumbnail_factory_generate_thumbnail (GnomeThumbnailFactory *factory,
|
||||
const char *uri,
|
||||
|
@ -829,6 +889,18 @@ make_thumbnail_fail_dirs (GnomeThumbnailFactory *factory)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_save_thumbnail:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @thumbnail: the thumbnail as a pixbuf
|
||||
* @uri: the uri of a file
|
||||
* @original_mtime: the mime type of the file
|
||||
*
|
||||
* Saves @thumbnail at the right place. If the save fails a
|
||||
* failed thumbnail is written.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
**/
|
||||
void
|
||||
gnome_thumbnail_factory_save_thumbnail (GnomeThumbnailFactory *factory,
|
||||
GdkPixbuf *thumbnail,
|
||||
|
@ -932,6 +1004,17 @@ gnome_thumbnail_factory_save_thumbnail (GnomeThumbnailFactory *factory,
|
|||
g_free (tmp_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_factory_create_failed_thumbnail:
|
||||
* @factory: a #GnomeThumbnailFactory
|
||||
* @uri: the uri of a file
|
||||
* @mtime: the mime type of the file
|
||||
*
|
||||
* Creates a failed thumbnail for the file so that we don't try
|
||||
* to re-thumbnail the file later.
|
||||
*
|
||||
* Usage of this function is threadsafe.
|
||||
**/
|
||||
void
|
||||
gnome_thumbnail_factory_create_failed_thumbnail (GnomeThumbnailFactory *factory,
|
||||
const char *uri,
|
||||
|
@ -1028,6 +1111,15 @@ gnome_thumbnail_factory_create_failed_thumbnail (GnomeThumbnailFactory *factory,
|
|||
g_free (tmp_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_md5:
|
||||
* @uri: an uri
|
||||
*
|
||||
* Calculates the MD5 checksum of the uri. This can be useful
|
||||
* if you want to manually handle thumbnail files.
|
||||
*
|
||||
* Return value: A string with the MD5 digest of the uri string.
|
||||
**/
|
||||
char *
|
||||
gnome_thumbnail_md5 (const char *uri)
|
||||
{
|
||||
|
@ -1037,6 +1129,15 @@ gnome_thumbnail_md5 (const char *uri)
|
|||
return thumb_digest_to_ascii (digest);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_path_for_uri:
|
||||
* @uri: an uri
|
||||
* @size: a thumbnail size
|
||||
*
|
||||
* Returns the filename that a thumbnail of size @size for @uri would have.
|
||||
*
|
||||
* Return value: an absolute filename
|
||||
**/
|
||||
char *
|
||||
gnome_thumbnail_path_for_uri (const char *uri,
|
||||
GnomeThumbnailSize size)
|
||||
|
@ -1060,6 +1161,16 @@ gnome_thumbnail_path_for_uri (const char *uri,
|
|||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_has_uri:
|
||||
* @pixbuf: an loaded thumbnail pixbuf
|
||||
* @uri: a uri
|
||||
*
|
||||
* Returns whether the thumbnail has the correct uri embedded in the
|
||||
* Thumb::URI option in the png.
|
||||
*
|
||||
* Return value: TRUE if the thumbnail is for @uri
|
||||
**/
|
||||
gboolean
|
||||
gnome_thumbnail_has_uri (GdkPixbuf *pixbuf,
|
||||
const char *uri)
|
||||
|
@ -1070,6 +1181,17 @@ gnome_thumbnail_has_uri (GdkPixbuf *pixbuf,
|
|||
return strcmp (uri, thumb_uri) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_thumbnail_is_valid:
|
||||
* @pixbuf: an loaded thumbnail #GdkPixbuf
|
||||
* @uri: a uri
|
||||
* @mtime: the mtime
|
||||
*
|
||||
* Returns whether the thumbnail has the correct uri and mtime embedded in the
|
||||
* png options.
|
||||
*
|
||||
* Return value: TRUE if the thumbnail has the right @uri and @mtime
|
||||
**/
|
||||
gboolean
|
||||
gnome_thumbnail_is_valid (GdkPixbuf *pixbuf,
|
||||
const char *uri,
|
||||
|
|
Loading…
Reference in a new issue