|
mate-desktop 1.29.2
Library with common API for various MATE modules
|
#include <config.h>#include <glib.h>#include <glib/gstdio.h>#include <gdk-pixbuf/gdk-pixbuf.h>#include <string.h>#include <stdlib.h>#include "mate-desktop-thumbnail.h"Data Structures | |
| struct | _MateDesktopThumbnailFactoryPrivate |
Macros | |
| #define | MATE_DESKTOP_USE_UNSTABLE_API |
| #define | parent_class mate_desktop_thumbnail_factory_parent_class |
| #define | THUMBNAILER_ENTRY_GROUP "Thumbnailer Entry" |
| #define | THUMBNAILER_EXTENSION ".thumbnailer" |
Functions | |
| static void | thumbnailers_directory_changed (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, MateDesktopThumbnailFactory *factory) |
| G_DEFINE_TYPE_WITH_PRIVATE (MateDesktopThumbnailFactory, mate_desktop_thumbnail_factory, G_TYPE_OBJECT) | |
| static Thumbnailer * | thumbnailer_ref (Thumbnailer *thumb) |
| static void | thumbnailer_unref (Thumbnailer *thumb) |
| static Thumbnailer * | thumbnailer_load (Thumbnailer *thumb) |
| static Thumbnailer * | thumbnailer_reload (Thumbnailer *thumb) |
| static Thumbnailer * | thumbnailer_new (const gchar *path) |
| static gboolean | thumbnailer_try_exec (Thumbnailer *thumb) |
| static gpointer | init_thumbnailers_dirs (gpointer data) |
| static const gchar *const * | get_thumbnailers_dirs (void) |
| static void | mate_desktop_thumbnail_factory_register_mime_types (MateDesktopThumbnailFactory *factory, Thumbnailer *thumb) |
| static void | mate_desktop_thumbnail_factory_add_thumbnailer (MateDesktopThumbnailFactory *factory, Thumbnailer *thumb) |
| static gboolean | mate_desktop_thumbnail_factory_is_disabled (MateDesktopThumbnailFactory *factory, const gchar *mime_type) |
| static gboolean | remove_thumbnailer_from_mime_type_map (gchar *key, Thumbnailer *value, gchar *path) |
| static void | update_or_create_thumbnailer (MateDesktopThumbnailFactory *factory, const gchar *path) |
| static void | remove_thumbnailer (MateDesktopThumbnailFactory *factory, const gchar *path) |
| static void | remove_thumbnailers_for_dir (MateDesktopThumbnailFactory *factory, const gchar *thumbnailer_dir, GFileMonitor *monitor) |
| static void | mate_desktop_thumbnail_factory_load_thumbnailers_for_dir (MateDesktopThumbnailFactory *factory, const gchar *path) |
| static void | mate_desktop_thumbnail_factory_load_thumbnailers (MateDesktopThumbnailFactory *factory) |
| static void | external_thumbnailers_disabled_all_changed_cb (GSettings *settings, const gchar *key, MateDesktopThumbnailFactory *factory) |
| static void | external_thumbnailers_disabled_changed_cb (GSettings *settings, const gchar *key, MateDesktopThumbnailFactory *factory) |
| static void | mate_desktop_thumbnail_factory_init (MateDesktopThumbnailFactory *factory) |
| static void | mate_desktop_thumbnail_factory_finalize (GObject *object) |
| static void | mate_desktop_thumbnail_factory_class_init (MateDesktopThumbnailFactoryClass *class) |
| MateDesktopThumbnailFactory * | mate_desktop_thumbnail_factory_new (MateDesktopThumbnailSize size) |
| mate_desktop_thumbnail_factory_new: @size: The thumbnail size to use | |
| static char * | thumbnail_filename (const char *uri) |
| static char * | thumbnail_path (const char *uri, MateDesktopThumbnailSize size) |
| static char * | thumbnail_failed_path (const char *uri) |
| static char * | validate_thumbnail_path (char *path, const char *uri, time_t mtime, MateDesktopThumbnailSize size) |
| static char * | lookup_thumbnail_path (const char *uri, time_t mtime, MateDesktopThumbnailSize size) |
| static char * | lookup_failed_thumbnail_path (const char *uri, time_t mtime, MateDesktopThumbnailSize size) |
| char * | mate_desktop_thumbnail_factory_lookup (MateDesktopThumbnailFactory *factory, const char *uri, time_t mtime) |
| mate_desktop_thumbnail_factory_lookup: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mtime: the mtime of the file | |
| gboolean | mate_desktop_thumbnail_factory_has_valid_failed_thumbnail (MateDesktopThumbnailFactory *factory, const char *uri, time_t mtime) |
| mate_desktop_thumbnail_factory_has_valid_failed_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mtime: the mtime of the file | |
| gboolean | mate_desktop_thumbnail_factory_can_thumbnail (MateDesktopThumbnailFactory *factory, const char *uri, const char *mime_type, time_t mtime) |
| mate_desktop_thumbnail_factory_can_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mime_type: the mime type of the file @mtime: the mtime of the file | |
| static char * | expand_thumbnailing_elem (const char *elem, const int size, const char *inuri, const char *outfile, gboolean *got_input, gboolean *got_output) |
| static char ** | expand_thumbnailing_script (const char *script, const int size, const char *inuri, const char *outfile, GError **error) |
| static GdkPixbuf * | get_preview_thumbnail (const char *uri, int size) |
| GdkPixbuf * | mate_desktop_thumbnail_factory_generate_thumbnail (MateDesktopThumbnailFactory *factory, const char *uri, const char *mime_type) |
| mate_desktop_thumbnail_factory_generate_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mime_type: the mime type of the file | |
| static gboolean | save_thumbnail (GdkPixbuf *pixbuf, char *path, const char *uri, time_t mtime) |
| static GdkPixbuf * | make_failed_thumbnail (void) |
| void | mate_desktop_thumbnail_factory_save_thumbnail (MateDesktopThumbnailFactory *factory, GdkPixbuf *thumbnail, const char *uri, time_t original_mtime) |
| mate_desktop_thumbnail_factory_save_thumbnail: @factory: a MateDesktopThumbnailFactory @thumbnail: the thumbnail as a pixbuf @uri: the uri of a file @original_mtime: the modification time of the original file | |
| void | mate_desktop_thumbnail_factory_create_failed_thumbnail (MateDesktopThumbnailFactory *factory, const char *uri, time_t mtime) |
| mate_desktop_thumbnail_factory_create_failed_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mtime: the modification time of the file | |
| char * | mate_desktop_thumbnail_path_for_uri (const char *uri, MateDesktopThumbnailSize size) |
| mate_desktop_thumbnail_path_for_uri: @uri: an uri @size: a thumbnail size | |
| gboolean | mate_desktop_thumbnail_has_uri (GdkPixbuf *pixbuf, const char *uri) |
| mate_desktop_thumbnail_has_uri: @pixbuf: an loaded thumbnail pixbuf @uri: a uri | |
| gboolean | mate_desktop_thumbnail_is_valid (GdkPixbuf *pixbuf, const char *uri, time_t mtime) |
| mate_desktop_thumbnail_is_valid: @pixbuf: an loaded thumbnail #GdkPixbuf @uri: a uri @mtime: the mtime | |
Variables | |
| static const char * | appname = "mate-thumbnail-factory" |
| Thumbnailer | |
| #define MATE_DESKTOP_USE_UNSTABLE_API |
| #define parent_class mate_desktop_thumbnail_factory_parent_class |
| #define THUMBNAILER_ENTRY_GROUP "Thumbnailer Entry" |
| #define THUMBNAILER_EXTENSION ".thumbnailer" |
|
static |
Referenced by expand_thumbnailing_script().
|
static |
References expand_thumbnailing_elem().
Referenced by mate_desktop_thumbnail_factory_generate_thumbnail().
|
static |
References _MateDesktopThumbnailFactoryPrivate::disabled, _MateDesktopThumbnailFactoryPrivate::disabled_types, _MateDesktopThumbnailFactoryPrivate::lock, mate_desktop_thumbnail_factory_load_thumbnailers(), _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::settings.
Referenced by mate_desktop_thumbnail_factory_finalize(), and mate_desktop_thumbnail_factory_init().
|
static |
References _MateDesktopThumbnailFactoryPrivate::disabled, _MateDesktopThumbnailFactoryPrivate::disabled_types, _MateDesktopThumbnailFactoryPrivate::lock, _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::settings.
Referenced by mate_desktop_thumbnail_factory_finalize(), and mate_desktop_thumbnail_factory_init().
| G_DEFINE_TYPE_WITH_PRIVATE | ( | MateDesktopThumbnailFactory | , |
| mate_desktop_thumbnail_factory | , | ||
| G_TYPE_OBJECT | |||
| ) |
|
static |
Referenced by mate_desktop_thumbnail_factory_generate_thumbnail().
|
static |
References init_thumbnailers_dirs().
Referenced by mate_desktop_thumbnail_factory_load_thumbnailers().
|
static |
Referenced by get_thumbnailers_dirs().
|
static |
References thumbnail_failed_path(), and validate_thumbnail_path().
Referenced by mate_desktop_thumbnail_factory_has_valid_failed_thumbnail().
|
static |
References thumbnail_path(), and validate_thumbnail_path().
Referenced by mate_desktop_thumbnail_factory_lookup().
|
static |
|
static |
References mate_desktop_thumbnail_factory_register_mime_types(), _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::thumbnailers.
Referenced by mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), and update_or_create_thumbnailer().
| gboolean mate_desktop_thumbnail_factory_can_thumbnail | ( | MateDesktopThumbnailFactory * | factory, |
| const char * | uri, | ||
| const char * | mime_type, | ||
| time_t | mtime | ||
| ) |
mate_desktop_thumbnail_factory_can_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mime_type: the mime type of the file @mtime: the mtime of the file
Returns TRUE if this MateDesktopThumbnailFactory 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.
Since: 2.2
References _MateDesktopThumbnailFactoryPrivate::lock, mate_desktop_thumbnail_factory_has_valid_failed_thumbnail(), mate_desktop_thumbnail_factory_is_disabled(), _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, Thumbnailer, and thumbnailer_try_exec().
|
static |
| void mate_desktop_thumbnail_factory_create_failed_thumbnail | ( | MateDesktopThumbnailFactory * | factory, |
| const char * | uri, | ||
| time_t | mtime | ||
| ) |
mate_desktop_thumbnail_factory_create_failed_thumbnail: @factory: a MateDesktopThumbnailFactory @uri: the uri of a file @mtime: the modification time 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.
Since: 2.2
References make_failed_thumbnail(), save_thumbnail(), and thumbnail_failed_path().
Referenced by create_thumbnail_for_filename().
|
static |
References _MateDesktopThumbnailFactoryPrivate::disabled_types, external_thumbnailers_disabled_all_changed_cb(), external_thumbnailers_disabled_changed_cb(), _MateDesktopThumbnailFactoryPrivate::lock, MATE_DESKTOP_THUMBNAIL_FACTORY, _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactoryPrivate::monitors, parent_class, _MateDesktopThumbnailFactory::priv, _MateDesktopThumbnailFactoryPrivate::settings, thumbnailer_unref(), and _MateDesktopThumbnailFactoryPrivate::thumbnailers.
Referenced by mate_desktop_thumbnail_factory_class_init().
| GdkPixbuf * mate_desktop_thumbnail_factory_generate_thumbnail | ( | MateDesktopThumbnailFactory * | factory, |
| const char * | uri, | ||
| const char * | mime_type | ||
| ) |
mate_desktop_thumbnail_factory_generate_thumbnail: @factory: a MateDesktopThumbnailFactory @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: (transfer full): thumbnail pixbuf if thumbnailing succeeded, NULL otherwise.
Since: 2.2
References expand_thumbnailing_script(), get_preview_thumbnail(), _MateDesktopThumbnailFactoryPrivate::lock, mate_desktop_thumbnail_factory_is_disabled(), MATE_DESKTOP_THUMBNAIL_SIZE_LARGE, _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, _MateDesktopThumbnailFactoryPrivate::size, and Thumbnailer.
Referenced by main().
| gboolean mate_desktop_thumbnail_factory_has_valid_failed_thumbnail | ( | MateDesktopThumbnailFactory * | factory, |
| const char * | uri, | ||
| time_t | mtime | ||
| ) |
mate_desktop_thumbnail_factory_has_valid_failed_thumbnail: @factory: a MateDesktopThumbnailFactory @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.
Since: 2.2
References lookup_failed_thumbnail_path(), _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::size.
Referenced by mate_desktop_thumbnail_factory_can_thumbnail().
|
static |
References _MateDesktopThumbnailFactoryPrivate::disabled, _MateDesktopThumbnailFactoryPrivate::disabled_types, external_thumbnailers_disabled_all_changed_cb(), external_thumbnailers_disabled_changed_cb(), _MateDesktopThumbnailFactoryPrivate::lock, mate_desktop_thumbnail_factory_load_thumbnailers(), MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL, _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, _MateDesktopThumbnailFactoryPrivate::settings, _MateDesktopThumbnailFactoryPrivate::size, and thumbnailer_unref().
|
static |
|
static |
References get_thumbnailers_dirs(), _MateDesktopThumbnailFactoryPrivate::loaded, mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), and _MateDesktopThumbnailFactory::priv.
Referenced by external_thumbnailers_disabled_all_changed_cb(), and mate_desktop_thumbnail_factory_init().
|
static |
References mate_desktop_thumbnail_factory_add_thumbnailer(), _MateDesktopThumbnailFactoryPrivate::monitors, _MateDesktopThumbnailFactory::priv, Thumbnailer, THUMBNAILER_EXTENSION, thumbnailer_new(), and thumbnailers_directory_changed().
Referenced by mate_desktop_thumbnail_factory_load_thumbnailers(), and thumbnailers_directory_changed().
| char * mate_desktop_thumbnail_factory_lookup | ( | MateDesktopThumbnailFactory * | factory, |
| const char * | uri, | ||
| time_t | mtime | ||
| ) |
mate_desktop_thumbnail_factory_lookup: @factory: a MateDesktopThumbnailFactory @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: (transfer full): The absolute path of the thumbnail, or NULL if none exist.
Since: 2.2
References lookup_thumbnail_path(), _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::size.
Referenced by create_thumbnail_for_filename().
| MateDesktopThumbnailFactory * mate_desktop_thumbnail_factory_new | ( | MateDesktopThumbnailSize | size | ) |
mate_desktop_thumbnail_factory_new: @size: The thumbnail size to use
Creates a new MateDesktopThumbnailFactory.
This function must be called on the main thread.
Return value: a new MateDesktopThumbnailFactory
Since: 2.2
References MATE_DESKTOP_TYPE_THUMBNAIL_FACTORY, _MateDesktopThumbnailFactory::priv, and _MateDesktopThumbnailFactoryPrivate::size.
Referenced by main().
|
static |
References _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, and thumbnailer_ref().
Referenced by mate_desktop_thumbnail_factory_add_thumbnailer(), and update_or_create_thumbnailer().
| void mate_desktop_thumbnail_factory_save_thumbnail | ( | MateDesktopThumbnailFactory * | factory, |
| GdkPixbuf * | thumbnail, | ||
| const char * | uri, | ||
| time_t | original_mtime | ||
| ) |
mate_desktop_thumbnail_factory_save_thumbnail: @factory: a MateDesktopThumbnailFactory @thumbnail: the thumbnail as a pixbuf @uri: the uri of a file @original_mtime: the modification time of the original file
Saves @thumbnail at the right place. If the save fails a failed thumbnail is written.
Usage of this function is threadsafe.
Since: 2.2
References make_failed_thumbnail(), _MateDesktopThumbnailFactory::priv, save_thumbnail(), _MateDesktopThumbnailFactoryPrivate::size, thumbnail_failed_path(), and thumbnail_path().
Referenced by create_thumbnail_for_filename().
| gboolean mate_desktop_thumbnail_has_uri | ( | GdkPixbuf * | pixbuf, |
| const char * | uri | ||
| ) |
mate_desktop_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
Since: 2.2
| gboolean mate_desktop_thumbnail_is_valid | ( | GdkPixbuf * | pixbuf, |
| const char * | uri, | ||
| time_t | mtime | ||
| ) |
mate_desktop_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
Since: 2.2
Referenced by validate_thumbnail_path().
| char * mate_desktop_thumbnail_path_for_uri | ( | const char * | uri, |
| MateDesktopThumbnailSize | size | ||
| ) |
mate_desktop_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
Since: 2.2
References thumbnail_path().
|
static |
References _MateDesktopThumbnailFactoryPrivate::lock, _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, remove_thumbnailer_from_mime_type_map(), Thumbnailer, thumbnailer_unref(), and _MateDesktopThumbnailFactoryPrivate::thumbnailers.
Referenced by thumbnailers_directory_changed().
|
static |
Referenced by remove_thumbnailer(), remove_thumbnailers_for_dir(), and update_or_create_thumbnailer().
|
static |
References _MateDesktopThumbnailFactoryPrivate::lock, _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactoryPrivate::monitors, _MateDesktopThumbnailFactory::priv, remove_thumbnailer_from_mime_type_map(), Thumbnailer, thumbnailer_unref(), _MateDesktopThumbnailFactoryPrivate::thumbnailers, and thumbnailers_directory_changed().
Referenced by thumbnailers_directory_changed().
|
static |
|
static |
References appname, and thumbnail_filename().
Referenced by lookup_failed_thumbnail_path(), mate_desktop_thumbnail_factory_create_failed_thumbnail(), and mate_desktop_thumbnail_factory_save_thumbnail().
|
static |
Referenced by thumbnail_failed_path(), and thumbnail_path().
|
static |
References MATE_DESKTOP_THUMBNAIL_SIZE_LARGE, and thumbnail_filename().
Referenced by lookup_thumbnail_path(), mate_desktop_thumbnail_factory_save_thumbnail(), and mate_desktop_thumbnail_path_for_uri().
|
static |
References THUMBNAILER_ENTRY_GROUP, and thumbnailer_unref().
Referenced by thumbnailer_new(), and thumbnailer_reload().
|
static |
References Thumbnailer, and thumbnailer_load().
Referenced by mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), and update_or_create_thumbnailer().
|
static |
Referenced by mate_desktop_thumbnail_factory_register_mime_types().
|
static |
References thumbnailer_load().
Referenced by update_or_create_thumbnailer().
|
static |
Referenced by mate_desktop_thumbnail_factory_can_thumbnail().
|
static |
References Thumbnailer.
Referenced by mate_desktop_thumbnail_factory_finalize(), mate_desktop_thumbnail_factory_init(), remove_thumbnailer(), remove_thumbnailers_for_dir(), and thumbnailer_load().
|
static |
References mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), remove_thumbnailer(), remove_thumbnailers_for_dir(), THUMBNAILER_EXTENSION, and update_or_create_thumbnailer().
Referenced by mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), and remove_thumbnailers_for_dir().
|
static |
References _MateDesktopThumbnailFactoryPrivate::lock, mate_desktop_thumbnail_factory_add_thumbnailer(), mate_desktop_thumbnail_factory_register_mime_types(), _MateDesktopThumbnailFactoryPrivate::mime_types_map, _MateDesktopThumbnailFactory::priv, remove_thumbnailer_from_mime_type_map(), Thumbnailer, thumbnailer_new(), thumbnailer_reload(), and _MateDesktopThumbnailFactoryPrivate::thumbnailers.
Referenced by thumbnailers_directory_changed().
|
static |
References mate_desktop_thumbnail_is_valid().
Referenced by lookup_failed_thumbnail_path(), and lookup_thumbnail_path().
|
static |
Referenced by thumbnail_failed_path().
| Thumbnailer |
Referenced by mate_desktop_thumbnail_factory_can_thumbnail(), mate_desktop_thumbnail_factory_generate_thumbnail(), mate_desktop_thumbnail_factory_load_thumbnailers_for_dir(), remove_thumbnailer(), remove_thumbnailers_for_dir(), thumbnailer_new(), thumbnailer_unref(), and update_or_create_thumbnailer().